Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

pump-cpi-adapter

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.


Overview

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.


Supported Instruction

pump_buy_exact_sol_in

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.


Execution Flow

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

Flow Details

  1. 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.

  2. initializeAccount3
    Initializes the newly created token account for the specified mint using Token-2022. Account size is computed dynamically based on mint extensions.

  3. 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.


Unsupported Instructions

The following entrypoints exist but are intentionally disabled:

  • pump_buy
  • pump_sell
  • amm_buy
  • amm_sell

These functions always return ExactSolOnly.


Token Account Handling

  • 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 Execution Model

  • 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

Intended Usage

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.


Security Notes

  • 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

Development Status

This adapter is experimental and may change. No backward compatibility guarantees are provided.


License

MIT

About

Anchor-based CPI adapter for Pump.fun that enforces exact SOL input execution.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages