@xitadel-fi/sdk 0.2.4 → 0.2.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.
@@ -481,15 +481,12 @@ export declare class XitadelProgram {
481
481
  harvestLTT(lttId: PublicKey, manager: PublicKey, positionNftMint: PublicKey): Promise<TransactionInstruction[]>;
482
482
  getHarvestVaultPda(lttId: PublicKey): PublicKey;
483
483
  /**
484
- * Claim LP fees for an active LTT
485
- * @param signer The signer's public key
486
- * @param lttId The LTT ID
487
- * @param positionNftMint The position NFT mint
488
- * @param ammConfig The AMM config
489
- * @param cpAmmProgramId The CP AMM program ID
490
- * @returns Transaction instruction for claiming fees
484
+ * Claim LP fees from both cp_amm positions of an LTT.
485
+ * Pool B accounts default to pool A accounts when LTT is single-pool
486
+ * (positionNftMintB == default). The on-chain program skips the pool B
487
+ * CPI in that case.
491
488
  */
492
- claimFees(signer: PublicKey, lttId: PublicKey, positionNftMint: PublicKey, ammConfig: PublicKey, cpAmmProgramId: PublicKey, receiver: PublicKey): Promise<TransactionInstruction>;
489
+ claimFees(signer: PublicKey, lttId: PublicKey, positionNftMint: PublicKey, ammConfig: PublicKey, cpAmmProgramId: PublicKey, receiver: PublicKey, positionNftMintB?: PublicKey, ammConfigB?: PublicKey): Promise<TransactionInstruction>;
493
490
  /**
494
491
  * Deposit stake to flash trade from collateral vault
495
492
  * @param lttId The LTT ID
@@ -541,4 +538,13 @@ export declare class XitadelProgram {
541
538
  * @returns Transaction instruction for withdrawing stake from flash trade
542
539
  */
543
540
  withdrawStakeFlashTrade(lttId: PublicKey, authority: PublicKey, unstakeAmount: BN, lpTokenMint: PublicKey, flashTradeProgramId: PublicKey, transferAuthority: PublicKey, perpetuals: PublicKey, pool: PublicKey, flpStakeAccount: PublicKey, poolStakedLpVault: PublicKey, rewardCustody: PublicKey, eventAuthority: PublicKey): Promise<TransactionInstruction>;
541
+ /**
542
+ * Build a `version` instruction.
543
+ */
544
+ versionInstruction(): Promise<TransactionInstruction>;
545
+ /**
546
+ * Return the deployed program's git commit hash by simulating
547
+ * the `version` instruction and parsing its log output.
548
+ */
549
+ getVersion(): Promise<string>;
544
550
  }
@@ -22,16 +22,17 @@ exports.SEEDS = {
22
22
  };
23
23
  class XitadelProgram {
24
24
  constructor(provider, address) {
25
- const idl = Object.assign(xitadel_json_1.default, {});
26
- if (address) {
27
- idl.address = address;
25
+ if (process.env.NODE_ENV === 'development') {
26
+ const workspace = require('@coral-xyz/anchor').workspace;
27
+ this.program = workspace.Xitadel;
28
+ }
29
+ else {
30
+ const idl = Object.assign(xitadel_json_1.default, {});
31
+ if (address) {
32
+ idl.address = address;
33
+ }
34
+ this.program = new anchor_1.Program(idl, provider);
28
35
  }
29
- this.program = new anchor_1.Program(idl, provider);
30
- // if (process.env.NODE_ENV === 'development') {
31
- // const workspace = require('@coral-xyz/anchor').workspace;
32
- // this.program = workspace.Xitadel as Program<Xitadel>;
33
- // } else {
34
- // }
35
36
  }
36
37
  getProgramId() {
37
38
  return this.program.programId;
@@ -1034,37 +1035,46 @@ class XitadelProgram {
1034
1035
  return web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('harvest_vault'), lttId.toBuffer()], this.program.programId)[0];
1035
1036
  }
1036
1037
  /**
1037
- * Claim LP fees for an active LTT
1038
- * @param signer The signer's public key
1039
- * @param lttId The LTT ID
1040
- * @param positionNftMint The position NFT mint
1041
- * @param ammConfig The AMM config
1042
- * @param cpAmmProgramId The CP AMM program ID
1043
- * @returns Transaction instruction for claiming fees
1038
+ * Claim LP fees from both cp_amm positions of an LTT.
1039
+ * Pool B accounts default to pool A accounts when LTT is single-pool
1040
+ * (positionNftMintB == default). The on-chain program skips the pool B
1041
+ * CPI in that case.
1044
1042
  */
1045
- async claimFees(signer, lttId, positionNftMint, ammConfig, cpAmmProgramId, receiver) {
1043
+ async claimFees(signer, lttId, positionNftMint, ammConfig, cpAmmProgramId, receiver, positionNftMintB, ammConfigB) {
1046
1044
  const lttConfigPda = this.getLTTConfigPda(lttId);
1047
1045
  const configPda = this.getConfigPda();
1048
1046
  const lttConfig = await this.getLttConfig(lttId);
1049
1047
  const lpAuthority = this.getLpAuthority();
1050
- // Derive pool key
1048
+ // Pool A
1051
1049
  const pool = (0, utils_1.derivePoolKey)(ammConfig, lttId, lttConfig.fundingTokenMint, cpAmmProgramId);
1052
- // Derive position PDA
1053
1050
  const [position] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_SEED, positionNftMint.toBuffer()], cpAmmProgramId);
1054
- // Derive pool authority
1055
1051
  const [poolAuthority] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.POOL_AUTHORITY_SEED], cpAmmProgramId);
