@kamino-finance/klend-sdk 2.10.21 → 2.11.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.
Files changed (57) hide show
  1. package/dist/classes/action.d.ts +1 -0
  2. package/dist/classes/action.js +55 -38
  3. package/dist/classes/action.js.map +1 -1
  4. package/dist/classes/obligation.js +21 -0
  5. package/dist/classes/obligation.js.map +1 -1
  6. package/dist/classes/reserve.d.ts +30 -0
  7. package/dist/classes/reserve.js +66 -6
  8. package/dist/classes/reserve.js.map +1 -1
  9. package/dist/idl.json +156 -72
  10. package/dist/idl_codegen/accounts/LendingMarket.d.ts +3 -3
  11. package/dist/idl_codegen/accounts/LendingMarket.js +7 -1
  12. package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
  13. package/dist/idl_codegen/accounts/Obligation.d.ts +6 -3
  14. package/dist/idl_codegen/accounts/Obligation.js +12 -6
  15. package/dist/idl_codegen/accounts/Obligation.js.map +1 -1
  16. package/dist/idl_codegen/accounts/Reserve.d.ts +18 -0
  17. package/dist/idl_codegen/accounts/Reserve.js +14 -2
  18. package/dist/idl_codegen/accounts/Reserve.js.map +1 -1
  19. package/dist/idl_codegen/errors/custom.d.ts +76 -4
  20. package/dist/idl_codegen/errors/custom.js +126 -8
  21. package/dist/idl_codegen/errors/custom.js.map +1 -1
  22. package/dist/idl_codegen/instructions/index.d.ts +2 -4
  23. package/dist/idl_codegen/instructions/index.js +3 -5
  24. package/dist/idl_codegen/instructions/index.js.map +1 -1
  25. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.d.ts +1 -1
  26. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js +2 -2
  27. package/dist/idl_codegen/instructions/liquidateObligationAndRedeemReserveCollateral.js.map +1 -1
  28. package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +2 -1
  29. package/dist/idl_codegen/instructions/updateReserveConfig.js +4 -2
  30. package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
  31. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js +1 -1
  32. package/dist/idl_codegen/instructions/withdrawObligationCollateral.js.map +1 -1
  33. package/dist/idl_codegen/types/ElevationGroup.d.ts +24 -10
  34. package/dist/idl_codegen/types/ElevationGroup.js +25 -12
  35. package/dist/idl_codegen/types/ElevationGroup.js.map +1 -1
  36. package/dist/idl_codegen/types/ObligationCollateral.d.ts +23 -0
  37. package/dist/idl_codegen/types/ObligationCollateral.js +8 -1
  38. package/dist/idl_codegen/types/ObligationCollateral.js.map +1 -1
  39. package/dist/idl_codegen/types/ObligationLiquidity.d.ts +8 -0
  40. package/dist/idl_codegen/types/ObligationLiquidity.js +8 -1
  41. package/dist/idl_codegen/types/ObligationLiquidity.js.map +1 -1
  42. package/dist/idl_codegen/types/ReserveConfig.d.ts +55 -9
  43. package/dist/idl_codegen/types/ReserveConfig.js +20 -6
  44. package/dist/idl_codegen/types/ReserveConfig.js.map +1 -1
  45. package/dist/idl_codegen/types/UpdateConfigMode.d.ts +39 -0
  46. package/dist/idl_codegen/types/UpdateConfigMode.js +79 -1
  47. package/dist/idl_codegen/types/UpdateConfigMode.js.map +1 -1
  48. package/dist/idl_codegen/types/UpdateLendingMarketConfigValue.d.ts +4 -2
  49. package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +13 -0
  50. package/dist/idl_codegen/types/UpdateLendingMarketMode.js +27 -1
  51. package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
  52. package/dist/idl_codegen/types/index.d.ts +4 -4
  53. package/dist/idl_codegen/types/index.js.map +1 -1
  54. package/dist/idl_codegen/zero_padding/ObligationZP.d.ts +3 -2
  55. package/dist/idl_codegen/zero_padding/ObligationZP.js +8 -3
  56. package/dist/idl_codegen/zero_padding/ObligationZP.js.map +1 -1
  57. package/package.json +1 -1
@@ -67,6 +67,8 @@ class LendingMarket {
67
67
  this.elevationGroups = fields.elevationGroups.map((item) => new types.ElevationGroup(Object.assign({}, item)));
68
68
  this.elevationGroupPadding = fields.elevationGroupPadding;
69
69
  this.minNetValueInObligationSf = fields.minNetValueInObligationSf;
70
+ this.minValueSkipLiquidationLtvBfChecks =
71
+ fields.minValueSkipLiquidationLtvBfChecks;
70
72
  this.padding1 = fields.padding1;
71
73
  }
72
74
  static fetch(c, address, programId = programId_1.PROGRAM_ID) {
@@ -122,6 +124,7 @@ class LendingMarket {
122
124
  elevationGroups: dec.elevationGroups.map((item /* eslint-disable-line @typescript-eslint/no-explicit-any */) => types.ElevationGroup.fromDecoded(item)),
123
125
  elevationGroupPadding: dec.elevationGroupPadding,
124
126
  minNetValueInObligationSf: dec.minNetValueInObligationSf,
127
+ minValueSkipLiquidationLtvBfChecks: dec.minValueSkipLiquidationLtvBfChecks,
125
128
  padding1: dec.padding1,
126
129
  });
127
130
  }
@@ -148,6 +151,7 @@ class LendingMarket {
148
151
  elevationGroups: this.elevationGroups.map((item) => item.toJSON()),
149
152
  elevationGroupPadding: this.elevationGroupPadding.map((item) => item.toString()),
150
153
  minNetValueInObligationSf: this.minNetValueInObligationSf.toString(),
154
+ minValueSkipLiquidationLtvBfChecks: this.minValueSkipLiquidationLtvBfChecks.toString(),
151
155
  padding1: this.padding1.map((item) => item.toString()),
152
156
  };
153
157
  }
@@ -174,6 +178,7 @@ class LendingMarket {
174
178
  elevationGroups: obj.elevationGroups.map((item) => types.ElevationGroup.fromJSON(item)),
175
179
  elevationGroupPadding: obj.elevationGroupPadding.map((item) => new bn_js_1.default(item)),
176
180
  minNetValueInObligationSf: new bn_js_1.default(obj.minNetValueInObligationSf),
181
+ minValueSkipLiquidationLtvBfChecks: new bn_js_1.default(obj.minValueSkipLiquidationLtvBfChecks),
177
182
  padding1: obj.padding1.map((item) => new bn_js_1.default(item)),
178
183
  });
179
184
  }
@@ -204,6 +209,7 @@ LendingMarket.layout = borsh.struct([
204
209
  borsh.array(types.ElevationGroup.layout(), 32, "elevationGroups"),
205
210
  borsh.array(borsh.u64(), 90, "elevationGroupPadding"),
206
211
  borsh.u128("minNetValueInObligationSf"),
207
- borsh.array(borsh.u64(), 178, "padding1"),
212
+ borsh.u64("minValueSkipLiquidationLtvBfChecks"),
213
+ borsh.array(borsh.u64(), 177, "padding1"),
208
214
  ]);
