gmsol_store/instructions/exchange/
mod.rs

1/// Deposit creation and cancellation.
2pub mod deposit;
3
4/// Withdrawal creation and cancellation.
5pub mod withdrawal;
6
7/// Order creation and cancellation.
8pub mod order;
9
10/// Execute Deposit.
11pub mod execute_deposit;
12
13/// Execute Withdrawal.
14pub mod execute_withdrawal;
15
16/// Execute Order.
17pub mod execute_order;
18
19/// Update ADL state.
20pub mod update_adl;
21
22/// Position cut.
23pub mod position_cut;
24
25/// Creation and cancellation for shift.
26pub mod shift;
27
28/// Execute shift.
29pub mod execute_shift;
30
31pub use deposit::*;
32pub use execute_deposit::*;
33pub use execute_order::*;
34pub use execute_shift::*;
35pub use execute_withdrawal::*;
36pub use order::*;
37pub use position_cut::*;
38pub use shift::*;
39pub use update_adl::*;
40pub use withdrawal::*;
41
42use crate::CoreError;
43
44pub(crate) struct ModelError(gmsol_model::Error);
45
46impl From<gmsol_model::Error> for ModelError {
47    fn from(err: gmsol_model::Error) -> Self {
48        Self(err)
49    }
50}
51
52impl From<ModelError> for anchor_lang::prelude::Error {
53    fn from(err: ModelError) -> Self {
54        match err.0 {
55            gmsol_model::Error::EmptyDeposit => CoreError::EmptyDeposit.into(),
56            gmsol_model::Error::Solana(err) => err,
57            core_error => {
58                crate::msg!("A model error occurred. Error Message: {}", core_error);
59                CoreError::Model.into()
60            }
61        }
62    }
63}