@drift-labs/sdk 2.113.0-beta.5 → 2.114.0-beta.0

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 CHANGED
@@ -1 +1 @@
1
- 2.113.0-beta.5
1
+ 2.114.0-beta.0
@@ -368,6 +368,8 @@ export declare class DriftClient {
368
368
  getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
369
369
  transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
370
370
  getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>;
371
+ transferPerpPosition(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
372
+ getTransferPerpPositionIx(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN): Promise<TransactionInstruction>;
371
373
  updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
372
374
  updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
373
375
  settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
@@ -1849,6 +1849,32 @@ class DriftClient {
1849
1849
  remainingAccounts,
1850
1850
  });
1851
1851
  }
1852
+ async transferPerpPosition(fromSubAccountId, toSubAccountId, marketIndex, amount, txParams) {
1853
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount), txParams), [], this.opts);
1854
+ return txSig;
1855
+ }
1856
+ async getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount) {
1857
+ const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
1858
+ const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
1859
+ const remainingAccounts = this.getRemainingAccounts({
1860
+ userAccounts: [
1861
+ this.getUserAccount(fromSubAccountId),
1862
+ this.getUserAccount(toSubAccountId),
1863
+ ],
1864
+ useMarketLastSlotCache: true,
1865
+ writablePerpMarketIndexes: [marketIndex],
1866
+ });
1867
+ return await this.program.instruction.transferPerpPosition(marketIndex, amount !== null && amount !== void 0 ? amount : null, {
1868
+ accounts: {
1869
+ authority: this.wallet.publicKey,
1870
+ fromUser,
1871
+ toUser,
1872
+ userStats: this.getUserStatsAccountPublicKey(),
1873
+ state: await this.getStatePublicKey(),
1874
+ },
1875
+ remainingAccounts,
1876
+ });
1877
+ }
1852
1878
  async updateSpotMarketCumulativeInterest(marketIndex, txParams) {
1853
1879
  const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.updateSpotMarketCumulativeInterestIx(marketIndex), txParams), [], this.opts);
1854
1880
  return txSig;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.112.0",
2
+ "version": "2.113.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -600,6 +600,48 @@
600
600
  }
601
601
  ]
602
602
  },
603
+ {
604
+ "name": "transferPerpPosition",
605
+ "accounts": [
606
+ {
607
+ "name": "fromUser",
608
+ "isMut": true,
609
+ "isSigner": false
610
+ },
611
+ {
612
+ "name": "toUser",
613
+ "isMut": true,
614
+ "isSigner": false
615
+ },
616
+ {
617
+ "name": "userStats",
618
+ "isMut": true,
619
+ "isSigner": false
620
+ },
621
+ {
622
+ "name": "authority",
623
+ "isMut": false,
624
+ "isSigner": true
625
+ },
626
+ {
627
+ "name": "state",
628
+ "isMut": false,
629
+ "isSigner": false
630
+ }
631
+ ],
632
+ "args": [
633
+ {
634
+ "name": "marketIndex",
635
+ "type": "u16"
636
+ },
637
+ {
638
+ "name": "amount",
639
+ "type": {
640
+ "option": "i64"
641
+ }
642
+ }
643
+ ]
644
+ },
603
645
  {
604
646
  "name": "placePerpOrder",
605
647
  "accounts": [
@@ -11356,6 +11398,9 @@
11356
11398
  },
11357
11399
  {
11358
11400
  "name": "OrderFilledWithOpenbookV2"
11401
+ },
11402
+ {
11403
+ "name": "TransferPerpPosition"
11359
11404
  }
11360
11405
  ]
11361
11406
  }
@@ -14930,6 +14975,11 @@
14930
14975
  "code": 6311,
14931
14976
  "name": "FuelOverflowAccountNotFound",
14932
14977
  "msg": "FuelOverflow account not found"
14978
+ },
14979
+ {
14980
+ "code": 6312,
14981
+ "name": "InvalidTransferPerpPosition",
14982
+ "msg": "Invalid Transfer Perp Position"
14933
14983
  }
14934
14984
  ],
