Raydium Liquidity Locking decoder
Decode Raydium Liquidity Locking instructions, accounts and events in Rust with the carbon-raydium-liquidity-locking-decoder crate.
On this page
carbon-raydium-liquidity-locking-decoder decodes the instructions, accounts and events of the Raydium Liquidity Locking program (LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE): 4 instructions, 2 account types, 1 event. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-raydium-liquidity-locking-decoder 2.0.0 |
| Install | cargo add carbon-raydium-liquidity-locking-decoder@2. |
| Program ID | LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE (carbon_) |
| Category | Other |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Event enum | instructions:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-raydium-liquidity-locking-decoder/2.0.0 |
| Source | decoders/raydium-liquidity-locking-decoder |
More program decoders without a category: Jupiter DCA, Kamino Farms, Pump Fees, Swig. To decode several in one pipeline, see other program 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 Raydium Liquidity Locking transactions from the public RPC and prints every decoded CollectClmmFeesAndRewards instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-raydium-liquidity-locking-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_raydium_liquidity_locking_decoder::{
instructions::RaydiumLiquidityLockingInstruction, RaydiumLiquidityLockingDecoder,
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(RaydiumLiquidityLockingDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, RaydiumLiquidityLockingInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, RaydiumLiquidityLockingInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let RaydiumLiquidityLockingInstruction::CollectClmmFeesAndRewards { data, accounts, .. } = input.decoded_instruction {
println!("collect_clmm_fees_and_rewards {signature}: {data:?} authority={}", accounts.authority);
}
Ok(())
}
}RUST_LOG=info cargo runEach CollectClmmFeesAndRewards instruction prints one line with the transaction signature and the decoded CollectClmmFeesAndRewards 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 RaydiumLiquidityLockingInstruction:: (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 LockedClmmPositionState 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_raydium_liquidity_locking_decoder::{
accounts::RaydiumLiquidityLockingAccount, RaydiumLiquidityLockingDecoder, 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(RaydiumLiquidityLockingDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, RaydiumLiquidityLockingAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, RaydiumLiquidityLockingAccount>,
) -> CarbonResult<()> {
if let RaydiumLiquidityLockingAccount::LockedClmmPositionState(locked_clmm_position_state) = &input.decoded_account.data {
println!("locked_clmm_position_state {}: {locked_clmm_position_state:?}", input.metadata.pubkey);
}
Ok(())
}
}RUST_LOG=info cargo runEach update to a LockedClmmPositionState 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 RaydiumLiquidityLockingInstruction. Each is RaydiumLiquidityLockingInstruction::, 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
LockrWmn6K5twhz3y9w1dQERbmgSaRkfnTeTKbpofwE. - 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.
CollectClmmFeesAndRewards#
From the program's IDL:
collect clmm locked postion fees and rewards
Arguments
ctx- The context of accounts
Discriminator 1048fac60ea2d413 · data CollectClmmFeesAndRewards · accounts CollectClmmFeesAndRewardsInstructionAccounts.
No data fields.
Required accounts: 20; extras go to remaining.
Fields of CollectClmmFeesAndRewardsInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | fee_ | Pubkey |
| 2 | fee_ | Pubkey |
| 3 | locked_ | Pubkey |
| 4 | clmm_ | Pubkey |
| 5 | locked_ | Pubkey |
| 6 | personal_ | Pubkey |
| 7 | pool_state | Pubkey |
| 8 | protocol_ | Pubkey |
| 9 | token0_ | Pubkey |
| 10 | token1_ | Pubkey |
| 11 | tick_ | Pubkey |
| 12 | tick_ | Pubkey |
| 13 | recipient_ | Pubkey |
| 14 | recipient_ | Pubkey |
| 15 | token_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | memo_ | Pubkey |
| 18 | vault0_mint | Pubkey |
| 19 | vault1_mint | Pubkey |
| 20… | remaining | Vec< |
CollectCpFees#
From the program's IDL:
collect cpSwap locked liquidity's fees
Arguments
ctx- The context of accountsfee_- The amount lp want to claimlp_ amount
Discriminator 081e33c7d1b8f785 · data CollectCpFees · accounts CollectCpFeesInstructionAccounts.
| Field | Type |
|---|---|
fee_ | u64 |
Required accounts: 18; extras go to remaining.
Fields of CollectCpFeesInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | fee_ | Pubkey |
| 2 | fee_ | Pubkey |
| 3 | locked_ | Pubkey |
| 4 | cp_ | Pubkey |
| 5 | cp_ | Pubkey |
| 6 | pool_state | Pubkey |
| 7 | lp_mint | Pubkey |
| 8 | recipient_ | Pubkey |
| 9 | recipient_ | Pubkey |
| 10 | token0_ | Pubkey |
| 11 | token1_ | Pubkey |
| 12 | vault0_mint | Pubkey |
| 13 | vault1_mint | Pubkey |
| 14 | locked_ | Pubkey |
| 15 | token_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | memo_ | Pubkey |
| 18… | remaining | Vec< |
LockClmmPosition#
From the program's IDL:
Lock an existing clmm's position
Arguments
ctx- The context of accountswith_- Create NFT with metadata or notmetadata
Discriminator bc25b38352965449 · data LockClmmPosition · accounts LockClmmPositionInstructionAccounts.
| Field | Type |
|---|---|
with_ | bool |
Required accounts: 18; extras go to remaining.
Fields of LockClmmPositionInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | payer | Pubkey |
| 2 | position_ | Pubkey |
| 3 | fee_ | Pubkey |
| 4 | position_ | Pubkey |
| 5 | personal_ | Pubkey |
| 6 | position_ | Pubkey |
| 7 | locked_ | Pubkey |
| 8 | locked_ | Pubkey |
| 9 | fee_ | Pubkey |
| 10 | fee_ | Pubkey |
| 11 | metadata_ | Pubkey |
| 12 | metadata_ | Pubkey |
| 13 | associated_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | fee_ | Pubkey |
| 16 | locked_ | Pubkey |
| 17 | system_ | Pubkey |
| 18… | remaining | Vec< |
LockCpLiquidity#
From the program's IDL:
Lock cpSwap liquidity and mint a nft to collect locked liquidity's fee.
Arguments
ctx- The context of accountslp_amount- The lp amount to lockwith_- Create NFT with metadata or notmetadata
Discriminator d89d1d4e26331f1a · data LockCpLiquidity · accounts LockCpLiquidityInstructionAccounts.
| Field | Type |
|---|---|
lp_amount | u64 |
with_ | bool |
Required accounts: 19; extras go to remaining.
Fields of LockCpLiquidityInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | authority | Pubkey |
| 1 | payer | Pubkey |
| 2 | liquidity_ | Pubkey |
| 3 | fee_ | Pubkey |
| 4 | fee_ | Pubkey |
| 5 | fee_ | Pubkey |
| 6 | pool_state | Pubkey |
| 7 | locked_ | Pubkey |
| 8 | lp_mint | Pubkey |
| 9 | liquidity_ | Pubkey |
| 10 | locked_ | Pubkey |
| 11 | token0_ | Pubkey |
| 12 | token1_ | Pubkey |
| 13 | metadata_ | Pubkey |
| 14 | rent | Pubkey |
| 15 | system_ | Pubkey |
| 16 | token_ | Pubkey |
| 17 | associated_ | Pubkey |
| 18 | metadata_ | Pubkey |
| 19… | 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 RaydiumLiquidityLockingAccount. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
LockedClmmPositionState#
Discriminator 34170507aa5a6cd5 · accounts::.
| Field | Type | Description |
|---|---|---|
bump | [u8; 1] | Bump to identify PDA |
position_ | Pubkey | The owner who has locked clmm NFT |
pool_id | Pubkey | The ID of the pool with which this record is connected |
position_id | Pubkey | The ID of the position with which this record is connected |
locked_ | Pubkey | Program ATA locked NFT account or user ATA position NFT account |
fee_ | Pubkey | nft mint to check who has authority to collect fee |
recent_ | u64 | account update recent epoch |
padding | [u64; 8] | Unused bytes for future upgrades. |
LockedCpLiquidityState#
Discriminator 190aeec5cfea4916 · accounts::.
| Field | Type | Description |
|---|---|---|
locked_ | u64 | The Locked liquidity amount without claimed lp fee |
claimed_ | u64 | Claimed lp fee amount |
unclaimed_ | u64 | Unclaimed lp fee amount |
last_lp | u64 | Last updated cp pool lp total supply |
last_k | u128 | Last updated cp pool k |
recent_ | u64 | Account update recent epoch |
pool_id | Pubkey | The ID of the pool with which this record is connected |
fee_ | Pubkey | nft mint to check who has authority to collect fee |
locked_ | Pubkey | The owner who has locked liquidity |
locked_ | Pubkey | The mint of locked lp token |
padding | [u64; 8] | Unused bytes for future upgrades. |
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.
SettleCpFeeEvent#
Discriminator 1d4ea505f6a75bf4 · events::.
| Field | Type |
|---|---|
delta_ | u64 |
unclaimed_ | u64 |
locked_ | u64 |
curr_ | u64 |
last_ | u64 |
curr_k | u128 |
last_k | u128 |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
SettleCpFeeEvent#
Struct types::. Same fields as the SettleCpFeeEvent event.