bucks-api 0.2.0

White label stablecoin launchpad
Documentation
use serde::{Deserialize, Serialize};
use steel::*;

/// Bucks protocol event types.
pub enum BucksEvent {
    Wrap = 0,
    Unwrap = 1,
    Claim = 2,
    Rebalance = 3,
    Checkpoint = 4,
    ProtocolInit = 5,
}

/// Emitted when USDC is wrapped into stablecoin.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct WrapEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The user who wrapped.
    pub user: Pubkey,

    /// The stablecoin mint.
    pub mint: Pubkey,

    /// The protocol ID used for deposit.
    pub protocol_id: u64,

    /// The amount of USDC wrapped.
    pub usdc_amount: u64,

    /// The amount of stablecoin minted.
    pub stable_amount: u64,

    /// The shares credited.
    pub shares_minted: u64,

    /// The timestamp of the event.
    pub ts: i64,
}

/// Emitted when stablecoin is unwrapped to USDC.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct UnwrapEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The user who unwrapped.
    pub user: Pubkey,

    /// The stablecoin mint.
    pub mint: Pubkey,

    /// The protocol ID used for withdrawal.
    pub protocol_id: u64,

    /// The amount of stablecoin burned.
    pub stable_amount: u64,

    /// The amount of USDC returned.
    pub usdc_amount: u64,

    /// The shares burned.
    pub shares_burned: u64,

    /// The timestamp of the event.
    pub ts: i64,
}

/// Emitted when a creator claims yield.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct ClaimEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The creator who claimed.
    pub creator: Pubkey,

    /// The stablecoin mint.
    pub mint: Pubkey,

    /// The amount of USDC claimed.
    pub usdc_amount: u64,

    /// The platform fee deducted.
    pub platform_fee: u64,

    /// The timestamp of the event.
    pub ts: i64,
}

/// Emitted when funds are rebalanced between protocols.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct RebalanceEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The source protocol ID.
    pub from_protocol: u64,

    /// The destination protocol ID.
    pub to_protocol: u64,

    /// The USDC amount moved.
    pub usdc_amount: u64,

    /// The timestamp of the event.
    pub ts: i64,
}

/// Emitted when a protocol checkpoint is recorded.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct CheckpointEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The protocol ID checkpointed.
    pub protocol_id: u64,

    /// The new exchange rate (scaled by 1e9).
    pub exchange_rate: u64,

    /// The total USDC value in the protocol.
    pub usdc_value: u64,

    /// The timestamp of the event.
    pub ts: i64,
}

/// Emitted when a new protocol is initialized.
#[repr(C)]
#[derive(Clone, Copy, Debug, Default, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
pub struct ProtocolInitEvent {
    /// The event discriminator.
    pub disc: u64,

    /// The protocol ID initialized.
    pub protocol_id: u64,

    /// The protocol name (first 32 bytes).
    pub name: [u8; 32],

    /// The timestamp of the event.
    pub ts: i64,
}


event!(WrapEvent);
event!(UnwrapEvent);
event!(ClaimEvent);
event!(RebalanceEvent);
event!(CheckpointEvent);
event!(ProtocolInitEvent);