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