@xitadel-fi/sdk 0.2.1 → 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.
@@ -526,6 +526,26 @@ class XitadelProgram {
526
526
  if (positionNftAccountInfo == null) {
527
527
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(signer, positionNftAccount, lpAuthority, positionNftMint, spl_token_1.TOKEN_2022_PROGRAM_ID));
528
528
  }
529
+ // Pool B: when LTT has two pools, derive pool B accounts; otherwise use pool A accounts for _b slots
530
+ const positionNftMintB = lttConfig.positionNftMintB;
531
+ const hasPoolB = !positionNftMintB.equals(web3_js_2.SystemProgram.programId);
532
+ let positionNftAccountB = positionNftAccount;
533
+ let harvestVaultPositionNftAtaB = harvestVaultPositionNftAta;
534
+ if (hasPoolB) {
535
+ const [positionNftAccountBDerived] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_NFT_ACCOUNT_SEED, positionNftMintB.toBuffer()], cpAmmProgramId);
536
+ positionNftAccountB = positionNftAccountBDerived;
537
+ harvestVaultPositionNftAtaB = (0, spl_token_1.getAssociatedTokenAddressSync)(positionNftMintB, harvestVault, true, spl_token_1.TOKEN_2022_PROGRAM_ID);
538
+ let harvestVaultPositionNftAtaBInfo = null;
539
+ try {
540
+ harvestVaultPositionNftAtaBInfo = await this.program.provider.connection.getAccountInfo(harvestVaultPositionNftAtaB);
541
+ }
542
+ catch {
543
+ // Account doesn't exist
544
+ }
545
+ if (harvestVaultPositionNftAtaBInfo == null) {
546
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(signer, harvestVaultPositionNftAtaB, harvestVault, positionNftMintB, spl_token_1.TOKEN_2022_PROGRAM_ID));
547
+ }
548
+ }
529
549
  const configPda = this.getConfigPda();
530
550
  // Add the main deactivate instruction
531
551
  instructions.push(await this.program.methods
@@ -540,7 +560,10 @@ class XitadelProgram {
540
560
  collateralVaultAta: (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, lttConfigPda, true),
541
561
  positionNftMint,
542
562
  positionNftAccount: positionNftAccount,
563
+ positionNftMintB,
564
+ positionNftAccountB,
543
565
  harvestVaultPositionNftAta,
566
+ harvestVaultPositionNftAtaB,
544
567
  harvestVaultFundingAta,
545
568
  harvestVaultCollateralAta,
546
569
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -836,6 +859,15 @@ class XitadelProgram {
836
859
  // Derive all ATAs
837
860
  const harvestVaultPositionNftAta = (0, spl_token_1.getAssociatedTokenAddressSync)(positionNftMint, harvestVault, true, spl_token_1.TOKEN_2022_PROGRAM_ID);
838
861
  const managerPositionNftAta = (0, spl_token_1.getAssociatedTokenAddressSync)(positionNftMint, manager, true, spl_token_1.TOKEN_2022_PROGRAM_ID);
862
+ // Pool B: when LTT has two pools use pool B ATAs; otherwise use pool A for _b slots
863
+ const positionNftMintB = lttConfig.positionNftMintB;
864
+ const hasPoolB = !positionNftMintB.equals(web3_js_2.SystemProgram.programId);
865
+ let harvestVaultPositionNftAtaB = harvestVaultPositionNftAta;
866
+ let managerPositionNftAtaB = managerPositionNftAta;
867
+ if (hasPoolB) {
868
+ harvestVaultPositionNftAtaB = (0, spl_token_1.getAssociatedTokenAddressSync)(positionNftMintB, harvestVault, true, spl_token_1.TOKEN_2022_PROGRAM_ID);
869
+ managerPositionNftAtaB = (0, spl_token_1.getAssociatedTokenAddressSync)(positionNftMintB, manager, true, spl_token_1.TOKEN_2022_PROGRAM_ID);
870
+ }
839
871
  const harvestVaultFundingAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, harvestVault, true, spl_token_1.TOKEN_PROGRAM_ID);
840
872
  const harvestVaultCollateralAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, harvestVault, true, spl_token_1.TOKEN_PROGRAM_ID);
841
873
  const managerFundingAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, manager, true, spl_token_1.TOKEN_PROGRAM_ID);
@@ -853,6 +885,16 @@ class XitadelProgram {
853
885
  if (!managerPositionNftAtaInfo) {
854
886
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(manager, managerPositionNftAta, manager, positionNftMint, spl_token_1.TOKEN_2022_PROGRAM_ID));
855
887
  }
888
+ if (hasPoolB) {
889
+ const managerPositionNftAtaBInfo = await connection.getAccountInfo(managerPositionNftAtaB);
890
+ if (!managerPositionNftAtaBInfo) {
891
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(manager, managerPositionNftAtaB, manager, positionNftMintB, spl_token_1.TOKEN_2022_PROGRAM_ID));
892
+ }
893
+ const harvestVaultPositionNftAtaBInfo = await connection.getAccountInfo(harvestVaultPositionNftAtaB);
894
+ if (!harvestVaultPositionNftAtaBInfo) {
895
+ instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(manager, harvestVaultPositionNftAtaB, harvestVault, positionNftMintB, spl_token_1.TOKEN_2022_PROGRAM_ID));
896
+ }
897
+ }
856
898
  const harvestVaultFundingAtaInfo = await connection.getAccountInfo(harvestVaultFundingAta);
