@drift-labs/sdk 2.37.1-beta.1 → 2.37.1-beta.3
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/VERSION +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/tx/baseTxSender.d.ts +30 -0
- package/lib/tx/baseTxSender.js +176 -0
- package/lib/tx/fastSingleTxSender.d.ts +27 -0
- package/lib/tx/fastSingleTxSender.js +83 -0
- package/lib/tx/retryTxSender.d.ts +5 -14
- package/lib/tx/retryTxSender.js +7 -158
- package/lib/user.d.ts +6 -0
- package/lib/user.js +69 -52
- package/package.json +2 -2
- package/src/index.ts +1 -0
- package/src/marinade/types.ts +70 -70
- package/src/tx/baseTxSender.ts +276 -0
- package/src/tx/fastSingleTxSender.ts +142 -0
- package/src/tx/retryTxSender.ts +9 -235
- package/src/user.ts +132 -91
- package/tests/amm/test.ts +83 -39
- package/tests/dlob/test.ts +19 -17
package/src/user.ts
CHANGED
|
@@ -1196,116 +1196,157 @@ export class User {
|
|
|
1196
1196
|
return health;
|
|
1197
1197
|
}
|
|
1198
1198
|
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
* @returns : Precision QUOTE_PRECISION
|
|
1202
|
-
*/
|
|
1203
|
-
getTotalPerpPositionValue(
|
|
1199
|
+
calculateWeightedPerpPositionValue(
|
|
1200
|
+
perpPosition: PerpPosition,
|
|
1204
1201
|
marginCategory?: MarginCategory,
|
|
1205
1202
|
liquidationBuffer?: BN,
|
|
1206
1203
|
includeOpenOrders?: boolean,
|
|
1207
1204
|
strict = false
|
|
1208
1205
|
): BN {
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
perpPosition.marketIndex
|
|
1213
|
-
);
|
|
1206
|
+
const market = this.driftClient.getPerpMarketAccount(
|
|
1207
|
+
perpPosition.marketIndex
|
|
1208
|
+
);
|
|
1214
1209
|
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1210
|
+
if (perpPosition.lpShares.gt(ZERO)) {
|
|
1211
|
+
// is an lp, clone so we dont mutate the position
|
|
1212
|
+
perpPosition = this.getPerpPositionWithLPSettle(
|
|
1213
|
+
market.marketIndex,
|
|
1214
|
+
this.getClonedPosition(perpPosition),
|
|
1215
|
+
!!marginCategory
|
|
1216
|
+
)[0];
|
|
1217
|
+
}
|
|
1223
1218
|
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1219
|
+
let valuationPrice = this.getOracleDataForPerpMarket(
|
|
1220
|
+
market.marketIndex
|
|
1221
|
+
).price;
|
|
1227
1222
|
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1223
|
+
if (isVariant(market.status, 'settlement')) {
|
|
1224
|
+
valuationPrice = market.expiryPrice;
|
|
1225
|
+
}
|
|
1231
1226
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1227
|
+
const baseAssetAmount = includeOpenOrders
|
|
1228
|
+
? calculateWorstCaseBaseAssetAmount(perpPosition)
|
|
1229
|
+
: perpPosition.baseAssetAmount;
|
|
1235
1230
|
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
if (marginCategory) {
|
|
1242
|
-
let marginRatio = new BN(
|
|
1243
|
-
calculateMarketMarginRatio(
|
|
1244
|
-
market,
|
|
1245
|
-
baseAssetAmount.abs(),
|
|
1246
|
-
marginCategory
|
|
1247
|
-
)
|
|
1248
|
-
);
|
|
1231
|
+
let baseAssetValue = baseAssetAmount
|
|
1232
|
+
.abs()
|
|
1233
|
+
.mul(valuationPrice)
|
|
1234
|
+
.div(AMM_TO_QUOTE_PRECISION_RATIO.mul(PRICE_PRECISION));
|
|
1249
1235
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1236
|
+
if (marginCategory) {
|
|
1237
|
+
let marginRatio = new BN(
|
|
1238
|
+
calculateMarketMarginRatio(
|
|
1239
|
+
market,
|
|
1240
|
+
baseAssetAmount.abs(),
|
|
1241
|
+
marginCategory
|
|
1242
|
+
)
|
|
1243
|
+
);
|
|
1256
1244
|
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1245
|
+
if (marginCategory === 'Initial') {
|
|
1246
|
+
marginRatio = BN.max(
|
|
1247
|
+
marginRatio,
|
|
1248
|
+
new BN(this.getUserAccount().maxMarginRatio)
|
|
1249
|
+
);
|
|
1250
|
+
}
|
|
1260
1251
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1252
|
+
if (liquidationBuffer !== undefined) {
|
|
1253
|
+
marginRatio = marginRatio.add(liquidationBuffer);
|
|
1254
|
+
}
|
|
1264
1255
|
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1256
|
+
if (isVariant(market.status, 'settlement')) {
|
|
1257
|
+
marginRatio = ZERO;
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
const quoteSpotMarket = this.driftClient.getSpotMarketAccount(
|
|
1261
|
+
market.quoteSpotMarketIndex
|
|
1262
|
+
);
|
|
1263
|
+
const quoteOraclePriceData = this.driftClient.getOraclePriceDataAndSlot(
|
|
1264
|
+
quoteSpotMarket.oracle
|
|
1265
|
+
).data;
|
|
1266
|
+
|
|
1267
|
+
let quotePrice;
|
|
1268
|
+
if (strict) {
|
|
1269
|
+
quotePrice = BN.max(
|
|
1270
|
+
quoteOraclePriceData.price,
|
|
1271
|
+
quoteSpotMarket.historicalOracleData.lastOraclePriceTwap5Min
|
|
1272
|
+
);
|
|
1273
|
+
} else {
|
|
1274
|
+
quotePrice = quoteOraclePriceData.price;
|
|
1275
|
+
}
|
|
1282
1276
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1277
|
+
baseAssetValue = baseAssetValue
|
|
1278
|
+
.mul(quotePrice)
|
|
1279
|
+
.div(PRICE_PRECISION)
|
|
1280
|
+
.mul(marginRatio)
|
|
1281
|
+
.div(MARGIN_PRECISION);
|
|
1288
1282
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1283
|
+
if (includeOpenOrders) {
|
|
1284
|
+
baseAssetValue = baseAssetValue.add(
|
|
1285
|
+
new BN(perpPosition.openOrders).mul(OPEN_ORDER_MARGIN_REQUIREMENT)
|
|
1286
|
+
);
|
|
1293
1287
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
}
|
|
1306
|
-
}
|
|
1288
|
+
if (perpPosition.lpShares.gt(ZERO)) {
|
|
1289
|
+
baseAssetValue = baseAssetValue.add(
|
|
1290
|
+
BN.max(
|
|
1291
|
+
QUOTE_PRECISION,
|
|
1292
|
+
valuationPrice
|
|
1293
|
+
.mul(market.amm.orderStepSize)
|
|
1294
|
+
.mul(QUOTE_PRECISION)
|
|
1295
|
+
.div(AMM_RESERVE_PRECISION)
|
|
1296
|
+
.div(PRICE_PRECISION)
|
|
1297
|
+
)
|
|
1298
|
+
);
|
|
1307
1299
|
}
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
return baseAssetValue;
|
|
1304
|
+
}
|
|
1308
1305
|
|
|
1306
|
+
/**
|
|
1307
|
+
* calculates position value of a single perp market in margin system
|
|
1308
|
+
* @returns : Precision QUOTE_PRECISION
|
|
1309
|
+
*/
|
|
1310
|
+
public getPerpMarketLiabilityValue(
|
|
1311
|
+
marketIndex: number,
|
|
1312
|
+
marginCategory?: MarginCategory,
|
|
1313
|
+
liquidationBuffer?: BN,
|
|
1314
|
+
includeOpenOrders?: boolean,
|
|
1315
|
+
strict = false
|
|
1316
|
+
): BN {
|
|
1317
|
+
const perpPosition = this.getPerpPosition(marketIndex);
|
|
1318
|
+
if (!perpPosition) {
|
|
1319
|
+
return ZERO;
|
|
1320
|
+
} else {
|
|
1321
|
+
return this.calculateWeightedPerpPositionValue(
|
|
1322
|
+
perpPosition,
|
|
1323
|
+
marginCategory,
|
|
1324
|
+
liquidationBuffer,
|
|
1325
|
+
includeOpenOrders,
|
|
1326
|
+
strict
|
|
1327
|
+
);
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
|
|
1331
|
+
/**
|
|
1332
|
+
* calculates sum of position value across all positions in margin system
|
|
1333
|
+
* @returns : Precision QUOTE_PRECISION
|
|
1334
|
+
*/
|
|
1335
|
+
getTotalPerpPositionValue(
|
|
1336
|
+
marginCategory?: MarginCategory,
|
|
1337
|
+
liquidationBuffer?: BN,
|
|
1338
|
+
includeOpenOrders?: boolean,
|
|
1339
|
+
strict = false
|
|
1340
|
+
): BN {
|
|
1341
|
+
return this.getActivePerpPositions().reduce(
|
|
1342
|
+
(totalPerpValue, perpPosition) => {
|
|
1343
|
+
const baseAssetValue = this.calculateWeightedPerpPositionValue(
|
|
1344
|
+
perpPosition,
|
|
1345
|
+
marginCategory,
|
|
1346
|
+
liquidationBuffer,
|
|
1347
|
+
includeOpenOrders,
|
|
1348
|
+
strict
|
|
1349
|
+
);
|
|
1309
1350
|
return totalPerpValue.add(baseAssetValue);
|
|
1310
1351
|
},
|
|
1311
1352
|
ZERO
|
package/tests/amm/test.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
calculateInventoryScale,
|
|
13
13
|
calculateAllEstimatedFundingRate,
|
|
14
14
|
calculateLongShortFundingRateAndLiveTwaps,
|
|
15
|
-
OraclePriceData
|
|
15
|
+
OraclePriceData,
|
|
16
16
|
} from '../../src';
|
|
17
17
|
import { mockPerpMarkets } from '../dlob/helpers';
|
|
18
18
|
|
|
@@ -408,33 +408,51 @@ describe('AMM Tests', () => {
|
|
|
408
408
|
confidence: new BN(1),
|
|
409
409
|
hasSufficientNumberOfDataPoints: true,
|
|
410
410
|
};
|
|
411
|
-
mockMarket1.amm.historicalOracleData.lastOraclePrice = new BN(
|
|
411
|
+
mockMarket1.amm.historicalOracleData.lastOraclePrice = new BN(
|
|
412
|
+
1.9535 * PRICE_PRECISION.toNumber()
|
|
413
|
+
);
|
|
412
414
|
|
|
413
415
|
// mockMarket1.amm.pegMultiplier = new BN(1.897573 * 1e3);
|
|
414
416
|
|
|
415
|
-
mockMarket1.amm.lastMarkPriceTwap = new BN(
|
|
416
|
-
|
|
417
|
-
|
|
417
|
+
mockMarket1.amm.lastMarkPriceTwap = new BN(
|
|
418
|
+
1.945594 * PRICE_PRECISION.toNumber()
|
|
419
|
+
);
|
|
420
|
+
mockMarket1.amm.lastBidPriceTwap = new BN(
|
|
421
|
+
1.941629 * PRICE_PRECISION.toNumber()
|
|
422
|
+
);
|
|
423
|
+
mockMarket1.amm.lastAskPriceTwap = new BN(
|
|
424
|
+
1.94956 * PRICE_PRECISION.toNumber()
|
|
425
|
+
);
|
|
418
426
|
mockMarket1.amm.lastMarkPriceTwapTs = new BN(1688877729);
|
|
419
427
|
|
|
420
|
-
mockMarket1.amm.historicalOracleData.lastOraclePriceTwap = new BN(
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
oraclePriceData,
|
|
427
|
-
currentMarkPrice,
|
|
428
|
-
now
|
|
429
|
-
);
|
|
428
|
+
mockMarket1.amm.historicalOracleData.lastOraclePriceTwap = new BN(
|
|
429
|
+
1.942449 * PRICE_PRECISION.toNumber()
|
|
430
|
+
);
|
|
431
|
+
mockMarket1.amm.historicalOracleData.lastOraclePriceTwapTs = new BN(
|
|
432
|
+
1688878333
|
|
433
|
+
);
|
|
430
434
|
|
|
431
|
-
const [
|
|
435
|
+
const [
|
|
436
|
+
_markTwapLive,
|
|
437
|
+
_oracleTwapLive,
|
|
438
|
+
_lowerboundEst,
|
|
439
|
+
_cappedAltEst,
|
|
440
|
+
_interpEst,
|
|
441
|
+
] = await calculateAllEstimatedFundingRate(
|
|
432
442
|
mockMarket1,
|
|
433
443
|
oraclePriceData,
|
|
434
444
|
currentMarkPrice,
|
|
435
445
|
now
|
|
436
446
|
);
|
|
437
447
|
|
|
448
|
+
const [markTwapLive, oracleTwapLive, est1, est2] =
|
|
449
|
+
await calculateLongShortFundingRateAndLiveTwaps(
|
|
450
|
+
mockMarket1,
|
|
451
|
+
oraclePriceData,
|
|
452
|
+
currentMarkPrice,
|
|
453
|
+
now
|
|
454
|
+
);
|
|
455
|
+
|
|
438
456
|
// console.log(markTwapLive.toString());
|
|
439
457
|
// console.log(oracleTwapLive.toString());
|
|
440
458
|
// console.log(est1.toString());
|
|
@@ -444,7 +462,6 @@ describe('AMM Tests', () => {
|
|
|
444
462
|
assert(oracleTwapLive.eq(new BN('1942510')));
|
|
445
463
|
assert(est1.eq(new BN('15692')));
|
|
446
464
|
assert(est2.eq(new BN('15692')));
|
|
447
|
-
|
|
448
465
|
});
|
|
449
466
|
|
|
450
467
|
it('predicted funding rate mock2', async () => {
|
|
@@ -464,25 +481,42 @@ describe('AMM Tests', () => {
|
|
|
464
481
|
confidence: new BN(1),
|
|
465
482
|
hasSufficientNumberOfDataPoints: true,
|
|
466
483
|
};
|
|
467
|
-
mockMarket1.amm.historicalOracleData.lastOraclePrice = new BN(
|
|
484
|
+
mockMarket1.amm.historicalOracleData.lastOraclePrice = new BN(
|
|
485
|
+
1.9535 * PRICE_PRECISION.toNumber()
|
|
486
|
+
);
|
|
468
487
|
|
|
469
488
|
// mockMarket1.amm.pegMultiplier = new BN(1.897573 * 1e3);
|
|
470
489
|
|
|
471
|
-
mockMarket1.amm.lastMarkPriceTwap = new BN(
|
|
472
|
-
|
|
473
|
-
|
|
490
|
+
mockMarket1.amm.lastMarkPriceTwap = new BN(
|
|
491
|
+
1.218363 * PRICE_PRECISION.toNumber()
|
|
492
|
+
);
|
|
493
|
+
mockMarket1.amm.lastBidPriceTwap = new BN(
|
|
494
|
+
1.218363 * PRICE_PRECISION.toNumber()
|
|
495
|
+
);
|
|
496
|
+
mockMarket1.amm.lastAskPriceTwap = new BN(
|
|
497
|
+
1.218364 * PRICE_PRECISION.toNumber()
|
|
498
|
+
);
|
|
474
499
|
mockMarket1.amm.lastMarkPriceTwapTs = new BN(1688878815);
|
|
475
500
|
|
|
476
|
-
mockMarket1.amm.historicalOracleData.lastOraclePriceTwap = new BN(
|
|
477
|
-
|
|
501
|
+
mockMarket1.amm.historicalOracleData.lastOraclePriceTwap = new BN(
|
|
502
|
+
1.220964 * PRICE_PRECISION.toNumber()
|
|
503
|
+
);
|
|
504
|
+
mockMarket1.amm.historicalOracleData.lastOraclePriceTwapTs = new BN(
|
|
505
|
+
1688879991
|
|
506
|
+
);
|
|
478
507
|
|
|
479
|
-
const [
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
508
|
+
const [
|
|
509
|
+
_markTwapLive,
|
|
510
|
+
_oracleTwapLive,
|
|
511
|
+
_lowerboundEst,
|
|
512
|
+
_cappedAltEst,
|
|
513
|
+
_interpEst,
|
|
514
|
+
] = await calculateAllEstimatedFundingRate(
|
|
515
|
+
mockMarket1,
|
|
516
|
+
oraclePriceData,
|
|
517
|
+
currentMarkPrice,
|
|
518
|
+
now
|
|
519
|
+
);
|
|
486
520
|
|
|
487
521
|
// console.log(_markTwapLive.toString());
|
|
488
522
|
// console.log(_oracleTwapLive.toString());
|
|
@@ -491,21 +525,31 @@ describe('AMM Tests', () => {
|
|
|
491
525
|
// console.log(_interpEst.toString());
|
|
492
526
|
// console.log('-----');
|
|
493
527
|
|
|
494
|
-
const [markTwapLive, oracleTwapLive, est1, est2] =
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
528
|
+
const [markTwapLive, oracleTwapLive, est1, est2] =
|
|
529
|
+
await calculateLongShortFundingRateAndLiveTwaps(
|
|
530
|
+
mockMarket1,
|
|
531
|
+
oraclePriceData,
|
|
532
|
+
currentMarkPrice,
|
|
533
|
+
now
|
|
534
|
+
);
|
|
500
535
|
|
|
501
|
-
console.log(
|
|
502
|
-
|
|
536
|
+
console.log(
|
|
537
|
+
'markTwapLive:',
|
|
538
|
+
mockMarket1.amm.lastMarkPriceTwap.toString(),
|
|
539
|
+
'->',
|
|
540
|
+
markTwapLive.toString()
|
|
541
|
+
);
|
|
542
|
+
console.log(
|
|
543
|
+
'oracTwapLive:',
|
|
544
|
+
mockMarket1.amm.historicalOracleData.lastOraclePriceTwap.toString(),
|
|
545
|
+
'->',
|
|
546
|
+
oracleTwapLive.toString()
|
|
547
|
+
);
|
|
503
548
|
console.log('pred funding:', est1.toString(), est2.toString());
|
|
504
549
|
|
|
505
550
|
assert(markTwapLive.eq(new BN('1222131')));
|
|
506
551
|
assert(oracleTwapLive.eq(new BN('1222586')));
|
|
507
552
|
assert(est1.eq(est2));
|
|
508
553
|
assert(est2.eq(new BN('-1550')));
|
|
509
|
-
|
|
510
554
|
});
|
|
511
555
|
});
|
package/tests/dlob/test.ts
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
convertToNumber,
|
|
24
24
|
QUOTE_PRECISION,
|
|
25
25
|
isVariant,
|
|
26
|
-
TWO
|
|
26
|
+
TWO,
|
|
27
27
|
} from '../../src';
|
|
28
28
|
|
|
29
29
|
import { mockPerpMarkets, mockSpotMarkets, mockStateAccount } from './helpers';
|
|
@@ -137,11 +137,16 @@ function printOrderNode(
|
|
|
137
137
|
slot: number | undefined
|
|
138
138
|
) {
|
|
139
139
|
console.log(
|
|
140
|
-
` . vAMMNode? ${node.isVammNode()},\t${
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
}
|
|
140
|
+
` . vAMMNode? ${node.isVammNode()},\t${
|
|
141
|
+
node.order ? getVariant(node.order?.orderType) : '~'
|
|
142
|
+
} ${node.order ? getVariant(node.order?.direction) : '~'}\t, slot: ${
|
|
143
|
+
node.order?.slot.toString() || '~'
|
|
144
|
+
}, orderId: ${node.order?.orderId.toString() || '~'},\tnode.getPrice: ${
|
|
145
|
+
oracle ? node.getPrice(oracle, slot!) : '~'
|
|
146
|
+
}, node.price: ${node.order?.price.toString() || '~'}, priceOffset: ${
|
|
147
|
+
node.order?.oraclePriceOffset.toString() || '~'
|
|
148
|
+
} quantity: ${node.order?.baseAssetAmountFilled.toString() || '~'}/${
|
|
149
|
+
node.order?.baseAssetAmount.toString() || '~'
|
|
145
150
|
}`
|
|
146
151
|
);
|
|
147
152
|
}
|
|
@@ -188,7 +193,8 @@ function printBookState(
|
|
|
188
193
|
|
|
189
194
|
function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
190
195
|
console.log(
|
|
191
|
-
`Cross Found, takerExists: ${n.node.order !== undefined}, makerExists: ${
|
|
196
|
+
`Cross Found, takerExists: ${n.node.order !== undefined}, makerExists: ${
|
|
197
|
+
n.makerNodes !== undefined
|
|
192
198
|
}`
|
|
193
199
|
);
|
|
194
200
|
console.log(
|
|
@@ -210,8 +216,10 @@ function printCrossedNodes(n: NodeToFill, slot: number) {
|
|
|
210
216
|
console.log(
|
|
211
217
|
` orderId: ${o.orderId}, ${getVariant(o.orderType)}, ${getVariant(
|
|
212
218
|
o.direction
|
|
213
|
-
)},\texpired: ${isOrderExpired(o, slot)}, postOnly: ${
|
|
214
|
-
|
|
219
|
+
)},\texpired: ${isOrderExpired(o, slot)}, postOnly: ${
|
|
220
|
+
o.postOnly
|
|
221
|
+
}, reduceOnly: ${
|
|
222
|
+
o.reduceOnly
|
|
215
223
|
}, price: ${o.price.toString()}, priceOffset: ${o.oraclePriceOffset.toString()}, baseAmtFileld: ${o.baseAssetAmountFilled.toString()}/${o.baseAssetAmount.toString()}`
|
|
216
224
|
);
|
|
217
225
|
};
|
|
@@ -5790,10 +5798,7 @@ describe('DLOB Spot Tests', () => {
|
|
|
5790
5798
|
slot,
|
|
5791
5799
|
oraclePriceData: oracle,
|
|
5792
5800
|
});
|
|
5793
|
-
const quoteAmtOut = convertToNumber(
|
|
5794
|
-
out,
|
|
5795
|
-
QUOTE_PRECISION
|
|
5796
|
-
);
|
|
5801
|
+
const quoteAmtOut = convertToNumber(out, QUOTE_PRECISION);
|
|
5797
5802
|
|
|
5798
5803
|
// 1 * 20.69 + 2 * 20.70 + 1 * 20.71 = 82.8
|
|
5799
5804
|
expect(quoteAmtOut === 82.8).to.be.true;
|
|
@@ -5882,10 +5887,7 @@ describe('DLOB Spot Tests', () => {
|
|
|
5882
5887
|
slot,
|
|
5883
5888
|
oraclePriceData: oracle,
|
|
5884
5889
|
});
|
|
5885
|
-
const quoteAmtOut = convertToNumber(
|
|
5886
|
-
out,
|
|
5887
|
-
QUOTE_PRECISION
|
|
5888
|
-
);
|
|
5890
|
+
const quoteAmtOut = convertToNumber(out, QUOTE_PRECISION);
|
|
5889
5891
|
|
|
5890
5892
|
// 1 * 20.69 + 2 * 20.68 + 1 * 20.67 = 82.72
|
|
5891
5893
|
expect(quoteAmtOut === 82.72).to.be.true;
|