diff --git a/package-lock.json b/package-lock.json index 0e274091..9bc744d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,6 +24,7 @@ "@project-serum/serum": "^0.13.65", "@raydium-io/raydium-sdk": "^1.3.1-beta.47", "@raydium-io/raydium-sdk-v2": "^0.1.23-alpha", + "@shyft-to/solana-transaction-parser": "^1.1.17", "@solana/spl-token": "^0.4.0", "@solana/web3.js": "^1.89.1", "@triton-one/yellowstone-grpc": "^0.4.0", @@ -47,6 +48,7 @@ "rpc-websockets": "7.10.0" }, "devDependencies": { + "@types/bn.js": "^5.2.0", "typescript": "^5.5.4" }, "engines": { @@ -4218,6 +4220,100 @@ ], "license": "MIT" }, + "node_modules/@shyft-to/solana-transaction-parser": { + "version": "1.1.20", + "resolved": "https://registry.npmjs.org/@shyft-to/solana-transaction-parser/-/solana-transaction-parser-1.1.20.tgz", + "integrity": "sha512-J8HJja0oDYfu0ziZkRYiWia8GcOI4AZVN5ZA+ERaP0wGFpTH7Vrzf5OryV/3/ejlZ92ND5HP+XBHAmO6PI1egA==", + "license": "LGPL-2.1", + "dependencies": { + "@project-serum/anchor": "^0.26.0", + "@solana/codecs": "2.0.0-preview.2", + "@solana/spl-token": "^0.4.6", + "@solana/spl-type-length-value": "0.1.0", + "@solana/web3.js": "^1.91.8", + "buffer": "6.0.3" + } + }, + "node_modules/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@shyft-to/solana-transaction-parser/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/@sindresorhus/merge-streams": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz", @@ -4717,6 +4813,16 @@ "integrity": "sha512-e2cOW9YlVzFY2iScnGBBkplKsrn2CsObHQ2Hiw4V1sSyiGbgWL8IyqE3zFi1Pt5o1pdAtYkDAIsF3KKUPjdzaA==", "license": "MIT" }, + "node_modules/@types/bn.js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.2.0.tgz", + "integrity": "sha512-DLbJ1BPqxvQhIGbeu8VbUC1DiAiahHtAYvA0ZEAa4P31F7IaArc8z3C3BRQdWX4mtLQuABG4yzp76ZrS02Ui1Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/bs58": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/bs58/-/bs58-4.0.4.tgz", diff --git a/package.json b/package.json index eefc6fb8..d8e04789 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,11 @@ "@bloxroute/solana-trader-client-ts": "^2.1.6", "@coral-xyz/anchor": "^0.28.1-beta.2", "@mercurial-finance/dynamic-amm-sdk": "^1.0.3", + "@metaplex-foundation/js": "^0.20.1", + "@metaplex-foundation/mpl-candy-machine": "^6.0.1", + "@metaplex-foundation/mpl-token-metadata": "^3.2.1", + "@metaplex-foundation/umi": "^0.9.1", + "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", "@meteora-ag/dlmm": "^1.0.54", "@orca-so/common-sdk": "^0.6.0-alpha.3", "@orca-so/whirlpools-sdk": "^0.11.8", @@ -22,14 +27,13 @@ "@project-serum/serum": "^0.13.65", "@raydium-io/raydium-sdk": "^1.3.1-beta.47", "@raydium-io/raydium-sdk-v2": "^0.1.23-alpha", - "@metaplex-foundation/js": "^0.20.1", - "@metaplex-foundation/mpl-candy-machine": "^6.0.1", - "@metaplex-foundation/mpl-token-metadata": "^3.2.1", - "@metaplex-foundation/umi": "^0.9.1", - "@metaplex-foundation/umi-bundle-defaults": "^0.9.1", + "@shyft-to/solana-transaction-parser": "^1.1.17", "@solana/spl-token": "^0.4.0", "@solana/web3.js": "^1.89.1", + "@triton-one/yellowstone-grpc": "^0.4.0", + "async-mutex": "^0.5.0", "axios": "^1.6.8", + "bigint-buffer": "^1.1.5", "bip39": "^3.1.0", "bn.js": "^5.2.1", "bs58": "^5.0.0", @@ -37,18 +41,14 @@ "decimal.js": "^10.4.3", "dotenv": "^16.4.5", "i": "^0.3.7", + "jito-ts": "^4.0.0", "npm": "^10.5.2", "pino": "^8.18.0", "pino-pretty": "^10.3.1", "pino-std-serializers": "^6.2.2", "pumpdotfun-sdk": "^1.3.2", "random-js": "^2.1.0", - "rpc-websockets": "7.10.0", - "@triton-one/yellowstone-grpc": "^0.4.0", - "jito-ts": "^4.0.0", - "async-mutex": "^0.5.0", - "bigint-buffer": "^1.1.5", - "@shyft-to/solana-transaction-parser": "^1.1.17" + "rpc-websockets": "7.10.0" }, "overrides": { "@solana/web3.js": "^1.89.1", @@ -61,6 +61,7 @@ "bigint-buffer": "^1.1.5" }, "devDependencies": { + "@types/bn.js": "^5.2.0", "typescript": "^5.5.4" }, "engines": { diff --git a/src/grpc_streaming_dev/grpc-pf-sniper/src/jito/bundle.ts b/src/grpc_streaming_dev/grpc-pf-sniper/src/jito/bundle.ts index 3fdd55ee..96c81479 100644 --- a/src/grpc_streaming_dev/grpc-pf-sniper/src/jito/bundle.ts +++ b/src/grpc_streaming_dev/grpc-pf-sniper/src/jito/bundle.ts @@ -46,17 +46,21 @@ import { } - // Get Tip Accounts - - let tipAccounts: string[] = []; - (async () => { +// Get Tip Accounts + +let tipAccounts: string[] = []; +(async () => { try { - tipAccounts = await c.getTipAccounts(); - // console.log('Result:', tipAccounts); + const tipResult = await c.getTipAccounts(); + if ((tipResult as any).ok) { + tipAccounts = (tipResult as any).value as string[]; + } else { + logger.warn({ err: (tipResult as any).error }, 'Failed to fetch tip accounts'); + } } catch (error) { - console.error('Error:', error); + console.error('Error:', error); } - })(); +})(); diff --git a/src/grpc_streaming_dev/grpc-pf-sniper/src/pumpdotfun-sdk/src/pumpfun.ts b/src/grpc_streaming_dev/grpc-pf-sniper/src/pumpdotfun-sdk/src/pumpfun.ts index 2883cbd8..ac0f00d2 100644 --- a/src/grpc_streaming_dev/grpc-pf-sniper/src/pumpdotfun-sdk/src/pumpfun.ts +++ b/src/grpc_streaming_dev/grpc-pf-sniper/src/pumpdotfun-sdk/src/pumpfun.ts @@ -53,10 +53,10 @@ export const METADATA_SEED = "metadata"; export const DEFAULT_DECIMALS = 6; export class PumpFunSDK { - public program: Program; + public program: Program; public connection: Connection; constructor(provider?: Provider) { - this.program = new Program(IDL as PumpFun, provider); + this.program = new Program(IDL as any, new PublicKey(PROGRAM_ID), provider); this.connection = this.program.provider.connection; } @@ -188,7 +188,7 @@ export class PumpFunSDK { ); return this.program.methods - .create(name, symbol, uri) + .create(name, symbol, uri, creator) .accounts({ mint: mint.publicKey, associatedBondingCurve: associatedBondingCurve, diff --git a/src/grpc_streaming_dev/grpc-pf-sniper/src/transaction/transaction.ts b/src/grpc_streaming_dev/grpc-pf-sniper/src/transaction/transaction.ts index e6cfad6b..2542e9d5 100644 --- a/src/grpc_streaming_dev/grpc-pf-sniper/src/transaction/transaction.ts +++ b/src/grpc_streaming_dev/grpc-pf-sniper/src/transaction/transaction.ts @@ -51,7 +51,7 @@ import { AnchorProvider } from "@coral-xyz/anchor"; import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet"; import { printSPLBalance } from "../pumpdotfun-sdk/example/util"; let wallet: Keypair; -let dev_wallet: Keypair; +let dev_wallet: Keypair | undefined; let quoteAmount: TokenAmount; quoteAmount = new TokenAmount(Token.WSOL, QUOTE_AMOUNT, false); export const solanaConnection = new Connection(RPC_ENDPOINT, { @@ -167,12 +167,14 @@ export async function sell( if (isJito) { sendBundle(latestBlockhash.blockhash, transaction, mintPublicKey, wallet); // with jito await new Promise((r) => setTimeout(r, 1000)); - sendBundle( - latestBlockhash.blockhash, - transaction, - mintPublicKey, - dev_wallet - ); // with jito + if (dev_wallet) { + sendBundle( + latestBlockhash.blockhash, + transaction, + mintPublicKey, + dev_wallet + ); // with jito + } } else simple_executeAndConfirm(transaction); // without jito } @@ -249,6 +251,9 @@ export async function createAndBuy( tokenMetadata: any, initialBuySolAmount: number ) { + if (!dev_wallet) { + throw new Error('dev_wallet is not configured'); + } const Wallet = new NodeWallet(dev_wallet); const provider = new AnchorProvider(solanaConnection, Wallet, { commitment: "processed", diff --git a/src/grpc_streaming_dev/grpc-raydium-sniper/src/jito/bundle.ts b/src/grpc_streaming_dev/grpc-raydium-sniper/src/jito/bundle.ts index bc21302a..588bba0c 100755 --- a/src/grpc_streaming_dev/grpc-raydium-sniper/src/jito/bundle.ts +++ b/src/grpc_streaming_dev/grpc-raydium-sniper/src/jito/bundle.ts @@ -70,12 +70,17 @@ return client; let tipAccounts: string[] = []; (async () => { -try { - tipAccounts = await c.getTipAccounts(); - console.log('Result:', tipAccounts); -} catch (error) { + try { + const tipResult: any = await c.getTipAccounts(); + if (tipResult && tipResult.ok) { + tipAccounts = tipResult.value as string[]; + console.log('Result:', tipAccounts); + } else { + console.warn('Failed to fetch tip accounts', tipResult?.error); + } + } catch (error) { console.error('Error:', error); -} + } })(); diff --git a/src/meteora/token-filters/pool-sol.ts b/src/meteora/token-filters/pool-sol.ts index 3f5c7a51..c03bed62 100644 --- a/src/meteora/token-filters/pool-sol.ts +++ b/src/meteora/token-filters/pool-sol.ts @@ -4,9 +4,11 @@ export async function getCurrentSolInPool(token_address:string):Promise { const dlmmPool = await fetchDLMMPool(token_address); let solReserve:number; if(dlmmPool.tokenX.publicKey.toBase58() === wsol){ - solReserve = Number(dlmmPool.tokenX.amount)/Math.pow(10,dlmmPool.tokenX.decimal); + const decimalsX = (dlmmPool.tokenX as any).decimals ?? (dlmmPool.tokenX as any).decimal; + solReserve = Number(dlmmPool.tokenX.amount)/Math.pow(10,decimalsX); }else{ - solReserve = Number(dlmmPool.tokenY.amount)/Math.pow(10,dlmmPool.tokenY.decimal); + const decimalsY = (dlmmPool.tokenY as any).decimals ?? (dlmmPool.tokenY as any).decimal; + solReserve = Number(dlmmPool.tokenY.amount)/Math.pow(10,decimalsY); } console.log(solReserve); return solReserve; diff --git a/src/pumpfunsdk/pumpdotfun-sdk/example/basic/index.ts b/src/pumpfunsdk/pumpdotfun-sdk/example/basic/index.ts index 5e347de8..106fdaa9 100644 --- a/src/pumpfunsdk/pumpdotfun-sdk/example/basic/index.ts +++ b/src/pumpfunsdk/pumpdotfun-sdk/example/basic/index.ts @@ -11,7 +11,7 @@ import { printSPLBalance, } from "../util"; -const KEYS_FOLDER = __dirname + "/.keys";s +const KEYS_FOLDER = __dirname + "/.keys"; const SLIPPAGE_BASIS_POINTS = 100n; //create token example: @@ -85,7 +85,7 @@ const main = async () => { }, ); - if (createResults.success) { + if ((createResults as any).success) { console.log("Success:", `https://pump.fun/${mint.publicKey.toBase58()}`); boundingCurveAccount = await sdk.getBondingCurveAccount(mint.publicKey); console.log("Bonding curve after create and buy", boundingCurveAccount); diff --git a/src/pumpfunsdk/pumpdotfun-sdk/example/events/index.ts b/src/pumpfunsdk/pumpdotfun-sdk/example/events/index.ts index cfd3bc75..0f332a31 100644 --- a/src/pumpfunsdk/pumpdotfun-sdk/example/events/index.ts +++ b/src/pumpfunsdk/pumpdotfun-sdk/example/events/index.ts @@ -25,17 +25,17 @@ const main = async () => { let sdk = new PumpFunSDK(provider); - let createEvent = sdk.addEventListener("createEvent", (event) => { + let createEvent = sdk.addEventListener("createEvent", (event: any) => { console.log("createEvent", event); }); console.log("createEvent", createEvent); - let tradeEvent = sdk.addEventListener("tradeEvent", (event) => { + let tradeEvent = sdk.addEventListener("tradeEvent", (event: any) => { console.log("tradeEvent", event); }); console.log("tradeEvent", tradeEvent); - let completeEvent = sdk.addEventListener("completeEvent", (event) => { + let completeEvent = sdk.addEventListener("completeEvent", (event: any) => { console.log("completeEvent", event); }); console.log("completeEvent", completeEvent); diff --git a/src/pumpfunsdk/pumpdotfun-sdk/src/pumpfun.ts b/src/pumpfunsdk/pumpdotfun-sdk/src/pumpfun.ts index b678db90..b3c68f4a 100644 --- a/src/pumpfunsdk/pumpdotfun-sdk/src/pumpfun.ts +++ b/src/pumpfunsdk/pumpdotfun-sdk/src/pumpfun.ts @@ -44,10 +44,10 @@ export const METADATA_SEED = "metadata"; export const DEFAULT_DECIMALS = 6; export class PumpFunSDK { - public program: Program; + public program: Program; public connection: Connection; constructor(provider?: Provider) { - this.program = new Program(IDL as PumpFun, provider); + this.program = new Program(IDL as any, new PublicKey(PROGRAM_ID), provider); this.connection = this.program.provider.connection; } async bundleBuys( diff --git a/tsconfig.json b/tsconfig.json index 2aaa2edc..897d98e9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -105,6 +105,7 @@ /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "skipLibCheck": true, /* Skip type checking all .d.ts files. */ + "typeRoots": ["./types", "./node_modules/@types"] } } \ No newline at end of file diff --git a/types/bnjs.d.ts b/types/bnjs.d.ts new file mode 100644 index 00000000..28be5949 --- /dev/null +++ b/types/bnjs.d.ts @@ -0,0 +1,5 @@ +declare module 'bn.js' { + export default class BN { + constructor(number: string | number | bigint | Buffer | number[], base?: number, endian?: 'le' | 'be'); + } +}