carbon_phoenix_v1_decoder/instructions/
mod.rs

1use crate::PROGRAM_ID;
2
3use super::PhoenixDecoder;
4pub mod cancel_all_orders;
5pub mod cancel_all_orders_with_free_funds;
6pub mod cancel_multiple_orders_by_id;
7pub mod cancel_multiple_orders_by_id_with_free_funds;
8pub mod cancel_up_to;
9pub mod cancel_up_to_with_free_funds;
10pub mod change_fee_recipient;
11pub mod change_market_status;
12pub mod change_seat_status;
13pub mod claim_authority;
14pub mod collect_fees;
15pub mod deposit_funds;
16pub mod evict_seat;
17pub mod force_cancel_orders;
18pub mod initialize_market;
19pub mod log;
20pub mod name_successor;
21pub mod place_limit_order;
22pub mod place_limit_order_with_free_funds;
23pub mod place_multiple_post_only_orders;
24pub mod place_multiple_post_only_orders_with_free_funds;
25pub mod reduce_order;
26pub mod reduce_order_with_free_funds;
27pub mod request_seat;
28pub mod request_seat_authorized;
29pub mod swap;
30pub mod swap_with_free_funds;
31pub mod withdraw_funds;
32
33#[derive(
34    carbon_core::InstructionType,
35    serde::Serialize,
36    serde::Deserialize,
37    PartialEq,
38    Eq,
39    Debug,
40    Clone,
41    Hash,
42)]
43pub enum PhoenixInstruction {
44    Swap(swap::Swap),
45    SwapWithFreeFunds(swap_with_free_funds::SwapWithFreeFunds),
46    PlaceLimitOrder(place_limit_order::PlaceLimitOrder),
47    PlaceLimitOrderWithFreeFunds(place_limit_order_with_free_funds::PlaceLimitOrderWithFreeFunds),
48    ReduceOrder(reduce_order::ReduceOrder),
49    ReduceOrderWithFreeFunds(reduce_order_with_free_funds::ReduceOrderWithFreeFunds),
50    CancelAllOrders(cancel_all_orders::CancelAllOrders),
51    CancelAllOrdersWithFreeFunds(cancel_all_orders_with_free_funds::CancelAllOrdersWithFreeFunds),
52    CancelUpTo(cancel_up_to::CancelUpTo),
53    CancelUpToWithFreeFunds(cancel_up_to_with_free_funds::CancelUpToWithFreeFunds),
54    CancelMultipleOrdersById(cancel_multiple_orders_by_id::CancelMultipleOrdersById),
55    CancelMultipleOrdersByIdWithFreeFunds(
56        cancel_multiple_orders_by_id_with_free_funds::CancelMultipleOrdersByIdWithFreeFunds,
57    ),
58    WithdrawFunds(withdraw_funds::WithdrawFunds),
59    DepositFunds(deposit_funds::DepositFunds),
60    RequestSeat(request_seat::RequestSeat),
61    Log(log::Log),
62    PlaceMultiplePostOnlyOrders(place_multiple_post_only_orders::PlaceMultiplePostOnlyOrders),
63    PlaceMultiplePostOnlyOrdersWithFreeFunds(
64        place_multiple_post_only_orders_with_free_funds::PlaceMultiplePostOnlyOrdersWithFreeFunds,
65    ),
66    InitializeMarket(initialize_market::InitializeMarket),
67    ClaimAuthority(claim_authority::ClaimAuthority),
68    NameSuccessor(name_successor::NameSuccessor),
69    ChangeMarketStatus(change_market_status::ChangeMarketStatus),
70    ChangeSeatStatus(change_seat_status::ChangeSeatStatus),
71    RequestSeatAuthorized(request_seat_authorized::RequestSeatAuthorized),
72    EvictSeat(evict_seat::EvictSeat),
73    ForceCancelOrders(force_cancel_orders::ForceCancelOrders),
74    CollectFees(collect_fees::CollectFees),
75    ChangeFeeRecipient(change_fee_recipient::ChangeFeeRecipient),
76}
77
78impl carbon_core::instruction::InstructionDecoder<'_> for PhoenixDecoder {
79    type InstructionType = PhoenixInstruction;
80
81    fn decode_instruction(
82        &self,
83        instruction: &solana_instruction::Instruction,
84    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
85        if !instruction.program_id.eq(&PROGRAM_ID) {
86            return None;
87        }
88
89        carbon_core::try_decode_instructions!(instruction,
90            PhoenixInstruction::Swap => swap::Swap,
91            PhoenixInstruction::SwapWithFreeFunds => swap_with_free_funds::SwapWithFreeFunds,
92            PhoenixInstruction::PlaceLimitOrder => place_limit_order::PlaceLimitOrder,
93            PhoenixInstruction::PlaceLimitOrderWithFreeFunds => place_limit_order_with_free_funds::PlaceLimitOrderWithFreeFunds,
94            PhoenixInstruction::ReduceOrder => reduce_order::ReduceOrder,
95            PhoenixInstruction::ReduceOrderWithFreeFunds => reduce_order_with_free_funds::ReduceOrderWithFreeFunds,
96            PhoenixInstruction::CancelAllOrders => cancel_all_orders::CancelAllOrders,
97            PhoenixInstruction::CancelAllOrdersWithFreeFunds => cancel_all_orders_with_free_funds::CancelAllOrdersWithFreeFunds,
98            PhoenixInstruction::CancelUpTo => cancel_up_to::CancelUpTo,
99            PhoenixInstruction::CancelUpToWithFreeFunds => cancel_up_to_with_free_funds::CancelUpToWithFreeFunds,
100            PhoenixInstruction::CancelMultipleOrdersById => cancel_multiple_orders_by_id::CancelMultipleOrdersById,
101            PhoenixInstruction::CancelMultipleOrdersByIdWithFreeFunds => cancel_multiple_orders_by_id_with_free_funds::CancelMultipleOrdersByIdWithFreeFunds,
102            PhoenixInstruction::WithdrawFunds => withdraw_funds::WithdrawFunds,
103            PhoenixInstruction::DepositFunds => deposit_funds::DepositFunds,
104            PhoenixInstruction::RequestSeat => request_seat::RequestSeat,
105            PhoenixInstruction::Log => log::Log,
106            PhoenixInstruction::PlaceMultiplePostOnlyOrders => place_multiple_post_only_orders::PlaceMultiplePostOnlyOrders,
107            PhoenixInstruction::PlaceMultiplePostOnlyOrdersWithFreeFunds => place_multiple_post_only_orders_with_free_funds::PlaceMultiplePostOnlyOrdersWithFreeFunds,
108            PhoenixInstruction::InitializeMarket => initialize_market::InitializeMarket,
109            PhoenixInstruction::ClaimAuthority => claim_authority::ClaimAuthority,
110            PhoenixInstruction::NameSuccessor => name_successor::NameSuccessor,
111            PhoenixInstruction::ChangeMarketStatus => change_market_status::ChangeMarketStatus,
112            PhoenixInstruction::ChangeSeatStatus => change_seat_status::ChangeSeatStatus,
113            PhoenixInstruction::RequestSeatAuthorized => request_seat_authorized::RequestSeatAuthorized,
114            PhoenixInstruction::EvictSeat => evict_seat::EvictSeat,
115            PhoenixInstruction::ForceCancelOrders => force_cancel_orders::ForceCancelOrders,
116            PhoenixInstruction::CollectFees => collect_fees::CollectFees,
117            PhoenixInstruction::ChangeFeeRecipient => change_fee_recipient::ChangeFeeRecipient,
118        )
119    }
120}