universalsettle-api 0.1.2

X402-inspired settlement program for any token on Solana
Documentation
use steel::*;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum SettlementInstruction {
    // User (public — no authority required)
    Sweep = 0,       // Indirect/batch settlement sweep
    CreateVault = 1, // Setup SplitVault for a seller
    // 2–99 reserved for future public instructions

    // Admin (require Config authority signer)
    Initialize = 100,
    UpdateAuthority = 101,
    UpdateFeeRate = 102,
    UpdateFeeDestination = 103,
    UpdateMinFeeAmount = 104,
    UpdateProvisioningFee = 105,
    UpdateDiscountedFeeRate = 106,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct CreateVault {
    pub seller: Pubkey, // 32 bytes - Resource owner wallet address
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Sweep {
    pub token_mint: Pubkey, // For SOL: Pubkey::default(), For SPL: the mint address
    pub amount: [u8; 8],    // Amount to sweep (0 = all available)
    pub is_sol: [u8; 1],    // 1 for native SOL, 0 for SPL token
    pub _padding: [u8; 7],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Initialize {
    pub fee_destination: Pubkey,       // 32
    pub min_fee_amount: [u8; 8],       // 8
    pub provisioning_fee_sol: [u8; 8], // 8
    pub provisioning_fee_spl: [u8; 8], // 8
    pub fee_bps: [u8; 2],              // 2
    pub discounted_fee_bps: [u8; 2],   // 2
    pub _padding: [u8; 4],             // 4
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateAuthority {
    pub new_authority: Pubkey,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateFeeRate {
    pub new_fee_bps: [u8; 2],
    pub _padding: [u8; 6], // 6 bytes padding
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateFeeDestination {
    pub new_fee_destination: Pubkey,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateMinFeeAmount {
    pub new_min_fee_amount: [u8; 8],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateProvisioningFee {
    pub new_provisioning_fee_sol: [u8; 8],
    pub new_provisioning_fee_spl: [u8; 8],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateDiscountedFeeRate {
    pub new_discounted_fee_bps: [u8; 2],
    pub _padding: [u8; 6],
}

instruction!(SettlementInstruction, CreateVault);
instruction!(SettlementInstruction, Sweep);
instruction!(SettlementInstruction, Initialize);
instruction!(SettlementInstruction, UpdateAuthority);
instruction!(SettlementInstruction, UpdateFeeRate);
instruction!(SettlementInstruction, UpdateFeeDestination);
instruction!(SettlementInstruction, UpdateMinFeeAmount);
instruction!(SettlementInstruction, UpdateProvisioningFee);
instruction!(SettlementInstruction, UpdateDiscountedFeeRate);