1056
- // Derive event authority
1057
1052
  const [eventAuthority] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('__event_authority')], cpAmmProgramId);
1058
- // Derive vault addresses
1059
1053
  const [lttVault, stableVault] = [
1060
1054
  (0, utils_1.getVaultPda)(lttId, cpAmmProgramId, pool),
1061
1055
  (0, utils_1.getVaultPda)(lttConfig.fundingTokenMint, cpAmmProgramId, pool),
1062
1056
  ];
1063
- // Get receiver's token accounts for receiving fees
1057
+ const [positionNftAccount] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('position_nft_account'), positionNftMint.toBuffer()], cpAmmProgramId);
1064
1058
  const receiverTokenAAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(lttId, receiver, true);
1065
1059
  const receiverTokenBAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, receiver, true);
1066
- // Get position NFT account
1067
- const [positionNftAccount] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('position_nft_account'), positionNftMint.toBuffer()], cpAmmProgramId);
1060
+ // Pool B: prefer explicit args; fall back to on-chain position_nft_mint_b
1061
+ const onChainMintB = lttConfig.positionNftMintB;
1062
+ const hasPoolB = (positionNftMintB && !positionNftMintB.equals(web3_js_1.PublicKey.default)) ||
1063
+ (onChainMintB && !onChainMintB.equals(web3_js_1.PublicKey.default));
1064
+ let poolB = pool;
1065
+ let positionB = position;
1066
+ let lttVaultB = lttVault;
1067
+ let stableVaultB = stableVault;
1068
+ let positionNftAccountB = positionNftAccount;
1069
+ if (hasPoolB) {
1070
+ const mintB = (positionNftMintB ?? onChainMintB);
1071
+ const cfgB = ammConfigB ?? ammConfig;
1072
+ poolB = (0, utils_1.derivePoolKey)(cfgB, lttId, lttConfig.fundingTokenMint, cpAmmProgramId);
1073
+ [positionB] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_SEED, mintB.toBuffer()], cpAmmProgramId);
1074
+ lttVaultB = (0, utils_1.getVaultPda)(lttId, cpAmmProgramId, poolB);
1075
+ stableVaultB = (0, utils_1.getVaultPda)(lttConfig.fundingTokenMint, cpAmmProgramId, poolB);
1076
+ [positionNftAccountB] = web3_js_1.PublicKey.findProgramAddressSync([Buffer.from('position_nft_account'), mintB.toBuffer()], cpAmmProgramId);
1077
+ }
1068
1078
  return await this.program.methods
1069
1079
  .claimFees()
