Skip to content

Commit 6827402

Browse files
committed
sdk: idl for new existing position order action records
1 parent 7d2c8fd commit 6827402

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

sdk/src/idl/drift.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13031,6 +13031,34 @@
1303113031
"name": "bitFlags",
1303213032
"type": "u8",
1303313033
"index": false
13034+
},
13035+
{
13036+
"name": "takerExistingQuoteEntryAmount",
13037+
"type": {
13038+
"option": "u64"
13039+
},
13040+
"index": false
13041+
},
13042+
{
13043+
"name": "takerExistingBaseAssetAmount",
13044+
"type": {
13045+
"option": "u64"
13046+
},
13047+
"index": false
13048+
},
13049+
{
13050+
"name": "makerExistingQuoteEntryAmount",
13051+
"type": {
13052+
"option": "u64"
13053+
},
13054+
"index": false
13055+
},
13056+
{
13057+
"name": "makerExistingBaseAssetAmount",
13058+
"type": {
13059+
"option": "u64"
13060+
},
13061+
"index": false
1303413062
}
1303513063
]
1303613064
},

sdk/src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,10 @@ export type OrderActionRecord = {
625625
makerOrderCumulativeQuoteAssetAmountFilled: BN | null;
626626
oraclePrice: BN;
627627
bitFlags: number;
628+
takerExistingQuoteEntryAmount: BN | null;
629+
takerExistingBaseAssetAmount: BN | null;
630+
makerExistingQuoteEntryAmount: BN | null;
631+
makerExistingBaseAssetAmount: BN | null;
628632
};
629633

630634
export type SwapRecord = {

tests/driftClient.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,9 @@ describe('drift client', () => {
338338
assert.ok(orderActionRecord.quoteAssetAmountFilled.eq(new BN(48000001)));
339339
assert.ok(orderActionRecord.marketIndex === marketIndex);
340340

341+
assert.ok(orderActionRecord.takerExistingQuoteEntryAmount === null);
342+
assert.ok(orderActionRecord.takerExistingBaseAssetAmount === null);
343+
341344
assert(driftClient.getPerpMarketAccount(0).nextFillRecordId.eq(new BN(2)));
342345
});
343346

@@ -420,6 +423,8 @@ describe('drift client', () => {
420423
assert.ok(orderActionRecord.baseAssetAmountFilled.eq(new BN(24000000000)));
421424
assert.ok(orderActionRecord.quoteAssetAmountFilled.eq(new BN(24000000)));
422425
assert.ok(orderActionRecord.marketIndex === 0);
426+
assert.ok(orderActionRecord.takerExistingQuoteEntryAmount.eq(new BN(24000000)));
427+
assert.ok(orderActionRecord.takerExistingBaseAssetAmount === null);
423428
});
424429

425430
it('Reverse long position', async () => {
@@ -486,6 +491,9 @@ describe('drift client', () => {
486491
assert.ok(orderActionRecord.baseAssetAmountFilled.eq(new BN(48000000000)));
487492
assert.ok(orderActionRecord.quoteAssetAmountFilled.eq(new BN(48000000)));
488493

494+
assert.ok(orderActionRecord.takerExistingQuoteEntryAmount.eq(new BN(24000001)));
495+
assert.ok(orderActionRecord.takerExistingBaseAssetAmount.eq(new BN(24000000000)));
496+
489497
assert.ok(orderActionRecord.marketIndex === 0);
490498
});
491499

@@ -532,6 +540,9 @@ describe('drift client', () => {
532540
assert.ok(orderActionRecord.baseAssetAmountFilled.eq(new BN(24000000000)));
533541
assert.ok(orderActionRecord.quoteAssetAmountFilled.eq(new BN(24000000)));
534542
assert.ok(orderActionRecord.marketIndex === 0);
543+
544+
assert.ok(orderActionRecord.takerExistingQuoteEntryAmount.eq(new BN(24000000)));
545+
assert.ok(orderActionRecord.takerExistingBaseAssetAmount === null);
535546
});
536547

537548
it('Open short position', async () => {

tests/liquidatePerp.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,11 @@ describe('liquidate perp (no open orders)', () => {
403403
assert(fillRecord.makerFee.eq(new BN(ZERO)));
404404
assert(isVariant(fillRecord.makerOrderDirection, 'long'));
405405

406+
assert(fillRecord.takerExistingQuoteEntryAmount.eq(new BN(17500007)));
407+
assert(fillRecord.takerExistingBaseAssetAmount === null);
408+
assert(fillRecord.makerExistingQuoteEntryAmount === null);
409+
assert(fillRecord.makerExistingBaseAssetAmount === null);
410+
406411
const _sig2 = await liquidatorDriftClient.liquidatePerpPnlForDeposit(
407412
await driftClient.getUserAccountPublicKey(),
408413
driftClient.getUserAccount(),

0 commit comments

Comments
 (0)