feat(pump): add buy_v2, sell_v2, buy_exact_quote_in_v2 instruction builders
Support Pump.fun Bonding Curve v2 unified trading interface with quote_mint parameter for SOL-paired (WSOL) and USDC-paired coins. - Add BUY_V2, SELL_V2, BUY_EXACT_QUOTE_IN_V2 discriminators - Implement 27/26-account v2 instruction layouts matching official IDL - Add PumpFunParams::quote_mint and use_v2_ix fields (default legacy) - Add with_quote_mint() builder, buyback fee recipient pool, and PDA helpers - Legacy instructions remain default for backward compatibility Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
7ac07247a3
commit
12af055bff
@@ -74,7 +74,7 @@ This SDK is available in multiple languages:
|
||||
|
||||
## ✨ Features
|
||||
|
||||
1. **PumpFun Trading**: Support for `buy` and `sell` operations
|
||||
1. **PumpFun Trading**: Support for `buy`, `sell`, `buy_exact_sol_in`, and the new unified `buy_v2`/`sell_v2`/`buy_exact_quote_in_v2` instructions (SOL + USDC)
|
||||
2. **PumpSwap Trading**: Support for PumpSwap pool trading operations
|
||||
3. **Bonk Trading**: Support for Bonk trading operations
|
||||
4. **Raydium CPMM Trading**: Support for Raydium CPMM (Concentrated Pool Market Maker) trading operations
|
||||
@@ -335,6 +335,52 @@ PumpFun and PumpSwap support **cashback** for eligible tokens: part of the tradi
|
||||
- The **pumpfun_copy_trading** and **pumpfun_sniper_trading** examples use sol-parser-sdk for gRPC subscription and pass `e.is_cashback_coin` when building params.
|
||||
- **Claim**: Use `client.claim_cashback_pumpfun()` and `client.claim_cashback_pumpswap(...)` to claim accumulated cashback.
|
||||
|
||||
### Pump.fun Bonding Curve v2 (buy_v2 / sell_v2 / buy_exact_quote_in_v2)
|
||||
|
||||
Pump.fun has upgraded the Bonding Curve contract with **unified v2 instructions** that support both SOL-paired and USDC-paired coins through a single fixed account layout. The legacy `buy`/`sell`/`buy_exact_sol_in` instructions continue to work for SOL-paired coins and remain the default.
|
||||
|
||||
**Key changes in v2 instructions:**
|
||||
- `quote_mint` parameter — pass wrapped SOL (`So11111111111111111111111111111111111111112`) for SOL-paired, or USDC mint for USDC-paired
|
||||
- 27 fixed accounts (buy) / 26 fixed accounts (sell) — **no optional accounts**
|
||||
- `buyback_fee_recipient`, `sharing_config`, and 6 `associated_quote_*` ATAs are now mandatory
|
||||
- Same pricing and cost as legacy instructions for SOL-paired coins
|
||||
|
||||
**Using v2 instructions:**
|
||||
|
||||
To use v2 instructions, set `quote_mint` on your `PumpFunParams`. The SDK automatically switches to `buy_v2`/`sell_v2`/`buy_exact_quote_in_v2` discriminators and the 27/26-account layout:
|
||||
|
||||
```rust
|
||||
use sol_trade_sdk::constants::WSOL_TOKEN_ACCOUNT;
|
||||
use sol_trade_sdk::constants::USDC_TOKEN_ACCOUNT;
|
||||
|
||||
// SOL-paired coin (legacy bonding curves — use wrapped SOL mint)
|
||||
let params = PumpFunParams::from_trade(
|
||||
bonding_curve, associated_bonding_curve, mint, creator, creator_vault,
|
||||
virtual_token_reserves, virtual_sol_reserves,
|
||||
real_token_reserves, real_sol_reserves,
|
||||
close_token_account_when_sell, fee_recipient, token_program,
|
||||
is_cashback_coin, mayhem_mode,
|
||||
).with_quote_mint(WSOL_TOKEN_ACCOUNT); // enables use_v2_ix
|
||||
|
||||
// USDC-paired coin (coming soon — requires v2)
|
||||
let params = PumpFunParams::from_trade(/* ... */)
|
||||
.with_quote_mint(USDC_TOKEN_ACCOUNT);
|
||||
|
||||
// From RPC (auto-detects quote_mint when available)
|
||||
let params = PumpFunParams::from_mint_by_rpc(&rpc, &mint).await?
|
||||
.with_quote_mint(WSOL_TOKEN_ACCOUNT);
|
||||
|
||||
// Then trade as usual
|
||||
client.buy(buy_params).await?;
|
||||
client.sell(sell_params).await?;
|
||||
```
|
||||
|
||||
| Quote Mint | `use_v2_ix` | Instruction Used | Notes |
|
||||
|-----------|-------------|-----------------|-------|
|
||||
| Not set (default) | `false` | Legacy `buy`/`sell`/`buy_exact_sol_in` | Backward compatible, SOL-only |
|
||||
| `WSOL_TOKEN_ACCOUNT` | `true` | `buy_v2`/`sell_v2`/`buy_exact_quote_in_v2` | SOL-paired, unified layout |
|
||||
| `USDC_TOKEN_ACCOUNT` | `true` | `buy_v2`/`sell_v2`/`buy_exact_quote_in_v2` | USDC-paired (requires v2) |
|
||||
|
||||
#### PumpFun: Creator Rewards Sharing (creator_vault)
|
||||
|
||||
Some PumpFun coins use **Creator Rewards Sharing**, so the on-chain `creator_vault` can differ from the default derivation. If you reuse cached params from a **buy** when **selling**, you may see program error **2006 (seeds constraint violated)**. To avoid this:
|
||||
|
||||
Reference in New Issue
Block a user