Meteora Vault decoder
Decode Meteora Vault instructions, accounts and events in Rust with carbon-meteora-vault-decoder 2.0.0. Program ID 24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi.
On this page
carbon-meteora-vault-decoder decodes the instructions, accounts and events of the Meteora Vault program (24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi): 14 instructions, 2 account types, 8 events. It is generated with Codama from the program's IDL; see decoders for how decoders plug into a pipeline.
| Crate | carbon-meteora-vault-decoder 2.0.0 |
| Install | cargo add carbon-meteora-vault-decoder@2. |
| Program ID | 24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi (carbon_) |
| Category | Lending |
| Decoder | carbon_ |
| Instruction enum | instructions:: |
| Account enum | accounts:: |
| Event enum | instructions:: |
| Features | serde, postgres, graphql (none enabled by default) |
| API docs | docs.rs/carbon-meteora-vault-decoder/2.0.0 |
| Source | decoders/meteora-vault-decoder |
Other lending decoders: Jupiter Lend, Kamino Lending, Kamino Vault, marginfi v2, Sharky. To decode several in one pipeline, see lending 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 Meteora Vault transactions from the public RPC and prints every decoded Deposit instruction. Add the dependencies:
cargo add carbon-core@2.0.0 carbon-meteora-vault-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_meteora_vault_decoder::{
instructions::MeteoraVaultInstruction, MeteoraVaultDecoder, 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(MeteoraVaultDecoder, InstructionLogger)
.build()?
.run()
.await
}
struct InstructionLogger;
impl Processor<InstructionProcessorInputType<'_, MeteoraVaultInstruction>> for InstructionLogger {
async fn process(
&mut self,
input: &InstructionProcessorInputType<'_, MeteoraVaultInstruction>,
) -> CarbonResult<()> {
let signature = input.metadata.transaction_metadata.signature;
if let MeteoraVaultInstruction::Deposit { data, accounts, .. } = input.decoded_instruction {
println!("deposit {signature}: {data:?} vault={}", accounts.vault);
}
Ok(())
}
}RUST_LOG=info cargo runEach Deposit instruction prints one line with the transaction signature and the decoded Deposit 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 MeteoraVaultInstruction:: (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 Vault 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_meteora_vault_decoder::{accounts::MeteoraVaultAccount, MeteoraVaultDecoder, 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(MeteoraVaultDecoder, AccountLogger)
.build()?
.run()
.await
}
struct AccountLogger;
impl Processor<AccountProcessorInputType<'_, MeteoraVaultAccount>> for AccountLogger {
async fn process(
&mut self,
input: &AccountProcessorInputType<'_, MeteoraVaultAccount>,
) -> CarbonResult<()> {
if let MeteoraVaultAccount::Vault(vault) = &input.decoded_account.data {
println!("vault {}: {vault:?}", input.metadata.pubkey);
}
Ok(())
}
}RUST_LOG=info cargo runEach update to a Vault 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 MeteoraVaultInstruction. Each is MeteoraVaultInstruction::, 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
24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi. - 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.
AddStrategy#
From the program's IDL:
add a strategy
Discriminator 407b7fe3c0eac614 · data AddStrategy · accounts AddStrategyInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of AddStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | admin | Pubkey |
| 3… | remaining | Vec< |
CollectDust#
From the program's IDL:
collect token, that someone send wrongly also help in case Mango reimbursement
Discriminator f6951552a04afef0 · data CollectDust · accounts CollectDustInstructionAccounts.
No data fields.
Required accounts: 5; extras go to remaining.
Fields of CollectDustInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | token_vault | Pubkey |
| 2 | token_admin | Pubkey |
| 3 | admin | Pubkey |
| 4 | token_ | Pubkey |
| 5… | remaining | Vec< |
Deposit#
From the program's IDL:
user deposit liquidity to vault
Discriminator f223c68952e1f2b6 · data Deposit · accounts DepositInstructionAccounts.
| Field | Type |
|---|---|
token_ | u64 |
minimum_ | u64 |
Required accounts: 7; extras go to remaining.
Fields of DepositInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | token_vault | Pubkey |
| 2 | lp_mint | Pubkey |
| 3 | user_token | Pubkey |
| 4 | user_lp | Pubkey |
| 5 | user | Pubkey |
| 6 | token_ | Pubkey |
| 7… | remaining | Vec< |
DepositStrategy#
From the program's IDL:
deposit liquidity to a strategy
Discriminator f65239e283defdf9 · data DepositStrategy · accounts DepositStrategyInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
Required accounts: 10; extras go to remaining.
Fields of DepositStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | token_vault | Pubkey |
| 3 | fee_vault | Pubkey |
| 4 | lp_mint | Pubkey |
| 5 | strategy_ | Pubkey |
| 6 | collateral_ | Pubkey |
| 7 | reserve | Pubkey |
| 8 | token_ | Pubkey |
| 9 | operator | Pubkey |
| 10… | remaining | Vec< |
EnableVault#
From the program's IDL:
enable vault
Discriminator 9152f19c1a9ae9d3 · data EnableVault · accounts EnableVaultInstructionAccounts.
| Field | Type |
|---|---|
enabled | u8 |
Required accounts: 2; extras go to remaining.
Fields of EnableVaultInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | admin | Pubkey |
| 2… | remaining | Vec< |
Initialize#
From the program's IDL:
initialize new vault
Discriminator afaf6d1f0d989bed · data Initialize · accounts InitializeInstructionAccounts.
No data fields.
Required accounts: 8; extras go to remaining.
Fields of InitializeInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | payer | Pubkey |
| 2 | token_vault | Pubkey |
| 3 | token_mint | Pubkey |
| 4 | lp_mint | Pubkey |
| 5 | rent | Pubkey |
| 6 | token_ | Pubkey |
| 7 | system_ | Pubkey |
| 8… | remaining | Vec< |
InitializeStrategy#
From the program's IDL:
Initialize a strategy and add strategy to vault.strategies index
Discriminator d0779091b23969fc · data InitializeStrategy · accounts InitializeStrategyInstructionAccounts.
| Field | Type |
|---|---|
bumps | StrategyBumps |
strategy_ | StrategyType |
Required accounts: 10; extras go to remaining.
Fields of InitializeStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy_ | Pubkey |
| 2 | strategy | Pubkey |
| 3 | reserve | Pubkey |
| 4 | collateral_ | Pubkey |
| 5 | collateral_ | Pubkey |
| 6 | admin | Pubkey |
| 7 | system_ | Pubkey |
| 8 | rent | Pubkey |
| 9 | token_ | Pubkey |
| 10… | remaining | Vec< |
RemoveStrategy#
From the program's IDL:
remove a strategy
Discriminator b9ee215b86d2611a · data RemoveStrategy · accounts RemoveStrategyInstructionAccounts.
No data fields.
Required accounts: 10; extras go to remaining.
Fields of RemoveStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | strategy_ | Pubkey |
| 3 | collateral_ | Pubkey |
| 4 | reserve | Pubkey |
| 5 | token_vault | Pubkey |
| 6 | fee_vault | Pubkey |
| 7 | lp_mint | Pubkey |
| 8 | token_ | Pubkey |
| 9 | admin | Pubkey |
| 10… | remaining | Vec< |
RemoveStrategy2#
From the program's IDL:
remove a strategy by advance payment
Discriminator 8a68d0947e23c30e · data RemoveStrategy2 · accounts RemoveStrategy2InstructionAccounts.
| Field | Type |
|---|---|
max_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of RemoveStrategy2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | strategy_ | Pubkey |
| 3 | collateral_ | Pubkey |
| 4 | reserve | Pubkey |
| 5 | token_vault | Pubkey |
| 6 | token_ | Pubkey |
| 7 | token_ | Pubkey |
| 8 | fee_vault | Pubkey |
| 9 | lp_mint | Pubkey |
| 10 | token_ | Pubkey |
| 11 | admin | Pubkey |
| 12… | remaining | Vec< |
SetOperator#
From the program's IDL:
set new operator
Discriminator ee9965a9f3832401 · data SetOperator · accounts SetOperatorInstructionAccounts.
No data fields.
Required accounts: 3; extras go to remaining.
Fields of SetOperatorInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | operator | Pubkey |
| 2 | admin | Pubkey |
| 3… | remaining | Vec< |
Withdraw#
From the program's IDL:
user withdraw liquidity from vault
Discriminator b712469c946da122 · data Withdraw · accounts WithdrawInstructionAccounts.
| Field | Type |
|---|---|
unmint_ | u64 |
min_ | u64 |
Required accounts: 7; extras go to remaining.
Fields of WithdrawInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | token_vault | Pubkey |
| 2 | lp_mint | Pubkey |
| 3 | user_token | Pubkey |
| 4 | user_lp | Pubkey |
| 5 | user | Pubkey |
| 6 | token_ | Pubkey |
| 7… | remaining | Vec< |
Withdraw2#
From the program's IDL:
Withdraw v2. Withdraw from token vault if no remaining accounts are available. Else, it will attempt to withdraw from strategy and token vault.
This method just proxy between 2 methods. Protocol integration should be using withdraw instead of this function.
Discriminator 50066f49aed34284 · data Withdraw2 · accounts Withdraw2InstructionAccounts.
| Field | Type |
|---|---|
unmint_ | u64 |
min_ | u64 |
Required accounts: 7; extras go to remaining.
Fields of Withdraw2InstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | token_vault | Pubkey |
| 2 | lp_mint | Pubkey |
| 3 | user_token | Pubkey |
| 4 | user_lp | Pubkey |
| 5 | user | Pubkey |
| 6 | token_ | Pubkey |
| 7… | remaining | Vec< |
WithdrawDirectlyFromStrategy#
From the program's IDL:
user withdraw liquidity from vault, if vault reserve doesn't have enough liquidity, it will withdraw from the strategy firstly
Discriminator c98d922ead74c616 · data WithdrawDirectlyFromStrategy · accounts WithdrawDirectlyFromStrategyInstructionAccounts.
| Field | Type |
|---|---|
unmint_ | u64 |
min_ | u64 |
Required accounts: 12; extras go to remaining.
Fields of WithdrawDirectlyFromStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | reserve | Pubkey |
| 3 | strategy_ | Pubkey |
| 4 | collateral_ | Pubkey |
| 5 | token_vault | Pubkey |
| 6 | lp_mint | Pubkey |
| 7 | fee_vault | Pubkey |
| 8 | user_token | Pubkey |
| 9 | user_lp | Pubkey |
| 10 | user | Pubkey |
| 11 | token_ | Pubkey |
| 12… | remaining | Vec< |
WithdrawStrategy#
From the program's IDL:
withdraw liquidity from a strategy
Discriminator 1f2da205c1d986bc · data WithdrawStrategy · accounts WithdrawStrategyInstructionAccounts.
| Field | Type |
|---|---|
amount | u64 |
Required accounts: 10; extras go to remaining.
Fields of WithdrawStrategyInstructionAccounts, in account order:
| # | Field | Type |
|---|---|---|
| 0 | vault | Pubkey |
| 1 | strategy | Pubkey |
| 2 | token_vault | Pubkey |
| 3 | fee_vault | Pubkey |
| 4 | lp_mint | Pubkey |
| 5 | strategy_ | Pubkey |
| 6 | collateral_ | Pubkey |
| 7 | reserve | Pubkey |
| 8 | token_ | Pubkey |
| 9 | operator | Pubkey |
| 10… | 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 MeteoraVaultAccount. Each wraps a boxed struct from carbon_. decode_ only considers accounts owned by PROGRAM_ID and returns the first variant that matches.
Strategy#
From the program's IDL:
Strategy struct
Discriminator ae6e2777526aa966 · accounts::.
| Field | Type | Description |
|---|---|---|
reserve | Pubkey | Lending pool address, that the strategy will deposit/withdraw balance |
collateral_ | Pubkey | The token account, that holds the collateral token |
strategy_ | StrategyType | Specify type of strategy |
current_ | u64 | The liquidity in strategy at the time vault deposit/withdraw from a lending protocol |
bumps | [u8; 10] | Hold some bumps, in case the strategy needs to use other seeds to sign a CPI call. |
vault | Pubkey | Vault address, that the strategy belongs |
is_disable | u8 | If we remove strategy by remove_strategy2 endpoint, this account will be never added again |
Vault#
From the program's IDL:
Vault struct
Discriminator d308e82b02987577 · accounts::.
| Field | Type | Description |
|---|---|---|
enabled | u8 | The flag, if admin set enable = false, then the user can only withdraw and cannot deposit in the vault. |
bumps | VaultBumps | Vault nonce, to create vault seeds |
total_ | u64 | The total liquidity of the vault, including remaining tokens in token_vault and the liquidity in all strategies. |
token_vault | Pubkey | Token account, hold liquidity in vault reserve |
fee_vault | Pubkey | Hold lp token of vault, each time rebalance crank is called, vault calculate performance fee and mint corresponding lp token amount to fee_vault. fee_vault is owned by treasury address |
token_mint | Pubkey | Token mint that vault supports |
lp_mint | Pubkey | Lp mint of vault |
strategies | [Pubkey; 30] | The list of strategy addresses that vault supports, vault can support up to MAX_STRATEGY strategies at the same time. |
base | Pubkey | The base address to create vault seeds |
admin | Pubkey | Admin of vault |
operator | Pubkey | Person who can send the crank. Operator can only send liquidity to strategies that admin defined, and claim reward to account of treasury address |
locked_ | LockedProfitTracker | Stores information for locked profit. |
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.
AddLiquidity#
Discriminator 1f5e7d5ae3343dba · events::.
| Field | Type |
|---|---|
lp_ | u64 |
token_ | u64 |
RemoveLiquidity#
Discriminator 74f461e8671f983a · events::.
| Field | Type |
|---|---|
lp_ | u64 |
token_ | u64 |
StrategyDeposit#
Discriminator cd355bef2288492f · events::.
| Field | Type |
|---|---|
strategy_ | StrategyType |
token_ | u64 |
StrategyWithdraw#
Discriminator 784cd05fddd2e5bd · events::.
| Field | Type |
|---|---|
strategy_ | StrategyType |
collateral_ | u64 |
estimated_ | u64 |
ClaimReward#
Discriminator 947486cc16ab555f · events::.
| Field | Type |
|---|---|
strategy_ | StrategyType |
token_ | u64 |
mint_ | Pubkey |
PerformanceFee#
Discriminator 1c46e7df516defa7 · events::.
| Field | Type |
|---|---|
lp_ | u64 |
ReportLoss#
Discriminator 9a249ec420a37b7e · events::.
| Field | Type |
|---|---|
strategy | Pubkey |
loss | u64 |
TotalAmount#
Discriminator 5cc87a91d3cb31cd · events::.
| Field | Type |
|---|---|
total_ | u64 |
Types#
Types used by the instructions, accounts and events above, exported from carbon_.
AddLiquidity#
Struct types::. Same fields as the AddLiquidity event.
ClaimReward#
Struct types::. Same fields as the ClaimReward event.
LockedProfitTracker#
From the program's IDL:
LockedProfitTracker struct
Struct types::.
| Field | Type | Description |
|---|---|---|
last_ | u64 | The total locked profit from the last report |
last_report | u64 | The last timestamp (in seconds) rebalancing |
locked_ | u64 | Rate per second of degradation |
PerformanceFee#
Struct types::. Same fields as the PerformanceFee event.
RemoveLiquidity#
Struct types::. Same fields as the RemoveLiquidity event.
ReportLoss#
Struct types::. Same fields as the ReportLoss event.
StrategyBumps#
From the program's IDL:
Strategy bumps struct
Struct types::.
| Field | Type | Description |
|---|---|---|
strategy_ | u8 | strategy_index |
other_bumps | [u8; 10] | Bumps of PDAs for the integrated protocol. |
StrategyDeposit#
Struct types::. Same fields as the StrategyDeposit event.
StrategyType#
From the program's IDL:
StrategyType struct
Enum types::.
| Variant |
|---|
PortFinanceWithoutLM |
PortFinanceWithLM |
SolendWithoutLM |
Mango |
SolendWithLM |
ApricotWithoutLM |
Francium |
Tulip |
Vault |
Drift |
Frakt |
Marginfi |
StrategyWithdraw#
Struct types::. Same fields as the StrategyWithdraw event.
TotalAmount#
Struct types::. Same fields as the TotalAmount event.
VaultBumps#
From the program's IDL:
Vault bumps struct
Struct types::.
| Field | Type | Description |
|---|---|---|
vault_bump | u8 | vault_bump |
token_ | u8 | token_vault_bump |