From a236d54afb94b41b232eb3f42c71dd1abec762d4 Mon Sep 17 00:00:00 2001 From: MarcoMandar Date: Sun, 27 Oct 2024 02:47:12 +0300 Subject: [PATCH] pumpfun action Signed-off-by: MarcoMandar --- package-lock.json | 362 ++++++++++++++++++++++++++++++++++++++++- package.json | 1 + src/actions/pumpfun.ts | 295 +++++++++++++++++++++++++++++++++ 3 files changed, 653 insertions(+), 5 deletions(-) create mode 100644 src/actions/pumpfun.ts diff --git a/package-lock.json b/package-lock.json index 1bee6efaca2..9f49b599810 100644 --- a/package-lock.json +++ b/package-lock.json @@ -74,6 +74,7 @@ "playwright": "^1.46.1", "pm2": "^5.4.2", "prism-media": "^1.3.5", + "pumpdotfun-sdk": "^1.3.2", "puppeteer-extra": "^3.3.6", "puppeteer-extra-plugin-capsolver": "^2.0.1", "sql.js": "^1.10.2", @@ -900,6 +901,96 @@ "node": ">=16.7.0" } }, + "node_modules/@coral-xyz/anchor": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/anchor/-/anchor-0.30.1.tgz", + "integrity": "sha512-gDXFoF5oHgpriXAaLpxyWBHdCs8Awgf/gLHIo6crv7Aqm937CNdY+x+6hoj7QR5vaJV7MxWSQ0NGFzL3kPbWEQ==", + "license": "(MIT OR Apache-2.0)", + "dependencies": { + "@coral-xyz/anchor-errors": "^0.30.1", + "@coral-xyz/borsh": "^0.30.1", + "@noble/hashes": "^1.3.1", + "@solana/web3.js": "^1.68.0", + "bn.js": "^5.1.2", + "bs58": "^4.0.1", + "buffer-layout": "^1.2.2", + "camelcase": "^6.3.0", + "cross-fetch": "^3.1.5", + "crypto-hash": "^1.3.0", + "eventemitter3": "^4.0.7", + "pako": "^2.0.3", + "snake-case": "^3.0.4", + "superstruct": "^0.15.4", + "toml": "^3.0.0" + }, + "engines": { + "node": ">=11" + } + }, + "node_modules/@coral-xyz/anchor-errors": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/anchor-errors/-/anchor-errors-0.30.1.tgz", + "integrity": "sha512-9Mkradf5yS5xiLWrl9WrpjqOrAV+/W2RQHDlbnAZBivoGpOs1ECjoDCkVk4aRG8ZdiFiB8zQEVlxf+8fKkmSfQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=10" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/cross-fetch": { + "version": "3.1.8", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.8.tgz", + "integrity": "sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==", + "license": "MIT", + "dependencies": { + "node-fetch": "^2.6.12" + } + }, + "node_modules/@coral-xyz/anchor/node_modules/eventemitter3": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz", + "integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==", + "license": "MIT" + }, + "node_modules/@coral-xyz/anchor/node_modules/pako": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.1.0.tgz", + "integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==", + "license": "(MIT AND Zlib)" + }, + "node_modules/@coral-xyz/anchor/node_modules/superstruct": { + "version": "0.15.5", + "resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.15.5.tgz", + "integrity": "sha512-4AOeU+P5UuE/4nOUkmcQdW5y7i9ndt1cQd/3iUe+LTz3RxESf/W/5lg4B74HbDMMv8PHnPnGCQFH45kBcrQYoQ==", + "license": "MIT" + }, + "node_modules/@coral-xyz/borsh": { + "version": "0.30.1", + "resolved": "https://registry.npmjs.org/@coral-xyz/borsh/-/borsh-0.30.1.tgz", + "integrity": "sha512-aaxswpPrCFKl8vZTbxLssA2RvwX2zmKLlRCIktJOwW+VpVwYtXRtlWiIP+c2pPRKneiTiWCN2GEMSH9j1zTlWQ==", + "license": "Apache-2.0", + "dependencies": { + "bn.js": "^5.1.2", + "buffer-layout": "^1.2.0" + }, + "engines": { + "node": ">=10" + }, + "peerDependencies": { + "@solana/web3.js": "^1.68.0" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -3456,7 +3547,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.1.0" @@ -3552,7 +3642,6 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.0.tgz", "integrity": "sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "^1.0.0", @@ -3881,6 +3970,42 @@ "ieee754": "^1.2.1" } }, + "node_modules/@solana/spl-type-length-value": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/@solana/spl-type-length-value/-/spl-type-length-value-0.1.0.tgz", + "integrity": "sha512-JBMGB0oR4lPttOZ5XiUGyvylwLQjt1CPJa6qQ5oM+MBCndfjz2TKKkw0eATlLLcYmq1jBVsNlJ2cD6ns2GR7lA==", + "license": "Apache-2.0", + "dependencies": { + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/@solana/spl-type-length-value/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, "node_modules/@solana/web3.js": { "version": "1.95.4", "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.95.4.tgz", @@ -4183,7 +4308,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true, "license": "MIT" }, "node_modules/@types/express": { @@ -5784,6 +5908,15 @@ "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", "license": "MIT" }, + "node_modules/buffer-layout": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/buffer-layout/-/buffer-layout-1.2.2.tgz", + "integrity": "sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==", + "license": "MIT", + "engines": { + "node": ">=4.5" + } + }, "node_modules/bufferutil": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.8.tgz", @@ -6735,6 +6868,18 @@ "node": ">= 8" } }, + "node_modules/crypto-hash": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", + "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==", + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/csv-writer": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/csv-writer/-/csv-writer-1.6.0.tgz", @@ -7255,6 +7400,16 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "license": "MIT", + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/dotenv": { "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", @@ -7957,7 +8112,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true, "license": "MIT" }, "node_modules/esutils": { @@ -12637,6 +12791,15 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "license": "MIT", + "dependencies": { + "tslib": "^2.0.3" + } + }, "node_modules/lru-cache": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", @@ -13279,6 +13442,16 @@ "dev": true, "license": "MIT" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "license": "MIT", + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, "node_modules/node-abi": { "version": "3.67.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.67.0.tgz", @@ -15376,6 +15549,169 @@ "once": "^1.3.1" } }, + "node_modules/pumpdotfun-sdk": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/pumpdotfun-sdk/-/pumpdotfun-sdk-1.3.2.tgz", + "integrity": "sha512-TkYY+ZztxyPzv1f38evgdam92Po3YATI8s6BzmvxH8FypBpPs3pBKS301z7k3KXc1WWfjGWG79K/BANWaAcvkQ==", + "license": "ISC", + "dependencies": { + "@coral-xyz/anchor": "^0.30.1", + "@rollup/plugin-json": "^6.1.0", + "@solana/spl-token": "0.4.6", + "@solana/web3.js": "^1.92.1" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs/-/codecs-2.0.0-preview.2.tgz", + "integrity": "sha512-4HHzCD5+pOSmSB71X6w9ptweV48Zj1Vqhe732+pcAQ2cMNnN0gMPMdDq7j3YwaZDZ7yrILVV/3+HTnfT77t2yA==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-data-structures": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/codecs-strings": "2.0.0-preview.2", + "@solana/options": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-core": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-core/-/codecs-core-2.0.0-preview.2.tgz", + "integrity": "sha512-gLhCJXieSCrAU7acUJjbXl+IbGnqovvxQLlimztPoGgfLQ1wFYu+XJswrEVQqknZYK1pgxpxH3rZ+OKFs0ndQg==", + "license": "MIT", + "dependencies": { + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-data-structures": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.2.tgz", + "integrity": "sha512-Xf5vIfromOZo94Q8HbR04TbgTwzigqrKII0GjYr21K7rb3nba4hUW2ir8kguY7HWFBcjHGlU5x3MevKBOLp3Zg==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-numbers": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.2.tgz", + "integrity": "sha512-aLZnDTf43z4qOnpTcDsUVy1Ci9im1Md8thWipSWbE+WM9ojZAx528oAql+Cv8M8N+6ALKwgVRhPZkto6E59ARw==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/codecs-strings": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.2.tgz", + "integrity": "sha512-EgBwY+lIaHHgMJIqVOGHfIfpdmmUDNoNO/GAUGeFPf+q0dF+DtwhJPEMShhzh64X2MeCZcmSO6Kinx0Bvmmz2g==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2", + "@solana/errors": "2.0.0-preview.2" + }, + "peerDependencies": { + "fastestsmallesttextencoderdecoder": "^1.0.22" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/errors": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/errors/-/errors-2.0.0-preview.2.tgz", + "integrity": "sha512-H2DZ1l3iYF5Rp5pPbJpmmtCauWeQXRJapkDg8epQ8BJ7cA2Ut/QEtC3CMmw/iMTcuS6uemFNLcWvlOfoQhvQuA==", + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "commander": "^12.0.0" + }, + "bin": { + "errors": "bin/cli.js" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/options": { + "version": "2.0.0-preview.2", + "resolved": "https://registry.npmjs.org/@solana/options/-/options-2.0.0-preview.2.tgz", + "integrity": "sha512-FAHqEeH0cVsUOTzjl5OfUBw2cyT8d5Oekx4xcn5hn+NyPAfQJgM3CEThzgRD6Q/4mM5pVUnND3oK/Mt1RzSE/w==", + "license": "MIT", + "dependencies": { + "@solana/codecs-core": "2.0.0-preview.2", + "@solana/codecs-numbers": "2.0.0-preview.2" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/spl-token": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/@solana/spl-token/-/spl-token-0.4.6.tgz", + "integrity": "sha512-1nCnUqfHVtdguFciVWaY/RKcQz1IF4b31jnKgAmjU9QVN1q7dRUkTEWJZgTYIEtsULjVnC9jRqlhgGN39WbKKA==", + "license": "Apache-2.0", + "dependencies": { + "@solana/buffer-layout": "^4.0.0", + "@solana/buffer-layout-utils": "^0.2.0", + "@solana/spl-token-group": "^0.0.4", + "@solana/spl-token-metadata": "^0.1.4", + "buffer": "^6.0.3" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.91.6" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/@solana/spl-token-group": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@solana/spl-token-group/-/spl-token-group-0.0.4.tgz", + "integrity": "sha512-7+80nrEMdUKlK37V6kOe024+T7J4nNss0F8LQ9OOPYdWCCfJmsGUzVx2W3oeizZR4IHM6N4yC9v1Xqwc3BTPWw==", + "license": "Apache-2.0", + "dependencies": { + "@solana/codecs": "2.0.0-preview.2", + "@solana/spl-type-length-value": "0.1.0" + }, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "@solana/web3.js": "^1.91.6" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/pumpdotfun-sdk/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, "node_modules/punycode": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", @@ -16103,7 +16439,7 @@ "version": "2.79.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.79.1.tgz", "integrity": "sha512-uKxbd0IhMZOhjAiD5oAFp7BqvkA4Dv47qpOCtaNvng4HBwdbWtdOh8f5nZNuk2rp51PMGk3bzfWu5oayNEuYnw==", - "dev": true, + "devOptional": true, "license": "MIT", "bin": { "rollup": "dist/bin/rollup" @@ -16940,6 +17276,16 @@ "npm": ">= 3.0.0" } }, + "node_modules/snake-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/snake-case/-/snake-case-3.0.4.tgz", + "integrity": "sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==", + "license": "MIT", + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, "node_modules/socks": { "version": "2.8.3", "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.3.tgz", @@ -17980,6 +18326,12 @@ "node": ">=0.6" } }, + "node_modules/toml": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz", + "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==", + "license": "MIT" + }, "node_modules/touch": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/touch/-/touch-3.1.1.tgz", diff --git a/package.json b/package.json index ca8cc2a4024..27afd327842 100644 --- a/package.json +++ b/package.json @@ -130,6 +130,7 @@ "playwright": "^1.46.1", "pm2": "^5.4.2", "prism-media": "^1.3.5", + "pumpdotfun-sdk": "^1.3.2", "puppeteer-extra": "^3.3.6", "puppeteer-extra-plugin-capsolver": "^2.0.1", "sql.js": "^1.10.2", diff --git a/src/actions/pumpfun.ts b/src/actions/pumpfun.ts new file mode 100644 index 00000000000..0c69577ad8d --- /dev/null +++ b/src/actions/pumpfun.ts @@ -0,0 +1,295 @@ +import { + Connection, + Keypair, + PublicKey, + LAMPORTS_PER_SOL, +} from "@solana/web3.js"; +import { + DEFAULT_DECIMALS, + PumpFunSDK, + CreateTokenMetadata, + PriorityFee, +} from "pumpdotfun-sdk"; +import { AnchorProvider } from "@coral-xyz/anchor"; +import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; + +import settings from "../core/settings"; +import { getAssociatedTokenAddressSync } from "@solana/spl-token"; + +import { + ActionExample, + IAgentRuntime, + Memory, + Content, + type Action, +} from "../core/types.ts"; + +export interface CreateAndBuyContent extends Content { + deployerPrivateKey: string; + tokenMetadata: CreateTokenMetadata; + buyAmountSol: string | number; + priorityFee: { + unitLimit: number; + unitPrice: number; + }; + allowOffCurve: boolean; +} + +export function isCreateAndBuyContent( + content: any +): content is CreateAndBuyContent { + return ( + (typeof content.deployerPrivateKey === "string" && + typeof content.tokenMetadata === "object" && + typeof content.buyAmountSol === "string") || + (typeof content.buyAmountSol === "number" && + typeof content.priorityFee === "number" && + typeof content.allowOffCurve === "boolean") + ); +} + +const privateKey = settings.WALLET_PRIVATE_KEY!; +const wallet = new NodeWallet( + Keypair.fromSecretKey(new Uint8Array(JSON.parse(privateKey))) +); +const connection = new Connection(settings.RPC_URL!); +const provider = new AnchorProvider(connection, wallet, { + commitment: "finalized", +}); +const sdk = new PumpFunSDK(provider); +const slippage = settings.SLIPPAGE!; + +export const createAndBuyToken = async ({ + deployer, + mint, + tokenMetadata, + buyAmountSol, + priorityFee, + allowOffCurve, + commitment = "finalized", +}: { + deployer: Keypair; + mint: Keypair; + tokenMetadata: CreateTokenMetadata; + buyAmountSol: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; + commitment?: + | "processed" + | "confirmed" + | "finalized" + | "recent" + | "single" + | "singleGossip" + | "root" + | "max"; +}) => { + const createResults = await sdk.createAndBuy( + deployer, + mint, + tokenMetadata, + buyAmountSol, + BigInt(slippage), + priorityFee, + commitment + ); + if (createResults.success) { + console.log("Success:", `https://pump.fun/${mint.publicKey.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint.publicKey, + deployer.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${deployer.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${deployer.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Create and Buy failed"); + } +}; + +export const buyToken = async ({ + sdk, + buyer, + mint, + amount, + priorityFee, + allowOffCurve, +}: { + sdk: PumpFunSDK; + buyer: Keypair; + mint: PublicKey; + amount: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; +}) => { + const buyResults = await sdk.buy( + buyer, + mint, + amount, + BigInt(slippage), + priorityFee + ); + if (buyResults.success) { + console.log("Success:", `https://pump.fun/${mint.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint, + buyer.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${buyer.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${buyer.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Buy failed"); + } +}; + +export const sellToken = async ({ + sdk, + seller, + mint, + amount, + priorityFee, + allowOffCurve, +}: { + sdk: PumpFunSDK; + seller: Keypair; + mint: PublicKey; + amount: bigint; + priorityFee: PriorityFee; + allowOffCurve: boolean; +}) => { + const sellResults = await sdk.sell( + seller, + mint, + amount, + BigInt(slippage), + priorityFee + ); + if (sellResults.success) { + console.log("Success:", `https://pump.fun/${mint.toBase58()}`); + let ata = getAssociatedTokenAddressSync( + mint, + seller.publicKey, + allowOffCurve + ); + const balance = await connection.getTokenAccountBalance(ata, "processed"); + const amount = balance.value.uiAmount; + if (amount === null) { + console.log(`${seller.publicKey.toBase58()}:`, "No Account Found"); + } else { + console.log(`${seller.publicKey.toBase58()}:`, amount); + } + } else { + console.log("Sell failed"); + } +}; + +const promptConfirmation = async (): Promise => { + if (typeof window !== "undefined" && typeof window.confirm === "function") { + return window.confirm("Confirm the creation and purchase of the token?"); + } + return true; +}; + +export default { + name: "CREATE_AND_BUY_TOKEN", + similes: ["CREATE_AND_PURCHASE_TOKEN", "DEPLOY_AND_BUY_TOKEN"], + validate: async (runtime: IAgentRuntime, message: Memory) => { + return isCreateAndBuyContent(message.content); + }, + description: + "Create a new token and buy a specified amount using SOL. Requires deployer private key, token metadata, buy amount in SOL, priority fee, and allowOffCurve flag.", + handler: async ( + runtime: IAgentRuntime, + message: Memory + ): Promise => { + const content = message.content; + if (!isCreateAndBuyContent(content)) { + console.error("Invalid content for CREATE_AND_BUY_TOKEN action."); + return false; + } + const { + deployerPrivateKey, + tokenMetadata, + buyAmountSol, + priorityFee, + allowOffCurve, + } = content; + + try { + const deployerKeypair = Keypair.fromSecretKey( + Uint8Array.from(Buffer.from(deployerPrivateKey, "base64")) + ); + + const mintKeypair = Keypair.generate(); + + const createAndBuyConfirmation = await promptConfirmation(); + if (!createAndBuyConfirmation) { + console.log("Create and buy token canceled by user"); + return false; + } + + // Execute Create and Buy + await createAndBuyToken({ + deployer: deployerKeypair, + mint: mintKeypair, + tokenMetadata: tokenMetadata as CreateTokenMetadata, + buyAmountSol: BigInt(buyAmountSol), + priorityFee: priorityFee as PriorityFee, + allowOffCurve: allowOffCurve as boolean, + }); + + console.log( + `Token created and purchased successfully! View at: https://pump.fun/${mintKeypair.publicKey.toBase58()}` + ); + return true; + } catch (error) { + console.error("Error during create and buy token:", error); + return false; + } + }, + + examples: [ + [ + { + user: "{{user1}}", + content: { + deployerPrivateKey: "Base64EncodedPrivateKey", + tokenMetadata: { + name: "MyToken", + symbol: "MTK", + description: "My first token", + file: "Base64EncodedFile", // blob file of the image + decimals: DEFAULT_DECIMALS, + }, + buyAmountSol: "1000000000", // 1 SOL in lamports + priorityFee: 1000, + allowOffCurve: false, + }, + }, + { + user: "{{user2}}", + content: { + text: "Creating and buying 1 SOL worth of MyToken...", + action: "CREATE_AND_BUY_TOKEN", + }, + }, + { + user: "{{user2}}", + content: { + text: "Token created and purchased successfully! View at: https://pump.fun/MintPublicKey", + }, + }, + ], + ] as ActionExample[][], +} as Action;