Skip to main content

universalsettle_api/
instruction.rs

1use steel::*;
2
3#[repr(u8)]
4#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5pub enum SettlementInstruction {
6    // User (public — no authority required)
7    Sweep = 0,       // Indirect/batch settlement sweep
8    CreateVault = 1, // Setup SplitVault for a seller
9    // 2–99 reserved for future public instructions
10
11    // Admin (require Config authority signer)
12    Initialize = 100,
13    UpdateAuthority = 101,
14    UpdateFeeRate = 102,
15    UpdateFeeDestination = 103,
16    UpdateMinFeeAmount = 104,
17}
18
19#[repr(C)]
20#[derive(Clone, Copy, Debug, Pod, Zeroable)]
21pub struct CreateVault {
22    pub seller: Pubkey, // 32 bytes - Resource owner wallet address
23}
24
25#[repr(C)]
26#[derive(Clone, Copy, Debug, Pod, Zeroable)]
27pub struct Sweep {
28    pub token_mint: Pubkey, // For SOL: Pubkey::default(), For SPL: the mint address
29    pub amount: [u8; 8],    // Amount to sweep (0 = all available)
30    pub is_sol: [u8; 1],    // 1 for native SOL, 0 for SPL token
31    pub _padding: [u8; 7],
32}
33
34#[repr(C)]
35#[derive(Clone, Copy, Debug, Pod, Zeroable)]
36pub struct Initialize {
37    pub fee_destination: Pubkey, // Facilitator fee destination wallet address
38    pub min_fee_amount: [u8; 8], // Minimum absolute fee amount
39    pub fee_bps: [u8; 2],        // Use byte array to avoid endianness issues
40    pub _padding: [u8; 6],       // Pad to 8 bytes for alignment
41}
42
43#[repr(C)]
44#[derive(Clone, Copy, Debug, Pod, Zeroable)]
45pub struct UpdateAuthority {
46    pub new_authority: Pubkey,
47}
48
49#[repr(C)]
50#[derive(Clone, Copy, Debug, Pod, Zeroable)]
51pub struct UpdateFeeRate {
52    pub new_fee_bps: [u8; 2],
53    pub _padding: [u8; 6], // 6 bytes padding
54}
55
56#[repr(C)]
57#[derive(Clone, Copy, Debug, Pod, Zeroable)]
58pub struct UpdateFeeDestination {
59    pub new_fee_destination: Pubkey,
60}
61
62#[repr(C)]
63#[derive(Clone, Copy, Debug, Pod, Zeroable)]
64pub struct UpdateMinFeeAmount {
65    pub new_min_fee_amount: [u8; 8],
66}
67
68instruction!(SettlementInstruction, CreateVault);
69instruction!(SettlementInstruction, Sweep);
70instruction!(SettlementInstruction, Initialize);
71instruction!(SettlementInstruction, UpdateAuthority);
72instruction!(SettlementInstruction, UpdateFeeRate);
73instruction!(SettlementInstruction, UpdateFeeDestination);
74instruction!(SettlementInstruction, UpdateMinFeeAmount);