@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
|
@@ -222,6 +222,12 @@ describe('TransactionConfirmationManager_Polling_Tests', () => {
|
|
|
222
222
|
}
|
|
223
223
|
};
|
|
224
224
|
|
|
225
|
+
// Fake timers: the poll intervals (and the Date.now used for callTimes) must
|
|
226
|
+
// be driven deterministically. The previous real `setTimeout(1250)` wait was
|
|
227
|
+
// flaky under CI load — a slow runner let an extra 400ms poll fire (4 calls
|
|
228
|
+
// instead of 3). Ticking fake time aligns the 400ms/1200ms intervals exactly
|
|
229
|
+
// at 1200ms, so the third poll batches both signatures.
|
|
230
|
+
const clock = sinon.useFakeTimers();
|
|
225
231
|
const startTime = Date.now();
|
|
226
232
|
|
|
227
233
|
// Start both confirmation processes
|
|
@@ -238,11 +244,12 @@ describe('TransactionConfirmationManager_Polling_Tests', () => {
|
|
|
238
244
|
1200
|
|
239
245
|
);
|
|
240
246
|
|
|
241
|
-
//
|
|
242
|
-
await
|
|
247
|
+
// Advance fake time past the third 400ms interval / first 1200ms interval.
|
|
248
|
+
await clock.tickAsync(1250);
|
|
243
249
|
|
|
244
250
|
// Resolve both promises
|
|
245
251
|
await Promise.all([promise1, promise2]);
|
|
252
|
+
clock.restore();
|
|
246
253
|
|
|
247
254
|
// Check the call times and signatures
|
|
248
255
|
assert.strictEqual(callTimes.length, 3, 'Should have exactly 3 calls');
|
|
@@ -261,7 +261,7 @@ describe('getMarginCalculation snapshot', () => {
|
|
|
261
261
|
const myMockSpotMarkets = _.cloneDeep(mockSpotMarkets);
|
|
262
262
|
myMockSpotMarkets[0].oracle = new PublicKey(2);
|
|
263
263
|
myMockSpotMarkets[1].oracle = new PublicKey(5);
|
|
264
|
-
myMockPerpMarkets[0].
|
|
264
|
+
myMockPerpMarkets[0].oracle = new PublicKey(5);
|
|
265
265
|
|
|
266
266
|
// Configure perp market 0 ratios to match on-chain test
|
|
267
267
|
myMockPerpMarkets[0].marginRatioInitial = 1000; // 10%
|
package/tests/user/helpers.ts
CHANGED
|
@@ -33,7 +33,6 @@ export const mockOrder: Order = {
|
|
|
33
33
|
price: ZERO,
|
|
34
34
|
baseAssetAmount: ZERO,
|
|
35
35
|
baseAssetAmountFilled: ZERO,
|
|
36
|
-
quoteAssetAmount: ZERO,
|
|
37
36
|
quoteAssetAmountFilled: ZERO,
|
|
38
37
|
direction: PositionDirection.LONG,
|
|
39
38
|
reduceOnly: false,
|
|
@@ -120,7 +119,7 @@ export async function makeMockUser(
|
|
|
120
119
|
|
|
121
120
|
const oraclePriceMap: Record<string, number> = {};
|
|
122
121
|
for (let i = 0; i < myMockPerpMarkets.length; i++) {
|
|
123
|
-
oraclePriceMap[myMockPerpMarkets[i].
|
|
122
|
+
oraclePriceMap[myMockPerpMarkets[i].oracle.toString()] =
|
|
124
123
|
perpOraclePriceList[i] ?? 1;
|
|
125
124
|
}
|
|
126
125
|
for (let i = 0; i < myMockSpotMarkets.length; i++) {
|
|
@@ -149,7 +148,7 @@ export async function makeMockUser(
|
|
|
149
148
|
return { data, slot: 0 };
|
|
150
149
|
}
|
|
151
150
|
function getOracleDataForPerpMarket(marketIndex: number) {
|
|
152
|
-
const oracle = getMockPerpMarket(marketIndex).
|
|
151
|
+
const oracle = getMockPerpMarket(marketIndex).oracle;
|
|
153
152
|
return getMockOracle(oracle).data;
|
|
154
153
|
}
|
|
155
154
|
function getOracleDataForSpotMarket(marketIndex: number) {
|
|
@@ -160,7 +159,7 @@ export async function makeMockUser(
|
|
|
160
159
|
function getMMOracleDataForPerpMarket(
|
|
161
160
|
marketIndex: number
|
|
162
161
|
): MMOraclePriceData {
|
|
163
|
-
const oracle = getMockPerpMarket(marketIndex).
|
|
162
|
+
const oracle = getMockPerpMarket(marketIndex).oracle;
|
|
164
163
|
return {
|
|
165
164
|
price: getMockOracle(oracle).data.price,
|
|
166
165
|
slot: getMockOracle(oracle).data.slot,
|
|
@@ -237,7 +237,7 @@ describe('User margin calculations', () => {
|
|
|
237
237
|
const myMockPerpMarkets = _.cloneDeep(mockPerpMarkets);
|
|
238
238
|
const myMockSpotMarkets = _.cloneDeep(mockSpotMarkets);
|
|
239
239
|
const myMockUserAccount = _.cloneDeep(mockUserAccount);
|
|
240
|
-
myMockPerpMarkets[0].
|
|
240
|
+
myMockPerpMarkets[0].orderStepSize = BASE_PRECISION;
|
|
241
241
|
|
|
242
242
|
myMockUserAccount.spotPositions[0].marketIndex = 0;
|
|
243
243
|
myMockUserAccount.spotPositions[0].balanceType = SpotBalanceType.DEPOSIT;
|
|
@@ -276,7 +276,7 @@ describe('User margin calculations', () => {
|
|
|
276
276
|
const myMockPerpMarkets = _.cloneDeep(mockPerpMarkets);
|
|
277
277
|
const myMockSpotMarkets = _.cloneDeep(mockSpotMarkets);
|
|
278
278
|
const myMockUserAccount = _.cloneDeep(mockUserAccount);
|
|
279
|
-
myMockPerpMarkets[0].
|
|
279
|
+
myMockPerpMarkets[0].orderStepSize = BASE_PRECISION;
|
|
280
280
|
|
|
281
281
|
myMockUserAccount.perpPositions[0].marketIndex = 0;
|
|
282
282
|
myMockUserAccount.perpPositions[0].positionFlag =
|
package/tests/user/test.ts
CHANGED
|
@@ -47,7 +47,7 @@ async function makeMockUser(
|
|
|
47
47
|
// console.log(spotOraclePriceList, myMockSpotMarkets.length);
|
|
48
48
|
|
|
49
49
|
for (let i = 0; i < myMockPerpMarkets.length; i++) {
|
|
50
|
-
oraclePriceMap[myMockPerpMarkets[i].
|
|
50
|
+
oraclePriceMap[myMockPerpMarkets[i].oracle.toString()] =
|
|
51
51
|
perpOraclePriceList[i];
|
|
52
52
|
}
|
|
53
53
|
for (let i = 0; i < myMockSpotMarkets.length; i++) {
|
|
@@ -88,7 +88,7 @@ async function makeMockUser(
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
function getOracleDataForPerpMarket(marketIndex) {
|
|
91
|
-
const oracle = getMockPerpMarket(marketIndex).
|
|
91
|
+
const oracle = getMockPerpMarket(marketIndex).oracle;
|
|
92
92
|
return getMockOracle(oracle).data;
|
|
93
93
|
}
|
|
94
94
|
|
|
@@ -100,7 +100,7 @@ async function makeMockUser(
|
|
|
100
100
|
function getMMOracleDataForPerpMarket(
|
|
101
101
|
marketIndex: number
|
|
102
102
|
): MMOraclePriceData {
|
|
103
|
-
const oracle = getMockPerpMarket(marketIndex).
|
|
103
|
+
const oracle = getMockPerpMarket(marketIndex).oracle;
|
|
104
104
|
return getMockOracle(oracle).data as unknown as MMOraclePriceData;
|
|
105
105
|
}
|
|
106
106
|
|
package/tsconfig.browser.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
+
"strict": true,
|
|
3
4
|
"module": "commonjs",
|
|
4
5
|
"target": "ES2019",
|
|
5
6
|
"esModuleInterop": true,
|
|
@@ -7,8 +8,9 @@
|
|
|
7
8
|
"outDir": "./lib/browser",
|
|
8
9
|
"resolveJsonModule": true,
|
|
9
10
|
"skipLibCheck": true,
|
|
11
|
+
"types": [],
|
|
10
12
|
"paths": {
|
|
11
|
-
"@solana/web3.js": ["
|
|
13
|
+
"@solana/web3.js": ["../../node_modules/@solana/web3.js"]
|
|
12
14
|
}
|
|
13
15
|
},
|
|
14
16
|
"include": ["src"],
|
package/tsconfig.json
CHANGED
|
@@ -9,10 +9,28 @@
|
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"skipLibCheck": true,
|
|
11
11
|
"declarationMap": true,
|
|
12
|
+
// Allowlist ambient @types instead of auto-including all of them: the
|
|
13
|
+
// hoisted root node_modules/@types holds broken @types/hapi__* stubs (no
|
|
14
|
+
// index.d.ts) that otherwise break the build (TS2688). node is for src;
|
|
15
|
+
// mocha/chai are the globals the ts-node/ts-mocha test run needs.
|
|
16
|
+
"types": ["node", "mocha", "chai"],
|
|
17
|
+
// Unify every @solana/web3.js specifier (including those inside dep .d.ts
|
|
18
|
+
// like solana-bankrun, which bundles its own copy) onto the single hoisted
|
|
19
|
+
// root install, so structurally-identical types don't clash nominally.
|
|
12
20
|
"paths": {
|
|
13
|
-
"@solana/web3.js": ["
|
|
21
|
+
"@solana/web3.js": ["../../node_modules/@solana/web3.js"]
|
|
14
22
|
}
|
|
15
23
|
},
|
|
16
24
|
"include": ["src"],
|
|
17
|
-
"exclude": ["node_modules", "tests"]
|
|
25
|
+
"exclude": ["node_modules", "tests"],
|
|
26
|
+
// `strict` (added with the SDK strict-mode pass) applies to the shipped `src`
|
|
27
|
+
// build + the sdk-typecheck gate (both `exclude` tests). The mocha suites run
|
|
28
|
+
// through ts-node, which would otherwise compile the test files under strict
|
|
29
|
+
// too — and the tests aren't strict-clean (implicit-any deps, uninitialized
|
|
30
|
+
// fixture fields). Scope strict to the build, not the test run.
|
|
31
|
+
"ts-node": {
|
|
32
|
+
"compilerOptions": {
|
|
33
|
+
"strict": false
|
|
34
|
+
}
|
|
35
|
+
}
|
|
18
36
|
}
|
package/.yarn/install-state.gz
DELETED
|
Binary file
|
package/VERSION
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.163.0-beta.13
|