@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@velocity-exchange/sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "module": "./lib/browser/index.js",
@@ -14,19 +14,18 @@
14
14
  "build:browser": "bun run clean && tsc -p tsconfig.json && tsc -p tsconfig.browser.json && node scripts/postbuild.js --force-env browser",
15
15
  "build:minify": "node build-browser.js",
16
16
  "clean": "rm -rf lib",
17
- "test": "mocha -r ts-node/register tests/**/*.ts --ignore 'tests/dlob/**/*.ts'",
18
- "test:match": "mocha -r ts-node/register --ignore 'tests/dlob/**/*.ts'",
17
+ "test": "mocha -r ts-node/register tests/**/*.ts --ignore 'tests/dlob/**/*.ts' --ignore 'tests/VelocityCore/**/*.ts' --ignore 'tests/ci/**/*.ts'",
18
+ "test:match": "mocha -r ts-node/register --ignore 'tests/dlob/**/*.ts' --ignore 'tests/VelocityCore/**/*.ts' --ignore 'tests/ci/**/*.ts'",
19
19
  "test:inspect": "mocha --inspect-brk -r ts-node/register tests/**/*.ts",
20
20
  "test:bignum": "mocha -r ts-node/register tests/bn/**/*.ts",
21
21
  "test:ci": "mocha -r ts-node/register tests/ci/**/*.ts",
22
22
  "test:dlob": "mocha -r ts-node/register tests/dlob/**/*.ts",
23
23
  "test:events": "mocha -r ts-node/register tests/events/**/*.ts",
24
24
  "test:velocitycore": "bun test tests/VelocityCore",
25
- "patch-and-pub": "npm version patch --force && npm publish",
26
25
  "prettify": "prettier --check './src/**/*.ts'",
27
26
  "prettify:fix": "prettier --write './{src,tests}/**/*.ts'",
28
- "version": "node ./scripts/updateVersion.js",
29
- "circular-deps": "bunx madge --circular --circular --extensions ts src"
27
+ "circular-deps": "bunx madge --circular --circular --extensions ts src",
28
+ "typecheck": "tsc --noEmit"
30
29
  },
31
30
  "keywords": [
32
31
  "velocity-exchange",
@@ -47,17 +46,21 @@
47
46
  "@coral-xyz/anchor": "npm:@anchor-lang/core@1.0.1",
48
47
  "@coral-xyz/anchor-29": "npm:@coral-xyz/anchor@0.29.0",
49
48
  "@msgpack/msgpack": "3.1.2",
49
+ "@noble/hashes": "1.7.1",
50
+ "@solana/buffer-layout": "4.0.1",
51
+ "node-fetch": "2.7.0",
52
+ "ws": "8.18.1",
50
53
  "@pythnetwork/client": "2.5.3",
51
54
  "@pythnetwork/price-service-sdk": "1.7.1",
52
55
  "@pythnetwork/pyth-lazer-sdk": "6.0.0",
53
56
  "@solana/spl-token": "0.4.13",
54
57
  "@solana/web3.js": "1.98.0",
55
58
  "@triton-one/yellowstone-grpc": "5.0.5",
59
+ "bs58": "4.0.1",
56
60
  "anchor-bankrun": "0.5.0",
57
61
  "gill": "0.10.2",
58
62
  "nanoid": "3.3.4",
59
63
  "node-cache": "5.1.2",
60
- "node-fetch": "2.6.11",
61
64
  "solana-bankrun": "0.4.0",
62
65
  "strict-event-emitter-types": "2.0.0",
63
66
  "tweetnacl": "1.0.3",
@@ -65,7 +68,8 @@
65
68
  "uuid": "8.3.2",
66
69
  "yargs": "17.7.2",
67
70
  "zod": "4.0.17",
68
- "zstddec": "0.1.0"
71
+ "zstddec": "0.1.0",
72
+ "bn.js": "^5.2.0"
69
73
  },
70
74
  "optionalDependencies": {
71
75
  "helius-laserstream": "0.1.8"
@@ -78,6 +82,8 @@
78
82
  "@types/jest": "28.1.8",
79
83
  "@types/mocha": "9.1.1",
80
84
  "@types/node-fetch": "2.6.11",
85
+ "@types/uuid": "8.3.4",
86
+ "@types/ws": "8.18.1",
81
87
  "@typescript-eslint/eslint-plugin": "6.21.0",
82
88
  "@typescript-eslint/parser": "6.21.0",
83
89
  "chai": "4.5.0",
@@ -99,7 +105,8 @@
99
105
  "stream-browserify": "3.0.0",
100
106
  "ts-node": "10.9.2",
101
107
  "typescript": "5.4.5",
102
- "vm-browserify": "1.1.2"
108
+ "vm-browserify": "1.1.2",
109
+ "@types/node": "24.0.0"
103
110
  },
104
111
  "description": "SDK for Velocity Protocol",
