@drift-labs/sdk 0.2.0-temp.2 → 2.0.0
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
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import {
|
|
3
|
+
AMM,
|
|
4
|
+
AssetTier,
|
|
5
|
+
PerpPosition,
|
|
6
|
+
BN,
|
|
7
|
+
DriftClient,
|
|
8
|
+
User,
|
|
9
|
+
PerpMarketAccount,
|
|
10
|
+
SpotMarketAccount,
|
|
11
|
+
MarketStatus,
|
|
12
|
+
ContractType,
|
|
13
|
+
OracleSource,
|
|
14
|
+
DevnetSpotMarkets,
|
|
15
|
+
BASE_PRECISION,
|
|
16
|
+
QUOTE_PRECISION,
|
|
17
|
+
AMM_TO_QUOTE_PRECISION_RATIO,
|
|
18
|
+
StateAccount,
|
|
19
|
+
UserMapInterface,
|
|
20
|
+
Wallet,
|
|
21
|
+
OrderRecord,
|
|
22
|
+
ExchangeStatus,
|
|
23
|
+
ZERO,
|
|
24
|
+
ContractTier,
|
|
25
|
+
} from '../../src';
|
|
26
|
+
|
|
27
|
+
export const mockPerpPosition: PerpPosition = {
|
|
28
|
+
baseAssetAmount: new BN(0),
|
|
29
|
+
lastCumulativeFundingRate: new BN(0),
|
|
30
|
+
marketIndex: 0,
|
|
31
|
+
quoteAssetAmount: new BN(0),
|
|
32
|
+
quoteBreakEvenAmount: new BN(0),
|
|
33
|
+
quoteEntryAmount: new BN(0),
|
|
34
|
+
openOrders: 0,
|
|
35
|
+
openBids: new BN(0),
|
|
36
|
+
openAsks: new BN(0),
|
|
37
|
+
settledPnl: new BN(0),
|
|
38
|
+
lpShares: new BN(0),
|
|
39
|
+
remainderBaseAssetAmount: 0,
|
|
40
|
+
lastNetBaseAssetAmountPerLp: new BN(0),
|
|
41
|
+
lastNetQuoteAssetAmountPerLp: new BN(0),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const mockAMM: AMM = {
|
|
45
|
+
/* these values create a bid/ask price of 12 */
|
|
46
|
+
baseAssetReserve: new BN(1).mul(BASE_PRECISION),
|
|
47
|
+
quoteAssetReserve: new BN(12)
|
|
48
|
+
.mul(QUOTE_PRECISION)
|
|
49
|
+
.mul(AMM_TO_QUOTE_PRECISION_RATIO),
|
|
50
|
+
sqrtK: new BN(1),
|
|
51
|
+
pegMultiplier: new BN(1),
|
|
52
|
+
maxSlippageRatio: 1_000_000,
|
|
53
|
+
|
|
54
|
+
cumulativeFundingRate: new BN(0),
|
|
55
|
+
lastFundingRate: new BN(0),
|
|
56
|
+
lastFundingRateTs: new BN(0),
|
|
57
|
+
lastMarkPriceTwap: new BN(0),
|
|
58
|
+
lastMarkPriceTwap5Min: new BN(0),
|
|
59
|
+
lastMarkPriceTwapTs: new BN(0),
|
|
60
|
+
historicalOracleData: {
|
|
61
|
+
lastOraclePrice: new BN(0),
|
|
62
|
+
lastOracleConf: new BN(0),
|
|
63
|
+
lastOracleDelay: new BN(0),
|
|
64
|
+
lastOraclePriceTwap: new BN(0),
|
|
65
|
+
lastOraclePriceTwap5Min: new BN(0),
|
|
66
|
+
lastOraclePriceTwapTs: new BN(0),
|
|
67
|
+
},
|
|
68
|
+
lastOracleReservePriceSpreadPct: new BN(0),
|
|
69
|
+
lastOracleConfPct: new BN(0),
|
|
70
|
+
oracle: PublicKey.default,
|
|
71
|
+
oracleSource: OracleSource.PYTH,
|
|
72
|
+
fundingPeriod: new BN(0),
|
|
73
|
+
cumulativeFundingRateLong: new BN(0),
|
|
74
|
+
cumulativeFundingRateShort: new BN(0),
|
|
75
|
+
totalFeeMinusDistributions: new BN(0),
|
|
76
|
+
totalFeeWithdrawn: new BN(0),
|
|
77
|
+
totalFee: new BN(0),
|
|
78
|
+
userLpShares: new BN(0),
|
|
79
|
+
baseAssetAmountWithUnsettledLp: new BN(0),
|
|
80
|
+
orderStepSize: new BN(0),
|
|
81
|
+
orderTickSize: new BN(1),
|
|
82
|
+
last24hAvgFundingRate: new BN(0),
|
|
83
|
+
lastFundingRateShort: new BN(0),
|
|
84
|
+
lastFundingRateLong: new BN(0),
|
|
85
|
+
concentrationCoef: new BN(0),
|
|
86
|
+
lastTradeTs: new BN(0),
|
|
87
|
+
lastOracleNormalisedPrice: new BN(0),
|
|
88
|
+
maxOpenInterest: new BN(0),
|
|
89
|
+
totalLiquidationFee: new BN(0),
|
|
90
|
+
maxFillReserveFraction: 0,
|
|
91
|
+
baseSpread: 0,
|
|
92
|
+
curveUpdateIntensity: 0,
|
|
93
|
+
baseAssetAmountWithAmm: new BN(0),
|
|
94
|
+
baseAssetAmountLong: new BN(0),
|
|
95
|
+
baseAssetAmountShort: new BN(0),
|
|
96
|
+
quoteAssetAmount: new BN(0),
|
|
97
|
+
terminalQuoteAssetReserve: new BN(0),
|
|
98
|
+
feePool: {
|
|
99
|
+
scaledBalance: new BN(0),
|
|
100
|
+
marketIndex: 0,
|
|
101
|
+
},
|
|
102
|
+
totalExchangeFee: new BN(0),
|
|
103
|
+
totalMmFee: new BN(0),
|
|
104
|
+
netRevenueSinceLastFunding: new BN(0),
|
|
105
|
+
lastUpdateSlot: new BN(0),
|
|
106
|
+
lastOracleValid: true,
|
|
107
|
+
lastBidPriceTwap: new BN(0),
|
|
108
|
+
lastAskPriceTwap: new BN(0),
|
|
109
|
+
longSpread: 0,
|
|
110
|
+
shortSpread: 0,
|
|
111
|
+
maxSpread: 0,
|
|
112
|
+
ammJitIntensity: 0,
|
|
113
|
+
maxBaseAssetReserve: new BN(0),
|
|
114
|
+
minBaseAssetReserve: new BN(0),
|
|
115
|
+
totalSocialLoss: new BN(0),
|
|
116
|
+
baseAssetAmountPerLp: new BN(0),
|
|
117
|
+
quoteAssetAmountPerLp: new BN(0),
|
|
118
|
+
|
|
119
|
+
quoteBreakEvenAmountLong: new BN(0),
|
|
120
|
+
quoteBreakEvenAmountShort: new BN(0),
|
|
121
|
+
quoteEntryAmountLong: new BN(0),
|
|
122
|
+
quoteEntryAmountShort: new BN(0),
|
|
123
|
+
|
|
124
|
+
markStd: new BN(0),
|
|
125
|
+
oracleStd: new BN(0),
|
|
126
|
+
longIntensityCount: 0,
|
|
127
|
+
longIntensityVolume: new BN(0),
|
|
128
|
+
shortIntensityCount: 0,
|
|
129
|
+
shortIntensityVolume: new BN(0),
|
|
130
|
+
volume24H: new BN(0),
|
|
131
|
+
minOrderSize: new BN(0),
|
|
132
|
+
maxPositionSize: new BN(0),
|
|
133
|
+
|
|
134
|
+
bidBaseAssetReserve: new BN(0),
|
|
135
|
+
bidQuoteAssetReserve: new BN(0),
|
|
136
|
+
askBaseAssetReserve: new BN(0),
|
|
137
|
+
askQuoteAssetReserve: new BN(0),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
141
|
+
{
|
|
142
|
+
status: MarketStatus.INITIALIZED,
|
|
143
|
+
name: [],
|
|
144
|
+
contractType: ContractType.PERPETUAL,
|
|
145
|
+
contractTier: ContractTier.A,
|
|
146
|
+
expiryTs: new BN(0),
|
|
147
|
+
expiryPrice: new BN(0),
|
|
148
|
+
marketIndex: 0,
|
|
149
|
+
pubkey: PublicKey.default,
|
|
150
|
+
amm: mockAMM,
|
|
151
|
+
numberOfUsersWithBase: 0,
|
|
152
|
+
numberOfUsers: 0,
|
|
153
|
+
marginRatioInitial: 0,
|
|
154
|
+
marginRatioMaintenance: 0,
|
|
155
|
+
nextFillRecordId: new BN(0),
|
|
156
|
+
pnlPool: {
|
|
157
|
+
scaledBalance: new BN(0),
|
|
158
|
+
marketIndex: 0,
|
|
159
|
+
},
|
|
160
|
+
ifLiquidationFee: 0,
|
|
161
|
+
liquidatorFee: 0,
|
|
162
|
+
imfFactor: 0,
|
|
163
|
+
nextFundingRateRecordId: new BN(0),
|
|
164
|
+
nextCurveRecordId: new BN(0),
|
|
165
|
+
unrealizedPnlImfFactor: 0,
|
|
166
|
+
unrealizedPnlMaxImbalance: ZERO,
|
|
167
|
+
unrealizedPnlInitialAssetWeight: 0,
|
|
168
|
+
unrealizedPnlMaintenanceAssetWeight: 0,
|
|
169
|
+
insuranceClaim: {
|
|
170
|
+
revenueWithdrawSinceLastSettle: new BN(0),
|
|
171
|
+
maxRevenueWithdrawPerPeriod: new BN(0),
|
|
172
|
+
lastRevenueWithdrawTs: new BN(0),
|
|
173
|
+
quoteSettledInsurance: new BN(0),
|
|
174
|
+
quoteMaxInsurance: new BN(0),
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
status: MarketStatus.INITIALIZED,
|
|
179
|
+
contractTier: ContractTier.A,
|
|
180
|
+
nextFundingRateRecordId: new BN(0),
|
|
181
|
+
nextCurveRecordId: new BN(0),
|
|
182
|
+
name: [],
|
|
183
|
+
contractType: ContractType.PERPETUAL,
|
|
184
|
+
expiryTs: new BN(0),
|
|
185
|
+
expiryPrice: new BN(0),
|
|
186
|
+
marketIndex: 1,
|
|
187
|
+
pubkey: PublicKey.default,
|
|
188
|
+
amm: mockAMM,
|
|
189
|
+
numberOfUsersWithBase: 0,
|
|
190
|
+
numberOfUsers: 0,
|
|
191
|
+
marginRatioInitial: 0,
|
|
192
|
+
marginRatioMaintenance: 0,
|
|
193
|
+
nextFillRecordId: new BN(0),
|
|
194
|
+
pnlPool: {
|
|
195
|
+
scaledBalance: new BN(0),
|
|
196
|
+
marketIndex: 0,
|
|
197
|
+
},
|
|
198
|
+
ifLiquidationFee: 0,
|
|
199
|
+
liquidatorFee: 0,
|
|
200
|
+
imfFactor: 0,
|
|
201
|
+
unrealizedPnlImfFactor: 0,
|
|
202
|
+
unrealizedPnlMaxImbalance: ZERO,
|
|
203
|
+
unrealizedPnlInitialAssetWeight: 0,
|
|
204
|
+
unrealizedPnlMaintenanceAssetWeight: 0,
|
|
205
|
+
insuranceClaim: {
|
|
206
|
+
revenueWithdrawSinceLastSettle: new BN(0),
|
|
207
|
+
maxRevenueWithdrawPerPeriod: new BN(0),
|
|
208
|
+
lastRevenueWithdrawTs: new BN(0),
|
|
209
|
+
quoteSettledInsurance: new BN(0),
|
|
210
|
+
quoteMaxInsurance: new BN(0),
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
status: MarketStatus.INITIALIZED,
|
|
215
|
+
contractTier: ContractTier.A,
|
|
216
|
+
nextFundingRateRecordId: new BN(0),
|
|
217
|
+
nextCurveRecordId: new BN(0),
|
|
218
|
+
name: [],
|
|
219
|
+
contractType: ContractType.PERPETUAL,
|
|
220
|
+
expiryTs: new BN(0),
|
|
221
|
+
expiryPrice: new BN(0),
|
|
222
|
+
marketIndex: 2,
|
|
223
|
+
pubkey: PublicKey.default,
|
|
224
|
+
amm: mockAMM,
|
|
225
|
+
numberOfUsersWithBase: 0,
|
|
226
|
+
numberOfUsers: 0,
|
|
227
|
+
marginRatioInitial: 0,
|
|
228
|
+
marginRatioMaintenance: 0,
|
|
229
|
+
nextFillRecordId: new BN(0),
|
|
230
|
+
pnlPool: {
|
|
231
|
+
scaledBalance: new BN(0),
|
|
232
|
+
marketIndex: 0,
|
|
233
|
+
},
|
|
234
|
+
ifLiquidationFee: 0,
|
|
235
|
+
liquidatorFee: 0,
|
|
236
|
+
imfFactor: 0,
|
|
237
|
+
unrealizedPnlImfFactor: 0,
|
|
238
|
+
unrealizedPnlMaxImbalance: ZERO,
|
|
239
|
+
unrealizedPnlInitialAssetWeight: 0,
|
|
240
|
+
unrealizedPnlMaintenanceAssetWeight: 0,
|
|
241
|
+
insuranceClaim: {
|
|
242
|
+
revenueWithdrawSinceLastSettle: new BN(0),
|
|
243
|
+
maxRevenueWithdrawPerPeriod: new BN(0),
|
|
244
|
+
lastRevenueWithdrawTs: new BN(0),
|
|
245
|
+
quoteSettledInsurance: new BN(0),
|
|
246
|
+
quoteMaxInsurance: new BN(0),
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
];
|
|
250
|
+
|
|
251
|
+
export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
252
|
+
{
|
|
253
|
+
status: MarketStatus.ACTIVE,
|
|
254
|
+
assetTier: AssetTier.COLLATERAL,
|
|
255
|
+
maxTokenDeposits: new BN(100),
|
|
256
|
+
marketIndex: 0,
|
|
257
|
+
pubkey: PublicKey.default,
|
|
258
|
+
mint: DevnetSpotMarkets[0].mint,
|
|
259
|
+
vault: PublicKey.default,
|
|
260
|
+
revenuePool: {
|
|
261
|
+
scaledBalance: new BN(0),
|
|
262
|
+
marketIndex: 0,
|
|
263
|
+
},
|
|
264
|
+
insuranceFund: {
|
|
265
|
+
vault: PublicKey.default,
|
|
266
|
+
totalShares: new BN(0),
|
|
267
|
+
userShares: new BN(0),
|
|
268
|
+
sharesBase: new BN(0),
|
|
269
|
+
unstakingPeriod: new BN(0),
|
|
270
|
+
lastRevenueSettleTs: new BN(0),
|
|
271
|
+
revenueSettlePeriod: new BN(0),
|
|
272
|
+
totalFactor: 0,
|
|
273
|
+
userFactor: 0,
|
|
274
|
+
},
|
|
275
|
+
ifLiquidationFee: 0,
|
|
276
|
+
liquidatorFee: 0,
|
|
277
|
+
decimals: 6,
|
|
278
|
+
optimalUtilization: 0,
|
|
279
|
+
optimalBorrowRate: 0,
|
|
280
|
+
maxBorrowRate: 0,
|
|
281
|
+
cumulativeDepositInterest: new BN(0),
|
|
282
|
+
cumulativeBorrowInterest: new BN(0),
|
|
283
|
+
totalSocialLoss: new BN(0),
|
|
284
|
+
totalQuoteSocialLoss: new BN(0),
|
|
285
|
+
depositBalance: new BN(0),
|
|
286
|
+
borrowBalance: new BN(0),
|
|
287
|
+
lastInterestTs: new BN(0),
|
|
288
|
+
lastTwapTs: new BN(0),
|
|
289
|
+
oracle: PublicKey.default,
|
|
290
|
+
initialAssetWeight: 0,
|
|
291
|
+
maintenanceAssetWeight: 0,
|
|
292
|
+
initialLiabilityWeight: 0,
|
|
293
|
+
maintenanceLiabilityWeight: 0,
|
|
294
|
+
imfFactor: 0,
|
|
295
|
+
withdrawGuardThreshold: new BN(0),
|
|
296
|
+
depositTokenTwap: new BN(0),
|
|
297
|
+
borrowTokenTwap: new BN(0),
|
|
298
|
+
utilizationTwap: new BN(0),
|
|
299
|
+
orderStepSize: new BN(0),
|
|
300
|
+
orderTickSize: new BN(0),
|
|
301
|
+
nextFillRecordId: new BN(0),
|
|
302
|
+
nextDepositRecordId: new BN(0),
|
|
303
|
+
ordersEnabled: true,
|
|
304
|
+
spotFeePool: {
|
|
305
|
+
scaledBalance: new BN(0),
|
|
306
|
+
marketIndex: 0,
|
|
307
|
+
},
|
|
308
|
+
totalSpotFee: new BN(0),
|
|
309
|
+
oracleSource: OracleSource.PYTH,
|
|
310
|
+
historicalOracleData: {
|
|
311
|
+
lastOraclePrice: new BN(0),
|
|
312
|
+
lastOracleConf: new BN(0),
|
|
313
|
+
lastOracleDelay: new BN(0),
|
|
314
|
+
lastOraclePriceTwap: new BN(0),
|
|
315
|
+
lastOraclePriceTwap5Min: new BN(0),
|
|
316
|
+
lastOraclePriceTwapTs: new BN(0),
|
|
317
|
+
},
|
|
318
|
+
historicalIndexData: {
|
|
319
|
+
lastIndexBidPrice: new BN(0),
|
|
320
|
+
lastIndexAskPrice: new BN(0),
|
|
321
|
+
lastIndexPriceTwap: new BN(0),
|
|
322
|
+
lastIndexPriceTwap5Min: new BN(0),
|
|
323
|
+
lastIndexPriceTwapTs: new BN(0),
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
status: MarketStatus.ACTIVE,
|
|
328
|
+
assetTier: AssetTier.CROSS,
|
|
329
|
+
maxTokenDeposits: new BN(100),
|
|
330
|
+
marketIndex: 1,
|
|
331
|
+
pubkey: PublicKey.default,
|
|
332
|
+
mint: DevnetSpotMarkets[1].mint,
|
|
333
|
+
vault: PublicKey.default,
|
|
334
|
+
revenuePool: {
|
|
335
|
+
scaledBalance: new BN(0),
|
|
336
|
+
marketIndex: 0,
|
|
337
|
+
},
|
|
338
|
+
insuranceFund: {
|
|
339
|
+
vault: PublicKey.default,
|
|
340
|
+
totalShares: new BN(0),
|
|
341
|
+
userShares: new BN(0),
|
|
342
|
+
sharesBase: new BN(0),
|
|
343
|
+
unstakingPeriod: new BN(0),
|
|
344
|
+
lastRevenueSettleTs: new BN(0),
|
|
345
|
+
revenueSettlePeriod: new BN(0),
|
|
346
|
+
totalFactor: 0,
|
|
347
|
+
userFactor: 0,
|
|
348
|
+
},
|
|
349
|
+
ifLiquidationFee: 0,
|
|
350
|
+
liquidatorFee: 0,
|
|
351
|
+
decimals: 9,
|
|
352
|
+
optimalUtilization: 0,
|
|
353
|
+
optimalBorrowRate: 0,
|
|
354
|
+
maxBorrowRate: 0,
|
|
355
|
+
cumulativeDepositInterest: new BN(0),
|
|
356
|
+
cumulativeBorrowInterest: new BN(0),
|
|
357
|
+
totalSocialLoss: new BN(0),
|
|
358
|
+
totalQuoteSocialLoss: new BN(0),
|
|
359
|
+
depositBalance: new BN(0),
|
|
360
|
+
borrowBalance: new BN(0),
|
|
361
|
+
lastInterestTs: new BN(0),
|
|
362
|
+
lastTwapTs: new BN(0),
|
|
363
|
+
oracle: PublicKey.default,
|
|
364
|
+
initialAssetWeight: 0,
|
|
365
|
+
maintenanceAssetWeight: 0,
|
|
366
|
+
initialLiabilityWeight: 0,
|
|
367
|
+
maintenanceLiabilityWeight: 0,
|
|
368
|
+
imfFactor: 0,
|
|
369
|
+
withdrawGuardThreshold: new BN(0),
|
|
370
|
+
depositTokenTwap: new BN(0),
|
|
371
|
+
borrowTokenTwap: new BN(0),
|
|
372
|
+
utilizationTwap: new BN(0),
|
|
373
|
+
orderStepSize: new BN(0),
|
|
374
|
+
orderTickSize: new BN(0),
|
|
375
|
+
nextFillRecordId: new BN(0),
|
|
376
|
+
nextDepositRecordId: new BN(0),
|
|
377
|
+
ordersEnabled: true,
|
|
378
|
+
spotFeePool: {
|
|
379
|
+
scaledBalance: new BN(0),
|
|
380
|
+
marketIndex: 0,
|
|
381
|
+
},
|
|
382
|
+
totalSpotFee: new BN(0),
|
|
383
|
+
oracleSource: OracleSource.PYTH,
|
|
384
|
+
historicalOracleData: {
|
|
385
|
+
lastOraclePrice: new BN(0),
|
|
386
|
+
lastOracleConf: new BN(0),
|
|
387
|
+
lastOracleDelay: new BN(0),
|
|
388
|
+
lastOraclePriceTwap: new BN(0),
|
|
389
|
+
lastOraclePriceTwap5Min: new BN(0),
|
|
390
|
+
lastOraclePriceTwapTs: new BN(0),
|
|
391
|
+
},
|
|
392
|
+
historicalIndexData: {
|
|
393
|
+
lastIndexBidPrice: new BN(0),
|
|
394
|
+
lastIndexAskPrice: new BN(0),
|
|
395
|
+
lastIndexPriceTwap: new BN(0),
|
|
396
|
+
lastIndexPriceTwap5Min: new BN(0),
|
|
397
|
+
lastIndexPriceTwapTs: new BN(0),
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
status: MarketStatus.ACTIVE,
|
|
402
|
+
assetTier: AssetTier.PROTECTED,
|
|
403
|
+
maxTokenDeposits: new BN(100),
|
|
404
|
+
marketIndex: 2,
|
|
405
|
+
pubkey: PublicKey.default,
|
|
406
|
+
mint: DevnetSpotMarkets[2].mint,
|
|
407
|
+
vault: PublicKey.default,
|
|
408
|
+
revenuePool: {
|
|
409
|
+
scaledBalance: new BN(0),
|
|
410
|
+
marketIndex: 0,
|
|
411
|
+
},
|
|
412
|
+
insuranceFund: {
|
|
413
|
+
vault: PublicKey.default,
|
|
414
|
+
totalShares: new BN(0),
|
|
415
|
+
userShares: new BN(0),
|
|
416
|
+
sharesBase: new BN(0),
|
|
417
|
+
unstakingPeriod: new BN(0),
|
|
418
|
+
lastRevenueSettleTs: new BN(0),
|
|
419
|
+
revenueSettlePeriod: new BN(0),
|
|
420
|
+
totalFactor: 0,
|
|
421
|
+
userFactor: 0,
|
|
422
|
+
},
|
|
423
|
+
ifLiquidationFee: 0,
|
|
424
|
+
liquidatorFee: 0,
|
|
425
|
+
decimals: 6,
|
|
426
|
+
optimalUtilization: 0,
|
|
427
|
+
optimalBorrowRate: 0,
|
|
428
|
+
maxBorrowRate: 0,
|
|
429
|
+
cumulativeDepositInterest: new BN(0),
|
|
430
|
+
cumulativeBorrowInterest: new BN(0),
|
|
431
|
+
totalSocialLoss: new BN(0),
|
|
432
|
+
totalQuoteSocialLoss: new BN(0),
|
|
433
|
+
depositBalance: new BN(0),
|
|
434
|
+
borrowBalance: new BN(0),
|
|
435
|
+
lastInterestTs: new BN(0),
|
|
436
|
+
lastTwapTs: new BN(0),
|
|
437
|
+
oracle: PublicKey.default,
|
|
438
|
+
initialAssetWeight: 0,
|
|
439
|
+
maintenanceAssetWeight: 0,
|
|
440
|
+
initialLiabilityWeight: 0,
|
|
441
|
+
maintenanceLiabilityWeight: 0,
|
|
442
|
+
imfFactor: 0,
|
|
443
|
+
withdrawGuardThreshold: new BN(0),
|
|
444
|
+
depositTokenTwap: new BN(0),
|
|
445
|
+
borrowTokenTwap: new BN(0),
|
|
446
|
+
utilizationTwap: new BN(0),
|
|
447
|
+
orderStepSize: new BN(0),
|
|
448
|
+
orderTickSize: new BN(0),
|
|
449
|
+
nextFillRecordId: new BN(0),
|
|
450
|
+
nextDepositRecordId: new BN(0),
|
|
451
|
+
ordersEnabled: true,
|
|
452
|
+
spotFeePool: {
|
|
453
|
+
scaledBalance: new BN(0),
|
|
454
|
+
marketIndex: 0,
|
|
455
|
+
},
|
|
456
|
+
totalSpotFee: new BN(0),
|
|
457
|
+
oracleSource: OracleSource.PYTH,
|
|
458
|
+
historicalOracleData: {
|
|
459
|
+
lastOraclePrice: new BN(0),
|
|
460
|
+
lastOracleConf: new BN(0),
|
|
461
|
+
lastOracleDelay: new BN(0),
|
|
462
|
+
lastOraclePriceTwap: new BN(0),
|
|
463
|
+
lastOraclePriceTwap5Min: new BN(0),
|
|
464
|
+
lastOraclePriceTwapTs: new BN(0),
|
|
465
|
+
},
|
|
466
|
+
historicalIndexData: {
|
|
467
|
+
lastIndexBidPrice: new BN(0),
|
|
468
|
+
lastIndexAskPrice: new BN(0),
|
|
469
|
+
lastIndexPriceTwap: new BN(0),
|
|
470
|
+
lastIndexPriceTwap5Min: new BN(0),
|
|
471
|
+
lastIndexPriceTwapTs: new BN(0),
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
];
|
|
475
|
+
|
|
476
|
+
export const mockStateAccount: StateAccount = {
|
|
477
|
+
admin: PublicKey.default,
|
|
478
|
+
defaultMarketOrderTimeInForce: 0,
|
|
479
|
+
defaultSpotAuctionDuration: 0,
|
|
480
|
+
discountMint: PublicKey.default,
|
|
481
|
+
exchangeStatus: ExchangeStatus.ACTIVE,
|
|
482
|
+
liquidationMarginBufferRatio: 0,
|
|
483
|
+
lpCooldownTime: new BN(0),
|
|
484
|
+
minPerpAuctionDuration: 0,
|
|
485
|
+
numberOfMarkets: 0,
|
|
486
|
+
numberOfSpotMarkets: 0,
|
|
487
|
+
numberOfSubAccounts: new BN(0),
|
|
488
|
+
numberOfAuthorities: new BN(0),
|
|
489
|
+
oracleGuardRails: {
|
|
490
|
+
priceDivergence: {
|
|
491
|
+
markOracleDivergenceNumerator: new BN(0),
|
|
492
|
+
markOracleDivergenceDenominator: new BN(0),
|
|
493
|
+
},
|
|
494
|
+
validity: {
|
|
495
|
+
slotsBeforeStaleForAmm: new BN(0),
|
|
496
|
+
slotsBeforeStaleForMargin: new BN(0),
|
|
497
|
+
confidenceIntervalMaxSize: new BN(0),
|
|
498
|
+
tooVolatileRatio: new BN(0),
|
|
499
|
+
},
|
|
500
|
+
},
|
|
501
|
+
perpFeeStructure: {
|
|
502
|
+
feeTiers: [
|
|
503
|
+
{
|
|
504
|
+
feeNumerator: 0,
|
|
505
|
+
feeDenominator: 0,
|
|
506
|
+
makerRebateNumerator: 0,
|
|
507
|
+
makerRebateDenominator: 0,
|
|
508
|
+
referrerRewardNumerator: 0,
|
|
509
|
+
referrerRewardDenominator: 0,
|
|
510
|
+
refereeFeeNumerator: 0,
|
|
511
|
+
refereeFeeDenominator: 0,
|
|
512
|
+
},
|
|
513
|
+
],
|
|
514
|
+
makerRebateNumerator: new BN(0),
|
|
515
|
+
makerRebateDenominator: new BN(0),
|
|
516
|
+
fillerRewardStructure: {
|
|
517
|
+
rewardNumerator: new BN(0),
|
|
518
|
+
rewardDenominator: new BN(0),
|
|
519
|
+
timeBasedRewardLowerBound: new BN(0),
|
|
520
|
+
},
|
|
521
|
+
flatFillerFee: new BN(0),
|
|
522
|
+
referrerRewardEpochUpperBound: new BN(0),
|
|
523
|
+
},
|
|
524
|
+
settlementDuration: 0,
|
|
525
|
+
signer: PublicKey.default,
|
|
526
|
+
signerNonce: 0,
|
|
527
|
+
spotFeeStructure: {
|
|
528
|
+
feeTiers: [
|
|
529
|
+
{
|
|
530
|
+
feeNumerator: 0,
|
|
531
|
+
feeDenominator: 0,
|
|
532
|
+
makerRebateNumerator: 0,
|
|
533
|
+
makerRebateDenominator: 0,
|
|
534
|
+
referrerRewardNumerator: 0,
|
|
535
|
+
referrerRewardDenominator: 0,
|
|
536
|
+
refereeFeeNumerator: 0,
|
|
537
|
+
refereeFeeDenominator: 0,
|
|
538
|
+
},
|
|
539
|
+
],
|
|
540
|
+
makerRebateNumerator: new BN(0),
|
|
541
|
+
makerRebateDenominator: new BN(0),
|
|
542
|
+
fillerRewardStructure: {
|
|
543
|
+
rewardNumerator: new BN(0),
|
|
544
|
+
rewardDenominator: new BN(0),
|
|
545
|
+
timeBasedRewardLowerBound: new BN(0),
|
|
546
|
+
},
|
|
547
|
+
flatFillerFee: new BN(0),
|
|
548
|
+
referrerRewardEpochUpperBound: new BN(0),
|
|
549
|
+
},
|
|
550
|
+
srmVault: PublicKey.default,
|
|
551
|
+
whitelistMint: PublicKey.default,
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
export class MockUserMap implements UserMapInterface {
|
|
555
|
+
private userMap = new Map<string, User>();
|
|
556
|
+
private userAccountToAuthority = new Map<string, string>();
|
|
557
|
+
private driftClient: DriftClient;
|
|
558
|
+
|
|
559
|
+
constructor() {
|
|
560
|
+
this.userMap = new Map();
|
|
561
|
+
this.userAccountToAuthority = new Map();
|
|
562
|
+
this.driftClient = new DriftClient({
|
|
563
|
+
connection: new Connection('http://localhost:8899'),
|
|
564
|
+
wallet: new Wallet(new Keypair()),
|
|
565
|
+
programID: PublicKey.default,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
public async fetchAllUsers(): Promise<void> {}
|
|
570
|
+
|
|
571
|
+
public async addPubkey(userAccountPublicKey: PublicKey): Promise<void> {
|
|
572
|
+
const user = new User({
|
|
573
|
+
driftClient: this.driftClient,
|
|
574
|
+
userAccountPublicKey: userAccountPublicKey,
|
|
575
|
+
});
|
|
576
|
+
this.userMap.set(userAccountPublicKey.toBase58(), user);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// mock function
|
|
580
|
+
public addUserAccountAuthority(
|
|
581
|
+
userAccountPublicKey: PublicKey,
|
|
582
|
+
authorityPublicKey: PublicKey
|
|
583
|
+
): void {
|
|
584
|
+
if (!this.userMap.has(userAccountPublicKey.toBase58())) {
|
|
585
|
+
this.addPubkey(userAccountPublicKey);
|
|
586
|
+
}
|
|
587
|
+
this.userAccountToAuthority.set(
|
|
588
|
+
userAccountPublicKey.toBase58(),
|
|
589
|
+
authorityPublicKey.toBase58()
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
public has(key: string): boolean {
|
|
594
|
+
return this.userMap.has(key);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
public get(_key: string): User | undefined {
|
|
598
|
+
return undefined;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
public async mustGet(_key: string): Promise<User> {
|
|
602
|
+
return new User({
|
|
603
|
+
driftClient: this.driftClient,
|
|
604
|
+
userAccountPublicKey: PublicKey.default,
|
|
605
|
+
});
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
public getUserAuthority(key: string): PublicKey | undefined {
|
|
609
|
+
return new PublicKey(
|
|
610
|
+
this.userAccountToAuthority.get(key) || PublicKey.default.toBase58()
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
public async updateWithOrderRecord(_record: OrderRecord): Promise<void> {}
|
|
615
|
+
|
|
616
|
+
public values(): IterableIterator<User> {
|
|
617
|
+
return this.userMap.values();
|
|
618
|
+
}
|
|
619
|
+
}
|