-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmodels.ts
More file actions
386 lines (354 loc) · 12 KB
/
Copy pathmodels.ts
File metadata and controls
386 lines (354 loc) · 12 KB
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
export interface AccountTrade {
order_id: string;
market_id: string;
side: string;
price: string; // string representation of number
quantity: string; // string representation of number
fee_amount: string; // string representation of number
fee_denom: string; // string representation of number
address: string;
block_height: number;
block_created_at: string; // string representation of timestamp
trade_id: number;
}
export interface HistoryOrder {
address: string;
allocated_margin: string;
avg_filled_price: string;
available: string;
block_created_at: string;
block_height: number;
filled: string;
id: string;
initiator: string;
is_liquidation?: boolean;
is_post_only?: boolean;
is_reduce_only?: boolean;
market_id: string;
order_type: string;
pool_id?: number;
price: string;
quantity: string;
side: string;
status: string;
stop_price: string;
// old orders may not have time_in_force field
time_in_force?: string;
trigger_type: string;
triggered_block_height: number;
referral_address?: string;
referral_commission?: number;
referral_kickback?: number;
cancel_reason?: number;
}
// This is added to account for the updated data model
// Use this for order history websocket queries
export interface BaseHistoryOrder extends HistoryOrder {
allocated_margin_amount: string;
allocated_margin_denom: string;
last_updated_block_height: number;
username?: string;
}
// order history ws event
export interface BaseHistoryOrderEvent extends BaseHistoryOrder {
type?: string;
}
export interface Candlestick {
time: string; // string representation of timestamp
close: string;
market_id: string;
open: string;
high: string;
low: string;
volume: string;
quote_volume: string;
resolution: number;
}
export interface RecentTrade {
block_created_at: string;
block_height: number;
market_id: string;
price: string;
quantity: string;
id?: string;
liquidation?: string;
taker_id?: string;
taker_side?: string;
taker_address?: string;
taker_fee_amount?: string;
taker_fee_denom?: string;
taker_fee_kickback?: string;
taker_fee_commission?: string;
taker_fee_commission_address?: string;
maker_id?: string;
maker_side?: string;
maker_address?: string;
maker_fee_amount?: string;
maker_fee_denom?: string;
maker_fee_kickback?: string;
maker_fee_commission?: string;
maker_fee_commission_address?: string;
}
export interface Position {
market_id: string;
address: string;
trade_id: string; // string representation of number
side: string;
opened_block_height: number;
updated_block_height: number;
closed_block_height?: number;
realized_pnl: string; // string representation of number
max_lots: string; // string representation of number
total_fee_amount: string; // string representation of number
avg_allocated_margin?: string; // string representation of number
avg_entry_price: string; // string representation of number
avg_exit_price: string; // string representation of number
allocated_margin?: string; // string representation of number
lots: string; // string representation of number
opened_at: string; // string representation of timestamp
closed_at?: string; // string representation of timestamp
}
// Note: premium_rate/last_funding_at/open_interest is optional until after v2.9.0 upgrade
// where these fields will be added permanently
export interface MarketStat {
day_high: string;
day_low: string;
day_open: string;
day_close: string;
day_volume: string;
day_quote_volume: string;
index_price: string;
mark_price: string;
last_price: string;
market_id: string;
market_type: string;
premium_rate: string;
last_funding_at: string;
open_interest: string;
}
export interface PriceLevel {
price: string; // string representation of number
quantity: string; // string representation of number
market?: string;
side?: string;
}
// price level ws event
export interface PriceLevelEvent extends PriceLevel {
type?: string; // only for ws event
}
export interface Leverage {
market_id?: string;
leverage: string; // string representation of number
is_cross?: boolean;
}
export interface Pool {
pool: {
creator: string;
id: number;
name: string;
denom: string;
denom_a: string;
amount_a: string; // string representation of number
weight_a: string; // string representation of number
denom_b: string;
amount_b: string; // string representation of number
weight_b: string; // string representation of number
swap_fee: string; // string representation of number
shares_amount: string; // string representation of number
amp_bps: string;
v_amount_a: string;
v_amount_b: string;
is_deprecated?: boolean;
};
rewards_weight: string; // string representation of number
total_commitment: string; // string representation of number
}
export interface Commitment {
denom: string;
amount: string; // string representation of number
start_time: string; // string representation of date isostring
end_time: string; // string representation of date isostring
duration?: number;
is_locked: boolean;
commitment_power: string; // string representation of number
boost_factor: string; // string representation of number
}
// commitment ws event
export interface CommitmentEvent extends Commitment {
Type?: string;
}
export interface TokenPrice {
denom: string;
index: string; // string representation of number
index_updated_at: string; // string representation of timestamp
twap: string; // string representation of number
}
export interface CDPParams {
interest_fee: string; // string representation of number
liquidation_fee: string; // string representation of number
stablecoin_interest_rate: string; // string representation of number
stablecoin_mint_cap: string; // string representation of number
complete_liquidation_threshold: string; // string representation of number
minimum_close_factor: string; // string representation of number
small_liquidation_size: string; // string representation of number
stale_price_grace_period: string;
cdp_paused: boolean;
stablecoin_interest_rate_epoch: string;
stablecoin_interest_rate_adjuster_coefficient?: string;
}
export interface StablecoinInterestInfo {
last_updated_time: string;
stablecoin_interest_rate: string; // string representation of number
}
export interface RateStrategy {
// CDP
name: string;
optimal_usage: string; // string representation of number
base_variable_borrow_rate: string; // string representation of number
variable_rate_slope_1: string; // string representation of number
variable_rate_slope_2: string; // string representation of number
base_stable_borrow_rate: string; // string representation of number
stable_rate_slope_1: string; // string representation of number
stable_rate_slope_2: string; // string representation of number
optimal_stable_to_total_debt_ratio: string; // string representation of number
}
/**
* @deprecated old websocket response struct for get_cdp_assets_all
* use AssetParams instead
*/
export interface Asset {
// CDP
asset_params: {
denom: string;
oracle_id: string;
rate_strategy_name: string;
loan_to_value: string; // string representation of number
liquidation_threshold: string; // string representation of number
liquidation_bonus: string; // string representation of number
supply_cap: string; // string representation of number
borrow_cap: string; // string representation of number
};
asset_utilization: {
denom: string;
total_borrowed: string;
total_amount: string;
utilization_rate: string;
};
}
export interface AssetParams {
// CDP
denom: string;
oracle_id: string;
rate_strategy_name: string;
allow_repay_stablecoin_interest_debt: boolean;
loan_to_value: string; // string representation of number
liquidation_threshold: string; // string representation of number
liquidation_discount: string; // string representation of number
supply_cap: string; // string representation of number
borrow_cap: string; // string representation of number
}
export interface Collateral {
// CDP
cibt_denom: string;
denom: string;
collateral_amount: string; // string representation of number
}
export interface Debt {
// CDP
denom: string;
principal: string; // string representation of number
initial_cumulative_interest_multiplier: string; // string representation of number
}
export interface AccountData {
total_collaterals_usd: string; // string representation of number
total_debts_usd: string; // string representation of number
available_borrows_usd: string; // string representation of number
curr_liquidation_threshold: string; // string representation of number
health_factor: string; // string representation of number
}
export interface CDPAccountStablecoin {
principal: string; // string representation of number
interest_debt: string; // string representation of number
initial_cumulative_interest_multiplier: string; // string representation of number
}
/**
* Response for get_cdp_total_borrows and get_cdp_borrows
* Do not confuse with Debt
*/
export interface CDPBorrow {
address: string;
amount: string; // string representation of number
denom: string;
type: string;
initial_cumulative_interest_multiplier?: string; // string representation of number
}
/**
* Response for get_cdp_total_collaterals and get_cdp_collaterals
* Do not confuse with Collateral
*/
export interface CDPCollateral {
address: string;
amount: string; // string representation of number
denom: string;
}
export interface CDPDebtInfo {
denom: string;
last_updated_time: string; // string representation of timestamp
total_principal: string; // string representation of number
cumulative_interest_multiplier: string; // string representation of number
total_accumulated_interest: string; // string representation of number
utilization_rate: string; // string representation of number
}
export interface CDPStableCoinDebtInfo {
denom: string;
last_updated_time: string; // string representation of timestamp
total_principal: string; // string representation of number
cumulative_interest_multiplier: string; // string representation of number
total_accumulated_interest: string; // string representation of number
}
export interface CDPLiquidation {
liquidator: string;
debtor: string;
collateral_denom: string;
collateral_amount_liquidated: string; // string representation of number
collateral_amount_liquidator: string; // string representation of number
collateral_amount_fee: string; // string representation of number
liquidation_price: string; // string representation of number
market_price: string; // string representation of number
discount: string; // string representation of number
debt_denom: string;
debt_amount: string; // string representation of number
block_height: number;
block_time: string; // string representation of timestamp
transaction_hash: string;
}
export interface RewardScheme {
id: number;
creator: string;
reward_denom: string;
asset_denom: string;
reward_type: string;
reward_amount_per_second: string; // string representation of number
start_time: string; // string representation of timestamp
end_time: string; // string representation of timestamp
reward_per_share_last_updated_at: string; // string representation of timestamp
reward_per_share: string; // string representation of number
}
export interface RewardDebt {
user_address: string;
reward_scheme_id: number;
reward_debt: string; // string representation of number
last_updated_at: string; // string representation of timestamp
}
export interface CDPTokenSupply {
cibt_denom: string;
amount: string; // string representation of number
}
export interface TokenBalance {
available: string; // string representation of number
spot_order: string; // string representation of number
position: string; // string representation of number
denom: string;
futures: string; // string representation of number
futures_order: string; // string representation of number
}