209
215
  //# sourceMappingURL=LendingMarket.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LendingMarket.js","sourceRoot":"","sources":["../../../src/idl_codegen/accounts/LendingMarket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,kDAAsB,CAAC,wDAAwD;AAC/E,wDAAyC,CAAC,wDAAwD;AAClG,gDAAiC,CAAC,wDAAwD;AAC1F,4CAAyC;AAsGzC,MAAa,aAAa;IA8ExB,YAAY,MAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;QAC/B,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAA;QACnD,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAA;QAC/D,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAA;QACzD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,8BAA8B,GAAG,MAAM,CAAC,8BAA8B,CAAA;QAC3E,IAAI,CAAC,gCAAgC;YACnC,MAAM,CAAC,gCAAgC,CAAA;QACzC,IAAI,CAAC,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAA;QACzE,IAAI,CAAC,gCAAgC;YACnC,MAAM,CAA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KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,eAAe,CAAC;IAC5C,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC3B,KAAK,CAAC,EAAE,CAAC,eAAe,CAAC;IACzB,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,CAAC,gCAAgC,CAAC;IAC1C,KAAK,CAAC,EAAE,CAAC,kCAAkC,CAAC;IAC5C,KAAK,CAAC,EAAE,CAAC,+BAA+B,CAAC;IACzC,KAAK,CAAC,GAAG,CAAC,kCAAkC,CAAC;IAC7C,KAAK,CAAC,GAAG,CAAC,sCAAsC,CAAC;IACjD,KAAK,CAAC,GAAG,CAAC,4BAA4B,CAAC;IACvC,KAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC;IAC9B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,0BAA0B,CAAC;IACtD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,iBAAiB,CAAC;IACjE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,uBAAuB,CAAC;IACrD,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC;IACvC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC;CAC1C,CAAC,CAAA","sourcesContent":["import { PublicKey, Connection } from \"@solana/web3.js\"\nimport BN from \"bn.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface LendingMarketFields {\n /** Version of lending market */\n version: BN\n /** Bump seed for derived authority address */\n bumpSeed: BN\n /** Owner authority which can add new reserves */\n lendingMarketOwner: PublicKey\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n lendingMarketOwnerCached: PublicKey\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n referralFeeBps: number\n emergencyMode: number\n autodeleverageEnabled: number\n /** Padding used for alignment */\n borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n minFullLiquidationValueThreshold: BN\n /** Max allowed liquidation value in one ix call */\n maxLiquidatableDebtMarketValueAtOnce: BN\n /** Global maximum unhealthy borrow value allowed for any obligation */\n globalUnhealthyBorrowValue: BN\n /** Global maximum allowed borrow value allowed for any obligation */\n globalAllowedBorrowValue: BN\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n riskCouncil: PublicKey\n /** Reward points multiplier per obligation type */\n multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n elevationGroups: Array<types.ElevationGroupFields>\n elevationGroupPadding: Array<BN>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n minNetValueInObligationSf: BN\n padding1: Array<BN>\n}\n\nexport interface LendingMarketJSON {\n /** Version of lending market */\n version: string\n /** Bump seed for derived authority address */\n bumpSeed: string\n /** Owner authority which can add new reserves */\n lendingMarketOwner: string\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n lendingMarketOwnerCached: string\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n referralFeeBps: number\n emergencyMode: number\n autodeleverageEnabled: number\n /** Padding used for alignment */\n borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n minFullLiquidationValueThreshold: string\n /** Max allowed liquidation value in one ix call */\n maxLiquidatableDebtMarketValueAtOnce: string\n /** Global maximum unhealthy borrow value allowed for any obligation */\n globalUnhealthyBorrowValue: string\n /** Global maximum allowed borrow value allowed for any obligation */\n globalAllowedBorrowValue: string\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n riskCouncil: string\n /** Reward points multiplier per obligation type */\n multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n elevationGroups: Array<types.ElevationGroupJSON>\n elevationGroupPadding: Array<string>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n minNetValueInObligationSf: string\n padding1: Array<string>\n}\n\nexport class LendingMarket {\n /** Version of lending market */\n readonly version: BN\n /** Bump seed for derived authority address */\n readonly bumpSeed: BN\n /** Owner authority which can add new reserves */\n readonly lendingMarketOwner: PublicKey\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n readonly lendingMarketOwnerCached: PublicKey\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n readonly quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n readonly referralFeeBps: number\n readonly emergencyMode: number\n readonly autodeleverageEnabled: number\n /** Padding used for alignment */\n readonly borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n readonly priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n readonly liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n readonly insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n readonly minFullLiquidationValueThreshold: BN\n /** Max allowed liquidation value in one ix call */\n readonly maxLiquidatableDebtMarketValueAtOnce: BN\n /** Global maximum unhealthy borrow value allowed for any obligation */\n readonly globalUnhealthyBorrowValue: BN\n /** Global maximum allowed borrow value allowed for any obligation */\n readonly globalAllowedBorrowValue: BN\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n readonly riskCouncil: PublicKey\n /** Reward points multiplier per obligation type */\n readonly multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n readonly elevationGroups: Array<types.ElevationGroup>\n readonly elevationGroupPadding: Array<BN>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n readonly minNetValueInObligationSf: BN\n readonly padding1: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 246, 114, 50, 98, 72, 157, 28, 120,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"version\"),\n borsh.u64(\"bumpSeed\"),\n borsh.publicKey(\"lendingMarketOwner\"),\n borsh.publicKey(\"lendingMarketOwnerCached\"),\n borsh.array(borsh.u8(), 32, \"quoteCurrency\"),\n borsh.u16(\"referralFeeBps\"),\n borsh.u8(\"emergencyMode\"),\n borsh.u8(\"autodeleverageEnabled\"),\n borsh.u8(\"borrowDisabled\"),\n borsh.u8(\"priceRefreshTriggerToMaxAgePct\"),\n borsh.u8(\"liquidationMaxDebtCloseFactorPct\"),\n borsh.u8(\"insolvencyRiskUnhealthyLtvPct\"),\n borsh.u64(\"minFullLiquidationValueThreshold\"),\n borsh.u64(\"maxLiquidatableDebtMarketValueAtOnce\"),\n borsh.u64(\"globalUnhealthyBorrowValue\"),\n borsh.u64(\"globalAllowedBorrowValue\"),\n borsh.publicKey(\"riskCouncil\"),\n borsh.array(borsh.u8(), 8, \"multiplierPointsTagBoost\"),\n borsh.array(types.ElevationGroup.layout(), 32, \"elevationGroups\"),\n borsh.array(borsh.u64(), 90, \"elevationGroupPadding\"),\n borsh.u128(\"minNetValueInObligationSf\"),\n borsh.array(borsh.u64(), 178, \"padding1\"),\n ])\n\n constructor(fields: LendingMarketFields) {\n this.version = fields.version\n this.bumpSeed = fields.bumpSeed\n this.lendingMarketOwner = fields.lendingMarketOwner\n this.lendingMarketOwnerCached = fields.lendingMarketOwnerCached\n this.quoteCurrency = fields.quoteCurrency\n this.referralFeeBps = fields.referralFeeBps\n this.emergencyMode = fields.emergencyMode\n this.autodeleverageEnabled = fields.autodeleverageEnabled\n this.borrowDisabled = fields.borrowDisabled\n this.priceRefreshTriggerToMaxAgePct = fields.priceRefreshTriggerToMaxAgePct\n this.liquidationMaxDebtCloseFactorPct =\n fields.liquidationMaxDebtCloseFactorPct\n this.insolvencyRiskUnhealthyLtvPct = fields.insolvencyRiskUnhealthyLtvPct\n this.minFullLiquidationValueThreshold =\n fields.minFullLiquidationValueThreshold\n this.maxLiquidatableDebtMarketValueAtOnce =\n fields.maxLiquidatableDebtMarketValueAtOnce\n this.globalUnhealthyBorrowValue = fields.globalUnhealthyBorrowValue\n this.globalAllowedBorrowValue = fields.globalAllowedBorrowValue\n this.riskCouncil = fields.riskCouncil\n this.multiplierPointsTagBoost = fields.multiplierPointsTagBoost\n this.elevationGroups = fields.elevationGroups.map(\n (item) => new types.ElevationGroup({ ...item })\n )\n this.elevationGroupPadding = fields.elevationGroupPadding\n this.minNetValueInObligationSf = fields.minNetValueInObligationSf\n this.padding1 = fields.padding1\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<LendingMarket | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<LendingMarket | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): LendingMarket {\n if (!data.slice(0, 8).equals(LendingMarket.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = LendingMarket.layout.decode(data.slice(8))\n\n return new LendingMarket({\n version: dec.version,\n bumpSeed: dec.bumpSeed,\n lendingMarketOwner: dec.lendingMarketOwner,\n lendingMarketOwnerCached: dec.lendingMarketOwnerCached,\n quoteCurrency: dec.quoteCurrency,\n referralFeeBps: dec.referralFeeBps,\n emergencyMode: dec.emergencyMode,\n autodeleverageEnabled: dec.autodeleverageEnabled,\n borrowDisabled: dec.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: dec.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: dec.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: dec.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold: dec.minFullLiquidationValueThreshold,\n maxLiquidatableDebtMarketValueAtOnce:\n dec.maxLiquidatableDebtMarketValueAtOnce,\n globalUnhealthyBorrowValue: dec.globalUnhealthyBorrowValue,\n globalAllowedBorrowValue: dec.globalAllowedBorrowValue,\n riskCouncil: dec.riskCouncil,\n multiplierPointsTagBoost: dec.multiplierPointsTagBoost,\n elevationGroups: dec.elevationGroups.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ElevationGroup.fromDecoded(item)\n ),\n elevationGroupPadding: dec.elevationGroupPadding,\n minNetValueInObligationSf: dec.minNetValueInObligationSf,\n padding1: dec.padding1,\n })\n }\n\n toJSON(): LendingMarketJSON {\n return {\n version: this.version.toString(),\n bumpSeed: this.bumpSeed.toString(),\n lendingMarketOwner: this.lendingMarketOwner.toString(),\n lendingMarketOwnerCached: this.lendingMarketOwnerCached.toString(),\n quoteCurrency: this.quoteCurrency,\n referralFeeBps: this.referralFeeBps,\n emergencyMode: this.emergencyMode,\n autodeleverageEnabled: this.autodeleverageEnabled,\n borrowDisabled: this.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: this.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: this.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: this.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold:\n this.minFullLiquidationValueThreshold.toString(),\n maxLiquidatableDebtMarketValueAtOnce:\n this.maxLiquidatableDebtMarketValueAtOnce.toString(),\n globalUnhealthyBorrowValue: this.globalUnhealthyBorrowValue.toString(),\n globalAllowedBorrowValue: this.globalAllowedBorrowValue.toString(),\n riskCouncil: this.riskCouncil.toString(),\n multiplierPointsTagBoost: this.multiplierPointsTagBoost,\n elevationGroups: this.elevationGroups.map((item) => item.toJSON()),\n elevationGroupPadding: this.elevationGroupPadding.map((item) =>\n item.toString()\n ),\n minNetValueInObligationSf: this.minNetValueInObligationSf.toString(),\n padding1: this.padding1.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: LendingMarketJSON): LendingMarket {\n return new LendingMarket({\n version: new BN(obj.version),\n bumpSeed: new BN(obj.bumpSeed),\n lendingMarketOwner: new PublicKey(obj.lendingMarketOwner),\n lendingMarketOwnerCached: new PublicKey(obj.lendingMarketOwnerCached),\n quoteCurrency: obj.quoteCurrency,\n referralFeeBps: obj.referralFeeBps,\n emergencyMode: obj.emergencyMode,\n autodeleverageEnabled: obj.autodeleverageEnabled,\n borrowDisabled: obj.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: obj.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: obj.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: obj.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold: new BN(\n obj.minFullLiquidationValueThreshold\n ),\n maxLiquidatableDebtMarketValueAtOnce: new BN(\n obj.maxLiquidatableDebtMarketValueAtOnce\n ),\n globalUnhealthyBorrowValue: new BN(obj.globalUnhealthyBorrowValue),\n globalAllowedBorrowValue: new BN(obj.globalAllowedBorrowValue),\n riskCouncil: new PublicKey(obj.riskCouncil),\n multiplierPointsTagBoost: obj.multiplierPointsTagBoost,\n elevationGroups: obj.elevationGroups.map((item) =>\n types.ElevationGroup.fromJSON(item)\n ),\n elevationGroupPadding: obj.elevationGroupPadding.map(\n (item) => new BN(item)\n ),\n minNetValueInObligationSf: new BN(obj.minNetValueInObligationSf),\n padding1: obj.padding1.map((item) => new BN(item)),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"LendingMarket.js","sourceRoot":"","sources":["../../../src/idl_codegen/accounts/LendingMarket.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,kDAAsB,CAAC,wDAAwD;AAC/E,wDAAyC,CAAC,wDAAwD;AAClG,gDAAiC,CAAC,wDAAwD;AAC1F,4CAAyC;AAsGzC,MAAa,aAAa;IA+ExB,YAAY,MAA2B;QACrC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;QAC/B,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAA;QACnD,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,wBAAwB,CAAA;QAC/D,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,qBAAqB,GAAG,MAAM,CAAC,qBAAqB,CAAA;QACzD,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,8BAA8B,GAAG,MAAM,CAAC,8BAA8B,CAAA;QAC3E,IAAI,CAAC,gCAAgC;YACnC,MAAM,CAAC,gCAAgC,CAAA;QACzC,IAAI,CAAC,6BAA6B,GAAG,MAAM,CAAC,6BAA6B,CAAA;QACzE,IAAI,CAAC,gCAAgC;YACnC,MAAM,CAAC,gCAAgC,CAAA;QACzC,IAAI,CAAC,oCAAoC;YACvC,MAAM,CAAC,oCAAoC,CAAA;QAC7C,IAAI,CAAC,0BAA0B,GAAG,MAAM,CAAC,0BAA0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.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface LendingMarketFields {\n /** Version of lending market */\n version: BN\n /** Bump seed for derived authority address */\n bumpSeed: BN\n /** Owner authority which can add new reserves */\n lendingMarketOwner: PublicKey\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n lendingMarketOwnerCached: PublicKey\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n referralFeeBps: number\n emergencyMode: number\n autodeleverageEnabled: number\n borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n minFullLiquidationValueThreshold: BN\n /** Max allowed liquidation value in one ix call */\n maxLiquidatableDebtMarketValueAtOnce: BN\n /** Global maximum unhealthy borrow value allowed for any obligation */\n globalUnhealthyBorrowValue: BN\n /** Global maximum allowed borrow value allowed for any obligation */\n globalAllowedBorrowValue: BN\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n riskCouncil: PublicKey\n /** Reward points multiplier per obligation type */\n multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n elevationGroups: Array<types.ElevationGroupFields>\n elevationGroupPadding: Array<BN>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n minNetValueInObligationSf: BN\n minValueSkipLiquidationLtvBfChecks: BN\n padding1: Array<BN>\n}\n\nexport interface LendingMarketJSON {\n /** Version of lending market */\n version: string\n /** Bump seed for derived authority address */\n bumpSeed: string\n /** Owner authority which can add new reserves */\n lendingMarketOwner: string\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n lendingMarketOwnerCached: string\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n referralFeeBps: number\n emergencyMode: number\n autodeleverageEnabled: number\n borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n minFullLiquidationValueThreshold: string\n /** Max allowed liquidation value in one ix call */\n maxLiquidatableDebtMarketValueAtOnce: string\n /** Global maximum unhealthy borrow value allowed for any obligation */\n globalUnhealthyBorrowValue: string\n /** Global maximum allowed borrow value allowed for any obligation */\n globalAllowedBorrowValue: string\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n riskCouncil: string\n /** Reward points multiplier per obligation type */\n multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n elevationGroups: Array<types.ElevationGroupJSON>\n elevationGroupPadding: Array<string>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n minNetValueInObligationSf: string\n minValueSkipLiquidationLtvBfChecks: string\n padding1: Array<string>\n}\n\nexport class LendingMarket {\n /** Version of lending market */\n readonly version: BN\n /** Bump seed for derived authority address */\n readonly bumpSeed: BN\n /** Owner authority which can add new reserves */\n readonly lendingMarketOwner: PublicKey\n /** Temporary cache of the lending market owner, used in update_lending_market_owner */\n readonly lendingMarketOwnerCached: PublicKey\n /**\n * Currency market prices are quoted in\n * e.g. \"USD\" null padded (`*b\"USD\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\"`) or a SPL token mint pubkey\n */\n readonly quoteCurrency: Array<number>\n /** Referral fee for the lending market, as bps out of the total protocol fee */\n readonly referralFeeBps: number\n readonly emergencyMode: number\n readonly autodeleverageEnabled: number\n readonly borrowDisabled: number\n /**\n * Refresh price from oracle only if it's older than this percentage of the price max age.\n * e.g. if the max age is set to 100s and this is set to 80%, the price will be refreshed if it's older than 80s.\n * Price is always refreshed if this set to 0.\n */\n readonly priceRefreshTriggerToMaxAgePct: number\n /** Percentage of the total borrowed value in an obligation available for liquidation */\n readonly liquidationMaxDebtCloseFactorPct: number\n /** Minimum acceptable unhealthy LTV before max_debt_close_factor_pct becomes 100% */\n readonly insolvencyRiskUnhealthyLtvPct: number\n /** Minimum liquidation value threshold triggering full liquidation for an obligation */\n readonly minFullLiquidationValueThreshold: BN\n /** Max allowed liquidation value in one ix call */\n readonly maxLiquidatableDebtMarketValueAtOnce: BN\n /** Global maximum unhealthy borrow value allowed for any obligation */\n readonly globalUnhealthyBorrowValue: BN\n /** Global maximum allowed borrow value allowed for any obligation */\n readonly globalAllowedBorrowValue: BN\n /** The address of the risk council, in charge of making parameter and risk decisions on behalf of the protocol */\n readonly riskCouncil: PublicKey\n /** Reward points multiplier per obligation type */\n readonly multiplierPointsTagBoost: Array<number>\n /** Elevation groups are used to group together reserves that have the same risk parameters and can bump the ltv and liquidation threshold */\n readonly elevationGroups: Array<types.ElevationGroup>\n readonly elevationGroupPadding: Array<BN>\n /** Min net value accepted to be found in a position after any lending action in an obligation (scaled by quote currency decimals) */\n readonly minNetValueInObligationSf: BN\n readonly minValueSkipLiquidationLtvBfChecks: BN\n readonly padding1: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 246, 114, 50, 98, 72, 157, 28, 120,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"version\"),\n borsh.u64(\"bumpSeed\"),\n borsh.publicKey(\"lendingMarketOwner\"),\n borsh.publicKey(\"lendingMarketOwnerCached\"),\n borsh.array(borsh.u8(), 32, \"quoteCurrency\"),\n borsh.u16(\"referralFeeBps\"),\n borsh.u8(\"emergencyMode\"),\n borsh.u8(\"autodeleverageEnabled\"),\n borsh.u8(\"borrowDisabled\"),\n borsh.u8(\"priceRefreshTriggerToMaxAgePct\"),\n borsh.u8(\"liquidationMaxDebtCloseFactorPct\"),\n borsh.u8(\"insolvencyRiskUnhealthyLtvPct\"),\n borsh.u64(\"minFullLiquidationValueThreshold\"),\n borsh.u64(\"maxLiquidatableDebtMarketValueAtOnce\"),\n borsh.u64(\"globalUnhealthyBorrowValue\"),\n borsh.u64(\"globalAllowedBorrowValue\"),\n borsh.publicKey(\"riskCouncil\"),\n borsh.array(borsh.u8(), 8, \"multiplierPointsTagBoost\"),\n borsh.array(types.ElevationGroup.layout(), 32, \"elevationGroups\"),\n borsh.array(borsh.u64(), 90, \"elevationGroupPadding\"),\n borsh.u128(\"minNetValueInObligationSf\"),\n borsh.u64(\"minValueSkipLiquidationLtvBfChecks\"),\n borsh.array(borsh.u64(), 177, \"padding1\"),\n ])\n\n constructor(fields: LendingMarketFields) {\n this.version = fields.version\n this.bumpSeed = fields.bumpSeed\n this.lendingMarketOwner = fields.lendingMarketOwner\n this.lendingMarketOwnerCached = fields.lendingMarketOwnerCached\n this.quoteCurrency = fields.quoteCurrency\n this.referralFeeBps = fields.referralFeeBps\n this.emergencyMode = fields.emergencyMode\n this.autodeleverageEnabled = fields.autodeleverageEnabled\n this.borrowDisabled = fields.borrowDisabled\n this.priceRefreshTriggerToMaxAgePct = fields.priceRefreshTriggerToMaxAgePct\n this.liquidationMaxDebtCloseFactorPct =\n fields.liquidationMaxDebtCloseFactorPct\n this.insolvencyRiskUnhealthyLtvPct = fields.insolvencyRiskUnhealthyLtvPct\n this.minFullLiquidationValueThreshold =\n fields.minFullLiquidationValueThreshold\n this.maxLiquidatableDebtMarketValueAtOnce =\n fields.maxLiquidatableDebtMarketValueAtOnce\n this.globalUnhealthyBorrowValue = fields.globalUnhealthyBorrowValue\n this.globalAllowedBorrowValue = fields.globalAllowedBorrowValue\n this.riskCouncil = fields.riskCouncil\n this.multiplierPointsTagBoost = fields.multiplierPointsTagBoost\n this.elevationGroups = fields.elevationGroups.map(\n (item) => new types.ElevationGroup({ ...item })\n )\n this.elevationGroupPadding = fields.elevationGroupPadding\n this.minNetValueInObligationSf = fields.minNetValueInObligationSf\n this.minValueSkipLiquidationLtvBfChecks =\n fields.minValueSkipLiquidationLtvBfChecks\n this.padding1 = fields.padding1\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<LendingMarket | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<LendingMarket | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): LendingMarket {\n if (!data.slice(0, 8).equals(LendingMarket.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = LendingMarket.layout.decode(data.slice(8))\n\n return new LendingMarket({\n version: dec.version,\n bumpSeed: dec.bumpSeed,\n lendingMarketOwner: dec.lendingMarketOwner,\n lendingMarketOwnerCached: dec.lendingMarketOwnerCached,\n quoteCurrency: dec.quoteCurrency,\n referralFeeBps: dec.referralFeeBps,\n emergencyMode: dec.emergencyMode,\n autodeleverageEnabled: dec.autodeleverageEnabled,\n borrowDisabled: dec.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: dec.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: dec.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: dec.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold: dec.minFullLiquidationValueThreshold,\n maxLiquidatableDebtMarketValueAtOnce:\n dec.maxLiquidatableDebtMarketValueAtOnce,\n globalUnhealthyBorrowValue: dec.globalUnhealthyBorrowValue,\n globalAllowedBorrowValue: dec.globalAllowedBorrowValue,\n riskCouncil: dec.riskCouncil,\n multiplierPointsTagBoost: dec.multiplierPointsTagBoost,\n elevationGroups: dec.elevationGroups.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ElevationGroup.fromDecoded(item)\n ),\n elevationGroupPadding: dec.elevationGroupPadding,\n minNetValueInObligationSf: dec.minNetValueInObligationSf,\n minValueSkipLiquidationLtvBfChecks:\n dec.minValueSkipLiquidationLtvBfChecks,\n padding1: dec.padding1,\n })\n }\n\n toJSON(): LendingMarketJSON {\n return {\n version: this.version.toString(),\n bumpSeed: this.bumpSeed.toString(),\n lendingMarketOwner: this.lendingMarketOwner.toString(),\n lendingMarketOwnerCached: this.lendingMarketOwnerCached.toString(),\n quoteCurrency: this.quoteCurrency,\n referralFeeBps: this.referralFeeBps,\n emergencyMode: this.emergencyMode,\n autodeleverageEnabled: this.autodeleverageEnabled,\n borrowDisabled: this.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: this.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: this.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: this.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold:\n this.minFullLiquidationValueThreshold.toString(),\n maxLiquidatableDebtMarketValueAtOnce:\n this.maxLiquidatableDebtMarketValueAtOnce.toString(),\n globalUnhealthyBorrowValue: this.globalUnhealthyBorrowValue.toString(),\n globalAllowedBorrowValue: this.globalAllowedBorrowValue.toString(),\n riskCouncil: this.riskCouncil.toString(),\n multiplierPointsTagBoost: this.multiplierPointsTagBoost,\n elevationGroups: this.elevationGroups.map((item) => item.toJSON()),\n elevationGroupPadding: this.elevationGroupPadding.map((item) =>\n item.toString()\n ),\n minNetValueInObligationSf: this.minNetValueInObligationSf.toString(),\n minValueSkipLiquidationLtvBfChecks:\n this.minValueSkipLiquidationLtvBfChecks.toString(),\n padding1: this.padding1.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: LendingMarketJSON): LendingMarket {\n return new LendingMarket({\n version: new BN(obj.version),\n bumpSeed: new BN(obj.bumpSeed),\n lendingMarketOwner: new PublicKey(obj.lendingMarketOwner),\n lendingMarketOwnerCached: new PublicKey(obj.lendingMarketOwnerCached),\n quoteCurrency: obj.quoteCurrency,\n referralFeeBps: obj.referralFeeBps,\n emergencyMode: obj.emergencyMode,\n autodeleverageEnabled: obj.autodeleverageEnabled,\n borrowDisabled: obj.borrowDisabled,\n priceRefreshTriggerToMaxAgePct: obj.priceRefreshTriggerToMaxAgePct,\n liquidationMaxDebtCloseFactorPct: obj.liquidationMaxDebtCloseFactorPct,\n insolvencyRiskUnhealthyLtvPct: obj.insolvencyRiskUnhealthyLtvPct,\n minFullLiquidationValueThreshold: new BN(\n obj.minFullLiquidationValueThreshold\n ),\n maxLiquidatableDebtMarketValueAtOnce: new BN(\n obj.maxLiquidatableDebtMarketValueAtOnce\n ),\n globalUnhealthyBorrowValue: new BN(obj.globalUnhealthyBorrowValue),\n globalAllowedBorrowValue: new BN(obj.globalAllowedBorrowValue),\n riskCouncil: new PublicKey(obj.riskCouncil),\n multiplierPointsTagBoost: obj.multiplierPointsTagBoost,\n elevationGroups: obj.elevationGroups.map((item) =>\n types.ElevationGroup.fromJSON(item)\n ),\n elevationGroupPadding: obj.elevationGroupPadding.map(\n (item) => new BN(item)\n ),\n minNetValueInObligationSf: new BN(obj.minNetValueInObligationSf),\n minValueSkipLiquidationLtvBfChecks: new BN(\n obj.minValueSkipLiquidationLtvBfChecks\n ),\n padding1: obj.padding1.map((item) => new BN(item)),\n })\n }\n}\n"]}