105
112
  "engines": {
@@ -107,8 +114,6 @@
107
114
  },
108
115
  "resolutions": {
109
116
  "@solana/web3.js": "1.98.0",
110
- "@solana/errors": "2.0.0-preview.4",
111
- "@solana/codecs-data-structures": "2.0.0-preview.4",
112
117
  "chalk": "4.1.2",
113
118
  "debug": "<4.4.2",
114
119
  "ansi-styles": "4.3.0",
@@ -204,6 +204,22 @@ export class BankrunConnection {
204
204
  return unpackAccount(publicKey, info, info.owner);
205
205
  }
206
206
 
207
+ // Mirrors the drift-vaults bankrun helper: returns the decoded SPL token
208
+ // Account (with .amount), not web3.js's { value: { amount } } shape. The
209
+ // vaults tests read `.amount` off the result directly.
210
+ async getTokenAccountBalance(
211
+ publicKey: PublicKey,
212
+ _commitment?: Commitment
213
+ ): Promise<Account> {
214
+ return this.getTokenAccount(publicKey);
215
+ }
216
+
217
+ // SOL lamport balance, straight off the BanksClient. Returns a bigint like
218
+ // the drift-vaults bankrun helper (callers wrap with Number()).
219
+ async getBalance(publicKey: PublicKey): Promise<bigint> {
220
+ return this._banksClient.getBalance(publicKey);
221
+ }
222
+
207
223
  async getMultipleAccountsInfo(
208
224
  publicKeys: PublicKey[],
209
225
  _commitmentOrConfig?: Commitment
@@ -236,7 +252,17 @@ export class BankrunConnection {
236
252
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
237
253
  _options?: any
238
254
  ): Promise<TransactionSignature> {
239
- const tx = Transaction.from(rawTransaction);
255
+ // Raw bytes may encode either a legacy or a versioned (v0) transaction.
256
+ // sendTransaction handles both, but they must be deserialized with the
257
+ // matching type: legacy parses with Transaction.from, versioned needs
258
+ // VersionedTransaction.deserialize. Versioned-tx clients (e.g. the vaults
259
+ // VaultClient) always send v0, so fall back when the legacy parse throws.
260
+ let tx: Transaction | VersionedTransaction;
261
+ try {
262
+ tx = Transaction.from(rawTransaction);
263
+ } catch (e) {
264
+ tx = VersionedTransaction.deserialize(rawTransaction as Uint8Array);
265
+ }
240
266
  const signature = await this.sendTransaction(tx);
241
267
  return signature;
242
268
  }
@@ -1,6 +1,5 @@
1
1
  import { LAMPORTS_PER_SOL } from '@solana/web3.js';
2
2
  import { BN } from '../isomorphic/anchor';
3
- import { BigNum } from '../factory/bigNum';
4
3
 
5
4
  export const ZERO = new BN(0);
6
5
  export const ONE = new BN(1);
@@ -15,6 +14,7 @@ export const NINE = new BN(9);
15
14
  export const TEN = new BN(10);
16
15
  export const TEN_THOUSAND = new BN(10000);
17
16
  export const BN_MAX = new BN(Number.MAX_SAFE_INTEGER);
17
+ export const TEN_MILLION = TEN_THOUSAND.mul(TEN_THOUSAND);
18
18
 
19
19
  export const MAX_LEVERAGE = new BN(5);
20
20
  export const MAX_LEVERAGE_ORDER_SIZE = new BN('18446744073709551615');
@@ -116,4 +116,8 @@ export const DUST_POSITION_SIZE = QUOTE_PRECISION.divn(100); // Dust position is
116
116
  export const GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
117
117
 
118
118
  // integer constants
119
- export const MIN_I64 = BigNum.fromPrint('-9223372036854775808').val;
119
+ // Built with `BN` directly (not `BigNum.fromPrint`) to avoid a module-load
120
+ // circular dependency: `bigNum.ts` imports `ZERO` from this file, so importing
121
+ // `bigNum.ts` first leaves `BigNum` undefined while this module body evaluates.
122
+ export const MAX_I64 = new BN('9223372036854775807');
123
+ export const MIN_I64 = new BN('-9223372036854775808');
package/src/index.ts CHANGED
@@ -44,7 +44,11 @@ export * from './accounts/types';
44
44
  export * from './addresses/pda';
45
45
  export * from './adminClient';
46
46
  export * from './assert/assert';
47
- export { PythLazerSubscriber, type PythLazerPriceFeedArray } from './pyth';
47
+ export {
48
+ PythLazerSubscriber,
49
+ type PythLazerPriceFeedArray,
50
+ type PriceUpdateAccount,
51
+ } from './pyth';
48
52
  export * from './testClient';
49
53
  export * from './user';
50
54
  export * from './userConfig';
@@ -11,10 +11,19 @@ const marinadeFinanceProgramId = new PublicKey(
11
11
  'MarBmsSgKXdrN1egZf5sqe1TMai9K1rChYNDJgjq7aD'
12
12
  );
13
13
 
14
+ // The Marinade SDK is built against anchor 0.29 (3-arg `new Program`), so the
15
+ // provider is typed against the anchor29 shim. Callers hold an anchor 1.0
16
+ // AnchorProvider, which is runtime-compatible but nominally distinct — accept it
17
+ // loosely and narrow at the construction boundary rather than leaking the cast to
18
+ // every call site.
14
19
  export function getMarinadeFinanceProgram(
15
- provider: AnchorProvider
20
+ provider: unknown
16
21
  ): Program<MarinadeFinance> {
17
- return new Program<MarinadeFinance>(IDL, marinadeFinanceProgramId, provider);
22
+ return new Program<MarinadeFinance>(
23
+ IDL,
24
+ marinadeFinanceProgramId,
25
+ provider as AnchorProvider
26
+ );
18
27
  }
19
28
 
20
29
  export function getMarinadeDepositIx({
@@ -252,7 +252,7 @@ export class ReferrerMap {
252
252
  // @ts-ignore
253
253
  const buffer = Buffer.from(
254
254
  programAccount.account.data[0],
255
- programAccount.account.data[1]
255
+ programAccount.account.data[1] as BufferEncoding
256
256
  );
257
257
  const authority = bs58.encode(buffer.subarray(8, 40));
258
258
  const referrer = bs58.encode(buffer.subarray(40, 72));
@@ -183,7 +183,7 @@ export class RevenueShareEscrowMap {
183
183
  // @ts-ignore
184
184
  const buffer = Buffer.from(
185
185
  programAccount.account.data[0],
186
- programAccount.account.data[1]
186
+ programAccount.account.data[1] as BufferEncoding
187
187
  );
188
188
 
189
189
  const escrow = (
@@ -210,7 +210,7 @@ export class RevenueShareEscrowMap {
210
210
  // @ts-ignore
211
211
  const buffer = Buffer.from(
212
212
  programAccount.account.data[0],
213
- programAccount.account.data[1]
213
+ programAccount.account.data[1] as BufferEncoding
214
214
  );
215
215
 
216
216
  const escrow = (
@@ -19,10 +19,9 @@ describe('VelocityCore.remainingAccounts', () => {
19
19
  const perpMarket0 = {
20
20
  pubkey: Keypair.generate().publicKey,
21
21
  quoteSpotMarketIndex: 0,
22
- amm: {
23
- oracle: Keypair.generate().publicKey,
24
- oracleSource: { prelaunch: {} },
25
- },
22
+ oracle: Keypair.generate().publicKey,
23
+ oracleSource: { prelaunch: {} },
24
+ amm: {},
26
25
  } as any;
27
26
 
28
27
  const user: UserAccount = {
@@ -68,6 +67,6 @@ describe('VelocityCore.remainingAccounts', () => {
68
67
 
69
68
  const keys = new Set(metas.map((m) => m.pubkey.toBase58()));
70
69
  expect(keys.has(perpMarket0.pubkey.toBase58())).toBe(true);
71
- expect(keys.has(perpMarket0.amm.oracle.toBase58())).toBe(true);
70
+ expect(keys.has(perpMarket0.oracle.toBase58())).toBe(true);
72
71
  });
73
72
  });
@@ -9,22 +9,30 @@ describe('CustomizedCadenceBulkAccountLoader', () => {
9
9
 
10
10
  beforeEach(() => {
11
11
  connection = {
12
- _rpcBatchRequest: async () => {
13
- return Promise.resolve([
14
- {
15
- result: {
16
- context: { slot: 1 },
17
- value: Array(10)
18
- .fill(null)
19
- .map(() => ({
12
+ // Return one response per batched getMultipleAccounts request, each with a
13
+ // `value` entry for every pubkey actually requested (not a hard-coded 10), so
14
+ // all registered accounts get data. Fresh random buffers per call ensure each
15
+ // poll differs, so repeat polls re-fire callbacks (the loader skips unchanged
16
+ // buffers).
17
+ _rpcBatchRequest: async (
18
+ requests: Array<{ methodName: string; args: any[] }>
19
+ ) => {
20
+ return Promise.resolve(
21
+ requests.map((request) => {
22
+ const pubkeys: string[] = request.args?.[0] ?? [];
23
+ return {
24
+ result: {
25
+ context: { slot: 1 },
26
+ value: pubkeys.map(() => ({
20
27
  data: [
21
28
  Buffer.from(Math.random().toString()).toString('base64'),
22
29
  'base64',
23
30
  ],
24
31
  })),
25
- },
26
- },
27
- ]);
32
+ },
33
+ };
34
+ })
35
+ );
28
36
  },
29
37
  } as unknown as Connection;
30
38
  loader = new CustomizedCadenceBulkAccountLoader(