diff --git a/package.json b/package.json index 91273a0..cbe9a5d 100644 --- a/package.json +++ b/package.json @@ -40,24 +40,27 @@ "author": "Rick Porter, kalloc, Elijah Bare", "license": "MIT", "devDependencies": { + "@coral-xyz/anchor": "^0.31.0", "@rollup/plugin-commonjs": "^28.0.3", "@rollup/plugin-json": "^6.1.0", "@rollup/plugin-node-resolve": "^16.0.1", "@rollup/plugin-typescript": "^12.1.2", + "@solana/web3.js": "^1.98.0", "@tsconfig/node20": "^20.1.5", "@types/node": "^20.17.30", + "bs58": "^6.0.0", "dotenv": "^16.4.7", "js-sha256": "^0.11.0", "puppeteer": "^24.5.0", "rimraf": "^6.0.1", "rollup": "^4.38.0", + "ts-node": "^10.9.2", "tsx": "^4.19.3", "typescript": "^5.8.2" }, "dependencies": { - "@coral-xyz/anchor": "^0.31.0", "@coral-xyz/borsh": "^0.31.0", "@solana/spl-token": "0.4.13", - "@solana/web3.js": "^1.98.0" + "bn.js": "^5.2.2" } } diff --git a/src/IDL/pump-fun.json b/src/IDL/pump-fun.json index 12fe959..7f1fc8c 100644 --- a/src/IDL/pump-fun.json +++ b/src/IDL/pump-fun.json @@ -3,17 +3,28 @@ "metadata": { "name": "pump", "version": "0.1.0", - "spec": "0.1.0" + "spec": "0.1.0", + "description": "Created with Anchor" }, "instructions": [ { - "name": "initialize", - "discriminator": [175, 175, 109, 31, 13, 152, 155, 237], - "docs": ["Creates the global state."], + "name": "buy", + "docs": [ + "Buys tokens from a bonding curve." + ], + "discriminator": [ + 102, + 6, + 61, + 18, + 1, + 218, + 235, + 234 + ], "accounts": [ { "name": "global", - "writable": true, "pda": { "seeds": [ { @@ -31,41 +42,136 @@ } }, { - "name": "user", - "writable": true, - "signer": true + "name": "fee_recipient", + "writable": true }, { - "name": "system_program", - "address": "11111111111111111111111111111111" - } - ], - "args": [] - }, - { - "name": "setParams", - "discriminator": [165, 31, 134, 53, 189, 180, 130, 255], - "docs": ["Sets the global state parameters."], - "accounts": [ + "name": "mint" + }, { - "name": "global", + "name": "bonding_curve", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 103, - 108, - 111, 98, - 97, - 108 + 111, + 110, + 100, + 105, + 110, + 103, + 45, + 99, + 117, + 114, + 118, + 101 ] + }, + { + "kind": "account", + "path": "mint" } ] } }, + { + "name": "associated_bonding_curve", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "bonding_curve" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "associated_user", + "writable": true + }, { "name": "user", "writable": true, @@ -75,46 +181,190 @@ "name": "system_program", "address": "11111111111111111111111111111111" }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "creator_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 114, + 101, + 97, + 116, + 111, + 114, + 45, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bonding_curve.creator", + "account": "BondingCurve" + } + ] + } + }, { "name": "event_authority", - "address": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1" + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } }, { - "name": "program", - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" + "name": "program" } ], "args": [ { - "name": "feeRecipient", - "type": "pubkey" + "name": "amount", + "type": "u64" }, { - "name": "initialVirtualTokenReserves", + "name": "max_sol_cost", "type": "u64" + } + ] + }, + { + "name": "collect_creator_fee", + "docs": [ + "Collects creator_fee from creator_vault to the coin creator account" + ], + "discriminator": [ + 20, + 22, + 86, + 123, + 198, + 28, + 219, + 132 + ], + "accounts": [ + { + "name": "creator", + "writable": true, + "signer": true }, { - "name": "initialVirtualSolReserves", - "type": "u64" + "name": "creator_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 114, + 101, + 97, + 116, + 111, + 114, + 45, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "creator" + } + ] + } }, { - "name": "initialRealTokenReserves", - "type": "u64" + "name": "system_program", + "address": "11111111111111111111111111111111" }, { - "name": "tokenTotalSupply", - "type": "u64" + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } }, { - "name": "feeBasisPoints", - "type": "u64" + "name": "program" } - ] + ], + "args": [] }, { "name": "create", - "discriminator": [24, 30, 200, 40, 5, 28, 7, 119], - "docs": ["Creates a new coin and bonding curve."], + "docs": [ + "Creates a new coin and bonding curve." + ], + "discriminator": [ + 24, + 30, + 200, + 40, + 5, + 28, + 7, + 119 + ], "accounts": [ { "name": "mint", @@ -180,11 +430,95 @@ { "name": "associated_bonding_curve", "writable": true, - "signer": false + "pda": { + "seeds": [ + { + "kind": "account", + "path": "bonding_curve" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } }, { "name": "global", - "writable": false, "pda": { "seeds": [ { @@ -208,12 +542,73 @@ { "name": "metadata", "writable": true, - "signer": false + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "const", + "value": [ + 11, + 112, + 101, + 177, + 227, + 209, + 124, + 69, + 56, + 157, + 82, + 127, + 107, + 4, + 195, + 205, + 88, + 184, + 108, + 115, + 26, + 160, + 253, + 181, + 73, + 182, + 209, + 188, + 3, + 248, + 41, + 70 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "account", + "path": "mpl_token_metadata" + } + } }, { "name": "user", - "isMut": true, - "isSigner": true + "writable": true, + "signer": true }, { "name": "system_program", @@ -233,11 +628,35 @@ }, { "name": "event_authority", - "address": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1" + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } }, { - "name": "program", - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" + "name": "program" } ], "args": [ @@ -260,78 +679,103 @@ ] }, { - "name": "buy", - "discriminator": [102, 6, 61, 18, 1, 218, 235, 234], - "docs": ["Buys tokens from a bonding curve."], - "accounts": [ + "name": "extend_account", + "docs": [ + "Extends the size of program-owned accounts" + ], + "discriminator": [ + 234, + 102, + 194, + 203, + 150, + 72, + 62, + 229 + ], + "accounts": [ { - "name": "global", + "name": "account", + "writable": true + }, + { + "name": "user", + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "event_authority", "pda": { "seeds": [ { "kind": "const", "value": [ - 103, - 108, - 111, - 98, + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, 97, - 108 + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 ] } ] } }, { - "name": "fee_recipient", - "writable": true, - "signer": false - }, - { - "name": "mint", - "writable": false, - "signer": false - }, + "name": "program" + } + ], + "args": [] + }, + { + "name": "initialize", + "docs": [ + "Creates the global state." + ], + "discriminator": [ + 175, + 175, + 109, + 31, + 13, + 152, + 155, + 237 + ], + "accounts": [ { - "name": "bonding_curve", + "name": "global", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 98, - 111, - 110, - 100, - 105, - 110, 103, - 45, - 99, - 117, - 114, - 118, - 101 + 108, + 111, + 98, + 97, + 108 ] - }, - { - "kind": "account", - "path": "mint" } ] } }, - { - "name": "associated_bonding_curve", - "writable": true, - "signer": false - }, - { - "name": "associated_user", - "writable": true, - "signer": false - }, { "name": "user", "writable": true, @@ -340,43 +784,28 @@ { "name": "system_program", "address": "11111111111111111111111111111111" - }, - { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" - }, - { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" - }, - { - "name": "event_authority", - "address": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1" - }, - { - "name": "program", - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" } ], - "args": [ - { - "name": "amount", - "type": "u64" - }, - { - "name": "maxSolCost", - "type": "u64" - } - ] + "args": [] }, { - "name": "sell", - "discriminator": [51, 230, 133, 164, 1, 127, 131, 173], - "docs": ["Sells tokens into a bonding curve."], + "name": "migrate", + "docs": [ + "Migrates liquidity to pump_amm if the bonding curve is complete" + ], + "discriminator": [ + 155, + 234, + 231, + 146, + 236, + 158, + 162, + 30 + ], "accounts": [ { "name": "global", - "writable": false, "pda": { "seeds": [ { @@ -394,14 +823,14 @@ } }, { - "name": "feeRecipient", + "name": "withdraw_authority", "writable": true, - "signer": false + "relations": [ + "global" + ] }, { - "name": "mint", - "writable": false, - "signer": false + "name": "mint" }, { "name": "bonding_curve", @@ -434,109 +863,173 @@ } }, { - "name": "associatedBondingCurve", - "writable": true, - "signer": false - }, - { - "name": "associatedUser", + "name": "associated_bonding_curve", "writable": true, - "signer": false + "pda": { + "seeds": [ + { + "kind": "account", + "path": "bonding_curve" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } }, { "name": "user", - "writable": true, "signer": true }, { "name": "system_program", "address": "11111111111111111111111111111111" }, - { - "name": "associated_token_program", - "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" - }, { "name": "token_program", "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" }, { - "name": "event_authority", - "address": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1" - }, - { - "name": "program", - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" - } - ], - "args": [ - { - "name": "amount", - "type": "u64" + "name": "pump_amm", + "address": "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA" }, { - "name": "minSolOutput", - "type": "u64" - } - ] - }, - { - "name": "withdraw", - "discriminator": [183, 18, 70, 156, 148, 109, 161, 34], - "docs": [ - "Allows the admin to withdraw liquidity for a migration once the bonding curve completes" - ], - "accounts": [ - { - "name": "global", - "writable": false, + "name": "pool", + "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 103, - 108, + 112, + 111, 111, - 98, - 97, 108 ] + }, + { + "kind": "const", + "value": [ + 0, + 0 + ] + }, + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "account", + "path": "mint" + }, + { + "kind": "account", + "path": "wsol_mint" } - ] + ], + "program": { + "kind": "account", + "path": "pump_amm" + } } }, { - "name": "lastWithdraw", - "writable": true, - "signer": false - }, - { - "name": "mint", - "writable": false, - "signer": false - }, - { - "name": "bonding_curve", + "name": "pool_authority", "writable": true, "pda": { "seeds": [ { "kind": "const", "value": [ - 98, + 112, 111, - 110, - 100, - 105, - 110, - 103, + 111, + 108, 45, - 99, + 97, 117, + 116, + 104, + 111, 114, - 118, - 101 + 105, + 116, + 121 ] }, { @@ -547,39 +1040,1106 @@ } }, { - "name": "associatedBondingCurve", + "name": "pool_authority_mint_account", "writable": true, - "signer": false - }, - { - "name": "associatedUser", - "writable": true, - "signer": false + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "account", + "path": "associated_token_program" + } + } }, { - "name": "user", + "name": "pool_authority_wsol_account", "writable": true, - "signer": true - }, - { - "name": "system_program", - "address": "11111111111111111111111111111111" + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "wsol_mint" + } + ], + "program": { + "kind": "account", + "path": "associated_token_program" + } + } }, { - "name": "token_program", - "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + "name": "amm_global_config", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108, + 95, + 99, + 111, + 110, + 102, + 105, + 103 + ] + } + ], + "program": { + "kind": "account", + "path": "pump_amm" + } + } }, { - "name": "rent", - "address": "SysvarRent111111111111111111111111111111111" + "name": "wsol_mint", + "address": "So11111111111111111111111111111111111111112" + }, + { + "name": "lp_mint", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 112, + 111, + 111, + 108, + 95, + 108, + 112, + 95, + 109, + 105, + 110, + 116 + ] + }, + { + "kind": "account", + "path": "pool" + } + ], + "program": { + "kind": "account", + "path": "pump_amm" + } + } + }, + { + "name": "user_pool_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool_authority" + }, + { + "kind": "account", + "path": "token_2022_program" + }, + { + "kind": "account", + "path": "lp_mint" + } + ], + "program": { + "kind": "account", + "path": "associated_token_program" + } + } + }, + { + "name": "pool_base_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "account", + "path": "associated_token_program" + } + } + }, + { + "name": "pool_quote_token_account", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "pool" + }, + { + "kind": "account", + "path": "token_program" + }, + { + "kind": "account", + "path": "wsol_mint" + } + ], + "program": { + "kind": "account", + "path": "associated_token_program" + } + } + }, + { + "name": "token_2022_program", + "address": "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, + { + "name": "associated_token_program", + "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, + { + "name": "pump_amm_event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ], + "program": { + "kind": "account", + "path": "pump_amm" + } + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "sell", + "docs": [ + "Sells tokens into a bonding curve." + ], + "discriminator": [ + 51, + 230, + 133, + 164, + 1, + 127, + 131, + 173 + ], + "accounts": [ + { + "name": "global", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "fee_recipient", + "writable": true + }, + { + "name": "mint" + }, + { + "name": "bonding_curve", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 111, + 110, + 100, + 105, + 110, + 103, + 45, + 99, + 117, + 114, + 118, + 101 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "associated_bonding_curve", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "account", + "path": "bonding_curve" + }, + { + "kind": "const", + "value": [ + 6, + 221, + 246, + 225, + 215, + 101, + 161, + 147, + 217, + 203, + 225, + 70, + 206, + 235, + 121, + 172, + 28, + 180, + 133, + 237, + 95, + 91, + 55, + 145, + 58, + 140, + 245, + 133, + 126, + 255, + 0, + 169 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 140, + 151, + 37, + 143, + 78, + 36, + 137, + 241, + 187, + 61, + 16, + 41, + 20, + 142, + 13, + 131, + 11, + 90, + 19, + 153, + 218, + 255, + 16, + 132, + 4, + 142, + 123, + 216, + 219, + 233, + 248, + 89 + ] + } + } + }, + { + "name": "associated_user", + "writable": true + }, + { + "name": "user", + "writable": true, + "signer": true + }, + { + "name": "system_program", + "address": "11111111111111111111111111111111" + }, + { + "name": "creator_vault", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 99, + 114, + 101, + 97, + 116, + 111, + 114, + 45, + 118, + 97, + 117, + 108, + 116 + ] + }, + { + "kind": "account", + "path": "bonding_curve.creator", + "account": "BondingCurve" + } + ] + } + }, + { + "name": "token_program", + "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + }, + { + "name": "min_sol_output", + "type": "u64" + } + ] + }, + { + "name": "set_creator", + "docs": [ + "Allows Global::set_creator_authority to set the bonding curve creator from Metaplex metadata or input argument" + ], + "discriminator": [ + 254, + 148, + 255, + 112, + 207, + 142, + 170, + 165 + ], + "accounts": [ + { + "name": "set_creator_authority", + "signer": true, + "relations": [ + "global" + ] + }, + { + "name": "global", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "mint" + }, + { + "name": "metadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "const", + "value": [ + 11, + 112, + 101, + 177, + 227, + 209, + 124, + 69, + 56, + 157, + 82, + 127, + 107, + 4, + 195, + 205, + 88, + 184, + 108, + 115, + 26, + 160, + 253, + 181, + 73, + 182, + 209, + 188, + 3, + 248, + 41, + 70 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 11, + 112, + 101, + 177, + 227, + 209, + 124, + 69, + 56, + 157, + 82, + 127, + 107, + 4, + 195, + 205, + 88, + 184, + 108, + 115, + 26, + 160, + 253, + 181, + 73, + 182, + 209, + 188, + 3, + 248, + 41, + 70 + ] + } + } + }, + { + "name": "bonding_curve", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 111, + 110, + 100, + 105, + 110, + 103, + 45, + 99, + 117, + 114, + 118, + 101 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "creator", + "type": "pubkey" + } + ] + }, + { + "name": "set_metaplex_creator", + "docs": [ + "Syncs the bonding curve creator with the Metaplex metadata creator if it exists" + ], + "discriminator": [ + 138, + 96, + 174, + 217, + 48, + 85, + 197, + 246 + ], + "accounts": [ + { + "name": "mint" + }, + { + "name": "metadata", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 109, + 101, + 116, + 97, + 100, + 97, + 116, + 97 + ] + }, + { + "kind": "const", + "value": [ + 11, + 112, + 101, + 177, + 227, + 209, + 124, + 69, + 56, + 157, + 82, + 127, + 107, + 4, + 195, + 205, + 88, + 184, + 108, + 115, + 26, + 160, + 253, + 181, + 73, + 182, + 209, + 188, + 3, + 248, + 41, + 70 + ] + }, + { + "kind": "account", + "path": "mint" + } + ], + "program": { + "kind": "const", + "value": [ + 11, + 112, + 101, + 177, + 227, + 209, + 124, + 69, + 56, + 157, + 82, + 127, + 107, + 4, + 195, + 205, + 88, + 184, + 108, + 115, + 26, + 160, + 253, + 181, + 73, + 182, + 209, + 188, + 3, + 248, + 41, + 70 + ] + } + } + }, + { + "name": "bonding_curve", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 98, + 111, + 110, + 100, + 105, + 110, + 103, + 45, + 99, + 117, + 114, + 118, + 101 + ] + }, + { + "kind": "account", + "path": "mint" + } + ] + } + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [] + }, + { + "name": "set_params", + "docs": [ + "Sets the global state parameters." + ], + "discriminator": [ + 27, + 234, + 178, + 52, + 147, + 2, + 187, + 141 + ], + "accounts": [ + { + "name": "global", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "authority", + "writable": true, + "signer": true, + "relations": [ + "global" + ] + }, + { + "name": "event_authority", + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } + }, + { + "name": "program" + } + ], + "args": [ + { + "name": "initial_virtual_token_reserves", + "type": "u64" + }, + { + "name": "initial_virtual_sol_reserves", + "type": "u64" + }, + { + "name": "initial_real_token_reserves", + "type": "u64" + }, + { + "name": "token_total_supply", + "type": "u64" + }, + { + "name": "fee_basis_points", + "type": "u64" + }, + { + "name": "withdraw_authority", + "type": "pubkey" + }, + { + "name": "enable_migrate", + "type": "bool" + }, + { + "name": "pool_migration_fee", + "type": "u64" + }, + { + "name": "creator_fee_basis_points", + "type": "u64" + }, + { + "name": "set_creator_authority", + "type": "pubkey" + } + ] + }, + { + "name": "update_global_authority", + "discriminator": [ + 227, + 181, + 74, + 196, + 208, + 21, + 97, + 213 + ], + "accounts": [ + { + "name": "global", + "writable": true, + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 103, + 108, + 111, + 98, + 97, + 108 + ] + } + ] + } + }, + { + "name": "authority", + "signer": true, + "relations": [ + "global" + ] + }, + { + "name": "new_authority" }, { "name": "event_authority", - "address": "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1" + "pda": { + "seeds": [ + { + "kind": "const", + "value": [ + 95, + 95, + 101, + 118, + 101, + 110, + 116, + 95, + 97, + 117, + 116, + 104, + 111, + 114, + 105, + 116, + 121 + ] + } + ] + } }, { - "name": "program", - "address": "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P" + "name": "program" } ], "args": [] @@ -599,331 +2159,801 @@ 96 ] }, - { - "name": "Global", - "discriminator": [ - 167, - 232, - 232, - 177, - 200, - 108, - 114, - 127 - ] - } - ], - "events": [ + { + "name": "Global", + "discriminator": [ + 167, + 232, + 232, + 177, + 200, + 108, + 114, + 127 + ] + } + ], + "events": [ + { + "name": "CollectCreatorFeeEvent", + "discriminator": [ + 122, + 2, + 127, + 1, + 14, + 191, + 12, + 175 + ] + }, + { + "name": "CompleteEvent", + "discriminator": [ + 95, + 114, + 97, + 156, + 212, + 46, + 152, + 8 + ] + }, + { + "name": "CompletePumpAmmMigrationEvent", + "discriminator": [ + 189, + 233, + 93, + 185, + 92, + 148, + 234, + 148 + ] + }, + { + "name": "CreateEvent", + "discriminator": [ + 27, + 114, + 169, + 77, + 222, + 235, + 99, + 118 + ] + }, + { + "name": "ExtendAccountEvent", + "discriminator": [ + 97, + 97, + 215, + 144, + 93, + 146, + 22, + 124 + ] + }, + { + "name": "SetCreatorEvent", + "discriminator": [ + 237, + 52, + 123, + 37, + 245, + 251, + 72, + 210 + ] + }, + { + "name": "SetMetaplexCreatorEvent", + "discriminator": [ + 142, + 203, + 6, + 32, + 127, + 105, + 191, + 162 + ] + }, + { + "name": "SetParamsEvent", + "discriminator": [ + 223, + 195, + 159, + 246, + 62, + 48, + 143, + 131 + ] + }, + { + "name": "TradeEvent", + "discriminator": [ + 189, + 219, + 127, + 211, + 78, + 230, + 97, + 238 + ] + }, + { + "name": "UpdateGlobalAuthorityEvent", + "discriminator": [ + 182, + 195, + 137, + 42, + 35, + 206, + 207, + 247 + ] + } + ], + "errors": [ + { + "code": 6000, + "name": "NotAuthorized", + "msg": "The given account is not authorized to execute this instruction." + }, + { + "code": 6001, + "name": "AlreadyInitialized", + "msg": "The program is already initialized." + }, + { + "code": 6002, + "name": "TooMuchSolRequired", + "msg": "slippage: Too much SOL required to buy the given amount of tokens." + }, + { + "code": 6003, + "name": "TooLittleSolReceived", + "msg": "slippage: Too little SOL received to sell the given amount of tokens." + }, + { + "code": 6004, + "name": "MintDoesNotMatchBondingCurve", + "msg": "The mint does not match the bonding curve." + }, + { + "code": 6005, + "name": "BondingCurveComplete", + "msg": "The bonding curve has completed and liquidity migrated to raydium." + }, + { + "code": 6006, + "name": "BondingCurveNotComplete", + "msg": "The bonding curve has not completed." + }, + { + "code": 6007, + "name": "NotInitialized", + "msg": "The program is not initialized." + }, + { + "code": 6008, + "name": "WithdrawTooFrequent", + "msg": "Withdraw too frequent" + }, + { + "code": 6009, + "name": "NewSizeShouldBeGreaterThanCurrentSize", + "msg": "new_size should be > current_size" + }, + { + "code": 6010, + "name": "AccountTypeNotSupported", + "msg": "Account type not supported" + }, + { + "code": 6011, + "name": "InitialRealTokenReservesShouldBeLessThanTokenTotalSupply", + "msg": "initial_real_token_reserves should be less than token_total_supply" + }, + { + "code": 6012, + "name": "InitialVirtualTokenReservesShouldBeGreaterThanInitialRealTokenReserves", + "msg": "initial_virtual_token_reserves should be greater than initial_real_token_reserves" + }, + { + "code": 6013, + "name": "FeeBasisPointsGreaterThanMaximum", + "msg": "fee_basis_points greater than maximum" + }, + { + "code": 6014, + "name": "AllZerosWithdrawAuthority", + "msg": "Withdraw authority cannot be set to System Program ID" + }, + { + "code": 6015, + "name": "PoolMigrationFeeShouldBeLessThanFinalRealSolReserves", + "msg": "pool_migration_fee should be less than final_real_sol_reserves" + }, + { + "code": 6016, + "name": "PoolMigrationFeeShouldBeGreaterThanCreatorFeePlusMaxMigrateFees", + "msg": "pool_migration_fee should be greater than creator_fee + MAX_MIGRATE_FEES" + }, + { + "code": 6017, + "name": "DisabledWithdraw", + "msg": "Migrate instruction is disabled" + }, + { + "code": 6018, + "name": "DisabledMigrate", + "msg": "Migrate instruction is disabled" + }, + { + "code": 6019, + "name": "InvalidCreator", + "msg": "Invalid creator pubkey" + }, + { + "code": 6020, + "name": "BuyZeroAmount", + "msg": "Buy zero amount" + }, + { + "code": 6021, + "name": "NotEnoughTokensToBuy", + "msg": "Not enough tokens to buy" + }, + { + "code": 6022, + "name": "SellZeroAmount", + "msg": "Sell zero amount" + }, + { + "code": 6023, + "name": "NotEnoughTokensToSell", + "msg": "Not enough tokens to sell" + }, + { + "code": 6024, + "name": "Overflow", + "msg": "Overflow" + }, + { + "code": 6025, + "name": "Truncation", + "msg": "Truncation" + }, + { + "code": 6026, + "name": "DivisionByZero", + "msg": "Division by zero" + }, + { + "code": 6027, + "name": "NotEnoughRemainingAccounts", + "msg": "Not enough remaining accounts" + }, + { + "code": 6028, + "name": "AllFeeRecipientsShouldBeNonZero", + "msg": "All fee recipients should be non-zero" + }, + { + "code": 6029, + "name": "UnsortedNotUniqueFeeRecipients", + "msg": "Unsorted or not unique fee recipients" + }, + { + "code": 6030, + "name": "CreatorShouldNotBeZero", + "msg": "Creator should not be zero" + } + ], + "types": [ + { + "name": "BondingCurve", + "type": { + "kind": "struct", + "fields": [ + { + "name": "virtual_token_reserves", + "type": "u64" + }, + { + "name": "virtual_sol_reserves", + "type": "u64" + }, + { + "name": "real_token_reserves", + "type": "u64" + }, + { + "name": "real_sol_reserves", + "type": "u64" + }, + { + "name": "token_total_supply", + "type": "u64" + }, + { + "name": "complete", + "type": "bool" + }, + { + "name": "creator", + "type": "pubkey" + } + ] + } + }, + { + "name": "CollectCreatorFeeEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "creator_fee", + "type": "u64" + } + ] + } + }, + { + "name": "CompleteEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "bonding_curve", + "type": "pubkey" + }, + { + "name": "timestamp", + "type": "i64" + } + ] + } + }, + { + "name": "CompletePumpAmmMigrationEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "user", + "type": "pubkey" + }, + { + "name": "mint", + "type": "pubkey" + }, + { + "name": "mint_amount", + "type": "u64" + }, + { + "name": "sol_amount", + "type": "u64" + }, + { + "name": "pool_migration_fee", + "type": "u64" + }, + { + "name": "bonding_curve", + "type": "pubkey" + }, + { + "name": "timestamp", + "type": "i64" + }, + { + "name": "pool", + "type": "pubkey" + } + ] + } + }, { "name": "CreateEvent", - "discriminator": [27, 114, 169, 77, 222, 235, 99, 118] - }, - { - "name": "TradeEvent", - "discriminator": [189, 219, 127, 211, 78, 230, 97, 238] - }, - { - "name": "CompleteEvent", - "discriminator": [95, 114, 97, 156, 212, 46, 152, 8] - }, - { - "name": "SetParamsEvent", - "discriminator": [223, 195, 159, 246, 62, 48, 143, 131] - } - ], - "types": [ - { - "name": "Global", "type": { "kind": "struct", "fields": [ { - "name": "initialized", - "type": "bool" + "name": "name", + "type": "string" }, { - "name": "authority", + "name": "symbol", + "type": "string" + }, + { + "name": "uri", + "type": "string" + }, + { + "name": "mint", "type": "pubkey" }, { - "name": "feeRecipient", + "name": "bonding_curve", "type": "pubkey" }, { - "name": "initialVirtualTokenReserves", - "type": "u64" + "name": "user", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "timestamp", + "type": "i64" }, { - "name": "initialVirtualSolReserves", + "name": "virtual_token_reserves", "type": "u64" }, { - "name": "initialRealTokenReserves", + "name": "virtual_sol_reserves", "type": "u64" }, { - "name": "tokenTotalSupply", + "name": "real_token_reserves", "type": "u64" }, { - "name": "feeBasisPoints", + "name": "token_total_supply", "type": "u64" } ] } }, { - "name": "LastWithdraw", + "name": "ExtendAccountEvent", "type": { "kind": "struct", "fields": [ { - "name": "lastWithdrawTimestamp", + "name": "account", + "type": "pubkey" + }, + { + "name": "user", + "type": "pubkey" + }, + { + "name": "current_size", + "type": "u64" + }, + { + "name": "new_size", + "type": "u64" + }, + { + "name": "timestamp", "type": "i64" } ] } }, { - "name": "BondingCurve", + "name": "Global", "type": { "kind": "struct", "fields": [ { - "name": "virtualTokenReserves", + "name": "initialized", + "docs": [ + "Unused" + ], + "type": "bool" + }, + { + "name": "authority", + "type": "pubkey" + }, + { + "name": "fee_recipient", + "type": "pubkey" + }, + { + "name": "initial_virtual_token_reserves", "type": "u64" }, { - "name": "virtualSolReserves", + "name": "initial_virtual_sol_reserves", "type": "u64" }, { - "name": "realTokenReserves", + "name": "initial_real_token_reserves", "type": "u64" }, { - "name": "realSolReserves", + "name": "token_total_supply", "type": "u64" }, { - "name": "tokenTotalSupply", + "name": "fee_basis_points", "type": "u64" }, { - "name": "complete", + "name": "withdraw_authority", + "type": "pubkey" + }, + { + "name": "enable_migrate", + "docs": [ + "Unused" + ], "type": "bool" + }, + { + "name": "pool_migration_fee", + "type": "u64" + }, + { + "name": "creator_fee_basis_points", + "type": "u64" + }, + { + "name": "fee_recipients", + "type": { + "array": [ + "pubkey", + 7 + ] + } + }, + { + "name": "set_creator_authority", + "type": "pubkey" } ] } }, { - "name": "CreateEvent", + "name": "SetCreatorEvent", "type": { "kind": "struct", "fields": [ { - "name": "name", - "type": "string", - "index": false + "name": "timestamp", + "type": "i64" }, { - "name": "symbol", - "type": "string", - "index": false + "name": "mint", + "type": "pubkey" }, { - "name": "uri", - "type": "string", - "index": false + "name": "bonding_curve", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" + } + ] + } + }, + { + "name": "SetMetaplexCreatorEvent", + "type": { + "kind": "struct", + "fields": [ + { + "name": "timestamp", + "type": "i64" }, { "name": "mint", - "type": "pubkey", - "index": false + "type": "pubkey" }, { - "name": "bondingCurve", - "type": "pubkey", - "index": false + "name": "bonding_curve", + "type": "pubkey" }, { - "name": "user", - "type": "pubkey", - "index": false + "name": "metadata", + "type": "pubkey" + }, + { + "name": "creator", + "type": "pubkey" } ] } }, { - "name": "TradeEvent", + "name": "SetParamsEvent", "type": { "kind": "struct", "fields": [ { - "name": "mint", - "type": "pubkey", - "index": false + "name": "initial_virtual_token_reserves", + "type": "u64" }, { - "name": "solAmount", - "type": "u64", - "index": false + "name": "initial_virtual_sol_reserves", + "type": "u64" }, { - "name": "tokenAmount", - "type": "u64", - "index": false + "name": "initial_real_token_reserves", + "type": "u64" }, { - "name": "isBuy", - "type": "bool", - "index": false + "name": "final_real_sol_reserves", + "type": "u64" }, { - "name": "user", - "type": "pubkey", - "index": false + "name": "token_total_supply", + "type": "u64" }, { - "name": "timestamp", - "type": "i64", - "index": false + "name": "fee_basis_points", + "type": "u64" + }, + { + "name": "withdraw_authority", + "type": "pubkey" + }, + { + "name": "enable_migrate", + "type": "bool" + }, + { + "name": "pool_migration_fee", + "type": "u64" }, { - "name": "virtualSolReserves", - "type": "u64", - "index": false + "name": "creator_fee_basis_points", + "type": "u64" }, { - "name": "virtualTokenReserves", - "type": "u64", - "index": false + "name": "fee_recipients", + "type": { + "array": [ + "pubkey", + 8 + ] + } }, { - "name": "realSolReserves", - "type": "u64", - "index": false + "name": "timestamp", + "type": "i64" }, { - "name": "realTokenReserves", - "type": "u64", - "index": false + "name": "set_creator_authority", + "type": "pubkey" } ] } }, { - "name": "CompleteEvent", + "name": "TradeEvent", "type": { "kind": "struct", "fields": [ { - "name": "user", - "type": "pubkey", - "index": false + "name": "mint", + "type": "pubkey" }, { - "name": "mint", - "type": "pubkey", - "index": false + "name": "sol_amount", + "type": "u64" + }, + { + "name": "token_amount", + "type": "u64" + }, + { + "name": "is_buy", + "type": "bool" }, { - "name": "bondingCurve", - "type": "pubkey", - "index": false + "name": "user", + "type": "pubkey" }, { "name": "timestamp", - "type": "i64", - "index": false + "type": "i64" + }, + { + "name": "virtual_sol_reserves", + "type": "u64" + }, + { + "name": "virtual_token_reserves", + "type": "u64" + }, + { + "name": "real_sol_reserves", + "type": "u64" + }, + { + "name": "real_token_reserves", + "type": "u64" + }, + { + "name": "fee_recipient", + "type": "pubkey" + }, + { + "name": "fee_basis_points", + "type": "u64" + }, + { + "name": "fee", + "type": "u64" + }, + { + "name": "creator", + "type": "pubkey" + }, + { + "name": "creator_fee_basis_points", + "type": "u64" + }, + { + "name": "creator_fee", + "type": "u64" } ] } }, { - "name": "SetParamsEvent", + "name": "UpdateGlobalAuthorityEvent", "type": { "kind": "struct", "fields": [ { - "name": "feeRecipient", - "type": "pubkey", - "index": false - }, - { - "name": "initialVirtualTokenReserves", - "type": "u64", - "index": false - }, - { - "name": "initialVirtualSolReserves", - "type": "u64", - "index": false + "name": "global", + "type": "pubkey" }, { - "name": "initialRealTokenReserves", - "type": "u64", - "index": false + "name": "authority", + "type": "pubkey" }, { - "name": "tokenTotalSupply", - "type": "u64", - "index": false + "name": "new_authority", + "type": "pubkey" }, { - "name": "feeBasisPoints", - "type": "u64", - "index": false + "name": "timestamp", + "type": "i64" } ] } } - ], - "errors": [ - { - "code": 6000, - "name": "NotAuthorized", - "msg": "The given account is not authorized to execute this instruction." - }, - { - "code": 6001, - "name": "AlreadyInitialized", - "msg": "The program is already initialized." - }, - { - "code": 6002, - "name": "TooMuchSolRequired", - "msg": "slippage: Too much SOL required to buy the given amount of tokens." - }, - { - "code": 6003, - "name": "TooLittleSolReceived", - "msg": "slippage: Too little SOL received to sell the given amount of tokens." - }, - { - "code": 6004, - "name": "MintDoesNotMatchBondingCurve", - "msg": "The mint does not match the bonding curve." - }, - { - "code": 6005, - "name": "BondingCurveComplete", - "msg": "The bonding curve has completed and liquidity migrated to raydium." - }, - { - "code": 6006, - "name": "BondingCurveNotComplete", - "msg": "The bonding curve has not completed." - }, - { - "code": 6007, - "name": "NotInitialized", - "msg": "The program is not initialized." - }, - { - "code": 6008, - "name": "WithdrawTooFrequent", - "msg": "Withdraw too frequent" - } ] -} +} \ No newline at end of file diff --git a/src/IDL/pump-fun.ts b/src/IDL/pump-fun.ts index f673ae7..e89d2a7 100644 --- a/src/IDL/pump-fun.ts +++ b/src/IDL/pump-fun.ts @@ -1,869 +1,1375 @@ export type PumpFun = { - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; + address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P", metadata: { - name: "pump"; - version: "0.1.0"; - spec: "0.1.0"; - }; - instructions: [ - { - name: "initialize"; - discriminator: [175, 175, 109, 31, 13, 152, 155, 237]; - docs: ["Creates the global state."]; - accounts: [ - { - name: "global"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + name: "pump", + version: "0.1.0", + spec: "0.1.0", + description: "Created with Anchor" + }, + instructions: [{ + name: "buy", + docs: ["Buys tokens from a bonding curve."], + discriminator: [102, 6, 61, 18, 1, 218, 235, 234], + accounts: [{ + name: "global", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "fee_recipient", + writable: true + }, { + name: "mint" + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "associated_bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "bonding_curve" + }, { + kind: "const", + value: [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89] } - ]; - }; - }, - { - name: "user"; - writable: true; - signer: true; - }, - { - name: "systemProgram"; - address: "11111111111111111111111111111111"; - } - ]; - args: []; - }, - { - name: "setParams"; - discriminator: [165, 31, 134, 53, 189, 180, 130, 255]; - docs: ["Sets the global state parameters."]; - accounts: [ - { - name: "global"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + } + }, { + name: "associated_user", + writable: true + }, { + name: "user", + writable: true, + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "token_program", + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, { + name: "creator_vault", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116] + }, { + kind: "account", + path: "bonding_curve.creator", + account: "BondingCurve" + }] + } + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [{ + name: "amount", + type: "u64" + }, { + name: "max_sol_cost", + type: "u64" + }] + }, { + name: "collect_creator_fee", + docs: ["Collects creator_fee from creator_vault to the coin creator account"], + discriminator: [20, 22, 86, 123, 198, 28, 219, 132], + accounts: [{ + name: "creator", + writable: true, + signer: true + }, { + name: "creator_vault", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116] + }, { + kind: "account", + path: "creator" + }] + } + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [] + }, { + name: "create", + docs: ["Creates a new coin and bonding curve."], + discriminator: [24, 30, 200, 40, 5, 28, 7, 119], + accounts: [{ + name: "mint", + writable: true, + signer: true + }, { + name: "mint_authority", + pda: { + seeds: [{ + kind: "const", + value: [109, 105, 110, 116, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "associated_bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "bonding_curve" + }, { + kind: "const", + value: [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89] } - ]; - }; - }, - { - name: "user"; - writable: true; - signer: true; - }, - { - name: "systemProgram"; - address: "11111111111111111111111111111111"; - }, - { - name: "eventAuthority"; - address: "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"; - }, - { - name: "program"; - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; - } - ]; - args: [ - { - name: "feeRecipient"; - type: "pubkey"; - }, - { - name: "initialVirtualTokenReserves"; - type: "u64"; - }, - { - name: "initialVirtualSolReserves"; - type: "u64"; - }, - { - name: "initialRealTokenReserves"; - type: "u64"; - }, - { - name: "tokenTotalSupply"; - type: "u64"; - }, - { - name: "feeBasisPoints"; - type: "u64"; - } - ]; - }, - { - name: "create"; - discriminator: [24, 30, 200, 40, 5, 28, 7, 119]; - docs: ["Creates a new coin and bonding curve."]; - accounts: [ - { - name: "mint"; - writable: true; - signer: true; - }, - { - name: "mint_authority"; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 109, - 105, - 110, - 116, - 45, - 97, - 117, - 116, - 104, - 111, - 114, - 105, - 116, - 121 - ]; + } + }, { + name: "global", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "mpl_token_metadata", + address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" + }, { + name: "metadata", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [109, 101, 116, 97, 100, 97, 116, 97] + }, { + kind: "const", + value: [11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "account", + path: "mpl_token_metadata" } - ]; - }; - }, - { - name: "bondingCurve"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 45, - 99, - 117, - 114, - 118, - 101 - ]; - }, - { - kind: "account"; - path: "mint"; + } + }, { + name: "user", + writable: true, + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "token_program", + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, { + name: "associated_token_program", + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, { + name: "rent", + address: "SysvarRent111111111111111111111111111111111" + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [{ + name: "name", + type: "string" + }, { + name: "symbol", + type: "string" + }, { + name: "uri", + type: "string" + }, { + name: "creator", + type: "pubkey" + }] + }, { + name: "extend_account", + docs: ["Extends the size of program-owned accounts"], + discriminator: [234, 102, 194, 203, 150, 72, 62, 229], + accounts: [{ + name: "account", + writable: true + }, { + name: "user", + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [] + }, { + name: "initialize", + docs: ["Creates the global state."], + discriminator: [175, 175, 109, 31, 13, 152, 155, 237], + accounts: [{ + name: "global", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "user", + writable: true, + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }], + args: [] + }, { + name: "migrate", + docs: ["Migrates liquidity to pump_amm if the bonding curve is complete"], + discriminator: [155, 234, 231, 146, 236, 158, 162, 30], + accounts: [{ + name: "global", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "withdraw_authority", + writable: true, + relations: ["global"] + }, { + name: "mint" + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "associated_bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "bonding_curve" + }, { + kind: "const", + value: [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89] + } + } + }, { + name: "user", + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "token_program", + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, { + name: "pump_amm", + address: "pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA" + }, { + name: "pool", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [112, 111, 111, 108] + }, { + kind: "const", + value: [0, 0] + }, { + kind: "account", + path: "pool_authority" + }, { + kind: "account", + path: "mint" + }, { + kind: "account", + path: "wsol_mint" + }], + program: { + kind: "account", + path: "pump_amm" + } + } + }, { + name: "pool_authority", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [112, 111, 111, 108, 45, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "pool_authority_mint_account", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "pool_authority" + }, { + kind: "account", + path: "token_program" + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "account", + path: "associated_token_program" + } + } + }, { + name: "pool_authority_wsol_account", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "pool_authority" + }, { + kind: "account", + path: "token_program" + }, { + kind: "account", + path: "wsol_mint" + }], + program: { + kind: "account", + path: "associated_token_program" + } + } + }, { + name: "amm_global_config", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108, 95, 99, 111, 110, 102, 105, 103] + }], + program: { + kind: "account", + path: "pump_amm" + } + } + }, { + name: "wsol_mint", + address: "So11111111111111111111111111111111111111112" + }, { + name: "lp_mint", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [112, 111, 111, 108, 95, 108, 112, 95, 109, 105, 110, 116] + }, { + kind: "account", + path: "pool" + }], + program: { + kind: "account", + path: "pump_amm" } - ]; - }; - }, - { - name: "associatedBondingCurve"; - writable: true; - signer: false; - }, - { - name: "global"; - writable: false; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + } + }, { + name: "user_pool_token_account", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "pool_authority" + }, { + kind: "account", + path: "token_2022_program" + }, { + kind: "account", + path: "lp_mint" + }], + program: { + kind: "account", + path: "associated_token_program" } - ]; - }; - }, - { - name: "mplTokenMetadata"; - address: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"; - }, - { - name: "metadata"; - writable: true; - signer: false; - }, - { - name: "user"; - isMut: true; - isSigner: true; - }, - { - name: "systemProgram"; - address: "11111111111111111111111111111111"; - }, - { - name: "tokenProgram"; - address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; - }, - { - name: "associatedTokenProgram"; - address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; - }, - { - name: "rent"; - address: "SysvarRent111111111111111111111111111111111"; - }, - { - name: "eventAuthority"; - address: "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"; - }, - { - name: "program"; - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; - } - ]; - args: [ - { - name: "name"; - type: "string"; - }, - { - name: "symbol"; - type: "string"; - }, - { - name: "uri"; - type: "string"; - }, - { - name: "creator"; - type: "pubkey"; - } - ]; - }, - { - name: "buy"; - discriminator: [102, 6, 61, 18, 1, 218, 235, 234]; - docs: ["Buys tokens from a bonding curve."]; - accounts: [ - { - name: "global"; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + } + }, { + name: "pool_base_token_account", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "pool" + }, { + kind: "account", + path: "token_program" + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "account", + path: "associated_token_program" } - ]; - }; - }, - { - name: "feeRecipient"; - writable: true; - signer: false; - }, - { - name: "mint"; - writable: false; - signer: false; - }, - { - name: "bondingCurve"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 45, - 99, - 117, - 114, - 118, - 101 - ]; - }, - { - kind: "account"; - path: "mint"; + } + }, { + name: "pool_quote_token_account", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "pool" + }, { + kind: "account", + path: "token_program" + }, { + kind: "account", + path: "wsol_mint" + }], + program: { + kind: "account", + path: "associated_token_program" } - ]; - }; - }, - { - name: "associatedBondingCurve"; - writable: true; - signer: false; - }, - { - name: "associatedUser"; - writable: true; - signer: false; - }, - { - name: "user"; - writable: true; - signer: true; - }, - { - name: "systemProgram"; - address: "11111111111111111111111111111111"; - }, - { - name: "tokenProgram"; - address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; - }, - { - name: "rent"; - address: "SysvarRent111111111111111111111111111111111"; - }, - { - name: "eventAuthority"; - address: "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"; - }, - { - name: "program"; - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; - } - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - { - name: "maxSolCost"; - type: "u64"; - } - ]; - }, - { - name: "sell"; - discriminator: [51, 230, 133, 164, 1, 127, 131, 173]; - docs: ["Sells tokens into a bonding curve."]; - accounts: [ - { - name: "global"; - writable: false; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + } + }, { + name: "token_2022_program", + address: "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb" + }, { + name: "associated_token_program", + address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL" + }, { + name: "pump_amm_event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }], + program: { + kind: "account", + path: "pump_amm" } - ]; - }; - }, - { - name: "feeRecipient"; - writable: true; - signer: false; - }, - { - name: "mint"; - writable: false; - signer: false; - }, - { - name: "bondingCurve"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 45, - 99, - 117, - 114, - 118, - 101 - ]; - }, - { - kind: "account"; - path: "mint"; + } + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [] + }, { + name: "sell", + docs: ["Sells tokens into a bonding curve."], + discriminator: [51, 230, 133, 164, 1, 127, 131, 173], + accounts: [{ + name: "global", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "fee_recipient", + writable: true + }, { + name: "mint" + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "associated_bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "account", + path: "bonding_curve" + }, { + kind: "const", + value: [6, 221, 246, 225, 215, 101, 161, 147, 217, 203, 225, 70, 206, 235, 121, 172, 28, 180, 133, 237, 95, 91, 55, 145, 58, 140, 245, 133, 126, 255, 0, 169] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [140, 151, 37, 143, 78, 36, 137, 241, 187, 61, 16, 41, 20, 142, 13, 131, 11, 90, 19, 153, 218, 255, 16, 132, 4, 142, 123, 216, 219, 233, 248, 89] } - ]; - }; - }, - { - name: "associatedBondingCurve"; - writable: true; - signer: false; - }, - { - name: "associatedUser"; - writable: true; - signer: false; - }, - { - name: "user"; - writable: true; - signer: true; - }, - { - name: "systemProgram"; - address: "11111111111111111111111111111111"; - }, - { - name: "associatedTokenProgram"; - address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; - }, - { - name: "tokenProgram"; - address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; - }, - { - name: "eventAuthority"; - address: "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"; - }, - { - name: "program"; - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; - } - ]; - args: [ - { - name: "amount"; - type: "u64"; - }, - { - name: "minSolOutput"; - type: "u64"; - } - ]; - }, - { - name: "withdraw"; - discriminator: [183, 18, 70, 156, 148, 109, 161, 34]; - docs: [ - "Allows the admin to withdraw liquidity for a migration once the bonding curve completes" - ]; - accounts: [ - { - name: "global"; - writable: false; - pda: { - seeds: [ - { - kind: "const"; - value: [103, 108, 111, 98, 97, 108]; + } + }, { + name: "associated_user", + writable: true + }, { + name: "user", + writable: true, + signer: true + }, { + name: "system_program", + address: "11111111111111111111111111111111" + }, { + name: "creator_vault", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [99, 114, 101, 97, 116, 111, 114, 45, 118, 97, 117, 108, 116] + }, { + kind: "account", + path: "bonding_curve.creator", + account: "BondingCurve" + }] + } + }, { + name: "token_program", + address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [{ + name: "amount", + type: "u64" + }, { + name: "min_sol_output", + type: "u64" + }] + }, { + name: "set_creator", + docs: ["Allows Global::set_creator_authority to set the bonding curve creator from Metaplex metadata or input argument"], + discriminator: [254, 148, 255, 112, 207, 142, 170, 165], + accounts: [{ + name: "set_creator_authority", + signer: true, + relations: ["global"] + }, { + name: "global", + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "mint" + }, { + name: "metadata", + pda: { + seeds: [{ + kind: "const", + value: [109, 101, 116, 97, 100, 97, 116, 97] + }, { + kind: "const", + value: [11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70] } - ]; - }; - }, - { - name: "lastWithdraw"; - writable: true; - signer: false; - }, - { - name: "mint"; - writable: false; - signer: false; - }, - { - name: "bondingCurve"; - writable: true; - pda: { - seeds: [ - { - kind: "const"; - value: [ - 98, - 111, - 110, - 100, - 105, - 110, - 103, - 45, - 99, - 117, - 114, - 118, - 101 - ]; - }, - { - kind: "account"; - path: "mint"; + } + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [{ + name: "creator", + type: "pubkey" + }] + }, { + name: "set_metaplex_creator", + docs: ["Syncs the bonding curve creator with the Metaplex metadata creator if it exists"], + discriminator: [138, 96, 174, 217, 48, 85, 197, 246], + accounts: [{ + name: "mint" + }, { + name: "metadata", + pda: { + seeds: [{ + kind: "const", + value: [109, 101, 116, 97, 100, 97, 116, 97] + }, { + kind: "const", + value: [11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70] + }, { + kind: "account", + path: "mint" + }], + program: { + kind: "const", + value: [11, 112, 101, 177, 227, 209, 124, 69, 56, 157, 82, 127, 107, 4, 195, 205, 88, 184, 108, 115, 26, 160, 253, 181, 73, 182, 209, 188, 3, 248, 41, 70] } - ]; - }; - }, - { - name: "associatedBondingCurve"; - writable: true; - signer: false; - }, - { - name: "associatedUser"; - writable: true; - signer: false; - }, - { - name: "user"; - writable: true; - signer: true; - }, - { - name: "system_program"; - address: "11111111111111111111111111111111"; - }, - { - name: "tokenProgram"; - address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; - }, - { - name: "rent"; - address: "SysvarRent111111111111111111111111111111111"; - }, - { - name: "eventAuthority"; - address: "Ce6TQqeHC9p8KetsN6JsjHK7UTZk7nasjjnr7XxXp9F1"; - }, - { - name: "program"; - address: "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; - } - ]; - args: []; - } - ]; - accounts: [ - { - name: "bondingCurve"; - discriminator: [23, 183, 248, 55, 96, 216, 172, 96]; - }, - { - name: "global"; - discriminator: [167, 232, 232, 177, 200, 108, 114, 127]; - } - ]; - events: [ - { - name: "createEvent"; - discriminator: [27, 114, 169, 77, 222, 235, 99, 118]; - }, - { - name: "tradeEvent"; - discriminator: [189, 219, 127, 211, 78, 230, 97, 238]; - }, - { - name: "completeEvent"; - discriminator: [95, 114, 97, 156, 212, 46, 152, 8]; - }, - { - name: "setParamsEvent"; - discriminator: [223, 195, 159, 246, 62, 48, 143, 131]; - } - ]; - types: [ - { - name: "global"; + } + }, { + name: "bonding_curve", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [98, 111, 110, 100, 105, 110, 103, 45, 99, 117, 114, 118, 101] + }, { + kind: "account", + path: "mint" + }] + } + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [] + }, { + name: "set_params", + docs: ["Sets the global state parameters."], + discriminator: [27, 234, 178, 52, 147, 2, 187, 141], + accounts: [{ + name: "global", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "authority", + writable: true, + signer: true, + relations: ["global"] + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [{ + name: "initial_virtual_token_reserves", + type: "u64" + }, { + name: "initial_virtual_sol_reserves", + type: "u64" + }, { + name: "initial_real_token_reserves", + type: "u64" + }, { + name: "token_total_supply", + type: "u64" + }, { + name: "fee_basis_points", + type: "u64" + }, { + name: "withdraw_authority", + type: "pubkey" + }, { + name: "enable_migrate", + type: "bool" + }, { + name: "pool_migration_fee", + type: "u64" + }, { + name: "creator_fee_basis_points", + type: "u64" + }, { + name: "set_creator_authority", + type: "pubkey" + }] + }, { + name: "update_global_authority", + discriminator: [227, 181, 74, 196, 208, 21, 97, 213], + accounts: [{ + name: "global", + writable: true, + pda: { + seeds: [{ + kind: "const", + value: [103, 108, 111, 98, 97, 108] + }] + } + }, { + name: "authority", + signer: true, + relations: ["global"] + }, { + name: "new_authority" + }, { + name: "event_authority", + pda: { + seeds: [{ + kind: "const", + value: [95, 95, 101, 118, 101, 110, 116, 95, 97, 117, 116, 104, 111, 114, 105, 116, 121] + }] + } + }, { + name: "program" + }], + args: [] + }], + accounts: [{ + name: "BondingCurve", + discriminator: [23, 183, 248, 55, 96, 216, 172, 96] + }, { + name: "Global", + discriminator: [167, 232, 232, 177, 200, 108, 114, 127] + }], + events: [{ + name: "CollectCreatorFeeEvent", + discriminator: [122, 2, 127, 1, 14, 191, 12, 175] + }, { + name: "CompleteEvent", + discriminator: [95, 114, 97, 156, 212, 46, 152, 8] + }, { + name: "CompletePumpAmmMigrationEvent", + discriminator: [189, 233, 93, 185, 92, 148, 234, 148] + }, { + name: "CreateEvent", + discriminator: [27, 114, 169, 77, 222, 235, 99, 118] + }, { + name: "ExtendAccountEvent", + discriminator: [97, 97, 215, 144, 93, 146, 22, 124] + }, { + name: "SetCreatorEvent", + discriminator: [237, 52, 123, 37, 245, 251, 72, 210] + }, { + name: "SetMetaplexCreatorEvent", + discriminator: [142, 203, 6, 32, 127, 105, 191, 162] + }, { + name: "SetParamsEvent", + discriminator: [223, 195, 159, 246, 62, 48, 143, 131] + }, { + name: "TradeEvent", + discriminator: [189, 219, 127, 211, 78, 230, 97, 238] + }, { + name: "UpdateGlobalAuthorityEvent", + discriminator: [182, 195, 137, 42, 35, 206, 207, 247] + }], + errors: [{ + code: 6e3, + name: "NotAuthorized", + msg: "The given account is not authorized to execute this instruction." + }, { + code: 6001, + name: "AlreadyInitialized", + msg: "The program is already initialized." + }, { + code: 6002, + name: "TooMuchSolRequired", + msg: "slippage: Too much SOL required to buy the given amount of tokens." + }, { + code: 6003, + name: "TooLittleSolReceived", + msg: "slippage: Too little SOL received to sell the given amount of tokens." + }, { + code: 6004, + name: "MintDoesNotMatchBondingCurve", + msg: "The mint does not match the bonding curve." + }, { + code: 6005, + name: "BondingCurveComplete", + msg: "The bonding curve has completed and liquidity migrated to raydium." + }, { + code: 6006, + name: "BondingCurveNotComplete", + msg: "The bonding curve has not completed." + }, { + code: 6007, + name: "NotInitialized", + msg: "The program is not initialized." + }, { + code: 6008, + name: "WithdrawTooFrequent", + msg: "Withdraw too frequent" + }, { + code: 6009, + name: "NewSizeShouldBeGreaterThanCurrentSize", + msg: "new_size should be > current_size" + }, { + code: 6010, + name: "AccountTypeNotSupported", + msg: "Account type not supported" + }, { + code: 6011, + name: "InitialRealTokenReservesShouldBeLessThanTokenTotalSupply", + msg: "initial_real_token_reserves should be less than token_total_supply" + }, { + code: 6012, + name: "InitialVirtualTokenReservesShouldBeGreaterThanInitialRealTokenReserves", + msg: "initial_virtual_token_reserves should be greater than initial_real_token_reserves" + }, { + code: 6013, + name: "FeeBasisPointsGreaterThanMaximum", + msg: "fee_basis_points greater than maximum" + }, { + code: 6014, + name: "AllZerosWithdrawAuthority", + msg: "Withdraw authority cannot be set to System Program ID" + }, { + code: 6015, + name: "PoolMigrationFeeShouldBeLessThanFinalRealSolReserves", + msg: "pool_migration_fee should be less than final_real_sol_reserves" + }, { + code: 6016, + name: "PoolMigrationFeeShouldBeGreaterThanCreatorFeePlusMaxMigrateFees", + msg: "pool_migration_fee should be greater than creator_fee + MAX_MIGRATE_FEES" + }, { + code: 6017, + name: "DisabledWithdraw", + msg: "Migrate instruction is disabled" + }, { + code: 6018, + name: "DisabledMigrate", + msg: "Migrate instruction is disabled" + }, { + code: 6019, + name: "InvalidCreator", + msg: "Invalid creator pubkey" + }, { + code: 6020, + name: "BuyZeroAmount", + msg: "Buy zero amount" + }, { + code: 6021, + name: "NotEnoughTokensToBuy", + msg: "Not enough tokens to buy" + }, { + code: 6022, + name: "SellZeroAmount", + msg: "Sell zero amount" + }, { + code: 6023, + name: "NotEnoughTokensToSell", + msg: "Not enough tokens to sell" + }, { + code: 6024, + name: "Overflow", + msg: "Overflow" + }, { + code: 6025, + name: "Truncation", + msg: "Truncation" + }, { + code: 6026, + name: "DivisionByZero", + msg: "Division by zero" + }, { + code: 6027, + name: "NotEnoughRemainingAccounts", + msg: "Not enough remaining accounts" + }, { + code: 6028, + name: "AllFeeRecipientsShouldBeNonZero", + msg: "All fee recipients should be non-zero" + }, { + code: 6029, + name: "UnsortedNotUniqueFeeRecipients", + msg: "Unsorted or not unique fee recipients" + }, { + code: 6030, + name: "CreatorShouldNotBeZero", + msg: "Creator should not be zero" + }], + types: [{ + name: "BondingCurve", + type: { + kind: "struct", + fields: [{ + name: "virtual_token_reserves", + type: "u64" + }, { + name: "virtual_sol_reserves", + type: "u64" + }, { + name: "real_token_reserves", + type: "u64" + }, { + name: "real_sol_reserves", + type: "u64" + }, { + name: "token_total_supply", + type: "u64" + }, { + name: "complete", + type: "bool" + }, { + name: "creator", + type: "pubkey" + }] + } + }, { + name: "CollectCreatorFeeEvent", type: { - kind: "struct"; - fields: [ - { - name: "initialized"; - type: "bool"; - }, - { - name: "authority"; - type: "pubkey"; - }, - { - name: "feeRecipient"; - type: "pubkey"; - }, - { - name: "initialVirtualTokenReserves"; - type: "u64"; - }, - { - name: "initialVirtualSolReserves"; - type: "u64"; - }, - { - name: "initialRealTokenReserves"; - type: "u64"; - }, - { - name: "tokenTotalSupply"; - type: "u64"; - }, - { - name: "feeBasisPoints"; - type: "u64"; - } - ]; - }; - }, - { - name: "lastWithdraw"; + kind: "struct", + fields: [{ + name: "timestamp", + type: "i64" + }, { + name: "creator", + type: "pubkey" + }, { + name: "creator_fee", + type: "u64" + }] + } + }, { + name: "CompleteEvent", type: { - kind: "struct"; - fields: [ - { - name: "lastWithdrawTimestamp"; - type: "i64"; - } - ]; - }; - }, - { - name: "bondingCurve"; + kind: "struct", + fields: [{ + name: "user", + type: "pubkey" + }, { + name: "mint", + type: "pubkey" + }, { + name: "bonding_curve", + type: "pubkey" + }, { + name: "timestamp", + type: "i64" + }] + } + }, { + name: "CompletePumpAmmMigrationEvent", type: { - kind: "struct"; - fields: [ - { - name: "virtualTokenReserves"; - type: "u64"; - }, - { - name: "virtualSolReserves"; - type: "u64"; - }, - { - name: "realTokenReserves"; - type: "u64"; - }, - { - name: "realSolReserves"; - type: "u64"; - }, - { - name: "tokenTotalSupply"; - type: "u64"; - }, - { - name: "complete"; - type: "bool"; - } - ]; - }; - }, - { - name: "createEvent"; + kind: "struct", + fields: [{ + name: "user", + type: "pubkey" + }, { + name: "mint", + type: "pubkey" + }, { + name: "mint_amount", + type: "u64" + }, { + name: "sol_amount", + type: "u64" + }, { + name: "pool_migration_fee", + type: "u64" + }, { + name: "bonding_curve", + type: "pubkey" + }, { + name: "timestamp", + type: "i64" + }, { + name: "pool", + type: "pubkey" + }] + } + }, { + name: "CreateEvent", type: { - kind: "struct"; - fields: [ - { - name: "name"; - type: "string"; - index: false; - }, - { - name: "symbol"; - type: "string"; - index: false; - }, - { - name: "uri"; - type: "string"; - index: false; - }, - { - name: "mint"; - type: "pubkey"; - index: false; - }, - { - name: "bondingCurve"; - type: "pubkey"; - index: false; - }, - { - name: "user"; - type: "pubkey"; - index: false; - } - ]; - }; - }, - { - name: "tradeEvent"; + kind: "struct", + fields: [{ + name: "name", + type: "string" + }, { + name: "symbol", + type: "string" + }, { + name: "uri", + type: "string" + }, { + name: "mint", + type: "pubkey" + }, { + name: "bonding_curve", + type: "pubkey" + }, { + name: "user", + type: "pubkey" + }, { + name: "creator", + type: "pubkey" + }, { + name: "timestamp", + type: "i64" + }, { + name: "virtual_token_reserves", + type: "u64" + }, { + name: "virtual_sol_reserves", + type: "u64" + }, { + name: "real_token_reserves", + type: "u64" + }, { + name: "token_total_supply", + type: "u64" + }] + } + }, { + name: "ExtendAccountEvent", type: { - kind: "struct"; - fields: [ - { - name: "mint"; - type: "pubkey"; - index: false; - }, - { - name: "solAmount"; - type: "u64"; - index: false; - }, - { - name: "tokenAmount"; - type: "u64"; - index: false; - }, - { - name: "isBuy"; - type: "bool"; - index: false; - }, - { - name: "user"; - type: "pubkey"; - index: false; - }, - { - name: "timestamp"; - type: "i64"; - index: false; - }, - { - name: "virtualSolReserves"; - type: "u64"; - index: false; - }, - { - name: "virtualTokenReserves"; - type: "u64"; - index: false; - }, - { - name: "realSolReserves"; - type: "u64"; - index: false; - }, - { - name: "realTokenReserves"; - type: "u64"; - index: false; - } - ]; - }; - }, - { - name: "completeEvent"; + kind: "struct", + fields: [{ + name: "account", + type: "pubkey" + }, { + name: "user", + type: "pubkey" + }, { + name: "current_size", + type: "u64" + }, { + name: "new_size", + type: "u64" + }, { + name: "timestamp", + type: "i64" + }] + } + }, { + name: "Global", + type: { + kind: "struct", + fields: [{ + name: "initialized", + docs: ["Unused"], + type: "bool" + }, { + name: "authority", + type: "pubkey" + }, { + name: "fee_recipient", + type: "pubkey" + }, { + name: "initial_virtual_token_reserves", + type: "u64" + }, { + name: "initial_virtual_sol_reserves", + type: "u64" + }, { + name: "initial_real_token_reserves", + type: "u64" + }, { + name: "token_total_supply", + type: "u64" + }, { + name: "fee_basis_points", + type: "u64" + }, { + name: "withdraw_authority", + type: "pubkey" + }, { + name: "enable_migrate", + docs: ["Unused"], + type: "bool" + }, { + name: "pool_migration_fee", + type: "u64" + }, { + name: "creator_fee_basis_points", + type: "u64" + }, { + name: "fee_recipients", + type: { + array: ["pubkey", 7] + } + }, { + name: "set_creator_authority", + type: "pubkey" + }] + } + }, { + name: "SetCreatorEvent", + type: { + kind: "struct", + fields: [{ + name: "timestamp", + type: "i64" + }, { + name: "mint", + type: "pubkey" + }, { + name: "bonding_curve", + type: "pubkey" + }, { + name: "creator", + type: "pubkey" + }] + } + }, { + name: "SetMetaplexCreatorEvent", + type: { + kind: "struct", + fields: [{ + name: "timestamp", + type: "i64" + }, { + name: "mint", + type: "pubkey" + }, { + name: "bonding_curve", + type: "pubkey" + }, { + name: "metadata", + type: "pubkey" + }, { + name: "creator", + type: "pubkey" + }] + } + }, { + name: "SetParamsEvent", + type: { + kind: "struct", + fields: [{ + name: "initial_virtual_token_reserves", + type: "u64" + }, { + name: "initial_virtual_sol_reserves", + type: "u64" + }, { + name: "initial_real_token_reserves", + type: "u64" + }, { + name: "final_real_sol_reserves", + type: "u64" + }, { + name: "token_total_supply", + type: "u64" + }, { + name: "fee_basis_points", + type: "u64" + }, { + name: "withdraw_authority", + type: "pubkey" + }, { + name: "enable_migrate", + type: "bool" + }, { + name: "pool_migration_fee", + type: "u64" + }, { + name: "creator_fee_basis_points", + type: "u64" + }, { + name: "fee_recipients", + type: { + array: ["pubkey", 8] + } + }, { + name: "timestamp", + type: "i64" + }, { + name: "set_creator_authority", + type: "pubkey" + }] + } + }, { + name: "TradeEvent", type: { - kind: "struct"; - fields: [ - { - name: "user"; - type: "pubkey"; - index: false; - }, - { - name: "mint"; - type: "pubkey"; - index: false; - }, - { - name: "bondingCurve"; - type: "pubkey"; - index: false; - }, - { - name: "timestamp"; - type: "i64"; - index: false; - } - ]; - }; - }, - { - name: "setParamsEvent"; + kind: "struct", + fields: [{ + name: "mint", + type: "pubkey" + }, { + name: "sol_amount", + type: "u64" + }, { + name: "token_amount", + type: "u64" + }, { + name: "is_buy", + type: "bool" + }, { + name: "user", + type: "pubkey" + }, { + name: "timestamp", + type: "i64" + }, { + name: "virtual_sol_reserves", + type: "u64" + }, { + name: "virtual_token_reserves", + type: "u64" + }, { + name: "real_sol_reserves", + type: "u64" + }, { + name: "real_token_reserves", + type: "u64" + }, { + name: "fee_recipient", + type: "pubkey" + }, { + name: "fee_basis_points", + type: "u64" + }, { + name: "fee", + type: "u64" + }, { + name: "creator", + type: "pubkey" + }, { + name: "creator_fee_basis_points", + type: "u64" + }, { + name: "creator_fee", + type: "u64" + }] + } + }, { + name: "UpdateGlobalAuthorityEvent", type: { - kind: "struct"; - fields: [ - { - name: "feeRecipient"; - type: "pubkey"; - index: false; - }, - { - name: "initialVirtualTokenReserves"; - type: "u64"; - index: false; - }, - { - name: "initialVirtualSolReserves"; - type: "u64"; - index: false; - }, - { - name: "initialRealTokenReserves"; - type: "u64"; - index: false; - }, - { - name: "tokenTotalSupply"; - type: "u64"; - index: false; - }, - { - name: "feeBasisPoints"; - type: "u64"; - index: false; - } - ]; - }; - } - ]; - errors: [ - { - code: 6000; - name: "NotAuthorized"; - msg: "The given account is not authorized to execute this instruction."; - }, - { - code: 6001; - name: "AlreadyInitialized"; - msg: "The program is already initialized."; - }, - { - code: 6002; - name: "TooMuchSolRequired"; - msg: "slippage: Too much SOL required to buy the given amount of tokens."; - }, - { - code: 6003; - name: "TooLittleSolReceived"; - msg: "slippage: Too little SOL received to sell the given amount of tokens."; - }, - { - code: 6004; - name: "MintDoesNotMatchBondingCurve"; - msg: "The mint does not match the bonding curve."; - }, - { - code: 6005; - name: "BondingCurveComplete"; - msg: "The bonding curve has completed and liquidity migrated to raydium."; - }, - { - code: 6006; - name: "BondingCurveNotComplete"; - msg: "The bonding curve has not completed."; - }, - { - code: 6007; - name: "NotInitialized"; - msg: "The program is not initialized."; - }, - { - code: 6008; - name: "WithdrawTooFrequent"; - msg: "Withdraw too frequent"; - } - ]; + kind: "struct", + fields: [{ + name: "global", + type: "pubkey" + }, { + name: "authority", + type: "pubkey" + }, { + name: "new_authority", + type: "pubkey" + }, { + name: "timestamp", + type: "i64" + }] + } + }] }; diff --git a/src/pumpfun.ts b/src/pumpfun.ts index cd8aaf9..51a74b3 100644 --- a/src/pumpfun.ts +++ b/src/pumpfun.ts @@ -5,6 +5,7 @@ import { Keypair, PublicKey, Transaction, + TransactionInstruction, } from "@solana/web3.js"; import { Program, Provider } from "@coral-xyz/anchor"; import { GlobalAccount } from "./globalAccount.js"; @@ -40,22 +41,27 @@ import { sendTx, } from "./util.js"; import { PumpFun, IDL } from "./IDL/index.js"; -const PROGRAM_ID = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"; -const MPL_TOKEN_METADATA_PROGRAM_ID = - "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"; +import { Idl } from "@coral-xyz/anchor"; + +// SDK Constants +const MPL_TOKEN_METADATA_PROGRAM_ID = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"; +const SYSTEM_PROGRAM_ID = "11111111111111111111111111111111"; +const TOKEN_PROGRAM_ID = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; +const ASSOCIATED_TOKEN_PROGRAM_ID = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"; export const GLOBAL_ACCOUNT_SEED = "global"; export const MINT_AUTHORITY_SEED = "mint-authority"; export const BONDING_CURVE_SEED = "bonding-curve"; export const METADATA_SEED = "metadata"; +export const EVENT_AUTHORITY_SEED = "__event_authority"; 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 Idl, provider); this.connection = this.program.provider.connection; } @@ -89,15 +95,64 @@ export class PumpFunSDK { slippageBasisPoints ); - const buyTx = await this.getBuyInstructions( + // Instead of calling getBuyInstructions which requires an existing bonding curve, + // we'll create the buy instruction manually since we know the token is being created + + const bondingCurvePDA = this.getBondingCurvePDA(mint.publicKey); + + const associatedBondingCurve = await getAssociatedTokenAddress( + mint.publicKey, + bondingCurvePDA, + true + ); + + // Create associated token account for user if needed + const associatedUser = await this.createAssociatedTokenAccountIfNeeded( + creator.publicKey, creator.publicKey, mint.publicKey, - globalAccount.feeRecipient, - buyAmount, - buyAmountWithSlippage + newTx, + commitment ); - newTx.add(buyTx); + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + + // Get global account PDA + const globalAccountPDA = this.getGlobalAccountPda(); + + // Derive creator_vault PDA using the creator's public key (for createAndBuy, bonding curve doesn't exist yet) + const creatorVaultPda = this.getCreatorVaultPda(creator.publicKey); + + // Create buy instruction using Anchor coder + const buyInstructionData = this.program.coder.instruction.encode("buy", { + amount: new BN(buyAmount.toString()), + maxSolCost: new BN(buyAmountWithSlippage.toString()) + }); + + // Create accounts array in the exact order + const accounts = [ + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, + { pubkey: globalAccount.feeRecipient, isSigner: false, isWritable: true }, + { pubkey: mint.publicKey, isSigner: false, isWritable: false }, + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, + { pubkey: associatedUser, isSigner: false, isWritable: true }, + { pubkey: creator.publicKey, isSigner: true, isWritable: true }, + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: creatorVaultPda, isSigner: false, isWritable: true }, + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, + { pubkey: this.program.programId, isSigner: false, isWritable: false } + ]; + + newTx.add( + new TransactionInstruction({ + keys: accounts, + programId: this.program.programId, + data: buyInstructionData + }) + ); } let createResults = await sendTx( @@ -121,24 +176,93 @@ export class PumpFunSDK { commitment: Commitment = DEFAULT_COMMITMENT, finality: Finality = DEFAULT_FINALITY ): Promise { - let buyTx = await this.getBuyInstructionsBySolAmount( + // Get bonding curve account + const bondingCurvePDA = this.getBondingCurvePDA(mint); + const bondingAccount = await this.getBondingCurveAccount(mint, commitment); + if (!bondingAccount) { + throw new Error(`Bonding curve account not found: ${mint.toBase58()}`); + } + + // Get global account + const globalAccountPDA = this.getGlobalAccountPda(); + const globalAccount = await this.getGlobalAccount(commitment); + + // Calculate buy amount + const buyAmount = bondingAccount.getBuyPrice(buyAmountSol); + const buyAmountWithSlippage = calculateWithSlippageBuy( + buyAmountSol, + slippageBasisPoints + ); + + // Get the associated token accounts + const associatedBondingCurve = await getAssociatedTokenAddress( + mint, + bondingCurvePDA, + true + ); + + // Get bonding curve creator using helper function + const bondingCurveCreator = await this.getBondingCurveCreator(bondingCurvePDA, commitment); + + // Derive creator_vault PDA using bonding curve creator (not user public key) + const creatorVaultPda = this.getCreatorVaultPda(bondingCurveCreator); + + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + + // Create a new transaction + let transaction = new Transaction(); + + // Add token account creation instruction if needed + const associatedUser = await this.createAssociatedTokenAccountIfNeeded( + buyer.publicKey, buyer.publicKey, mint, - buyAmountSol, - slippageBasisPoints, + transaction, commitment ); - - let buyResults = await sendTx( + + // Create buy instruction using Anchor coder + const buyInstructionData = this.program.coder.instruction.encode("buy", { + amount: new BN(buyAmount.toString()), + maxSolCost: new BN(buyAmountWithSlippage.toString()) + }); + + // Create accounts array in the exact order from buy_token_fixed.ts + const accounts = [ + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, + { pubkey: globalAccount.feeRecipient, isSigner: false, isWritable: true }, + { pubkey: mint, isSigner: false, isWritable: false }, + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, + { pubkey: associatedUser, isSigner: false, isWritable: true }, + { pubkey: buyer.publicKey, isSigner: true, isWritable: true }, + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, // SystemProgram + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, // TokenProgram + { pubkey: creatorVaultPda, isSigner: false, isWritable: true }, + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, + { pubkey: this.program.programId, isSigner: false, isWritable: false } + ]; + + // Add the buy instruction (manually created to ensure correct account order) + transaction.add( + new TransactionInstruction({ + keys: accounts, + programId: this.program.programId, + data: buyInstructionData + }) + ); + + // Send the transaction + return await sendTx( this.connection, - buyTx, + transaction, buyer.publicKey, [buyer], priorityFees, commitment, finality ); - return buyResults; } async sell( @@ -150,24 +274,101 @@ export class PumpFunSDK { commitment: Commitment = DEFAULT_COMMITMENT, finality: Finality = DEFAULT_FINALITY ): Promise { - let sellTx = await this.getSellInstructionsByTokenAmount( - seller.publicKey, - mint, + // Get bonding curve account + const bondingCurvePDA = this.getBondingCurvePDA(mint); + const bondingAccount = await this.getBondingCurveAccount(mint, commitment); + if (!bondingAccount) { + throw new Error(`Bonding curve account not found: ${mint.toBase58()}`); + } + + // Get global account + const globalAccountPDA = this.getGlobalAccountPda(); + const globalAccount = await this.getGlobalAccount(commitment); + + // Calculate sell amount and slippage + // Get exact price from bonding curve + const minSolOutput = bondingAccount.getSellPrice( sellTokenAmount, - slippageBasisPoints, - commitment + globalAccount.feeBasisPoints ); - - let sellResults = await sendTx( + + // Calculate with percentage-based slippage rather than a fixed value reduction + let sellAmountWithSlippage = calculateWithSlippageSell( + minSolOutput, + slippageBasisPoints + ); + + // Make sure we don't go below 1 for very small amounts + if (sellAmountWithSlippage < 1n) { + sellAmountWithSlippage = 1n; + } + + console.log(`Sell details: amount=${sellTokenAmount}, exactSolOutput=${minSolOutput}, withSlippage=${sellAmountWithSlippage}`); + + // Get the associated token accounts + const associatedBondingCurve = await getAssociatedTokenAddress( + mint, + bondingCurvePDA, + true + ); + const sellerPublicKey = seller.publicKey; + const associatedUser = await getAssociatedTokenAddress( + mint, + sellerPublicKey, + false + ); + + // Get bonding curve creator using helper function + const bondingCurveCreator = await this.getBondingCurveCreator(bondingCurvePDA, commitment); + + // Get the creator vault PDA + const creatorVaultPda = this.getCreatorVaultPda(bondingCurveCreator); + console.log("Creator vault PDA:", creatorVaultPda.toString()); + + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + + // Create a new transaction + let transaction = new Transaction(); + + const sellInstructionData = this.program.coder.instruction.encode("sell", { + amount: new BN(sellTokenAmount.toString()), + minSolOutput: new BN(sellAmountWithSlippage.toString()) + }); + + const sellAccounts = [ + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, + { pubkey: globalAccount.feeRecipient, isSigner: false, isWritable: true }, + { pubkey: mint, isSigner: false, isWritable: false }, + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, + { pubkey: associatedUser, isSigner: false, isWritable: true }, + { pubkey: sellerPublicKey, isSigner: true, isWritable: true }, + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: creatorVaultPda, isSigner: false, isWritable: true }, + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, + { pubkey: this.program.programId, isSigner: false, isWritable: false } + ]; + + let ix = new TransactionInstruction({ + keys: sellAccounts, + programId: this.program.programId, + data: sellInstructionData + }); + + transaction.add(ix); + + // Send the transaction + return await sendTx( this.connection, - sellTx, - seller.publicKey, + transaction, + sellerPublicKey, [seller], priorityFees, commitment, finality ); - return sellResults; } //create token instructions @@ -189,22 +390,58 @@ export class PumpFunSDK { mplTokenMetadata ); + const bondingCurvePDA = this.getBondingCurvePDA(mint.publicKey); + const associatedBondingCurve = await getAssociatedTokenAddress( mint.publicKey, - this.getBondingCurvePDA(mint.publicKey), + bondingCurvePDA, true ); - return this.program.methods - .create(name, symbol, uri, creator) - .accounts({ - mint: mint.publicKey, - associatedBondingCurve: associatedBondingCurve, - metadata: metadataPDA, - user: creator, - }) - .signers([mint]) - .transaction(); + // Get mint authority PDA + const [mintAuthorityPDA] = PublicKey.findProgramAddressSync( + [Buffer.from(MINT_AUTHORITY_SEED)], + this.program.programId + ); + + // Get global account PDA + const globalAccountPDA = this.getGlobalAccountPda(); + + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + + // Create instruction manually to avoid typing issues + const createInstructionData = this.program.coder.instruction.encode("create", { + name: name, + symbol: symbol, + uri: uri, + creator: creator + }); + + const createAccounts = [ + { pubkey: mint.publicKey, isSigner: true, isWritable: true }, // mint + { pubkey: mintAuthorityPDA, isSigner: false, isWritable: false }, // mint_authority + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, // bonding_curve + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, // associated_bonding_curve + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, // global + { pubkey: mplTokenMetadata, isSigner: false, isWritable: false }, // mpl_token_metadata + { pubkey: metadataPDA, isSigner: false, isWritable: true }, // metadata + { pubkey: creator, isSigner: true, isWritable: true }, // user + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, // system_program + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, // token_program + { pubkey: new PublicKey(ASSOCIATED_TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, // associated_token_program + { pubkey: new PublicKey("SysvarRent111111111111111111111111111111111"), isSigner: false, isWritable: false }, // rent + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, // event_authority + { pubkey: this.program.programId, isSigner: false, isWritable: false } // program + ]; + + const createInstruction = new TransactionInstruction({ + keys: createAccounts, + programId: this.program.programId, + data: createInstructionData + }); + + return new Transaction().add(createInstruction); } async getBuyInstructionsBySolAmount( @@ -248,14 +485,31 @@ export class PumpFunSDK { solAmount: bigint, commitment: Commitment = DEFAULT_COMMITMENT ) { + const bondingCurvePDA = this.getBondingCurvePDA(mint); + const associatedBondingCurve = await getAssociatedTokenAddress( mint, - this.getBondingCurvePDA(mint), + bondingCurvePDA, true ); const associatedUser = await getAssociatedTokenAddress(mint, buyer, false); + // Get bonding curve account to extract creator + const bondingCurveAccountInfo2 = await this.connection.getAccountInfo(bondingCurvePDA); + if (!bondingCurveAccountInfo2) { + throw new Error("Bonding curve account not found"); + } + + // Get bonding curve creator using helper function + const bondingCurveCreator = await this.getBondingCurveCreator(bondingCurvePDA, commitment); + + // Derive creator_vault PDA using bonding curve creator (not user public key) + const creatorVaultPda = this.getCreatorVaultPda(bondingCurveCreator); + + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + let transaction = new Transaction(); try { @@ -271,17 +525,36 @@ export class PumpFunSDK { ); } + // Get global account PDA + const globalAccountPDA = this.getGlobalAccountPda(); + + // Create buy instruction using Anchor coder + const buyInstructionData = this.program.coder.instruction.encode("buy", { + amount: new BN(amount.toString()), + maxSolCost: new BN(solAmount.toString()) + }); + + const buyAccounts = [ + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, + { pubkey: feeRecipient, isSigner: false, isWritable: true }, + { pubkey: mint, isSigner: false, isWritable: false }, + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, + { pubkey: associatedUser, isSigner: false, isWritable: true }, + { pubkey: buyer, isSigner: true, isWritable: true }, + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: creatorVaultPda, isSigner: false, isWritable: true }, + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, + { pubkey: this.program.programId, isSigner: false, isWritable: false } + ]; + transaction.add( - await this.program.methods - .buy(new BN(amount.toString()), new BN(solAmount.toString())) - .accounts({ - feeRecipient: feeRecipient, - mint: mint, - associatedBondingCurve: associatedBondingCurve, - associatedUser: associatedUser, - user: buyer, - }) - .transaction() + new TransactionInstruction({ + keys: buyAccounts, + programId: this.program.programId, + data: buyInstructionData + }) ); return transaction; @@ -305,15 +578,24 @@ export class PumpFunSDK { let globalAccount = await this.getGlobalAccount(commitment); - let minSolOutput = bondingCurveAccount.getSellPrice( + // Get exact price from bonding curve + const minSolOutput = bondingCurveAccount.getSellPrice( sellTokenAmount, globalAccount.feeBasisPoints ); - + + // Calculate with percentage-based slippage rather than a fixed value reduction let sellAmountWithSlippage = calculateWithSlippageSell( minSolOutput, slippageBasisPoints ); + + // Make sure we don't go below 1 for very small amounts + if (sellAmountWithSlippage < 1n) { + sellAmountWithSlippage = 1n; + } + + console.log(`getSellInstructionsByTokenAmount - amount=${sellTokenAmount}, exactOutput=${minSolOutput}, withSlippage=${sellAmountWithSlippage}`); return await this.getSellInstructions( seller, @@ -329,11 +611,14 @@ export class PumpFunSDK { mint: PublicKey, feeRecipient: PublicKey, amount: bigint, - minSolOutput: bigint + minSolOutput: bigint, + commitment: Commitment = DEFAULT_COMMITMENT ) { + const bondingCurvePDA = this.getBondingCurvePDA(mint); + const associatedBondingCurve = await getAssociatedTokenAddress( mint, - this.getBondingCurvePDA(mint), + bondingCurvePDA, true ); @@ -341,17 +626,47 @@ export class PumpFunSDK { let transaction = new Transaction(); + // Get global account PDA + const globalAccountPDA = this.getGlobalAccountPda(); + + const bondingCurveCreator = await this.getBondingCurveCreator(bondingCurvePDA, commitment); + + // Derive creator_vault PDA using bonding curve creator + const creatorVaultPda = this.getCreatorVaultPda(bondingCurveCreator); + + // Get event authority PDA + const eventAuthorityPda = this.getEventAuthorityPda(); + + // Check IDL for the correct order of accounts + const accounts = [ + { pubkey: globalAccountPDA, isSigner: false, isWritable: false }, + { pubkey: feeRecipient, isSigner: false, isWritable: true }, + { pubkey: mint, isSigner: false, isWritable: false }, + { pubkey: bondingCurvePDA, isSigner: false, isWritable: true }, + { pubkey: associatedBondingCurve, isSigner: false, isWritable: true }, + { pubkey: associatedUser, isSigner: false, isWritable: true }, + { pubkey: seller, isSigner: true, isWritable: true }, + { pubkey: new PublicKey(SYSTEM_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: new PublicKey(ASSOCIATED_TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: new PublicKey(TOKEN_PROGRAM_ID), isSigner: false, isWritable: false }, + { pubkey: creatorVaultPda, isSigner: false, isWritable: true }, + { pubkey: eventAuthorityPda, isSigner: false, isWritable: false }, + { pubkey: this.program.programId, isSigner: false, isWritable: false } + ]; + + // Create the sell instruction with BN values for amount and minSolOutput + const instructionData = this.program.coder.instruction.encode("sell", { + amount: new BN(amount.toString()), + minSolOutput: new BN(minSolOutput.toString()) + }); + + // Add the instruction to the transaction transaction.add( - await this.program.methods - .sell(new BN(amount.toString()), new BN(minSolOutput.toString())) - .accounts({ - feeRecipient: feeRecipient, - mint: mint, - associatedBondingCurve: associatedBondingCurve, - associatedUser: associatedUser, - user: seller, - }) - .transaction() + new TransactionInstruction({ + keys: accounts, + programId: this.program.programId, + data: instructionData + }) ); return transaction; @@ -372,10 +687,7 @@ export class PumpFunSDK { } async getGlobalAccount(commitment: Commitment = DEFAULT_COMMITMENT) { - const [globalAccountPDA] = PublicKey.findProgramAddressSync( - [Buffer.from(GLOBAL_ACCOUNT_SEED)], - new PublicKey(PROGRAM_ID) - ); + const globalAccountPDA = this.getGlobalAccountPda(); const tokenAccount = await this.connection.getAccountInfo( globalAccountPDA, @@ -392,6 +704,20 @@ export class PumpFunSDK { )[0]; } + private async getBondingCurveCreator( + bondingCurvePDA: PublicKey, + commitment: Commitment = DEFAULT_COMMITMENT + ): Promise { + const bondingAccountInfo = await this.connection.getAccountInfo(bondingCurvePDA, commitment); + if (!bondingAccountInfo) { + throw new Error("Bonding curve account not found"); + } + + // Creator is at offset 49 (after 8 bytes discriminator, 5 u64 fields, and 1 byte boolean) + const creatorBytes = bondingAccountInfo.data.subarray(49, 49 + 32); + return new PublicKey(creatorBytes); + } + async createTokenMetadata(create: CreateTokenMetadata) { // Validate file if (!(create.file instanceof Blob)) { @@ -442,7 +768,54 @@ export class PumpFunSDK { console.error('Error in createTokenMetadata:', error); throw error; } -} + } + + + private getCreatorVaultPda(creator: PublicKey): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from("creator-vault"), creator.toBuffer()], + this.program.programId + )[0]; + } + + private getGlobalAccountPda(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from(GLOBAL_ACCOUNT_SEED)], + this.program.programId + )[0]; + } + + private getEventAuthorityPda(): PublicKey { + return PublicKey.findProgramAddressSync( + [Buffer.from(EVENT_AUTHORITY_SEED)], + this.program.programId + )[0]; + } + + private async createAssociatedTokenAccountIfNeeded( + payer: PublicKey, + owner: PublicKey, + mint: PublicKey, + transaction: Transaction, + commitment: Commitment = DEFAULT_COMMITMENT + ): Promise { + const associatedTokenAccount = await getAssociatedTokenAddress(mint, owner, false); + + try { + await getAccount(this.connection, associatedTokenAccount, commitment); + } catch (e) { + transaction.add( + createAssociatedTokenAccountInstruction( + payer, + associatedTokenAccount, + owner, + mint + ) + ); + } + + return associatedTokenAccount; + } //EVENTS addEventListener( eventType: T, @@ -499,4 +872,5 @@ export class PumpFunSDK { removeEventListener(eventId: number) { this.program.removeEventListener(eventId); } + } diff --git a/src/util.ts b/src/util.ts index aad57c9..1af13b4 100644 --- a/src/util.ts +++ b/src/util.ts @@ -23,12 +23,17 @@ export const calculateWithSlippageBuy = ( return amount + (amount * basisPoints) / 10000n; }; -export const calculateWithSlippageSell = ( +export function calculateWithSlippageSell( amount: bigint, - basisPoints: bigint -) => { - return amount - (amount * basisPoints) / 10000n; -}; + slippageBasisPoints: bigint = 500n, +): bigint { + // Actually use the slippage basis points for calculation + const reduction = Math.max( + 1, + Number((amount * slippageBasisPoints) / 10000n) + ); + return amount - BigInt(reduction); +} export async function sendTx( connection: Connection,