pub mod cancel_all_orders_row;
pub mod cancel_all_orders_with_free_funds_row;
pub mod cancel_multiple_orders_by_id_row;
pub mod cancel_multiple_orders_by_id_with_free_funds_row;
pub mod cancel_up_to_row;
pub mod cancel_up_to_with_free_funds_row;
pub mod change_fee_recipient_row;
pub mod change_market_status_row;
pub mod change_seat_status_row;
pub mod claim_authority_row;
pub mod collect_fees_row;
pub mod deposit_funds_row;
pub mod evict_seat_row;
pub mod force_cancel_orders_row;
pub mod initialize_market_row;
pub mod log_row;
pub mod name_successor_row;
pub mod place_limit_order_row;
pub mod place_limit_order_with_free_funds_row;
pub mod place_multiple_post_only_orders_row;
pub mod place_multiple_post_only_orders_with_free_funds_row;
pub mod reduce_order_row;
pub mod reduce_order_with_free_funds_row;
pub mod request_seat_authorized_row;
pub mod request_seat_row;
pub mod swap_row;
pub mod swap_with_free_funds_row;
pub mod withdraw_funds_row;
pub use self::{
cancel_all_orders_row::*, cancel_all_orders_with_free_funds_row::*,
cancel_multiple_orders_by_id_row::*, cancel_multiple_orders_by_id_with_free_funds_row::*,
cancel_up_to_row::*, cancel_up_to_with_free_funds_row::*, change_fee_recipient_row::*,
change_market_status_row::*, change_seat_status_row::*, claim_authority_row::*,
collect_fees_row::*, deposit_funds_row::*, evict_seat_row::*, force_cancel_orders_row::*,
initialize_market_row::*, log_row::*, name_successor_row::*, place_limit_order_row::*,
place_limit_order_with_free_funds_row::*, place_multiple_post_only_orders_row::*,
place_multiple_post_only_orders_with_free_funds_row::*, reduce_order_row::*,
reduce_order_with_free_funds_row::*, request_seat_authorized_row::*, request_seat_row::*,
swap_row::*, swap_with_free_funds_row::*, withdraw_funds_row::*,
};
use super::PhoenixV1Instruction;
pub struct PhoenixV1InstructionsMigration;
impl sqlx_migrator::Migration<sqlx::Postgres> for PhoenixV1InstructionsMigration {
fn app(&self) -> &str {
"phoenix-v1"
}
fn name(&self) -> &str {
"phoenix_v1_instructions"
}
fn operations(&self) -> Vec<Box<dyn sqlx_migrator::Operation<sqlx::Postgres>>> {
vec![
Box::new(CancelAllOrdersMigrationOperation),
Box::new(CancelAllOrdersWithFreeFundsMigrationOperation),
Box::new(CancelMultipleOrdersByIdMigrationOperation),
Box::new(CancelMultipleOrdersByIdWithFreeFundsMigrationOperation),
Box::new(CancelUpToMigrationOperation),
Box::new(CancelUpToWithFreeFundsMigrationOperation),
Box::new(ChangeFeeRecipientMigrationOperation),
Box::new(ChangeMarketStatusMigrationOperation),
Box::new(ChangeSeatStatusMigrationOperation),
Box::new(ClaimAuthorityMigrationOperation),
Box::new(CollectFeesMigrationOperation),
Box::new(DepositFundsMigrationOperation),
Box::new(EvictSeatMigrationOperation),
Box::new(ForceCancelOrdersMigrationOperation),
Box::new(InitializeMarketMigrationOperation),
Box::new(LogMigrationOperation),
Box::new(NameSuccessorMigrationOperation),
Box::new(PlaceLimitOrderMigrationOperation),
Box::new(PlaceLimitOrderWithFreeFundsMigrationOperation),
Box::new(PlaceMultiplePostOnlyOrdersMigrationOperation),
Box::new(PlaceMultiplePostOnlyOrdersWithFreeFundsMigrationOperation),
Box::new(ReduceOrderMigrationOperation),
Box::new(ReduceOrderWithFreeFundsMigrationOperation),
Box::new(RequestSeatMigrationOperation),
Box::new(RequestSeatAuthorizedMigrationOperation),
Box::new(SwapMigrationOperation),
Box::new(SwapWithFreeFundsMigrationOperation),
Box::new(WithdrawFundsMigrationOperation),
]
}
fn parents(&self) -> Vec<Box<dyn sqlx_migrator::Migration<sqlx::Postgres>>> {
vec![]
}
}
pub struct PhoenixV1InstructionWithMetadata(
pub PhoenixV1Instruction,
pub carbon_core::instruction::InstructionMetadata,
pub Vec<solana_instruction::AccountMeta>,
);
impl
From<(
PhoenixV1Instruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
)> for PhoenixV1InstructionWithMetadata
{
fn from(
value: (
PhoenixV1Instruction,
carbon_core::instruction::InstructionMetadata,
Vec<solana_instruction::AccountMeta>,
),
) -> Self {
PhoenixV1InstructionWithMetadata(value.0, value.1, value.2)
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Insert for PhoenixV1InstructionWithMetadata {
async fn insert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let PhoenixV1InstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
PhoenixV1Instruction::Swap { data, .. } => {
let row = swap_row::SwapRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::SwapWithFreeFunds { data, .. } => {
let row = swap_with_free_funds_row::SwapWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceLimitOrder { data, .. } => {
let row = place_limit_order_row::PlaceLimitOrderRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceLimitOrderWithFreeFunds { data, .. } => {
let row = place_limit_order_with_free_funds_row::PlaceLimitOrderWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ReduceOrder { data, .. } => {
let row = reduce_order_row::ReduceOrderRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ReduceOrderWithFreeFunds { data, .. } => {
let row = reduce_order_with_free_funds_row::ReduceOrderWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelAllOrders { data, .. } => {
let row = cancel_all_orders_row::CancelAllOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelAllOrdersWithFreeFunds { data, .. } => {
let row = cancel_all_orders_with_free_funds_row::CancelAllOrdersWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelUpTo { data, .. } => {
let row = cancel_up_to_row::CancelUpToRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelUpToWithFreeFunds { data, .. } => {
let row = cancel_up_to_with_free_funds_row::CancelUpToWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelMultipleOrdersById { data, .. } => {
let row = cancel_multiple_orders_by_id_row::CancelMultipleOrdersByIdRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelMultipleOrdersByIdWithFreeFunds { data, .. } => {
let row = cancel_multiple_orders_by_id_with_free_funds_row::CancelMultipleOrdersByIdWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::WithdrawFunds { data, .. } => {
let row = withdraw_funds_row::WithdrawFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::DepositFunds { data, .. } => {
let row = deposit_funds_row::DepositFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::RequestSeat { data, .. } => {
let row = request_seat_row::RequestSeatRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::Log { data, .. } => {
let row = log_row::LogRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceMultiplePostOnlyOrders { data, .. } => {
let row =
place_multiple_post_only_orders_row::PlaceMultiplePostOnlyOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceMultiplePostOnlyOrdersWithFreeFunds { data, .. } => {
let row = place_multiple_post_only_orders_with_free_funds_row::PlaceMultiplePostOnlyOrdersWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::InitializeMarket { data, .. } => {
let row = initialize_market_row::InitializeMarketRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ClaimAuthority { data, .. } => {
let row = claim_authority_row::ClaimAuthorityRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::NameSuccessor { data, .. } => {
let row = name_successor_row::NameSuccessorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeMarketStatus { data, .. } => {
let row = change_market_status_row::ChangeMarketStatusRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeSeatStatus { data, .. } => {
let row = change_seat_status_row::ChangeSeatStatusRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::RequestSeatAuthorized { data, .. } => {
let row = request_seat_authorized_row::RequestSeatAuthorizedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::EvictSeat { data, .. } => {
let row = evict_seat_row::EvictSeatRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ForceCancelOrders { data, .. } => {
let row = force_cancel_orders_row::ForceCancelOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CollectFees { data, .. } => {
let row = collect_fees_row::CollectFeesRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeFeeRecipient { data, .. } => {
let row = change_fee_recipient_row::ChangeFeeRecipientRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.insert(pool).await?;
Ok(())
}
}
}
}
#[async_trait::async_trait]
impl carbon_core::postgres::operations::Upsert for PhoenixV1InstructionWithMetadata {
async fn upsert(&self, pool: &sqlx::PgPool) -> carbon_core::error::CarbonResult<()> {
let PhoenixV1InstructionWithMetadata(decoded_instruction, metadata, raw_accounts) = self;
match decoded_instruction {
PhoenixV1Instruction::Swap { data, .. } => {
let row = swap_row::SwapRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::SwapWithFreeFunds { data, .. } => {
let row = swap_with_free_funds_row::SwapWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceLimitOrder { data, .. } => {
let row = place_limit_order_row::PlaceLimitOrderRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceLimitOrderWithFreeFunds { data, .. } => {
let row = place_limit_order_with_free_funds_row::PlaceLimitOrderWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ReduceOrder { data, .. } => {
let row = reduce_order_row::ReduceOrderRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ReduceOrderWithFreeFunds { data, .. } => {
let row = reduce_order_with_free_funds_row::ReduceOrderWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelAllOrders { data, .. } => {
let row = cancel_all_orders_row::CancelAllOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelAllOrdersWithFreeFunds { data, .. } => {
let row = cancel_all_orders_with_free_funds_row::CancelAllOrdersWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelUpTo { data, .. } => {
let row = cancel_up_to_row::CancelUpToRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelUpToWithFreeFunds { data, .. } => {
let row = cancel_up_to_with_free_funds_row::CancelUpToWithFreeFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelMultipleOrdersById { data, .. } => {
let row = cancel_multiple_orders_by_id_row::CancelMultipleOrdersByIdRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CancelMultipleOrdersByIdWithFreeFunds { data, .. } => {
let row = cancel_multiple_orders_by_id_with_free_funds_row::CancelMultipleOrdersByIdWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::WithdrawFunds { data, .. } => {
let row = withdraw_funds_row::WithdrawFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::DepositFunds { data, .. } => {
let row = deposit_funds_row::DepositFundsRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::RequestSeat { data, .. } => {
let row = request_seat_row::RequestSeatRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::Log { data, .. } => {
let row = log_row::LogRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceMultiplePostOnlyOrders { data, .. } => {
let row =
place_multiple_post_only_orders_row::PlaceMultiplePostOnlyOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::PlaceMultiplePostOnlyOrdersWithFreeFunds { data, .. } => {
let row = place_multiple_post_only_orders_with_free_funds_row::PlaceMultiplePostOnlyOrdersWithFreeFundsRow::from_parts(data.clone(), metadata.clone(), raw_accounts.clone());
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::InitializeMarket { data, .. } => {
let row = initialize_market_row::InitializeMarketRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ClaimAuthority { data, .. } => {
let row = claim_authority_row::ClaimAuthorityRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::NameSuccessor { data, .. } => {
let row = name_successor_row::NameSuccessorRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeMarketStatus { data, .. } => {
let row = change_market_status_row::ChangeMarketStatusRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeSeatStatus { data, .. } => {
let row = change_seat_status_row::ChangeSeatStatusRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::RequestSeatAuthorized { data, .. } => {
let row = request_seat_authorized_row::RequestSeatAuthorizedRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::EvictSeat { data, .. } => {
let row = evict_seat_row::EvictSeatRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ForceCancelOrders { data, .. } => {
let row = force_cancel_orders_row::ForceCancelOrdersRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::CollectFees { data, .. } => {
let row = collect_fees_row::CollectFeesRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
PhoenixV1Instruction::ChangeFeeRecipient { data, .. } => {
let row = change_fee_recipient_row::ChangeFeeRecipientRow::from_parts(
data.clone(),
metadata.clone(),
raw_accounts.clone(),
);
row.upsert(pool).await?;
Ok(())
}
}
}
}