An Anchor-based CPI adapter that exposes exact SOL input buy execution for the Pump.fun program.
This program intentionally supports a single execution model: exact SOL in. All other swap variants are rejected.
pump-cpi-adapter is a minimal on-chain adapter intended to be invoked via CPI.
It wraps Pump.fun buy logic while enforcing explicit and deterministic execution
semantics.
The adapter does not perform price calculations, token amount estimation, or slippage handling. These responsibilities are delegated to the underlying Pump program.
Executes a Pump.fun buy using an exact amount of SOL as input.
- The caller specifies the amount of SOL to spend
- Token output is determined by the Pump program
- Optional volume tracking can be enabled
- Token accounts are created deterministically if required
All other instruction variants return an error.
All successful executions of pump_buy_exact_sol_in follow the same fixed
instruction sequence. This order is mandatory and must not be altered.
1. System Program: createAccountWithSeed
2. Token-2022 Program: initializeAccount3
3. Pump.fun Program: buy_exact_sol_in
-
createAccountWithSeed
Creates the user token account deterministically using a seed. The account is funded with the minimum rent-exempt balance and owned by the Token-2022 program. -
initializeAccount3
Initializes the newly created token account for the specified mint using Token-2022. Account size is computed dynamically based on mint extensions. -
buy_exact_sol_in
Executes the Pump.fun buy instruction using an exact SOL input amount. Token output, fees, and volume tracking are handled by the Pump program.
If any step fails, execution aborts and no subsequent instructions are invoked.
The following entrypoints exist but are intentionally disabled:
pump_buypump_sellamm_buyamm_sell
These functions always return ExactSolOnly.
- Token accounts are created using
create_account_with_seed - Token-2022 is required
- Account size is computed dynamically based on mint extensions
- Accounts are initialized using
initialize_account3
- CPI instructions are constructed manually
- Anchor CPI macros are not used
- Fee configuration and volume accumulator accounts are passed through unchanged
- The adapter performs no custody or balance management
This program is intended to be called via CPI by:
- On-chain routing programs
- Automated trading systems
- Backend-controlled Solana programs
It is not designed for direct user interaction.
- The program does not store funds
- All SOL movement occurs in the downstream Pump program
- Unsupported execution paths fail fast
- Correct account wiring is the responsibility of the caller
This adapter is experimental and may change. No backward compatibility guarantees are provided.
MIT