@velocity-exchange/sdk 0.2.0 → 0.2.2
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/CHANGELOG.md +7 -44
- package/lib/browser/adminClient.d.ts +0 -1
- package/lib/browser/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/browser/bankrun/bankrunConnection.js +23 -1
- package/lib/browser/constants/numericConstants.d.ts +2 -1
- package/lib/browser/constants/numericConstants.js +8 -4
- package/lib/browser/constants/spotMarkets.d.ts +0 -1
- package/lib/browser/core/VelocityCore.d.ts +0 -1
- package/lib/browser/core/instructions/deposit.d.ts +0 -1
- package/lib/browser/core/instructions/withdraw.d.ts +0 -1
- package/lib/browser/dlob/DLOB.d.ts +0 -1
- package/lib/browser/dlob/DLOBNode.d.ts +0 -1
- package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/browser/dlob/NodeList.d.ts +0 -1
- package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
- package/lib/browser/events/eventList.d.ts +3 -3
- package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
- package/lib/browser/events/pollingLogProvider.d.ts +1 -1
- package/lib/browser/events/txEventCache.d.ts +3 -3
- package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
- package/lib/browser/factory/bigNum.d.ts +0 -1
- package/lib/browser/index.d.ts +1 -1
- package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/browser/jupiter/jupiterClient.d.ts +0 -1
- package/lib/browser/marginCalculation.d.ts +0 -1
- package/lib/browser/marinade/index.d.ts +2 -3
- package/lib/browser/marinade/index.js +5 -0
- package/lib/browser/math/amm.d.ts +0 -1
- package/lib/browser/math/auction.d.ts +0 -1
- package/lib/browser/math/conversion.d.ts +0 -1
- package/lib/browser/math/funding.d.ts +0 -1
- package/lib/browser/math/insurance.d.ts +0 -1
- package/lib/browser/math/liquidation.d.ts +0 -1
- package/lib/browser/math/margin.d.ts +0 -1
- package/lib/browser/math/market.d.ts +0 -1
- package/lib/browser/math/oracles.d.ts +0 -1
- package/lib/browser/math/orders.d.ts +0 -1
- package/lib/browser/math/position.d.ts +1 -2
- package/lib/browser/math/repeg.d.ts +0 -1
- package/lib/browser/math/spotBalance.d.ts +0 -1
- package/lib/browser/math/spotMarket.d.ts +0 -1
- package/lib/browser/math/spotPosition.d.ts +0 -1
- package/lib/browser/math/state.d.ts +0 -1
- package/lib/browser/math/superStake.d.ts +0 -1
- package/lib/browser/math/trade.d.ts +2 -3
- package/lib/browser/math/utils.d.ts +0 -1
- package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
- package/lib/browser/oracles/pythClient.d.ts +0 -1
- package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
- package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/browser/oracles/types.d.ts +0 -1
- package/lib/browser/oracles/utils.d.ts +0 -1
- package/lib/browser/orderParams.d.ts +0 -1
- package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/browser/titan/titanClient.d.ts +0 -1
- package/lib/browser/tokenFaucet.d.ts +0 -1
- package/lib/browser/tx/txHandler.d.ts +2 -2
- package/lib/browser/types.d.ts +2 -3
- package/lib/browser/user.d.ts +0 -1
- package/lib/browser/velocityClient.d.ts +1 -2
- package/lib/node/adminClient.d.ts +0 -1
- package/lib/node/adminClient.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.d.ts +2 -1
- package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
- package/lib/node/bankrun/bankrunConnection.js +23 -1
- package/lib/node/constants/numericConstants.d.ts +2 -1
- package/lib/node/constants/numericConstants.d.ts.map +1 -1
- package/lib/node/constants/numericConstants.js +8 -4
- package/lib/node/constants/spotMarkets.d.ts +0 -1
- package/lib/node/constants/spotMarkets.d.ts.map +1 -1
- package/lib/node/core/VelocityCore.d.ts +0 -1
- package/lib/node/core/VelocityCore.d.ts.map +1 -1
- package/lib/node/core/instructions/deposit.d.ts +0 -1
- package/lib/node/core/instructions/deposit.d.ts.map +1 -1
- package/lib/node/core/instructions/withdraw.d.ts +0 -1
- package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
- package/lib/node/dlob/DLOB.d.ts +0 -1
- package/lib/node/dlob/DLOB.d.ts.map +1 -1
- package/lib/node/dlob/DLOBNode.d.ts +0 -1
- package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
- package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
- package/lib/node/dlob/NodeList.d.ts +0 -1
- package/lib/node/dlob/NodeList.d.ts.map +1 -1
- package/lib/node/dlob/orderBookLevels.d.ts +0 -1
- package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
- package/lib/node/factory/bigNum.d.ts +0 -1
- package/lib/node/factory/bigNum.d.ts.map +1 -1
- package/lib/node/index.d.ts +1 -1
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
- package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
- package/lib/node/jupiter/jupiterClient.d.ts +0 -1
- package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
- package/lib/node/marginCalculation.d.ts +0 -1
- package/lib/node/marginCalculation.d.ts.map +1 -1
- package/lib/node/marinade/index.d.ts +2 -3
- package/lib/node/marinade/index.d.ts.map +1 -1
- package/lib/node/marinade/index.js +5 -0
- package/lib/node/math/amm.d.ts +0 -1
- package/lib/node/math/amm.d.ts.map +1 -1
- package/lib/node/math/auction.d.ts +0 -1
- package/lib/node/math/auction.d.ts.map +1 -1
- package/lib/node/math/conversion.d.ts +0 -1
- package/lib/node/math/conversion.d.ts.map +1 -1
- package/lib/node/math/funding.d.ts +0 -1
- package/lib/node/math/funding.d.ts.map +1 -1
- package/lib/node/math/insurance.d.ts +0 -1
- package/lib/node/math/insurance.d.ts.map +1 -1
- package/lib/node/math/liquidation.d.ts +0 -1
- package/lib/node/math/liquidation.d.ts.map +1 -1
- package/lib/node/math/margin.d.ts +0 -1
- package/lib/node/math/margin.d.ts.map +1 -1
- package/lib/node/math/market.d.ts +0 -1
- package/lib/node/math/market.d.ts.map +1 -1
- package/lib/node/math/oracles.d.ts +0 -1
- package/lib/node/math/oracles.d.ts.map +1 -1
- package/lib/node/math/orders.d.ts +0 -1
- package/lib/node/math/orders.d.ts.map +1 -1
- package/lib/node/math/position.d.ts +0 -1
- package/lib/node/math/position.d.ts.map +1 -1
- package/lib/node/math/repeg.d.ts +0 -1
- package/lib/node/math/repeg.d.ts.map +1 -1
- package/lib/node/math/spotBalance.d.ts +0 -1
- package/lib/node/math/spotBalance.d.ts.map +1 -1
- package/lib/node/math/spotMarket.d.ts +0 -1
- package/lib/node/math/spotMarket.d.ts.map +1 -1
- package/lib/node/math/spotPosition.d.ts +0 -1
- package/lib/node/math/spotPosition.d.ts.map +1 -1
- package/lib/node/math/state.d.ts +0 -1
- package/lib/node/math/state.d.ts.map +1 -1
- package/lib/node/math/superStake.d.ts +0 -1
- package/lib/node/math/superStake.d.ts.map +1 -1
- package/lib/node/math/trade.d.ts +0 -1
- package/lib/node/math/trade.d.ts.map +1 -1
- package/lib/node/math/utils.d.ts +0 -1
- package/lib/node/math/utils.d.ts.map +1 -1
- package/lib/node/oracles/pythClient.d.ts +0 -1
- package/lib/node/oracles/pythClient.d.ts.map +1 -1
- package/lib/node/oracles/pythLazerClient.d.ts +0 -1
- package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
- package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
- package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
- package/lib/node/oracles/types.d.ts +0 -1
- package/lib/node/oracles/types.d.ts.map +1 -1
- package/lib/node/oracles/utils.d.ts +0 -1
- package/lib/node/oracles/utils.d.ts.map +1 -1
- package/lib/node/orderParams.d.ts +0 -1
- package/lib/node/orderParams.d.ts.map +1 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
- package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
- package/lib/node/titan/titanClient.d.ts +0 -1
- package/lib/node/titan/titanClient.d.ts.map +1 -1
- package/lib/node/tokenFaucet.d.ts +0 -1
- package/lib/node/tokenFaucet.d.ts.map +1 -1
- package/lib/node/types.d.ts +0 -1
- package/lib/node/types.d.ts.map +1 -1
- package/lib/node/user.d.ts +0 -1
- package/lib/node/user.d.ts.map +1 -1
- package/lib/node/velocityClient.d.ts +0 -1
- package/lib/node/velocityClient.d.ts.map +1 -1
- package/package.json +16 -11
- package/src/bankrun/bankrunConnection.ts +27 -1
- package/src/constants/numericConstants.ts +6 -2
- package/src/index.ts +5 -1
- package/src/marinade/index.ts +11 -2
- package/src/userMap/referrerMap.ts +1 -1
- package/src/userMap/revenueShareEscrowMap.ts +2 -2
- package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
- package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
- package/tests/amm/test.ts +162 -95
- package/tests/decode/userAccountBufferStrings.ts +100 -100
- package/tests/dlob/helpers.ts +156 -172
- package/tests/dlob/test.ts +155 -106
- package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
- package/tests/user/getMarginCalculation.ts +1 -1
- package/tests/user/helpers.ts +3 -4
- package/tests/user/marginCalculations.test.ts +2 -2
- package/tests/user/test.ts +3 -3
- package/tsconfig.browser.json +3 -1
- package/tsconfig.json +20 -2
- package/.yarn/install-state.gz +0 -0
- package/VERSION +0 -1
- package/bun.lock +0 -1907
- package/scripts/updateVersion.js +0 -28
- package/tests/decode/phoenix.ts +0 -71
package/tests/dlob/helpers.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import {
|
|
3
3
|
AMM,
|
|
4
4
|
AssetTier,
|
|
5
|
+
MarketStats,
|
|
5
6
|
PerpPosition,
|
|
6
7
|
BN,
|
|
7
8
|
VelocityClient,
|
|
@@ -55,123 +56,114 @@ export const mockAMM: AMM = {
|
|
|
55
56
|
pegMultiplier: new BN(1),
|
|
56
57
|
maxSlippageRatio: 1_000_000,
|
|
57
58
|
|
|
58
|
-
cumulativeFundingRate: new BN(0),
|
|
59
|
-
lastFundingRate: new BN(0),
|
|
60
|
-
lastFundingRateTs: new BN(0),
|
|
61
|
-
lastMarkPriceTwap: new BN(0),
|
|
62
|
-
lastMarkPriceTwap5Min: new BN(0),
|
|
63
|
-
lastMarkPriceTwapTs: new BN(0),
|
|
64
|
-
historicalOracleData: {
|
|
65
|
-
lastOraclePrice: new BN(0),
|
|
66
|
-
lastOracleConf: new BN(0),
|
|
67
|
-
lastOracleDelay: new BN(0),
|
|
68
|
-
lastOraclePriceTwap: new BN(0),
|
|
69
|
-
lastOraclePriceTwap5Min: new BN(0),
|
|
70
|
-
lastOraclePriceTwapTs: new BN(0),
|
|
71
|
-
},
|
|
72
|
-
lastOracleReservePriceSpreadPct: new BN(0),
|
|
73
|
-
lastOracleConfPct: new BN(0),
|
|
74
|
-
oracle: PublicKey.default,
|
|
75
|
-
oracleSource: OracleSource.PYTH_LAZER,
|
|
76
|
-
fundingPeriod: new BN(0),
|
|
77
|
-
cumulativeFundingRateLong: new BN(0),
|
|
78
|
-
cumulativeFundingRateShort: new BN(0),
|
|
79
|
-
totalFeeMinusDistributions: new BN(0),
|
|
80
|
-
totalFeeWithdrawn: new BN(0),
|
|
81
|
-
totalFee: new BN(0),
|
|
82
|
-
orderStepSize: new BN(1),
|
|
83
|
-
orderTickSize: new BN(1),
|
|
84
|
-
last24HAvgFundingRate: new BN(0),
|
|
85
|
-
lastFundingRateShort: new BN(0),
|
|
86
|
-
lastFundingRateLong: new BN(0),
|
|
87
|
-
concentrationCoef: new BN(0),
|
|
88
|
-
lastTradeTs: new BN(0),
|
|
89
|
-
lastOracleNormalisedPrice: new BN(0),
|
|
90
|
-
maxOpenInterest: new BN(0),
|
|
91
|
-
totalLiquidationFee: new BN(0),
|
|
92
|
-
maxFillReserveFraction: 0,
|
|
93
|
-
baseSpread: 0,
|
|
94
|
-
curveUpdateIntensity: 0,
|
|
95
|
-
baseAssetAmountWithAmm: new BN(0),
|
|
96
|
-
baseAssetAmountLong: new BN(0),
|
|
97
|
-
baseAssetAmountShort: new BN(0),
|
|
98
|
-
quoteAssetAmount: new BN(0),
|
|
99
|
-
terminalQuoteAssetReserve: new BN(0),
|
|
100
59
|
feePool: {
|
|
101
60
|
scaledBalance: new BN(0),
|
|
102
61
|
marketIndex: 0,
|
|
103
62
|
},
|
|
104
|
-
|
|
63
|
+
concentrationCoef: new BN(0),
|
|
64
|
+
minBaseAssetReserve: new BN(0),
|
|
65
|
+
maxBaseAssetReserve: new BN(0),
|
|
66
|
+
terminalQuoteAssetReserve: new BN(0),
|
|
67
|
+
baseAssetAmountWithAmm: new BN(0),
|
|
68
|
+
totalFee: new BN(0),
|
|
105
69
|
totalMmFee: new BN(0),
|
|
106
|
-
|
|
70
|
+
totalFeeMinusDistributions: new BN(0),
|
|
71
|
+
totalFeeWithdrawn: new BN(0),
|
|
107
72
|
lastUpdateSlot: new BN(0),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
shortSpread: 0,
|
|
73
|
+
netRevenueSinceLastFunding: new BN(0),
|
|
74
|
+
lastCumulativeFundingRateLong: new BN(0),
|
|
75
|
+
lastCumulativeFundingRateShort: new BN(0),
|
|
76
|
+
baseSpread: 0,
|
|
113
77
|
maxSpread: 0,
|
|
78
|
+
maxFillReserveFraction: 0,
|
|
79
|
+
curveUpdateIntensity: 0,
|
|
114
80
|
ammJitIntensity: 0,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
quoteBreakEvenAmountShort: new BN(0),
|
|
121
|
-
quoteEntryAmountLong: new BN(0),
|
|
122
|
-
quoteEntryAmountShort: new BN(0),
|
|
81
|
+
ammSpreadAdjustment: 0,
|
|
82
|
+
ammInventorySpreadAdjustment: 0,
|
|
83
|
+
referencePriceOffsetDeadbandPct: 0,
|
|
84
|
+
fundingBiasSensitivity: 0,
|
|
85
|
+
};
|
|
123
86
|
|
|
87
|
+
// Per-market analytics/oracle/twap data that was moved off AMM onto its own
|
|
88
|
+
// MarketStats sub-struct. mockPerpMarkets clones this for each market.
|
|
89
|
+
export const mockMarketStats: MarketStats = {
|
|
90
|
+
lastMarkPriceTwap: new BN(0),
|
|
91
|
+
lastMarkPriceTwap5Min: new BN(0),
|
|
92
|
+
lastMarkPriceTwapTs: new BN(0),
|
|
93
|
+
lastBidPriceTwap: new BN(0),
|
|
94
|
+
lastAskPriceTwap: new BN(0),
|
|
124
95
|
markStd: new BN(0),
|
|
125
96
|
oracleStd: new BN(0),
|
|
97
|
+
lastOracleConfPct: new BN(0),
|
|
98
|
+
volume24H: new BN(0),
|
|
126
99
|
longIntensityVolume: new BN(0),
|
|
127
100
|
shortIntensityVolume: new BN(0),
|
|
128
|
-
|
|
101
|
+
lastTradeTs: new BN(0),
|
|
102
|
+
last24HAvgFundingRate: new BN(0),
|
|
103
|
+
fundingPeriod: new BN(0),
|
|
129
104
|
minOrderSize: new BN(0),
|
|
130
|
-
|
|
131
|
-
bidBaseAssetReserve: new BN(0),
|
|
132
|
-
bidQuoteAssetReserve: new BN(0),
|
|
133
|
-
askBaseAssetReserve: new BN(0),
|
|
134
|
-
askQuoteAssetReserve: new BN(0),
|
|
135
|
-
|
|
136
|
-
netUnsettledFundingPnl: new BN(0),
|
|
137
|
-
referencePriceOffset: 0,
|
|
138
|
-
|
|
139
|
-
oracleLowRiskSlotDelayOverride: 0,
|
|
140
|
-
ammSpreadAdjustment: 0,
|
|
141
|
-
ammInventorySpreadAdjustment: 0,
|
|
142
|
-
mmOracleSequenceId: new BN(0),
|
|
143
105
|
mmOraclePrice: new BN(0),
|
|
144
106
|
mmOracleSlot: new BN(0),
|
|
107
|
+
mmOracleSequenceId: new BN(0),
|
|
108
|
+
lastOracleNormalisedPrice: new BN(0),
|
|
109
|
+
lastReferencePriceOffset: 0,
|
|
110
|
+
lastOracleValid: true,
|
|
145
111
|
lastFundingOracleTwap: new BN(0),
|
|
146
|
-
|
|
147
|
-
|
|
112
|
+
historicalOracleData: {
|
|
113
|
+
lastOraclePrice: new BN(0),
|
|
114
|
+
lastOracleConf: new BN(0),
|
|
115
|
+
lastOracleDelay: new BN(0),
|
|
116
|
+
lastOraclePriceTwap: new BN(0),
|
|
117
|
+
lastOraclePriceTwap5Min: new BN(0),
|
|
118
|
+
lastOraclePriceTwapTs: new BN(0),
|
|
119
|
+
},
|
|
148
120
|
};
|
|
149
121
|
|
|
150
|
-
|
|
151
|
-
|
|
122
|
+
// Fields shared by every mock perp market: the AMM, its MarketStats, the
|
|
123
|
+
// fields migrated off AMM to the top-level PerpMarket, and the other required
|
|
124
|
+
// PerpMarketAccount members the dlob/amm tests don't individually tweak.
|
|
125
|
+
function mockPerpMarketCommon(): Omit<
|
|
126
|
+
PerpMarketAccount,
|
|
127
|
+
| 'marketIndex'
|
|
128
|
+
| 'marginRatioInitial'
|
|
129
|
+
| 'marginRatioMaintenance'
|
|
130
|
+
| 'contractTier'
|
|
131
|
+
> {
|
|
132
|
+
return {
|
|
152
133
|
status: MarketStatus.INITIALIZED,
|
|
153
134
|
lastFillPrice: new BN(0),
|
|
154
135
|
name: [],
|
|
155
136
|
contractType: ContractType.PERPETUAL,
|
|
156
|
-
contractTier: ContractTier.A,
|
|
157
137
|
expiryTs: new BN(0),
|
|
158
138
|
expiryPrice: new BN(0),
|
|
159
|
-
marketIndex: 0,
|
|
160
139
|
pubkey: PublicKey.default,
|
|
161
140
|
amm: mockAMM,
|
|
141
|
+
marketStats: mockMarketStats,
|
|
162
142
|
numberOfUsersWithBase: 0,
|
|
163
143
|
numberOfUsers: 0,
|
|
164
|
-
marginRatioInitial: 2000,
|
|
165
|
-
marginRatioMaintenance: 1000,
|
|
166
144
|
nextFillRecordId: new BN(0),
|
|
145
|
+
nextFundingRateRecordId: new BN(0),
|
|
167
146
|
pnlPool: {
|
|
168
147
|
scaledBalance: new BN(0),
|
|
169
148
|
marketIndex: 0,
|
|
170
149
|
},
|
|
171
|
-
|
|
150
|
+
protocolFeePool: {
|
|
151
|
+
scaledBalance: new BN(0),
|
|
152
|
+
marketIndex: 0,
|
|
153
|
+
},
|
|
154
|
+
feeLedger: {
|
|
155
|
+
totalExchangeFee: new BN(0),
|
|
156
|
+
totalLiquidationFee: new BN(0),
|
|
157
|
+
pendingProtocolFee: new BN(0),
|
|
158
|
+
pendingIfFee: new BN(0),
|
|
159
|
+
ammProtocolFeesReceived: new BN(0),
|
|
160
|
+
pendingAmmProvision: new BN(0),
|
|
161
|
+
},
|
|
172
162
|
liquidatorFee: 0,
|
|
163
|
+
ifLiquidationFee: 0,
|
|
164
|
+
protocolLiquidationFee: 0,
|
|
165
|
+
feePoolBufferTarget: new BN(0),
|
|
173
166
|
imfFactor: 0,
|
|
174
|
-
nextFundingRateRecordId: new BN(0),
|
|
175
167
|
unrealizedPnlImfFactor: 0,
|
|
176
168
|
unrealizedPnlMaxImbalance: ZERO,
|
|
177
169
|
unrealizedPnlInitialAssetWeight: 0,
|
|
@@ -186,102 +178,62 @@ export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
|
186
178
|
quoteSpotMarketIndex: 0,
|
|
187
179
|
feeAdjustment: 0,
|
|
188
180
|
pausedOperations: 0,
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
181
|
+
hedgeConfig: {
|
|
182
|
+
poolId: 0,
|
|
183
|
+
status: 0,
|
|
184
|
+
pausedOperations: 0,
|
|
185
|
+
exchangeFeeExclusionScalar: 0,
|
|
186
|
+
feeTransferScalar: 0,
|
|
187
|
+
},
|
|
194
188
|
marketConfig: 0,
|
|
189
|
+
|
|
190
|
+
// Fields migrated off AMM to top-level PerpMarket
|
|
191
|
+
oracle: PublicKey.default,
|
|
192
|
+
oracleSource: OracleSource.PYTH_LAZER,
|
|
193
|
+
oracleSlotDelayOverride: 0,
|
|
194
|
+
oracleLowRiskSlotDelayOverride: 0,
|
|
195
|
+
baseAssetAmountLong: new BN(0),
|
|
196
|
+
baseAssetAmountShort: new BN(0),
|
|
197
|
+
quoteAssetAmount: new BN(0),
|
|
198
|
+
quoteEntryAmountLong: new BN(0),
|
|
199
|
+
quoteEntryAmountShort: new BN(0),
|
|
200
|
+
quoteBreakEvenAmountLong: new BN(0),
|
|
201
|
+
quoteBreakEvenAmountShort: new BN(0),
|
|
202
|
+
totalSocialLoss: new BN(0),
|
|
203
|
+
maxOpenInterest: new BN(0),
|
|
204
|
+
cumulativeFundingRateLong: new BN(0),
|
|
205
|
+
cumulativeFundingRateShort: new BN(0),
|
|
206
|
+
lastFundingRate: new BN(0),
|
|
207
|
+
lastFundingRateLong: new BN(0),
|
|
208
|
+
lastFundingRateShort: new BN(0),
|
|
209
|
+
lastFundingRateTs: new BN(0),
|
|
210
|
+
netUnsettledFundingPnl: new BN(0),
|
|
211
|
+
orderStepSize: new BN(1),
|
|
212
|
+
orderTickSize: new BN(1),
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export const mockPerpMarkets: Array<PerpMarketAccount> = [
|
|
217
|
+
{
|
|
218
|
+
...mockPerpMarketCommon(),
|
|
219
|
+
contractTier: ContractTier.A,
|
|
220
|
+
marketIndex: 0,
|
|
221
|
+
marginRatioInitial: 2000,
|
|
222
|
+
marginRatioMaintenance: 1000,
|
|
195
223
|
},
|
|
196
224
|
{
|
|
197
|
-
|
|
198
|
-
lastFillPrice: new BN(0),
|
|
225
|
+
...mockPerpMarketCommon(),
|
|
199
226
|
contractTier: ContractTier.A,
|
|
200
|
-
nextFundingRateRecordId: new BN(0),
|
|
201
|
-
name: [],
|
|
202
|
-
contractType: ContractType.PERPETUAL,
|
|
203
|
-
expiryTs: new BN(0),
|
|
204
|
-
expiryPrice: new BN(0),
|
|
205
227
|
marketIndex: 1,
|
|
206
|
-
pubkey: PublicKey.default,
|
|
207
|
-
amm: mockAMM,
|
|
208
|
-
numberOfUsersWithBase: 0,
|
|
209
|
-
numberOfUsers: 0,
|
|
210
228
|
marginRatioInitial: 0,
|
|
211
229
|
marginRatioMaintenance: 0,
|
|
212
|
-
nextFillRecordId: new BN(0),
|
|
213
|
-
pnlPool: {
|
|
214
|
-
scaledBalance: new BN(0),
|
|
215
|
-
marketIndex: 0,
|
|
216
|
-
},
|
|
217
|
-
ifLiquidationFee: 0,
|
|
218
|
-
liquidatorFee: 0,
|
|
219
|
-
imfFactor: 0,
|
|
220
|
-
unrealizedPnlImfFactor: 0,
|
|
221
|
-
unrealizedPnlMaxImbalance: ZERO,
|
|
222
|
-
unrealizedPnlInitialAssetWeight: 0,
|
|
223
|
-
unrealizedPnlMaintenanceAssetWeight: 0,
|
|
224
|
-
insuranceClaim: {
|
|
225
|
-
revenueWithdrawSinceLastSettle: new BN(0),
|
|
226
|
-
maxRevenueWithdrawPerPeriod: new BN(0),
|
|
227
|
-
lastRevenueWithdrawTs: new BN(0),
|
|
228
|
-
quoteSettledInsurance: new BN(0),
|
|
229
|
-
quoteMaxInsurance: new BN(0),
|
|
230
|
-
},
|
|
231
|
-
quoteSpotMarketIndex: 0,
|
|
232
|
-
feeAdjustment: 0,
|
|
233
|
-
pausedOperations: 0,
|
|
234
|
-
lpPoolId: 0,
|
|
235
|
-
lpFeeTransferScalar: 0,
|
|
236
|
-
lpExchangeFeeExcluscionScalar: 0,
|
|
237
|
-
lpStatus: 0,
|
|
238
|
-
lpPausedOperations: 0,
|
|
239
|
-
marketConfig: 0,
|
|
240
230
|
},
|
|
241
231
|
{
|
|
242
|
-
|
|
243
|
-
lastFillPrice: new BN(0),
|
|
232
|
+
...mockPerpMarketCommon(),
|
|
244
233
|
contractTier: ContractTier.A,
|
|
245
|
-
nextFundingRateRecordId: new BN(0),
|
|
246
|
-
name: [],
|
|
247
|
-
contractType: ContractType.PERPETUAL,
|
|
248
|
-
expiryTs: new BN(0),
|
|
249
|
-
expiryPrice: new BN(0),
|
|
250
234
|
marketIndex: 2,
|
|
251
|
-
pubkey: PublicKey.default,
|
|
252
|
-
amm: mockAMM,
|
|
253
|
-
numberOfUsersWithBase: 0,
|
|
254
|
-
numberOfUsers: 0,
|
|
255
235
|
marginRatioInitial: 0,
|
|
256
236
|
marginRatioMaintenance: 0,
|
|
257
|
-
nextFillRecordId: new BN(0),
|
|
258
|
-
pnlPool: {
|
|
259
|
-
scaledBalance: new BN(0),
|
|
260
|
-
marketIndex: 0,
|
|
261
|
-
},
|
|
262
|
-
ifLiquidationFee: 0,
|
|
263
|
-
liquidatorFee: 0,
|
|
264
|
-
imfFactor: 0,
|
|
265
|
-
unrealizedPnlImfFactor: 0,
|
|
266
|
-
unrealizedPnlMaxImbalance: ZERO,
|
|
267
|
-
unrealizedPnlInitialAssetWeight: 0,
|
|
268
|
-
unrealizedPnlMaintenanceAssetWeight: 0,
|
|
269
|
-
insuranceClaim: {
|
|
270
|
-
revenueWithdrawSinceLastSettle: new BN(0),
|
|
271
|
-
maxRevenueWithdrawPerPeriod: new BN(0),
|
|
272
|
-
lastRevenueWithdrawTs: new BN(0),
|
|
273
|
-
quoteSettledInsurance: new BN(0),
|
|
274
|
-
quoteMaxInsurance: new BN(0),
|
|
275
|
-
},
|
|
276
|
-
quoteSpotMarketIndex: 0,
|
|
277
|
-
feeAdjustment: 0,
|
|
278
|
-
pausedOperations: 0,
|
|
279
|
-
lpPoolId: 0,
|
|
280
|
-
lpFeeTransferScalar: 0,
|
|
281
|
-
lpExchangeFeeExcluscionScalar: 0,
|
|
282
|
-
lpStatus: 0,
|
|
283
|
-
lpPausedOperations: 0,
|
|
284
|
-
marketConfig: 0,
|
|
285
237
|
},
|
|
286
238
|
];
|
|
287
239
|
|
|
@@ -309,11 +261,16 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
309
261
|
unstakingPeriod: new BN(0),
|
|
310
262
|
lastRevenueSettleTs: new BN(0),
|
|
311
263
|
revenueSettlePeriod: new BN(0),
|
|
312
|
-
|
|
313
|
-
userFactor: 0,
|
|
264
|
+
ifFeeFactor: 0,
|
|
314
265
|
},
|
|
315
266
|
ifLiquidationFee: 0,
|
|
316
267
|
liquidatorFee: 0,
|
|
268
|
+
protocolFeePool: {
|
|
269
|
+
scaledBalance: new BN(0),
|
|
270
|
+
marketIndex: 0,
|
|
271
|
+
},
|
|
272
|
+
protocolLiquidationFee: 0,
|
|
273
|
+
protocolFeeFactor: 0,
|
|
317
274
|
decimals: 6,
|
|
318
275
|
optimalUtilization: 0,
|
|
319
276
|
optimalBorrowRate: 0,
|
|
@@ -397,11 +354,16 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
397
354
|
unstakingPeriod: new BN(0),
|
|
398
355
|
lastRevenueSettleTs: new BN(0),
|
|
399
356
|
revenueSettlePeriod: new BN(0),
|
|
400
|
-
|
|
401
|
-
userFactor: 0,
|
|
357
|
+
ifFeeFactor: 0,
|
|
402
358
|
},
|
|
403
359
|
ifLiquidationFee: 0,
|
|
404
360
|
liquidatorFee: 0,
|
|
361
|
+
protocolFeePool: {
|
|
362
|
+
scaledBalance: new BN(0),
|
|
363
|
+
marketIndex: 0,
|
|
364
|
+
},
|
|
365
|
+
protocolLiquidationFee: 0,
|
|
366
|
+
protocolFeeFactor: 0,
|
|
405
367
|
decimals: 9,
|
|
406
368
|
optimalUtilization: 0,
|
|
407
369
|
optimalBorrowRate: 0,
|
|
@@ -487,11 +449,16 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
487
449
|
unstakingPeriod: new BN(0),
|
|
488
450
|
lastRevenueSettleTs: new BN(0),
|
|
489
451
|
revenueSettlePeriod: new BN(0),
|
|
490
|
-
|
|
491
|
-
userFactor: 0,
|
|
452
|
+
ifFeeFactor: 0,
|
|
492
453
|
},
|
|
493
454
|
ifLiquidationFee: 0,
|
|
494
455
|
liquidatorFee: 0,
|
|
456
|
+
protocolFeePool: {
|
|
457
|
+
scaledBalance: new BN(0),
|
|
458
|
+
marketIndex: 0,
|
|
459
|
+
},
|
|
460
|
+
protocolLiquidationFee: 0,
|
|
461
|
+
protocolFeeFactor: 0,
|
|
495
462
|
decimals: 6,
|
|
496
463
|
optimalUtilization: 0,
|
|
497
464
|
optimalBorrowRate: 0,
|
|
@@ -555,6 +522,21 @@ export const mockSpotMarkets: Array<SpotMarketAccount> = [
|
|
|
555
522
|
];
|
|
556
523
|
|
|
557
524
|
export const mockStateAccount: StateAccount = {
|
|
525
|
+
coldAdmin: PublicKey.default,
|
|
526
|
+
warmAdmin: PublicKey.default,
|
|
527
|
+
hotAmmCrank: PublicKey.default,
|
|
528
|
+
hotLpCache: PublicKey.default,
|
|
529
|
+
hotLpSwap: PublicKey.default,
|
|
530
|
+
hotLpSettle: PublicKey.default,
|
|
531
|
+
hotFeatureFlag: PublicKey.default,
|
|
532
|
+
hotFuel: PublicKey.default,
|
|
533
|
+
hotUserFlag: PublicKey.default,
|
|
534
|
+
hotVaultDeposit: PublicKey.default,
|
|
535
|
+
hotMmOracleCrank: PublicKey.default,
|
|
536
|
+
hotAmmSpreadAdjust: PublicKey.default,
|
|
537
|
+
hotFeeWithdraw: PublicKey.default,
|
|
538
|
+
protocolFeeRecipientPerp: PublicKey.default,
|
|
539
|
+
protocolFeeRecipientSpot: PublicKey.default,
|
|
558
540
|
featureBitFlags: 0,
|
|
559
541
|
defaultMarketOrderTimeInForce: 0,
|
|
560
542
|
defaultSpotAuctionDuration: 0,
|
|
@@ -599,7 +581,8 @@ export const mockStateAccount: StateAccount = {
|
|
|
599
581
|
timeBasedRewardLowerBound: new BN(0),
|
|
600
582
|
},
|
|
601
583
|
flatFillerFee: new BN(0),
|
|
602
|
-
|
|
584
|
+
ammFeeNumerator: 0,
|
|
585
|
+
ifFeeNumerator: 0,
|
|
603
586
|
},
|
|
604
587
|
settlementDuration: 0,
|
|
605
588
|
signer: PublicKey.default,
|
|
@@ -623,7 +606,8 @@ export const mockStateAccount: StateAccount = {
|
|
|
623
606
|
timeBasedRewardLowerBound: new BN(0),
|
|
624
607
|
},
|
|
625
608
|
flatFillerFee: new BN(0),
|
|
626
|
-
|
|
609
|
+
ammFeeNumerator: 0,
|
|
610
|
+
ifFeeNumerator: 0,
|
|
627
611
|
},
|
|
628
612
|
srmVault: PublicKey.default,
|
|
629
613
|
whitelistMint: PublicKey.default,
|