@drift-labs/sdk 2.45.0-beta.3 → 2.45.0-beta.5
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/dlob/orderBookLevels.js +2 -2
- package/lib/driftClient.d.ts +1 -1
- package/lib/driftClient.js +10 -9
- package/package.json +1 -1
- package/src/dlob/orderBookLevels.ts +3 -3
- package/src/driftClient.ts +21 -23
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.45.0-beta.
|
|
1
|
+
2.45.0-beta.5
|
|
@@ -173,8 +173,8 @@ function getVammL2Generator({ marketAccount, oraclePriceData, numOrders, now, to
|
|
|
173
173
|
if (remainingBaseLiquidity.lt(baseSwapped)) {
|
|
174
174
|
baseSwapped = remainingBaseLiquidity;
|
|
175
175
|
[afterSwapQuoteReserves, afterSwapBaseReserves] =
|
|
176
|
-
(0, __1.calculateAmmReservesAfterSwap)(
|
|
177
|
-
quoteSwapped = (0, __1.calculateQuoteAssetAmountSwapped)(
|
|
176
|
+
(0, __1.calculateAmmReservesAfterSwap)(askAmm, 'base', baseSwapped, __1.SwapDirection.REMOVE);
|
|
177
|
+
quoteSwapped = (0, __1.calculateQuoteAssetAmountSwapped)(askAmm.quoteAssetReserve.sub(afterSwapQuoteReserves).abs(), askAmm.pegMultiplier, __1.SwapDirection.REMOVE);
|
|
178
178
|
}
|
|
179
179
|
topOfBookAskSize = topOfBookAskSize.add(baseSwapped);
|
|
180
180
|
askSize = openAsks
|
package/lib/driftClient.d.ts
CHANGED
|
@@ -280,7 +280,7 @@ export declare class DriftClient {
|
|
|
280
280
|
*/
|
|
281
281
|
sendMarketOrderAndGetSignedFillTx(orderParams: OptionalOrderParams, userAccountPublicKey: PublicKey, userAccount: UserAccount, makerInfo?: MakerInfo | MakerInfo[], txParams?: TxParams, bracketOrdersParams?: OptionalOrderParams[], referrerInfo?: ReferrerInfo, cancelExistingOrders?: boolean): Promise<{
|
|
282
282
|
txSig: TransactionSignature;
|
|
283
|
-
signedFillTx
|
|
283
|
+
signedFillTx?: Transaction;
|
|
284
284
|
signedCancelExistingOrdersTx?: Transaction;
|
|
285
285
|
}>;
|
|
286
286
|
placePerpOrder(orderParams: OptionalOrderParams, txParams?: TxParams): Promise<TransactionSignature>;
|
package/lib/driftClient.js
CHANGED
|
@@ -1378,10 +1378,6 @@ class DriftClient {
|
|
|
1378
1378
|
const placeBracketOrderIx = await this.getPlacePerpOrderIx(bracketOrderParams);
|
|
1379
1379
|
bracketOrderIxs.push(placeBracketOrderIx);
|
|
1380
1380
|
}
|
|
1381
|
-
const fillPerpOrderIx = await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
|
|
1382
|
-
orderId,
|
|
1383
|
-
marketIndex,
|
|
1384
|
-
}, makerInfo, referrerInfo);
|
|
1385
1381
|
let cancelOrdersIx;
|
|
1386
1382
|
let cancelExistingOrdersTx;
|
|
1387
1383
|
if (cancelExistingOrders && (0, types_1.isVariant)(orderParams.marketType, 'perp')) {
|
|
@@ -1392,6 +1388,10 @@ class DriftClient {
|
|
|
1392
1388
|
// use versioned transactions if there is a lookup table account and wallet is compatible
|
|
1393
1389
|
if (this.txVersion === 0) {
|
|
1394
1390
|
const versionedMarketOrderTx = await this.buildTransaction([placePerpOrderIx].concat(bracketOrderIxs), txParams, 0);
|
|
1391
|
+
const fillPerpOrderIx = await this.getFillPerpOrderIx(userAccountPublicKey, userAccount, {
|
|
1392
|
+
orderId,
|
|
1393
|
+
marketIndex,
|
|
1394
|
+
}, makerInfo, referrerInfo);
|
|
1395
1395
|
const versionedFillTx = await this.buildTransaction([fillPerpOrderIx], txParams, 0);
|
|
1396
1396
|
const [signedVersionedMarketOrderTx, signedVersionedFillTx, signedCancelExistingOrdersTx,] = await this.provider.wallet.signAllTransactions([
|
|
1397
1397
|
versionedMarketOrderTx,
|
|
@@ -1413,17 +1413,18 @@ class DriftClient {
|
|
|
1413
1413
|
if (bracketOrderIxs.length > 0) {
|
|
1414
1414
|
marketOrderTx.add(...bracketOrderIxs);
|
|
1415
1415
|
}
|
|
1416
|
-
const fillTx = (0, utils_1.wrapInTx)(fillPerpOrderIx, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnits, txParams === null || txParams === void 0 ? void 0 : txParams.computeUnitsPrice);
|
|
1417
1416
|
// Apply the latest blockhash to the txs so that we can sign before sending them
|
|
1418
1417
|
const currentBlockHash = (await this.connection.getLatestBlockhash('finalized')).blockhash;
|
|
1419
1418
|
marketOrderTx.recentBlockhash = currentBlockHash;
|
|
1420
|
-
fillTx.recentBlockhash = currentBlockHash;
|
|
1421
1419
|
marketOrderTx.feePayer = userAccount.authority;
|
|
1422
|
-
|
|
1423
|
-
|
|
1420
|
+
if (cancelExistingOrdersTx) {
|
|
1421
|
+
cancelExistingOrdersTx.recentBlockhash = currentBlockHash;
|
|
1422
|
+
cancelExistingOrdersTx.feePayer = userAccount.authority;
|
|
1423
|
+
}
|
|
1424
|
+
const [signedMarketOrderTx, signedCancelExistingOrdersTx] = await this.provider.wallet.signAllTransactions([marketOrderTx, cancelExistingOrdersTx].filter((tx) => tx !== undefined));
|
|
1424
1425
|
const { txSig, slot } = await this.sendTransaction(signedMarketOrderTx, [], this.opts, true);
|
|
1425
1426
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
1426
|
-
return { txSig, signedFillTx, signedCancelExistingOrdersTx };
|
|
1427
|
+
return { txSig, signedFillTx: undefined, signedCancelExistingOrdersTx };
|
|
1427
1428
|
}
|
|
1428
1429
|
}
|
|
1429
1430
|
async placePerpOrder(orderParams, txParams) {
|
package/package.json
CHANGED
|
@@ -302,15 +302,15 @@ export function getVammL2Generator({
|
|
|
302
302
|
baseSwapped = remainingBaseLiquidity;
|
|
303
303
|
[afterSwapQuoteReserves, afterSwapBaseReserves] =
|
|
304
304
|
calculateAmmReservesAfterSwap(
|
|
305
|
-
|
|
305
|
+
askAmm,
|
|
306
306
|
'base',
|
|
307
307
|
baseSwapped,
|
|
308
308
|
SwapDirection.REMOVE
|
|
309
309
|
);
|
|
310
310
|
|
|
311
311
|
quoteSwapped = calculateQuoteAssetAmountSwapped(
|
|
312
|
-
|
|
313
|
-
|
|
312
|
+
askAmm.quoteAssetReserve.sub(afterSwapQuoteReserves).abs(),
|
|
313
|
+
askAmm.pegMultiplier,
|
|
314
314
|
SwapDirection.REMOVE
|
|
315
315
|
);
|
|
316
316
|
}
|
package/src/driftClient.ts
CHANGED
|
@@ -2462,7 +2462,7 @@ export class DriftClient {
|
|
|
2462
2462
|
cancelExistingOrders?: boolean
|
|
2463
2463
|
): Promise<{
|
|
2464
2464
|
txSig: TransactionSignature;
|
|
2465
|
-
signedFillTx
|
|
2465
|
+
signedFillTx?: Transaction;
|
|
2466
2466
|
signedCancelExistingOrdersTx?: Transaction;
|
|
2467
2467
|
}> {
|
|
2468
2468
|
const marketIndex = orderParams.marketIndex;
|
|
@@ -2478,17 +2478,6 @@ export class DriftClient {
|
|
|
2478
2478
|
bracketOrderIxs.push(placeBracketOrderIx);
|
|
2479
2479
|
}
|
|
2480
2480
|
|
|
2481
|
-
const fillPerpOrderIx = await this.getFillPerpOrderIx(
|
|
2482
|
-
userAccountPublicKey,
|
|
2483
|
-
userAccount,
|
|
2484
|
-
{
|
|
2485
|
-
orderId,
|
|
2486
|
-
marketIndex,
|
|
2487
|
-
},
|
|
2488
|
-
makerInfo,
|
|
2489
|
-
referrerInfo
|
|
2490
|
-
);
|
|
2491
|
-
|
|
2492
2481
|
let cancelOrdersIx: TransactionInstruction;
|
|
2493
2482
|
let cancelExistingOrdersTx: Transaction;
|
|
2494
2483
|
if (cancelExistingOrders && isVariant(orderParams.marketType, 'perp')) {
|
|
@@ -2513,6 +2502,18 @@ export class DriftClient {
|
|
|
2513
2502
|
txParams,
|
|
2514
2503
|
0
|
|
2515
2504
|
);
|
|
2505
|
+
|
|
2506
|
+
const fillPerpOrderIx = await this.getFillPerpOrderIx(
|
|
2507
|
+
userAccountPublicKey,
|
|
2508
|
+
userAccount,
|
|
2509
|
+
{
|
|
2510
|
+
orderId,
|
|
2511
|
+
marketIndex,
|
|
2512
|
+
},
|
|
2513
|
+
makerInfo,
|
|
2514
|
+
referrerInfo
|
|
2515
|
+
);
|
|
2516
|
+
|
|
2516
2517
|
const versionedFillTx = await this.buildTransaction(
|
|
2517
2518
|
[fillPerpOrderIx],
|
|
2518
2519
|
txParams,
|
|
@@ -2554,25 +2555,22 @@ export class DriftClient {
|
|
|
2554
2555
|
marketOrderTx.add(...bracketOrderIxs);
|
|
2555
2556
|
}
|
|
2556
2557
|
|
|
2557
|
-
const fillTx = wrapInTx(
|
|
2558
|
-
fillPerpOrderIx,
|
|
2559
|
-
txParams?.computeUnits,
|
|
2560
|
-
txParams?.computeUnitsPrice
|
|
2561
|
-
);
|
|
2562
|
-
|
|
2563
2558
|
// Apply the latest blockhash to the txs so that we can sign before sending them
|
|
2564
2559
|
const currentBlockHash = (
|
|
2565
2560
|
await this.connection.getLatestBlockhash('finalized')
|
|
2566
2561
|
).blockhash;
|
|
2567
2562
|
marketOrderTx.recentBlockhash = currentBlockHash;
|
|
2568
|
-
fillTx.recentBlockhash = currentBlockHash;
|
|
2569
2563
|
|
|
2570
2564
|
marketOrderTx.feePayer = userAccount.authority;
|
|
2571
|
-
fillTx.feePayer = userAccount.authority;
|
|
2572
2565
|
|
|
2573
|
-
|
|
2566
|
+
if (cancelExistingOrdersTx) {
|
|
2567
|
+
cancelExistingOrdersTx.recentBlockhash = currentBlockHash;
|
|
2568
|
+
cancelExistingOrdersTx.feePayer = userAccount.authority;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
const [signedMarketOrderTx, signedCancelExistingOrdersTx] =
|
|
2574
2572
|
await this.provider.wallet.signAllTransactions(
|
|
2575
|
-
[marketOrderTx,
|
|
2573
|
+
[marketOrderTx, cancelExistingOrdersTx].filter(
|
|
2576
2574
|
(tx) => tx !== undefined
|
|
2577
2575
|
)
|
|
2578
2576
|
);
|
|
@@ -2584,7 +2582,7 @@ export class DriftClient {
|
|
|
2584
2582
|
);
|
|
2585
2583
|
this.perpMarketLastSlotCache.set(orderParams.marketIndex, slot);
|
|
2586
2584
|
|
|
2587
|
-
return { txSig, signedFillTx, signedCancelExistingOrdersTx };
|
|
2585
|
+
return { txSig, signedFillTx: undefined, signedCancelExistingOrdersTx };
|
|
2588
2586
|
}
|
|
2589
2587
|
}
|
|
2590
2588
|
|