Skip to main content

roshi_interface/instructions/
args.rs

1use crate::{
2    action::{ActionScope, Ops},
3    oracle::OracleConfig,
4    state::VaultControls,
5};
6use wincode::{SchemaRead, SchemaWrite};
7
8#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
9pub struct InitializeProgramArgs {
10    pub authority: [u8; 32],
11}
12
13#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
14pub struct InitializeVaultArgs {
15    pub tag: [u8; 32],
16    pub tag_len: u8,
17    pub admin: [u8; 32],
18    pub strategist: [u8; 32],
19    pub swap_authority: [u8; 32],
20    pub nav_authority: [u8; 32],
21    pub withdrawal_authority: [u8; 32],
22    pub base_mint: [u8; 32],
23    pub base_decimals: u8,
24    pub base_oracle: OracleConfig,
25    pub deposit_sub_account: u8,
26    pub withdraw_sub_account: u8,
27    pub treasury: [u8; 32],
28    pub performance_fee_bps: u16,
29    pub withdrawal_buffer_bps: u16,
30    pub controls: VaultControls,
31    pub private: bool,
32    pub access_merkle_root: [u8; 32],
33}
34
35#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
36pub struct AuthorizeActionArgs {
37    pub action_hash: [u8; 32],
38    pub scope: ActionScope,
39    pub ops: Ops,
40    pub redeem_amount_offset: u16,
41}
42
43#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
44pub struct RevokeActionArgs {
45    pub action_hash: [u8; 32],
46}
47
48#[derive(Clone, Copy, Debug, Eq, PartialEq, codama_macros::CodamaType, SchemaWrite, SchemaRead)]
49pub struct AccountFlags {
50    pub is_signer: bool,
51    pub is_writable: bool,
52}
53
54#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
55pub struct ManageArgs {
56    pub sub_account: u8,
57    pub program_id: [u8; 32],
58    pub accounts_start: u8,
59    pub accounts_len: u8,
60    pub account_flags: Vec<AccountFlags>,
61    pub ix_data: Vec<u8>,
62}
63
64#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
65pub struct AtomicRedeemArgs {
66    pub shares: u64,
67    pub min_output: u64,
68    pub sub_account: u8,
69    pub program_id: [u8; 32],
70    pub accounts_start: u8,
71    pub accounts_len: u8,
72    pub account_flags: Vec<AccountFlags>,
73    pub ix_data: Vec<u8>,
74}
75
76#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
77pub struct SwapArgs {
78    pub min_out: u64,
79    pub max_in: u64,
80    pub sub_account: u8,
81    pub program_id: [u8; 32],
82    pub accounts_start: u8,
83    pub accounts_len: u8,
84    pub account_flags: Vec<AccountFlags>,
85    pub ix_data: Vec<u8>,
86}
87
88#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
89pub struct ManageBatchArgs {
90    pub actions: Vec<ManageArgs>,
91}
92
93#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
94pub struct DepositArgs {
95    pub asset_mint: [u8; 32],
96    pub amount: u64,
97    pub min_shares_out: u64,
98    pub access_proof: Vec<[u8; 32]>,
99}
100
101#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
102pub struct RedeemArgs {
103    pub recipient_token_account: [u8; 32],
104    pub ticket_index: u8,
105    pub shares: u64,
106}
107
108#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
109pub struct CancelRedeemArgs {
110    pub min_shares_out: u64,
111}
112
113#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
114pub struct ProcessWithdrawalsArgs;
115
116#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
117pub struct InvestExternalArgs {
118    pub sub_account: u8,
119    pub amount: u64,
120}
121
122#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
123pub struct ReturnExternalArgs {
124    pub sub_account: u8,
125    pub amount: u64,
126}
127
128#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
129pub struct CollectFeesArgs {
130    pub sub_account: u8,
131    pub amount: u64,
132}
133
134#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
135pub struct ReportNavArgs {
136    /// Marked base-atom value of everything the program does *not* read as idle:
137    /// venue positions, non-base idle, and any base not held in the vault's
138    /// current deposit/withdraw custodies (e.g. base stranded in a sub-account
139    /// after a repoint — accounting for it is the off-chain NAV's job). The
140    /// program reads idle base on-chain and forms gross NAV = idle +
141    /// `external_value`.
142    pub external_value: u64,
143    pub report_hash: [u8; 32],
144}
145
146#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
147pub struct UpdateVaultConfigArgs {
148    pub treasury: [u8; 32],
149    pub deposit_sub_account: u8,
150    pub withdraw_sub_account: u8,
151    pub base_oracle: OracleConfig,
152    pub performance_fee_bps: u16,
153    pub withdrawal_buffer_bps: u16,
154    pub controls: VaultControls,
155    pub external_enabled: bool,
156}
157
158#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
159pub struct InitializeAssetArgs {
160    pub asset_mint: [u8; 32],
161    pub oracle: OracleConfig,
162    pub asset_decimals: u8,
163    pub enabled: bool,
164    /// Price deposits as `oracle / vault.base_oracle` (two legs sharing a
165    /// quote currency) instead of reading `oracle` as a direct asset/base feed.
166    pub routed: bool,
167    /// Inventory cap in asset atoms: deposits rejecting once
168    /// `custody_balance + amount` would exceed it. `u64::MAX` = uncapped.
169    pub deposit_cap_atoms: u64,
170}
171
172#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
173pub struct UpdateAssetArgs {
174    pub oracle: OracleConfig,
175    pub enabled: bool,
176    pub routed: bool,
177    pub deposit_cap_atoms: u64,
178}
179
180#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
181pub struct SetPauseFlagsArgs {
182    pub deposits_paused: bool,
183    pub withdrawals_paused: bool,
184    pub manage_paused: bool,
185}
186
187#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
188pub struct SetVaultAccessArgs {
189    pub private: bool,
190    pub access_merkle_root: [u8; 32],
191}
192
193#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
194pub struct TransferProgramAuthorityArgs {
195    pub new_authority: [u8; 32],
196}
197
198#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
199pub struct TransferVaultAuthorityArgs {
200    pub new_authority: [u8; 32],
201}
202
203#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
204pub struct SetStrategistArgs {
205    pub strategist: [u8; 32],
206}
207
208#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
209pub struct SetSwapAuthorityArgs {
210    pub swap_authority: [u8; 32],
211}
212
213#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
214pub struct SetNavAuthorityArgs {
215    pub nav_authority: [u8; 32],
216}
217
218#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
219pub struct SetWithdrawalAuthorityArgs {
220    pub withdrawal_authority: [u8; 32],
221}
222
223#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
224pub struct SetShareMetadataArgs {
225    /// Display metadata for the share mint, stored via Metaplex Token
226    /// Metadata (length limits are enforced by the Metaplex program: name
227    /// <= 32, symbol <= 10, uri <= 200). Display only — no economic
228    /// invariant may depend on it.
229    pub name: String,
230    pub symbol: String,
231    pub uri: String,
232}
233
234#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
235pub struct WriteDownFeesArgs {
236    /// Fee liability to forgive: `0 < amount <= fees_payable`. No tokens
237    /// move; gross NAV is unchanged and liabilities shrink.
238    pub amount: u64,
239}
240
241#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
242pub struct RegisterExternalDestinationArgs;
243
244#[derive(codama_macros::CodamaType, SchemaWrite, SchemaRead)]
245pub struct RevokeExternalDestinationArgs;