14935
14985
  "metadata": {
@@ -368,6 +368,8 @@ export declare class DriftClient {
368
368
  getTransferDepositIx(amount: BN, marketIndex: number, fromSubAccountId: number, toSubAccountId: number): Promise<TransactionInstruction>;
369
369
  transferPools(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, txParams?: TxParams): Promise<TransactionSignature>;
370
370
  getTransferPoolsIx(depositFromMarketIndex: number, depositToMarketIndex: number, borrowFromMarketIndex: number, borrowToMarketIndex: number, depositAmount: BN | undefined, borrowAmount: BN | undefined, fromSubAccountId: number, toSubAccountId: number, isToNewSubAccount?: boolean): Promise<TransactionInstruction>;
371
+ transferPerpPosition(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN, txParams?: TxParams): Promise<TransactionSignature>;
372
+ getTransferPerpPositionIx(fromSubAccountId: number, toSubAccountId: number, marketIndex: number, amount: BN): Promise<TransactionInstruction>;
371
373
  updateSpotMarketCumulativeInterest(marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
372
374
  updateSpotMarketCumulativeInterestIx(marketIndex: number): Promise<TransactionInstruction>;
373
375
  settleLP(settleeUserAccountPublicKey: PublicKey, marketIndex: number, txParams?: TxParams): Promise<TransactionSignature>;
@@ -1849,6 +1849,32 @@ class DriftClient {
1849
1849
  remainingAccounts,
1850
1850
  });
1851
1851
  }
1852
+ async transferPerpPosition(fromSubAccountId, toSubAccountId, marketIndex, amount, txParams) {
1853
+ const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount), txParams), [], this.opts);
1854
+ return txSig;
1855
+ }
1856
+ async getTransferPerpPositionIx(fromSubAccountId, toSubAccountId, marketIndex, amount) {
1857
+ const fromUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, fromSubAccountId);
1858
+ const toUser = await (0, pda_1.getUserAccountPublicKey)(this.program.programId, this.wallet.publicKey, toSubAccountId);
1859
+ const remainingAccounts = this.getRemainingAccounts({
1860
+ userAccounts: [
1861
+ this.getUserAccount(fromSubAccountId),
1862
+ this.getUserAccount(toSubAccountId),
1863
+ ],
1864
+ useMarketLastSlotCache: true,
1865
+ writablePerpMarketIndexes: [marketIndex],
1866
+ });
1867
+ return await this.program.instruction.transferPerpPosition(marketIndex, amount !== null && amount !== void 0 ? amount : null, {
1868
+ accounts: {
1869
+ authority: this.wallet.publicKey,
1870
+ fromUser,
1871
+ toUser,
1872
+ userStats: this.getUserStatsAccountPublicKey(),
1873
+ state: await this.getStatePublicKey(),
1874
+ },
1875
+ remainingAccounts,
1876
+ });
1877
+ }
1852
1878
  async updateSpotMarketCumulativeInterest(marketIndex, txParams) {
1853
1879
  const { txSig } = await this.sendTransaction(await this.buildTransaction(await this.updateSpotMarketCumulativeInterestIx(marketIndex), txParams), [], this.opts);
1854
1880
  return txSig;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.112.0",
2
+ "version": "2.113.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -600,6 +600,48 @@
600
600
  }
601
601
  ]
602
602
  },
603
+ {
604
+ "name": "transferPerpPosition",
605
+ "accounts": [
606
+ {
607
+ "name": "fromUser",
608
+ "isMut": true,
609
+ "isSigner": false
610
+ },
611
+ {
612
+ "name": "toUser",
613
+ "isMut": true,
614
+ "isSigner": false
615
+ },
616
+ {
617
+ "name": "userStats",
618
+ "isMut": true,
619
+ "isSigner": false
620
+ },
621
+ {
622
+ "name": "authority",
623
+ "isMut": false,
624
+ "isSigner": true
625
+ },
626
+ {
627
+ "name": "state",
628
+ "isMut": false,
629
+ "isSigner": false
630
+ }
631
+ ],
632
+ "args": [
633
+ {
634
+ "name": "marketIndex",
635
+ "type": "u16"
636
+ },
637
+ {
638
+ "name": "amount",
639
+ "type": {
640
+ "option": "i64"
641
+ }
642
+ }
643
+ ]
644
+ },
603
645
  {
604
646
  "name": "placePerpOrder",
605
647
  "accounts": [
@@ -11356,6 +11398,9 @@
11356
11398
  },
11357
11399
  {
11358
11400
  "name": "OrderFilledWithOpenbookV2"
11401
+ },
11402
+ {
11403
+ "name": "TransferPerpPosition"
11359
11404
  }
11360
11405
  ]
11361
11406
  }
@@ -14930,6 +14975,11 @@
14930
14975
  "code": 6311,
14931
14976
  "name": "FuelOverflowAccountNotFound",
14932
14977
  "msg": "FuelOverflow account not found"
14978
+ },
14979
+ {
14980
+ "code": 6312,
14981
+ "name": "InvalidTransferPerpPosition",
14982
+ "msg": "Invalid Transfer Perp Position"
14933
14983
  }
14934
14984
  ],
14935
14985
  "metadata": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drift-labs/sdk",
3
- "version": "2.113.0-beta.5",
3
+ "version": "2.114.0-beta.0",
4
4
  "main": "lib/node/index.js",
5
5
  "types": "lib/node/index.d.ts",
