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