repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #1 | --- |
| #2 | name: pump-token-lifecycle |
| #3 | description: "Full token lifecycle from creation through bonding curve trading, graduation detection, AMM migration, fee collection, and volume tracking on Solana using PumpSdk and OnlinePumpSdk." |
| #4 | metadata: |
| #5 | openclaw: |
| #6 | homepage: https://github.com/nirholas/pump-fun-sdk |
| #7 | requires: |
| #8 | env: |
| #9 | - SOLANA_RPC_URL |
| #10 | --- |
| #11 | |
| #12 | # Token Lifecycle — Create, Trade, Graduate, Migrate & Collect |
| #13 | |
| #14 | Manage the full lifecycle of Pump tokens from creation through bonding curve trading, graduation detection, AMM migration, fee collection, and volume tracking — using the offline `PumpSdk` and online `OnlinePumpSdk`. |
| #15 | |
| #16 | ## Context |
| #17 | |
| #18 | Pump tokens follow a defined lifecycle: creation → bonding curve trading → graduation (when market cap reaches threshold) → AMM migration → AMM trading. The SDK provides instruction builders for each phase, with both offline (no RPC) and online (live fetches) variants. |
| #19 | |
| #20 | ## Lifecycle Phases |
| #21 | |
| #22 | ### Phase 1: Token Creation |
| #23 | |
| #24 | ```typescript |
| #25 | // V2 creation with Token-2022 (preferred) |
| #26 | const ix = await PUMP_SDK.createV2Instruction({ |
| #27 | mint, name, symbol, uri, creator, user, |
| #28 | }); |
| #29 | |
| #30 | // Create and immediately buy in same transaction |
| #31 | const ixs = await PUMP_SDK.createV2AndBuyInstructions({ |
| #32 | global, feeConfig, mint, name, symbol, uri, |
| #33 | creator, user, solAmount, amount, slippage |
| #34 | }); |
| #35 | ``` |
| #36 | |
| #37 | - `createInstruction` (v1) is **deprecated** — use `createV2Instruction` (Token-2022) |
| #38 | - Token-2022 enables advanced token features (transfer hooks, confidential transfers) |
| #39 | - Mayhem mode tokens use additional Mayhem program PDAs |
| #40 | |
| #41 | ### Phase 2: Bonding Curve Trading |
| #42 | |
| #43 | ```typescript |
| #44 | // Buy |
| #45 | const { bondingCurve } = await onlineSdk.fetchBuyState(mint, user); |
| #46 | const amount = getBuyTokenAmountFromSolAmount({ global, feeConfig, mintSupply, bondingCurve, amount: solAmount }); |
| #47 | const ixs = await PUMP_SDK.buyInstructions({ global, bondingCurveAccountInfo, bondingCurve, associatedUserAccountInfo, mint, user, solAmount, amount, slippage: 1 }); |
| #48 | |
| #49 | // Sell |
| #50 | const solAmount = getSellSolAmountFromTokenAmount({ global, feeConfig, mintSupply, bondingCurve, amount }); |
| #51 | const ixs = await PUMP_SDK.sellInstructions({ global, bondingCurveAccountInfo, bondingCurve, mint, user, amount, solAmount, slippage: 1 }); |
| #52 | ``` |
| #53 | |
| #54 | ### Phase 3: Graduation Detection |
| #55 | |
| #56 | ```typescript |
| #57 | const bondingCurve = await onlineSdk.fetchBondingCurve(mint); |
| #58 | if (bondingCurve.complete) { |
| #59 | // Token has graduated — must migrate to AMM |
| #60 | } |
| #61 | ``` |
| #62 | |
| #63 | ### Phase 4: AMM Migration |
| #64 | |
| #65 | ```typescript |
| #66 | const extendIx = await PUMP_SDK.extendAccountInstruction({ bondingCurvePda, bondingCurveAccountInfo }); |
| #67 | const migrateIx = await PUMP_SDK.migrateInstruction({ mint, creator }); |
| #68 | ``` |
| #69 | |
| #70 | ### Phase 5: Post-Migration (AMM Trading) |
| #71 | |
| #72 | After migration, the SDK's "BothPrograms" methods handle trading transparently across Pump and PumpAMM. |
| #73 | |
| #74 | ### Phase 6: Creator Fee Collection |
| #75 | |
| #76 | ```typescript |
| #77 | const ixs = await onlineSdk.collectCoinCreatorFeeInstructions(creator); |
| #78 | const balance = await onlineSdk.getCreatorVaultBalanceBothPrograms(creator); |
| #79 | ``` |
| #80 | |
| #81 | ## Key Constants |
| #82 | |
| #83 | | Constant | Value | Description | |
| #84 | |----------|-------|-------------| |
| #85 | | `PUMP_PROGRAM_ID` | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` | Bonding curve program | |
| #86 | | `PUMP_AMM_PROGRAM_ID` | `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` | AMM pool program | |
| #87 | | `PUMP_FEE_PROGRAM_ID` | `pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ` | Fee sharing program | |
| #88 | | `BONDING_CURVE_NEW_SIZE` | `151` | Extended account size | |
| #89 | |
| #90 | ## State Transition Diagram |
| #91 | |
| #92 | ``` |
| #93 | create |
| #94 | ────────────────────── ► ACTIVE (BondingCurve) |
| #95 | │ |
| #96 | buy / sell |
| #97 | │ |
| #98 | graduation |
| #99 | (complete = true) |
| #100 | │ |
| #101 | migrate |
| #102 | ▼ |
| #103 | GRADUATED (AMM Pool) |
| #104 | │ |
| #105 | AMM trading + fee collection |
| #106 | ``` |
| #107 | |
| #108 | ## Patterns to Follow |
| #109 | |
| #110 | - Return `TransactionInstruction[]`, never `Transaction` objects |
| #111 | - Use `getMultipleAccountsInfo` to batch RPC calls |
| #112 | - Check `bondingCurve.complete` before any bonding curve operation |
| #113 | - Use `fetchBuyState` / `fetchSellState` for efficient account fetching |
| #114 | - Always extend account before migration if needed |
| #115 | |
| #116 | ## Common Pitfalls |
| #117 | |
| #118 | - `BondingCurve.complete === true` means graduated — buy/sell will fail on-chain |
| #119 | - Creator vault PDAs differ: `"creator-vault"` (Pump, hyphen) vs `"creator_vault"` (AMM, underscore) |
| #120 | - `fetchSellState` requires ATA to exist (unlike `fetchBuyState`) |
| #121 | - Fee recipient is selected randomly from `global.feeRecipients[]` |
| #122 | |
| #123 |