@drift-labs/sdk 0.2.0-master.3 → 0.2.0-master.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/accounts/bulkUserSubscription.js +0 -1
- package/lib/accounts/fetch.d.ts +2 -1
- package/lib/accounts/fetch.js +9 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +16 -16
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +31 -28
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
- package/lib/accounts/types.d.ts +22 -11
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +17 -17
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +37 -35
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
- package/lib/addresses/marketAddresses.d.ts +1 -3
- package/lib/addresses/pda.d.ts +10 -4
- package/lib/addresses/pda.js +51 -14
- package/lib/admin.d.ts +42 -26
- package/lib/admin.js +228 -81
- package/lib/clearingHouse.d.ts +130 -49
- package/lib/clearingHouse.js +1256 -367
- package/lib/clearingHouseConfig.d.ts +4 -4
- package/lib/clearingHouseUser.d.ts +51 -39
- package/lib/clearingHouseUser.js +408 -191
- package/lib/clearingHouseUserStats.d.ts +18 -0
- package/lib/clearingHouseUserStats.js +49 -0
- package/lib/clearingHouseUserStatsConfig.d.ts +14 -0
- package/lib/clearingHouseUserStatsConfig.js +2 -0
- package/lib/config.d.ts +7 -9
- package/lib/config.js +21 -21
- package/lib/constants/numericConstants.d.ts +25 -12
- package/lib/constants/numericConstants.js +35 -21
- package/lib/constants/perpMarkets.d.ts +18 -0
- package/lib/constants/{markets.js → perpMarkets.js} +7 -7
- package/lib/constants/spotMarkets.d.ts +19 -0
- package/lib/constants/spotMarkets.js +53 -0
- package/lib/dlob/DLOB.d.ts +74 -0
- package/lib/dlob/DLOB.js +595 -0
- package/lib/dlob/DLOBNode.d.ts +54 -0
- package/lib/dlob/DLOBNode.js +85 -0
- package/lib/dlob/NodeList.d.ts +26 -0
- package/lib/dlob/NodeList.js +139 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +4 -2
- package/lib/events/eventSubscriber.js +16 -9
- package/lib/events/fetchLogs.d.ts +10 -1
- package/lib/events/fetchLogs.js +27 -7
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +6 -2
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +8 -2
- package/lib/events/types.js +6 -0
- package/lib/examples/makeTradeExample.js +20 -8
- package/lib/factory/bigNum.d.ts +2 -0
- package/lib/factory/bigNum.js +48 -10
- package/lib/idl/clearing_house.json +4889 -1529
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +21 -6
- package/lib/index.js +25 -6
- package/lib/math/amm.d.ts +9 -6
- package/lib/math/amm.js +91 -66
- package/lib/math/auction.js +4 -1
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +11 -10
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +11 -0
- package/lib/math/margin.js +77 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +72 -10
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +6 -2
- package/lib/math/orders.js +78 -3
- package/lib/math/position.d.ts +21 -13
- package/lib/math/position.js +76 -36
- package/lib/math/repeg.js +14 -5
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +192 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +6 -0
- package/lib/math/spotPosition.js +23 -0
- package/lib/math/trade.d.ts +10 -10
- package/lib/math/trade.js +32 -39
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/orderParams.d.ts +14 -5
- package/lib/orderParams.js +12 -92
- package/lib/serum/serumSubscriber.d.ts +23 -0
- package/lib/serum/serumSubscriber.js +41 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/serum/types.js +2 -0
- package/lib/slot/SlotSubscriber.d.ts +7 -0
- package/lib/slot/SlotSubscriber.js +3 -0
- package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
- package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +13 -4
- package/lib/tx/types.d.ts +1 -1
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +566 -138
- package/lib/types.js +129 -5
- package/lib/userMap/userMap.d.ts +25 -0
- package/lib/userMap/userMap.js +73 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/lib/util/computeUnits.js +1 -1
- package/lib/util/getTokenAddress.d.ts +2 -0
- package/lib/util/getTokenAddress.js +9 -0
- package/package.json +12 -6
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +0 -1
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +46 -42
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
- package/src/accounts/types.ts +31 -11
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +64 -59
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +1 -2
- package/src/addresses/pda.ts +88 -14
- package/src/admin.ts +452 -147
- package/src/assert/assert.js +9 -0
- package/src/clearingHouse.ts +2066 -467
- package/src/clearingHouseConfig.ts +4 -3
- package/src/clearingHouseUser.ts +747 -294
- package/src/clearingHouseUserStats.ts +75 -0
- package/src/clearingHouseUserStatsConfig.ts +18 -0
- package/src/config.ts +30 -31
- package/src/constants/numericConstants.ts +48 -25
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +73 -0
- package/src/dlob/DLOB.ts +953 -0
- package/src/dlob/DLOBNode.ts +167 -0
- package/src/dlob/NodeList.ts +189 -0
- package/src/events/eventList.js +77 -0
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +20 -12
- package/src/events/fetchLogs.ts +35 -8
- package/src/events/pollingLogProvider.ts +10 -2
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +19 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/examples/makeTradeExample.ts +32 -14
- package/src/factory/bigNum.ts +65 -13
- package/src/idl/clearing_house.json +4889 -1529
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +21 -6
- package/src/math/amm.ts +171 -88
- package/src/math/auction.ts +5 -1
- package/src/math/conversion.ts +2 -2
- package/src/math/funding.ts +20 -18
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +127 -0
- package/src/math/market.ts +145 -14
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +138 -4
- package/src/math/position.ts +119 -58
- package/src/math/repeg.ts +16 -6
- package/src/math/spotBalance.ts +319 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +53 -59
- package/src/oracles/pythClient.ts +2 -2
- package/src/oracles/quoteAssetOracleClient.ts +2 -2
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/orderParams.ts +24 -137
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/token/index.js +38 -0
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.js +2 -0
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +17 -0
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +533 -140
- package/src/userMap/userMap.ts +100 -0
- package/src/userMap/userStatsMap.ts +110 -0
- package/src/util/computeUnits.js +21 -11
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/getTokenAddress.ts +18 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +24 -10
- package/tests/dlob/helpers.ts +397 -0
- package/tests/dlob/test.ts +3688 -0
- package/lib/constants/banks.d.ts +0 -16
- package/lib/constants/banks.js +0 -34
- package/lib/constants/markets.d.ts +0 -19
- package/lib/math/bankBalance.d.ts +0 -9
- package/lib/math/bankBalance.js +0 -75
- package/lib/math/state.d.ts +0 -8
- package/lib/math/state.js +0 -15
- package/lib/orders.d.ts +0 -8
- package/lib/orders.js +0 -134
- package/src/constants/banks.ts +0 -43
- package/src/math/bankBalance.ts +0 -112
- package/src/math/state.ts +0 -14
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/orders.ts +0 -244
- package/src/util/computeUnits.js.map +0 -1
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,97 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { PublicKey, Transaction } from '@solana/web3.js';
|
|
3
3
|
import { BN } from '.';
|
|
4
|
+
export declare class ExchangeStatus {
|
|
5
|
+
static readonly ACTIVE: {
|
|
6
|
+
active: {};
|
|
7
|
+
};
|
|
8
|
+
static readonly FUNDINGPAUSED: {
|
|
9
|
+
fundingpaused: {};
|
|
10
|
+
};
|
|
11
|
+
static readonly AMMPAUSED: {
|
|
12
|
+
ammpaused: {};
|
|
13
|
+
};
|
|
14
|
+
static readonly FILLPAUSED: {
|
|
15
|
+
fillpaused: {};
|
|
16
|
+
};
|
|
17
|
+
static readonly LIQPAUSED: {
|
|
18
|
+
liqpaused: {};
|
|
19
|
+
};
|
|
20
|
+
static readonly WITHDRAWPAUSED: {
|
|
21
|
+
withdrawpaused: {};
|
|
22
|
+
};
|
|
23
|
+
static readonly PAUSED: {
|
|
24
|
+
paused: {};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export declare class MarketStatus {
|
|
28
|
+
static readonly INITIALIZED: {
|
|
29
|
+
initialized: {};
|
|
30
|
+
};
|
|
31
|
+
static readonly ACTIVE: {
|
|
32
|
+
active: {};
|
|
33
|
+
};
|
|
34
|
+
static readonly FUNDINGPAUSED: {
|
|
35
|
+
fundingpaused: {};
|
|
36
|
+
};
|
|
37
|
+
static readonly AMMPAUSED: {
|
|
38
|
+
ammpaused: {};
|
|
39
|
+
};
|
|
40
|
+
static readonly FILLPAUSED: {
|
|
41
|
+
fillpaused: {};
|
|
42
|
+
};
|
|
43
|
+
static readonly WITHDRAWPAUSED: {
|
|
44
|
+
withdrawpaused: {};
|
|
45
|
+
};
|
|
46
|
+
static readonly REDUCEONLY: {
|
|
47
|
+
reduceonly: {};
|
|
48
|
+
};
|
|
49
|
+
static readonly SETTLEMENT: {
|
|
50
|
+
settlement: {};
|
|
51
|
+
};
|
|
52
|
+
static readonly DELISTED: {
|
|
53
|
+
delisted: {};
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export declare class ContractType {
|
|
57
|
+
static readonly PERPETUAL: {
|
|
58
|
+
perpetual: {};
|
|
59
|
+
};
|
|
60
|
+
static readonly FUTURE: {
|
|
61
|
+
future: {};
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export declare class ContractTier {
|
|
65
|
+
static readonly A: {
|
|
66
|
+
a: {};
|
|
67
|
+
};
|
|
68
|
+
static readonly B: {
|
|
69
|
+
b: {};
|
|
70
|
+
};
|
|
71
|
+
static readonly C: {
|
|
72
|
+
c: {};
|
|
73
|
+
};
|
|
74
|
+
static readonly Speculative: {
|
|
75
|
+
speculative: {};
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
export declare class AssetTier {
|
|
79
|
+
static readonly COLLATERAL: {
|
|
80
|
+
collateral: {};
|
|
81
|
+
};
|
|
82
|
+
static readonly PROTECTED: {
|
|
83
|
+
protected: {};
|
|
84
|
+
};
|
|
85
|
+
static readonly CROSS: {
|
|
86
|
+
cross: {};
|
|
87
|
+
};
|
|
88
|
+
static readonly ISOLATED: {
|
|
89
|
+
isolated: {};
|
|
90
|
+
};
|
|
91
|
+
static readonly UNLISTED: {
|
|
92
|
+
unlisted: {};
|
|
93
|
+
};
|
|
94
|
+
}
|
|
4
95
|
export declare class SwapDirection {
|
|
5
96
|
static readonly ADD: {
|
|
6
97
|
add: {};
|
|
@@ -9,7 +100,7 @@ export declare class SwapDirection {
|
|
|
9
100
|
remove: {};
|
|
10
101
|
};
|
|
11
102
|
}
|
|
12
|
-
export declare class
|
|
103
|
+
export declare class SpotBalanceType {
|
|
13
104
|
static readonly DEPOSIT: {
|
|
14
105
|
deposit: {};
|
|
15
106
|
};
|
|
@@ -25,6 +116,14 @@ export declare class PositionDirection {
|
|
|
25
116
|
short: {};
|
|
26
117
|
};
|
|
27
118
|
}
|
|
119
|
+
export declare class DepositDirection {
|
|
120
|
+
static readonly DEPOSIT: {
|
|
121
|
+
deposit: {};
|
|
122
|
+
};
|
|
123
|
+
static readonly WITHDRAW: {
|
|
124
|
+
withdraw: {};
|
|
125
|
+
};
|
|
126
|
+
}
|
|
28
127
|
export declare class OracleSource {
|
|
29
128
|
static readonly PYTH: {
|
|
30
129
|
pyth: {};
|
|
@@ -50,6 +149,15 @@ export declare class OrderType {
|
|
|
50
149
|
market: {};
|
|
51
150
|
};
|
|
52
151
|
}
|
|
152
|
+
export declare type MarketTypeStr = 'perp' | 'spot';
|
|
153
|
+
export declare class MarketType {
|
|
154
|
+
static readonly SPOT: {
|
|
155
|
+
spot: {};
|
|
156
|
+
};
|
|
157
|
+
static readonly PERP: {
|
|
158
|
+
perp: {};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
53
161
|
export declare class OrderStatus {
|
|
54
162
|
static readonly INIT: {
|
|
55
163
|
init: {};
|
|
@@ -92,6 +200,23 @@ export declare class OrderAction {
|
|
|
92
200
|
trigger: {};
|
|
93
201
|
};
|
|
94
202
|
}
|
|
203
|
+
export declare class OrderActionExplanation {
|
|
204
|
+
static readonly NONE: {
|
|
205
|
+
none: {};
|
|
206
|
+
};
|
|
207
|
+
static readonly ORACLE_PRICE_BREACHED_LIMIT_PRICE: {
|
|
208
|
+
oraclePriceBreachedLimitPrice: {};
|
|
209
|
+
};
|
|
210
|
+
static readonly MARKET_ORDER_FILLED_TO_LIMIT_PRICE: {
|
|
211
|
+
marketOrderFilledToLimitPrice: {};
|
|
212
|
+
};
|
|
213
|
+
static readonly CANCELED_FOR_LIQUIDATION: {
|
|
214
|
+
canceledForLiquidation: {};
|
|
215
|
+
};
|
|
216
|
+
static readonly MARKET_ORDER_AUCTION_EXPIRED: {
|
|
217
|
+
marketOrderAuctionExpired: {};
|
|
218
|
+
};
|
|
219
|
+
}
|
|
95
220
|
export declare class OrderTriggerCondition {
|
|
96
221
|
static readonly ABOVE: {
|
|
97
222
|
above: {};
|
|
@@ -100,14 +225,36 @@ export declare class OrderTriggerCondition {
|
|
|
100
225
|
below: {};
|
|
101
226
|
};
|
|
102
227
|
}
|
|
228
|
+
export declare class SpotFulfillmentType {
|
|
229
|
+
static readonly SERUM_v3: {
|
|
230
|
+
serumV3: {};
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
export declare class SpotFulfillmentStatus {
|
|
234
|
+
static readonly ENABLED: {
|
|
235
|
+
enabled: {};
|
|
236
|
+
};
|
|
237
|
+
static readonly DISABLED: {
|
|
238
|
+
disabled: {};
|
|
239
|
+
};
|
|
240
|
+
}
|
|
103
241
|
export declare function isVariant(object: unknown, type: string): boolean;
|
|
104
242
|
export declare function isOneOfVariant(object: unknown, types: string[]): boolean;
|
|
243
|
+
export declare function getVariant(object: unknown): string;
|
|
105
244
|
export declare enum TradeSide {
|
|
106
245
|
None = 0,
|
|
107
246
|
Buy = 1,
|
|
108
247
|
Sell = 2
|
|
109
248
|
}
|
|
110
249
|
export declare type CandleResolution = '1' | '5' | '15' | '60' | '240' | 'D' | 'W' | 'M';
|
|
250
|
+
export declare type NewUserRecord = {
|
|
251
|
+
ts: BN;
|
|
252
|
+
userAuthority: PublicKey;
|
|
253
|
+
user: PublicKey;
|
|
254
|
+
userId: number;
|
|
255
|
+
name: number[];
|
|
256
|
+
referrer: PublicKey;
|
|
257
|
+
};
|
|
111
258
|
export declare type DepositRecord = {
|
|
112
259
|
ts: BN;
|
|
113
260
|
userAuthority: PublicKey;
|
|
@@ -116,15 +263,30 @@ export declare type DepositRecord = {
|
|
|
116
263
|
deposit?: any;
|
|
117
264
|
withdraw?: any;
|
|
118
265
|
};
|
|
119
|
-
|
|
266
|
+
marketIndex: number;
|
|
120
267
|
amount: BN;
|
|
121
|
-
|
|
122
|
-
|
|
268
|
+
oraclePrice: BN;
|
|
269
|
+
marketDepositBalance: BN;
|
|
270
|
+
marketWithdrawBalance: BN;
|
|
271
|
+
marketCumulativeDepositInterest: BN;
|
|
272
|
+
marketCumulativeBorrowInterest: BN;
|
|
273
|
+
transferUser?: PublicKey;
|
|
274
|
+
};
|
|
275
|
+
export declare type SpotInterestRecord = {
|
|
276
|
+
ts: BN;
|
|
277
|
+
marketIndex: number;
|
|
278
|
+
depositBalance: BN;
|
|
279
|
+
cumulativeDepositInterest: BN;
|
|
280
|
+
borrowBalance: BN;
|
|
281
|
+
cumulativeBorrowInterest: BN;
|
|
282
|
+
optimalUtilization: number;
|
|
283
|
+
optimalBorrowRate: number;
|
|
284
|
+
maxBorrowRate: number;
|
|
123
285
|
};
|
|
124
286
|
export declare type CurveRecord = {
|
|
125
287
|
ts: BN;
|
|
126
288
|
recordId: BN;
|
|
127
|
-
marketIndex:
|
|
289
|
+
marketIndex: number;
|
|
128
290
|
pegMultiplierBefore: BN;
|
|
129
291
|
baseAssetReserveBefore: BN;
|
|
130
292
|
quoteAssetReserveBefore: BN;
|
|
@@ -140,96 +302,219 @@ export declare type CurveRecord = {
|
|
|
140
302
|
oraclePrice: BN;
|
|
141
303
|
tradeId: BN;
|
|
142
304
|
};
|
|
305
|
+
export declare type InsuranceFundRecord = {
|
|
306
|
+
ts: BN;
|
|
307
|
+
bankIndex: BN;
|
|
308
|
+
marketIndex: number;
|
|
309
|
+
userIfFactor: number;
|
|
310
|
+
totalIfFactor: number;
|
|
311
|
+
vaultAmountBefore: BN;
|
|
312
|
+
insuranceVaultAmountBefore: BN;
|
|
313
|
+
amount: BN;
|
|
314
|
+
totalIfSharesBefore: BN;
|
|
315
|
+
totalIfSharesAfter: BN;
|
|
316
|
+
};
|
|
317
|
+
export declare type LPRecord = {
|
|
318
|
+
ts: BN;
|
|
319
|
+
user: PublicKey;
|
|
320
|
+
action: LPAction;
|
|
321
|
+
nShares: BN;
|
|
322
|
+
marketIndex: number;
|
|
323
|
+
deltaBaseAssetAmount: BN;
|
|
324
|
+
deltaQuoteAssetAmount: BN;
|
|
325
|
+
pnl: BN;
|
|
326
|
+
};
|
|
327
|
+
export declare class LPAction {
|
|
328
|
+
static readonly ADD_LIQUIDITY: {
|
|
329
|
+
addLiquidity: {};
|
|
330
|
+
};
|
|
331
|
+
static readonly REMOVE_LIQUIDITY: {
|
|
332
|
+
removeLiquidity: {};
|
|
333
|
+
};
|
|
334
|
+
static readonly SETTLE_LIQUIDITY: {
|
|
335
|
+
settleLiquidity: {};
|
|
336
|
+
};
|
|
337
|
+
}
|
|
143
338
|
export declare type FundingRateRecord = {
|
|
144
339
|
ts: BN;
|
|
145
340
|
recordId: BN;
|
|
146
|
-
marketIndex:
|
|
341
|
+
marketIndex: number;
|
|
147
342
|
fundingRate: BN;
|
|
343
|
+
fundingRateLong: BN;
|
|
344
|
+
fundingRateShort: BN;
|
|
148
345
|
cumulativeFundingRateLong: BN;
|
|
149
346
|
cumulativeFundingRateShort: BN;
|
|
150
347
|
oraclePriceTwap: BN;
|
|
151
348
|
markPriceTwap: BN;
|
|
349
|
+
periodRevenue: BN;
|
|
350
|
+
netBaseAssetAmount: BN;
|
|
351
|
+
netUnsettledLpBaseAssetAmount: BN;
|
|
152
352
|
};
|
|
153
353
|
export declare type FundingPaymentRecord = {
|
|
154
354
|
ts: BN;
|
|
155
355
|
userAuthority: PublicKey;
|
|
156
356
|
user: PublicKey;
|
|
157
|
-
marketIndex:
|
|
357
|
+
marketIndex: number;
|
|
158
358
|
fundingPayment: BN;
|
|
159
359
|
baseAssetAmount: BN;
|
|
160
360
|
userLastCumulativeFunding: BN;
|
|
161
|
-
userLastFundingRateTs: BN;
|
|
162
361
|
ammCumulativeFundingLong: BN;
|
|
163
362
|
ammCumulativeFundingShort: BN;
|
|
164
363
|
};
|
|
165
364
|
export declare type LiquidationRecord = {
|
|
166
365
|
ts: BN;
|
|
167
|
-
recordId: BN;
|
|
168
|
-
userAuthority: PublicKey;
|
|
169
366
|
user: PublicKey;
|
|
170
|
-
partial: boolean;
|
|
171
|
-
baseAssetValue: BN;
|
|
172
|
-
baseAssetValueClosed: BN;
|
|
173
|
-
liquidationFee: BN;
|
|
174
|
-
feeToLiquidator: BN;
|
|
175
|
-
feeToInsuranceFund: BN;
|
|
176
367
|
liquidator: PublicKey;
|
|
368
|
+
liquidationType: LiquidationType;
|
|
369
|
+
marginRequirement: BN;
|
|
177
370
|
totalCollateral: BN;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
371
|
+
liquidationId: number;
|
|
372
|
+
canceledOrderIds: BN[];
|
|
373
|
+
liquidatePerp: LiquidatePerpRecord;
|
|
374
|
+
liquidateSpot: LiquidateSpotRecord;
|
|
375
|
+
liquidateBorrowForPerpPnl: LiquidateBorrowForPerpPnlRecord;
|
|
376
|
+
liquidatePerpPnlForDeposit: LiquidatePerpPnlForDepositRecord;
|
|
377
|
+
perpBankruptcy: PerpBankruptcyRecord;
|
|
378
|
+
spotBankruptcy: SpotBankruptcyRecord;
|
|
379
|
+
};
|
|
380
|
+
export declare class LiquidationType {
|
|
381
|
+
static readonly LIQUIDATE_PERP: {
|
|
382
|
+
liquidatePerp: {};
|
|
383
|
+
};
|
|
384
|
+
static readonly LIQUIDATE_BORROW: {
|
|
385
|
+
liquidateBorrow: {};
|
|
386
|
+
};
|
|
387
|
+
static readonly LIQUIDATE_BORROW_FOR_PERP_PNL: {
|
|
388
|
+
liquidateBorrowForPerpPnl: {};
|
|
389
|
+
};
|
|
390
|
+
static readonly LIQUIDATE_PERP_PNL_FOR_DEPOSIT: {
|
|
391
|
+
liquidatePerpPnlForDeposit: {};
|
|
392
|
+
};
|
|
393
|
+
static readonly PERP_BANKRUPTCY: {
|
|
394
|
+
perpBankruptcy: {};
|
|
395
|
+
};
|
|
396
|
+
static readonly BORROW_BANKRUPTCY: {
|
|
397
|
+
borrowBankruptcy: {};
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
export declare type LiquidatePerpRecord = {
|
|
401
|
+
marketIndex: number;
|
|
402
|
+
oraclePrice: BN;
|
|
403
|
+
baseAssetAmount: BN;
|
|
404
|
+
quoteAssetAmount: BN;
|
|
405
|
+
lpShares: BN;
|
|
406
|
+
userOrderId: BN;
|
|
407
|
+
liquidatorOrderId: BN;
|
|
408
|
+
fillRecordId: BN;
|
|
409
|
+
ifFee: BN;
|
|
410
|
+
};
|
|
411
|
+
export declare type LiquidateSpotRecord = {
|
|
412
|
+
assetMarketIndex: number;
|
|
413
|
+
assetPrice: BN;
|
|
414
|
+
assetTransfer: BN;
|
|
415
|
+
liabilityMarketIndex: number;
|
|
416
|
+
liabilityPrice: BN;
|
|
417
|
+
liabilityTransfer: BN;
|
|
418
|
+
ifFee: BN;
|
|
419
|
+
};
|
|
420
|
+
export declare type LiquidateBorrowForPerpPnlRecord = {
|
|
421
|
+
perpMarketIndex: number;
|
|
422
|
+
marketOraclePrice: BN;
|
|
423
|
+
pnlTransfer: BN;
|
|
424
|
+
liabilityMarketIndex: number;
|
|
425
|
+
liabilityPrice: BN;
|
|
426
|
+
liabilityTransfer: BN;
|
|
427
|
+
};
|
|
428
|
+
export declare type LiquidatePerpPnlForDepositRecord = {
|
|
429
|
+
perpMarketIndex: number;
|
|
430
|
+
marketOraclePrice: BN;
|
|
431
|
+
pnlTransfer: BN;
|
|
432
|
+
assetMarketIndex: number;
|
|
433
|
+
assetPrice: BN;
|
|
434
|
+
assetTransfer: BN;
|
|
435
|
+
};
|
|
436
|
+
export declare type PerpBankruptcyRecord = {
|
|
437
|
+
marketIndex: number;
|
|
438
|
+
pnl: BN;
|
|
439
|
+
cumulativeFundingRateDelta: BN;
|
|
440
|
+
};
|
|
441
|
+
export declare type SpotBankruptcyRecord = {
|
|
442
|
+
marketIndex: number;
|
|
443
|
+
borrowAmount: BN;
|
|
444
|
+
cumulativeDepositInterestDelta: BN;
|
|
445
|
+
};
|
|
446
|
+
export declare type SettlePnlRecord = {
|
|
447
|
+
ts: BN;
|
|
448
|
+
user: PublicKey;
|
|
449
|
+
marketIndex: number;
|
|
450
|
+
pnl: BN;
|
|
451
|
+
baseAssetAmount: BN;
|
|
452
|
+
quoteAssetAmountAfter: BN;
|
|
453
|
+
quoteEntryAmount: BN;
|
|
454
|
+
settlePrice: BN;
|
|
181
455
|
};
|
|
182
456
|
export declare type OrderRecord = {
|
|
183
457
|
ts: BN;
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
458
|
+
user: PublicKey;
|
|
459
|
+
order: Order;
|
|
460
|
+
};
|
|
461
|
+
export declare type OrderActionRecord = {
|
|
462
|
+
ts: BN;
|
|
188
463
|
action: OrderAction;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
464
|
+
actionExplanation: OrderActionExplanation;
|
|
465
|
+
marketIndex: number;
|
|
466
|
+
marketType: MarketType;
|
|
467
|
+
filler: PublicKey | null;
|
|
468
|
+
fillerReward: BN | null;
|
|
469
|
+
fillRecordId: BN | null;
|
|
470
|
+
baseAssetAmountFilled: BN | null;
|
|
471
|
+
quoteAssetAmountFilled: BN | null;
|
|
472
|
+
takerFee: BN | null;
|
|
473
|
+
makerFee: BN | null;
|
|
474
|
+
referrerReward: number | null;
|
|
475
|
+
quoteAssetAmountSurplus: BN | null;
|
|
476
|
+
taker: PublicKey | null;
|
|
477
|
+
takerOrderId: number | null;
|
|
478
|
+
takerOrderDirection: PositionDirection | null;
|
|
479
|
+
takerOrderBaseAssetAmount: BN | null;
|
|
480
|
+
takerOrderCumulativeBaseAssetAmountFilled: BN | null;
|
|
481
|
+
takerOrderCumulativeQuoteAssetAmountFilled: BN | null;
|
|
482
|
+
takerOrderFee: BN | null;
|
|
483
|
+
maker: PublicKey | null;
|
|
484
|
+
makerOrderId: number | null;
|
|
485
|
+
makerOrderDirection: PositionDirection | null;
|
|
486
|
+
makerOrderBaseAssetAmount: BN | null;
|
|
487
|
+
makerOrderCumulativeBaseAssetAmountFilled: BN | null;
|
|
488
|
+
makerOrderCumulativeQuoteAssetAmountFilled: BN | null;
|
|
489
|
+
makerOrderFee: BN | null;
|
|
198
490
|
oraclePrice: BN;
|
|
199
491
|
};
|
|
200
492
|
export declare type StateAccount = {
|
|
201
493
|
admin: PublicKey;
|
|
202
|
-
|
|
203
|
-
exchangePaused: boolean;
|
|
204
|
-
adminControlsPrices: boolean;
|
|
205
|
-
insuranceVault: PublicKey;
|
|
206
|
-
insuranceVaultAuthority: PublicKey;
|
|
207
|
-
insuranceVaultNonce: number;
|
|
208
|
-
marginRatioInitial: BN;
|
|
209
|
-
marginRatioMaintenance: BN;
|
|
210
|
-
marginRatioPartial: BN;
|
|
211
|
-
partialLiquidationClosePercentageNumerator: BN;
|
|
212
|
-
partialLiquidationClosePercentageDenominator: BN;
|
|
213
|
-
partialLiquidationPenaltyPercentageNumerator: BN;
|
|
214
|
-
partialLiquidationPenaltyPercentageDenominator: BN;
|
|
215
|
-
fullLiquidationPenaltyPercentageNumerator: BN;
|
|
216
|
-
fullLiquidationPenaltyPercentageDenominator: BN;
|
|
217
|
-
partialLiquidationLiquidatorShareDenominator: BN;
|
|
218
|
-
fullLiquidationLiquidatorShareDenominator: BN;
|
|
219
|
-
feeStructure: FeeStructure;
|
|
220
|
-
totalFee: BN;
|
|
221
|
-
totalFeeWithdrawn: BN;
|
|
494
|
+
exchangeStatus: ExchangeStatus;
|
|
222
495
|
whitelistMint: PublicKey;
|
|
223
496
|
discountMint: PublicKey;
|
|
224
497
|
oracleGuardRails: OracleGuardRails;
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
numberOfBanks: BN;
|
|
498
|
+
numberOfMarkets: number;
|
|
499
|
+
numberOfSpotMarkets: number;
|
|
228
500
|
minOrderQuoteAssetAmount: BN;
|
|
501
|
+
minPerpAuctionDuration: number;
|
|
502
|
+
defaultMarketOrderTimeInForce: number;
|
|
503
|
+
defaultSpotAuctionDuration: number;
|
|
504
|
+
liquidationMarginBufferRatio: number;
|
|
505
|
+
settlementDuration: number;
|
|
506
|
+
signer: PublicKey;
|
|
507
|
+
signerNonce: number;
|
|
508
|
+
srmVault: PublicKey;
|
|
509
|
+
perpFeeStructure: FeeStructure;
|
|
510
|
+
spotFeeStructure: FeeStructure;
|
|
229
511
|
};
|
|
230
|
-
export declare type
|
|
231
|
-
|
|
232
|
-
|
|
512
|
+
export declare type PerpMarketAccount = {
|
|
513
|
+
status: MarketStatus;
|
|
514
|
+
contractType: ContractType;
|
|
515
|
+
expiryTs: BN;
|
|
516
|
+
settlementPrice: BN;
|
|
517
|
+
marketIndex: number;
|
|
233
518
|
pubkey: PublicKey;
|
|
234
519
|
amm: AMM;
|
|
235
520
|
baseAssetAmount: BN;
|
|
@@ -238,34 +523,84 @@ export declare type MarketAccount = {
|
|
|
238
523
|
openInterest: BN;
|
|
239
524
|
marginRatioInitial: number;
|
|
240
525
|
marginRatioMaintenance: number;
|
|
241
|
-
marginRatioPartial: number;
|
|
242
526
|
nextFillRecordId: BN;
|
|
243
527
|
pnlPool: PoolBalance;
|
|
528
|
+
liquidatorFee: BN;
|
|
529
|
+
ifLiquidationFee: BN;
|
|
530
|
+
imfFactor: BN;
|
|
531
|
+
unrealizedImfFactor: BN;
|
|
532
|
+
unrealizedMaxImbalance: BN;
|
|
533
|
+
unrealizedInitialAssetWeight: number;
|
|
534
|
+
unrealizedMaintenanceAssetWeight: number;
|
|
535
|
+
revenueWithdrawSinceLastSettle: BN;
|
|
536
|
+
maxRevenueWithdrawPerPeriod: BN;
|
|
537
|
+
lastRevenueWithdrawTs: BN;
|
|
538
|
+
quoteSettledInsurance: BN;
|
|
539
|
+
quoteMaxInsurance: BN;
|
|
244
540
|
};
|
|
245
|
-
export declare type
|
|
246
|
-
|
|
541
|
+
export declare type HistoricalOracleData = {
|
|
542
|
+
lastOraclePrice: BN;
|
|
543
|
+
lastOracleDelay: BN;
|
|
544
|
+
lastOracleConf: BN;
|
|
545
|
+
lastOraclePriceTwap: BN;
|
|
546
|
+
lastOraclePriceTwap5min: BN;
|
|
547
|
+
lastOraclePriceTwapTs: BN;
|
|
548
|
+
};
|
|
549
|
+
export declare type HistoricalIndexData = {
|
|
550
|
+
lastIndexBidPrice: BN;
|
|
551
|
+
lastIndexAskPrice: BN;
|
|
552
|
+
lastIndexPriceTwap: BN;
|
|
553
|
+
lastIndexPriceTwap5Min: BN;
|
|
554
|
+
lastIndexPriceTwapTs: BN;
|
|
555
|
+
};
|
|
556
|
+
export declare type SpotMarketAccount = {
|
|
557
|
+
status: MarketStatus;
|
|
558
|
+
assetTier: AssetTier;
|
|
559
|
+
marketIndex: number;
|
|
247
560
|
pubkey: PublicKey;
|
|
248
561
|
mint: PublicKey;
|
|
249
562
|
vault: PublicKey;
|
|
250
|
-
|
|
251
|
-
|
|
563
|
+
oracle: PublicKey;
|
|
564
|
+
oracleSource: OracleSource;
|
|
565
|
+
historicalOracleData: HistoricalOracleData;
|
|
566
|
+
historicalIndexData: HistoricalIndexData;
|
|
567
|
+
insuranceFundVault: PublicKey;
|
|
568
|
+
insuranceWithdrawEscrowPeriod: BN;
|
|
569
|
+
revenuePool: PoolBalance;
|
|
570
|
+
totalIfShares: BN;
|
|
571
|
+
userIfShares: BN;
|
|
572
|
+
userIfFactor: number;
|
|
573
|
+
totalIfFactor: number;
|
|
574
|
+
ifLiquidationFee: BN;
|
|
252
575
|
decimals: number;
|
|
253
|
-
optimalUtilization:
|
|
254
|
-
optimalBorrowRate:
|
|
255
|
-
maxBorrowRate:
|
|
576
|
+
optimalUtilization: number;
|
|
577
|
+
optimalBorrowRate: number;
|
|
578
|
+
maxBorrowRate: number;
|
|
256
579
|
cumulativeDepositInterest: BN;
|
|
257
580
|
cumulativeBorrowInterest: BN;
|
|
258
581
|
depositBalance: BN;
|
|
259
582
|
borrowBalance: BN;
|
|
260
|
-
|
|
261
|
-
|
|
583
|
+
maxTokenDeposits: BN;
|
|
584
|
+
lastInterestTs: BN;
|
|
585
|
+
lastTwapTs: BN;
|
|
262
586
|
initialAssetWeight: BN;
|
|
263
587
|
maintenanceAssetWeight: BN;
|
|
264
588
|
initialLiabilityWeight: BN;
|
|
265
589
|
maintenanceLiabilityWeight: BN;
|
|
590
|
+
liquidatorFee: BN;
|
|
591
|
+
imfFactor: BN;
|
|
592
|
+
withdrawGuardThreshold: BN;
|
|
593
|
+
depositTokenTwap: BN;
|
|
594
|
+
borrowTokenTwap: BN;
|
|
595
|
+
utilizationTwap: BN;
|
|
596
|
+
orderStepSize: BN;
|
|
597
|
+
nextFillRecordId: BN;
|
|
598
|
+
spotFeePool: PoolBalance;
|
|
599
|
+
totalSpotFee: BN;
|
|
266
600
|
};
|
|
267
601
|
export declare type PoolBalance = {
|
|
268
602
|
balance: BN;
|
|
603
|
+
marketIndex: number;
|
|
269
604
|
};
|
|
270
605
|
export declare type AMM = {
|
|
271
606
|
baseAssetReserve: BN;
|
|
@@ -274,24 +609,31 @@ export declare type AMM = {
|
|
|
274
609
|
lastFundingRate: BN;
|
|
275
610
|
lastFundingRateTs: BN;
|
|
276
611
|
lastMarkPriceTwap: BN;
|
|
612
|
+
lastMarkPriceTwap5min: BN;
|
|
277
613
|
lastMarkPriceTwapTs: BN;
|
|
278
|
-
lastOraclePriceTwap: BN;
|
|
279
|
-
lastOraclePriceTwapTs: BN;
|
|
280
614
|
oracle: PublicKey;
|
|
281
615
|
oracleSource: OracleSource;
|
|
616
|
+
historicalOracleData: HistoricalOracleData;
|
|
617
|
+
lastOracleReservePriceSpreadPct: BN;
|
|
618
|
+
lastOracleConfPct: BN;
|
|
282
619
|
fundingPeriod: BN;
|
|
283
620
|
quoteAssetReserve: BN;
|
|
284
621
|
pegMultiplier: BN;
|
|
285
622
|
cumulativeFundingRateLong: BN;
|
|
286
623
|
cumulativeFundingRateShort: BN;
|
|
287
|
-
|
|
288
|
-
cumulativeRepegRebateShort: BN;
|
|
624
|
+
cumulativeFundingRateLp: BN;
|
|
289
625
|
totalFeeMinusDistributions: BN;
|
|
290
626
|
totalFeeWithdrawn: BN;
|
|
291
627
|
totalFee: BN;
|
|
628
|
+
cumulativeFundingPaymentPerLp: BN;
|
|
629
|
+
cumulativeFeePerLp: BN;
|
|
630
|
+
cumulativeNetBaseAssetAmountPerLp: BN;
|
|
631
|
+
userLpShares: BN;
|
|
632
|
+
netUnsettledLpBaseAssetAmount: BN;
|
|
292
633
|
minimumQuoteAssetTradeSize: BN;
|
|
293
634
|
baseAssetAmountStepSize: BN;
|
|
294
|
-
|
|
635
|
+
maxBaseAssetAmountRatio: number;
|
|
636
|
+
maxSlippageRatio: number;
|
|
295
637
|
baseSpread: number;
|
|
296
638
|
curveUpdateIntensity: number;
|
|
297
639
|
netBaseAssetAmount: BN;
|
|
@@ -303,53 +645,86 @@ export declare type AMM = {
|
|
|
303
645
|
totalMmFee: BN;
|
|
304
646
|
netRevenueSinceLastFunding: BN;
|
|
305
647
|
lastUpdateSlot: BN;
|
|
648
|
+
lastOracleValid: boolean;
|
|
306
649
|
lastBidPriceTwap: BN;
|
|
307
650
|
lastAskPriceTwap: BN;
|
|
308
651
|
longSpread: BN;
|
|
309
652
|
shortSpread: BN;
|
|
310
653
|
maxSpread: number;
|
|
654
|
+
marketPosition: PerpPosition;
|
|
655
|
+
marketPositionPerLp: PerpPosition;
|
|
656
|
+
ammJitIntensity: number;
|
|
657
|
+
maxBaseAssetReserve: BN;
|
|
658
|
+
minBaseAssetReserve: BN;
|
|
659
|
+
cumulativeSocialLoss: BN;
|
|
311
660
|
};
|
|
312
|
-
export declare type
|
|
661
|
+
export declare type PerpPosition = {
|
|
313
662
|
baseAssetAmount: BN;
|
|
314
663
|
lastCumulativeFundingRate: BN;
|
|
315
|
-
marketIndex:
|
|
664
|
+
marketIndex: number;
|
|
316
665
|
quoteAssetAmount: BN;
|
|
317
666
|
quoteEntryAmount: BN;
|
|
318
|
-
openOrders:
|
|
319
|
-
unsettledPnl: BN;
|
|
667
|
+
openOrders: number;
|
|
320
668
|
openBids: BN;
|
|
321
669
|
openAsks: BN;
|
|
670
|
+
settledPnl: BN;
|
|
671
|
+
lpShares: BN;
|
|
672
|
+
remainderBaseAssetAmount: number;
|
|
673
|
+
lastNetBaseAssetAmountPerLp: BN;
|
|
674
|
+
lastNetQuoteAssetAmountPerLp: BN;
|
|
322
675
|
};
|
|
323
|
-
export declare type
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
676
|
+
export declare type UserStatsAccount = {
|
|
677
|
+
numberOfUsers: number;
|
|
678
|
+
makerVolume30D: BN;
|
|
679
|
+
takerVolume30D: BN;
|
|
680
|
+
fillerVolume30D: BN;
|
|
681
|
+
lastMakerVolume30DTs: BN;
|
|
682
|
+
lastTakerVolume30DTs: BN;
|
|
683
|
+
lastFillerVolume30DTs: BN;
|
|
330
684
|
fees: {
|
|
331
685
|
totalFeePaid: BN;
|
|
332
686
|
totalFeeRebate: BN;
|
|
333
687
|
totalTokenDiscount: BN;
|
|
334
|
-
totalReferralReward: BN;
|
|
335
688
|
totalRefereeDiscount: BN;
|
|
336
689
|
};
|
|
337
|
-
|
|
690
|
+
referrer: PublicKey;
|
|
691
|
+
isReferrer: boolean;
|
|
692
|
+
totalReferrerReward: BN;
|
|
693
|
+
authority: PublicKey;
|
|
694
|
+
stakedQuoteAssetAmount: BN;
|
|
695
|
+
};
|
|
696
|
+
export declare type UserAccount = {
|
|
697
|
+
authority: PublicKey;
|
|
698
|
+
delegate: PublicKey;
|
|
699
|
+
name: number[];
|
|
700
|
+
userId: number;
|
|
701
|
+
spotPositions: SpotPosition[];
|
|
702
|
+
perpPositions: PerpPosition[];
|
|
338
703
|
orders: Order[];
|
|
704
|
+
beingLiquidated: boolean;
|
|
705
|
+
bankrupt: boolean;
|
|
706
|
+
nextLiquidationId: number;
|
|
707
|
+
nextOrderId: number;
|
|
708
|
+
customMarginRatio: number;
|
|
339
709
|
};
|
|
340
|
-
export declare type
|
|
341
|
-
|
|
342
|
-
balanceType:
|
|
710
|
+
export declare type SpotPosition = {
|
|
711
|
+
marketIndex: number;
|
|
712
|
+
balanceType: SpotBalanceType;
|
|
343
713
|
balance: BN;
|
|
714
|
+
openOrders: number;
|
|
715
|
+
openBids: BN;
|
|
716
|
+
openAsks: BN;
|
|
717
|
+
cumulativeDeposits: BN;
|
|
344
718
|
};
|
|
345
719
|
export declare type Order = {
|
|
346
720
|
status: OrderStatus;
|
|
347
721
|
orderType: OrderType;
|
|
722
|
+
marketType: MarketType;
|
|
348
723
|
ts: BN;
|
|
349
724
|
slot: BN;
|
|
350
|
-
orderId:
|
|
725
|
+
orderId: number;
|
|
351
726
|
userOrderId: number;
|
|
352
|
-
marketIndex:
|
|
727
|
+
marketIndex: number;
|
|
353
728
|
price: BN;
|
|
354
729
|
baseAssetAmount: BN;
|
|
355
730
|
baseAssetAmountFilled: BN;
|
|
@@ -361,81 +736,113 @@ export declare type Order = {
|
|
|
361
736
|
triggerPrice: BN;
|
|
362
737
|
triggerCondition: OrderTriggerCondition;
|
|
363
738
|
triggered: boolean;
|
|
364
|
-
discountTier: OrderDiscountTier;
|
|
365
739
|
existingPositionDirection: PositionDirection;
|
|
366
|
-
referrer: PublicKey;
|
|
367
740
|
postOnly: boolean;
|
|
368
741
|
immediateOrCancel: boolean;
|
|
369
742
|
oraclePriceOffset: BN;
|
|
370
743
|
auctionDuration: number;
|
|
371
744
|
auctionStartPrice: BN;
|
|
372
745
|
auctionEndPrice: BN;
|
|
746
|
+
timeInForce: number;
|
|
373
747
|
};
|
|
374
748
|
export declare type OrderParams = {
|
|
375
749
|
orderType: OrderType;
|
|
750
|
+
marketType: MarketType;
|
|
376
751
|
userOrderId: number;
|
|
377
752
|
direction: PositionDirection;
|
|
378
|
-
quoteAssetAmount: BN;
|
|
379
753
|
baseAssetAmount: BN;
|
|
380
754
|
price: BN;
|
|
381
|
-
marketIndex:
|
|
755
|
+
marketIndex: number;
|
|
382
756
|
reduceOnly: boolean;
|
|
383
757
|
postOnly: boolean;
|
|
384
758
|
immediateOrCancel: boolean;
|
|
385
|
-
triggerPrice: BN;
|
|
759
|
+
triggerPrice: BN | null;
|
|
386
760
|
triggerCondition: OrderTriggerCondition;
|
|
387
761
|
positionLimit: BN;
|
|
388
|
-
oraclePriceOffset: BN;
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
762
|
+
oraclePriceOffset: BN | null;
|
|
763
|
+
auctionDuration: number | null;
|
|
764
|
+
timeInForce: number | null;
|
|
765
|
+
auctionStartPrice: BN | null;
|
|
766
|
+
};
|
|
767
|
+
export declare type NecessaryOrderParams = {
|
|
768
|
+
orderType: OrderType;
|
|
769
|
+
marketIndex: number;
|
|
770
|
+
baseAssetAmount: BN;
|
|
771
|
+
direction: PositionDirection;
|
|
772
|
+
};
|
|
773
|
+
export declare type OptionalOrderParams = {
|
|
774
|
+
[Property in keyof OrderParams]?: OrderParams[Property];
|
|
775
|
+
} & NecessaryOrderParams;
|
|
776
|
+
export declare const DefaultOrderParams: {
|
|
777
|
+
orderType: {
|
|
778
|
+
market: {};
|
|
779
|
+
};
|
|
780
|
+
marketType: {
|
|
781
|
+
perp: {};
|
|
782
|
+
};
|
|
783
|
+
userOrderId: number;
|
|
784
|
+
direction: {
|
|
785
|
+
long: {};
|
|
786
|
+
};
|
|
787
|
+
baseAssetAmount: BN;
|
|
788
|
+
price: BN;
|
|
789
|
+
marketIndex: number;
|
|
790
|
+
reduceOnly: boolean;
|
|
791
|
+
postOnly: boolean;
|
|
792
|
+
immediateOrCancel: boolean;
|
|
793
|
+
triggerPrice: any;
|
|
794
|
+
triggerCondition: {
|
|
795
|
+
above: {};
|
|
394
796
|
};
|
|
797
|
+
positionLimit: BN;
|
|
798
|
+
oraclePriceOffset: any;
|
|
799
|
+
auctionDuration: any;
|
|
800
|
+
timeInForce: any;
|
|
801
|
+
auctionStartPrice: any;
|
|
395
802
|
};
|
|
396
803
|
export declare type MakerInfo = {
|
|
397
804
|
maker: PublicKey;
|
|
805
|
+
makerStats: PublicKey;
|
|
806
|
+
makerUserAccount: UserAccount;
|
|
807
|
+
order: Order;
|
|
808
|
+
};
|
|
809
|
+
export declare type TakerInfo = {
|
|
810
|
+
taker: PublicKey;
|
|
811
|
+
takerStats: PublicKey;
|
|
812
|
+
takerUserAccount: UserAccount;
|
|
398
813
|
order: Order;
|
|
399
814
|
};
|
|
815
|
+
export declare type ReferrerInfo = {
|
|
816
|
+
referrer: PublicKey;
|
|
817
|
+
referrerStats: PublicKey;
|
|
818
|
+
};
|
|
400
819
|
export interface IWallet {
|
|
401
820
|
signTransaction(tx: Transaction): Promise<Transaction>;
|
|
402
821
|
signAllTransactions(txs: Transaction[]): Promise<Transaction[]>;
|
|
403
822
|
publicKey: PublicKey;
|
|
404
823
|
}
|
|
405
824
|
export declare type FeeStructure = {
|
|
406
|
-
|
|
407
|
-
feeDenominator: BN;
|
|
408
|
-
discountTokenTiers: {
|
|
409
|
-
firstTier: {
|
|
410
|
-
minimumBalance: BN;
|
|
411
|
-
discountNumerator: BN;
|
|
412
|
-
discountDenominator: BN;
|
|
413
|
-
};
|
|
414
|
-
secondTier: {
|
|
415
|
-
minimumBalance: BN;
|
|
416
|
-
discountNumerator: BN;
|
|
417
|
-
discountDenominator: BN;
|
|
418
|
-
};
|
|
419
|
-
thirdTier: {
|
|
420
|
-
minimumBalance: BN;
|
|
421
|
-
discountNumerator: BN;
|
|
422
|
-
discountDenominator: BN;
|
|
423
|
-
};
|
|
424
|
-
fourthTier: {
|
|
425
|
-
minimumBalance: BN;
|
|
426
|
-
discountNumerator: BN;
|
|
427
|
-
discountDenominator: BN;
|
|
428
|
-
};
|
|
429
|
-
};
|
|
430
|
-
referralDiscount: {
|
|
431
|
-
referrerRewardNumerator: BN;
|
|
432
|
-
referrerRewardDenominator: BN;
|
|
433
|
-
refereeDiscountNumerator: BN;
|
|
434
|
-
refereeDiscountDenominator: BN;
|
|
435
|
-
};
|
|
825
|
+
feeTiers: FeeTier[];
|
|
436
826
|
makerRebateNumerator: BN;
|
|
437
827
|
makerRebateDenominator: BN;
|
|
438
828
|
fillerRewardStructure: OrderFillerRewardStructure;
|
|
829
|
+
flatFillerFee: BN;
|
|
830
|
+
referrerRewardEpochUpperBound: BN;
|
|
831
|
+
};
|
|
832
|
+
export declare type FeeTier = {
|
|
833
|
+
feeNumerator: number;
|
|
834
|
+
feeDenominator: number;
|
|
835
|
+
makerRebateNumerator: number;
|
|
836
|
+
makerRebateDenominator: number;
|
|
837
|
+
referrerRewardNumerator: number;
|
|
838
|
+
referrerRewardDenominator: number;
|
|
839
|
+
refereeFeeNumerator: number;
|
|
840
|
+
refereeFeeDenominator: number;
|
|
841
|
+
};
|
|
842
|
+
export declare type OrderFillerRewardStructure = {
|
|
843
|
+
rewardNumerator: BN;
|
|
844
|
+
rewardDenominator: BN;
|
|
845
|
+
timeBasedRewardLowerBound: BN;
|
|
439
846
|
};
|
|
440
847
|
export declare type OracleGuardRails = {
|
|
441
848
|
priceDivergence: {
|
|
@@ -443,15 +850,36 @@ export declare type OracleGuardRails = {
|
|
|
443
850
|
markOracleDivergenceDenominator: BN;
|
|
444
851
|
};
|
|
445
852
|
validity: {
|
|
446
|
-
|
|
853
|
+
slotsBeforeStaleForAmm: BN;
|
|
854
|
+
slotsBeforeStaleForMargin: BN;
|
|
447
855
|
confidenceIntervalMaxSize: BN;
|
|
448
856
|
tooVolatileRatio: BN;
|
|
449
857
|
};
|
|
450
858
|
useForLiquidations: boolean;
|
|
451
859
|
};
|
|
452
|
-
export declare type
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
860
|
+
export declare type MarginCategory = 'Initial' | 'Maintenance';
|
|
861
|
+
export declare type InsuranceFundStake = {
|
|
862
|
+
marketIndex: number;
|
|
863
|
+
authority: PublicKey;
|
|
864
|
+
ifShares: BN;
|
|
865
|
+
ifBase: BN;
|
|
866
|
+
lastWithdrawRequestShares: BN;
|
|
867
|
+
lastWithdrawRequestValue: BN;
|
|
868
|
+
lastWithdrawRequestTs: BN;
|
|
869
|
+
};
|
|
870
|
+
export declare type SerumV3FulfillmentConfigAccount = {
|
|
871
|
+
fulfillmentType: SpotFulfillmentType;
|
|
872
|
+
status: SpotFulfillmentStatus;
|
|
873
|
+
pubkey: PublicKey;
|
|
874
|
+
marketIndex: number;
|
|
875
|
+
serumProgramId: PublicKey;
|
|
876
|
+
serumMarket: PublicKey;
|
|
877
|
+
serumRequestQueue: PublicKey;
|
|
878
|
+
serumEventQueue: PublicKey;
|
|
879
|
+
serumBids: PublicKey;
|
|
880
|
+
serumAsks: PublicKey;
|
|
881
|
+
serumBaseVault: PublicKey;
|
|
882
|
+
serumQuoteVault: PublicKey;
|
|
883
|
+
serumOpenOrders: PublicKey;
|
|
884
|
+
serumSignerNonce: BN;
|
|
456
885
|
};
|
|
457
|
-
export declare type MarginCategory = 'Initial' | 'Partial' | 'Maintenance';
|