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 | description: Buy and sell tokens on Pump.fun bonding curves and AMM pools |
| #3 | --- |
| #4 | |
| #5 | # PumpFun Trading |
| #6 | |
| #7 | Execute buy and sell trades on the Pump.fun protocol using the native Pump SDK. Supports both bonding curve trading (pre-graduation) and AMM pool trading (post-graduation). |
| #8 | |
| #9 | ## Prerequisites |
| #10 | |
| #11 | - Funded Solana wallet via `nanosolana birth` |
| #12 | - `HELIUS_RPC_URL` configured |
| #13 | - Understanding of bonding curve mechanics |
| #14 | |
| #15 | ## Trading Flow |
| #16 | |
| #17 | ### 1. Check Token State |
| #18 | |
| #19 | Before trading, always check if the token is on the bonding curve or has graduated: |
| #20 | |
| #21 | ```typescript |
| #22 | const sdk = new OnlinePumpSdk(connection); |
| #23 | const summary = await sdk.fetchBondingCurveSummary(mint); |
| #24 | |
| #25 | if (summary.isGraduated) { |
| #26 | // Use AMM trading instructions |
| #27 | } else { |
| #28 | // Use bonding curve trading instructions |
| #29 | } |
| #30 | ``` |
| #31 | |
| #32 | ### 2. Buy on Bonding Curve |
| #33 | |
| #34 | ```typescript |
| #35 | import { OnlinePumpSdk, getBuyTokenAmountFromSolAmount } from "nanosolana"; |
| #36 | import BN from "bn.js"; |
| #37 | |
| #38 | const sdk = new OnlinePumpSdk(connection); |
| #39 | |
| #40 | // Fetch state |
| #41 | const [buyState, global, feeConfig] = await Promise.all([ |
| #42 | sdk.fetchBuyState(mint, user), |
| #43 | sdk.fetchGlobal(), |
| #44 | sdk.fetchFeeConfig(), |
| #45 | ]); |
| #46 | |
| #47 | // Calculate expected tokens |
| #48 | const solAmount = new BN(100_000_000); // 0.1 SOL |
| #49 | const expectedTokens = getBuyTokenAmountFromSolAmount({ |
| #50 | global, feeConfig, |
| #51 | mintSupply: buyState.bondingCurve.tokenTotalSupply, |
| #52 | bondingCurve: buyState.bondingCurve, |
| #53 | amount: solAmount, |
| #54 | }); |
| #55 | |
| #56 | // Build instructions |
| #57 | const buyIxs = await sdk.buyInstructions({ |
| #58 | ...buyState, mint, user, |
| #59 | amount: expectedTokens, |
| #60 | solAmount, |
| #61 | slippage: 0.05, // 5% |
| #62 | }); |
| #63 | ``` |
| #64 | |
| #65 | ### 3. Sell on Bonding Curve |
| #66 | |
| #67 | ```typescript |
| #68 | import { getSellSolAmountFromTokenAmount } from "nanosolana"; |
| #69 | |
| #70 | const [sellState, global, feeConfig] = await Promise.all([ |
| #71 | sdk.fetchSellState(mint, user), |
| #72 | sdk.fetchGlobal(), |
| #73 | sdk.fetchFeeConfig(), |
| #74 | ]); |
| #75 | |
| #76 | const tokenAmount = new BN(1_000_000_000); |
| #77 | const expectedSol = getSellSolAmountFromTokenAmount({ |
| #78 | global, feeConfig, |
| #79 | mintSupply: sellState.bondingCurve.tokenTotalSupply, |
| #80 | bondingCurve: sellState.bondingCurve, |
| #81 | amount: tokenAmount, |
| #82 | }); |
| #83 | |
| #84 | const sellIxs = await sdk.sellInstructions({ |
| #85 | ...sellState, mint, user, |
| #86 | amount: tokenAmount, |
| #87 | solAmount: expectedSol, |
| #88 | slippage: 0.05, |
| #89 | }); |
| #90 | ``` |
| #91 | |
| #92 | ## Risk Management |
| #93 | |
| #94 | | Control | Value | |
| #95 | |---------|-------| |
| #96 | | Always use slippage | 3-5% recommended | |
| #97 | | Check `bondingCurve.complete` | Before trading | |
| #98 | | Use `BN` for all amounts | Never use JS `number` | |
| #99 | | Max position per trade | Follow Kelly Criterion | |
| #100 | | Circuit breaker | -10% daily → pause 24h | |
| #101 | |
| #102 | ## Integration with Swarm |
| #103 | |
| #104 | Swarm agents with the `sniper`, `momentum`, and `graduation` roles use this skill automatically via the OODA trading loop. |
| #105 |