@0dotxyz/p0-ts-sdk 2.4.0 → 2.4.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.
@@ -51,6 +51,10 @@ interface KaminoReserveConfig {
51
51
  protocolTakeRatePct: number;
52
52
  /** Flat rate that goes to the host */
53
53
  hostFixedInterestRateBps: number;
54
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
55
+ depositLimit: BN;
56
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
57
+ borrowLimit: BN;
54
58
  /** Borrow rate curve based on utilization */
55
59
  borrowRateCurve: KaminoBorrowRateCurve;
56
60
  /** Oracle configurations */
@@ -114,6 +118,8 @@ interface KaminoReserveCollateralJSON {
114
118
  interface KaminoReserveConfigJSON {
115
119
  protocolTakeRatePct: number;
116
120
  hostFixedInterestRateBps: number;
121
+ depositLimit: string;
122
+ borrowLimit: string;
117
123
  borrowRateCurve: KaminoBorrowRateCurveJSON;
118
124
  tokenInfo: KaminoReserveTokenInfoJSON;
119
125
  }
@@ -210,6 +216,8 @@ interface KaminoFarmTokenInfo {
210
216
  }
211
217
  interface KaminoFarmRewardInfo {
212
218
  token: KaminoFarmTokenInfo;
219
+ /** Amount of rewards remaining in the rewards vault */
220
+ rewardsAvailable: BN;
213
221
  rewardsPerSecondDecimals: number;
214
222
  rewardScheduleCurve: KaminoRewardScheduleCurve;
215
223
  }
@@ -240,6 +248,7 @@ interface KaminoFarmTokenInfoJSON {
240
248
  }
241
249
  interface KaminoFarmRewardInfoJSON {
242
250
  token: KaminoFarmTokenInfoJSON;
251
+ rewardsAvailable: string;
243
252
  rewardsPerSecondDecimals: number;
244
253
  rewardScheduleCurve: KaminoRewardScheduleCurveJSON;
245
254
  }
@@ -743,48 +752,32 @@ interface JupLendingState {
743
752
  */
744
753
  interface JupTokenReserve {
745
754
  pubkey: PublicKey;
746
- mint: PublicKey;
747
- vault: PublicKey;
748
755
  borrowRate: number;
749
756
  feeOnInterest: number;
750
757
  lastUtilization: number;
751
- lastUpdateTimestamp: BN;
752
758
  supplyExchangePrice: BN;
753
759
  borrowExchangePrice: BN;
754
- maxUtilization: number;
755
760
  totalSupplyWithInterest: BN;
756
761
  totalSupplyInterestFree: BN;
757
762
  totalBorrowWithInterest: BN;
758
763
  totalBorrowInterestFree: BN;
759
- totalClaimAmount: BN;
760
- interactingProtocol: PublicKey;
761
- interactingTimestamp: BN;
762
- interactingBalance: BN;
763
764
  }
764
765
 
765
766
  /**
766
- * JSON-serializable DTO for the TokenReserve account.
767
+ * JSON-serializable DTO for the curated TokenReserve.
767
768
  * PublicKey → string, BN → string.
768
769
  */
769
770
  interface JupTokenReserveJSON {
770
771
  pubkey: string;
771
- mint: string;
772
- vault: string;
773
772
  borrowRate: number;
774
773
  feeOnInterest: number;
775
774
  lastUtilization: number;
776
- lastUpdateTimestamp: string;
777
775
  supplyExchangePrice: string;
778
776
  borrowExchangePrice: string;
779
- maxUtilization: number;
780
777
  totalSupplyWithInterest: string;
781
778
  totalSupplyInterestFree: string;
782
779
  totalBorrowWithInterest: string;
783
780
  totalBorrowInterestFree: string;
784
- totalClaimAmount: string;
785
- interactingProtocol: string;
786
- interactingTimestamp: string;
787
- interactingBalance: string;
788
781
  }
789
782
 
790
783
  /**
@@ -793,9 +786,6 @@ interface JupTokenReserveJSON {
793
786
  * Controls the rewards distribution parameters for a jup-lend market.
794
787
  */
795
788
  interface JupLendingRewardsRateModel {
796
- pubkey: PublicKey;
797
- /** Mint address */
798
- mint: PublicKey;
799
789
  /** TVL below which rewards rate is 0 */
800
790
  startTvl: BN;
801
791
  /** Duration for which current rewards should run */
@@ -804,34 +794,25 @@ interface JupLendingRewardsRateModel {
804
794
  startTime: BN;
805
795
  /** Annualized reward based on input params (duration, rewardAmount) */
806
796
  yearlyReward: BN;
807
- /** Duration for the next rewards phase */
808
- nextDuration: BN;
809
- /** Amount of rewards for the next phase */
810
- nextRewardAmount: BN;
811
797
  }
812
798
 
813
799
  /**
814
- * JSON-serializable DTO for the LendingRewardsRateModel account.
815
- * PublicKey → string, BN → string.
800
+ * JSON-serializable DTO for the curated LendingRewardsRateModel.
801
+ * BN → string.
816
802
  */
817
803
  interface JupLendingRewardsRateModelJSON {
818
- pubkey: string;
819
- mint: string;
820
804
  startTvl: string;
821
805
  duration: string;
822
806
  startTime: string;
823
807
  yearlyReward: string;
824
- nextDuration: string;
825
- nextRewardAmount: string;
826
- bump?: number;
827
808
  }
828
809
 
829
810
  /**
830
- * Curated RateModel identical to raw since all fields are primitives + PublicKey.
811
+ * Curated RateModel used throughout the codebase.
812
+ *
813
+ * Interest-rate curve parameters (all bps values).
831
814
  */
832
815
  interface JupRateModel {
833
- pubkey: PublicKey;
834
- mint: PublicKey;
835
816
  version: number;
836
817
  rateAtZero: number;
837
818
  kink1Utilization: number;
@@ -842,12 +823,9 @@ interface JupRateModel {
842
823
  }
843
824
 
844
825
  /**
845
- * JSON-serializable DTO for the RateModel account.
846
- * PublicKey → string.
826
+ * JSON-serializable DTO for the curated RateModel.
847
827
  */
848
828
  interface JupRateModelJSON {
849
- pubkey: string;
850
- mint: string;
851
829
  version: number;
852
830
  rateAtZero: number;
853
831
  kink1Utilization: number;
@@ -51,6 +51,10 @@ interface KaminoReserveConfig {
51
51
  protocolTakeRatePct: number;
52
52
  /** Flat rate that goes to the host */
53
53
  hostFixedInterestRateBps: number;
54
+ /** Maximum deposit limit of liquidity in native units, u64::MAX for inf */
55
+ depositLimit: BN;
56
+ /** Maximum amount borrowed, u64::MAX for inf, 0 to disable borrows (protected deposits) */
57
+ borrowLimit: BN;
54
58
  /** Borrow rate curve based on utilization */
55
59
  borrowRateCurve: KaminoBorrowRateCurve;
56
60
  /** Oracle configurations */
@@ -114,6 +118,8 @@ interface KaminoReserveCollateralJSON {
114
118
  interface KaminoReserveConfigJSON {
115
119
  protocolTakeRatePct: number;
116
120
  hostFixedInterestRateBps: number;
121
+ depositLimit: string;
122
+ borrowLimit: string;
117
123
  borrowRateCurve: KaminoBorrowRateCurveJSON;
118
124
  tokenInfo: KaminoReserveTokenInfoJSON;
119
125
  }
@@ -210,6 +216,8 @@ interface KaminoFarmTokenInfo {
210
216
  }
211
217
  interface KaminoFarmRewardInfo {
212
218
  token: KaminoFarmTokenInfo;
219
+ /** Amount of rewards remaining in the rewards vault */
220
+ rewardsAvailable: BN;
213
221
  rewardsPerSecondDecimals: number;
214
222
  rewardScheduleCurve: KaminoRewardScheduleCurve;
215
223
  }
@@ -240,6 +248,7 @@ interface KaminoFarmTokenInfoJSON {
240
248
  }
241
249
  interface KaminoFarmRewardInfoJSON {
242
250
  token: KaminoFarmTokenInfoJSON;
251
+ rewardsAvailable: string;
243
252
  rewardsPerSecondDecimals: number;
244
253
  rewardScheduleCurve: KaminoRewardScheduleCurveJSON;
245
254
  }
@@ -743,48 +752,32 @@ interface JupLendingState {
743
752
  */
744
753
  interface JupTokenReserve {
745
754
  pubkey: PublicKey;
746
- mint: PublicKey;
747
- vault: PublicKey;
748
755
  borrowRate: number;
749
756
  feeOnInterest: number;
750
757
  lastUtilization: number;
751
- lastUpdateTimestamp: BN;
752
758
  supplyExchangePrice: BN;
753
759
  borrowExchangePrice: BN;
754
- maxUtilization: number;
755
760
  totalSupplyWithInterest: BN;
756
761
  totalSupplyInterestFree: BN;
757
762
  totalBorrowWithInterest: BN;
758
763
  totalBorrowInterestFree: BN;
759
- totalClaimAmount: BN;
760
- interactingProtocol: PublicKey;
761
- interactingTimestamp: BN;
762
- interactingBalance: BN;
763
764
  }
764
765
 
765
766
  /**
766
- * JSON-serializable DTO for the TokenReserve account.
767
+ * JSON-serializable DTO for the curated TokenReserve.
767
768
  * PublicKey → string, BN → string.
768
769
  */
769
770
  interface JupTokenReserveJSON {
770
771
  pubkey: string;
771
- mint: string;
772
- vault: string;
773
772
  borrowRate: number;
774
773
  feeOnInterest: number;
775
774
  lastUtilization: number;
776
- lastUpdateTimestamp: string;
777
775
  supplyExchangePrice: string;
778
776
  borrowExchangePrice: string;
779
- maxUtilization: number;
780
777
  totalSupplyWithInterest: string;
781
778
  totalSupplyInterestFree: string;
782
779
  totalBorrowWithInterest: string;
783
780
  totalBorrowInterestFree: string;
784
- totalClaimAmount: string;
785
- interactingProtocol: string;
786
- interactingTimestamp: string;
787
- interactingBalance: string;
788
781
  }
789
782
 
790
783
  /**
@@ -793,9 +786,6 @@ interface JupTokenReserveJSON {
793
786
  * Controls the rewards distribution parameters for a jup-lend market.
794
787
  */
795
788
  interface JupLendingRewardsRateModel {
796
- pubkey: PublicKey;
797
- /** Mint address */
798
- mint: PublicKey;
799
789
  /** TVL below which rewards rate is 0 */
800
790
  startTvl: BN;
801
791
  /** Duration for which current rewards should run */
@@ -804,34 +794,25 @@ interface JupLendingRewardsRateModel {
804
794
  startTime: BN;
805
795
  /** Annualized reward based on input params (duration, rewardAmount) */
806
796
  yearlyReward: BN;
807
- /** Duration for the next rewards phase */
808
- nextDuration: BN;
809
- /** Amount of rewards for the next phase */
810
- nextRewardAmount: BN;
811
797
  }
812
798
 
813
799
  /**
814
- * JSON-serializable DTO for the LendingRewardsRateModel account.
815
- * PublicKey → string, BN → string.
800
+ * JSON-serializable DTO for the curated LendingRewardsRateModel.
801
+ * BN → string.
816
802
  */
817
803
  interface JupLendingRewardsRateModelJSON {
818
- pubkey: string;
819
- mint: string;
820
804
  startTvl: string;
821
805
  duration: string;
822
806
  startTime: string;
823
807
  yearlyReward: string;
824
- nextDuration: string;
825
- nextRewardAmount: string;
826
- bump?: number;
827
808
  }
828
809
 
829
810
  /**
830
- * Curated RateModel identical to raw since all fields are primitives + PublicKey.
811
+ * Curated RateModel used throughout the codebase.
812
+ *
813
+ * Interest-rate curve parameters (all bps values).
831
814
  */
832
815
  interface JupRateModel {
833
- pubkey: PublicKey;
834
- mint: PublicKey;
835
816
  version: number;
836
817
  rateAtZero: number;
837
818
  kink1Utilization: number;
@@ -842,12 +823,9 @@ interface JupRateModel {
842
823
  }
843
824
 
844
825
  /**
845
- * JSON-serializable DTO for the RateModel account.
846
- * PublicKey → string.
826
+ * JSON-serializable DTO for the curated RateModel.
847
827
  */
848
828
  interface JupRateModelJSON {
849
- pubkey: string;
850
- mint: string;
851
829
  version: number;
852
830
  rateAtZero: number;
853
831
  kink1Utilization: number;
package/dist/index.cjs CHANGED
@@ -36493,6 +36493,8 @@ function kaminoReserveToDto(reserve) {
36493
36493
  config: {
36494
36494
  protocolTakeRatePct: reserve.config.protocolTakeRatePct,
36495
36495
  hostFixedInterestRateBps: reserve.config.hostFixedInterestRateBps,
36496
+ depositLimit: reserve.config.depositLimit.toString(),
36497
+ borrowLimit: reserve.config.borrowLimit.toString(),
36496
36498
  borrowRateCurve: {
36497
36499
  points: reserve.config.borrowRateCurve.points.map((item) => ({
36498
36500
  utilizationRateBps: item.utilizationRateBps,
@@ -43013,12 +43015,13 @@ function dtoToKaminoObligation(obligationDto) {
43013
43015
  return {
43014
43016
  lendingMarket: new web3_js.PublicKey(obligationDto.lendingMarket),
43015
43017
  owner: new web3_js.PublicKey(obligationDto.owner),
43016
- deposits: obligationDto.deposits.map((item) => ({
43018
+ // Hosted endpoints may prune empty position arrays from the payload
43019
+ deposits: (obligationDto.deposits ?? []).map((item) => ({
43017
43020
  depositReserve: new web3_js.PublicKey(item.depositReserve),
43018
43021
  depositedAmount: new BN8__default.default(item.depositedAmount),
43019
43022
  marketValueSf: new BN8__default.default(item.marketValueSf)
43020
43023
  })),
43021
- borrows: obligationDto.borrows.map((item) => ({
43024
+ borrows: (obligationDto.borrows ?? []).map((item) => ({
43022
43025
  borrowReserve: new web3_js.PublicKey(item.borrowReserve),
43023
43026
  borrowedAmountSf: new BN8__default.default(item.borrowedAmountSf),
43024
43027
  marketValueSf: new BN8__default.default(item.marketValueSf)
@@ -43051,6 +43054,8 @@ function dtoToKaminoReserve(reserveDto) {
43051
43054
  config: {
43052
43055
  protocolTakeRatePct: reserveDto.config.protocolTakeRatePct,
43053
43056
  hostFixedInterestRateBps: reserveDto.config.hostFixedInterestRateBps,
43057
+ depositLimit: new BN8__default.default(reserveDto.config.depositLimit),
43058
+ borrowLimit: new BN8__default.default(reserveDto.config.borrowLimit),
43054
43059
  borrowRateCurve: {
43055
43060
  points: reserveDto.config.borrowRateCurve.points.map((item) => ({
43056
43061
  utilizationRateBps: item.utilizationRateBps,
@@ -43695,41 +43700,27 @@ function jupLendingStateRawToDto(raw) {
43695
43700
  function jupTokenReserveRawToDto(raw) {
43696
43701
  return {
43697
43702
  pubkey: raw.pubkey.toBase58(),
43698
- mint: raw.mint.toBase58(),
43699
- vault: raw.vault.toBase58(),
43700
43703
  borrowRate: raw.borrowRate,
43701
43704
  feeOnInterest: raw.feeOnInterest,
43702
43705
  lastUtilization: raw.lastUtilization,
43703
- lastUpdateTimestamp: raw.lastUpdateTimestamp.toString(),
43704
43706
  supplyExchangePrice: raw.supplyExchangePrice.toString(),
43705
43707
  borrowExchangePrice: raw.borrowExchangePrice.toString(),
43706
- maxUtilization: raw.maxUtilization,
43707
43708
  totalSupplyWithInterest: raw.totalSupplyWithInterest.toString(),
43708
43709
  totalSupplyInterestFree: raw.totalSupplyInterestFree.toString(),
43709
43710
  totalBorrowWithInterest: raw.totalBorrowWithInterest.toString(),
43710
- totalBorrowInterestFree: raw.totalBorrowInterestFree.toString(),
43711
- totalClaimAmount: raw.totalClaimAmount.toString(),
43712
- interactingProtocol: raw.interactingProtocol.toBase58(),
43713
- interactingTimestamp: raw.interactingTimestamp.toString(),
43714
- interactingBalance: raw.interactingBalance.toString()
43711
+ totalBorrowInterestFree: raw.totalBorrowInterestFree.toString()
43715
43712
  };
43716
43713
  }
43717
43714
  function jupLendingRewardsRateModelRawToDto(raw) {
43718
43715
  return {
43719
- pubkey: raw.pubkey.toBase58(),
43720
- mint: raw.mint.toBase58(),
43721
43716
  startTvl: raw.startTvl.toString(),
43722
43717
  duration: raw.duration.toString(),
43723
43718
  startTime: raw.startTime.toString(),
43724
- yearlyReward: raw.yearlyReward.toString(),
43725
- nextDuration: raw.nextDuration.toString(),
43726
- nextRewardAmount: raw.nextRewardAmount.toString()
43719
+ yearlyReward: raw.yearlyReward.toString()
43727
43720
  };
43728
43721
  }
43729
43722
  function jupRateModelRawToDto(raw) {
43730
43723
  return {
43731
- pubkey: raw.pubkey.toBase58(),
43732
- mint: raw.mint.toBase58(),
43733
43724
  version: raw.version,
43734
43725
  rateAtZero: raw.rateAtZero,
43735
43726
  kink1Utilization: raw.kink1Utilization,
@@ -43886,41 +43877,27 @@ function dtoToJupLendingStateRaw(dto) {
43886
43877
  function dtoToJupTokenReserveRaw(dto) {
43887
43878
  return {
43888
43879
  pubkey: new web3_js.PublicKey(dto.pubkey),
43889
- mint: new web3_js.PublicKey(dto.mint),
43890
- vault: new web3_js.PublicKey(dto.vault),
43891
43880
  borrowRate: dto.borrowRate,
43892
43881
  feeOnInterest: dto.feeOnInterest,
43893
43882
  lastUtilization: dto.lastUtilization,
43894
- lastUpdateTimestamp: new BN8__default.default(dto.lastUpdateTimestamp),
43895
43883
  supplyExchangePrice: new BN8__default.default(dto.supplyExchangePrice),
43896
43884
  borrowExchangePrice: new BN8__default.default(dto.borrowExchangePrice),
43897
- maxUtilization: dto.maxUtilization,
43898
43885
  totalSupplyWithInterest: new BN8__default.default(dto.totalSupplyWithInterest),
43899
43886
  totalSupplyInterestFree: new BN8__default.default(dto.totalSupplyInterestFree),
43900
43887
  totalBorrowWithInterest: new BN8__default.default(dto.totalBorrowWithInterest),
43901
- totalBorrowInterestFree: new BN8__default.default(dto.totalBorrowInterestFree),
43902
- totalClaimAmount: new BN8__default.default(dto.totalClaimAmount),
43903
- interactingProtocol: new web3_js.PublicKey(dto.interactingProtocol),
43904
- interactingTimestamp: new BN8__default.default(dto.interactingTimestamp),
43905
- interactingBalance: new BN8__default.default(dto.interactingBalance)
43888
+ totalBorrowInterestFree: new BN8__default.default(dto.totalBorrowInterestFree)
43906
43889
  };
43907
43890
  }
43908
43891
  function dtoToJupLendingRewardsRateModelRaw(dto) {
43909
43892
  return {
43910
- pubkey: new web3_js.PublicKey(dto.pubkey),
43911
- mint: new web3_js.PublicKey(dto.mint),
43912
43893
  startTvl: new BN8__default.default(dto.startTvl),
43913
43894
  duration: new BN8__default.default(dto.duration),
43914
43895
  startTime: new BN8__default.default(dto.startTime),
43915
- yearlyReward: new BN8__default.default(dto.yearlyReward),
43916
- nextDuration: new BN8__default.default(dto.nextDuration),
43917
- nextRewardAmount: new BN8__default.default(dto.nextRewardAmount)
43896
+ yearlyReward: new BN8__default.default(dto.yearlyReward)
43918
43897
  };
43919
43898
  }
43920
43899
  function dtoToJupRateModelRaw(dto) {
43921
43900
  return {
43922
- pubkey: new web3_js.PublicKey(dto.pubkey),
43923
- mint: new web3_js.PublicKey(dto.mint),
43924
43901
  version: dto.version,
43925
43902
  rateAtZero: dto.rateAtZero,
43926
43903
  kink1Utilization: dto.kink1Utilization,
@@ -57904,6 +57881,7 @@ function kaminoFarmStateToDto(farmState) {
57904
57881
  mint: item.token.mint.toBase58(),
57905
57882
  decimals: item.token.decimals.toString()
57906
57883
  },
57884
+ rewardsAvailable: item.rewardsAvailable.toString(),
57907
57885
  rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
57908
57886
  rewardScheduleCurve: {
57909
57887
  points: item.rewardScheduleCurve.points.map((p) => ({
@@ -58017,6 +57995,7 @@ function dtoToKaminoFarmState(dto) {
58017
57995
  mint: new web3_js.PublicKey(item.token.mint),
58018
57996
  decimals: new BN8__default.default(item.token.decimals)
58019
57997
  },
57998
+ rewardsAvailable: new BN8__default.default(item.rewardsAvailable),
58020
57999
  rewardsPerSecondDecimals: item.rewardsPerSecondDecimals,
58021
58000
  rewardScheduleCurve: {
58022
58001
  points: item.rewardScheduleCurve.points.map((p) => ({