@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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velocity-exchange/sdk",
|
|
3
|
-
"version": "0.2.
|
|
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
|
-
"
|
|
29
|
-
"
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
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';
|
package/src/marinade/index.ts
CHANGED
|
@@ -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:
|
|
20
|
+
provider: unknown
|
|
16
21
|
): Program<MarinadeFinance> {
|
|
17
|
-
return new Program<MarinadeFinance>(
|
|
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
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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.
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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(
|