6
6
  "browser": "./lib/browser/index.js",
@@ -3431,6 +3431,71 @@ export class DriftClient {
3431
3431
  );
3432
3432
  }
3433
3433
 
3434
+ public async transferPerpPosition(
3435
+ fromSubAccountId: number,
3436
+ toSubAccountId: number,
3437
+ marketIndex: number,
3438
+ amount: BN,
3439
+ txParams?: TxParams
3440
+ ): Promise<TransactionSignature> {
3441
+ const { txSig } = await this.sendTransaction(
3442
+ await this.buildTransaction(
3443
+ await this.getTransferPerpPositionIx(
3444
+ fromSubAccountId,
3445
+ toSubAccountId,
3446
+ marketIndex,
3447
+ amount
3448
+ ),
3449
+ txParams
3450
+ ),
3451
+ [],
3452
+ this.opts
3453
+ );
3454
+ return txSig;
3455
+ }
3456
+
3457
+ public async getTransferPerpPositionIx(
3458
+ fromSubAccountId: number,
3459
+ toSubAccountId: number,
3460
+ marketIndex: number,
3461
+ amount: BN
3462
+ ): Promise<TransactionInstruction> {
3463
+ const fromUser = await getUserAccountPublicKey(
3464
+ this.program.programId,
3465
+ this.wallet.publicKey,
3466
+ fromSubAccountId
3467
+ );
3468
+ const toUser = await getUserAccountPublicKey(
3469
+ this.program.programId,
3470
+ this.wallet.publicKey,
3471
+ toSubAccountId
3472
+ );
3473
+
3474
+ const remainingAccounts = this.getRemainingAccounts({
3475
+ userAccounts: [
3476
+ this.getUserAccount(fromSubAccountId),
3477
+ this.getUserAccount(toSubAccountId),
3478
+ ],
3479
+ useMarketLastSlotCache: true,
3480
+ writablePerpMarketIndexes: [marketIndex],
3481
+ });
3482
+
3483
+ return await this.program.instruction.transferPerpPosition(
3484
+ marketIndex,
3485
+ amount ?? null,
3486
+ {
3487
+ accounts: {
3488
+ authority: this.wallet.publicKey,
3489
+ fromUser,
3490
+ toUser,
3491
+ userStats: this.getUserStatsAccountPublicKey(),
3492
+ state: await this.getStatePublicKey(),
3493
+ },
3494
+ remainingAccounts,
3495
+ }
3496
+ );
3497
+ }
3498
+
3434
3499
  public async updateSpotMarketCumulativeInterest(
3435
3500
  marketIndex: number,
3436
3501
  txParams?: TxParams
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.112.0",
2
+ "version": "2.113.0",
3
3
  "name": "drift",
4
4
  "instructions": [
5
5
  {
@@ -600,6 +600,48 @@
600
600
  }
601
601
  ]
602
602
  },
603
+ {
604
+ "name": "transferPerpPosition",
605
+ "accounts": [
606
+ {
607
+ "name": "fromUser",
608
+ "isMut": true,
609
+ "isSigner": false
610
+ },
611
+ {
612
+ "name": "toUser",
613
+ "isMut": true,
614
+ "isSigner": false
615
+ },
616
+ {
617
+ "name": "userStats",
618
+ "isMut": true,
619
+ "isSigner": false
620
+ },
621
+ {
622
+ "name": "authority",
623
+ "isMut": false,
624
+ "isSigner": true
625
+ },
626
+ {
627
+ "name": "state",
628
+ "isMut": false,
629
+ "isSigner": false
630
+ }
631
+ ],
632
+ "args": [
633
+ {
634
+ "name": "marketIndex",
635
+ "type": "u16"
636
+ },
637
+ {
638
+ "name": "amount",
639
+ "type": {
640
+ "option": "i64"
641
+ }
642
+ }
643
+ ]
644
+ },
603
645
  {
604
646
  "name": "placePerpOrder",
605
647
  "accounts": [
@@ -11356,6 +11398,9 @@
11356
11398
  },
11357
11399
  {
11358
11400
  "name": "OrderFilledWithOpenbookV2"
11401
+ },
11402
+ {
11403
+ "name": "TransferPerpPosition"
11359
11404
  }
11360
11405
  ]
11361
11406
  }
@@ -14930,6 +14975,11 @@
14930
14975
  "code": 6311,
14931
14976
  "name": "FuelOverflowAccountNotFound",
14932
14977
  "msg": "FuelOverflow account not found"
14978
+ },
14979
+ {
14980
+ "code": 6312,
14981
+ "name": "InvalidTransferPerpPosition",
14982
+ "msg": "Invalid Transfer Perp Position"
14933
14983
  }
14934
14984
  ],
14935
14985
  "metadata": {