@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.
Files changed (186) hide show
  1. package/CHANGELOG.md +7 -44
  2. package/lib/browser/adminClient.d.ts +0 -1
  3. package/lib/browser/bankrun/bankrunConnection.d.ts +2 -1
  4. package/lib/browser/bankrun/bankrunConnection.js +23 -1
  5. package/lib/browser/constants/numericConstants.d.ts +2 -1
  6. package/lib/browser/constants/numericConstants.js +8 -4
  7. package/lib/browser/constants/spotMarkets.d.ts +0 -1
  8. package/lib/browser/core/VelocityCore.d.ts +0 -1
  9. package/lib/browser/core/instructions/deposit.d.ts +0 -1
  10. package/lib/browser/core/instructions/withdraw.d.ts +0 -1
  11. package/lib/browser/dlob/DLOB.d.ts +0 -1
  12. package/lib/browser/dlob/DLOBNode.d.ts +0 -1
  13. package/lib/browser/dlob/DLOBSubscriber.d.ts +0 -1
  14. package/lib/browser/dlob/NodeList.d.ts +0 -1
  15. package/lib/browser/dlob/orderBookLevels.d.ts +0 -1
  16. package/lib/browser/events/eventList.d.ts +3 -3
  17. package/lib/browser/events/eventsServerLogProvider.d.ts +1 -1
  18. package/lib/browser/events/pollingLogProvider.d.ts +1 -1
  19. package/lib/browser/events/txEventCache.d.ts +3 -3
  20. package/lib/browser/events/webSocketLogProvider.d.ts +1 -1
  21. package/lib/browser/factory/bigNum.d.ts +0 -1
  22. package/lib/browser/index.d.ts +1 -1
  23. package/lib/browser/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
  24. package/lib/browser/jupiter/jupiterClient.d.ts +0 -1
  25. package/lib/browser/marginCalculation.d.ts +0 -1
  26. package/lib/browser/marinade/index.d.ts +2 -3
  27. package/lib/browser/marinade/index.js +5 -0
  28. package/lib/browser/math/amm.d.ts +0 -1
  29. package/lib/browser/math/auction.d.ts +0 -1
  30. package/lib/browser/math/conversion.d.ts +0 -1
  31. package/lib/browser/math/funding.d.ts +0 -1
  32. package/lib/browser/math/insurance.d.ts +0 -1
  33. package/lib/browser/math/liquidation.d.ts +0 -1
  34. package/lib/browser/math/margin.d.ts +0 -1
  35. package/lib/browser/math/market.d.ts +0 -1
  36. package/lib/browser/math/oracles.d.ts +0 -1
  37. package/lib/browser/math/orders.d.ts +0 -1
  38. package/lib/browser/math/position.d.ts +1 -2
  39. package/lib/browser/math/repeg.d.ts +0 -1
  40. package/lib/browser/math/spotBalance.d.ts +0 -1
  41. package/lib/browser/math/spotMarket.d.ts +0 -1
  42. package/lib/browser/math/spotPosition.d.ts +0 -1
  43. package/lib/browser/math/state.d.ts +0 -1
  44. package/lib/browser/math/superStake.d.ts +0 -1
  45. package/lib/browser/math/trade.d.ts +2 -3
  46. package/lib/browser/math/utils.d.ts +0 -1
  47. package/lib/browser/oracles/oracleClientCache.d.ts +1 -1
  48. package/lib/browser/oracles/pythClient.d.ts +0 -1
  49. package/lib/browser/oracles/pythLazerClient.d.ts +0 -1
  50. package/lib/browser/oracles/strictOraclePrice.d.ts +0 -1
  51. package/lib/browser/oracles/types.d.ts +0 -1
  52. package/lib/browser/oracles/utils.d.ts +0 -1
  53. package/lib/browser/orderParams.d.ts +0 -1
  54. package/lib/browser/swap/UnifiedSwapClient.d.ts +0 -1
  55. package/lib/browser/titan/titanClient.d.ts +0 -1
  56. package/lib/browser/tokenFaucet.d.ts +0 -1
  57. package/lib/browser/tx/txHandler.d.ts +2 -2
  58. package/lib/browser/types.d.ts +2 -3
  59. package/lib/browser/user.d.ts +0 -1
  60. package/lib/browser/velocityClient.d.ts +1 -2
  61. package/lib/node/adminClient.d.ts +0 -1
  62. package/lib/node/adminClient.d.ts.map +1 -1
  63. package/lib/node/bankrun/bankrunConnection.d.ts +2 -1
  64. package/lib/node/bankrun/bankrunConnection.d.ts.map +1 -1
  65. package/lib/node/bankrun/bankrunConnection.js +23 -1
  66. package/lib/node/constants/numericConstants.d.ts +2 -1
  67. package/lib/node/constants/numericConstants.d.ts.map +1 -1
  68. package/lib/node/constants/numericConstants.js +8 -4
  69. package/lib/node/constants/spotMarkets.d.ts +0 -1
  70. package/lib/node/constants/spotMarkets.d.ts.map +1 -1
  71. package/lib/node/core/VelocityCore.d.ts +0 -1
  72. package/lib/node/core/VelocityCore.d.ts.map +1 -1
  73. package/lib/node/core/instructions/deposit.d.ts +0 -1
  74. package/lib/node/core/instructions/deposit.d.ts.map +1 -1
  75. package/lib/node/core/instructions/withdraw.d.ts +0 -1
  76. package/lib/node/core/instructions/withdraw.d.ts.map +1 -1
  77. package/lib/node/dlob/DLOB.d.ts +0 -1
  78. package/lib/node/dlob/DLOB.d.ts.map +1 -1
  79. package/lib/node/dlob/DLOBNode.d.ts +0 -1
  80. package/lib/node/dlob/DLOBNode.d.ts.map +1 -1
  81. package/lib/node/dlob/DLOBSubscriber.d.ts +0 -1
  82. package/lib/node/dlob/DLOBSubscriber.d.ts.map +1 -1
  83. package/lib/node/dlob/NodeList.d.ts +0 -1
  84. package/lib/node/dlob/NodeList.d.ts.map +1 -1
  85. package/lib/node/dlob/orderBookLevels.d.ts +0 -1
  86. package/lib/node/dlob/orderBookLevels.d.ts.map +1 -1
  87. package/lib/node/factory/bigNum.d.ts +0 -1
  88. package/lib/node/factory/bigNum.d.ts.map +1 -1
  89. package/lib/node/index.d.ts +1 -1
  90. package/lib/node/index.d.ts.map +1 -1
  91. package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts +0 -1
  92. package/lib/node/indicative-quotes/indicativeQuotesSender.d.ts.map +1 -1
  93. package/lib/node/jupiter/jupiterClient.d.ts +0 -1
  94. package/lib/node/jupiter/jupiterClient.d.ts.map +1 -1
  95. package/lib/node/marginCalculation.d.ts +0 -1
  96. package/lib/node/marginCalculation.d.ts.map +1 -1
  97. package/lib/node/marinade/index.d.ts +2 -3
  98. package/lib/node/marinade/index.d.ts.map +1 -1
  99. package/lib/node/marinade/index.js +5 -0
  100. package/lib/node/math/amm.d.ts +0 -1
  101. package/lib/node/math/amm.d.ts.map +1 -1
  102. package/lib/node/math/auction.d.ts +0 -1
  103. package/lib/node/math/auction.d.ts.map +1 -1
  104. package/lib/node/math/conversion.d.ts +0 -1
  105. package/lib/node/math/conversion.d.ts.map +1 -1
  106. package/lib/node/math/funding.d.ts +0 -1
  107. package/lib/node/math/funding.d.ts.map +1 -1
  108. package/lib/node/math/insurance.d.ts +0 -1
  109. package/lib/node/math/insurance.d.ts.map +1 -1
  110. package/lib/node/math/liquidation.d.ts +0 -1
  111. package/lib/node/math/liquidation.d.ts.map +1 -1
  112. package/lib/node/math/margin.d.ts +0 -1
  113. package/lib/node/math/margin.d.ts.map +1 -1
  114. package/lib/node/math/market.d.ts +0 -1
  115. package/lib/node/math/market.d.ts.map +1 -1
  116. package/lib/node/math/oracles.d.ts +0 -1
  117. package/lib/node/math/oracles.d.ts.map +1 -1
  118. package/lib/node/math/orders.d.ts +0 -1
  119. package/lib/node/math/orders.d.ts.map +1 -1
  120. package/lib/node/math/position.d.ts +0 -1
  121. package/lib/node/math/position.d.ts.map +1 -1
  122. package/lib/node/math/repeg.d.ts +0 -1
  123. package/lib/node/math/repeg.d.ts.map +1 -1
  124. package/lib/node/math/spotBalance.d.ts +0 -1
  125. package/lib/node/math/spotBalance.d.ts.map +1 -1
  126. package/lib/node/math/spotMarket.d.ts +0 -1
  127. package/lib/node/math/spotMarket.d.ts.map +1 -1
  128. package/lib/node/math/spotPosition.d.ts +0 -1
  129. package/lib/node/math/spotPosition.d.ts.map +1 -1
  130. package/lib/node/math/state.d.ts +0 -1
  131. package/lib/node/math/state.d.ts.map +1 -1
  132. package/lib/node/math/superStake.d.ts +0 -1
  133. package/lib/node/math/superStake.d.ts.map +1 -1
  134. package/lib/node/math/trade.d.ts +0 -1
  135. package/lib/node/math/trade.d.ts.map +1 -1
  136. package/lib/node/math/utils.d.ts +0 -1
  137. package/lib/node/math/utils.d.ts.map +1 -1
  138. package/lib/node/oracles/pythClient.d.ts +0 -1
  139. package/lib/node/oracles/pythClient.d.ts.map +1 -1
  140. package/lib/node/oracles/pythLazerClient.d.ts +0 -1
  141. package/lib/node/oracles/pythLazerClient.d.ts.map +1 -1
  142. package/lib/node/oracles/strictOraclePrice.d.ts +0 -1
  143. package/lib/node/oracles/strictOraclePrice.d.ts.map +1 -1
  144. package/lib/node/oracles/types.d.ts +0 -1
  145. package/lib/node/oracles/types.d.ts.map +1 -1
  146. package/lib/node/oracles/utils.d.ts +0 -1
  147. package/lib/node/oracles/utils.d.ts.map +1 -1
  148. package/lib/node/orderParams.d.ts +0 -1
  149. package/lib/node/orderParams.d.ts.map +1 -1
  150. package/lib/node/swap/UnifiedSwapClient.d.ts +0 -1
  151. package/lib/node/swap/UnifiedSwapClient.d.ts.map +1 -1
  152. package/lib/node/titan/titanClient.d.ts +0 -1
  153. package/lib/node/titan/titanClient.d.ts.map +1 -1
  154. package/lib/node/tokenFaucet.d.ts +0 -1
  155. package/lib/node/tokenFaucet.d.ts.map +1 -1
  156. package/lib/node/types.d.ts +0 -1
  157. package/lib/node/types.d.ts.map +1 -1
  158. package/lib/node/user.d.ts +0 -1
  159. package/lib/node/user.d.ts.map +1 -1
  160. package/lib/node/velocityClient.d.ts +0 -1
  161. package/lib/node/velocityClient.d.ts.map +1 -1
  162. package/package.json +16 -11
  163. package/src/bankrun/bankrunConnection.ts +27 -1
  164. package/src/constants/numericConstants.ts +6 -2
  165. package/src/index.ts +5 -1
  166. package/src/marinade/index.ts +11 -2
  167. package/src/userMap/referrerMap.ts +1 -1
  168. package/src/userMap/revenueShareEscrowMap.ts +2 -2
  169. package/tests/VelocityCore/remainingAccounts.test.ts +4 -5
  170. package/tests/accounts/customizedCadenceBulkAccountLoader.test.ts +19 -11
  171. package/tests/amm/test.ts +162 -95
  172. package/tests/decode/userAccountBufferStrings.ts +100 -100
  173. package/tests/dlob/helpers.ts +156 -172
  174. package/tests/dlob/test.ts +155 -106
  175. package/tests/tx/TransactionConfirmationManager.test.ts +9 -2
  176. package/tests/user/getMarginCalculation.ts +1 -1
  177. package/tests/user/helpers.ts +3 -4
  178. package/tests/user/marginCalculations.test.ts +2 -2
  179. package/tests/user/test.ts +3 -3
  180. package/tsconfig.browser.json +3 -1
  181. package/tsconfig.json +20 -2
  182. package/.yarn/install-state.gz +0 -0
  183. package/VERSION +0 -1
  184. package/bun.lock +0 -1907
  185. package/scripts/updateVersion.js +0 -28
  186. package/tests/decode/phoenix.ts +0 -71
