-
Notifications
You must be signed in to change notification settings - Fork 1
/
getMarket.ts
127 lines (116 loc) · 2.38 KB
/
getMarket.ts
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
import {invariant} from '@spinfi/shared';
import {nearErrorMessage, contractIdErrorMessage} from './messages';
import {createView} from '../../utils/createView';
/**
* @category getMarket
*/
export interface MarketFees {
/**
* Fixed decimals for fee values
*/
decimals: number;
/**
* True means the rebate exists for makers
*/
is_rebate: boolean;
/**
* Maker fee percent. E.g. maker_fee = 5000 and decimals = 6 means 0.005 (or 0.5%)
*/
maker_fee: string;
/**
* Taker fee percent. E.g. taker_fee = 10000 and decimals == 6 means 0.01 (or 1%)
*/
taker_fee: string;
}
/**
* @category getMarket
*/
export interface MarketLimits {
/**
* Minimum base asset quantity for the order
*/
min_base_quantity: string;
/**
* Maximum base asset quantity for the order
*/
max_base_quantity: string;
/**
* Minimum quote asset quantity for the order
*/
min_quote_quantity: string;
/**
* Maximum quote asset quantity for the order
*/
max_quote_quantity: string;
/**
* Limits on the maximum number of asks per user
*/
max_ask_count: number;
/**
* Limits on the maximum number of bids per user
*/
max_bid_count: number;
/**
* TODO
*/
tick_size?: string;
/**
* TODO
*/
step_size?: string;
}
/**
* @category getMarket
*/
export interface MarketAvailability {
/**
* Enable or disable order placing
*/
allow_place: boolean;
/**
* Enable or disable order cancelling
*/
allow_cancel: boolean;
}
/**
* @category getMarket
*/
export interface Market {
/**
* Market ID
*/
id: number;
leverage: string;
symbol: string;
fees: MarketFees;
availability: MarketAvailability;
limits: MarketLimits;
}
/**
* @category getMarket
*/
export type GetMarketResponse = Market;
/**
* @category getMarket
*/
export interface GetMarketRequest {
/**
* Market ID
*/
marketId: number;
}
const METHOD_NAME = 'get_market';
export const getMarket = createView<GetMarketRequest, GetMarketResponse>(({methodify}) => {
const createMethod = methodify((config) => {
return async (request) => {
invariant(config.near, nearErrorMessage('getMarket'));
invariant(config.contractId, contractIdErrorMessage('getMarket'));
return await config.near.view(config.contractId, METHOD_NAME, {
market_id: request.marketId,
});
};
});
return {
createMethod,
};
});