@xitadel-fi/sdk 0.2.2 → 0.2.4

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.
@@ -63,7 +63,7 @@ export declare class XitadelProgram {
63
63
  collateralTokenMint: PublicKey;
64
64
  lttSupply: BN;
65
65
  fundedLttSupply: BN;
66
- collateralAmount: BN;
66
+ reserved1: number[];
67
67
  stableInterestAmount: BN;
68
68
  tokenInterestAmount: BN;
69
69
  fundingStartTs: BN;
@@ -273,7 +273,7 @@ export declare class XitadelProgram {
273
273
  collateralTokenMint: PublicKey;
274
274
  lttSupply: BN;
275
275
  fundedLttSupply: BN;
276
- collateralAmount: BN;
276
+ reserved1: number[];
277
277
  stableInterestAmount: BN;
278
278
  tokenInterestAmount: BN;
279
279
  fundingStartTs: BN;
@@ -387,9 +387,18 @@ export declare class XitadelProgram {
387
387
  /**
388
388
  * Update LTT status
389
389
  * @param lttId The LTT ID
390
+ * @param signer The signer (e.g. keeper or caller)
391
+ * @param priceFeed Price feed (Switchboard or Chainlink)
392
+ * @param chainLinkProgram Chainlink program ID (required for account validation; use placeholder for Switchboard)
393
+ * @param signedReport Signed report bytes (empty buffer for Switchboard)
394
+ * @param verifierAccounts Chainlink verifier accounts (required by IDL; use placeholder pubkeys when not using Chainlink)
390
395
  * @returns Transaction instruction for updating LTT status
391
396
  */
392
- updateLTTStatus(lttId: PublicKey): Promise<TransactionInstruction>;
397
+ updateLTTStatus(lttId: PublicKey, signer: PublicKey, priceFeed: PublicKey, chainLinkProgram: PublicKey, signedReport: Buffer | Uint8Array, verifierAccounts: {
398
+ verifier: PublicKey;
399
+ accessController: PublicKey;
400
+ config: PublicKey;
401
+ }): Promise<TransactionInstruction>;
393
402
  /**
394
403
  * Deactivate an LTT
395
404
  * @param signer
@@ -414,6 +423,12 @@ export declare class XitadelProgram {
414
423
  stableCoinAmount: BN;
415
424
  cpAmmProgramId: PublicKey;
416
425
  collateralTokenMint: PublicKey;
426
+ priceFeed: PublicKey;
427
+ chainlinkProgram: PublicKey;
428
+ verifierAccount: PublicKey;
429
+ accessController: PublicKey;
430
+ configAccount: PublicKey;
431
+ signedReport?: Buffer | number[];
417
432
  }): Promise<{
418
433
  activateLttIx: TransactionInstruction[];
419
434
  createLookupTableIx: TransactionInstruction;
@@ -422,15 +437,29 @@ export declare class XitadelProgram {
422
437
  }>;
423
438
  /**
424
439
  * Maturate an LTT
425
- * @param signer
440
+ * @param signer Keeper/signer public key
426
441
  * @param lttId The LTT ID
427
442
  * @param positionNftMint The position NFT mint
443
+ * @param positionNftMintB The position NFT mint for pool B
428
444
  * @param ammConfig The AMM config
445
+ * @param ammConfigB The AMM config for pool B
429
446
  * @param cpAmmProgramId The CP AMM program ID
430
- * @param params The maturate parameters
447
+ * @param priceFeed Price feed (Chainlink or Switchboard)
448
+ * @param chainLinkProgram Chainlink program ID (required by IDL; use placeholder when not using Chainlink)
449
+ * @param reportBuffer Signed report bytes (empty buffer when not using Chainlink)
450
+ * @param verifierAccounts Chainlink verifier accounts (use placeholder pubkeys when not using Chainlink)
431
451
  * @returns Transaction instruction for maturing the LTT
432
452
  */
433
- maturateLtt(signer: PublicKey, lttId: PublicKey, positionNftMint: PublicKey, positionNftMintB: PublicKey, ammConfig: PublicKey, ammConfigB: PublicKey, cpAmmProgramId: PublicKey): Promise<TransactionInstruction>;
453
+ maturateLtt(signer: PublicKey, lttId: PublicKey, positionNftMint: PublicKey, positionNftMintB: PublicKey, ammConfig: PublicKey, ammConfigB: PublicKey, cpAmmProgramId: PublicKey, priceFeed: PublicKey, chainLinkProgram: PublicKey, reportBuffer: Buffer | Uint8Array, verifierAccounts: {
454
+ verifier: PublicKey;
455
+ accessController: PublicKey;
456
+ config: PublicKey;
457
+ }): Promise<{
458
+ maturateIx: TransactionInstruction;
459
+ createLookupTableIx: TransactionInstruction;
460
+ extendLookupTableIx: TransactionInstruction[];
461
+ lookupTableAddress: PublicKey;
462
+ }>;
434
463
  /**
435
464
  * Stop liquidation
436
465
  * @param lttId The LTT ID
@@ -444,22 +444,34 @@ class XitadelProgram {
444
444
  /**
445
445
  * Update LTT status
446
446
  * @param lttId The LTT ID
447
+ * @param signer The signer (e.g. keeper or caller)
448
+ * @param priceFeed Price feed (Switchboard or Chainlink)
449
+ * @param chainLinkProgram Chainlink program ID (required for account validation; use placeholder for Switchboard)
450
+ * @param signedReport Signed report bytes (empty buffer for Switchboard)
451
+ * @param verifierAccounts Chainlink verifier accounts (required by IDL; use placeholder pubkeys when not using Chainlink)
447
452
  * @returns Transaction instruction for updating LTT status
448
453
  */
449
- async updateLTTStatus(lttId) {
454
+ async updateLTTStatus(lttId, signer, priceFeed, chainLinkProgram, signedReport, verifierAccounts) {
450
455
  const lttConfigPda = this.getLTTConfigPda(lttId);
451
456
  const lttConfig = await this.program.account.lttConfiguration.fetch(lttConfigPda);
452
457
  const fundingVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, lttConfigPda, true);
453
458
  const collateralVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, lttConfigPda, true);
454
459
  const configPda = this.getConfigPda();
455
460
  return this.program.methods
456
- .updateLttStatus()
461
+ .updateLttStatus(Buffer.from(signedReport))
457
462
  .accountsPartial({
463
+ signer,
458
464
  config: configPda,
459
465
  lttConfiguration: lttConfigPda,
460
466
  fundingVaultAta,
461
467
  collateralVaultAta,
462
468
  fundingTokenMint: lttConfig.fundingTokenMint,
469
+ collateralTokenMint: lttConfig.collateralTokenMint,
470
+ priceFeed,
471
+ chainlinkProgram: chainLinkProgram,
472
+ verifierAccount: verifierAccounts.verifier,
473
+ accessController: verifierAccounts.accessController,
474
+ configAccount: verifierAccounts.config,
463
475
  systemProgram: web3_js_2.SystemProgram.programId,
464
476
  })
465
477
  .instruction();
@@ -671,6 +683,12 @@ class XitadelProgram {
671
683
  spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
672
684
  web3_js_2.SystemProgram.programId,
673
685
  collateralVaultAta,
686
+ params.collateralTokenMint,
687
+ params.priceFeed,
688
+ params.chainlinkProgram,
689
+ params.verifierAccount,
690
+ params.accessController,
691
+ params.configAccount,
674
692
  spl_token_1.TOKEN_PROGRAM_ID,
675
693
  spl_token_1.TOKEN_2022_PROGRAM_ID,
676
694
  eventAuthority,
@@ -690,9 +708,13 @@ class XitadelProgram {
690
708
  addresses: uniqueAddresses.slice(i, i + chunkSize),
691
709
  }));
692
710
  }
711
+ const signedReport = params.signedReport ?? Buffer.alloc(0);
712
+ const signedReportBuf = Buffer.isBuffer(signedReport)
713
+ ? signedReport
714
+ : Buffer.from(signedReport);
693
715
  const configPda = this.getConfigPda();
694
716
  instructions.push(await this.program.methods
695
- .activateLtt()
717
+ .activateLtt(signedReportBuf)
696
718
  .accountsPartial({
697
719
  config: configPda,
698
720
  signer: signer,
@@ -722,6 +744,12 @@ class XitadelProgram {
722
744
  associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
723
745
  systemProgram: web3_js_2.SystemProgram.programId,
724
746
  collateralAta: collateralVaultAta,
747
+ collateralTokenMint: params.collateralTokenMint,
748
+ priceFeed: params.priceFeed,
749
+ chainlinkProgram: params.chainlinkProgram,
750
+ verifierAccount: params.verifierAccount,
751
+ accessController: params.accessController,
752
+ reportConfigAccount: params.configAccount,
725
753
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
726
754
  tokenBProgram: spl_token_1.TOKEN_PROGRAM_ID,
727
755
  token2022Program: spl_token_1.TOKEN_2022_PROGRAM_ID,
@@ -739,15 +767,20 @@ class XitadelProgram {
739
767
  }
740
768
  /**
741
769
  * Maturate an LTT
742
- * @param signer
770
+ * @param signer Keeper/signer public key
743
771
  * @param lttId The LTT ID
744
772
  * @param positionNftMint The position NFT mint
773
+ * @param positionNftMintB The position NFT mint for pool B
745
774
  * @param ammConfig The AMM config
775
+ * @param ammConfigB The AMM config for pool B
746
776
  * @param cpAmmProgramId The CP AMM program ID
747
- * @param params The maturate parameters
777
+ * @param priceFeed Price feed (Chainlink or Switchboard)
778
+ * @param chainLinkProgram Chainlink program ID (required by IDL; use placeholder when not using Chainlink)
779
+ * @param reportBuffer Signed report bytes (empty buffer when not using Chainlink)
780
+ * @param verifierAccounts Chainlink verifier accounts (use placeholder pubkeys when not using Chainlink)
748
781
  * @returns Transaction instruction for maturing the LTT
749
782
  */
750
- async maturateLtt(signer, lttId, positionNftMint, positionNftMintB, ammConfig, ammConfigB, cpAmmProgramId) {
783
+ async maturateLtt(signer, lttId, positionNftMint, positionNftMintB, ammConfig, ammConfigB, cpAmmProgramId, priceFeed, chainLinkProgram, reportBuffer, verifierAccounts) {
751
784
  const lttConfigPda = this.getLTTConfigPda(lttId);
752
785
  const lttConfig = await this.getLttConfig(lttId);
753
786
  const lpAuthority = this.getLpAuthority();
@@ -778,9 +811,59 @@ class XitadelProgram {
778
811
  const [positionNftAccountB] = web3_js_1.PublicKey.findProgramAddressSync([constants_1.POSITION_NFT_ACCOUNT_SEED, positionNftMintB.toBuffer()], cpAmmProgramId);
779
812
  const collateralVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.collateralTokenMint, lttConfigPda, true);
780
813
  const fundingVaultAta = (0, spl_token_1.getAssociatedTokenAddressSync)(lttConfig.fundingTokenMint, lttConfigPda, true);
814
+ const [createLookupTableIx, lookupTableAddress] = web3_js_1.AddressLookupTableProgram.createLookupTable({
815
+ authority: signer,
816
+ payer: signer,
817
+ recentSlot: await this.program.provider.connection.getSlot(),
818
+ });
819
+ const allAddresses = [
820
+ lttConfigPda,
821
+ lpAuthority,
822
+ poolAuthority,
823
+ pool,
824
+ position,
825
+ poolB,
826
+ positionB,
827
+ fundingVaultAta,
828
+ collateralVaultAta,
829
+ lttConfig.collateralTokenMint,
830
+ priceFeed,
831
+ chainLinkProgram,
832
+ verifierAccounts.verifier,
833
+ verifierAccounts.accessController,
834
+ verifierAccounts.config,
835
+ lttTokenAccount,
836
+ stableCoinTokenAccount,
837
+ lttVault,
838
+ stableVault,
839
+ lttVaultB,
840
+ stableVaultB,
841
+ lttId,
842
+ lttConfig.fundingTokenMint,
843
+ positionNftMint,
844
+ positionNftAccount,
845
+ positionNftMintB,
846
+ positionNftAccountB,
847
+ spl_token_1.TOKEN_PROGRAM_ID,
848
+ spl_token_1.TOKEN_PROGRAM_ID,
849
+ eventAuthority,
850
+ cpAmmProgramId,
851
+ ];
852
+ const uniqueAddressesStr = new Set(allAddresses.map(a => a.toBase58()));
853
+ const uniqueAddresses = Array.from(uniqueAddressesStr).map(a => new web3_js_1.PublicKey(a));
854
+ const extendLookupTableIxs = [];
855
+ const chunkSize = 15;
856
+ for (let i = 0; i < uniqueAddresses.length; i += chunkSize) {
857
+ extendLookupTableIxs.push(web3_js_1.AddressLookupTableProgram.extendLookupTable({
858
+ payer: signer,
859
+ authority: signer,
860
+ lookupTable: lookupTableAddress,
861
+ addresses: uniqueAddresses.slice(i, i + chunkSize),
862
+ }));
863
+ }
781
864
  const configPda = this.getConfigPda();
782
865
  const maturateIx = await this.program.methods
783
- .maturate()
866
+ .maturate(Buffer.from(reportBuffer))
784
867
  .accountsPartial({
785
868
  config: configPda,
786
869
  signer,
@@ -793,6 +876,12 @@ class XitadelProgram {
793
876
  positionB,
794
877
  fundingVaultAta,
795
878
  collateralVaultAta,
879
+ collateralTokenMint: lttConfig.collateralTokenMint,
880
+ priceFeed,
881
+ chainlinkProgram: chainLinkProgram,
882
+ verifierAccount: verifierAccounts.verifier,
883
+ accessController: verifierAccounts.accessController,
884
+ configAccount: verifierAccounts.config,
796
885
  tokenAAccount: lttTokenAccount,
797
886
  tokenBAccount: stableCoinTokenAccount,
798
887
  tokenAVault: lttVault,
@@ -811,7 +900,12 @@ class XitadelProgram {
811
900
  cpAmmProgram: cpAmmProgramId,
812
901
  })
813
902
  .instruction();
814
- return maturateIx;
903
+ return {
904
+ maturateIx,
905
+ createLookupTableIx,
906
+ extendLookupTableIx: extendLookupTableIxs,
907
+ lookupTableAddress,
908
+ };
815
909
  }
816
910
  /**
817
911
  * Stop liquidation
@@ -427,6 +427,13 @@
427
427
  }
428
428
  }
429
429
  },
430
+ {
431
+ "name": "collateral_token_mint",
432
+ "writable": true
433
+ },
434
+ {
435
+ "name": "report_config_account"
436
+ },
430
437
  {
431
438
  "name": "pool_config"
432
439
  },
@@ -445,6 +452,18 @@
445
452
  "name": "pool_authority",
446
453
  "writable": true
447
454
  },
455
+ {
456
+ "name": "price_feed"
457
+ },
458
+ {
459
+ "name": "chainlink_program"
460
+ },
461
+ {
462
+ "name": "verifier_account"
463
+ },
464
+ {
465
+ "name": "access_controller"
466
+ },
448
467
  {
449
468
  "name": "event_authority",
450
469
  "writable": true
@@ -489,7 +508,12 @@
489
508
  "address": "SysvarRent111111111111111111111111111111111"
490
509
  }
491
510
  ],
492
- "args": []
511
+ "args": [
512
+ {
513
+ "name": "signed_report",
514
+ "type": "bytes"
515
+ }
516
+ ]
493
517
  },
494
518
  {
495
519
  "name": "claim_fees",
@@ -3556,6 +3580,24 @@
3556
3580
  }
3557
3581
  }
3558
3582
  },
3583
+ {
3584
+ "name": "collateral_token_mint"
3585
+ },
3586
+ {
3587
+ "name": "price_feed"
3588
+ },
3589
+ {
3590
+ "name": "chainlink_program"
3591
+ },
3592
+ {
3593
+ "name": "verifier_account"
3594
+ },
3595
+ {
3596
+ "name": "access_controller"
3597
+ },
3598
+ {
3599
+ "name": "config_account"
3600
+ },
3559
3601
  {
3560
3602
  "name": "token_a_account",
3561
3603
  "docs": [
@@ -3652,7 +3694,12 @@
3652
3694
  "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG"
3653
3695
  }
3654
3696
  ],
3655
- "args": []
3697
+ "args": [
3698
+ {
3699
+ "name": "signed_report",
3700
+ "type": "bytes"
3701
+ }
3702
+ ]
3656
3703
  },
3657
3704
  {
3658
3705
  "name": "redeem",
@@ -4709,6 +4756,10 @@
4709
4756
  104
4710
4757
  ],
4711
4758
  "accounts": [
4759
+ {
4760
+ "name": "signer",
4761
+ "signer": true
4762
+ },
4712
4763
  {
4713
4764
  "name": "config",
4714
4765
  "pda": {
@@ -4941,12 +4992,35 @@
4941
4992
  "name": "funding_token_mint",
4942
4993
  "writable": true
4943
4994
  },
4995
+ {
4996
+ "name": "collateral_token_mint"
4997
+ },
4998
+ {
4999
+ "name": "price_feed"
5000
+ },
5001
+ {
5002
+ "name": "chainlink_program"
5003
+ },
5004
+ {
5005
+ "name": "verifier_account"
5006
+ },
5007
+ {
5008
+ "name": "access_controller"
5009
+ },
5010
+ {
5011
+ "name": "config_account"
5012
+ },
4944
5013
  {
4945
5014
  "name": "system_program",
4946
5015
  "address": "11111111111111111111111111111111"
4947
5016
  }
4948
5017
  ],
4949
- "args": []
5018
+ "args": [
5019
+ {
5020
+ "name": "signed_report",
5021
+ "type": "bytes"
5022
+ }
5023
+ ]
4950
5024
  },
4951
5025
  {
4952
5026
  "name": "withdraw_collateral",
@@ -6011,8 +6085,13 @@
6011
6085
  "type": "u64"
6012
6086
  },
6013
6087
  {
6014
- "name": "collateral_amount",
6015
- "type": "u64"
6088
+ "name": "reserved_1",
6089
+ "type": {
6090
+ "array": [
6091
+ "u8",
6092
+ 8
6093
+ ]
6094
+ }
6016
6095
  },
6017
6096
  {
6018
6097
  "name": "stable_interest_amount",
@@ -6138,10 +6217,6 @@
6138
6217
  "name": "max_allowed_ltv_pct",
6139
6218
  "type": "u64"
6140
6219
  },
6141
- {
6142
- "name": "collateral_amount",
6143
- "type": "u64"
6144
- },
6145
6220
  {
6146
6221
  "name": "issuer",
6147
6222
  "type": "pubkey"
@@ -433,6 +433,13 @@ export type Xitadel = {
433
433
  };
434
434
  };
435
435
  },
436
+ {
437
+ "name": "collateralTokenMint";
438
+ "writable": true;
439
+ },
440
+ {
441
+ "name": "reportConfigAccount";
442
+ },
436
443
  {
437
444
  "name": "poolConfig";
438
445
  },
@@ -451,6 +458,18 @@ export type Xitadel = {
451
458
  "name": "poolAuthority";
452
459
  "writable": true;
453
460
  },
461
+ {
462
+ "name": "priceFeed";
463
+ },
464
+ {
465
+ "name": "chainlinkProgram";
466
+ },
467
+ {
468
+ "name": "verifierAccount";
469
+ },
470
+ {
471
+ "name": "accessController";
472
+ },
454
473
  {
455
474
  "name": "eventAuthority";
456
475
  "writable": true;
@@ -495,7 +514,12 @@ export type Xitadel = {
495
514
  "address": "SysvarRent111111111111111111111111111111111";
496
515
  }
497
516
  ];
498
- "args": [];
517
+ "args": [
518
+ {
519
+ "name": "signedReport";
520
+ "type": "bytes";
521
+ }
522
+ ];
499
523
  },
500
524
  {
501
525
  "name": "claimFees";
@@ -3562,6 +3586,24 @@ export type Xitadel = {
3562
3586
  };
3563
3587
  };
3564
3588
  },
3589
+ {
3590
+ "name": "collateralTokenMint";
3591
+ },
3592
+ {
3593
+ "name": "priceFeed";
3594
+ },
3595
+ {
3596
+ "name": "chainlinkProgram";
3597
+ },
3598
+ {
3599
+ "name": "verifierAccount";
3600
+ },
3601
+ {
3602
+ "name": "accessController";
3603
+ },
3604
+ {
3605
+ "name": "configAccount";
3606
+ },
3565
3607
  {
3566
3608
  "name": "tokenAAccount";
3567
3609
  "docs": [
@@ -3658,7 +3700,12 @@ export type Xitadel = {
3658
3700
  "address": "cpamdpZCGKUy5JxQXB4dcpGPiikHawvSWAd6mEn1sGG";
3659
3701
  }
3660
3702
  ];
3661
- "args": [];
3703
+ "args": [
3704
+ {
3705
+ "name": "signedReport";
3706
+ "type": "bytes";
3707
+ }
3708
+ ];
3662
3709
  },
3663
3710
  {
3664
3711
  "name": "redeem";
@@ -4715,6 +4762,10 @@ export type Xitadel = {
4715
4762
  104
4716
4763
  ];
4717
4764
  "accounts": [
4765
+ {
4766
+ "name": "signer";
4767
+ "signer": true;
4768
+ },
4718
4769
  {
4719
4770
  "name": "config";
4720
4771
  "pda": {
@@ -4947,12 +4998,35 @@ export type Xitadel = {
4947
4998
  "name": "fundingTokenMint";
4948
4999
  "writable": true;
4949
5000
  },
5001
+ {
5002
+ "name": "collateralTokenMint";
5003
+ },
5004
+ {
5005
+ "name": "priceFeed";
5006
+ },
5007
+ {
5008
+ "name": "chainlinkProgram";
5009
+ },
5010
+ {
5011
+ "name": "verifierAccount";
5012
+ },
5013
+ {
5014
+ "name": "accessController";
5015
+ },
5016
+ {
5017
+ "name": "configAccount";
5018
+ },
4950
5019
  {
4951
5020
  "name": "systemProgram";
4952
5021
  "address": "11111111111111111111111111111111";
4953
5022
  }
4954
5023
  ];
4955
- "args": [];
5024
+ "args": [
5025
+ {
5026
+ "name": "signedReport";
5027
+ "type": "bytes";
5028
+ }
5029
+ ];
4956
5030
  },
4957
5031
  {
4958
5032
  "name": "withdrawCollateral";
@@ -6017,8 +6091,13 @@ export type Xitadel = {
6017
6091
  "type": "u64";
6018
6092
  },
6019
6093
  {
6020
- "name": "collateralAmount";
6021
- "type": "u64";
6094
+ "name": "reserved1";
6095
+ "type": {
6096
+ "array": [
6097
+ "u8",
6098
+ 8
6099
+ ];
6100
+ };
6022
6101
  },
6023
6102
  {
6024
6103
  "name": "stableInterestAmount";
@@ -6144,10 +6223,6 @@ export type Xitadel = {
6144
6223
  "name": "maxAllowedLtvPct";
6145
6224
  "type": "u64";
6146
6225
  },
6147
- {
6148
- "name": "collateralAmount";
6149
- "type": "u64";
6150
- },
6151
6226
  {
6152
6227
  "name": "issuer";
6153
6228
  "type": "pubkey";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@xitadel-fi/sdk",
4
- "version": "0.2.2",
4
+ "version": "0.2.4",
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",