3 releases
| 0.1.2 | Jul 12, 2025 |
|---|---|
| 0.1.1 | Jul 12, 2025 |
| 0.1.0 | Jul 11, 2025 |
#4 in #cpmm
40 downloads per month
49KB
714 lines
pinocchio-raydium-cpmm-cpi
Overview
This crate contains pinocchio helpers to perform cross-program invocations (CPIs) for Raydium CPMM instructions.
Each instruction defines a struct with the accounts and parameters required. Once all values are set, you can call directly invoke or invoke_signed to perform the CPI.
This is a no_std crate.
Note: The API defined in this crate is subject to change.
Examples
Initializing a CPMM pool:
// This example assumes that the instruction receives all required accounts
// for pool creation including creator, amm_config, authority, pool_state, etc.
InitializeCpmm {
creator,
amm_config,
authority,
pool_state,
token_0_mint,
token_1_mint,
lp_mint,
creator_token_0,
creator_token_1,
creator_lp_token,
token_0_vault,
token_1_vault,
create_pool_fee,
observation_state,
token_program,
token_0_program,
token_1_program,
associated_token_program,
system_program,
rent,
init_amount_0: 1000000,
init_amount_1: 1000000,
open_time: 1640995200, // Unix timestamp
}.invoke()?;
Performing a swap with base input:
// This example assumes that the instruction receives all required accounts
// for swapping including payer, authority, pool_state, token accounts, etc.
SwapBaseInput {
payer,
authority,
amm_config,
pool_state,
input_token_account,
output_token_account,
input_vault,
output_vault,
input_token_program,
output_token_program,
input_token_mint,
output_token_mint,
observation_state,
amount_in: 1000000, // Amount of input tokens to swap
minimum_amount_out: 950000, // Minimum output tokens expected
}.invoke()?;
License
The code is licensed under the Apache License Version 2.0
Dependencies
~3.5MB
~77K SLoC