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