@@ -17,7 +17,7 @@ export interface ObligationFields {
17
17
  */
18
18
  deposits: Array<types.ObligationCollateralFields>;
19
19
  /** Worst LTV for the collaterals backing the loan, represented as a percentage */
20
- lowestReserveDepositLtv: BN;
20
+ lowestReserveDepositLiquidationLtv: BN;
21
21
  /** Market value of deposits (scaled fraction) */
22
22
  depositedValueSf: BN;
23
23
  /** Borrowed liquidity for the obligation, unique by borrow reserve address */
@@ -45,6 +45,7 @@ export interface ObligationFields {
45
45
  /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
46
46
  borrowingDisabled: number;
47
47
  reserved: Array<number>;
48
+ highestBorrowFactorPct: BN;
48
49
  padding3: Array<BN>;
49
50
  }
50
51
  export interface ObligationJSON {
@@ -62,7 +63,7 @@ export interface ObligationJSON {
62
63
  */
63
64
  deposits: Array<types.ObligationCollateralJSON>;
64
65
  /** Worst LTV for the collaterals backing the loan, represented as a percentage */
65
- lowestReserveDepositLtv: string;
66
+ lowestReserveDepositLiquidationLtv: string;
66
67
  /** Market value of deposits (scaled fraction) */
67
68
  depositedValueSf: string;
68
69
  /** Borrowed liquidity for the obligation, unique by borrow reserve address */
@@ -90,6 +91,7 @@ export interface ObligationJSON {
90
91
  /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
91
92
  borrowingDisabled: number;
92
93
  reserved: Array<number>;
94
+ highestBorrowFactorPct: string;
93
95
  padding3: Array<string>;
94
96
  }
95
97
  /** Lending market obligation state */
@@ -108,7 +110,7 @@ export declare class Obligation {
108
110
  */
109
111
  readonly deposits: Array<types.ObligationCollateral>;
110
112
  /** Worst LTV for the collaterals backing the loan, represented as a percentage */
111
- readonly lowestReserveDepositLtv: BN;
113
+ readonly lowestReserveDepositLiquidationLtv: BN;
112
114
  /** Market value of deposits (scaled fraction) */
113
115
  readonly depositedValueSf: BN;
114
116
  /** Borrowed liquidity for the obligation, unique by borrow reserve address */
@@ -136,6 +138,7 @@ export declare class Obligation {
136
138
  /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */
137
139
  readonly borrowingDisabled: number;
138
140
  readonly reserved: Array<number>;
141
+ readonly highestBorrowFactorPct: BN;
139
142
  readonly padding3: Array<BN>;
140
143
  static readonly discriminator: Buffer;
141
144
  static readonly layout: any;
@@ -49,7 +49,8 @@ class Obligation {
49
49
  this.lendingMarket = fields.lendingMarket;
50
50
  this.owner = fields.owner;
51
51
  this.deposits = fields.deposits.map((item) => new types.ObligationCollateral(Object.assign({}, item)));
52
- this.lowestReserveDepositLtv = fields.lowestReserveDepositLtv;
52
+ this.lowestReserveDepositLiquidationLtv =
53
+ fields.lowestReserveDepositLiquidationLtv;
53
54
  this.depositedValueSf = fields.depositedValueSf;
54
55
  this.borrows = fields.borrows.map((item) => new types.ObligationLiquidity(Object.assign({}, item)));
55
56
  this.borrowFactorAdjustedDebtValueSf =
@@ -65,6 +66,7 @@ class Obligation {
65
66
  this.referrer = fields.referrer;
66
67
  this.borrowingDisabled = fields.borrowingDisabled;
67
68
  this.reserved = fields.reserved;
69
+ this.highestBorrowFactorPct = fields.highestBorrowFactorPct;
68
70
  this.padding3 = fields.padding3;
69
71
  }
70
72
  static fetch(c, address, programId = programId_1.PROGRAM_ID) {
@@ -104,7 +106,7 @@ class Obligation {
104
106
  lendingMarket: dec.lendingMarket,
105
107
  owner: dec.owner,
106
108
  deposits: dec.deposits.map((item /* eslint-disable-line @typescript-eslint/no-explicit-any */) => types.ObligationCollateral.fromDecoded(item)),
107
- lowestReserveDepositLtv: dec.lowestReserveDepositLtv,
109
+ lowestReserveDepositLiquidationLtv: dec.lowestReserveDepositLiquidationLtv,
108
110
  depositedValueSf: dec.depositedValueSf,
109
111
  borrows: dec.borrows.map((item /* eslint-disable-line @typescript-eslint/no-explicit-any */) => types.ObligationLiquidity.fromDecoded(item)),
110
112
  borrowFactorAdjustedDebtValueSf: dec.borrowFactorAdjustedDebtValueSf,
@@ -119,6 +121,7 @@ class Obligation {
119
121
  referrer: dec.referrer,
120
122
  borrowingDisabled: dec.borrowingDisabled,
121
123
  reserved: dec.reserved,
124
+ highestBorrowFactorPct: dec.highestBorrowFactorPct,
122
125
  padding3: dec.padding3,
123
126
  });
124
127
  }
@@ -129,7 +132,7 @@ class Obligation {
129
132
  lendingMarket: this.lendingMarket.toString(),
130
133
  owner: this.owner.toString(),
131
134
  deposits: this.deposits.map((item) => item.toJSON()),
132
- lowestReserveDepositLtv: this.lowestReserveDepositLtv.toString(),
135
+ lowestReserveDepositLiquidationLtv: this.lowestReserveDepositLiquidationLtv.toString(),
133
136
  depositedValueSf: this.depositedValueSf.toString(),
134
137
  borrows: this.borrows.map((item) => item.toJSON()),
135
138
  borrowFactorAdjustedDebtValueSf: this.borrowFactorAdjustedDebtValueSf.toString(),
@@ -144,6 +147,7 @@ class Obligation {
144
147
  referrer: this.referrer.toString(),
145
148
  borrowingDisabled: this.borrowingDisabled,
146
149
  reserved: this.reserved,
150
+ highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),
147
151
  padding3: this.padding3.map((item) => item.toString()),
148
152
  };
149
153
  }
@@ -154,7 +158,7 @@ class Obligation {
154
158
  lendingMarket: new web3_js_1.PublicKey(obj.lendingMarket),
155
159
  owner: new web3_js_1.PublicKey(obj.owner),
156
160
  deposits: obj.deposits.map((item) => types.ObligationCollateral.fromJSON(item)),
157
- lowestReserveDepositLtv: new bn_js_1.default(obj.lowestReserveDepositLtv),
161
+ lowestReserveDepositLiquidationLtv: new bn_js_1.default(obj.lowestReserveDepositLiquidationLtv),
158
162
  depositedValueSf: new bn_js_1.default(obj.depositedValueSf),
159
163
  borrows: obj.borrows.map((item) => types.ObligationLiquidity.fromJSON(item)),
160
164
  borrowFactorAdjustedDebtValueSf: new bn_js_1.default(obj.borrowFactorAdjustedDebtValueSf),
@@ -169,6 +173,7 @@ class Obligation {
169
173
  referrer: new web3_js_1.PublicKey(obj.referrer),
170
174
  borrowingDisabled: obj.borrowingDisabled,
171
175
  reserved: obj.reserved,
176
+ highestBorrowFactorPct: new bn_js_1.default(obj.highestBorrowFactorPct),
172
177
  padding3: obj.padding3.map((item) => new bn_js_1.default(item)),
173
178
  });
174
179
  }
@@ -183,7 +188,7 @@ Obligation.layout = borsh.struct([
183
188
  borsh.publicKey("lendingMarket"),
184
189
  borsh.publicKey("owner"),
185
190
  borsh.array(types.ObligationCollateral.layout(), 8, "deposits"),
186
- borsh.u64("lowestReserveDepositLtv"),
191
+ borsh.u64("lowestReserveDepositLiquidationLtv"),
187
192
  borsh.u128("depositedValueSf"),
188
193
  borsh.array(types.ObligationLiquidity.layout(), 5, "borrows"),
189
194
  borsh.u128("borrowFactorAdjustedDebtValueSf"),
@@ -198,6 +203,7 @@ Obligation.layout = borsh.struct([
198
203
  borsh.publicKey("referrer"),
199
204
  borsh.u8("borrowingDisabled"),
200
205
  borsh.array(borsh.u8(), 7, "reserved"),
201
- borsh.array(borsh.u64(), 127, "padding3"),
206
+ borsh.u64("highestBorrowFactorPct"),
207
+ borsh.array(borsh.u64(), 126, "padding3"),
202
208
  ]);
203
209
  //# sourceMappingURL=Obligation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Obligation.js","sourceRo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BAAoB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC;IAC/D,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC;IACpC,KAAK,CAAC,IAAI,CAAC,kBAAkB,CAAC;IAC9B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,mBAAmB,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,SAAS,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC;IAC7C,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC;IACzC,KAAK,CAAC,IAAI,CAAC,sBAAsB,CAAC;IAClC,KAAK,CAAC,IAAI,CAAC,wBAAwB,CAAC;IACpC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,oBAAoB,CAAC;IAChD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,mBAAmB,CAAC;IAC/C,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,CAAC,uBAAuB,CAAC;IACjC,KAAK,CAAC,EAAE,CAAC,SAAS,CAAC;IACnB,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC;IAC3B,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAAC;IAC7B,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,UAAU,CAAC;IACtC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,UAAU,CAAC;CAC1C,CAAC,CAAA","sourcesContent":["import { PublicKey, Connection } from \"@solana/web3.js\"\nimport BN from \"bn.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface ObligationFields {\n /** Version of the struct */\n tag: BN\n /** Last update to collateral, liquidity, or their market values */\n lastUpdate: types.LastUpdateFields\n /** Lending market address */\n lendingMarket: PublicKey\n /** Owner authority which can borrow liquidity */\n owner: PublicKey\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n deposits: Array<types.ObligationCollateralFields>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n lowestReserveDepositLtv: BN\n /** Market value of deposits (scaled fraction) */\n depositedValueSf: BN\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n borrows: Array<types.ObligationLiquidityFields>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n borrowFactorAdjustedDebtValueSf: BN\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n borrowedAssetsMarketValueSf: BN\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n allowedBorrowValueSf: BN\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n unhealthyBorrowValueSf: BN\n /** The asset tier of the deposits */\n depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n hasDebt: number\n /** Wallet address of the referrer */\n referrer: PublicKey\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n borrowingDisabled: number\n reserved: Array<number>\n padding3: Array<BN>\n}\n\nexport interface ObligationJSON {\n /** Version of the struct */\n tag: string\n /** Last update to collateral, liquidity, or their market values */\n lastUpdate: types.LastUpdateJSON\n /** Lending market address */\n lendingMarket: string\n /** Owner authority which can borrow liquidity */\n owner: string\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n deposits: Array<types.ObligationCollateralJSON>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n lowestReserveDepositLtv: string\n /** Market value of deposits (scaled fraction) */\n depositedValueSf: string\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n borrows: Array<types.ObligationLiquidityJSON>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n borrowFactorAdjustedDebtValueSf: string\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n borrowedAssetsMarketValueSf: string\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n allowedBorrowValueSf: string\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n unhealthyBorrowValueSf: string\n /** The asset tier of the deposits */\n depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n hasDebt: number\n /** Wallet address of the referrer */\n referrer: string\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n borrowingDisabled: number\n reserved: Array<number>\n padding3: Array<string>\n}\n\n/** Lending market obligation state */\nexport class Obligation {\n /** Version of the struct */\n readonly tag: BN\n /** Last update to collateral, liquidity, or their market values */\n readonly lastUpdate: types.LastUpdate\n /** Lending market address */\n readonly lendingMarket: PublicKey\n /** Owner authority which can borrow liquidity */\n readonly owner: PublicKey\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n readonly deposits: Array<types.ObligationCollateral>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n readonly lowestReserveDepositLtv: BN\n /** Market value of deposits (scaled fraction) */\n readonly depositedValueSf: BN\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n readonly borrows: Array<types.ObligationLiquidity>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n readonly borrowFactorAdjustedDebtValueSf: BN\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n readonly borrowedAssetsMarketValueSf: BN\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n readonly allowedBorrowValueSf: BN\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n readonly unhealthyBorrowValueSf: BN\n /** The asset tier of the deposits */\n readonly depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n readonly borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n readonly elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n readonly numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n readonly hasDebt: number\n /** Wallet address of the referrer */\n readonly referrer: PublicKey\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n readonly borrowingDisabled: number\n readonly reserved: Array<number>\n readonly padding3: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 168, 206, 141, 106, 88, 76, 172, 167,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"tag\"),\n types.LastUpdate.layout(\"lastUpdate\"),\n borsh.publicKey(\"lendingMarket\"),\n borsh.publicKey(\"owner\"),\n borsh.array(types.ObligationCollateral.layout(), 8, \"deposits\"),\n borsh.u64(\"lowestReserveDepositLtv\"),\n borsh.u128(\"depositedValueSf\"),\n borsh.array(types.ObligationLiquidity.layout(), 5, \"borrows\"),\n borsh.u128(\"borrowFactorAdjustedDebtValueSf\"),\n borsh.u128(\"borrowedAssetsMarketValueSf\"),\n borsh.u128(\"allowedBorrowValueSf\"),\n borsh.u128(\"unhealthyBorrowValueSf\"),\n borsh.array(borsh.u8(), 8, \"depositsAssetTiers\"),\n borsh.array(borsh.u8(), 5, \"borrowsAssetTiers\"),\n borsh.u8(\"elevationGroup\"),\n borsh.u8(\"numOfObsoleteReserves\"),\n borsh.u8(\"hasDebt\"),\n borsh.publicKey(\"referrer\"),\n borsh.u8(\"borrowingDisabled\"),\n borsh.array(borsh.u8(), 7, \"reserved\"),\n borsh.array(borsh.u64(), 127, \"padding3\"),\n ])\n\n constructor(fields: ObligationFields) {\n this.tag = fields.tag\n this.lastUpdate = new types.LastUpdate({ ...fields.lastUpdate })\n this.lendingMarket = fields.lendingMarket\n this.owner = fields.owner\n this.deposits = fields.deposits.map(\n (item) => new types.ObligationCollateral({ ...item })\n )\n this.lowestReserveDepositLtv = fields.lowestReserveDepositLtv\n this.depositedValueSf = fields.depositedValueSf\n this.borrows = fields.borrows.map(\n (item) => new types.ObligationLiquidity({ ...item })\n )\n this.borrowFactorAdjustedDebtValueSf =\n fields.borrowFactorAdjustedDebtValueSf\n this.borrowedAssetsMarketValueSf = fields.borrowedAssetsMarketValueSf\n this.allowedBorrowValueSf = fields.allowedBorrowValueSf\n this.unhealthyBorrowValueSf = fields.unhealthyBorrowValueSf\n this.depositsAssetTiers = fields.depositsAssetTiers\n this.borrowsAssetTiers = fields.borrowsAssetTiers\n this.elevationGroup = fields.elevationGroup\n this.numOfObsoleteReserves = fields.numOfObsoleteReserves\n this.hasDebt = fields.hasDebt\n this.referrer = fields.referrer\n this.borrowingDisabled = fields.borrowingDisabled\n this.reserved = fields.reserved\n this.padding3 = fields.padding3\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<Obligation | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<Obligation | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): Obligation {\n if (!data.slice(0, 8).equals(Obligation.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = Obligation.layout.decode(data.slice(8))\n\n return new Obligation({\n tag: dec.tag,\n lastUpdate: types.LastUpdate.fromDecoded(dec.lastUpdate),\n lendingMarket: dec.lendingMarket,\n owner: dec.owner,\n deposits: dec.deposits.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ObligationCollateral.fromDecoded(item)\n ),\n lowestReserveDepositLtv: dec.lowestReserveDepositLtv,\n depositedValueSf: dec.depositedValueSf,\n borrows: dec.borrows.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ObligationLiquidity.fromDecoded(item)\n ),\n borrowFactorAdjustedDebtValueSf: dec.borrowFactorAdjustedDebtValueSf,\n borrowedAssetsMarketValueSf: dec.borrowedAssetsMarketValueSf,\n allowedBorrowValueSf: dec.allowedBorrowValueSf,\n unhealthyBorrowValueSf: dec.unhealthyBorrowValueSf,\n depositsAssetTiers: dec.depositsAssetTiers,\n borrowsAssetTiers: dec.borrowsAssetTiers,\n elevationGroup: dec.elevationGroup,\n numOfObsoleteReserves: dec.numOfObsoleteReserves,\n hasDebt: dec.hasDebt,\n referrer: dec.referrer,\n borrowingDisabled: dec.borrowingDisabled,\n reserved: dec.reserved,\n padding3: dec.padding3,\n })\n }\n\n toJSON(): ObligationJSON {\n return {\n tag: this.tag.toString(),\n lastUpdate: this.lastUpdate.toJSON(),\n lendingMarket: this.lendingMarket.toString(),\n owner: this.owner.toString(),\n deposits: this.deposits.map((item) => item.toJSON()),\n lowestReserveDepositLtv: this.lowestReserveDepositLtv.toString(),\n depositedValueSf: this.depositedValueSf.toString(),\n borrows: this.borrows.map((item) => item.toJSON()),\n borrowFactorAdjustedDebtValueSf:\n this.borrowFactorAdjustedDebtValueSf.toString(),\n borrowedAssetsMarketValueSf: this.borrowedAssetsMarketValueSf.toString(),\n allowedBorrowValueSf: this.allowedBorrowValueSf.toString(),\n unhealthyBorrowValueSf: this.unhealthyBorrowValueSf.toString(),\n depositsAssetTiers: this.depositsAssetTiers,\n borrowsAssetTiers: this.borrowsAssetTiers,\n elevationGroup: this.elevationGroup,\n numOfObsoleteReserves: this.numOfObsoleteReserves,\n hasDebt: this.hasDebt,\n referrer: this.referrer.toString(),\n borrowingDisabled: this.borrowingDisabled,\n reserved: this.reserved,\n padding3: this.padding3.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: ObligationJSON): Obligation {\n return new Obligation({\n tag: new BN(obj.tag),\n lastUpdate: types.LastUpdate.fromJSON(obj.lastUpdate),\n lendingMarket: new PublicKey(obj.lendingMarket),\n owner: new PublicKey(obj.owner),\n deposits: obj.deposits.map((item) =>\n types.ObligationCollateral.fromJSON(item)\n ),\n lowestReserveDepositLtv: new BN(obj.lowestReserveDepositLtv),\n depositedValueSf: new BN(obj.depositedValueSf),\n borrows: obj.borrows.map((item) =>\n types.ObligationLiquidity.fromJSON(item)\n ),\n borrowFactorAdjustedDebtValueSf: new BN(\n obj.borrowFactorAdjustedDebtValueSf\n ),\n borrowedAssetsMarketValueSf: new BN(obj.borrowedAssetsMarketValueSf),\n allowedBorrowValueSf: new BN(obj.allowedBorrowValueSf),\n unhealthyBorrowValueSf: new BN(obj.unhealthyBorrowValueSf),\n depositsAssetTiers: obj.depositsAssetTiers,\n borrowsAssetTiers: obj.borrowsAssetTiers,\n elevationGroup: obj.elevationGroup,\n numOfObsoleteReserves: obj.numOfObsoleteReserves,\n hasDebt: obj.hasDebt,\n referrer: new PublicKey(obj.referrer),\n borrowingDisabled: obj.borrowingDisabled,\n reserved: obj.reserved,\n padding3: obj.padding3.map((item) => new BN(item)),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"Obligation.js","sourceRoot":"","sources":["../../../src/idl_codegen/accounts/Obligation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;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solana/web3.js\"\nimport BN from \"bn.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface ObligationFields {\n /** Version of the struct */\n tag: BN\n /** Last update to collateral, liquidity, or their market values */\n lastUpdate: types.LastUpdateFields\n /** Lending market address */\n lendingMarket: PublicKey\n /** Owner authority which can borrow liquidity */\n owner: PublicKey\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n deposits: Array<types.ObligationCollateralFields>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n lowestReserveDepositLiquidationLtv: BN\n /** Market value of deposits (scaled fraction) */\n depositedValueSf: BN\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n borrows: Array<types.ObligationLiquidityFields>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n borrowFactorAdjustedDebtValueSf: BN\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n borrowedAssetsMarketValueSf: BN\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n allowedBorrowValueSf: BN\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n unhealthyBorrowValueSf: BN\n /** The asset tier of the deposits */\n depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n hasDebt: number\n /** Wallet address of the referrer */\n referrer: PublicKey\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n borrowingDisabled: number\n reserved: Array<number>\n highestBorrowFactorPct: BN\n padding3: Array<BN>\n}\n\nexport interface ObligationJSON {\n /** Version of the struct */\n tag: string\n /** Last update to collateral, liquidity, or their market values */\n lastUpdate: types.LastUpdateJSON\n /** Lending market address */\n lendingMarket: string\n /** Owner authority which can borrow liquidity */\n owner: string\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n deposits: Array<types.ObligationCollateralJSON>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n lowestReserveDepositLiquidationLtv: string\n /** Market value of deposits (scaled fraction) */\n depositedValueSf: string\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n borrows: Array<types.ObligationLiquidityJSON>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n borrowFactorAdjustedDebtValueSf: string\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n borrowedAssetsMarketValueSf: string\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n allowedBorrowValueSf: string\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n unhealthyBorrowValueSf: string\n /** The asset tier of the deposits */\n depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n hasDebt: number\n /** Wallet address of the referrer */\n referrer: string\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n borrowingDisabled: number\n reserved: Array<number>\n highestBorrowFactorPct: string\n padding3: Array<string>\n}\n\n/** Lending market obligation state */\nexport class Obligation {\n /** Version of the struct */\n readonly tag: BN\n /** Last update to collateral, liquidity, or their market values */\n readonly lastUpdate: types.LastUpdate\n /** Lending market address */\n readonly lendingMarket: PublicKey\n /** Owner authority which can borrow liquidity */\n readonly owner: PublicKey\n /**\n * TODO: Does this break the stack size when copied onto the stack, if too big?\n * Deposited collateral for the obligation, unique by deposit reserve address\n */\n readonly deposits: Array<types.ObligationCollateral>\n /** Worst LTV for the collaterals backing the loan, represented as a percentage */\n readonly lowestReserveDepositLiquidationLtv: BN\n /** Market value of deposits (scaled fraction) */\n readonly depositedValueSf: BN\n /** Borrowed liquidity for the obligation, unique by borrow reserve address */\n readonly borrows: Array<types.ObligationLiquidity>\n /** Risk adjusted market value of borrows/debt (sum of price * borrowed_amount * borrow_factor) (scaled fraction) */\n readonly borrowFactorAdjustedDebtValueSf: BN\n /** Market value of borrows - used for max_liquidatable_borrowed_amount (scaled fraction) */\n readonly borrowedAssetsMarketValueSf: BN\n /** The maximum borrow value at the weighted average loan to value ratio (scaled fraction) */\n readonly allowedBorrowValueSf: BN\n /** The dangerous borrow value at the weighted average liquidation threshold (scaled fraction) */\n readonly unhealthyBorrowValueSf: BN\n /** The asset tier of the deposits */\n readonly depositsAssetTiers: Array<number>\n /** The asset tier of the borrows */\n readonly borrowsAssetTiers: Array<number>\n /** The elevation group id the obligation opted into. */\n readonly elevationGroup: number\n /** The number of deprecated reserves the obligation has a deposit */\n readonly numOfObsoleteReserves: number\n /** Marked = 1 if borrows array is not empty, 0 = borrows empty */\n readonly hasDebt: number\n /** Wallet address of the referrer */\n readonly referrer: PublicKey\n /** Marked = 1 if borrowing disabled, 0 = borrowing enabled */\n readonly borrowingDisabled: number\n readonly reserved: Array<number>\n readonly highestBorrowFactorPct: BN\n readonly padding3: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 168, 206, 141, 106, 88, 76, 172, 167,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"tag\"),\n types.LastUpdate.layout(\"lastUpdate\"),\n borsh.publicKey(\"lendingMarket\"),\n borsh.publicKey(\"owner\"),\n borsh.array(types.ObligationCollateral.layout(), 8, \"deposits\"),\n borsh.u64(\"lowestReserveDepositLiquidationLtv\"),\n borsh.u128(\"depositedValueSf\"),\n borsh.array(types.ObligationLiquidity.layout(), 5, \"borrows\"),\n borsh.u128(\"borrowFactorAdjustedDebtValueSf\"),\n borsh.u128(\"borrowedAssetsMarketValueSf\"),\n borsh.u128(\"allowedBorrowValueSf\"),\n borsh.u128(\"unhealthyBorrowValueSf\"),\n borsh.array(borsh.u8(), 8, \"depositsAssetTiers\"),\n borsh.array(borsh.u8(), 5, \"borrowsAssetTiers\"),\n borsh.u8(\"elevationGroup\"),\n borsh.u8(\"numOfObsoleteReserves\"),\n borsh.u8(\"hasDebt\"),\n borsh.publicKey(\"referrer\"),\n borsh.u8(\"borrowingDisabled\"),\n borsh.array(borsh.u8(), 7, \"reserved\"),\n borsh.u64(\"highestBorrowFactorPct\"),\n borsh.array(borsh.u64(), 126, \"padding3\"),\n ])\n\n constructor(fields: ObligationFields) {\n this.tag = fields.tag\n this.lastUpdate = new types.LastUpdate({ ...fields.lastUpdate })\n this.lendingMarket = fields.lendingMarket\n this.owner = fields.owner\n this.deposits = fields.deposits.map(\n (item) => new types.ObligationCollateral({ ...item })\n )\n this.lowestReserveDepositLiquidationLtv =\n fields.lowestReserveDepositLiquidationLtv\n this.depositedValueSf = fields.depositedValueSf\n this.borrows = fields.borrows.map(\n (item) => new types.ObligationLiquidity({ ...item })\n )\n this.borrowFactorAdjustedDebtValueSf =\n fields.borrowFactorAdjustedDebtValueSf\n this.borrowedAssetsMarketValueSf = fields.borrowedAssetsMarketValueSf\n this.allowedBorrowValueSf = fields.allowedBorrowValueSf\n this.unhealthyBorrowValueSf = fields.unhealthyBorrowValueSf\n this.depositsAssetTiers = fields.depositsAssetTiers\n this.borrowsAssetTiers = fields.borrowsAssetTiers\n this.elevationGroup = fields.elevationGroup\n this.numOfObsoleteReserves = fields.numOfObsoleteReserves\n this.hasDebt = fields.hasDebt\n this.referrer = fields.referrer\n this.borrowingDisabled = fields.borrowingDisabled\n this.reserved = fields.reserved\n this.highestBorrowFactorPct = fields.highestBorrowFactorPct\n this.padding3 = fields.padding3\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<Obligation | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<Obligation | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): Obligation {\n if (!data.slice(0, 8).equals(Obligation.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = Obligation.layout.decode(data.slice(8))\n\n return new Obligation({\n tag: dec.tag,\n lastUpdate: types.LastUpdate.fromDecoded(dec.lastUpdate),\n lendingMarket: dec.lendingMarket,\n owner: dec.owner,\n deposits: dec.deposits.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ObligationCollateral.fromDecoded(item)\n ),\n lowestReserveDepositLiquidationLtv:\n dec.lowestReserveDepositLiquidationLtv,\n depositedValueSf: dec.depositedValueSf,\n borrows: dec.borrows.map(\n (\n item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */\n ) => types.ObligationLiquidity.fromDecoded(item)\n ),\n borrowFactorAdjustedDebtValueSf: dec.borrowFactorAdjustedDebtValueSf,\n borrowedAssetsMarketValueSf: dec.borrowedAssetsMarketValueSf,\n allowedBorrowValueSf: dec.allowedBorrowValueSf,\n unhealthyBorrowValueSf: dec.unhealthyBorrowValueSf,\n depositsAssetTiers: dec.depositsAssetTiers,\n borrowsAssetTiers: dec.borrowsAssetTiers,\n elevationGroup: dec.elevationGroup,\n numOfObsoleteReserves: dec.numOfObsoleteReserves,\n hasDebt: dec.hasDebt,\n referrer: dec.referrer,\n borrowingDisabled: dec.borrowingDisabled,\n reserved: dec.reserved,\n highestBorrowFactorPct: dec.highestBorrowFactorPct,\n padding3: dec.padding3,\n })\n }\n\n toJSON(): ObligationJSON {\n return {\n tag: this.tag.toString(),\n lastUpdate: this.lastUpdate.toJSON(),\n lendingMarket: this.lendingMarket.toString(),\n owner: this.owner.toString(),\n deposits: this.deposits.map((item) => item.toJSON()),\n lowestReserveDepositLiquidationLtv:\n this.lowestReserveDepositLiquidationLtv.toString(),\n depositedValueSf: this.depositedValueSf.toString(),\n borrows: this.borrows.map((item) => item.toJSON()),\n borrowFactorAdjustedDebtValueSf:\n this.borrowFactorAdjustedDebtValueSf.toString(),\n borrowedAssetsMarketValueSf: this.borrowedAssetsMarketValueSf.toString(),\n allowedBorrowValueSf: this.allowedBorrowValueSf.toString(),\n unhealthyBorrowValueSf: this.unhealthyBorrowValueSf.toString(),\n depositsAssetTiers: this.depositsAssetTiers,\n borrowsAssetTiers: this.borrowsAssetTiers,\n elevationGroup: this.elevationGroup,\n numOfObsoleteReserves: this.numOfObsoleteReserves,\n hasDebt: this.hasDebt,\n referrer: this.referrer.toString(),\n borrowingDisabled: this.borrowingDisabled,\n reserved: this.reserved,\n highestBorrowFactorPct: this.highestBorrowFactorPct.toString(),\n padding3: this.padding3.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: ObligationJSON): Obligation {\n return new Obligation({\n tag: new BN(obj.tag),\n lastUpdate: types.LastUpdate.fromJSON(obj.lastUpdate),\n lendingMarket: new PublicKey(obj.lendingMarket),\n owner: new PublicKey(obj.owner),\n deposits: obj.deposits.map((item) =>\n types.ObligationCollateral.fromJSON(item)\n ),\n lowestReserveDepositLiquidationLtv: new BN(\n obj.lowestReserveDepositLiquidationLtv\n ),\n depositedValueSf: new BN(obj.depositedValueSf),\n borrows: obj.borrows.map((item) =>\n types.ObligationLiquidity.fromJSON(item)\n ),\n borrowFactorAdjustedDebtValueSf: new BN(\n obj.borrowFactorAdjustedDebtValueSf\n ),\n borrowedAssetsMarketValueSf: new BN(obj.borrowedAssetsMarketValueSf),\n allowedBorrowValueSf: new BN(obj.allowedBorrowValueSf),\n unhealthyBorrowValueSf: new BN(obj.unhealthyBorrowValueSf),\n depositsAssetTiers: obj.depositsAssetTiers,\n borrowsAssetTiers: obj.borrowsAssetTiers,\n elevationGroup: obj.elevationGroup,\n numOfObsoleteReserves: obj.numOfObsoleteReserves,\n hasDebt: obj.hasDebt,\n referrer: new PublicKey(obj.referrer),\n borrowingDisabled: obj.borrowingDisabled,\n reserved: obj.reserved,\n highestBorrowFactorPct: new BN(obj.highestBorrowFactorPct),\n padding3: obj.padding3.map((item) => new BN(item)),\n })\n }\n}\n"]}
@@ -20,6 +20,12 @@ export interface ReserveFields {
20
20
  /** Reserve configuration values */
21
21
  config: types.ReserveConfigFields;
22
22
  configPadding: Array<BN>;
23
+ borrowedAmountOutsideElevationGroup: BN;
24
+ /**
25
+ * Amount of token borrowed in lamport of debt asset in the given
26
+ * elevation group when this reserve is part of the collaterals.
27
+ */
28
+ borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>;
23
29
  padding: Array<BN>;
24
30
  }
25
31
  export interface ReserveJSON {
@@ -40,6 +46,12 @@ export interface ReserveJSON {
40
46
  /** Reserve configuration values */
41
47
  config: types.ReserveConfigJSON;
42
48
  configPadding: Array<string>;
49
+ borrowedAmountOutsideElevationGroup: string;
50
+ /**
51
+ * Amount of token borrowed in lamport of debt asset in the given
52
+ * elevation group when this reserve is part of the collaterals.
53
+ */
54
+ borrowedAmountsAgainstThisReserveInElevationGroups: Array<string>;
43
55
  padding: Array<string>;
44
56
  }
45
57
  export declare class Reserve {
@@ -60,6 +72,12 @@ export declare class Reserve {
60
72
  /** Reserve configuration values */
61
73
  readonly config: types.ReserveConfig;
62
74
  readonly configPadding: Array<BN>;
75
+ readonly borrowedAmountOutsideElevationGroup: BN;
76
+ /**
77
+ * Amount of token borrowed in lamport of debt asset in the given
78
+ * elevation group when this reserve is part of the collaterals.
79
+ */
80
+ readonly borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>;
63
81
  readonly padding: Array<BN>;
64
82
  static readonly discriminator: Buffer;
65
83
  static readonly layout: any;
@@ -54,6 +54,10 @@ class Reserve {
54
54
  this.reserveCollateralPadding = fields.reserveCollateralPadding;
55
55
  this.config = new types.ReserveConfig(Object.assign({}, fields.config));
56
56
  this.configPadding = fields.configPadding;
57
+ this.borrowedAmountOutsideElevationGroup =
58
+ fields.borrowedAmountOutsideElevationGroup;
59
+ this.borrowedAmountsAgainstThisReserveInElevationGroups =
60
+ fields.borrowedAmountsAgainstThisReserveInElevationGroups;
57
61
  this.padding = fields.padding;
58
62
  }
59
63
  static fetch(c, address, programId = programId_1.PROGRAM_ID) {
@@ -99,6 +103,8 @@ class Reserve {
99
103
  reserveCollateralPadding: dec.reserveCollateralPadding,
100
104
  config: types.ReserveConfig.fromDecoded(dec.config),
101
105
  configPadding: dec.configPadding,
106
+ borrowedAmountOutsideElevationGroup: dec.borrowedAmountOutsideElevationGroup,
107
+ borrowedAmountsAgainstThisReserveInElevationGroups: dec.borrowedAmountsAgainstThisReserveInElevationGroups,
102
108
  padding: dec.padding,
103
109
  });
104
110
  }
@@ -115,6 +121,8 @@ class Reserve {
115
121
  reserveCollateralPadding: this.reserveCollateralPadding.map((item) => item.toString()),
116
122
  config: this.config.toJSON(),
117
123
  configPadding: this.configPadding.map((item) => item.toString()),
124
+ borrowedAmountOutsideElevationGroup: this.borrowedAmountOutsideElevationGroup.toString(),
125
+ borrowedAmountsAgainstThisReserveInElevationGroups: this.borrowedAmountsAgainstThisReserveInElevationGroups.map((item) => item.toString()),
118
126
  padding: this.padding.map((item) => item.toString()),
119
127
  };
120
128
  }
@@ -131,6 +139,8 @@ class Reserve {
131
139
  reserveCollateralPadding: obj.reserveCollateralPadding.map((item) => new bn_js_1.default(item)),
132
140
  config: types.ReserveConfig.fromJSON(obj.config),
133
141
  configPadding: obj.configPadding.map((item) => new bn_js_1.default(item)),
142
+ borrowedAmountOutsideElevationGroup: new bn_js_1.default(obj.borrowedAmountOutsideElevationGroup),
143
+ borrowedAmountsAgainstThisReserveInElevationGroups: obj.borrowedAmountsAgainstThisReserveInElevationGroups.map((item) => new bn_js_1.default(item)),
134
144
  padding: obj.padding.map((item) => new bn_js_1.default(item)),
135
145
  });
136
146
  }
@@ -150,7 +160,9 @@ Reserve.layout = borsh.struct([
150
160
  types.ReserveCollateral.layout("collateral"),
151
161
  borsh.array(borsh.u64(), 150, "reserveCollateralPadding"),
152
162
  types.ReserveConfig.layout("config"),
153
- borsh.array(borsh.u64(), 150, "configPadding"),
154
- borsh.array(borsh.u64(), 240, "padding"),
163
+ borsh.array(borsh.u64(), 117, "configPadding"),
164
+ borsh.u64("borrowedAmountOutsideElevationGroup"),
165
+ borsh.array(borsh.u64(), 32, "borrowedAmountsAgainstThisReserveInElevationGroups"),
166
+ borsh.array(borsh.u64(), 207, "padding"),
155
167
  ]);
156
168
  //# sourceMappingURL=Reserve.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Reserve.js","sourceRoot":"","sources":["../../../src/idl_codegen/accounts/Reserve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,kDAAsB,CAAC,wDAAwD;AAC/E,wDAAyC,CAAC,wDAAwD;AAClG,gDAAiC,CAAC,wDAAwD;AAC1F,4CAAyC;AA4CzC,MAAa,OAAO;IAuClB,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,KAAK,CAAC,UAAU,mBAAM,MAAM,CAAC,UAAU,EAAG,CAAA;QAChE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;QAC3C,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;QAC/B,IAAI,CAAC,SA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AAC,SAAS,CAAC,gBAAgB,CAAC;IACjC,KAAK,CAAC,SAAS,CAAC,UAAU,CAAC;IAC3B,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC;IAC1C,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,yBAAyB,CAAC;IACxD,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,YAAY,CAAC;IAC5C,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,0BAA0B,CAAC;IACzD,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC;IACpC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,eAAe,CAAC;IAC9C,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC;CACzC,CAAC,CAAA","sourcesContent":["import { PublicKey, Connection } from \"@solana/web3.js\"\nimport BN from \"bn.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface ReserveFields {\n /** Version of the reserve */\n version: BN\n /** Last slot when supply and rates updated */\n lastUpdate: types.LastUpdateFields\n /** Lending market address */\n lendingMarket: PublicKey\n farmCollateral: PublicKey\n farmDebt: PublicKey\n /** Reserve liquidity */\n liquidity: types.ReserveLiquidityFields\n reserveLiquidityPadding: Array<BN>\n /** Reserve collateral */\n collateral: types.ReserveCollateralFields\n reserveCollateralPadding: Array<BN>\n /** Reserve configuration values */\n config: types.ReserveConfigFields\n configPadding: Array<BN>\n padding: Array<BN>\n}\n\nexport interface ReserveJSON {\n /** Version of the reserve */\n version: string\n /** Last slot when supply and rates updated */\n lastUpdate: types.LastUpdateJSON\n /** Lending market address */\n lendingMarket: string\n farmCollateral: string\n farmDebt: string\n /** Reserve liquidity */\n liquidity: types.ReserveLiquidityJSON\n reserveLiquidityPadding: Array<string>\n /** Reserve collateral */\n collateral: types.ReserveCollateralJSON\n reserveCollateralPadding: Array<string>\n /** Reserve configuration values */\n config: types.ReserveConfigJSON\n configPadding: Array<string>\n padding: Array<string>\n}\n\nexport class Reserve {\n /** Version of the reserve */\n readonly version: BN\n /** Last slot when supply and rates updated */\n readonly lastUpdate: types.LastUpdate\n /** Lending market address */\n readonly lendingMarket: PublicKey\n readonly farmCollateral: PublicKey\n readonly farmDebt: PublicKey\n /** Reserve liquidity */\n readonly liquidity: types.ReserveLiquidity\n readonly reserveLiquidityPadding: Array<BN>\n /** Reserve collateral */\n readonly collateral: types.ReserveCollateral\n readonly reserveCollateralPadding: Array<BN>\n /** Reserve configuration values */\n readonly config: types.ReserveConfig\n readonly configPadding: Array<BN>\n readonly padding: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 43, 242, 204, 202, 26, 247, 59, 127,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"version\"),\n types.LastUpdate.layout(\"lastUpdate\"),\n borsh.publicKey(\"lendingMarket\"),\n borsh.publicKey(\"farmCollateral\"),\n borsh.publicKey(\"farmDebt\"),\n types.ReserveLiquidity.layout(\"liquidity\"),\n borsh.array(borsh.u64(), 150, \"reserveLiquidityPadding\"),\n types.ReserveCollateral.layout(\"collateral\"),\n borsh.array(borsh.u64(), 150, \"reserveCollateralPadding\"),\n types.ReserveConfig.layout(\"config\"),\n borsh.array(borsh.u64(), 150, \"configPadding\"),\n borsh.array(borsh.u64(), 240, \"padding\"),\n ])\n\n constructor(fields: ReserveFields) {\n this.version = fields.version\n this.lastUpdate = new types.LastUpdate({ ...fields.lastUpdate })\n this.lendingMarket = fields.lendingMarket\n this.farmCollateral = fields.farmCollateral\n this.farmDebt = fields.farmDebt\n this.liquidity = new types.ReserveLiquidity({ ...fields.liquidity })\n this.reserveLiquidityPadding = fields.reserveLiquidityPadding\n this.collateral = new types.ReserveCollateral({ ...fields.collateral })\n this.reserveCollateralPadding = fields.reserveCollateralPadding\n this.config = new types.ReserveConfig({ ...fields.config })\n this.configPadding = fields.configPadding\n this.padding = fields.padding\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<Reserve | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<Reserve | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): Reserve {\n if (!data.slice(0, 8).equals(Reserve.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = Reserve.layout.decode(data.slice(8))\n\n return new Reserve({\n version: dec.version,\n lastUpdate: types.LastUpdate.fromDecoded(dec.lastUpdate),\n lendingMarket: dec.lendingMarket,\n farmCollateral: dec.farmCollateral,\n farmDebt: dec.farmDebt,\n liquidity: types.ReserveLiquidity.fromDecoded(dec.liquidity),\n reserveLiquidityPadding: dec.reserveLiquidityPadding,\n collateral: types.ReserveCollateral.fromDecoded(dec.collateral),\n reserveCollateralPadding: dec.reserveCollateralPadding,\n config: types.ReserveConfig.fromDecoded(dec.config),\n configPadding: dec.configPadding,\n padding: dec.padding,\n })\n }\n\n toJSON(): ReserveJSON {\n return {\n version: this.version.toString(),\n lastUpdate: this.lastUpdate.toJSON(),\n lendingMarket: this.lendingMarket.toString(),\n farmCollateral: this.farmCollateral.toString(),\n farmDebt: this.farmDebt.toString(),\n liquidity: this.liquidity.toJSON(),\n reserveLiquidityPadding: this.reserveLiquidityPadding.map((item) =>\n item.toString()\n ),\n collateral: this.collateral.toJSON(),\n reserveCollateralPadding: this.reserveCollateralPadding.map((item) =>\n item.toString()\n ),\n config: this.config.toJSON(),\n configPadding: this.configPadding.map((item) => item.toString()),\n padding: this.padding.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: ReserveJSON): Reserve {\n return new Reserve({\n version: new BN(obj.version),\n lastUpdate: types.LastUpdate.fromJSON(obj.lastUpdate),\n lendingMarket: new PublicKey(obj.lendingMarket),\n farmCollateral: new PublicKey(obj.farmCollateral),\n farmDebt: new PublicKey(obj.farmDebt),\n liquidity: types.ReserveLiquidity.fromJSON(obj.liquidity),\n reserveLiquidityPadding: obj.reserveLiquidityPadding.map(\n (item) => new BN(item)\n ),\n collateral: types.ReserveCollateral.fromJSON(obj.collateral),\n reserveCollateralPadding: obj.reserveCollateralPadding.map(\n (item) => new BN(item)\n ),\n config: types.ReserveConfig.fromJSON(obj.config),\n configPadding: obj.configPadding.map((item) => new BN(item)),\n padding: obj.padding.map((item) => new BN(item)),\n })\n }\n}\n"]}
1
+ {"version":3,"file":"Reserve.js","sourceRoot":"","sources":["../../../src/idl_codegen/accounts/Reserve.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAuD;AACvD,kDAAsB,CAAC,wDAAwD;AAC/E,wDAAyC,CAAC,wDAAwD;AAClG,gDAAiC,CAAC,wDAAwD;AAC1F,4CAAyC;AAwDzC,MAAa,OAAO;IAmDlB,YAAY,MAAqB;QAC/B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,IAAI,KAAK,CAAC,UAAU,mBAAM,MAAM,CAAC,UAAU,EAAG,CAAA;QAChE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,CAAA;QACzC,IAAI,CAAC,cAAc,GAAG,MAAM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C,KAAK,CACT,KAAK,CAAC,GAAG,EAAE,EACX,EAAE,EACF,oDAAoD,CACrD;IACD,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,GAAG,EAAE,SAAS,CAAC;CACzC,CAAC,CAAA","sourcesContent":["import { PublicKey, Connection } from \"@solana/web3.js\"\nimport BN from \"bn.js\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as borsh from \"@coral-xyz/borsh\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport * as types from \"../types\" // eslint-disable-line @typescript-eslint/no-unused-vars\nimport { PROGRAM_ID } from \"../programId\"\n\nexport interface ReserveFields {\n /** Version of the reserve */\n version: BN\n /** Last slot when supply and rates updated */\n lastUpdate: types.LastUpdateFields\n /** Lending market address */\n lendingMarket: PublicKey\n farmCollateral: PublicKey\n farmDebt: PublicKey\n /** Reserve liquidity */\n liquidity: types.ReserveLiquidityFields\n reserveLiquidityPadding: Array<BN>\n /** Reserve collateral */\n collateral: types.ReserveCollateralFields\n reserveCollateralPadding: Array<BN>\n /** Reserve configuration values */\n config: types.ReserveConfigFields\n configPadding: Array<BN>\n borrowedAmountOutsideElevationGroup: BN\n /**\n * Amount of token borrowed in lamport of debt asset in the given\n * elevation group when this reserve is part of the collaterals.\n */\n borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>\n padding: Array<BN>\n}\n\nexport interface ReserveJSON {\n /** Version of the reserve */\n version: string\n /** Last slot when supply and rates updated */\n lastUpdate: types.LastUpdateJSON\n /** Lending market address */\n lendingMarket: string\n farmCollateral: string\n farmDebt: string\n /** Reserve liquidity */\n liquidity: types.ReserveLiquidityJSON\n reserveLiquidityPadding: Array<string>\n /** Reserve collateral */\n collateral: types.ReserveCollateralJSON\n reserveCollateralPadding: Array<string>\n /** Reserve configuration values */\n config: types.ReserveConfigJSON\n configPadding: Array<string>\n borrowedAmountOutsideElevationGroup: string\n /**\n * Amount of token borrowed in lamport of debt asset in the given\n * elevation group when this reserve is part of the collaterals.\n */\n borrowedAmountsAgainstThisReserveInElevationGroups: Array<string>\n padding: Array<string>\n}\n\nexport class Reserve {\n /** Version of the reserve */\n readonly version: BN\n /** Last slot when supply and rates updated */\n readonly lastUpdate: types.LastUpdate\n /** Lending market address */\n readonly lendingMarket: PublicKey\n readonly farmCollateral: PublicKey\n readonly farmDebt: PublicKey\n /** Reserve liquidity */\n readonly liquidity: types.ReserveLiquidity\n readonly reserveLiquidityPadding: Array<BN>\n /** Reserve collateral */\n readonly collateral: types.ReserveCollateral\n readonly reserveCollateralPadding: Array<BN>\n /** Reserve configuration values */\n readonly config: types.ReserveConfig\n readonly configPadding: Array<BN>\n readonly borrowedAmountOutsideElevationGroup: BN\n /**\n * Amount of token borrowed in lamport of debt asset in the given\n * elevation group when this reserve is part of the collaterals.\n */\n readonly borrowedAmountsAgainstThisReserveInElevationGroups: Array<BN>\n readonly padding: Array<BN>\n\n static readonly discriminator = Buffer.from([\n 43, 242, 204, 202, 26, 247, 59, 127,\n ])\n\n static readonly layout = borsh.struct([\n borsh.u64(\"version\"),\n types.LastUpdate.layout(\"lastUpdate\"),\n borsh.publicKey(\"lendingMarket\"),\n borsh.publicKey(\"farmCollateral\"),\n borsh.publicKey(\"farmDebt\"),\n types.ReserveLiquidity.layout(\"liquidity\"),\n borsh.array(borsh.u64(), 150, \"reserveLiquidityPadding\"),\n types.ReserveCollateral.layout(\"collateral\"),\n borsh.array(borsh.u64(), 150, \"reserveCollateralPadding\"),\n types.ReserveConfig.layout(\"config\"),\n borsh.array(borsh.u64(), 117, \"configPadding\"),\n borsh.u64(\"borrowedAmountOutsideElevationGroup\"),\n borsh.array(\n borsh.u64(),\n 32,\n \"borrowedAmountsAgainstThisReserveInElevationGroups\"\n ),\n borsh.array(borsh.u64(), 207, \"padding\"),\n ])\n\n constructor(fields: ReserveFields) {\n this.version = fields.version\n this.lastUpdate = new types.LastUpdate({ ...fields.lastUpdate })\n this.lendingMarket = fields.lendingMarket\n this.farmCollateral = fields.farmCollateral\n this.farmDebt = fields.farmDebt\n this.liquidity = new types.ReserveLiquidity({ ...fields.liquidity })\n this.reserveLiquidityPadding = fields.reserveLiquidityPadding\n this.collateral = new types.ReserveCollateral({ ...fields.collateral })\n this.reserveCollateralPadding = fields.reserveCollateralPadding\n this.config = new types.ReserveConfig({ ...fields.config })\n this.configPadding = fields.configPadding\n this.borrowedAmountOutsideElevationGroup =\n fields.borrowedAmountOutsideElevationGroup\n this.borrowedAmountsAgainstThisReserveInElevationGroups =\n fields.borrowedAmountsAgainstThisReserveInElevationGroups\n this.padding = fields.padding\n }\n\n static async fetch(\n c: Connection,\n address: PublicKey,\n programId: PublicKey = PROGRAM_ID\n ): Promise<Reserve | null> {\n const info = await c.getAccountInfo(address)\n\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n }\n\n static async fetchMultiple(\n c: Connection,\n addresses: PublicKey[],\n programId: PublicKey = PROGRAM_ID\n ): Promise<Array<Reserve | null>> {\n const infos = await c.getMultipleAccountsInfo(addresses)\n\n return infos.map((info) => {\n if (info === null) {\n return null\n }\n if (!info.owner.equals(programId)) {\n throw new Error(\"account doesn't belong to this program\")\n }\n\n return this.decode(info.data)\n })\n }\n\n static decode(data: Buffer): Reserve {\n if (!data.slice(0, 8).equals(Reserve.discriminator)) {\n throw new Error(\"invalid account discriminator\")\n }\n\n const dec = Reserve.layout.decode(data.slice(8))\n\n return new Reserve({\n version: dec.version,\n lastUpdate: types.LastUpdate.fromDecoded(dec.lastUpdate),\n lendingMarket: dec.lendingMarket,\n farmCollateral: dec.farmCollateral,\n farmDebt: dec.farmDebt,\n liquidity: types.ReserveLiquidity.fromDecoded(dec.liquidity),\n reserveLiquidityPadding: dec.reserveLiquidityPadding,\n collateral: types.ReserveCollateral.fromDecoded(dec.collateral),\n reserveCollateralPadding: dec.reserveCollateralPadding,\n config: types.ReserveConfig.fromDecoded(dec.config),\n configPadding: dec.configPadding,\n borrowedAmountOutsideElevationGroup:\n dec.borrowedAmountOutsideElevationGroup,\n borrowedAmountsAgainstThisReserveInElevationGroups:\n dec.borrowedAmountsAgainstThisReserveInElevationGroups,\n padding: dec.padding,\n })\n }\n\n toJSON(): ReserveJSON {\n return {\n version: this.version.toString(),\n lastUpdate: this.lastUpdate.toJSON(),\n lendingMarket: this.lendingMarket.toString(),\n farmCollateral: this.farmCollateral.toString(),\n farmDebt: this.farmDebt.toString(),\n liquidity: this.liquidity.toJSON(),\n reserveLiquidityPadding: this.reserveLiquidityPadding.map((item) =>\n item.toString()\n ),\n collateral: this.collateral.toJSON(),\n reserveCollateralPadding: this.reserveCollateralPadding.map((item) =>\n item.toString()\n ),\n config: this.config.toJSON(),\n configPadding: this.configPadding.map((item) => item.toString()),\n borrowedAmountOutsideElevationGroup:\n this.borrowedAmountOutsideElevationGroup.toString(),\n borrowedAmountsAgainstThisReserveInElevationGroups:\n this.borrowedAmountsAgainstThisReserveInElevationGroups.map((item) =>\n item.toString()\n ),\n padding: this.padding.map((item) => item.toString()),\n }\n }\n\n static fromJSON(obj: ReserveJSON): Reserve {\n return new Reserve({\n version: new BN(obj.version),\n lastUpdate: types.LastUpdate.fromJSON(obj.lastUpdate),\n lendingMarket: new PublicKey(obj.lendingMarket),\n farmCollateral: new PublicKey(obj.farmCollateral),\n farmDebt: new PublicKey(obj.farmDebt),\n liquidity: types.ReserveLiquidity.fromJSON(obj.liquidity),\n reserveLiquidityPadding: obj.reserveLiquidityPadding.map(\n (item) => new BN(item)\n ),\n collateral: types.ReserveCollateral.fromJSON(obj.collateral),\n reserveCollateralPadding: obj.reserveCollateralPadding.map(\n (item) => new BN(item)\n ),\n config: types.ReserveConfig.fromJSON(obj.config),\n configPadding: obj.configPadding.map((item) => new BN(item)),\n borrowedAmountOutsideElevationGroup: new BN(\n obj.borrowedAmountOutsideElevationGroup\n ),\n borrowedAmountsAgainstThisReserveInElevationGroups:\n obj.borrowedAmountsAgainstThisReserveInElevationGroups.map(\n (item) => new BN(item)\n ),\n padding: obj.padding.map((item) => new BN(item)),\n })\n }\n}\n"]}