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