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