1070
1080
  .accountsPartial({
@@ -1079,9 +1089,14 @@ class XitadelProgram {
1079
1089
  stableCoinMint: lttConfig.fundingTokenMint,
1080
1090
  lttVaultAta: lttVault,
1081
1091
  stableCoinVaultAta: stableVault,
1082
- receiverTokenAAccount: receiverTokenAAccount,
1083
- receiverTokenBAccount: receiverTokenBAccount,
1092
+ receiverTokenAAccount,
1093
+ receiverTokenBAccount,
1084
1094
  positionNftAccount,
1095
+ poolB,
1096
+ positionB,
1097
+ lttVaultAtaB: lttVaultB,
1098
+ stableCoinVaultAtaB: stableVaultB,
1099
+ positionNftAccountB,
1085
1100
  eventAuthority,
1086
1101
  tokenAProgram: spl_token_1.TOKEN_PROGRAM_ID,
1087
1102
  tokenBProgram: spl_token_1.TOKEN_PROGRAM_ID,
@@ -1227,5 +1242,24 @@ class XitadelProgram {
1227
1242
  .remainingAccounts([...tokenStakeAccounts])
1228
1243
  .instruction();
1229
1244
  }
1245
+ /**
1246
+ * Build a `version` instruction.
1247
+ */
1248
+ async versionInstruction() {
1249
+ return this.program.methods.version().accounts({}).instruction();
1250
+ }
1251
+ /**
1252
+ * Return the deployed program's git commit hash by simulating
1253
+ * the `version` instruction and parsing its log output.
1254
+ */
1255
+ async getVersion() {
1256
+ const sim = await this.program.methods.version().accounts({}).simulate();
1257
+ const logs = sim.raw ?? [];
1258
+ const versionLog = logs.find((l) => l.includes('program_version:'));
1259
+ if (!versionLog) {
1260
+ throw new Error('program_version log not found in simulation output');
1261
+ }
1262
+ return versionLog.split('program_version:')[1].trim();
1263
+ }
1230
1264
  }
1231
1265
  exports.XitadelProgram = XitadelProgram;
@@ -650,6 +650,26 @@
650
650
  "name": "position_nft_account",
651
651
  "writable": true
652
652
  },
653
+ {
654
+ "name": "pool_b",
655
+ "writable": true
656
+ },
657
+ {
658
+ "name": "position_b",
659
+ "writable": true
660
+ },
661
+ {
662
+ "name": "ltt_vault_ata_b",
663
+ "writable": true
664
+ },
665
+ {
666
+ "name": "stable_coin_vault_ata_b",
667
+ "writable": true
668
+ },
669
+ {
670
+ "name": "position_nft_account_b",
671
+ "writable": true
672
+ },
653
673
  {
654
674
  "name": "event_authority",
655
675
  "writable": true
@@ -5022,6 +5042,21 @@
5022
5042
  }
5023
5043
  ]
5024
5044
  },
5045
+ {
5046
+ "name": "version",
5047
+ "discriminator": [
5048
+ 118,
5049
+ 65,
5050
+ 195,
5051
+ 198,
5052
+ 129,
5053
+ 216,
5054
+ 252,
5055
+ 192
5056
+ ],
5057
+ "accounts": [],
5058
+ "args": []
5059
+ },
5025
5060
  {
5026
5061
  "name": "withdraw_collateral",
5027
5062
  "discriminator": [
@@ -656,6 +656,26 @@ export type Xitadel = {
656
656
  "name": "positionNftAccount";
657
657
  "writable": true;
658
658
  },
659
+ {
660
+ "name": "poolB";
661
+ "writable": true;
662
+ },
663
+ {
664
+ "name": "positionB";
665
+ "writable": true;
666
+ },
667
+ {
668
+ "name": "lttVaultAtaB";
669
+ "writable": true;
670
+ },
671
+ {
672
+ "name": "stableCoinVaultAtaB";
673
+ "writable": true;
674
+ },
675
+ {
676
+ "name": "positionNftAccountB";
677
+ "writable": true;
678
+ },
659
679
  {
660
680
  "name": "eventAuthority";
661
681
  "writable": true;
@@ -5028,6 +5048,21 @@ export type Xitadel = {
5028
5048
  }
5029
5049
  ];
5030
5050
  },
5051
+ {
5052
+ "name": "version";
5053
+ "discriminator": [
5054
+ 118,
5055
+ 65,
5056
+ 195,
5057
+ 198,
5058
+ 129,
5059
+ 216,
5060
+ 252,
5061
+ 192
5062
+ ];
5063
+ "accounts": [];
5064
+ "args": [];
5065
+ },
5031
5066
  {
5032
5067
  "name": "withdrawCollateral";
5033
5068
  "discriminator": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@xitadel-fi/sdk",
4
- "version": "0.2.4",
4
+ "version": "0.2.5",
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",