857
899
  if (!harvestVaultFundingAtaInfo) {
858
900
  instructions.push((0, spl_token_1.createAssociatedTokenAccountInstruction)(manager, harvestVaultFundingAta, harvestVault, lttConfig.fundingTokenMint, spl_token_1.TOKEN_PROGRAM_ID));
@@ -876,6 +918,9 @@ class XitadelProgram {
876
918
  positionNftMint,
877
919
  harvestVaultPositionNftAta,
878
920
  managerPositionNftAta,
921
+ positionNftMintB,
922
+ harvestVaultPositionNftAtaB,
923
+ managerPositionNftAtaB,
879
924
  harvestVaultFundingAta,
880
925
  managerFundingAta,
881
926
  managerCollateralAta,
@@ -1436,6 +1436,17 @@
1436
1436
  ],
1437
1437
  "writable": true
1438
1438
  },
1439
+ {
1440
+ "name": "position_nft_mint_b",
1441
+ "writable": true
1442
+ },
1443
+ {
1444
+ "name": "position_nft_account_b",
1445
+ "docs": [
1446
+ "The position NFT token account for pool B owned by LP authority (pass same as position_nft_account if single pool)"
1447
+ ],
1448
+ "writable": true
1449
+ },
1439
1450
  {
1440
1451
  "name": "harvest_vault_position_nft_ata",
1441
1452
  "docs": [
@@ -1443,6 +1454,13 @@
1443
1454
  ],
1444
1455
  "writable": true
1445
1456
  },
1457
+ {
1458
+ "name": "harvest_vault_position_nft_ata_b",
1459
+ "docs": [
1460
+ "The harvest vault's position NFT token account for pool B (pass same as harvest_vault_position_nft_ata if single pool)"
1461
+ ],
1462
+ "writable": true
1463
+ },
1446
1464
  {
1447
1465
  "name": "harvest_vault_funding_ata",
1448
1466
  "docs": [
@@ -2617,6 +2635,24 @@
2617
2635
  "name": "manager_position_nft_ata",
2618
2636
  "writable": true
2619
2637
  },
2638
+ {
2639
+ "name": "position_nft_mint_b",
2640
+ "writable": true
2641
+ },
2642
+ {
2643
+ "name": "harvest_vault_position_nft_ata_b",
2644
+ "docs": [
2645
+ "Harvest vault's position NFT ATA for pool B (pass same as harvest_vault_position_nft_ata if single pool)"
2646
+ ],
2647
+ "writable": true
2648
+ },
2649
+ {
2650
+ "name": "manager_position_nft_ata_b",
2651
+ "docs": [
2652
+ "Manager's position NFT ATA for pool B (pass same as manager_position_nft_ata if single pool)"
2653
+ ],
2654
+ "writable": true
2655
+ },
2620
2656
  {
2621
2657
  "name": "harvest_vault_funding_ata",
2622
2658
  "writable": true,
@@ -1442,6 +1442,17 @@ export type Xitadel = {
1442
1442
  ];
1443
1443
  "writable": true;
1444
1444
  },
1445
+ {
1446
+ "name": "positionNftMintB";
1447
+ "writable": true;
1448
+ },
1449
+ {
1450
+ "name": "positionNftAccountB";
1451
+ "docs": [
1452
+ "The position NFT token account for pool B owned by LP authority (pass same as position_nft_account if single pool)"
1453
+ ];
1454
+ "writable": true;
1455
+ },
1445
1456
  {
1446
1457
  "name": "harvestVaultPositionNftAta";
1447
1458
  "docs": [
@@ -1449,6 +1460,13 @@ export type Xitadel = {
1449
1460
  ];
1450
1461
  "writable": true;
1451
1462
  },
1463
+ {
1464
+ "name": "harvestVaultPositionNftAtaB";
1465
+ "docs": [
1466
+ "The harvest vault's position NFT token account for pool B (pass same as harvest_vault_position_nft_ata if single pool)"
1467
+ ];
1468
+ "writable": true;
1469
+ },
1452
1470
  {
1453
1471
  "name": "harvestVaultFundingAta";
1454
1472
  "docs": [
@@ -2623,6 +2641,24 @@ export type Xitadel = {
2623
2641
  "name": "managerPositionNftAta";
2624
2642
  "writable": true;
2625
2643
  },
2644
+ {
2645
+ "name": "positionNftMintB";
2646
+ "writable": true;
2647
+ },
2648
+ {
2649
+ "name": "harvestVaultPositionNftAtaB";
2650
+ "docs": [
2651
+ "Harvest vault's position NFT ATA for pool B (pass same as harvest_vault_position_nft_ata if single pool)"
2652
+ ];
2653
+ "writable": true;
2654
+ },
2655
+ {
2656
+ "name": "managerPositionNftAtaB";
2657
+ "docs": [
2658
+ "Manager's position NFT ATA for pool B (pass same as manager_position_nft_ata if single pool)"
2659
+ ];
2660
+ "writable": true;
2661
+ },
2626
2662
  {
2627
2663
  "name": "harvestVaultFundingAta";
2628
2664
  "writable": true;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@xitadel-fi/sdk",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "SDK for interacting with the Xitadel program",
6
6
  "main": "dist/sdk/src/index.js",
7
7
  "types": "dist/sdk/src/index.d.ts",