@@ -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
- totalExchangeFee: new BN(0),
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
- netRevenueSinceLastFunding: new BN(0),
70
+ totalFeeMinusDistributions: new BN(0),
71
+ totalFeeWithdrawn: new BN(0),
107
72
  lastUpdateSlot: new BN(0),
108
- lastOracleValid: true,
109
- lastBidPriceTwap: new BN(0),
110
- lastAskPriceTwap: new BN(0),
111
- longSpread: 0,
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
- maxBaseAssetReserve: new BN(0),
116
- minBaseAssetReserve: new BN(0),
117
- totalSocialLoss: new BN(0),
118
-
119
- quoteBreakEvenAmountLong: new BN(0),
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
- volume24H: new BN(0),
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
- oracleSlotDelayOverride: 0,
147
- referencePriceOffsetDeadbandPct: 0,
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
- export const mockPerpMarkets: Array<PerpMarketAccount> = [
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
- ifLiquidationFee: 0,
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
- lpPoolId: 0,
190
- lpFeeTransferScalar: 0,
191
- lpExchangeFeeExcluscionScalar: 0,
192
- lpStatus: 0,
193
- lpPausedOperations: 0,
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
- status: MarketStatus.INITIALIZED,
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
- status: MarketStatus.INITIALIZED,
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
- totalFactor: 0,
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
- totalFactor: 0,
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
- totalFactor: 0,
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
- referrerRewardEpochUpperBound: new BN(0),
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
- referrerRewardEpochUpperBound: new BN(0),
609
+ ammFeeNumerator: 0,
610
+ ifFeeNumerator: 0,
627
611
  },
628
612
  srmVault: PublicKey.default,
629
613
  whitelistMint: PublicKey.default,