use borsh::{BorshDeserialize, BorshSerialize};
use solana_program::pubkey::Pubkey;
#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum PoolStatus {
#[default]
Fund = 0,
Migrate = 1,
Trade = 2,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq, Eq)]
#[repr(u8)]
pub enum TradeDirection {
Buy = 0,
Sell = 1,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum AmmCreatorFeeOn {
#[default]
Off = 0,
Quote = 1,
Both = 2,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum CurveType {
#[default]
ConstantProduct = 0,
FixedPrice = 1,
LinearPrice = 2,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Copy, Debug, PartialEq, Eq, Default)]
#[repr(u8)]
pub enum MigrateType {
#[default]
Amm = 0,
CpSwap = 1,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct MintParams {
pub decimals: u8,
pub name: String,
pub symbol: String,
pub uri: String,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct CurveParams {
pub supply: u64,
pub total_quote_fund_raising: u64,
pub migrate_type: u8,
pub migrate_fee: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct VestingParams {
pub total_locked_amount: u64,
pub cliff_period: u64,
pub unlock_period: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct VestingSchedule {
pub total_locked_amount: u64,
pub cliff_period: u64,
pub unlock_period: u64,
pub start_time: u64,
pub allocated_share_amount: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct PlatformParams {
pub migrate_nft_info: MigrateNftInfo,
pub fee_rate: u64,
pub name: String,
pub web: String,
pub img: String,
pub creator_fee_rate: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct MigrateNftInfo {
pub symbol: String,
pub name: String,
pub uri: String,
pub is_mutable: bool,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct BondingCurveParam {
pub supply: u64,
pub total_quote_fund_raising: u64,
pub migrate_fee: u64,
pub allow_creator_fee_on: bool,
pub decimals: u8,
pub name: String,
pub symbol: String,
pub uri: String,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug)]
pub enum PlatformConfigParam {
FeeWallet(Pubkey),
NftWallet(Pubkey),
FeeRate(u64),
NftInfo(MigrateNftInfo),
CpswapConfig(Pubkey),
Name(String),
Web(String),
Img(String),
CreatorFeeRate(u64),
TransferFeeExtensionAuthority(Pubkey),
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug, Default)]
pub struct TransferFeeExtensionParams {
pub transfer_fee_basis_points: u16,
pub maximum_fee: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug)]
pub struct PoolCreateEvent {
pub pool_state: Pubkey,
pub creator: Pubkey,
pub config: Pubkey,
pub base_mint_param: MintParams,
pub curve_param: CurveParams,
pub vesting_param: VestingParams,
pub amm_fee_on: AmmCreatorFeeOn,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug)]
pub struct TradeEvent {
pub pool_state: Pubkey,
pub total_base_sell: u64,
pub virtual_base: u64,
pub virtual_quote: u64,
pub real_base_before: u64,
pub real_quote_before: u64,
pub real_base_after: u64,
pub real_quote_after: u64,
pub amount_in: u64,
pub amount_out: u64,
pub protocol_fee: u64,
pub platform_fee: u64,
pub creator_fee: u64,
pub share_fee: u64,
pub trade_direction: TradeDirection,
pub pool_status: PoolStatus,
pub exact_in: bool,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug)]
pub struct CreateVestingEvent {
pub pool: Pubkey,
pub beneficiary: Pubkey,
pub share_amount: u64,
}
#[derive(BorshSerialize, BorshDeserialize, Clone, Debug)]
pub struct ClaimVestedEvent {
pub pool: Pubkey,
pub beneficiary: Pubkey,
pub amount: u64,
}
pub mod discriminators {
pub const BUY_EXACT_IN: [u8; 8] = [250, 234, 13, 123, 213, 156, 19, 236];
pub const BUY_EXACT_OUT: [u8; 8] = [24, 211, 116, 40, 105, 3, 153, 56];
pub const SELL_EXACT_IN: [u8; 8] = [149, 39, 222, 155, 211, 124, 152, 26];
pub const SELL_EXACT_OUT: [u8; 8] = [95, 200, 71, 34, 8, 9, 11, 166];
pub const INITIALIZE: [u8; 8] = [175, 175, 109, 31, 13, 152, 155, 237];
pub const INITIALIZE_V2: [u8; 8] = [67, 153, 175, 39, 218, 16, 38, 32];
pub const INITIALIZE_WITH_TOKEN_2022: [u8; 8] = [37, 190, 126, 222, 44, 154, 171, 17];
pub const CLAIM_CREATOR_FEE: [u8; 8] = [26, 97, 138, 203, 132, 171, 141, 252];
pub const CLAIM_PLATFORM_FEE: [u8; 8] = [156, 39, 208, 135, 76, 237, 61, 72];
pub const CLAIM_PLATFORM_FEE_FROM_VAULT: [u8; 8] = [117, 241, 198, 168, 248, 218, 80, 29];
pub const CLAIM_VESTED_TOKEN: [u8; 8] = [49, 33, 104, 30, 189, 157, 79, 35];
pub const COLLECT_FEE: [u8; 8] = [60, 173, 247, 103, 4, 93, 130, 48];
pub const COLLECT_MIGRATE_FEE: [u8; 8] = [255, 186, 150, 223, 235, 118, 201, 186];
pub const CREATE_CONFIG: [u8; 8] = [201, 207, 243, 114, 75, 111, 47, 189];
pub const CREATE_PLATFORM_CONFIG: [u8; 8] = [176, 90, 196, 175, 253, 113, 220, 20];
pub const CREATE_VESTING_ACCOUNT: [u8; 8] = [129, 178, 2, 13, 217, 172, 230, 218];
pub const MIGRATE_TO_AMM: [u8; 8] = [207, 82, 192, 145, 254, 207, 145, 223];
pub const MIGRATE_TO_CPSWAP: [u8; 8] = [136, 92, 200, 103, 28, 218, 144, 140];
pub const UPDATE_CONFIG: [u8; 8] = [29, 158, 252, 191, 10, 83, 219, 99];
pub const UPDATE_PLATFORM_CONFIG: [u8; 8] = [195, 60, 76, 129, 146, 45, 67, 143];
pub const UPDATE_PLATFORM_CURVE_PARAM: [u8; 8] = [138, 144, 138, 250, 220, 128, 4, 57];
pub const REMOVE_PLATFORM_CURVE_PARAM: [u8; 8] = [27, 30, 62, 169, 93, 224, 24, 145];
}
pub mod account_discriminators {
pub const GLOBAL_CONFIG: [u8; 8] = [149, 8, 156, 202, 160, 252, 176, 217];
pub const PLATFORM_CONFIG: [u8; 8] = [160, 78, 128, 0, 248, 83, 230, 160];
pub const POOL_STATE: [u8; 8] = [247, 237, 227, 245, 215, 195, 222, 70];
pub const VESTING_RECORD: [u8; 8] = [106, 243, 221, 205, 230, 126, 85, 83];
}