use borsh::{BorshDeserialize, BorshSerialize};
use solana_sdk::{instruction::{AccountMeta, Instruction}, pubkey::Pubkey};
pub const PROGRAM_ID: Pubkey = solana_sdk::pubkey!("GBPx215wQtoweA8NdeLuYkJ8VotSHuGLKUZKoJMMM8of");
pub const IDL: &str = include_str!("../../idl/treasury.json");
pub use super::swap::{AssetType, ExactMode, NavData};
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AcceptManagerEvent {
pub global_config: Pubkey,
pub new_manager: Pubkey,
}
impl AcceptManagerEvent {
pub const DISCRIMINATOR: [u8; 8] = [122, 8, 15, 50, 143, 7, 38, 25];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AccrueInterestEvent {
pub user_position: Pubkey,
pub principal_amount: u64,
pub accumulated_yield: u64,
pub pending_deposit_count: u16,
pub global_yield_index_on_last_update: u128,
}
impl AccrueInterestEvent {
pub const DISCRIMINATOR: [u8; 8] = [107, 191, 252, 125, 157, 84, 71, 124];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AdminUpdateUserYieldEvent {
pub manager: Pubkey,
pub user_position: Pubkey,
pub accumulated_yield: u64,
pub global_yield_index_on_last_update: u128,
}
impl AdminUpdateUserYieldEvent {
pub const DISCRIMINATOR: [u8; 8] = [154, 40, 212, 128, 128, 147, 28, 240];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct ApyEntry {
pub day_start_ts: i64,
pub apy_bps: u32,
pub global_yield_index_before: u128,
pub bump: u8,
}
impl ApyEntry {
pub const DISCRIMINATOR: [u8; 8] = [163, 185, 43, 251, 157, 154, 19, 76];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
impl ApyEntry {
pub async fn fetch_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Option<Self>> {
rpc.get_account(address).await?
.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from))
.transpose()
}
pub async fn fetch<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Self> {
Self::fetch_maybe(rpc, address).await?
.ok_or(crate::error::SdkError::AccountNotFound(*address))
}
pub async fn fetch_all_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Option<Self>>> {
let accounts = rpc.get_multiple_accounts(addresses).await?;
if accounts.len() != addresses.len() {
return Err(crate::error::SdkError::Rpc("get_multiple_accounts returned an unexpected account count".into()));
}
accounts.into_iter().map(|account| {
account.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from)).transpose()
}).collect()
}
pub async fn fetch_all<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Self>> {
Self::fetch_all_maybe(rpc, addresses).await?.into_iter().zip(addresses)
.map(|(account, address)| account.ok_or(crate::error::SdkError::AccountNotFound(*address)))
.collect()
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AssetConfig {
pub asset_mint: Pubkey,
pub asset_type: AssetType,
pub paused: bool,
pub nav_data: Vec<NavData>,
pub price_difference_bps: u16,
pub bump: u8,
}
impl AssetConfig {
pub const DISCRIMINATOR: [u8; 8] = [57, 112, 247, 166, 247, 64, 140, 23];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
impl AssetConfig {
pub async fn fetch_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Option<Self>> {
rpc.get_account(address).await?
.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from))
.transpose()
}
pub async fn fetch<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Self> {
Self::fetch_maybe(rpc, address).await?
.ok_or(crate::error::SdkError::AccountNotFound(*address))
}
pub async fn fetch_all_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Option<Self>>> {
let accounts = rpc.get_multiple_accounts(addresses).await?;
if accounts.len() != addresses.len() {
return Err(crate::error::SdkError::Rpc("get_multiple_accounts returned an unexpected account count".into()));
}
accounts.into_iter().map(|account| {
account.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from)).transpose()
}).collect()
}
pub async fn fetch_all<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Self>> {
Self::fetch_all_maybe(rpc, addresses).await?.into_iter().zip(addresses)
.map(|(account, address)| account.ok_or(crate::error::SdkError::AccountNotFound(*address)))
.collect()
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseAssetConfigEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub asset_mint: Pubkey,
pub swept_amount: u64,
pub supported_asset_count: u16,
}
impl CloseAssetConfigEvent {
pub const DISCRIMINATOR: [u8; 8] = [138, 204, 99, 145, 73, 104, 100, 196];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseGlobalConfigEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub treasury_mint: Pubkey,
}
impl CloseGlobalConfigEvent {
pub const DISCRIMINATOR: [u8; 8] = [164, 22, 91, 45, 69, 117, 112, 79];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseUserPositionEvent {
pub user: Pubkey,
pub user_position: Pubkey,
}
impl CloseUserPositionEvent {
pub const DISCRIMINATOR: [u8; 8] = [81, 161, 60, 134, 208, 247, 254, 133];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct DepositEvent {
pub user: Pubkey,
pub user_position: Pubkey,
pub asset_mint: Pubkey,
pub amount: u64,
pub nav_9dec: u64,
pub treasury_amount: u64,
pub principal_amount: u64,
pub accumulated_yield: u64,
pub pending_deposit_count: u16,
}
impl DepositEvent {
pub const DISCRIMINATOR: [u8; 8] = [120, 248, 61, 83, 31, 142, 107, 144];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct GlobalConfig {
pub manager: Pubkey,
pub pending_manager: Option<Pubkey>,
pub treasury_mint: Pubkey,
pub oracle_authority: Pubkey,
pub global_yield_index_fp: u128,
pub last_yield_update_ts: i64,
pub latest_apy_entry: Pubkey,
pub apy_history_retention_duration: u64,
pub management_fee_bps: u16,
pub max_apy_bps: u32,
pub max_unposted_yield_seconds: u64,
pub supported_asset_count: u16,
pub max_pending_deposit_slots: u16,
pub paused: bool,
pub bump: u8,
}
impl GlobalConfig {
pub const DISCRIMINATOR: [u8; 8] = [149, 8, 156, 202, 160, 252, 176, 217];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
impl GlobalConfig {
pub async fn fetch_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Option<Self>> {
rpc.get_account(address).await?
.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from))
.transpose()
}
pub async fn fetch<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Self> {
Self::fetch_maybe(rpc, address).await?
.ok_or(crate::error::SdkError::AccountNotFound(*address))
}
pub async fn fetch_all_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Option<Self>>> {
let accounts = rpc.get_multiple_accounts(addresses).await?;
if accounts.len() != addresses.len() {
return Err(crate::error::SdkError::Rpc("get_multiple_accounts returned an unexpected account count".into()));
}
accounts.into_iter().map(|account| {
account.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from)).transpose()
}).collect()
}
pub async fn fetch_all<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Self>> {
Self::fetch_all_maybe(rpc, addresses).await?.into_iter().zip(addresses)
.map(|(account, address)| account.ok_or(crate::error::SdkError::AccountNotFound(*address)))
.collect()
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct InitializeAssetConfigEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub asset_mint: Pubkey,
pub asset_vault: Pubkey,
pub asset_type: AssetType,
pub price_difference_bps: u16,
pub supported_asset_count: u16,
}
impl InitializeAssetConfigEvent {
pub const DISCRIMINATOR: [u8; 8] = [225, 38, 141, 103, 179, 94, 191, 157];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct InitializeEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub treasury_mint: Pubkey,
pub oracle_authority: Pubkey,
pub apy_history_retention_duration: u64,
pub management_fee_bps: u16,
pub max_unposted_yield_seconds: u64,
pub max_pending_deposit_slots: u16,
pub last_yield_update_ts: i64,
}
impl InitializeEvent {
pub const DISCRIMINATOR: [u8; 8] = [206, 175, 169, 208, 241, 210, 35, 221];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct ManagerDepositEvent {
pub manager: Pubkey,
pub asset_mint: Pubkey,
pub amount: u64,
}
impl ManagerDepositEvent {
pub const DISCRIMINATOR: [u8; 8] = [228, 210, 251, 18, 56, 69, 102, 164];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct ManagerWithdrawEvent {
pub manager: Pubkey,
pub asset_mint: Pubkey,
pub amount: u64,
}
impl ManagerWithdrawEvent {
pub const DISCRIMINATOR: [u8; 8] = [189, 192, 5, 198, 128, 188, 176, 52];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PendingDeposit {
pub amount_deposited_fp: u128,
pub deposit_ts: i64,
pub asset_type: AssetType,
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PendingDepositsMergedEvent {
pub user_position: Pubkey,
pub merged_count: u16,
pub merged_principal_delta: u64,
pub merged_yield_delta: u64,
}
impl PendingDepositsMergedEvent {
pub const DISCRIMINATOR: [u8; 8] = [60, 247, 30, 166, 55, 48, 240, 104];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PostDailyRateEvent {
pub oracle_authority: Pubkey,
pub global_config: Pubkey,
pub apy_entry: Pubkey,
pub day_start_ts: i64,
pub apy_bps: u32,
pub gross_apy_bps: u32,
pub management_fee_bps_applied: u32,
pub created: bool,
pub global_yield_index_fp: u128,
pub last_yield_update_ts: i64,
}
impl PostDailyRateEvent {
pub const DISCRIMINATOR: [u8; 8] = [158, 44, 182, 121, 77, 49, 52, 24];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PruneApyEntryEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub apy_entry: Pubkey,
pub day_start_ts: i64,
}
impl PruneApyEntryEvent {
pub const DISCRIMINATOR: [u8; 8] = [220, 238, 164, 146, 102, 49, 102, 233];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct RedeemEvent {
pub user: Pubkey,
pub user_position: Pubkey,
pub asset_mint: Pubkey,
pub treasury_amount: u64,
pub nav_9dec: u64,
pub redeem_asset_amount: u64,
pub principal_amount: u64,
pub accumulated_yield: u64,
pub pending_deposit_count: u16,
}
impl RedeemEvent {
pub const DISCRIMINATOR: [u8; 8] = [90, 114, 83, 146, 212, 26, 217, 59];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetAssetConfigEvent {
pub manager: Pubkey,
pub asset_config: Pubkey,
pub asset_mint: Pubkey,
pub asset_type: Option<AssetType>,
pub pause: Option<bool>,
pub price_difference_bps: Option<u16>,
pub nav_data_updated: bool,
}
impl SetAssetConfigEvent {
pub const DISCRIMINATOR: [u8; 8] = [5, 238, 242, 68, 251, 51, 148, 157];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetMaxApyBpsEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub max_apy_bps: u32,
}
impl SetMaxApyBpsEvent {
pub const DISCRIMINATOR: [u8; 8] = [225, 86, 222, 30, 99, 253, 243, 202];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetPendingManagerEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub pending_manager: Pubkey,
}
impl SetPendingManagerEvent {
pub const DISCRIMINATOR: [u8; 8] = [113, 146, 57, 18, 89, 66, 2, 248];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct UpdateGlobalConfigEvent {
pub manager: Pubkey,
pub global_config: Pubkey,
pub apy_history_retention_duration: Option<u64>,
pub management_fee_bps: Option<u16>,
pub pause: Option<bool>,
pub oracle_authority: Pubkey,
pub max_unposted_yield_seconds: Option<u64>,
pub max_pending_deposit_slots: Option<u16>,
}
impl UpdateGlobalConfigEvent {
pub const DISCRIMINATOR: [u8; 8] = [88, 201, 118, 69, 70, 159, 190, 16];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct UserPosition {
pub owner: Pubkey,
pub principal_amount: u64,
pub accumulated_yield: u64,
pub global_yield_index_on_last_update: u128,
pub pending_deposit_count: u16,
pub max_pending_deposits: u16,
pub bump: u8,
pub _padding: [u8; 3],
pub pending_deposits: [PendingDeposit; 50],
}
impl UserPosition {
pub const DISCRIMINATOR: [u8; 8] = [251, 248, 209, 245, 83, 234, 17, 27];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
impl UserPosition {
pub async fn fetch_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Option<Self>> {
rpc.get_account(address).await?
.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from))
.transpose()
}
pub async fn fetch<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
address: &Pubkey,
) -> crate::error::Result<Self> {
Self::fetch_maybe(rpc, address).await?
.ok_or(crate::error::SdkError::AccountNotFound(*address))
}
pub async fn fetch_all_maybe<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Option<Self>>> {
let accounts = rpc.get_multiple_accounts(addresses).await?;
if accounts.len() != addresses.len() {
return Err(crate::error::SdkError::Rpc("get_multiple_accounts returned an unexpected account count".into()));
}
accounts.into_iter().map(|account| {
account.map(|account| Self::decode(&account.data).map_err(crate::error::SdkError::from)).transpose()
}).collect()
}
pub async fn fetch_all<R: crate::rpc::Rpc + ?Sized>(
rpc: &R,
addresses: &[Pubkey],
) -> crate::error::Result<Vec<Self>> {
Self::fetch_all_maybe(rpc, addresses).await?.into_iter().zip(addresses)
.map(|(account, address)| account.ok_or(crate::error::SdkError::AccountNotFound(*address)))
.collect()
}
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AcceptManagerArgs {
}
impl AcceptManagerArgs {
pub const DISCRIMINATOR: [u8; 8] = [212, 23, 254, 58, 51, 238, 232, 67];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AcceptManagerAccounts {
pub pending_manager: Pubkey,
pub global_config: Pubkey,
}
impl AcceptManagerAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &AcceptManagerArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.pending_manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedAcceptManagerInstruction {
pub program_id: Pubkey,
pub accounts: AcceptManagerAccounts,
pub args: AcceptManagerArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_accept_manager_instruction(instruction: &Instruction) -> std::io::Result<ParsedAcceptManagerInstruction> {
let args = AcceptManagerArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 2 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "accept_manager requires 2 accounts"));
}
Ok(ParsedAcceptManagerInstruction {
program_id: instruction.program_id,
accounts: AcceptManagerAccounts {
pending_manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
},
args,
remaining_accounts: instruction.accounts[2..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AccrueInterestArgs {
}
impl AccrueInterestArgs {
pub const DISCRIMINATOR: [u8; 8] = [47, 40, 115, 198, 91, 12, 222, 49];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AccrueInterestAccounts {
pub global_config: Pubkey,
pub treasury_mint: Pubkey,
pub user_position: Pubkey,
}
impl AccrueInterestAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &AccrueInterestArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.treasury_mint, false));
accounts.push(AccountMeta::new(self.user_position, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedAccrueInterestInstruction {
pub program_id: Pubkey,
pub accounts: AccrueInterestAccounts,
pub args: AccrueInterestArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_accrue_interest_instruction(instruction: &Instruction) -> std::io::Result<ParsedAccrueInterestInstruction> {
let args = AccrueInterestArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 3 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "accrue_interest requires 3 accounts"));
}
Ok(ParsedAccrueInterestInstruction {
program_id: instruction.program_id,
accounts: AccrueInterestAccounts {
global_config: instruction.accounts[0].pubkey,
treasury_mint: instruction.accounts[1].pubkey,
user_position: instruction.accounts[2].pubkey,
},
args,
remaining_accounts: instruction.accounts[3..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct AdminUpdateUserYieldArgs {
pub accumulated_yield: Option<u64>,
}
impl AdminUpdateUserYieldArgs {
pub const DISCRIMINATOR: [u8; 8] = [58, 30, 138, 21, 235, 52, 41, 189];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct AdminUpdateUserYieldAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub user_position: Pubkey,
}
impl AdminUpdateUserYieldAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &AdminUpdateUserYieldArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.manager, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new(self.user_position, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedAdminUpdateUserYieldInstruction {
pub program_id: Pubkey,
pub accounts: AdminUpdateUserYieldAccounts,
pub args: AdminUpdateUserYieldArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_admin_update_user_yield_instruction(instruction: &Instruction) -> std::io::Result<ParsedAdminUpdateUserYieldInstruction> {
let args = AdminUpdateUserYieldArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 3 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "admin_update_user_yield requires 3 accounts"));
}
Ok(ParsedAdminUpdateUserYieldInstruction {
program_id: instruction.program_id,
accounts: AdminUpdateUserYieldAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
user_position: instruction.accounts[2].pubkey,
},
args,
remaining_accounts: instruction.accounts[3..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseAssetConfigArgs {
}
impl CloseAssetConfigArgs {
pub const DISCRIMINATOR: [u8; 8] = [106, 126, 17, 11, 206, 31, 41, 151];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CloseAssetConfigAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub vault_authority: Pubkey,
pub asset_mint: Pubkey,
pub asset_vault: Pubkey,
pub manager_asset_token_account: Pubkey,
pub token_program: Pubkey,
pub associated_token_program: Pubkey,
pub system_program: Pubkey,
}
impl CloseAssetConfigAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &CloseAssetConfigArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(10 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new(self.asset_config, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new(self.manager_asset_token_account, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.push(AccountMeta::new_readonly(self.system_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedCloseAssetConfigInstruction {
pub program_id: Pubkey,
pub accounts: CloseAssetConfigAccounts,
pub args: CloseAssetConfigArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_close_asset_config_instruction(instruction: &Instruction) -> std::io::Result<ParsedCloseAssetConfigInstruction> {
let args = CloseAssetConfigArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 10 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "close_asset_config requires 10 accounts"));
}
Ok(ParsedCloseAssetConfigInstruction {
program_id: instruction.program_id,
accounts: CloseAssetConfigAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
vault_authority: instruction.accounts[3].pubkey,
asset_mint: instruction.accounts[4].pubkey,
asset_vault: instruction.accounts[5].pubkey,
manager_asset_token_account: instruction.accounts[6].pubkey,
token_program: instruction.accounts[7].pubkey,
associated_token_program: instruction.accounts[8].pubkey,
system_program: instruction.accounts[9].pubkey,
},
args,
remaining_accounts: instruction.accounts[10..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseGlobalConfigArgs {
}
impl CloseGlobalConfigArgs {
pub const DISCRIMINATOR: [u8; 8] = [16, 244, 225, 240, 253, 137, 126, 39];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CloseGlobalConfigAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub treasury_mint: Pubkey,
pub token_program: Pubkey,
}
impl CloseGlobalConfigAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &CloseGlobalConfigArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.treasury_mint, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedCloseGlobalConfigInstruction {
pub program_id: Pubkey,
pub accounts: CloseGlobalConfigAccounts,
pub args: CloseGlobalConfigArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_close_global_config_instruction(instruction: &Instruction) -> std::io::Result<ParsedCloseGlobalConfigInstruction> {
let args = CloseGlobalConfigArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 4 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "close_global_config requires 4 accounts"));
}
Ok(ParsedCloseGlobalConfigInstruction {
program_id: instruction.program_id,
accounts: CloseGlobalConfigAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
treasury_mint: instruction.accounts[2].pubkey,
token_program: instruction.accounts[3].pubkey,
},
args,
remaining_accounts: instruction.accounts[4..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct CloseUserPositionArgs {
}
impl CloseUserPositionArgs {
pub const DISCRIMINATOR: [u8; 8] = [111, 105, 100, 191, 82, 118, 204, 64];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CloseUserPositionAccounts {
pub user: Pubkey,
pub user_position: Pubkey,
}
impl CloseUserPositionAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &CloseUserPositionArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.user, true));
accounts.push(AccountMeta::new(self.user_position, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedCloseUserPositionInstruction {
pub program_id: Pubkey,
pub accounts: CloseUserPositionAccounts,
pub args: CloseUserPositionArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_close_user_position_instruction(instruction: &Instruction) -> std::io::Result<ParsedCloseUserPositionInstruction> {
let args = CloseUserPositionArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 2 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "close_user_position requires 2 accounts"));
}
Ok(ParsedCloseUserPositionInstruction {
program_id: instruction.program_id,
accounts: CloseUserPositionAccounts {
user: instruction.accounts[0].pubkey,
user_position: instruction.accounts[1].pubkey,
},
args,
remaining_accounts: instruction.accounts[2..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct DepositArgs {
pub amount: u64,
pub nav_account_count: u8,
pub apy_account_count: u8,
pub exact_mode: ExactMode,
pub amount_threshold: Option<u64>,
}
impl DepositArgs {
pub const DISCRIMINATOR: [u8; 8] = [242, 35, 198, 137, 82, 225, 242, 182];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct DepositAccounts {
pub user: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub user_position: Pubkey,
pub vault_authority: Pubkey,
pub treasury_mint: Pubkey,
pub asset_mint: Pubkey,
pub user_asset_token_account: Pubkey,
pub asset_vault: Pubkey,
pub user_treasury_token_account: Pubkey,
pub asset_token_program: Pubkey,
pub treasury_token_program: Pubkey,
pub associated_token_program: Pubkey,
pub system_program: Pubkey,
}
impl DepositAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &DepositArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.user, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.asset_config, false));
accounts.push(AccountMeta::new(self.user_position, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new(self.treasury_mint, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new(self.user_asset_token_account, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new(self.user_treasury_token_account, false));
accounts.push(AccountMeta::new_readonly(self.asset_token_program, false));
accounts.push(AccountMeta::new_readonly(self.treasury_token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.push(AccountMeta::new_readonly(self.system_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedDepositInstruction {
pub program_id: Pubkey,
pub accounts: DepositAccounts,
pub args: DepositArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_deposit_instruction(instruction: &Instruction) -> std::io::Result<ParsedDepositInstruction> {
let args = DepositArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 14 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "deposit requires 14 accounts"));
}
Ok(ParsedDepositInstruction {
program_id: instruction.program_id,
accounts: DepositAccounts {
user: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
user_position: instruction.accounts[3].pubkey,
vault_authority: instruction.accounts[4].pubkey,
treasury_mint: instruction.accounts[5].pubkey,
asset_mint: instruction.accounts[6].pubkey,
user_asset_token_account: instruction.accounts[7].pubkey,
asset_vault: instruction.accounts[8].pubkey,
user_treasury_token_account: instruction.accounts[9].pubkey,
asset_token_program: instruction.accounts[10].pubkey,
treasury_token_program: instruction.accounts[11].pubkey,
associated_token_program: instruction.accounts[12].pubkey,
system_program: instruction.accounts[13].pubkey,
},
args,
remaining_accounts: instruction.accounts[14..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct InitializeArgs {
pub manager: Pubkey,
pub oracle_authority: Pubkey,
pub apy_history_retention_duration: u64,
pub management_fee_bps: u16,
pub max_unposted_yield_seconds: u64,
pub max_pending_deposit_slots: u16,
}
impl InitializeArgs {
pub const DISCRIMINATOR: [u8; 8] = [175, 175, 109, 31, 13, 152, 155, 237];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InitializeAccounts {
pub caller: Pubkey,
pub program_data: Pubkey,
pub global_config: Pubkey,
pub vault_authority: Pubkey,
pub token_program: Pubkey,
pub treasury_mint: Pubkey,
pub system_program: Pubkey,
}
impl InitializeAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &InitializeArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(7 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.caller, true));
accounts.push(AccountMeta::new_readonly(self.program_data, false));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.push(AccountMeta::new(self.treasury_mint, false));
accounts.push(AccountMeta::new_readonly(self.system_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedInitializeInstruction {
pub program_id: Pubkey,
pub accounts: InitializeAccounts,
pub args: InitializeArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_initialize_instruction(instruction: &Instruction) -> std::io::Result<ParsedInitializeInstruction> {
let args = InitializeArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 7 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "initialize requires 7 accounts"));
}
Ok(ParsedInitializeInstruction {
program_id: instruction.program_id,
accounts: InitializeAccounts {
caller: instruction.accounts[0].pubkey,
program_data: instruction.accounts[1].pubkey,
global_config: instruction.accounts[2].pubkey,
vault_authority: instruction.accounts[3].pubkey,
token_program: instruction.accounts[4].pubkey,
treasury_mint: instruction.accounts[5].pubkey,
system_program: instruction.accounts[6].pubkey,
},
args,
remaining_accounts: instruction.accounts[7..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct InitializeAssetConfigArgs {
pub asset_type: AssetType,
pub price_difference_bps: u16,
pub nav_data: Vec<NavData>,
}
impl InitializeAssetConfigArgs {
pub const DISCRIMINATOR: [u8; 8] = [201, 180, 166, 88, 111, 8, 150, 205];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct InitializeAssetConfigAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub vault_authority: Pubkey,
pub asset_vault: Pubkey,
pub asset_mint: Pubkey,
pub token_program: Pubkey,
pub associated_token_program: Pubkey,
pub system_program: Pubkey,
}
impl InitializeAssetConfigAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &InitializeAssetConfigArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(9 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new(self.asset_config, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.push(AccountMeta::new_readonly(self.system_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedInitializeAssetConfigInstruction {
pub program_id: Pubkey,
pub accounts: InitializeAssetConfigAccounts,
pub args: InitializeAssetConfigArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_initialize_asset_config_instruction(instruction: &Instruction) -> std::io::Result<ParsedInitializeAssetConfigInstruction> {
let args = InitializeAssetConfigArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 9 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "initialize_asset_config requires 9 accounts"));
}
Ok(ParsedInitializeAssetConfigInstruction {
program_id: instruction.program_id,
accounts: InitializeAssetConfigAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
vault_authority: instruction.accounts[3].pubkey,
asset_vault: instruction.accounts[4].pubkey,
asset_mint: instruction.accounts[5].pubkey,
token_program: instruction.accounts[6].pubkey,
associated_token_program: instruction.accounts[7].pubkey,
system_program: instruction.accounts[8].pubkey,
},
args,
remaining_accounts: instruction.accounts[9..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct ManagerDepositArgs {
pub amount: u64,
}
impl ManagerDepositArgs {
pub const DISCRIMINATOR: [u8; 8] = [73, 3, 16, 168, 143, 226, 201, 254];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ManagerDepositAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub vault_authority: Pubkey,
pub asset_mint: Pubkey,
pub manager_asset_token_account: Pubkey,
pub asset_vault: Pubkey,
pub token_program: Pubkey,
pub associated_token_program: Pubkey,
}
impl ManagerDepositAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &ManagerDepositArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(9 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.asset_config, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new(self.manager_asset_token_account, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedManagerDepositInstruction {
pub program_id: Pubkey,
pub accounts: ManagerDepositAccounts,
pub args: ManagerDepositArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_manager_deposit_instruction(instruction: &Instruction) -> std::io::Result<ParsedManagerDepositInstruction> {
let args = ManagerDepositArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 9 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "manager_deposit requires 9 accounts"));
}
Ok(ParsedManagerDepositInstruction {
program_id: instruction.program_id,
accounts: ManagerDepositAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
vault_authority: instruction.accounts[3].pubkey,
asset_mint: instruction.accounts[4].pubkey,
manager_asset_token_account: instruction.accounts[5].pubkey,
asset_vault: instruction.accounts[6].pubkey,
token_program: instruction.accounts[7].pubkey,
associated_token_program: instruction.accounts[8].pubkey,
},
args,
remaining_accounts: instruction.accounts[9..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct ManagerWithdrawArgs {
pub amount: u64,
}
impl ManagerWithdrawArgs {
pub const DISCRIMINATOR: [u8; 8] = [201, 248, 190, 143, 86, 43, 183, 254];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ManagerWithdrawAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub vault_authority: Pubkey,
pub asset_mint: Pubkey,
pub asset_vault: Pubkey,
pub manager_asset_token_account: Pubkey,
pub token_program: Pubkey,
pub associated_token_program: Pubkey,
}
impl ManagerWithdrawAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &ManagerWithdrawArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(9 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.asset_config, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new(self.manager_asset_token_account, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedManagerWithdrawInstruction {
pub program_id: Pubkey,
pub accounts: ManagerWithdrawAccounts,
pub args: ManagerWithdrawArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_manager_withdraw_instruction(instruction: &Instruction) -> std::io::Result<ParsedManagerWithdrawInstruction> {
let args = ManagerWithdrawArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 9 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "manager_withdraw requires 9 accounts"));
}
Ok(ParsedManagerWithdrawInstruction {
program_id: instruction.program_id,
accounts: ManagerWithdrawAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
vault_authority: instruction.accounts[3].pubkey,
asset_mint: instruction.accounts[4].pubkey,
asset_vault: instruction.accounts[5].pubkey,
manager_asset_token_account: instruction.accounts[6].pubkey,
token_program: instruction.accounts[7].pubkey,
associated_token_program: instruction.accounts[8].pubkey,
},
args,
remaining_accounts: instruction.accounts[9..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PostDailyRateArgs {
pub day_start_ts: u64,
pub apy_bps: u32,
}
impl PostDailyRateArgs {
pub const DISCRIMINATOR: [u8; 8] = [97, 148, 227, 180, 119, 174, 56, 81];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PostDailyRateAccounts {
pub oracle_authority: Pubkey,
pub global_config: Pubkey,
pub apy_entry: Pubkey,
pub system_program: Pubkey,
}
impl PostDailyRateAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &PostDailyRateArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(4 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.oracle_authority, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new(self.apy_entry, false));
accounts.push(AccountMeta::new_readonly(self.system_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedPostDailyRateInstruction {
pub program_id: Pubkey,
pub accounts: PostDailyRateAccounts,
pub args: PostDailyRateArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_post_daily_rate_instruction(instruction: &Instruction) -> std::io::Result<ParsedPostDailyRateInstruction> {
let args = PostDailyRateArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 4 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "post_daily_rate requires 4 accounts"));
}
Ok(ParsedPostDailyRateInstruction {
program_id: instruction.program_id,
accounts: PostDailyRateAccounts {
oracle_authority: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
apy_entry: instruction.accounts[2].pubkey,
system_program: instruction.accounts[3].pubkey,
},
args,
remaining_accounts: instruction.accounts[4..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct PruneApyEntryArgs {
pub day_start_ts: u64,
}
impl PruneApyEntryArgs {
pub const DISCRIMINATOR: [u8; 8] = [124, 138, 154, 164, 142, 71, 212, 79];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct PruneApyEntryAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub apy_entry: Pubkey,
}
impl PruneApyEntryAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &PruneApyEntryArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new(self.apy_entry, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedPruneApyEntryInstruction {
pub program_id: Pubkey,
pub accounts: PruneApyEntryAccounts,
pub args: PruneApyEntryArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_prune_apy_entry_instruction(instruction: &Instruction) -> std::io::Result<ParsedPruneApyEntryInstruction> {
let args = PruneApyEntryArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 3 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "prune_apy_entry requires 3 accounts"));
}
Ok(ParsedPruneApyEntryInstruction {
program_id: instruction.program_id,
accounts: PruneApyEntryAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
apy_entry: instruction.accounts[2].pubkey,
},
args,
remaining_accounts: instruction.accounts[3..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct RedeemArgs {
pub amount: u64,
pub nav_account_count: u8,
pub apy_account_count: u8,
pub exact_mode: ExactMode,
pub amount_threshold: Option<u64>,
}
impl RedeemArgs {
pub const DISCRIMINATOR: [u8; 8] = [184, 12, 86, 149, 70, 196, 97, 225];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct RedeemAccounts {
pub user: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub user_position: Pubkey,
pub vault_authority: Pubkey,
pub treasury_mint: Pubkey,
pub user_treasury_token_account: Pubkey,
pub asset_mint: Pubkey,
pub asset_vault: Pubkey,
pub user_asset_token_account: Pubkey,
pub latest_apy_entry: Pubkey,
pub treasury_token_program: Pubkey,
pub asset_token_program: Pubkey,
pub associated_token_program: Pubkey,
}
impl RedeemAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &RedeemArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(14 + remaining_accounts.len());
accounts.push(AccountMeta::new(self.user, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.asset_config, false));
accounts.push(AccountMeta::new(self.user_position, false));
accounts.push(AccountMeta::new_readonly(self.vault_authority, false));
accounts.push(AccountMeta::new(self.treasury_mint, false));
accounts.push(AccountMeta::new(self.user_treasury_token_account, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new(self.asset_vault, false));
accounts.push(AccountMeta::new(self.user_asset_token_account, false));
accounts.push(AccountMeta::new_readonly(self.latest_apy_entry, false));
accounts.push(AccountMeta::new_readonly(self.treasury_token_program, false));
accounts.push(AccountMeta::new_readonly(self.asset_token_program, false));
accounts.push(AccountMeta::new_readonly(self.associated_token_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedRedeemInstruction {
pub program_id: Pubkey,
pub accounts: RedeemAccounts,
pub args: RedeemArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_redeem_instruction(instruction: &Instruction) -> std::io::Result<ParsedRedeemInstruction> {
let args = RedeemArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 14 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "redeem requires 14 accounts"));
}
Ok(ParsedRedeemInstruction {
program_id: instruction.program_id,
accounts: RedeemAccounts {
user: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
user_position: instruction.accounts[3].pubkey,
vault_authority: instruction.accounts[4].pubkey,
treasury_mint: instruction.accounts[5].pubkey,
user_treasury_token_account: instruction.accounts[6].pubkey,
asset_mint: instruction.accounts[7].pubkey,
asset_vault: instruction.accounts[8].pubkey,
user_asset_token_account: instruction.accounts[9].pubkey,
latest_apy_entry: instruction.accounts[10].pubkey,
treasury_token_program: instruction.accounts[11].pubkey,
asset_token_program: instruction.accounts[12].pubkey,
associated_token_program: instruction.accounts[13].pubkey,
},
args,
remaining_accounts: instruction.accounts[14..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetAssetConfigArgs {
pub asset_type: Option<AssetType>,
pub pause: Option<bool>,
pub nav_data: Option<Vec<NavData>>,
pub price_difference_bps: Option<u16>,
}
impl SetAssetConfigArgs {
pub const DISCRIMINATOR: [u8; 8] = [110, 198, 171, 111, 60, 234, 8, 197];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SetAssetConfigAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub asset_config: Pubkey,
pub asset_mint: Pubkey,
pub token_program: Pubkey,
}
impl SetAssetConfigAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &SetAssetConfigArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(5 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.manager, true));
accounts.push(AccountMeta::new_readonly(self.global_config, false));
accounts.push(AccountMeta::new(self.asset_config, false));
accounts.push(AccountMeta::new_readonly(self.asset_mint, false));
accounts.push(AccountMeta::new_readonly(self.token_program, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedSetAssetConfigInstruction {
pub program_id: Pubkey,
pub accounts: SetAssetConfigAccounts,
pub args: SetAssetConfigArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_set_asset_config_instruction(instruction: &Instruction) -> std::io::Result<ParsedSetAssetConfigInstruction> {
let args = SetAssetConfigArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 5 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "set_asset_config requires 5 accounts"));
}
Ok(ParsedSetAssetConfigInstruction {
program_id: instruction.program_id,
accounts: SetAssetConfigAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
asset_config: instruction.accounts[2].pubkey,
asset_mint: instruction.accounts[3].pubkey,
token_program: instruction.accounts[4].pubkey,
},
args,
remaining_accounts: instruction.accounts[5..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetMaxApyBpsArgs {
pub max_apy_bps: u32,
}
impl SetMaxApyBpsArgs {
pub const DISCRIMINATOR: [u8; 8] = [175, 133, 235, 249, 117, 76, 242, 171];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SetMaxApyBpsAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
}
impl SetMaxApyBpsAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &SetMaxApyBpsArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedSetMaxApyBpsInstruction {
pub program_id: Pubkey,
pub accounts: SetMaxApyBpsAccounts,
pub args: SetMaxApyBpsArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_set_max_apy_bps_instruction(instruction: &Instruction) -> std::io::Result<ParsedSetMaxApyBpsInstruction> {
let args = SetMaxApyBpsArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 2 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "set_max_apy_bps requires 2 accounts"));
}
Ok(ParsedSetMaxApyBpsInstruction {
program_id: instruction.program_id,
accounts: SetMaxApyBpsAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
},
args,
remaining_accounts: instruction.accounts[2..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct SetPendingManagerArgs {
}
impl SetPendingManagerArgs {
pub const DISCRIMINATOR: [u8; 8] = [141, 140, 182, 240, 16, 23, 219, 99];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SetPendingManagerAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
pub pending_manager: Pubkey,
}
impl SetPendingManagerAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &SetPendingManagerArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(3 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.push(AccountMeta::new_readonly(self.pending_manager, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedSetPendingManagerInstruction {
pub program_id: Pubkey,
pub accounts: SetPendingManagerAccounts,
pub args: SetPendingManagerArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_set_pending_manager_instruction(instruction: &Instruction) -> std::io::Result<ParsedSetPendingManagerInstruction> {
let args = SetPendingManagerArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 3 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "set_pending_manager requires 3 accounts"));
}
Ok(ParsedSetPendingManagerInstruction {
program_id: instruction.program_id,
accounts: SetPendingManagerAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
pending_manager: instruction.accounts[2].pubkey,
},
args,
remaining_accounts: instruction.accounts[3..].to_vec(),
})
}
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
pub struct UpdateGlobalConfigArgs {
pub oracle_authority: Option<Pubkey>,
pub apy_history_retention_duration: Option<u64>,
pub management_fee_bps: Option<u16>,
pub pause: Option<bool>,
pub max_unposted_yield_seconds: Option<u64>,
pub max_pending_deposit_slots: Option<u16>,
}
impl UpdateGlobalConfigArgs {
pub const DISCRIMINATOR: [u8; 8] = [164, 84, 130, 189, 111, 58, 250, 200];
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
super::decode(data, Self::DISCRIMINATOR)
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
super::encode(self, Self::DISCRIMINATOR)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct UpdateGlobalConfigAccounts {
pub manager: Pubkey,
pub global_config: Pubkey,
}
impl UpdateGlobalConfigAccounts {
pub fn instruction(
&self,
program_id: Pubkey,
args: &UpdateGlobalConfigArgs,
remaining_accounts: &[AccountMeta],
) -> std::io::Result<Instruction> {
let mut accounts = Vec::with_capacity(2 + remaining_accounts.len());
accounts.push(AccountMeta::new_readonly(self.manager, true));
accounts.push(AccountMeta::new(self.global_config, false));
accounts.extend_from_slice(remaining_accounts);
Ok(Instruction { program_id, accounts, data: args.encode()? })
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ParsedUpdateGlobalConfigInstruction {
pub program_id: Pubkey,
pub accounts: UpdateGlobalConfigAccounts,
pub args: UpdateGlobalConfigArgs,
pub remaining_accounts: Vec<AccountMeta>,
}
pub fn parse_update_global_config_instruction(instruction: &Instruction) -> std::io::Result<ParsedUpdateGlobalConfigInstruction> {
let args = UpdateGlobalConfigArgs::decode(&instruction.data)?;
if instruction.accounts.len() < 2 {
return Err(std::io::Error::new(std::io::ErrorKind::UnexpectedEof, "update_global_config requires 2 accounts"));
}
Ok(ParsedUpdateGlobalConfigInstruction {
program_id: instruction.program_id,
accounts: UpdateGlobalConfigAccounts {
manager: instruction.accounts[0].pubkey,
global_config: instruction.accounts[1].pubkey,
},
args,
remaining_accounts: instruction.accounts[2..].to_vec(),
})
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum InstructionKind {
AcceptManager,
AccrueInterest,
AdminUpdateUserYield,
CloseAssetConfig,
CloseGlobalConfig,
CloseUserPosition,
Deposit,
Initialize,
InitializeAssetConfig,
ManagerDeposit,
ManagerWithdraw,
PostDailyRate,
PruneApyEntry,
Redeem,
SetAssetConfig,
SetMaxApyBps,
SetPendingManager,
UpdateGlobalConfig,
}
pub const INSTRUCTION_DISCRIMINATORS: &[(&str, [u8; 8])] = &[
("accept_manager", AcceptManagerArgs::DISCRIMINATOR),
("accrue_interest", AccrueInterestArgs::DISCRIMINATOR),
("admin_update_user_yield", AdminUpdateUserYieldArgs::DISCRIMINATOR),
("close_asset_config", CloseAssetConfigArgs::DISCRIMINATOR),
("close_global_config", CloseGlobalConfigArgs::DISCRIMINATOR),
("close_user_position", CloseUserPositionArgs::DISCRIMINATOR),
("deposit", DepositArgs::DISCRIMINATOR),
("initialize", InitializeArgs::DISCRIMINATOR),
("initialize_asset_config", InitializeAssetConfigArgs::DISCRIMINATOR),
("manager_deposit", ManagerDepositArgs::DISCRIMINATOR),
("manager_withdraw", ManagerWithdrawArgs::DISCRIMINATOR),
("post_daily_rate", PostDailyRateArgs::DISCRIMINATOR),
("prune_apy_entry", PruneApyEntryArgs::DISCRIMINATOR),
("redeem", RedeemArgs::DISCRIMINATOR),
("set_asset_config", SetAssetConfigArgs::DISCRIMINATOR),
("set_max_apy_bps", SetMaxApyBpsArgs::DISCRIMINATOR),
("set_pending_manager", SetPendingManagerArgs::DISCRIMINATOR),
("update_global_config", UpdateGlobalConfigArgs::DISCRIMINATOR),
];
pub fn identify_instruction(data: &[u8]) -> std::io::Result<InstructionKind> {
match super::discriminator(data)? {
AcceptManagerArgs::DISCRIMINATOR => Ok(InstructionKind::AcceptManager),
AccrueInterestArgs::DISCRIMINATOR => Ok(InstructionKind::AccrueInterest),
AdminUpdateUserYieldArgs::DISCRIMINATOR => Ok(InstructionKind::AdminUpdateUserYield),
CloseAssetConfigArgs::DISCRIMINATOR => Ok(InstructionKind::CloseAssetConfig),
CloseGlobalConfigArgs::DISCRIMINATOR => Ok(InstructionKind::CloseGlobalConfig),
CloseUserPositionArgs::DISCRIMINATOR => Ok(InstructionKind::CloseUserPosition),
DepositArgs::DISCRIMINATOR => Ok(InstructionKind::Deposit),
InitializeArgs::DISCRIMINATOR => Ok(InstructionKind::Initialize),
InitializeAssetConfigArgs::DISCRIMINATOR => Ok(InstructionKind::InitializeAssetConfig),
ManagerDepositArgs::DISCRIMINATOR => Ok(InstructionKind::ManagerDeposit),
ManagerWithdrawArgs::DISCRIMINATOR => Ok(InstructionKind::ManagerWithdraw),
PostDailyRateArgs::DISCRIMINATOR => Ok(InstructionKind::PostDailyRate),
PruneApyEntryArgs::DISCRIMINATOR => Ok(InstructionKind::PruneApyEntry),
RedeemArgs::DISCRIMINATOR => Ok(InstructionKind::Redeem),
SetAssetConfigArgs::DISCRIMINATOR => Ok(InstructionKind::SetAssetConfig),
SetMaxApyBpsArgs::DISCRIMINATOR => Ok(InstructionKind::SetMaxApyBps),
SetPendingManagerArgs::DISCRIMINATOR => Ok(InstructionKind::SetPendingManager),
UpdateGlobalConfigArgs::DISCRIMINATOR => Ok(InstructionKind::UpdateGlobalConfig),
_ => Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "Unknown instruction discriminator")),
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ParsedInstruction {
AcceptManager(ParsedAcceptManagerInstruction),
AccrueInterest(ParsedAccrueInterestInstruction),
AdminUpdateUserYield(ParsedAdminUpdateUserYieldInstruction),
CloseAssetConfig(ParsedCloseAssetConfigInstruction),
CloseGlobalConfig(ParsedCloseGlobalConfigInstruction),
CloseUserPosition(ParsedCloseUserPositionInstruction),
Deposit(ParsedDepositInstruction),
Initialize(ParsedInitializeInstruction),
InitializeAssetConfig(ParsedInitializeAssetConfigInstruction),
ManagerDeposit(ParsedManagerDepositInstruction),
ManagerWithdraw(ParsedManagerWithdrawInstruction),
PostDailyRate(ParsedPostDailyRateInstruction),
PruneApyEntry(ParsedPruneApyEntryInstruction),
Redeem(ParsedRedeemInstruction),
SetAssetConfig(ParsedSetAssetConfigInstruction),
SetMaxApyBps(ParsedSetMaxApyBpsInstruction),
SetPendingManager(ParsedSetPendingManagerInstruction),
UpdateGlobalConfig(ParsedUpdateGlobalConfigInstruction),
}
pub fn parse_instruction(instruction: &Instruction) -> std::io::Result<ParsedInstruction> {
match identify_instruction(&instruction.data)? {
InstructionKind::AcceptManager => Ok(ParsedInstruction::AcceptManager(parse_accept_manager_instruction(instruction)?)),
InstructionKind::AccrueInterest => Ok(ParsedInstruction::AccrueInterest(parse_accrue_interest_instruction(instruction)?)),
InstructionKind::AdminUpdateUserYield => Ok(ParsedInstruction::AdminUpdateUserYield(parse_admin_update_user_yield_instruction(instruction)?)),
InstructionKind::CloseAssetConfig => Ok(ParsedInstruction::CloseAssetConfig(parse_close_asset_config_instruction(instruction)?)),
InstructionKind::CloseGlobalConfig => Ok(ParsedInstruction::CloseGlobalConfig(parse_close_global_config_instruction(instruction)?)),
InstructionKind::CloseUserPosition => Ok(ParsedInstruction::CloseUserPosition(parse_close_user_position_instruction(instruction)?)),
InstructionKind::Deposit => Ok(ParsedInstruction::Deposit(parse_deposit_instruction(instruction)?)),
InstructionKind::Initialize => Ok(ParsedInstruction::Initialize(parse_initialize_instruction(instruction)?)),
InstructionKind::InitializeAssetConfig => Ok(ParsedInstruction::InitializeAssetConfig(parse_initialize_asset_config_instruction(instruction)?)),
InstructionKind::ManagerDeposit => Ok(ParsedInstruction::ManagerDeposit(parse_manager_deposit_instruction(instruction)?)),
InstructionKind::ManagerWithdraw => Ok(ParsedInstruction::ManagerWithdraw(parse_manager_withdraw_instruction(instruction)?)),
InstructionKind::PostDailyRate => Ok(ParsedInstruction::PostDailyRate(parse_post_daily_rate_instruction(instruction)?)),
InstructionKind::PruneApyEntry => Ok(ParsedInstruction::PruneApyEntry(parse_prune_apy_entry_instruction(instruction)?)),
InstructionKind::Redeem => Ok(ParsedInstruction::Redeem(parse_redeem_instruction(instruction)?)),
InstructionKind::SetAssetConfig => Ok(ParsedInstruction::SetAssetConfig(parse_set_asset_config_instruction(instruction)?)),
InstructionKind::SetMaxApyBps => Ok(ParsedInstruction::SetMaxApyBps(parse_set_max_apy_bps_instruction(instruction)?)),
InstructionKind::SetPendingManager => Ok(ParsedInstruction::SetPendingManager(parse_set_pending_manager_instruction(instruction)?)),
InstructionKind::UpdateGlobalConfig => Ok(ParsedInstruction::UpdateGlobalConfig(parse_update_global_config_instruction(instruction)?)),
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AccountKind {
ApyEntry,
AssetConfig,
GlobalConfig,
UserPosition,
}
pub const ACCOUNT_DISCRIMINATORS: &[(&str, [u8; 8])] = &[
("ApyEntry", ApyEntry::DISCRIMINATOR),
("AssetConfig", AssetConfig::DISCRIMINATOR),
("GlobalConfig", GlobalConfig::DISCRIMINATOR),
("UserPosition", UserPosition::DISCRIMINATOR),
];
pub fn identify_account(data: &[u8]) -> std::io::Result<AccountKind> {
match super::discriminator(data)? {
ApyEntry::DISCRIMINATOR => Ok(AccountKind::ApyEntry),
AssetConfig::DISCRIMINATOR => Ok(AccountKind::AssetConfig),
GlobalConfig::DISCRIMINATOR => Ok(AccountKind::GlobalConfig),
UserPosition::DISCRIMINATOR => Ok(AccountKind::UserPosition),
_ => Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "Unknown account discriminator")),
}
}
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Account {
ApyEntry(ApyEntry),
AssetConfig(AssetConfig),
GlobalConfig(GlobalConfig),
UserPosition(UserPosition),
}
impl Account {
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
match identify_account(data)? {
AccountKind::ApyEntry => Ok(Self::ApyEntry(ApyEntry::decode(data)?)),
AccountKind::AssetConfig => Ok(Self::AssetConfig(AssetConfig::decode(data)?)),
AccountKind::GlobalConfig => Ok(Self::GlobalConfig(GlobalConfig::decode(data)?)),
AccountKind::UserPosition => Ok(Self::UserPosition(UserPosition::decode(data)?)),
}
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
match self {
Self::ApyEntry(value) => value.encode(),
Self::AssetConfig(value) => value.encode(),
Self::GlobalConfig(value) => value.encode(),
Self::UserPosition(value) => value.encode(),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EventKind {
AcceptManagerEvent,
AccrueInterestEvent,
AdminUpdateUserYieldEvent,
CloseAssetConfigEvent,
CloseGlobalConfigEvent,
CloseUserPositionEvent,
DepositEvent,
InitializeAssetConfigEvent,
InitializeEvent,
ManagerDepositEvent,
ManagerWithdrawEvent,
PendingDepositsMergedEvent,
PostDailyRateEvent,
PruneApyEntryEvent,
RedeemEvent,
SetAssetConfigEvent,
SetMaxApyBpsEvent,
SetPendingManagerEvent,
UpdateGlobalConfigEvent,
}
pub const EVENT_DISCRIMINATORS: &[(&str, [u8; 8])] = &[
("AcceptManagerEvent", AcceptManagerEvent::DISCRIMINATOR),
("AccrueInterestEvent", AccrueInterestEvent::DISCRIMINATOR),
("AdminUpdateUserYieldEvent", AdminUpdateUserYieldEvent::DISCRIMINATOR),
("CloseAssetConfigEvent", CloseAssetConfigEvent::DISCRIMINATOR),
("CloseGlobalConfigEvent", CloseGlobalConfigEvent::DISCRIMINATOR),
("CloseUserPositionEvent", CloseUserPositionEvent::DISCRIMINATOR),
("DepositEvent", DepositEvent::DISCRIMINATOR),
("InitializeAssetConfigEvent", InitializeAssetConfigEvent::DISCRIMINATOR),
("InitializeEvent", InitializeEvent::DISCRIMINATOR),
("ManagerDepositEvent", ManagerDepositEvent::DISCRIMINATOR),
("ManagerWithdrawEvent", ManagerWithdrawEvent::DISCRIMINATOR),
("PendingDepositsMergedEvent", PendingDepositsMergedEvent::DISCRIMINATOR),
("PostDailyRateEvent", PostDailyRateEvent::DISCRIMINATOR),
("PruneApyEntryEvent", PruneApyEntryEvent::DISCRIMINATOR),
("RedeemEvent", RedeemEvent::DISCRIMINATOR),
("SetAssetConfigEvent", SetAssetConfigEvent::DISCRIMINATOR),
("SetMaxApyBpsEvent", SetMaxApyBpsEvent::DISCRIMINATOR),
("SetPendingManagerEvent", SetPendingManagerEvent::DISCRIMINATOR),
("UpdateGlobalConfigEvent", UpdateGlobalConfigEvent::DISCRIMINATOR),
];
pub fn identify_event(data: &[u8]) -> std::io::Result<EventKind> {
match super::discriminator(data)? {
AcceptManagerEvent::DISCRIMINATOR => Ok(EventKind::AcceptManagerEvent),
AccrueInterestEvent::DISCRIMINATOR => Ok(EventKind::AccrueInterestEvent),
AdminUpdateUserYieldEvent::DISCRIMINATOR => Ok(EventKind::AdminUpdateUserYieldEvent),
CloseAssetConfigEvent::DISCRIMINATOR => Ok(EventKind::CloseAssetConfigEvent),
CloseGlobalConfigEvent::DISCRIMINATOR => Ok(EventKind::CloseGlobalConfigEvent),
CloseUserPositionEvent::DISCRIMINATOR => Ok(EventKind::CloseUserPositionEvent),
DepositEvent::DISCRIMINATOR => Ok(EventKind::DepositEvent),
InitializeAssetConfigEvent::DISCRIMINATOR => Ok(EventKind::InitializeAssetConfigEvent),
InitializeEvent::DISCRIMINATOR => Ok(EventKind::InitializeEvent),
ManagerDepositEvent::DISCRIMINATOR => Ok(EventKind::ManagerDepositEvent),
ManagerWithdrawEvent::DISCRIMINATOR => Ok(EventKind::ManagerWithdrawEvent),
PendingDepositsMergedEvent::DISCRIMINATOR => Ok(EventKind::PendingDepositsMergedEvent),
PostDailyRateEvent::DISCRIMINATOR => Ok(EventKind::PostDailyRateEvent),
PruneApyEntryEvent::DISCRIMINATOR => Ok(EventKind::PruneApyEntryEvent),
RedeemEvent::DISCRIMINATOR => Ok(EventKind::RedeemEvent),
SetAssetConfigEvent::DISCRIMINATOR => Ok(EventKind::SetAssetConfigEvent),
SetMaxApyBpsEvent::DISCRIMINATOR => Ok(EventKind::SetMaxApyBpsEvent),
SetPendingManagerEvent::DISCRIMINATOR => Ok(EventKind::SetPendingManagerEvent),
UpdateGlobalConfigEvent::DISCRIMINATOR => Ok(EventKind::UpdateGlobalConfigEvent),
_ => Err(std::io::Error::new(std::io::ErrorKind::InvalidData, "Unknown event discriminator")),
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Event {
AcceptManagerEvent(AcceptManagerEvent),
AccrueInterestEvent(AccrueInterestEvent),
AdminUpdateUserYieldEvent(AdminUpdateUserYieldEvent),
CloseAssetConfigEvent(CloseAssetConfigEvent),
CloseGlobalConfigEvent(CloseGlobalConfigEvent),
CloseUserPositionEvent(CloseUserPositionEvent),
DepositEvent(DepositEvent),
InitializeAssetConfigEvent(InitializeAssetConfigEvent),
InitializeEvent(InitializeEvent),
ManagerDepositEvent(ManagerDepositEvent),
ManagerWithdrawEvent(ManagerWithdrawEvent),
PendingDepositsMergedEvent(PendingDepositsMergedEvent),
PostDailyRateEvent(PostDailyRateEvent),
PruneApyEntryEvent(PruneApyEntryEvent),
RedeemEvent(RedeemEvent),
SetAssetConfigEvent(SetAssetConfigEvent),
SetMaxApyBpsEvent(SetMaxApyBpsEvent),
SetPendingManagerEvent(SetPendingManagerEvent),
UpdateGlobalConfigEvent(UpdateGlobalConfigEvent),
}
impl Event {
pub fn decode(data: &[u8]) -> std::io::Result<Self> {
match identify_event(data)? {
EventKind::AcceptManagerEvent => Ok(Self::AcceptManagerEvent(AcceptManagerEvent::decode(data)?)),
EventKind::AccrueInterestEvent => Ok(Self::AccrueInterestEvent(AccrueInterestEvent::decode(data)?)),
EventKind::AdminUpdateUserYieldEvent => Ok(Self::AdminUpdateUserYieldEvent(AdminUpdateUserYieldEvent::decode(data)?)),
EventKind::CloseAssetConfigEvent => Ok(Self::CloseAssetConfigEvent(CloseAssetConfigEvent::decode(data)?)),
EventKind::CloseGlobalConfigEvent => Ok(Self::CloseGlobalConfigEvent(CloseGlobalConfigEvent::decode(data)?)),
EventKind::CloseUserPositionEvent => Ok(Self::CloseUserPositionEvent(CloseUserPositionEvent::decode(data)?)),
EventKind::DepositEvent => Ok(Self::DepositEvent(DepositEvent::decode(data)?)),
EventKind::InitializeAssetConfigEvent => Ok(Self::InitializeAssetConfigEvent(InitializeAssetConfigEvent::decode(data)?)),
EventKind::InitializeEvent => Ok(Self::InitializeEvent(InitializeEvent::decode(data)?)),
EventKind::ManagerDepositEvent => Ok(Self::ManagerDepositEvent(ManagerDepositEvent::decode(data)?)),
EventKind::ManagerWithdrawEvent => Ok(Self::ManagerWithdrawEvent(ManagerWithdrawEvent::decode(data)?)),
EventKind::PendingDepositsMergedEvent => Ok(Self::PendingDepositsMergedEvent(PendingDepositsMergedEvent::decode(data)?)),
EventKind::PostDailyRateEvent => Ok(Self::PostDailyRateEvent(PostDailyRateEvent::decode(data)?)),
EventKind::PruneApyEntryEvent => Ok(Self::PruneApyEntryEvent(PruneApyEntryEvent::decode(data)?)),
EventKind::RedeemEvent => Ok(Self::RedeemEvent(RedeemEvent::decode(data)?)),
EventKind::SetAssetConfigEvent => Ok(Self::SetAssetConfigEvent(SetAssetConfigEvent::decode(data)?)),
EventKind::SetMaxApyBpsEvent => Ok(Self::SetMaxApyBpsEvent(SetMaxApyBpsEvent::decode(data)?)),
EventKind::SetPendingManagerEvent => Ok(Self::SetPendingManagerEvent(SetPendingManagerEvent::decode(data)?)),
EventKind::UpdateGlobalConfigEvent => Ok(Self::UpdateGlobalConfigEvent(UpdateGlobalConfigEvent::decode(data)?)),
}
}
pub fn encode(&self) -> std::io::Result<Vec<u8>> {
match self {
Self::AcceptManagerEvent(value) => value.encode(),
Self::AccrueInterestEvent(value) => value.encode(),
Self::AdminUpdateUserYieldEvent(value) => value.encode(),
Self::CloseAssetConfigEvent(value) => value.encode(),
Self::CloseGlobalConfigEvent(value) => value.encode(),
Self::CloseUserPositionEvent(value) => value.encode(),
Self::DepositEvent(value) => value.encode(),
Self::InitializeAssetConfigEvent(value) => value.encode(),
Self::InitializeEvent(value) => value.encode(),
Self::ManagerDepositEvent(value) => value.encode(),
Self::ManagerWithdrawEvent(value) => value.encode(),
Self::PendingDepositsMergedEvent(value) => value.encode(),
Self::PostDailyRateEvent(value) => value.encode(),
Self::PruneApyEntryEvent(value) => value.encode(),
Self::RedeemEvent(value) => value.encode(),
Self::SetAssetConfigEvent(value) => value.encode(),
Self::SetMaxApyBpsEvent(value) => value.encode(),
Self::SetPendingManagerEvent(value) => value.encode(),
Self::UpdateGlobalConfigEvent(value) => value.encode(),
}
}
}
pub const ERRORS: &[super::ProgramErrorMetadata] = &[
super::ProgramErrorMetadata { code: 6000, name: "ArithmeticError", message: "Arithmetic Error" },
super::ProgramErrorMetadata { code: 6001, name: "BpsValueOutOfRange", message: "Bps value out of range" },
super::ProgramErrorMetadata { code: 6002, name: "ProgramPaused", message: "Program is paused" },
super::ProgramErrorMetadata { code: 6003, name: "AssetPaused", message: "Asset is paused" },
super::ProgramErrorMetadata { code: 6004, name: "AmountMustBePositive", message: "Amount must be positive" },
super::ProgramErrorMetadata { code: 6005, name: "DepositValueBelowMinimum", message: "Deposit value is below the minimum supported amount" },
super::ProgramErrorMetadata { code: 6006, name: "InvalidNav", message: "NAV must be positive" },
super::ProgramErrorMetadata { code: 6007, name: "InvalidDayStartTs", message: "Day start timestamp is invalid" },
super::ProgramErrorMetadata { code: 6008, name: "OutOfOrderApyEntry", message: "APY entries must be posted in chronological order" },
super::ProgramErrorMetadata { code: 6009, name: "InvalidRemainingAccounts", message: "Remaining account counts do not match the provided accounts" },
super::ProgramErrorMetadata { code: 6010, name: "ZeroBasisIndex", message: "Basis index cannot be zero" },
super::ProgramErrorMetadata { code: 6011, name: "ZeroYieldIndex", message: "Yield index cannot be zero" },
super::ProgramErrorMetadata { code: 6012, name: "YieldIndexRegression", message: "Current yield index cannot move backwards" },
super::ProgramErrorMetadata { code: 6013, name: "PendingDepositCountTooLarge", message: "Pending deposit count exceeds capacity" },
super::ProgramErrorMetadata { code: 6014, name: "MissingApyEntry", message: "Missing APY entry for mergeable pending deposit" },
super::ProgramErrorMetadata { code: 6015, name: "InsufficientRedeemableBalance", message: "Redeem amount exceeds the user's available balance" },
super::ProgramErrorMetadata { code: 6016, name: "UserPositionNotEmpty", message: "User position must be empty before it can be closed" },
super::ProgramErrorMetadata { code: 6017, name: "SupportedAssetsRemain", message: "All asset configs must be closed before the global config can be closed" },
super::ProgramErrorMetadata { code: 6018, name: "TreasuryMintSupplyNotZero", message: "Treasury mint supply must be zero before the global config can be closed" },
super::ProgramErrorMetadata { code: 6019, name: "InsufficientVaultBalance", message: "Insufficient vault balance" },
super::ProgramErrorMetadata { code: 6020, name: "ApyHistoryRetentionDurationTooShort", message: "APY history retention duration must be greater than 7 days" },
super::ProgramErrorMetadata { code: 6021, name: "ApyEntryRetentionNotMet", message: "APY entry is still within the retention window" },
super::ProgramErrorMetadata { code: 6022, name: "InvalidLatestApyEntry", message: "Provided APY entry is not the latest APY entry" },
super::ProgramErrorMetadata { code: 6023, name: "UnauthorizedInitializer", message: "Caller must be the program upgrade authority" },
super::ProgramErrorMetadata { code: 6024, name: "InvalidTreasuryMintTokenProgram", message: "Treasury mint must use Token-2022" },
super::ProgramErrorMetadata { code: 6025, name: "TreasuryMintDecimalsTooLarge", message: "Treasury mint decimals exceed supported fixed-point precision" },
super::ProgramErrorMetadata { code: 6026, name: "InvalidTreasuryMintAuthority", message: "Treasury mint authority is invalid" },
super::ProgramErrorMetadata { code: 6027, name: "InvalidTreasuryMintSupply", message: "Treasury mint supply must be zero" },
super::ProgramErrorMetadata { code: 6028, name: "InvalidTreasuryMintMetadata", message: "Treasury mint metadata is invalid" },
super::ProgramErrorMetadata { code: 6029, name: "InvalidTreasuryMintFreezeAuthority", message: "Treasury mint freeze authority must be unset" },
super::ProgramErrorMetadata { code: 6030, name: "InvalidAssetMint", message: "Asset mint cannot be the treasury mint" },
super::ProgramErrorMetadata { code: 6031, name: "DayNotElapsed", message: "The full day has not elapsed since the day start timestamp" },
super::ProgramErrorMetadata { code: 6032, name: "DuplicateLatestApyEntry", message: "latest_apy_entry must not be duplicated in the apy remaining accounts" },
super::ProgramErrorMetadata { code: 6033, name: "CannotPruneLatestApyEntry", message: "Latest Apy entry can not be pruned" },
super::ProgramErrorMetadata { code: 6034, name: "ApyExceedsMax", message: "Posted APY exceeds the configured maximum" },
super::ProgramErrorMetadata { code: 6035, name: "UserIndexExceedsGlobalIndex", message: "User credit index cannot exceed the current global credit index" },
super::ProgramErrorMetadata { code: 6036, name: "MaxUnpostedYieldSecondsTooLarge", message: "max_unposted_yield_seconds exceeds the maximum representable value (i64::MAX)" },
super::ProgramErrorMetadata { code: 6037, name: "MaxApyBelowManagementFee", message: "max_apy_bps must be greater than or equal to management_fee_bps" },
super::ProgramErrorMetadata { code: 6038, name: "FirstApyEntryNotPosted", message: "deposits are disabled until the first daily APY rate has been posted" },
super::ProgramErrorMetadata { code: 6039, name: "TransferFeeNotSupported", message: "Mints charging a Token-2022 transfer fee are not supported" },
super::ProgramErrorMetadata { code: 6040, name: "InvalidTokenExtensionData", message: "Token-2022 extension data could not be decoded" },
super::ProgramErrorMetadata { code: 6041, name: "PendingDepositCapacityExceeded", message: "Position already holds the maximum number of pending deposits" },
super::ProgramErrorMetadata { code: 6042, name: "MaxPendingDepositSlotsOutOfRange", message: "max_pending_deposit_slots is outside the supported range" },
super::ProgramErrorMetadata { code: 6043, name: "InvalidUserPositionAccount", message: "Account data is not a readable UserPosition" },
super::ProgramErrorMetadata { code: 6044, name: "MaxPendingDepositSlotsDecreased", message: "max_pending_deposit_slots can only be raised, never lowered" },
super::ProgramErrorMetadata { code: 6045, name: "SignerInRemainingAccounts", message: "Remaining accounts must not contain signers" },
super::ProgramErrorMetadata { code: 6046, name: "AmountOutTooLow", message: "Output amount is below the caller's minimum" },
super::ProgramErrorMetadata { code: 6047, name: "AmountInTooHigh", message: "Input amount exceeds the caller's maximum" },
];
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum ProgramError {
ArithmeticError = 6000,
BpsValueOutOfRange = 6001,
ProgramPaused = 6002,
AssetPaused = 6003,
AmountMustBePositive = 6004,
DepositValueBelowMinimum = 6005,
InvalidNav = 6006,
InvalidDayStartTs = 6007,
OutOfOrderApyEntry = 6008,
InvalidRemainingAccounts = 6009,
ZeroBasisIndex = 6010,
ZeroYieldIndex = 6011,
YieldIndexRegression = 6012,
PendingDepositCountTooLarge = 6013,
MissingApyEntry = 6014,
InsufficientRedeemableBalance = 6015,
UserPositionNotEmpty = 6016,
SupportedAssetsRemain = 6017,
TreasuryMintSupplyNotZero = 6018,
InsufficientVaultBalance = 6019,
ApyHistoryRetentionDurationTooShort = 6020,
ApyEntryRetentionNotMet = 6021,
InvalidLatestApyEntry = 6022,
UnauthorizedInitializer = 6023,
InvalidTreasuryMintTokenProgram = 6024,
TreasuryMintDecimalsTooLarge = 6025,
InvalidTreasuryMintAuthority = 6026,
InvalidTreasuryMintSupply = 6027,
InvalidTreasuryMintMetadata = 6028,
InvalidTreasuryMintFreezeAuthority = 6029,
InvalidAssetMint = 6030,
DayNotElapsed = 6031,
DuplicateLatestApyEntry = 6032,
CannotPruneLatestApyEntry = 6033,
ApyExceedsMax = 6034,
UserIndexExceedsGlobalIndex = 6035,
MaxUnpostedYieldSecondsTooLarge = 6036,
MaxApyBelowManagementFee = 6037,
FirstApyEntryNotPosted = 6038,
TransferFeeNotSupported = 6039,
InvalidTokenExtensionData = 6040,
PendingDepositCapacityExceeded = 6041,
MaxPendingDepositSlotsOutOfRange = 6042,
InvalidUserPositionAccount = 6043,
MaxPendingDepositSlotsDecreased = 6044,
SignerInRemainingAccounts = 6045,
AmountOutTooLow = 6046,
AmountInTooHigh = 6047,
}
impl ProgramError {
pub const fn from_code(code: u32) -> Option<Self> {
match code {
6000 => Some(Self::ArithmeticError),
6001 => Some(Self::BpsValueOutOfRange),
6002 => Some(Self::ProgramPaused),
6003 => Some(Self::AssetPaused),
6004 => Some(Self::AmountMustBePositive),
6005 => Some(Self::DepositValueBelowMinimum),
6006 => Some(Self::InvalidNav),
6007 => Some(Self::InvalidDayStartTs),
6008 => Some(Self::OutOfOrderApyEntry),
6009 => Some(Self::InvalidRemainingAccounts),
6010 => Some(Self::ZeroBasisIndex),
6011 => Some(Self::ZeroYieldIndex),
6012 => Some(Self::YieldIndexRegression),
6013 => Some(Self::PendingDepositCountTooLarge),
6014 => Some(Self::MissingApyEntry),
6015 => Some(Self::InsufficientRedeemableBalance),
6016 => Some(Self::UserPositionNotEmpty),
6017 => Some(Self::SupportedAssetsRemain),
6018 => Some(Self::TreasuryMintSupplyNotZero),
6019 => Some(Self::InsufficientVaultBalance),
6020 => Some(Self::ApyHistoryRetentionDurationTooShort),
6021 => Some(Self::ApyEntryRetentionNotMet),
6022 => Some(Self::InvalidLatestApyEntry),
6023 => Some(Self::UnauthorizedInitializer),
6024 => Some(Self::InvalidTreasuryMintTokenProgram),
6025 => Some(Self::TreasuryMintDecimalsTooLarge),
6026 => Some(Self::InvalidTreasuryMintAuthority),
6027 => Some(Self::InvalidTreasuryMintSupply),
6028 => Some(Self::InvalidTreasuryMintMetadata),
6029 => Some(Self::InvalidTreasuryMintFreezeAuthority),
6030 => Some(Self::InvalidAssetMint),
6031 => Some(Self::DayNotElapsed),
6032 => Some(Self::DuplicateLatestApyEntry),
6033 => Some(Self::CannotPruneLatestApyEntry),
6034 => Some(Self::ApyExceedsMax),
6035 => Some(Self::UserIndexExceedsGlobalIndex),
6036 => Some(Self::MaxUnpostedYieldSecondsTooLarge),
6037 => Some(Self::MaxApyBelowManagementFee),
6038 => Some(Self::FirstApyEntryNotPosted),
6039 => Some(Self::TransferFeeNotSupported),
6040 => Some(Self::InvalidTokenExtensionData),
6041 => Some(Self::PendingDepositCapacityExceeded),
6042 => Some(Self::MaxPendingDepositSlotsOutOfRange),
6043 => Some(Self::InvalidUserPositionAccount),
6044 => Some(Self::MaxPendingDepositSlotsDecreased),
6045 => Some(Self::SignerInRemainingAccounts),
6046 => Some(Self::AmountOutTooLow),
6047 => Some(Self::AmountInTooHigh),
_ => None,
}
}
pub const fn code(self) -> u32 { self as u32 }
pub const fn name(self) -> &'static str {
match self {
Self::ArithmeticError => "ArithmeticError",
Self::BpsValueOutOfRange => "BpsValueOutOfRange",
Self::ProgramPaused => "ProgramPaused",
Self::AssetPaused => "AssetPaused",
Self::AmountMustBePositive => "AmountMustBePositive",
Self::DepositValueBelowMinimum => "DepositValueBelowMinimum",
Self::InvalidNav => "InvalidNav",
Self::InvalidDayStartTs => "InvalidDayStartTs",
Self::OutOfOrderApyEntry => "OutOfOrderApyEntry",
Self::InvalidRemainingAccounts => "InvalidRemainingAccounts",
Self::ZeroBasisIndex => "ZeroBasisIndex",
Self::ZeroYieldIndex => "ZeroYieldIndex",
Self::YieldIndexRegression => "YieldIndexRegression",
Self::PendingDepositCountTooLarge => "PendingDepositCountTooLarge",
Self::MissingApyEntry => "MissingApyEntry",
Self::InsufficientRedeemableBalance => "InsufficientRedeemableBalance",
Self::UserPositionNotEmpty => "UserPositionNotEmpty",
Self::SupportedAssetsRemain => "SupportedAssetsRemain",
Self::TreasuryMintSupplyNotZero => "TreasuryMintSupplyNotZero",
Self::InsufficientVaultBalance => "InsufficientVaultBalance",
Self::ApyHistoryRetentionDurationTooShort => "ApyHistoryRetentionDurationTooShort",
Self::ApyEntryRetentionNotMet => "ApyEntryRetentionNotMet",
Self::InvalidLatestApyEntry => "InvalidLatestApyEntry",
Self::UnauthorizedInitializer => "UnauthorizedInitializer",
Self::InvalidTreasuryMintTokenProgram => "InvalidTreasuryMintTokenProgram",
Self::TreasuryMintDecimalsTooLarge => "TreasuryMintDecimalsTooLarge",
Self::InvalidTreasuryMintAuthority => "InvalidTreasuryMintAuthority",
Self::InvalidTreasuryMintSupply => "InvalidTreasuryMintSupply",
Self::InvalidTreasuryMintMetadata => "InvalidTreasuryMintMetadata",
Self::InvalidTreasuryMintFreezeAuthority => "InvalidTreasuryMintFreezeAuthority",
Self::InvalidAssetMint => "InvalidAssetMint",
Self::DayNotElapsed => "DayNotElapsed",
Self::DuplicateLatestApyEntry => "DuplicateLatestApyEntry",
Self::CannotPruneLatestApyEntry => "CannotPruneLatestApyEntry",
Self::ApyExceedsMax => "ApyExceedsMax",
Self::UserIndexExceedsGlobalIndex => "UserIndexExceedsGlobalIndex",
Self::MaxUnpostedYieldSecondsTooLarge => "MaxUnpostedYieldSecondsTooLarge",
Self::MaxApyBelowManagementFee => "MaxApyBelowManagementFee",
Self::FirstApyEntryNotPosted => "FirstApyEntryNotPosted",
Self::TransferFeeNotSupported => "TransferFeeNotSupported",
Self::InvalidTokenExtensionData => "InvalidTokenExtensionData",
Self::PendingDepositCapacityExceeded => "PendingDepositCapacityExceeded",
Self::MaxPendingDepositSlotsOutOfRange => "MaxPendingDepositSlotsOutOfRange",
Self::InvalidUserPositionAccount => "InvalidUserPositionAccount",
Self::MaxPendingDepositSlotsDecreased => "MaxPendingDepositSlotsDecreased",
Self::SignerInRemainingAccounts => "SignerInRemainingAccounts",
Self::AmountOutTooLow => "AmountOutTooLow",
Self::AmountInTooHigh => "AmountInTooHigh",
}
}
pub const fn message(self) -> &'static str {
match self {
Self::ArithmeticError => "Arithmetic Error",
Self::BpsValueOutOfRange => "Bps value out of range",
Self::ProgramPaused => "Program is paused",
Self::AssetPaused => "Asset is paused",
Self::AmountMustBePositive => "Amount must be positive",
Self::DepositValueBelowMinimum => "Deposit value is below the minimum supported amount",
Self::InvalidNav => "NAV must be positive",
Self::InvalidDayStartTs => "Day start timestamp is invalid",
Self::OutOfOrderApyEntry => "APY entries must be posted in chronological order",
Self::InvalidRemainingAccounts => "Remaining account counts do not match the provided accounts",
Self::ZeroBasisIndex => "Basis index cannot be zero",
Self::ZeroYieldIndex => "Yield index cannot be zero",
Self::YieldIndexRegression => "Current yield index cannot move backwards",
Self::PendingDepositCountTooLarge => "Pending deposit count exceeds capacity",
Self::MissingApyEntry => "Missing APY entry for mergeable pending deposit",
Self::InsufficientRedeemableBalance => "Redeem amount exceeds the user's available balance",
Self::UserPositionNotEmpty => "User position must be empty before it can be closed",
Self::SupportedAssetsRemain => "All asset configs must be closed before the global config can be closed",
Self::TreasuryMintSupplyNotZero => "Treasury mint supply must be zero before the global config can be closed",
Self::InsufficientVaultBalance => "Insufficient vault balance",
Self::ApyHistoryRetentionDurationTooShort => "APY history retention duration must be greater than 7 days",
Self::ApyEntryRetentionNotMet => "APY entry is still within the retention window",
Self::InvalidLatestApyEntry => "Provided APY entry is not the latest APY entry",
Self::UnauthorizedInitializer => "Caller must be the program upgrade authority",
Self::InvalidTreasuryMintTokenProgram => "Treasury mint must use Token-2022",
Self::TreasuryMintDecimalsTooLarge => "Treasury mint decimals exceed supported fixed-point precision",
Self::InvalidTreasuryMintAuthority => "Treasury mint authority is invalid",
Self::InvalidTreasuryMintSupply => "Treasury mint supply must be zero",
Self::InvalidTreasuryMintMetadata => "Treasury mint metadata is invalid",
Self::InvalidTreasuryMintFreezeAuthority => "Treasury mint freeze authority must be unset",
Self::InvalidAssetMint => "Asset mint cannot be the treasury mint",
Self::DayNotElapsed => "The full day has not elapsed since the day start timestamp",
Self::DuplicateLatestApyEntry => "latest_apy_entry must not be duplicated in the apy remaining accounts",
Self::CannotPruneLatestApyEntry => "Latest Apy entry can not be pruned",
Self::ApyExceedsMax => "Posted APY exceeds the configured maximum",
Self::UserIndexExceedsGlobalIndex => "User credit index cannot exceed the current global credit index",
Self::MaxUnpostedYieldSecondsTooLarge => "max_unposted_yield_seconds exceeds the maximum representable value (i64::MAX)",
Self::MaxApyBelowManagementFee => "max_apy_bps must be greater than or equal to management_fee_bps",
Self::FirstApyEntryNotPosted => "deposits are disabled until the first daily APY rate has been posted",
Self::TransferFeeNotSupported => "Mints charging a Token-2022 transfer fee are not supported",
Self::InvalidTokenExtensionData => "Token-2022 extension data could not be decoded",
Self::PendingDepositCapacityExceeded => "Position already holds the maximum number of pending deposits",
Self::MaxPendingDepositSlotsOutOfRange => "max_pending_deposit_slots is outside the supported range",
Self::InvalidUserPositionAccount => "Account data is not a readable UserPosition",
Self::MaxPendingDepositSlotsDecreased => "max_pending_deposit_slots can only be raised, never lowered",
Self::SignerInRemainingAccounts => "Remaining accounts must not contain signers",
Self::AmountOutTooLow => "Output amount is below the caller's minimum",
Self::AmountInTooHigh => "Input amount exceeds the caller's maximum",
}
}
}
impl std::fmt::Display for ProgramError {
fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
formatter.write_str(self.message())
}
}
impl std::error::Error for ProgramError {}