bucks-api 0.2.0

White label stablecoin launchpad
Documentation
use steel::*;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum BucksInstruction {
    // Creator instructions
    Create = 0,
    Claim = 1,
    UpdateAuthority = 2,

    // User instructions
    Wrap = 100,
    Unwrap = 101,

    // Admin instructions
    Init = 200,
    InitProtocol = 201,
    Rebalance = 202,
    Checkpoint = 203,
    SetPrimaryProtocol = 205,
    SetPaused = 206,
    CollectPlatformFee = 207,
    SetTreasury = 208,
    DeleteVault = 209,

    // Log instruction (CPI only)
    Log = 250,
}

// =============================================================================
// Creator Instructions
// =============================================================================

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Create {
    pub id: [u8; 32],
    pub name: [u8; 32],
    pub symbol: [u8; 32],
    pub noise: [u8; 32],
    pub bump: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Claim {
    pub amount: [u8; 8],
    /// Minimum USDC to receive (slippage protection).
    pub min_usdc_out: [u8; 8],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct UpdateAuthority {
    /// The new authority address.
    pub new_authority: [u8; 32],
}

// =============================================================================
// User Instructions
// =============================================================================

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

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Unwrap {
    pub amount: [u8; 8],
    /// Minimum USDC to receive (slippage protection).
    pub min_usdc_out: [u8; 8],
}

// =============================================================================
// Admin Instructions
// =============================================================================

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Init {
    /// Platform fee in basis points (1000 = 10%).
    pub platform_fee_bps: [u8; 2],
    /// Padding for alignment.
    pub _padding: [u8; 6],
    /// Treasury address for platform fee collection.
    pub treasury: [u8; 32],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct InitProtocol {
    /// The protocol ID to initialize (0 = Kamino, 1 = Perena).
    pub protocol_id: u8,
    /// Human-readable name of the protocol (padded to 32 bytes).
    pub name: [u8; 32],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Rebalance {
    /// The source protocol ID.
    pub from_protocol: u8,
    /// The destination protocol ID.
    pub to_protocol: u8,
    /// Padding for alignment.
    pub _padding: [u8; 6],
    /// The amount of USDC value to move.
    pub amount: [u8; 8],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Checkpoint {
    /// The protocol ID to checkpoint (255 = all protocols).
    pub protocol_id: u8,
}


#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetPrimaryProtocol {
    /// The new primary protocol ID.
    pub protocol_id: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetPaused {
    /// 0 = unpause, 1 = pause.
    pub paused: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct CollectPlatformFee {
    /// Protocol ID to collect fees from.
    pub protocol_id: u8,
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct SetTreasury {
    /// New treasury address.
    pub treasury: [u8; 32],
}

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct DeleteVault {}

// =============================================================================
// Log Instruction
// =============================================================================

#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Log {}

// =============================================================================
// Instruction Macros
// =============================================================================

instruction!(BucksInstruction, Create);
instruction!(BucksInstruction, Claim);
instruction!(BucksInstruction, UpdateAuthority);
instruction!(BucksInstruction, Wrap);
instruction!(BucksInstruction, Unwrap);
instruction!(BucksInstruction, Init);
instruction!(BucksInstruction, InitProtocol);
instruction!(BucksInstruction, Rebalance);
instruction!(BucksInstruction, Checkpoint);
instruction!(BucksInstruction, SetPrimaryProtocol);
instruction!(BucksInstruction, SetPaused);
instruction!(BucksInstruction, CollectPlatformFee);
instruction!(BucksInstruction, SetTreasury);
instruction!(BucksInstruction, DeleteVault);
instruction!(BucksInstruction, Log);