1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! This code was AUTOGENERATED using the Codama library.
use {
carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
solana_pubkey::Pubkey,
};
/// Initializes an adaptive_fee_tier account usable by Whirlpools in a
/// WhirlpoolConfig space. ### Authority
/// - "fee_authority" - Set authority in the WhirlpoolConfig
///
/// ### Parameters
/// - `fee_tier_index` - The index of the fee-tier that this adaptive fee tier
/// will be initialized.
/// - `tick_spacing` - The tick-spacing that this fee-tier suggests the
/// default_fee_rate for.
/// - `initialize_pool_authority` - The authority that can initialize pools with
/// this adaptive fee-tier.
/// - `delegated_fee_authority` - The authority that can set the base fee rate
/// for pools using this adaptive fee-tier.
/// - `default_fee_rate` - The default fee rate that a pool will use if the pool
/// uses this
///
/// fee tier during initialization.
/// - `filter_period` - Period determine high frequency trading time window.
/// (seconds)
/// - `decay_period` - Period determine when the adaptive fee start decrease.
/// (seconds)
/// - `reduction_factor` - Adaptive fee rate decrement rate.
/// - `adaptive_fee_control_factor` - Adaptive fee control factor.
/// - `max_volatility_accumulator` - Max volatility accumulator.
/// - `tick_group_size` - Tick group size to define tick group index.
/// - `major_swap_threshold_ticks` - Major swap threshold ticks to define major
/// swap.
///
/// #### Special Errors
/// - `InvalidTickSpacing` - If the provided tick_spacing is 0.
/// - `InvalidFeeTierIndex` - If the provided fee_tier_index is same to
/// tick_spacing.
/// - `FeeRateMaxExceeded` - If the provided default_fee_rate exceeds
/// MAX_FEE_RATE.
/// - `InvalidAdaptiveFeeConstants` - If the provided adaptive fee constants are
/// invalid.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct InitializeAdaptiveFeeTier {
pub fee_tier_index: u16,
pub tick_spacing: u16,
pub initialize_pool_authority: Pubkey,
pub delegated_fee_authority: Pubkey,
pub default_base_fee_rate: u16,
pub filter_period: u16,
pub decay_period: u16,
pub reduction_factor: u16,
pub adaptive_fee_control_factor: u32,
pub max_volatility_accumulator: u32,
pub tick_group_size: u16,
pub major_swap_threshold_ticks: u16,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct InitializeAdaptiveFeeTierInstructionAccounts {
pub whirlpools_config: solana_pubkey::Pubkey,
pub adaptive_fee_tier: solana_pubkey::Pubkey,
pub funder: solana_pubkey::Pubkey,
pub fee_authority: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}
impl InitializeAdaptiveFeeTier {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [77, 99, 208, 200, 141, 123, 117, 48] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}
impl ArrangeAccounts for InitializeAdaptiveFeeTier {
type ArrangedAccounts = InitializeAdaptiveFeeTierInstructionAccounts;
fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let whirlpools_config = next_account(&mut iter)?;
let adaptive_fee_tier = next_account(&mut iter)?;
let funder = next_account(&mut iter)?;
let fee_authority = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;
let remaining = iter.as_slice();
Some(InitializeAdaptiveFeeTierInstructionAccounts {
whirlpools_config,
adaptive_fee_tier,
funder,
fee_authority,
system_program,
remaining: remaining.to_vec(),
})
}
}