Skip to main content

roshi_interface/instructions/
args.rs

1use crate::{
2    action::{ActionScope, Ops},
3    oracle::OracleConfig,
4};
5use wincode::{SchemaRead, SchemaWrite};
6
7#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
8pub struct InitializeProgramArgs {
9    pub authority: [u8; 32],
10}
11
12#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
13pub struct InitializeVaultArgs {
14    pub tag: [u8; 32],
15    pub tag_len: u8,
16    pub admin: [u8; 32],
17    pub strategist: [u8; 32],
18    pub swap_authority: [u8; 32],
19    pub nav_authority: [u8; 32],
20    pub withdrawal_authority: [u8; 32],
21    pub base_mint: [u8; 32],
22    pub base_decimals: u8,
23    pub base_oracle: OracleConfig,
24    pub deposit_sub_account: u8,
25    pub withdraw_sub_account: u8,
26    pub treasury: [u8; 32],
27    pub performance_fee_bps: u16,
28    pub withdrawal_buffer_bps: u16,
29    pub private: bool,
30    pub access_merkle_root: [u8; 32],
31}
32
33#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
34pub struct AuthorizeActionArgs {
35    pub action_hash: [u8; 32],
36    pub scope: ActionScope,
37    pub ops: Ops,
38    pub redeem_amount_offset: u16,
39}
40
41#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
42pub struct RevokeActionArgs {
43    pub action_hash: [u8; 32],
44}
45
46#[derive(Clone, Copy, Debug, Eq, PartialEq, codama_macros::CodamaType, SchemaWrite, SchemaRead)]
47pub struct AccountFlags {
48    pub is_signer: bool,
49    pub is_writable: bool,
50}
51
52#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
53pub struct ManageArgs {
54    pub sub_account: u8,
55    pub program_id: [u8; 32],
56    pub accounts_start: u8,
57    pub accounts_len: u8,
58    pub account_flags: Vec<AccountFlags>,
59    pub ix_data: Vec<u8>,
60}
61
62#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
63pub struct AtomicRedeemArgs {
64    pub shares: u64,
65    pub min_output: u64,
66    pub sub_account: u8,
67    pub program_id: [u8; 32],
68    pub accounts_start: u8,
69    pub accounts_len: u8,
70    pub account_flags: Vec<AccountFlags>,
71    pub ix_data: Vec<u8>,
72}
73
74#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
75pub struct SwapArgs {
76    pub min_out: u64,
77    pub max_in: u64,
78    pub sub_account: u8,
79    pub program_id: [u8; 32],
80    pub accounts_start: u8,
81    pub accounts_len: u8,
82    pub account_flags: Vec<AccountFlags>,
83    pub ix_data: Vec<u8>,
84}
85
86#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
87pub struct ManageBatchArgs {
88    pub actions: Vec<ManageArgs>,
89}
90
91#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
92pub struct DepositArgs {
93    pub asset_mint: [u8; 32],
94    pub amount: u64,
95    pub min_shares_out: u64,
96    pub access_proof: Vec<[u8; 32]>,
97}
98
99#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
100pub struct RedeemArgs {
101    pub recipient_token_account: [u8; 32],
102    pub ticket_index: u8,
103    pub shares: u64,
104}
105
106#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
107pub struct CancelRedeemArgs {
108    pub min_shares_out: u64,
109}
110
111#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
112pub struct ProcessWithdrawalsArgs;
113
114#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
115pub struct InvestExternalArgs {
116    pub sub_account: u8,
117    pub amount: u64,
118}
119
120#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
121pub struct ReturnExternalArgs {
122    pub sub_account: u8,
123    pub amount: u64,
124}
125
126#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
127pub struct CollectFeesArgs {
128    pub sub_account: u8,
129    pub amount: u64,
130}
131
132#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
133pub struct ReportNavArgs {
134    /// Marked base-atom value of everything the program does *not* read as idle:
135    /// venue positions, non-base idle, and any base not held in the vault's
136    /// current deposit/withdraw custodies (e.g. base stranded in a sub-account
137    /// after a repoint — accounting for it is the off-chain NAV's job). The
138    /// program reads idle base on-chain and forms gross NAV = idle +
139    /// `external_value`.
140    pub external_value: u64,
141    pub report_hash: [u8; 32],
142}
143
144#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
145pub struct UpdateVaultConfigArgs {
146    pub treasury: [u8; 32],
147    pub deposit_sub_account: u8,
148    pub withdraw_sub_account: u8,
149    pub base_oracle: OracleConfig,
150    pub performance_fee_bps: u16,
151    pub withdrawal_buffer_bps: u16,
152    pub external_enabled: bool,
153}
154
155#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
156pub struct InitializeAssetArgs {
157    pub asset_mint: [u8; 32],
158    pub oracle: OracleConfig,
159    pub asset_decimals: u8,
160    pub enabled: bool,
161}
162
163#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
164pub struct UpdateAssetArgs {
165    pub oracle: OracleConfig,
166    pub enabled: bool,
167}
168
169#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
170pub struct SetPauseFlagsArgs {
171    pub deposits_paused: bool,
172    pub withdrawals_paused: bool,
173    pub manage_paused: bool,
174}
175
176#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
177pub struct SetVaultAccessArgs {
178    pub private: bool,
179    pub access_merkle_root: [u8; 32],
180}
181
182#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
183pub struct TransferProgramAuthorityArgs {
184    pub new_authority: [u8; 32],
185}
186
187#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
188pub struct TransferVaultAuthorityArgs {
189    pub new_authority: [u8; 32],
190}
191
192#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
193pub struct SetStrategistArgs {
194    pub strategist: [u8; 32],
195}
196
197#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
198pub struct SetSwapAuthorityArgs {
199    pub swap_authority: [u8; 32],
200}
201
202#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
203pub struct SetNavAuthorityArgs {
204    pub nav_authority: [u8; 32],
205}
206
207#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
208pub struct SetWithdrawalAuthorityArgs {
209    pub withdrawal_authority: [u8; 32],
210}