-
Notifications
You must be signed in to change notification settings - Fork 4
/
data_models.py
181 lines (132 loc) · 2.89 KB
/
data_models.py
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
"""
/pairs -> Details on cryptoassets traded on an exchange.
/tickers -> Market related statistics for all markets for the last 24 hours.
/orderbook -> Order book depth of any given trading pair, split into two different arrays for bid and ask orders.
/historical -> Historical trade data for any given trading pair.
What are the pairs available
## Pairs
ticker_id string Mandatory Identifier of a ticker with delimiter to separate base/target, eg. BTC_ETH
base string Mandatory Symbol/currency code of a the base cryptoasset, eg. BTC
target string Mandatory Symbol/currency code of the target cryptoasset, eg. ETH
## Tickers
{
"ticker_id": "BTC_ETH",
"base_currency": "BTC",
"target_currency": "ETH",
"last_price":"50.0",
"base_volume":"10",
"target_volume":"500",
"bid":"49.9",
"ask":"50.1",
"high":”51.3”,
“low”:”49.2”,
}
## Orderbook
Get orders: bid and ask by ticker_id
{
"ticker_id": "BTC_ETH",
"timestamp":"1700050000",
"bids":[
[
"49.8",
"0.50000000"
],
[
"49.9",
"6.40000000"
]
],
"asks":[
[
"50.1",
"9.20000000"
],
[
"50.2",
"7.9000000"
]
]
}
## Historical trades
Example query:
.../api/historical_trades?ticker_id=BTC_ETH&limit=10
“buy”: [
{
"trade_id":1234567,
"price":"50.1",
"base_volume":"0.1",
"target_volume":"1",
"trade_timestamp":"1700050000",
"type":"buy"
}
],
“Sell”: [
{
"trade_id":1234567,
"price":"50.1",
"base_volume":"0.1",
"target_volume":"1",
"trade_timestamp":"1700050000",
"type":"sell"
}
]
DAI -> Oracle asset
Map the query
block 15:000 - what was the xor
XOR to DAI
XOR and VAL - converion
Some of the assets - we will get a different price
Ignore -
Withdraw & Adding LIQUIDITY
- Market depth
USDT
UCDC
"""
from dataclasses import dataclass
from typing import List, Tuple
@dataclass
class SoraOp:
id: int
timestamp: int
xor_fee: int
@dataclass
class LiquidityTx(SoraOp):
input_asset_id: str
output_asset_id: str
in_amount: int
out_amount: int
@dataclass
class Swap(LiquidityTx):
filter_mode: str
swap_fee_amount: int
intermediate_amounts: List[Tuple[str, int]]
dex_id: int
@dataclass
class Withdraw(LiquidityTx):
pass
@dataclass
class Deposit(LiquidityTx):
pass
@dataclass
class InBridgeTx(SoraOp):
asset_id: str
amount: float
external_hash: str
@dataclass
class OutBridgeTx(SoraOp):
asset_id: str
amount: float
address: str
ext_type: str
@dataclass
class ClaimTx(SoraOp):
asset_id: str
amount: float
@dataclass
class TransferTx(SoraOp):
asset_id: str
amount: float
@dataclass
class BondStakeTx(SoraOp):
batch_type: str
batch_amount: float