1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use cosmwasm_std::Decimal;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Serialize_repr, Deserialize_repr, Copy, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)]
#[repr(i32)]
pub enum PositionDirection {
Long = 0,
Short = 1,
}
#[derive(Serialize_repr, Deserialize_repr, Copy, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)]
#[repr(i32)]
pub enum OrderType {
Limit = 0,
Market = 1,
Liquidation = 2,
Fokmarket = 3, Fokmarketbyvalue = 4, }
#[derive(Serialize_repr, Deserialize_repr, Copy, Clone, Debug, PartialEq, Eq, Hash, JsonSchema)]
#[repr(i32)]
pub enum OrderStatus {
Placed = 0,
FailedToPlace = 1,
Cancelled = 2,
Fulfilled = 3,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct Order {
pub price: Decimal,
pub quantity: Decimal,
pub price_denom: String,
pub asset_denom: String,
pub order_type: OrderType,
pub position_direction: PositionDirection,
pub data: String, pub status_description: String,
pub nominal: Decimal, }
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct OrderResponse {
pub id: u64,
pub status: OrderStatus,
pub price: Decimal,
pub quantity: Decimal,
pub price_denom: String,
pub asset_denom: String,
pub order_type: OrderType,
pub position_direction: PositionDirection,
pub data: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct ContractOrderResult {
pub contract_address: String,
pub order_placement_results: Vec<OrderPlacementResult>,
pub order_execution_results: Vec<OrderExecutionResult>,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct OrderPlacementResult {
pub order_id: u64,
pub status_code: i32,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct OrderExecutionResult {
pub order_id: u64,
pub execution_price: Decimal,
pub executed_quantity: Decimal,
pub total_notional: Decimal,
pub position_direction: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct SettlementEntry {
pub account: String,
pub price_denom: String,
pub asset_denom: String,
pub quantity: Decimal,
pub execution_cost_or_proceed: Decimal,
pub expected_cost_or_proceed: Decimal,
pub position_direction: PositionDirection,
pub order_type: OrderType,
pub order_id: u64,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct DepositInfo {
pub account: String,
pub denom: String,
pub amount: Decimal,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct LiquidationRequest {
pub requestor: String,
pub account: String,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct LiquidationResponse {
pub successful_accounts: Vec<String>,
pub liquidation_orders: Vec<Order>,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct BulkOrderPlacementsResponse {
pub unsuccessful_orders: Vec<UnsuccessfulOrder>,
}
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema)]
pub struct UnsuccessfulOrder {
pub id: u64,
pub reason: String,
}