PancakeSwap decoder
Decode PancakeSwap instructions, accounts and events in Rust with carbon-pancake-swap-decoder 2.0.0. Program ID HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq.
On this page
carbon-pancake-swap-decoder decodes the instructions, accounts and events of the PancakeSwap program (HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq): 27 instructions, 10 account types, 11 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-pancake-swap-decoder 2.0.0 |
| Install | cargo add carbon-pancake-swap-decoder@2. |
| Program ID | HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq (carbon_) |
| Category | DEX & AMM |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Event enum | instructions:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-pancake-swap-decoder/2.0.0 |
| Source | decoders/pancake-swap-decoder |
Other DEX and AMM decoders: BonkSwap, FluxBeam, Gavel, Heaven, Jupiter Limit Order, Jupiter Limit Order v2, Kamino Limit Order, Lifinity AMM v2, Meteora DAMM v2, Meteora DLMM, Meteora Pools, OpenBook v2, Orca Whirlpools, Phoenix v1, PumpSwap, Raydium AMM v4, Raydium CLMM, Raydium CPMM, Raydium Stable Swap, Stabble Stable Swap, Stabble Weighted Swap. To decode several in one pipeline, see dEX and AMM decoders.
The serde feature derives Serialize/Deserialize on every type, postgres adds tables and processors for Postgres, and graphql adds a schema for the GraphQL server.
Usage#
This program crawls recent PancakeSwap transactions from the public RPC and prints every decoded Swap instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-pancake-swap-decoder@2.0.0 carbon-rpc-transaction-crawler-datasource@2.0.0 carbon-log-metrics@2.0.0 env_logger tokio --features tokio/fulluse {
carbon_core::{
error::CarbonResult, instruction::InstructionProcessorInputType, pipeline::Pipeline,
processor::Processor,
},
carbon_log_metrics::LogMetrics,
carbon_pancake_swap_decoder::{
instructions::PancakeSwapInstruction, PancakeSwapDecoder, PROGRAM_ID,
},
carbon_rpc_transaction_crawler_datasource::{ConnectionConfig, Filters, RpcTransactionCrawler},
std::sync::Arc,
};
#[tokio::main]
async fn main() -> CarbonResult<()> {
env_logger::init();
// Fetches the program's recent transactions over JSON-RPC, newest first.
let datasource = RpcTransactionCrawler::new(
"https://api.mainnet-beta.solana.com".to_string(),
PROGRAM_ID,
ConnectionConfig::default(),
Filters::new(None, None, None),
None,
);
Pipeline::builder()
.datasource(datasource)
.metrics(Arc::new(LogMetrics::new()))
.instruction(PancakeSwapDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, PancakeSwapInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, PancakeSwapInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let PancakeSwapInstruction::Swap { data, accounts, .. } = input.decoded_instruction {
println!("swap {signature}: {data:?} payer={}", accounts.payer);
}
Ok(())
}
}RUST_LOG=info cargo runEach Swap instruction prints one line with the transaction signature and the decoded Swap data. The public endpoint rate-limits requests, so the first lines can take a while; use your own RPC URL for anything beyond a test. See stream with RPC for the crawler options.
Events published with Anchor's emit_cpi! arrive as the CpiEvent instruction. Match them with PancakeSwapInstruction:: (import instructions::); see Events. If CpiEvent never arrives, the program logs its events with emit! instead: decode them with decode_.
Decode accounts#
The transaction crawler emits transactions only. To decode accounts, use a datasource that emits account updates. This program subscribes to the program's accounts with programSubscribe on the public WebSocket endpoint and prints every decoded PoolState account as it changes. Add the datasource and the Solana RPC types it takes:
cargo add carbon-rpc-program-subscribe-datasource@2.0.0 solana-client@4.2.2use {
carbon_core::{
account::AccountProcessorInputType, error::CarbonResult, pipeline::Pipeline,
processor::Processor,
},
carbon_log_metrics::LogMetrics,
carbon_pancake_swap_decoder::{accounts::PancakeSwapAccount, PancakeSwapDecoder, PROGRAM_ID},
carbon_rpc_program_subscribe_datasource::{Filters, RpcProgramSubscribe},
solana_client::rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig, UiAccountEncoding},
std::sync::Arc,
};
#[tokio::main]
async fn main() -> CarbonResult<()> {
env_logger::init();
// Streams every change to an account owned by the program (programSubscribe).
let config = RpcProgramAccountsConfig {
account_config: RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
..Default::default()
},
..Default::default()
};
let datasource = RpcProgramSubscribe::new(
"wss://api.mainnet-beta.solana.com".to_string(),
Filters::new(PROGRAM_ID, Some(config)),
);
Pipeline::builder()
.datasource(datasource)
.metrics(Arc::new(LogMetrics::new()))
.account(PancakeSwapDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, PancakeSwapAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, PancakeSwapAccount>,
) -> CarbonResult<()> {
if let PancakeSwapAccount::PoolState(pool_state) = &input.decoded_account.data {
println!("pool_state {}: {pool_state:?}", input.metadata.pubkey);
}
Ok(())
}
}RUST_LOG=info cargo runEach update to a PoolState account prints its address and decoded fields; the program runs until you stop it. Cargo resolves solana-client to 4.2.2, the exact version the datasource pins, so both use the same RpcProgramAccountsConfig type. To load every existing account once instead of streaming changes, see load account state.
Instructions#
Variants of PancakeSwapInstruction. Each is PancakeSwapInstruction::, where data and accounts are the types listed under the variant, exported from carbon_. Discriminators are the leading bytes of the instruction data, in hex.
How an instruction decodes. The decoder returns a variant only when all of these hold; otherwise the instruction is skipped and no processor is called:
- The instruction's program ID is
HpNfyc2Saw7RKkQd8nEL4khUcuPhQ7WwY1B2qjx8jxFq. - The data starts with the variant's discriminator, and the rest deserializes into its data type.
- The instruction has at least as many accounts as the variant requires (the "Required accounts" count under each variant).
Accounts. They are matched by position, in the order listed. An account marked optional is None only when the instruction ends before it; Anchor programs pass the program ID as a placeholder for an omitted optional account, so check for Some(PROGRAM_ too. Accounts after the listed ones are in accounts. as AccountMetas. The decoder doesn't record whether an account signed or was writable: read that from input. and ., which follow the same order. It doesn't check signer, writable, owner or PDA constraints either; the program enforced those when the transaction executed, so a decoded instruction from a successful transaction already satisfied them.
ClosePosition#
From the program's IDL:
Close the user's position and NFT account. If the NFT mint belongs to token2022, it will also be closed and the funds returned to the NFT owner. # Arguments
ctx- The context of accounts
Discriminator 7b86510031446262 · data ClosePosition · accounts ClosePositionInstructionAccounts.
No data fields.
Required accounts: 6; extras go to remaining.
Fields of ClosePositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | personal_ | Pubkey |
| 4 | system_ | Pubkey |
| 5 | token_ | Pubkey |
| 6… | remaining | Vec< |
CollectFundFee#
From the program's IDL:
Collect the fund fee accrued to the pool
Arguments
ctx- The context of accountsamount_- The maximum amount of token_0 to send, can be 0 to collect fees in only token_10_ requested amount_- The maximum amount of token_1 to send, can be 0 to collect fees in only token_01_ requested
Discriminator a78a4e95dfc2067e · data CollectFundFee · accounts CollectFundFeeInstructionAccounts.
| Field | Type |
|---|---|
amount0_ | u64 |
amount1_ | u64 |
Required accounts: 11; extras go to remaining.
Fields of CollectFundFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | vault0_mint | Pubkey |
| 6 | vault1_mint | Pubkey |
| 7 | recipient_ | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11… | remaining | Vec< |
CollectProtocolFee#
From the program's IDL:
Collect the protocol fee accrued to the pool
Arguments
ctx- The context of accountsamount_- The maximum amount of token_0 to send, can be 0 to collect fees in only token_10_ requested amount_- The maximum amount of token_1 to send, can be 0 to collect fees in only token_01_ requested
Discriminator 8888fcddc2427e59 · data CollectProtocolFee · accounts CollectProtocolFeeInstructionAccounts.
| Field | Type |
|---|---|
amount0_ | u64 |
amount1_ | u64 |
Required accounts: 11; extras go to remaining.
Fields of CollectProtocolFeeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | pool_state | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | vault0_mint | Pubkey |
| 6 | vault1_mint | Pubkey |
| 7 | recipient_ | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11… | remaining | Vec< |
CollectRemainingRewards#
From the program's IDL:
Collect remaining reward token for reward founder
Arguments
ctx- The context of accountsreward_- the index to reward infoindex
Discriminator 12eda6c52210d590 · data CollectRemainingRewards · accounts CollectRemainingRewardsInstructionAccounts.
| Field | Type |
|---|---|
reward_ | u8 |
Required accounts: 8; extras go to remaining.
Fields of CollectRemainingRewardsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | reward_ | Pubkey |
| 1 | funder_ | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | reward_ | Pubkey |
| 4 | reward_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | memo_ | Pubkey |
| 8… | remaining | Vec< |
CreateAmmConfig#
From the program's IDL:
Arguments
ctx- The accounts needed by instruction.index- The index of amm config, there may be multiple config.tick_- The tickspacing binding with config, cannot be changed.spacing trade_- Trade fee rate, can be changed.fee_ rate protocol_- The rate of protocol fee within trade fee.fee_ rate fund_- The rate of fund fee within trade fee.fee_ rate
Discriminator 8934edd4d7756c68 · data CreateAmmConfig · accounts CreateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
index | u16 |
tick_ | u16 |
trade_ | u32 |
protocol_ | u32 |
fund_ | u32 |
Required accounts: 3; extras go to remaining.
Fields of CreateAmmConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
CreateOperationAccount#
From the program's IDL:
Creates an operation account for the program
Arguments
ctx- The context of accounts
Discriminator 3f5794216d230868 · data CreateOperationAccount · accounts CreateOperationAccountInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of CreateOperationAccountInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | operation_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
CreatePermissionlessFarmSwitch#
From the program's IDL:
Creates a permissionless farm switch account for the program
Arguments
ctx- The context of accounts
Discriminator 58f2c646f106c4fb · data CreatePermissionlessFarmSwitch · accounts CreatePermissionlessFarmSwitchInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of CreatePermissionlessFarmSwitchInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | permissionless_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
CreatePool#
From the program's IDL:
Creates a pool for the given token pair and the initial price
Arguments
ctx- The context of accountssqrt_- the initial sqrt price (amount_token_1 / amount_token_0) of the pool as a Q64.64price_ x64 Note: The open_time must be smaller than the current block_timestamp on chain.
Discriminator e992d18ecf6840bc · data CreatePool · accounts CreatePoolInstructionAccounts.
| Field | Type |
|---|---|
sqrt_ | u128 |
open_time | u64 |
Required accounts: 13; extras go to remaining.
Fields of CreatePoolInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | pool_ | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | token_mint0 | Pubkey |
| 4 | token_mint1 | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | system_ | Pubkey |
| 12 | rent | Pubkey |
| 13… | remaining | Vec< |
CreateSupportMintAssociated#
From the program's IDL:
Create support token22 mint account which can create pool and send rewards with ignoring the not support extensions.
Discriminator 11fb415c88f20ea9 · data CreateSupportMintAssociated · accounts CreateSupportMintAssociatedInstructionAccounts.
No data fields.
Required accounts: 4; extras go to remaining.
Fields of CreateSupportMintAssociatedInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | token_mint | Pubkey |
| 2 | support_ | Pubkey |
| 3 | system_ | Pubkey |
| 4… | remaining | Vec< |
DecreaseLiquidity#
From the program's IDL:
#[deprecated(note = "Usedecrease_liquidity_v2instead.Decreases liquidity for an existing position")] Arguments
ctx- The context of accountsliquidity- The amount by which liquidity will be decreasedamount_- The minimum amount of token_0 that should be accounted for the burned liquidity0_ min amount_- The minimum amount of token_1 that should be accounted for the burned liquidity1_ min
Discriminator a026d06f685b2c01 · data DecreaseLiquidity · accounts DecreaseLiquidityInstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_min | u64 |
amount1_min | u64 |
Required accounts: 12; extras go to remaining.
Fields of DecreaseLiquidityInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | personal_ | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | protocol_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | recipient_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
DecreaseLiquidityV2#
From the program's IDL:
Decreases liquidity for an existing position, support Token2022
Arguments
ctx- The context of accountsliquidity- The amount by which liquidity will be decreasedamount_- The minimum amount of token_0 that should be accounted for the burned liquidity0_ min amount_- The minimum amount of token_1 that should be accounted for the burned liquidity1_ min
Discriminator 3a7fbc3e4f52c460 · data DecreaseLiquidityV2 · accounts DecreaseLiquidityV2InstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_min | u64 |
amount1_min | u64 |
Required accounts: 16; extras go to remaining.
Fields of DecreaseLiquidityV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | personal_ | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | protocol_ | Pubkey |
| 5 | token_ | Pubkey |
| 6 | token_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | recipient_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | memo_ | Pubkey |
| 14 | vault0_mint | Pubkey |
| 15 | vault1_mint | Pubkey |
| 16… | remaining | Vec< |
IncreaseLiquidity#
From the program's IDL:
#[deprecated(note = "Useincrease_liquidity_v2instead.Increases liquidity for an existing position, with amount paid by")] payerArguments
ctx- The context of accountsliquidity- The desired liquidity to be added, can't be zeroamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max
Discriminator 2e9cf3760dcdfbb2 · data IncreaseLiquidity · accounts IncreaseLiquidityInstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
Required accounts: 12; extras go to remaining.
Fields of IncreaseLiquidityInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | protocol_ | Pubkey |
| 4 | personal_ | Pubkey |
| 5 | tick_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | token_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
IncreaseLiquidityV2#
From the program's IDL:
Increases liquidity for an existing position, with amount paid by
payer, support Token2022 # Arguments
ctx- The context of accountsliquidity- The desired liquidity to be added, if zero, calculate liquidity base amount_0 or amount_1 according base_flagamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max base_flag- must be specified if liquidity is zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 851d59df45eeb00a · data IncreaseLiquidityV2 · accounts IncreaseLiquidityV2InstructionAccounts.
| Field | Type |
|---|---|
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
base_flag | Option< |
Required accounts: 15; extras go to remaining.
Fields of IncreaseLiquidityV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | nft_owner | Pubkey |
| 1 | nft_account | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | protocol_ | Pubkey |
| 4 | personal_ | Pubkey |
| 5 | tick_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | token_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | vault0_mint | Pubkey |
| 14 | vault1_mint | Pubkey |
| 15… | remaining | Vec< |
InitializeReward#
From the program's IDL:
Initialize a reward info for a given pool and reward index
Arguments
ctx- The context of accountsreward_- the index to reward infoindex open_time- reward open timestampend_time- reward end timestampemissions_- Token reward per second are earned per unit of liquidity.per_ second_ x64
Discriminator 5f87c0c4f281e644 · data InitializeReward · accounts InitializeRewardInstructionAccounts.
| Field | Type |
|---|---|
param | InitializeRewardParam |
Required accounts: 11; extras go to remaining.
Fields of InitializeRewardInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | reward_ | Pubkey |
| 1 | funder_ | Pubkey |
| 2 | amm_config | Pubkey |
| 3 | pool_state | Pubkey |
| 4 | operation_ | Pubkey |
| 5 | permissionless_ | Pubkey |
| 6 | reward_ | Pubkey |
| 7 | reward_ | Pubkey |
| 8 | reward_ | Pubkey |
| 9 | system_ | Pubkey |
| 10 | rent | Pubkey |
| 11… | remaining | Vec< |
OpenPosition#
From the program's IDL:
#[deprecated(note = "Useopen_position_with_token22_nftinstead.Creates a new position wrapped in a NFT")] Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which include tick lowarray_ lower_ start_ index tick_- The start index of tick array which include tick upperarray_ upper_ start_ index liquidity- The liquidity to be addedamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max
Discriminator 87802f4d0f98f031 · data OpenPosition · accounts OpenPositionInstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
Required accounts: 19; extras go to remaining.
Fields of OpenPositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | metadata_ | Pubkey |
| 5 | pool_state | Pubkey |
| 6 | protocol_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | personal_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | system_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | metadata_ | Pubkey |
| 19… | remaining | Vec< |
OpenPositionV2#
From the program's IDL:
#[deprecated(note = "Useopen_position_with_token22_nftinstead.Creates a new position wrapped in a NFT, support Token2022")] Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which include tick lowarray_ lower_ start_ index tick_- The start index of tick array which include tick upperarray_ upper_ start_ index liquidity- The liquidity to be added, if zero, and the base_flag is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidityamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max with_- The flag indicating whether to create NFT mint metadatametadata base_flag- if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 4db84ad67056f1c7 · data OpenPositionV2 · accounts OpenPositionV2InstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
with_ | bool |
base_flag | Option< |
Required accounts: 22; extras go to remaining.
Fields of OpenPositionV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | metadata_ | Pubkey |
| 5 | pool_state | Pubkey |
| 6 | protocol_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | tick_ | Pubkey |
| 9 | personal_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | token_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | system_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | metadata_ | Pubkey |
| 19 | token_ | Pubkey |
| 20 | vault0_mint | Pubkey |
| 21 | vault1_mint | Pubkey |
| 22… | remaining | Vec< |
OpenPositionWithToken22Nft#
From the program's IDL:
Creates a new position wrapped in a Token2022 NFT without relying on metadata_program and metadata_account, reduce the cost for user to create a personal position. # Arguments
ctx- The context of accountstick_- The low boundary of marketlower_ index tick_- The upper boundary of marketupper_ index tick_- The start index of tick array which include tick lowarray_ lower_ start_ index tick_- The start index of tick array which include tick upperarray_ upper_ start_ index liquidity- The liquidity to be added, if zero, and the base_flag is specified, calculate liquidity base amount_0_max or amount_1_max according base_flag, otherwise open position with zero liquidityamount_- The max amount of token_0 to spend, which serves as a slippage check0_ max amount_- The max amount of token_1 to spend, which serves as a slippage check1_ max with_- The flag indicating whether to create NFT mint metadatametadata base_flag- if the liquidity specified as zero, true: calculate liquidity base amount_0_max otherwise base amount_1_max
Discriminator 4dffae527d1dc92e · data OpenPositionWithToken22Nft · accounts OpenPositionWithToken22NftInstructionAccounts.
| Field | Type |
|---|---|
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
tick_ | i32 |
liquidity | u128 |
amount0_max | u64 |
amount1_max | u64 |
with_ | bool |
base_flag | Option< |
Required accounts: 20; extras go to remaining.
Fields of OpenPositionWithToken22NftInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | position_ | Pubkey |
| 2 | position_ | Pubkey |
| 3 | position_ | Pubkey |
| 4 | pool_state | Pubkey |
| 5 | protocol_ | Pubkey |
| 6 | tick_ | Pubkey |
| 7 | tick_ | Pubkey |
| 8 | personal_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | token_ | Pubkey |
| 11 | token_ | Pubkey |
| 12 | token_ | Pubkey |
| 13 | rent | Pubkey |
| 14 | system_ | Pubkey |
| 15 | token_ | Pubkey |
| 16 | associated_ | Pubkey |
| 17 | token_ | Pubkey |
| 18 | vault0_mint | Pubkey |
| 19 | vault1_mint | Pubkey |
| 20… | remaining | Vec< |
SetRewardParams#
From the program's IDL:
Reset reward param, start a new reward cycle or extend the current cycle.
Arguments
ctx- The context of accountsreward_- The index of reward token in the pool.index emissions_- The per second emission reward, when extend the current cycle,per_ second_ x64 new value can't be less than old value
open_time- reward open timestamp, must be set when starting a new cycleend_time- reward end timestamp
Discriminator 7034a74b20c9d389 · data SetRewardParams · accounts SetRewardParamsInstructionAccounts.
| Field | Type |
|---|---|
reward_ | u8 |
emissions_ | u128 |
open_time | u64 |
end_time | u64 |
Required accounts: 6; extras go to remaining.
Fields of SetRewardParamsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | operation_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | token_ | Pubkey |
| 6… | remaining | Vec< |
Swap#
From the program's IDL:
#[deprecated(note = "Useswap_v2instead.Swaps one token for as much as possible of another token across a single pool # Arguments")]
ctx- The context of accountsamount- Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)other_- For slippage checkamount_ threshold sqrt_- The Q64.64 sqrt price √P limit. If zero for one, the price cannotprice_ limit is_- swap base input or swap base outputbase_ input
Discriminator f8c69e91e17587c8 · data Swap · accounts SwapInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
other_ | u64 |
sqrt_ | u128 |
is_ | bool |
Required accounts: 10; extras go to remaining.
Fields of SwapInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | input_ | Pubkey |
| 4 | output_ | Pubkey |
| 5 | input_vault | Pubkey |
| 6 | output_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | tick_array | Pubkey |
| 10… | remaining | Vec< |
SwapRouterBaseIn#
From the program's IDL:
Swap token for as much as possible of another token across the path provided, base input # Arguments
ctx- The context of accountsamount_in- Token amount to be swapped inamount_- Panic if output amount is below minimum amount. For slippage.out_ minimum
Discriminator 457d73daf5baf2c4 · data SwapRouterBaseIn · accounts SwapRouterBaseInInstructionAccounts.
| Field | Type |
|---|---|
amount_in | u64 |
amount_ | u64 |
Required accounts: 6; extras go to remaining.
Fields of SwapRouterBaseInInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | input_ | Pubkey |
| 2 | input_ | Pubkey |
| 3 | token_ | Pubkey |
| 4 | token_ | Pubkey |
| 5 | memo_ | Pubkey |
| 6… | remaining | Vec< |
SwapV2#
From the program's IDL:
Swaps one token for as much as possible of another token across a single pool, support token program 2022 # Arguments
ctx- The context of accountsamount- Arranged in pairs with other_amount_threshold. (amount_in, amount_out_minimum) or (amount_out, amount_in_maximum)other_- For slippage checkamount_ threshold sqrt_- The Q64.64 sqrt price √P limit. If zero for one, the price cannotprice_ limit is_- swap base input or swap base outputbase_ input
Discriminator 2b04ed0b1ac91e62 · data SwapV2 · accounts SwapV2InstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
other_ | u64 |
sqrt_ | u128 |
is_ | bool |
Required accounts: 13; extras go to remaining.
Fields of SwapV2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | payer | Pubkey |
| 1 | amm_config | Pubkey |
| 2 | pool_state | Pubkey |
| 3 | input_ | Pubkey |
| 4 | output_ | Pubkey |
| 5 | input_vault | Pubkey |
| 6 | output_ | Pubkey |
| 7 | observation_ | Pubkey |
| 8 | token_ | Pubkey |
| 9 | token_ | Pubkey |
| 10 | memo_ | Pubkey |
| 11 | input_ | Pubkey |
| 12 | output_ | Pubkey |
| 13… | remaining | Vec< |
TogglePermissionlessFarmSwitch#
From the program's IDL:
Toggle the permissionless farm switch account
Arguments
ctx- The context of accountsis_on- Is the permissionless farm allowed or not
Discriminator 967036e9eea10756 · data TogglePermissionlessFarmSwitch · accounts TogglePermissionlessFarmSwitchInstructionAccounts.
| Field | Type |
|---|---|
is_on | bool |
Required accounts: 3; extras go to remaining.
Fields of TogglePermissionlessFarmSwitchInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | permissionless_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
TransferRewardOwner#
From the program's IDL:
Transfer reward owner
Arguments
ctx- The context of accountsnew_owner- new owner pubkey
Discriminator 07160c53f22b3079 · data TransferRewardOwner · accounts TransferRewardOwnerInstructionAccounts.
| Field | Type |
|---|---|
new_owner | Pubkey |
Required accounts: 2; extras go to remaining.
Fields of TransferRewardOwnerInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | pool_state | Pubkey |
| 2… | remaining | Vec< |
UpdateAmmConfig#
From the program's IDL:
Updates the owner of the amm config
Must be called by the current owner or adminArguments
ctx- The context of accountstrade_- The new trade fee rate of amm config, be set whenfee_ rate paramis 0protocol_- The new protocol fee rate of amm config, be set whenfee_ rate paramis 1fund_- The new fund fee rate of amm config, be set whenfee_ rate paramis 2new_owner- The config's new owner, be set whenparamis 3new_- The config's new fund owner, be set whenfund_ owner paramis 4param- The value can be 0 | 1 | 2 | 3 | 4, otherwise will report a error
Discriminator 313cae889a1c74c8 · data UpdateAmmConfig · accounts UpdateAmmConfigInstructionAccounts.
| Field | Type |
|---|---|
param | u8 |
value | u32 |
Required accounts: 2; extras go to remaining.
Fields of UpdateAmmConfigInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | amm_config | Pubkey |
| 2… | remaining | Vec< |
UpdateOperationAccount#
From the program's IDL:
Update the operation account
Arguments
ctx- The context of accountsparam- The value can be 0 | 1 | 2 | 3, otherwise will report a errorkeys- update operation owner when theparamis 0remove operation owner when the
paramis 1 update whitelist mint when theparamis 2 remove whitelist mint when theparamis 3
Discriminator 7f467728bce33d07 · data UpdateOperationAccount · accounts UpdateOperationAccountInstructionAccounts.
| Field | Type |
|---|---|
param | u8 |
keys | Vec<Pubkey> |
Required accounts: 3; extras go to remaining.
Fields of UpdateOperationAccountInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | owner | Pubkey |
| 1 | operation_ | Pubkey |
| 2 | system_ | Pubkey |
| 3… | remaining | Vec< |
UpdatePoolStatus#
From the program's IDL:
Update pool status for given value
Arguments
ctx- The context of accountsstatus- The value of status
Discriminator 82576c062ee0757b · data UpdatePoolStatus · accounts UpdatePoolStatusInstructionAccounts.
| Field | Type |
|---|---|
status | u8 |
Required accounts: 2; extras go to remaining.
Fields of UpdatePoolStatusInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | pool_state | Pubkey |
| 2… | remaining | Vec< |
UpdateRewardInfos#
From the program's IDL:
Update rewards info of the given pool, can be called for everyone
Arguments
ctx- The context of accounts
Discriminator a3ace0340b9a6adf · data UpdateRewardInfos · accounts UpdateRewardInfosInstructionAccounts.
No data fields.
Required accounts: 1; extras go to remaining.
Fields of UpdateRewardInfosInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | pool_state | Pubkey |
| 1… | remaining | Vec< |
CpiEvent#
Anchor self-CPI that carries one of the program's events. data is the CpiEvent enum.
Discriminator e445a52e51cb9a1d · data CpiEvent · accounts CpiEventInstructionAccounts.
Required accounts: 2; extras go to remaining.
Fields of CpiEventInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | program | Pubkey |
| 1 | event_ | Pubkey |
| 2… | remaining | Vec< |
Accounts#
Variants of PancakeSwapAccount. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
AmmConfig#
Discriminator daf42168cbcb2b6f · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
index | u16 | |
owner | Pubkey | Address of the protocol owner |
protocol_ | u32 | The protocol fee |
trade_ | u32 | The trade fee, denominated in hundredths of a bip (10^-6) |
tick_ | u16 | The tick spacing |
fund_ | u32 | The fund fee, denominated in hundredths of a bip (10^-6) |
padding_u32 | u32 | |
fund_owner | Pubkey | |
padding | [u64; 3] |
ObservationState#
Discriminator 7aaec5358109a584 · accounts::.
| Field | Type | Description |
|---|---|---|
initialized | bool | Whether the ObservationState is initialized |
recent_ | u64 | recent update epoch |
observation_ | u16 | the most-recently updated index of the observations array |
pool_id | Pubkey | belongs to which pool |
observations | [Observation; 100] | observation array |
padding | [u64; 4] | padding for feature update |
OperationState#
Discriminator 13ec3aed51deb7fc · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
operation_ | [Pubkey; 10] | Address of the operation owner |
whitelist_ | [Pubkey; 100] | The mint address of whitelist to emit reward |
PermissionlessFarmSwitch#
Discriminator 255c934efa649389 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
is_on | bool | Is the permissionless farm allowed or not |
PersonalPositionState#
Discriminator 466f967ee60f1975 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | [u8; 1] | Bump to identify PDA |
nft_mint | Pubkey | Mint address of the tokenized position |
pool_id | Pubkey | The ID of the pool with which this token is connected |
tick_ | i32 | The lower bound tick of the position |
tick_ | i32 | The upper bound tick of the position |
liquidity | u128 | The amount of liquidity owned by this position |
fee_ | u128 | The token_0 fee growth of the aggregate position as of the last action on the individual position |
fee_ | u128 | The token_1 fee growth of the aggregate position as of the last action on the individual position |
token_ | u64 | The fees owed to the position owner in token_0, as of the last computation |
token_ | u64 | The fees owed to the position owner in token_1, as of the last computation |
reward_ | [PositionRewardInfo; 3] | |
recent_ | u64 | |
padding | [u64; 7] |
PoolState#
Discriminator f7ede3f5d7c3de46 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | [u8; 1] | Bump to identify PDA |
amm_config | Pubkey | |
owner | Pubkey | |
token_mint0 | Pubkey | Token pair of the pool, where token_mint_0 address < token_mint_1 address |
token_mint1 | Pubkey | |
token_ | Pubkey | Token pair vault |
token_ | Pubkey | |
observation_ | Pubkey | observation account key |
mint_ | u8 | mint0 and mint1 decimals |
mint_ | u8 | |
tick_ | u16 | The minimum number of ticks between initialized ticks |
liquidity | u128 | The currently in range liquidity available to the pool. |
sqrt_ | u128 | The current price of the pool as a sqrt(token_1/token_0) Q64.64 value |
tick_ | i32 | The current tick of the pool, i.e. according to the last tick transition that was run. |
padding3 | u16 | |
padding4 | u16 | |
fee_ | u128 | The fee growth as a Q64.64 number, i.e. fees of token_0 and token_1 collected per unit of liquidity for the entire life of the pool. |
fee_ | u128 | |
protocol_ | u64 | The amounts of token_0 and token_1 that are owed to the protocol. |
protocol_ | u64 | |
swap_ | u128 | The amounts in and out of swap token_0 and token_1 |
swap_ | u128 | |
swap_ | u128 | |
swap_ | u128 | |
status | u8 | Bitwise representation of the state of the pool bit0, 1: disable open position and increase liquidity, 0: normal bit1, 1: disable decrease liquidity, 0: normal bit2, 1: disable collect fee, 0: normal bit3, 1: disable collect reward, 0: normal bit4, 1: disable swap, 0: normal |
padding | [u8; 7] | Leave blank for future use |
reward_ | [RewardInfo; 3] | |
tick_ | [u64; 16] | Packed initialized tick array state |
total_ | u64 | except protocol_fee and fund_fee |
total_ | u64 | except protocol_fee and fund_fee |
total_ | u64 | |
total_ | u64 | |
fund_ | u64 | |
fund_ | u64 | |
open_time | u64 | |
recent_ | u64 | |
padding1 | [u64; 24] | |
padding2 | [u64; 32] |
ProtocolPositionState#
Discriminator 64e2916392daa06a · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
pool_id | Pubkey | The ID of the pool with which this token is connected |
tick_ | i32 | The lower bound tick of the position |
tick_ | i32 | The upper bound tick of the position |
liquidity | u128 | The amount of liquidity owned by this position |
fee_ | u128 | The token_0 fee growth per unit of liquidity as of the last update to liquidity or fees owed |
fee_ | u128 | The token_1 fee growth per unit of liquidity as of the last update to liquidity or fees owed |
token_ | u64 | The fees owed to the position owner in token_0 |
token_ | u64 | The fees owed to the position owner in token_1 |
reward_ | [u128; 3] | The reward growth per unit of liquidity as of the last update to liquidity |
recent_ | u64 | |
padding | [u64; 7] |
SupportMintAssociated#
Discriminator 8628b74f0c70a235 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | u8 | Bump to identify PDA |
mint | Pubkey | Address of the supported token22 mint |
padding | [u64; 8] |
TickArrayBitmapExtension#
Discriminator 3c9624db61808b99 · accounts::.
| Field | Type | Description |
|---|---|---|
pool_id | Pubkey | |
positive_ | [[u64; 8]; 14] | Packed initialized tick array state for start_tick_index is positive |
negative_ | [[u64; 8]; 14] | Packed initialized tick array state for start_tick_index is negitive |
TickArrayState#
Discriminator c09b55cd31f9812a · accounts::.
| Field | Type |
|---|---|
pool_id | Pubkey |
start_ | i32 |
ticks | [TickState; 60] |
initialized_ | u8 |
recent_ | u64 |
padding | [u8; 107] |
Events#
Variants of instructions::, decoded from the CpiEvent instruction. Each wraps a struct from carbon_. The discriminator is the 8-byte event discriminator that follows the e445a52e51cb9a1d CPI-event tag.
CollectPersonalFeeEvent#
Discriminator a6ae69c051a15369 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which underlying tokens were collected |
recipient_ | Pubkey | The token account that received the collected token_0 tokens |
recipient_ | Pubkey | The token account that received the collected token_1 tokens |
amount0 | u64 | The amount of token_0 owed to the position that was collected |
amount1 | u64 | The amount of token_1 owed to the position that was collected |
CollectProtocolFeeEvent#
Discriminator ce57114f2d29d53d · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool whose protocol fee is collected |
recipient_ | Pubkey | The address that receives the collected token_0 protocol fees |
recipient_ | Pubkey | The address that receives the collected token_1 protocol fees |
amount0 | u64 | The amount of token_0 protocol fees that is withdrawn |
amount1 | u64 | The amount of token_0 protocol fees that is withdrawn |
ConfigChangeEvent#
Discriminator f7bd07776a705f97 · events::.
| Field | Type |
|---|---|
index | u16 |
owner | Pubkey |
protocol_ | u32 |
trade_ | u32 |
tick_ | u16 |
fund_ | u32 |
fund_owner | Pubkey |
CreatePersonalPositionEvent#
Discriminator 641e57f9c4df9ace · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for which liquidity was added |
minter | Pubkey | The address that create the position |
nft_owner | Pubkey | The owner of the position and recipient of any minted liquidity |
tick_ | i32 | The lower tick of the position |
tick_ | i32 | The upper tick of the position |
liquidity | u128 | The amount of liquidity minted to the position range |
deposit_ | u64 | The amount of token_0 was deposit for the liquidity |
deposit_ | u64 | The amount of token_1 was deposit for the liquidity |
deposit_ | u64 | The token transfer fee for deposit_amount_0 |
deposit_ | u64 | The token transfer fee for deposit_amount_1 |
DecreaseLiquidityEvent#
Discriminator 3ade563a44325538 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which liquidity was decreased |
liquidity | u128 | The amount by which liquidity for the position was decreased |
decrease_ | u64 | The amount of token_0 that was paid for the decrease in liquidity |
decrease_ | u64 | The amount of token_1 that was paid for the decrease in liquidity |
fee_amount0 | u64 | |
fee_amount1 | u64 | The amount of token_1 fee |
reward_ | [u64; 3] | The amount of rewards |
transfer_ | u64 | The amount of token_0 transfer fee |
transfer_ | u64 | The amount of token_1 transfer fee |
IncreaseLiquidityEvent#
Discriminator 314f69d420221e54 · events::.
| Field | Type | Description |
|---|---|---|
position_ | Pubkey | The ID of the token for which liquidity was increased |
liquidity | u128 | The amount by which liquidity for the NFT position was increased |
amount0 | u64 | The amount of token_0 that was paid for the increase in liquidity |
amount1 | u64 | The amount of token_1 that was paid for the increase in liquidity |
amount0_ | u64 | The token transfer fee for amount_0 |
amount1_ | u64 | The token transfer fee for amount_1 |
LiquidityCalculateEvent#
Discriminator ed7094e63954b4a2 · events::.
| Field | Type | Description |
|---|---|---|
pool_ | u128 | The pool liquidity before decrease or increase |
pool_ | u128 | The pool price when decrease or increase in liquidity |
pool_tick | i32 | The pool tick when decrease or increase in liquidity |
calc_ | u64 | The amount of token_0 that was calculated for the decrease or increase in liquidity |
calc_ | u64 | The amount of token_1 that was calculated for the decrease or increase in liquidity |
trade_ | u64 | |
trade_ | u64 | The amount of token_1 fee |
transfer_ | u64 | The amount of token_0 transfer fee without trade_fee_amount_0 |
transfer_ | u64 | The amount of token_1 transfer fee without trade_fee_amount_0 |
LiquidityChangeEvent#
Discriminator 7ef0afce9e58996b · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for swap |
tick | i32 | The tick of the pool |
tick_lower | i32 | The tick lower of position |
tick_upper | i32 | The tick lower of position |
liquidity_ | u128 | The liquidity of the pool before liquidity change |
liquidity_ | u128 | The liquidity of the pool after liquidity change |
PoolCreatedEvent#
Discriminator 195e4b2f7063353f · events::.
| Field | Type | Description |
|---|---|---|
token_mint0 | Pubkey | The first token of the pool by address sort order |
token_mint1 | Pubkey | The second token of the pool by address sort order |
tick_ | u16 | The minimum number of ticks between initialized ticks |
pool_state | Pubkey | The address of the created pool |
sqrt_ | u128 | The initial sqrt price of the pool, as a Q64.64 |
tick | i32 | The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool |
token_ | Pubkey | Vault of token_0 |
token_ | Pubkey | Vault of token_1 |
SwapEvent#
Discriminator 40c6cde8260871e2 · events::.
| Field | Type | Description |
|---|---|---|
pool_state | Pubkey | The pool for which token_0 and token_1 were swapped |
sender | Pubkey | The address that initiated the swap call, and that received the callback |
token_ | Pubkey | The payer token account in zero for one swaps, or the recipient token account in one for zero swaps |
token_ | Pubkey | The payer token account in one for zero swaps, or the recipient token account in zero for one swaps |
amount0 | u64 | The real delta amount of the token_0 of the pool or user |
transfer_ | u64 | The transfer fee charged by the withheld_amount of the token_0 |
amount1 | u64 | The real delta of the token_1 of the pool or user |
transfer_ | u64 | The transfer fee charged by the withheld_amount of the token_1 |
zero_ | bool | if true, amount_0 is negtive and amount_1 is positive |
sqrt_ | u128 | The sqrt(price) of the pool after the swap, as a Q64.64 |
liquidity | u128 | The liquidity of the pool after the swap |
tick | i32 | The log base 1.0001 of price of the pool after the swap |
UpdateRewardInfosEvent#
Discriminator 6d7fba4e724125ec · events::.
| Field | Type | Description |
|---|---|---|
reward_ | [u128; 3] | Reward info |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
CollectPersonalFeeEvent#
From the program's IDL:
Emitted when tokens are collected for a position
Struct types::. Same fields as the CollectPersonalFeeEvent event.
CollectProtocolFeeEvent#
From the program's IDL:
Emitted when the collected protocol fees are withdrawn by the factory owner
Struct types::. Same fields as the CollectProtocolFeeEvent event.
ConfigChangeEvent#
From the program's IDL:
Emitted when create or update a config
Struct types::. Same fields as the ConfigChangeEvent event.
CreatePersonalPositionEvent#
From the program's IDL:
Emitted when create a new position
Struct types::. Same fields as the CreatePersonalPositionEvent event.
DecreaseLiquidityEvent#
From the program's IDL:
Emitted when liquidity is decreased.
Struct types::. Same fields as the DecreaseLiquidityEvent event.
IncreaseLiquidityEvent#
From the program's IDL:
Emitted when liquidity is increased.
Struct types::. Same fields as the IncreaseLiquidityEvent event.
InitializeRewardParam#
Struct types::.
| Field | Type | Description |
|---|---|---|
open_time | u64 | Reward open time |
end_time | u64 | Reward end time |
emissions_ | u128 | Token reward per second are earned per unit of liquidity |
LiquidityCalculateEvent#
From the program's IDL:
Emitted when liquidity decreased or increase.
Struct types::. Same fields as the LiquidityCalculateEvent event.
LiquidityChangeEvent#
From the program's IDL:
Emitted pool liquidity change when increase and decrease liquidity
Struct types::. Same fields as the LiquidityChangeEvent event.
Observation#
From the program's IDL:
The element of observations in ObservationState
Struct types::.
| Field | Type | Description |
|---|---|---|
block_ | u32 | The block timestamp of the observation |
tick_ | i64 | the cumulative of tick during the duration time |
padding | [u64; 4] | padding for feature update |
PoolCreatedEvent#
From the program's IDL:
Emitted when a pool is created and initialized with a starting price
Struct types::. Same fields as the PoolCreatedEvent event.
PositionRewardInfo#
Struct types::.
| Field | Type |
|---|---|
growth_ | u128 |
reward_ | u64 |
RewardInfo#
Struct types::.
| Field | Type | Description |
|---|---|---|
reward_ | u8 | Reward state |
open_time | u64 | Reward open time |
end_time | u64 | Reward end time |
last_ | u64 | Reward last update time |
emissions_ | u128 | Q64.64 number indicates how many tokens per second are earned per unit of liquidity. |
reward_ | u64 | The total amount of reward emissioned |
reward_ | u64 | The total amount of claimed reward |
token_mint | Pubkey | Reward token mint. |
token_vault | Pubkey | Reward vault token account. |
authority | Pubkey | The owner that has permission to set reward param |
reward_ | u128 | Q64.64 number that tracks the total tokens earned per unit of liquidity since the reward emissions were turned on. |
SwapEvent#
From the program's IDL:
Emitted by when a swap is performed for a pool
Struct types::. Same fields as the SwapEvent event.
TickState#
Struct types::.
| Field | Type | Description |
|---|---|---|
tick | i32 | |
liquidity_ | i128 | Amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left) |
liquidity_ | u128 | The total position liquidity that references this tick |
fee_ | u128 | Fee growth per unit of liquidity on the other side of this tick (relative to the current tick) only has relative meaning, not absolute — the value depends on when the tick is initialized |
fee_ | u128 | |
reward_ | [u128; 3] | |
padding | [u32; 13] |
UpdateRewardInfosEvent#
From the program's IDL:
Emitted when Reward are updated for a pool
Struct types::. Same fields as the UpdateRewardInfosEvent event.