Log Structure
The Something Cool platform emits structured logs during various operations, which can be useful for tracking events, auditing, and debugging. This page documents the log structures used by both SC Bonding Curve and CoolDEX components.
SC Bonding Curve Logs
SC Bonding Curve emits logs for token creation, buying, and selling operations.
Log Types
/// LogType enum
#[derive(Debug)]
pub enum LogType {
Buy,
Sell,
Create,
}
impl LogType {
pub fn into_u8(&self) -> u8 {
match self {
LogType::Buy => 0u8,
LogType::Sell => 1u8,
LogType::Create => 2u8,
}
}
}
Buy Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BuyLog {
pub log_type: u8, // 0 for Buy
pub sol_in: u64, // Amount of SOL spent
pub token_out: u64, // Amount of tokens received
pub is_finalized: bool, // Whether this transaction finalized the token sale
pub vsol_after_trade: u64, // Virtual SOL balance after trade
pub vtoken_after_trade: u64, // Virtual token balance after trade
}
Sell Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SellLog {
pub log_type: u8, // 1 for Sell
pub token_in: u64, // Amount of tokens sold
pub sol_out: u64, // Amount of SOL received
pub vsol_after_trade: u64, // Virtual SOL balance after trade
pub vtoken_after_trade: u64, // Virtual token balance after trade
}
Create Token Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct CreateTokenLog {
pub log_type: u8, // 2 for Create
pub vsol_added: u64, // Initial virtual SOL amount
pub vtoken_added: u64, // Initial virtual token amount
}
CoolDEX Logs
CoolDEX emits logs for initialization, deposits, withdrawals, and swap operations.
Log Types
/// DEX LogType enum
#[derive(Debug)]
pub enum DexLogType {
Init,
Deposit,
Withdraw,
SwapBaseIn,
SwapBaseOut,
}
impl DexLogType {
pub fn into_u8(&self) -> u8 {
match self {
DexLogType::Init => 0u8,
DexLogType::Deposit => 1u8,
DexLogType::Withdraw => 2u8,
DexLogType::SwapBaseIn => 3u8,
DexLogType::SwapBaseOut => 4u8,
}
}
}
Init Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct InitLog {
pub log_type: u8, // 0 for Init
pub time: u64, // Timestamp
pub pc_decimals: u8, // PC token decimals
pub coin_decimals: u8, // Coin token decimals
pub pc_lot_size: u64, // PC lot size
pub coin_lot_size: u64, // Coin lot size
pub pc_amount: u64, // Initial PC amount
pub coin_amount: u64, // Initial coin amount
pub market: Pubkey, // Market address
}
Deposit Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DepositLog {
pub log_type: u8, // 1 for Deposit
pub max_coin: u64, // Maximum coin amount
pub max_pc: u64, // Maximum PC amount
pub base: u64, // Base side (0 for coin, 1 for PC)
pub pool_coin: u64, // Pool coin amount
pub pool_pc: u64, // Pool PC amount
pub pool_lp: u64, // Pool LP amount
pub calc_pnl_x: u64, // Calculated PnL X
pub calc_pnl_y: u64, // Calculated PnL Y
pub deduct_coin: u64, // Deducted coin amount
pub deduct_pc: u64, // Deducted PC amount
pub mint_lp: u64, // Minted LP amount
}
Withdraw Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WithdrawLog {
pub log_type: u8, // 2 for Withdraw
pub withdraw_lp: u64, // LP amount to withdraw
pub user_lp: u64, // User's LP balance
pub pool_coin: u64, // Pool coin amount
pub pool_pc: u64, // Pool PC amount
pub pool_lp: u64, // Pool LP amount
pub calc_pnl_x: u64, // Calculated PnL X
pub calc_pnl_y: u64, // Calculated PnL Y
pub out_coin: u64, // Output coin amount
pub out_pc: u64, // Output PC amount
}
SwapBaseIn Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SwapBaseInLog {
pub log_type: u8, // 3 for SwapBaseIn
pub amount_in: u64, // Input amount
pub minimum_out: u64, // Minimum output amount
pub direction: u64, // Swap direction (0 for Coin2PC, 1 for PC2Coin)
pub user_source: u64, // User source balance
pub pool_coin: u64, // Pool coin amount
pub pool_pc: u64, // Pool PC amount
pub out_amount: u64, // Output amount
}
SwapBaseOut Log Structure
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SwapBaseOutLog {
pub log_type: u8, // 4 for SwapBaseOut
pub max_in: u64, // Maximum input amount
pub amount_out: u64, // Output amount
pub direction: u64, // Swap direction (0 for Coin2PC, 1 for PC2Coin)
pub user_source: u64, // User source balance
pub pool_coin: u64, // Pool coin amount
pub pool_pc: u64, // Pool PC amount
pub deduct_in: u64, // Deducted input amount
}
Last updated