@gearbox-protocol/sdk 14.12.0-next.66 → 14.12.0-next.68

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 (244) hide show
  1. package/dist/cjs/common-utils/index.js +2 -2
  2. package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +3 -3
  3. package/dist/cjs/common-utils/utils/assets-math.js +7 -7
  4. package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +2 -2
  5. package/dist/cjs/common-utils/utils/creditAccount/debt.js +2 -2
  6. package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +5 -5
  7. package/dist/cjs/common-utils/utils/index.js +2 -2
  8. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +2 -2
  9. package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +5 -5
  10. package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +2 -2
  11. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +2 -2
  12. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +4 -4
  13. package/dist/cjs/model/history.js +28 -0
  14. package/dist/cjs/model/history.schema.js +84 -0
  15. package/dist/cjs/model/index.js +77 -0
  16. package/dist/cjs/model/liquidations.js +23 -0
  17. package/dist/cjs/model/liquidations.schema.js +93 -0
  18. package/dist/cjs/model/opportunities.js +55 -0
  19. package/dist/cjs/model/opportunities.schema.js +223 -0
  20. package/dist/cjs/model/package.json +1 -0
  21. package/dist/cjs/model/positions.js +1 -0
  22. package/dist/cjs/model/positions.schema.js +120 -0
  23. package/dist/cjs/model/primitives.js +1 -0
  24. package/dist/cjs/model/primitives.schema.js +85 -0
  25. package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
  26. package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
  27. package/dist/cjs/new-sdk/index.js +11 -0
  28. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
  29. package/dist/cjs/new-sdk/opportunities/index.js +4 -0
  30. package/dist/cjs/new-sdk/opportunities/types.js +1 -0
  31. package/dist/cjs/new-sdk/package.json +1 -0
  32. package/dist/cjs/new-sdk/types.js +22 -0
  33. package/dist/cjs/new-sdk/utils/history.js +1 -0
  34. package/dist/cjs/new-sdk/utils/index.js +2 -0
  35. package/dist/cjs/offchain/GearboxAPI.js +33 -0
  36. package/dist/cjs/offchain/index.js +8 -0
  37. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
  38. package/dist/cjs/offchain/opportunities/index.js +4 -0
  39. package/dist/cjs/offchain/package.json +1 -0
  40. package/dist/cjs/offchain/types.js +1 -0
  41. package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
  42. package/dist/cjs/rewards/rewards/api.js +2 -2
  43. package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
  44. package/dist/cjs/sdk/MultichainSDK.js +18 -2
  45. package/dist/cjs/sdk/OnchainSDK.js +8 -1
  46. package/dist/cjs/sdk/accounts/index.js +2 -0
  47. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +161 -106
  48. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  49. package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
  50. package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
  51. package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
  52. package/dist/cjs/sdk/base/TokensMeta.js +51 -0
  53. package/dist/cjs/sdk/base/index.js +2 -0
  54. package/dist/cjs/sdk/chain/chains.js +76 -0
  55. package/dist/cjs/sdk/chain/index.js +4 -0
  56. package/dist/cjs/sdk/core/errors.js +13 -0
  57. package/dist/cjs/sdk/core/index.js +2 -1
  58. package/dist/cjs/sdk/index.js +25 -1
  59. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
  60. package/dist/cjs/sdk/market/MarketSuite.js +159 -0
  61. package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  62. package/dist/cjs/sdk/market/credit/CreditSuite.js +92 -0
  63. package/dist/cjs/sdk/market/math.js +104 -0
  64. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  65. package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  66. package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  67. package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
  68. package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
  69. package/dist/cjs/sdk/market/pool/math.js +44 -0
  70. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  71. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
  72. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +48 -0
  73. package/dist/cjs/sdk/opportunities/index.js +12 -0
  74. package/dist/cjs/sdk/types/multichain.js +1 -0
  75. package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
  76. package/dist/cjs/sdk/utils/index.js +3 -0
  77. package/dist/cjs/sdk/utils/zod.js +12 -0
  78. package/dist/esm/common-utils/index.js +1 -1
  79. package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
  80. package/dist/esm/common-utils/utils/assets-math.js +1 -1
  81. package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
  82. package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
  83. package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
  84. package/dist/esm/common-utils/utils/index.js +1 -1
  85. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
  86. package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
  87. package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
  88. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
  89. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
  90. package/dist/esm/dev/AccountOpener.js +1 -1
  91. package/dist/esm/dev/withdrawalUtils.js +1 -1
  92. package/dist/esm/model/history.js +26 -0
  93. package/dist/esm/model/history.schema.js +76 -0
  94. package/dist/esm/model/index.js +11 -0
  95. package/dist/esm/model/liquidations.js +22 -0
  96. package/dist/esm/model/liquidations.schema.js +85 -0
  97. package/dist/esm/model/opportunities.js +51 -0
  98. package/dist/esm/model/opportunities.schema.js +201 -0
  99. package/dist/esm/model/package.json +1 -0
  100. package/dist/esm/model/positions.js +1 -0
  101. package/dist/esm/model/positions.schema.js +109 -0
  102. package/dist/esm/model/primitives.js +1 -0
  103. package/dist/esm/model/primitives.schema.js +75 -0
  104. package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
  105. package/dist/esm/new-sdk/GearboxSDK.js +121 -0
  106. package/dist/esm/new-sdk/index.js +7 -0
  107. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
  108. package/dist/esm/new-sdk/opportunities/index.js +3 -0
  109. package/dist/esm/new-sdk/opportunities/types.js +1 -0
  110. package/dist/esm/new-sdk/package.json +1 -0
  111. package/dist/esm/new-sdk/types.js +21 -0
  112. package/dist/esm/new-sdk/utils/history.js +1 -0
  113. package/dist/esm/new-sdk/utils/index.js +2 -0
  114. package/dist/esm/offchain/GearboxAPI.js +32 -0
  115. package/dist/esm/offchain/index.js +5 -0
  116. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
  117. package/dist/esm/offchain/opportunities/index.js +2 -0
  118. package/dist/esm/offchain/package.json +1 -0
  119. package/dist/esm/offchain/types.js +1 -0
  120. package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
  121. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  122. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  123. package/dist/esm/rewards/rewards/api.js +1 -1
  124. package/dist/esm/rewards/rewards/extra-apy.js +1 -1
  125. package/dist/esm/sdk/MultichainSDK.js +18 -2
  126. package/dist/esm/sdk/OnchainSDK.js +8 -1
  127. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  128. package/dist/esm/sdk/accounts/index.js +2 -2
  129. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +164 -109
  130. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
  131. package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
  132. package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
  133. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  134. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  135. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  136. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  137. package/dist/esm/sdk/base/MultichainConstruct.js +79 -0
  138. package/dist/esm/sdk/base/TokensMeta.js +53 -2
  139. package/dist/esm/sdk/base/index.js +2 -1
  140. package/dist/esm/sdk/chain/chains.js +74 -2
  141. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  142. package/dist/esm/sdk/chain/index.js +2 -2
  143. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  144. package/dist/esm/sdk/core/errors.js +13 -1
  145. package/dist/esm/sdk/core/index.js +2 -2
  146. package/dist/esm/sdk/index.js +11 -5
  147. package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
  148. package/dist/esm/sdk/market/MarketSuite.js +159 -0
  149. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  150. package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
  151. package/dist/esm/sdk/market/credit/CreditSuite.js +92 -0
  152. package/dist/esm/sdk/market/math.js +98 -0
  153. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
  154. package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
  155. package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
  156. package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
  157. package/dist/esm/sdk/market/pool/PoolV310Contract.js +28 -1
  158. package/dist/esm/sdk/market/pool/math.js +41 -0
  159. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
  160. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  161. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  162. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +59 -0
  163. package/dist/esm/sdk/opportunities/OpportunitiesService.js +47 -0
  164. package/dist/esm/sdk/opportunities/index.js +4 -0
  165. package/dist/esm/sdk/pools/PoolService.js +1 -1
  166. package/dist/esm/sdk/types/multichain.js +1 -0
  167. package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
  168. package/dist/esm/sdk/utils/index.js +3 -2
  169. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  170. package/dist/esm/sdk/utils/zod.js +13 -2
  171. package/dist/types/common-utils/index.d.ts +1 -1
  172. package/dist/types/common-utils/utils/index.d.ts +1 -1
  173. package/dist/types/model/history.d.ts +105 -0
  174. package/dist/types/model/history.schema.d.ts +66 -0
  175. package/dist/types/model/index.d.ts +11 -0
  176. package/dist/types/model/liquidations.d.ts +238 -0
  177. package/dist/types/model/liquidations.schema.d.ts +294 -0
  178. package/dist/types/model/opportunities.d.ts +584 -0
  179. package/dist/types/model/opportunities.schema.d.ts +1037 -0
  180. package/dist/types/model/positions.d.ts +247 -0
  181. package/dist/types/model/positions.schema.d.ts +701 -0
  182. package/dist/types/model/primitives.d.ts +194 -0
  183. package/dist/types/model/primitives.schema.d.ts +81 -0
  184. package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
  185. package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
  186. package/dist/types/new-sdk/index.d.ts +9 -0
  187. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
  188. package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
  189. package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
  190. package/dist/types/new-sdk/types.d.ts +149 -0
  191. package/dist/types/new-sdk/utils/history.d.ts +44 -0
  192. package/dist/types/new-sdk/utils/index.d.ts +2 -0
  193. package/dist/types/offchain/GearboxAPI.d.ts +31 -0
  194. package/dist/types/offchain/index.d.ts +5 -0
  195. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
  196. package/dist/types/offchain/opportunities/index.d.ts +2 -0
  197. package/dist/types/offchain/types.d.ts +50 -0
  198. package/dist/types/sdk/MultichainSDK.d.ts +15 -2
  199. package/dist/types/sdk/OnchainSDK.d.ts +9 -3
  200. package/dist/types/sdk/accounts/index.d.ts +3 -3
  201. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
  202. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
  203. package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
  204. package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
  205. package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
  206. package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
  207. package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
  208. package/dist/types/sdk/base/index.d.ts +2 -1
  209. package/dist/types/sdk/chain/chains.d.ts +68 -1
  210. package/dist/types/sdk/chain/index.d.ts +2 -2
  211. package/dist/types/sdk/core/errors.d.ts +10 -1
  212. package/dist/types/sdk/core/index.d.ts +2 -2
  213. package/dist/types/sdk/index.d.ts +15 -8
  214. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
  215. package/dist/types/sdk/market/MarketSuite.d.ts +98 -1
  216. package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
  217. package/dist/types/sdk/market/credit/CreditSuite.d.ts +43 -0
  218. package/dist/types/sdk/market/credit/types.d.ts +22 -0
  219. package/dist/types/sdk/market/index.d.ts +2 -2
  220. package/dist/types/sdk/market/math.d.ts +74 -0
  221. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
  222. package/dist/types/sdk/market/oracle/types.d.ts +46 -0
  223. package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
  224. package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
  225. package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
  226. package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
  227. package/dist/types/sdk/market/pool/math.d.ts +57 -0
  228. package/dist/types/sdk/market/pool/types.d.ts +23 -0
  229. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
  230. package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
  231. package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
  232. package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +42 -0
  233. package/dist/types/sdk/opportunities/index.d.ts +4 -0
  234. package/dist/types/sdk/types/index.d.ts +2 -1
  235. package/dist/types/sdk/types/multichain.d.ts +65 -0
  236. package/dist/types/sdk/types/state.d.ts +1 -1
  237. package/dist/types/sdk/types/transactions.d.ts +3 -0
  238. package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
  239. package/dist/types/sdk/utils/index.d.ts +3 -2
  240. package/dist/types/sdk/utils/zod.d.ts +6 -2
  241. package/package.json +16 -1
  242. package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
  243. package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
  244. package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
@@ -0,0 +1,104 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_constants_math = require("../constants/math.js");
3
+ //#region src/sdk/market/math.ts
4
+ /**
5
+ * Conversions between the units the protocol stores and the basis points the
6
+ * read model exposes.
7
+ *
8
+ * These live here rather than inside the service so that the on-chain adapter,
9
+ * the merger and any future consumer of the read model share one definition of
10
+ * every derived value.
11
+ **/
12
+ const FULL = Number(require_sdk_constants_math.PERCENTAGE_FACTOR);
13
+ /**
14
+ * Converts a ray-scaled rate (`10 ** 27` = 100%) to basis points, truncating
15
+ * towards zero.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * rayToBps(50_000_000_000_000_000_000_000_000n) // 500, i.e. 5%
20
+ * ```
21
+ **/
22
+ function rayToBps(ray) {
23
+ return Number(ray * require_sdk_constants_math.PERCENTAGE_FACTOR / require_sdk_constants_math.RAY);
24
+ }
25
+ /**
26
+ * Converts a USD value in the oracle's 8-decimal fixed point to a float.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * usdToNumber(150_050_000_000n) // 1500.5
31
+ * ```
32
+ **/
33
+ function usdToNumber(usd) {
34
+ return Number(usd) / Number(require_sdk_constants_math.PRICE_DECIMALS);
35
+ }
36
+ /**
37
+ * Share of capital currently borrowed, in basis points. Returns `0` when there
38
+ * is nothing to borrow from, and never exceeds 100%.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * utilizationBps(750n, 1000n) // 7500, i.e. 75%
43
+ * ```
44
+ **/
45
+ function utilizationBps(borrowed, total) {
46
+ if (total <= 0n || borrowed <= 0n) return 0;
47
+ const utilization = Number(borrowed * require_sdk_constants_math.PERCENTAGE_FACTOR / total);
48
+ return Math.min(utilization, FULL);
49
+ }
50
+ /**
51
+ * Annual cost of debt for a credit manager, in basis points: the pool's base
52
+ * rate plus the protocol's cut of the accrued interest.
53
+ *
54
+ * @param baseInterestRate - Pool base rate in ray.
55
+ * @param feeInterest - Credit manager interest fee in basis points.
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * // 5% base rate, 50% interest fee
60
+ * borrowApyBps(50_000_000_000_000_000_000_000_000n, 5000) // 750, i.e. 7.5%
61
+ * ```
62
+ **/
63
+ function borrowApyBps(baseInterestRate, feeInterest) {
64
+ return rayToBps(baseInterestRate * (require_sdk_constants_math.PERCENTAGE_FACTOR + BigInt(feeInterest)) / require_sdk_constants_math.PERCENTAGE_FACTOR);
65
+ }
66
+ /**
67
+ * Highest leverage a liquidation threshold allows: `1 / (1 - lt)`.
68
+ *
69
+ * A threshold of 100% or more would allow unbounded leverage; such tokens are
70
+ * not strategies and are filtered out before this is called, so the guard here
71
+ * only exists to keep the function total.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * maxLeverage(9000) // 10
76
+ * maxLeverage(8000) // 5
77
+ * ```
78
+ **/
79
+ function maxLeverage(liquidationThreshold) {
80
+ const equity = FULL - liquidationThreshold;
81
+ return equity > 0 ? FULL / equity : Number.POSITIVE_INFINITY;
82
+ }
83
+ /**
84
+ * Annual quota cost scaled to the debt a maximally leveraged position carries,
85
+ * in basis points. Every unit of own capital carries `maxLeverage - 1` units of
86
+ * debt, and the quota is paid on the whole quoted position.
87
+ *
88
+ * @example
89
+ * ```ts
90
+ * // 2.5% quota rate at 5x leverage
91
+ * additionalBorrowApyBps(250, 5) // 1000, i.e. 10%
92
+ * ```
93
+ **/
94
+ function additionalBorrowApyBps(quotaRate, leverage) {
95
+ if (!Number.isFinite(leverage)) return 0;
96
+ return Math.round(quotaRate * Math.max(leverage - 1, 0));
97
+ }
98
+ //#endregion
99
+ exports.additionalBorrowApyBps = additionalBorrowApyBps;
100
+ exports.borrowApyBps = borrowApyBps;
101
+ exports.maxLeverage = maxLeverage;
102
+ exports.rayToBps = rayToBps;
103
+ exports.usdToNumber = usdToNumber;
104
+ exports.utilizationBps = utilizationBps;
@@ -7,6 +7,7 @@ const require_sdk_utils_formatter = require("../../utils/formatter.js");
7
7
  require("../../utils/index.js");
8
8
  const require_sdk_base_BaseContract = require("../../base/BaseContract.js");
9
9
  require("../../base/index.js");
10
+ const require_sdk_market_math = require("../math.js");
10
11
  const require_sdk_market_pricefeeds_PriceFeedRef = require("../pricefeeds/PriceFeedRef.js");
11
12
  const require_abi_compressors_priceFeedCompressor = require("../../../abi/compressors/priceFeedCompressor.js");
12
13
  require("../pricefeeds/index.js");
@@ -104,6 +105,57 @@ var PriceOracleBaseContract = class extends require_sdk_base_BaseContract.BaseCo
104
105
  return amount * 10n ** BigInt(this.tokensMeta.decimals(to)) / price;
105
106
  }
106
107
  /**
108
+ * {@inheritDoc IPriceOracleContract.safeUsdValue}
109
+ **/
110
+ safeUsdValue(token, amount) {
111
+ try {
112
+ return require_sdk_market_math.usdToNumber(this.convertToUSD(token, amount));
113
+ } catch (e) {
114
+ this.logger?.debug(`cannot price ${this.labelAddress(token)}: ${e}`);
115
+ return null;
116
+ }
117
+ }
118
+ /**
119
+ * {@inheritDoc IPriceOracleContract.toAmount}
120
+ **/
121
+ toAmount = (token, value) => {
122
+ return {
123
+ value,
124
+ valueUsd: this.safeUsdValue(token, value)
125
+ };
126
+ };
127
+ /**
128
+ * {@inheritDoc IPriceOracleContract.toTokenAmount}
129
+ **/
130
+ toTokenAmount = (token, value) => {
131
+ return {
132
+ token: this.tokensMeta.mustGetToken(token),
133
+ ...this.toAmount(token, value)
134
+ };
135
+ };
136
+ /**
137
+ * {@inheritDoc IPriceOracleContract.priceFeedData}
138
+ **/
139
+ priceFeedData(token) {
140
+ const ref = this.mainPriceFeeds.get(token);
141
+ if (!ref) throw new Error(`no main price feed for ${this.labelAddress(token)} in oracle ${this.labelAddress(this.address)}`);
142
+ return ref.priceFeed.describe();
143
+ }
144
+ /**
145
+ * {@inheritDoc IPriceOracleContract.priceFeedSummary}
146
+ **/
147
+ priceFeedSummary(underlying, collateral) {
148
+ const collateralUnit = 10n ** BigInt(this.tokensMeta.decimals(collateral));
149
+ const underlyingUnit = 10n ** BigInt(this.tokensMeta.decimals(underlying));
150
+ return {
151
+ underlyingPriceInUsd: require_sdk_market_math.usdToNumber(this.mainPrice(underlying)),
152
+ collateralPriceInUsd: require_sdk_market_math.usdToNumber(this.mainPrice(collateral)),
153
+ collateralPriceInUnderlying: Number(this.convert(collateral, underlying, collateralUnit)) / Number(underlyingUnit),
154
+ underlyingFeed: this.priceFeedData(underlying),
155
+ collateralFeed: this.priceFeedData(collateral)
156
+ };
157
+ }
158
+ /**
107
159
  * {@inheritDoc IPriceOracleContract.priceFeeds}
108
160
  **/
109
161
  get priceFeeds() {
@@ -4,6 +4,7 @@ require("../../utils/index.js");
4
4
  const require_sdk_base_BaseContract = require("../../base/BaseContract.js");
5
5
  require("../../base/index.js");
6
6
  const require_abi_310_iLinearInterestRateModelV310 = require("../../../abi/310/iLinearInterestRateModelV310.js");
7
+ const require_sdk_market_pool_math = require("./math.js");
7
8
  let viem = require("viem");
8
9
  //#region src/sdk/market/pool/LinearInterestRateModelContract.ts
9
10
  const abi = require_abi_310_iLinearInterestRateModelV310.iLinearInterestRateModelV310Abi;
@@ -59,6 +60,35 @@ var LinearInterestRateModelContract = class extends require_sdk_base_BaseContrac
59
60
  this.Rslope3 = Rslope3;
60
61
  this.isBorrowingMoreU2Forbidden = isBorrowingMoreU2Forbidden;
61
62
  }
63
+ /**
64
+ * The model's own parameters, gathered for the rate math.
65
+ */
66
+ get params() {
67
+ return {
68
+ U1: this.U1,
69
+ U2: this.U2,
70
+ Rbase: this.Rbase,
71
+ Rslope1: this.Rslope1,
72
+ Rslope2: this.Rslope2,
73
+ Rslope3: this.Rslope3,
74
+ isBorrowingMoreU2Forbidden: this.isBorrowingMoreU2Forbidden
75
+ };
76
+ }
77
+ /**
78
+ * The model evaluated into chart-ready points, so that no consumer has to
79
+ * reimplement it.
80
+ */
81
+ rateCurve() {
82
+ const { params } = this;
83
+ return {
84
+ points: require_sdk_market_pool_math.rateCurveUtilizations(params).map((utilization) => ({
85
+ utilization,
86
+ supplyApy: require_sdk_market_pool_math.supplyRateAtUtilization(utilization, params),
87
+ borrowApy: require_sdk_market_pool_math.borrowRateAtUtilization(utilization, params)
88
+ })),
89
+ borrowingLimitUtilization: params.isBorrowingMoreU2Forbidden ? params.U2 : null
90
+ };
91
+ }
62
92
  stateHuman(raw) {
63
93
  return {
64
94
  ...super.stateHuman(raw),
@@ -21,6 +21,32 @@ var PoolQuotaKeeperV310Contract = class extends require_sdk_base_BaseContract.Ba
21
21
  return [q.token, q];
22
22
  }), "quotas");
23
23
  }
24
+ /**
25
+ * Whether the market still accepts quota for a token: a token whose quota is
26
+ * inactive or whose limit is exhausted can no longer back a new position.
27
+ *
28
+ * @param token - Token address.
29
+ */
30
+ hasActiveQuota(token) {
31
+ const quota = this.quotas.get(token);
32
+ return !!quota?.isActive && quota.limit > 0n;
33
+ }
34
+ /**
35
+ * Every token the market still accepts quota for, see
36
+ * {@link hasActiveQuota}.
37
+ */
38
+ get activeQuotaTokens() {
39
+ return this.quotas.keys().filter((token) => this.hasActiveQuota(token));
40
+ }
41
+ /**
42
+ * Annual quota rate paid on a quoted token, in basis points, or `0` when the
43
+ * market does not quote it.
44
+ *
45
+ * @param token - Quoted token address.
46
+ */
47
+ quotaRate(token) {
48
+ return this.quotas.get(token)?.rate ?? 0;
49
+ }
24
50
  stateHuman(raw = true) {
25
51
  return {
26
52
  ...super.stateHuman(raw),
@@ -100,6 +100,34 @@ var PoolSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
100
100
  return this.pool.underlying;
101
101
  }
102
102
  /**
103
+ * {@inheritDoc IPoolContract.unwrappedUnderlying}
104
+ */
105
+ get unwrappedUnderlying() {
106
+ return this.pool.unwrappedUnderlying;
107
+ }
108
+ /**
109
+ * {@inheritDoc IPoolContract.utilization}
110
+ */
111
+ get utilization() {
112
+ return this.pool.utilization;
113
+ }
114
+ /**
115
+ * Whether the pool is paused, which blocks borrowing across every connected
116
+ * credit suite.
117
+ */
118
+ get isPaused() {
119
+ return this.pool.isPaused;
120
+ }
121
+ /**
122
+ * Interest rate curve of the pool's rate model.
123
+ *
124
+ * @throws If the market uses an interest-rate model that is not linear, and
125
+ * therefore has no curve the SDK can evaluate.
126
+ */
127
+ get rateCurve() {
128
+ return this.linearModel.rateCurve();
129
+ }
130
+ /**
103
131
  * RWA factory associated with the pool's underlying, undefined for non-RWA markets.
104
132
  */
105
133
  get rwaFactory() {
@@ -2,10 +2,13 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_abi_iPausable = require("../../../abi/iPausable.js");
3
3
  const require_abi_310_generated = require("../../../abi/310/generated.js");
4
4
  const require_sdk_utils_AddressMap = require("../../utils/AddressMap.js");
5
+ const require_sdk_constants_math = require("../../constants/math.js");
6
+ require("../../constants/index.js");
5
7
  const require_sdk_utils_formatter = require("../../utils/formatter.js");
6
8
  require("../../utils/index.js");
7
9
  const require_sdk_base_BaseContract = require("../../base/BaseContract.js");
8
10
  require("../../base/index.js");
11
+ const require_sdk_market_math = require("../math.js");
9
12
  //#region src/sdk/market/pool/PoolV310Contract.ts
10
13
  const abi = [...require_abi_310_generated.iPoolV310Abi, ...require_abi_iPausable.iPausableAbi];
11
14
  var PoolV310Contract = class extends require_sdk_base_BaseContract.BaseContract {
@@ -32,6 +35,30 @@ var PoolV310Contract = class extends require_sdk_base_BaseContract.BaseContract
32
35
  const meta = this.#sdk.tokensMeta.mustGet(this.underlying);
33
36
  if (this.#sdk.tokensMeta.isRWAUnderlying(meta)) return this.#sdk.mustGetContract(meta.rwaFactory);
34
37
  }
38
+ /**
39
+ * {@inheritDoc IPoolContract.borrowed}
40
+ */
41
+ get borrowed() {
42
+ return this.expectedLiquidity > this.availableLiquidity ? this.expectedLiquidity - this.availableLiquidity : 0n;
43
+ }
44
+ /**
45
+ * {@inheritDoc IPoolContract.totalAssets}
46
+ */
47
+ get totalAssets() {
48
+ return this.totalSupply * this.dieselRate / require_sdk_constants_math.RAY;
49
+ }
50
+ /**
51
+ * {@inheritDoc IPoolContract.utilization}
52
+ */
53
+ get utilization() {
54
+ return require_sdk_market_math.utilizationBps(this.borrowed, this.expectedLiquidity);
55
+ }
56
+ /**
57
+ * {@inheritDoc IPoolContract.unwrappedUnderlying}
58
+ */
59
+ get unwrappedUnderlying() {
60
+ return this.tokensMeta.unwrapRWA(this.underlying);
61
+ }
35
62
  stateHuman(raw = true) {
36
63
  return {
37
64
  ...super.stateHuman(raw),
@@ -0,0 +1,44 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_constants_math = require("../../constants/math.js");
3
+ //#region src/sdk/market/pool/math.ts
4
+ const FULL = Number(require_sdk_constants_math.PERCENTAGE_FACTOR);
5
+ /**
6
+ * Base rate borrowers pay at a given utilization, in basis points, following
7
+ * the linear interest rate model's three segments.
8
+ *
9
+ * The result excludes the per-credit-manager interest fee: the model belongs to
10
+ * the pool, and every credit manager of a market can charge a different one.
11
+ **/
12
+ function borrowRateAtUtilization(utilization, params) {
13
+ const { U1, U2, Rbase, Rslope1, Rslope2, Rslope3 } = params;
14
+ const u = Math.min(Math.max(utilization, 0), FULL);
15
+ if (u <= 0) return Rbase;
16
+ if (u <= U1) return Math.round(Rbase + Rslope1 * u / U1);
17
+ if (u <= U2) return Math.round(Rbase + Rslope1 + Rslope2 * (u - U1) / Math.max(U2 - U1, 1));
18
+ return Math.round(Rbase + Rslope1 + Rslope2 + Rslope3 * (u - U2) / Math.max(FULL - U2, 1));
19
+ }
20
+ /**
21
+ * Rate depositors earn at a given utilization, in basis points: the interest
22
+ * borrowers pay, spread over the pool's whole liquidity.
23
+ **/
24
+ function supplyRateAtUtilization(utilization, params) {
25
+ const u = Math.min(Math.max(utilization, 0), FULL);
26
+ return Math.round(borrowRateAtUtilization(u, params) * u / FULL);
27
+ }
28
+ /**
29
+ * Utilizations the rate curve is sampled at: a fixed grid plus both kinks of
30
+ * the model, so the borrow leg is exact and the supply leg — which is
31
+ * quadratic between kinks — is smooth.
32
+ **/
33
+ function rateCurveUtilizations(params) {
34
+ const step = FULL / 20;
35
+ const grid = /* @__PURE__ */ new Set();
36
+ for (let u = 0; u <= FULL; u += step) grid.add(u);
37
+ grid.add(params.U1);
38
+ grid.add(params.U2);
39
+ return [...grid].filter((u) => u >= 0 && u <= FULL).sort((a, b) => a - b);
40
+ }
41
+ //#endregion
42
+ exports.borrowRateAtUtilization = borrowRateAtUtilization;
43
+ exports.rateCurveUtilizations = rateCurveUtilizations;
44
+ exports.supplyRateAtUtilization = supplyRateAtUtilization;
@@ -89,6 +89,23 @@ var AbstractPriceFeedContract = class extends require_sdk_base_BaseContract.Base
89
89
  const underlying = this.underlyingPriceFeeds.flatMap((f) => f.priceFeed.updatableDependencies());
90
90
  return require_sdk_market_pricefeeds_isUpdatablePriceFeed.isUpdatablePriceFeed(this) ? [this, ...underlying] : underlying;
91
91
  }
92
+ /**
93
+ * {@inheritDoc IPriceFeedContract.describe}
94
+ */
95
+ describe() {
96
+ let dependencies = [];
97
+ try {
98
+ dependencies = this.underlyingPriceFeeds.map((ref) => ref.priceFeed.describe());
99
+ } catch {
100
+ dependencies = [];
101
+ }
102
+ return {
103
+ name: this.name,
104
+ type: this.contractType,
105
+ feedAddress: this.address,
106
+ dependencies
107
+ };
108
+ }
92
109
  };
93
110
  //#endregion
94
111
  exports.AbstractPriceFeedContract = AbstractPriceFeedContract;
@@ -0,0 +1,60 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_chain_chains = require("../chain/chains.js");
3
+ const require_sdk_base_MultichainConstruct = require("../base/MultichainConstruct.js");
4
+ require("../base/index.js");
5
+ //#region src/sdk/opportunities/MultichainOpportunitiesService.ts
6
+ /**
7
+ * Cross-chain counterpart of {@link OpportunitiesService}.
8
+ *
9
+ * Fans out over every chain configured in {@link MultichainSDK}. A chain that
10
+ * fails is logged and skipped so one dead RPC does not empty the list; its
11
+ * failure is reported in {@link MultichainResult.meta}.
12
+ *
13
+ * Detail reads need no fan-out: an opportunity key names its chain.
14
+ *
15
+ * @typeParam Plugins - Map of attached plugin types.
16
+ **/
17
+ var MultichainOpportunitiesService = class extends require_sdk_base_MultichainConstruct.MultichainConstruct {
18
+ /**
19
+ * Opportunities of all queried chains, see {@link OpportunitiesService.list}.
20
+ *
21
+ * A filter that names chains narrows the fan-out itself, so chains whose rows
22
+ * would be discarded are never queried and never appear in the meta.
23
+ **/
24
+ async list(filter) {
25
+ return this.queryChains({
26
+ networks: this.#networksOf(filter),
27
+ label: "list opportunities",
28
+ run: (sdk) => sdk.opportunities.list(filter)
29
+ });
30
+ }
31
+ /**
32
+ * {@inheritDoc OpportunitiesService.getPool}
33
+ **/
34
+ async getPool(key) {
35
+ return this.sdk.chain(key.chainId).opportunities.getPool(key);
36
+ }
37
+ /**
38
+ * {@inheritDoc OpportunitiesService.getStrategy}
39
+ **/
40
+ async getStrategy(key) {
41
+ return this.sdk.chain(key.chainId).opportunities.getStrategy(key);
42
+ }
43
+ /**
44
+ * Chains named by the filter, or `undefined` to query all of them. Chain ids
45
+ * the SDK does not support are dropped here rather than reported as failures:
46
+ * a filter naming them is a narrowing, not a request.
47
+ **/
48
+ #networksOf(filter) {
49
+ if (!filter?.chainIds) return;
50
+ const networks = [];
51
+ for (const chainId of filter.chainIds) try {
52
+ networks.push(require_sdk_chain_chains.getNetworkType(chainId));
53
+ } catch {
54
+ this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
55
+ }
56
+ return networks;
57
+ }
58
+ };
59
+ //#endregion
60
+ exports.MultichainOpportunitiesService = MultichainOpportunitiesService;
@@ -0,0 +1,48 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
3
+ require("../base/index.js");
4
+ //#region src/sdk/opportunities/OpportunitiesService.ts
5
+ /**
6
+ * Builds the `opportunities` read model from the chain.
7
+ *
8
+ * Every value in a row is market state the SDK already holds, so a list costs
9
+ * no RPC round-trip at all. Yield figures that fold in incentives, points or
10
+ * history are deliberately absent: they are the backend's job, and this service
11
+ * never guesses them. So is the size of a strategy — summing it takes a sweep
12
+ * over every credit account of the chain, which is too expensive for a list.
13
+ *
14
+ * The rows themselves are assembled by the market wrappers — see
15
+ * {@link MarketSuite.opportunities} — because every value in them is market
16
+ * state. This service only picks the markets and applies the filter.
17
+ **/
18
+ var OpportunitiesService = class extends require_sdk_base_SDKConstruct.SDKConstruct {
19
+ /**
20
+ * Every pool and strategy of every loaded market on this chain.
21
+ *
22
+ * @param filter - Optional narrowing, applied to the built rows.
23
+ **/
24
+ async list(filter) {
25
+ if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
26
+ return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
27
+ }
28
+ /**
29
+ * A single pool opportunity plus its interest rate curve and quotas.
30
+ *
31
+ * @throws If no loaded market has this pool.
32
+ **/
33
+ async getPool(key) {
34
+ return this.sdk.marketRegister.findByPool(key.pool).poolOpportunityDetail();
35
+ }
36
+ /**
37
+ * A single strategy opportunity plus the rate curve of the pool it borrows
38
+ * from and the price feeds its liquidation price depends on.
39
+ *
40
+ * @throws If the credit manager is unknown, or does not accept the requested
41
+ * collateral as a strategy.
42
+ **/
43
+ async getStrategy(key) {
44
+ return this.sdk.marketRegister.findByCreditManager(key.creditManager).strategyOpportunityDetail(key.creditManager, key.targetCollateral);
45
+ }
46
+ };
47
+ //#endregion
48
+ exports.OpportunitiesService = OpportunitiesService;
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_sdk_market_math = require("../market/math.js");
3
+ const require_sdk_opportunities_MultichainOpportunitiesService = require("./MultichainOpportunitiesService.js");
4
+ const require_sdk_opportunities_OpportunitiesService = require("./OpportunitiesService.js");
5
+ exports.MultichainOpportunitiesService = require_sdk_opportunities_MultichainOpportunitiesService.MultichainOpportunitiesService;
6
+ exports.OpportunitiesService = require_sdk_opportunities_OpportunitiesService.OpportunitiesService;
7
+ exports.additionalBorrowApyBps = require_sdk_market_math.additionalBorrowApyBps;
8
+ exports.borrowApyBps = require_sdk_market_math.borrowApyBps;
9
+ exports.maxLeverage = require_sdk_market_math.maxLeverage;
10
+ exports.rayToBps = require_sdk_market_math.rayToBps;
11
+ exports.usdToNumber = require_sdk_market_math.usdToNumber;
12
+ exports.utilizationBps = require_sdk_market_math.utilizationBps;
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/common-utils/utils/bigint-math.ts
2
+ //#region src/sdk/utils/bigint-math.ts
3
3
  /**
4
4
  * Utility namespace for common `bigint` operations.
5
5
  *
@@ -17,20 +17,20 @@ var BigIntMath = class {
17
17
  static abs = (x) => x < 0n ? -x : x;
18
18
  /**
19
19
  * Returns the greater of two bigint values.
20
- *
21
- * @param a First candidate value.
22
- * @param b Second candidate value.
23
- * @returns The larger value between `a` and `b`.
20
+ * @param values - The values to find the maximum of.
21
+ * @returns The maximum value.
24
22
  */
25
- static max = (a, b) => a > b ? a : b;
23
+ static max = (...values) => {
24
+ return values.reduce((max, v) => v > max ? v : max);
25
+ };
26
26
  /**
27
27
  * Returns the smaller of two bigint values.
28
- *
29
- * @param a First candidate value.
30
- * @param b Second candidate value.
31
- * @returns The smaller value between `a` and `b`.
28
+ * @param values - The values to find the minimum of.
29
+ * @returns The minimum value.
32
30
  */
33
- static min = (a, b) => a < b ? a : b;
31
+ static min = (...values) => {
32
+ return values.reduce((min, v) => v < min ? v : min);
33
+ };
34
34
  /**
35
35
  * Returns the negative form of a bigint if it is currently positive.
36
36
  *
@@ -4,6 +4,7 @@ const require_sdk_utils_AddressSet = require("./AddressSet.js");
4
4
  const require_sdk_utils_AssetsMap = require("./AssetsMap.js");
5
5
  const require_sdk_utils_json = require("./json.js");
6
6
  const require_sdk_utils_abi_decode = require("./abi-decode.js");
7
+ const require_sdk_utils_bigint_math = require("./bigint-math.js");
7
8
  const require_sdk_utils_bytes32ToString = require("./bytes32ToString.js");
8
9
  const require_sdk_utils_childLogger = require("./childLogger.js");
9
10
  const require_sdk_utils_createRawTx = require("./createRawTx.js");
@@ -20,8 +21,10 @@ const require_sdk_utils_zod = require("./zod.js");
20
21
  exports.AddressMap = require_sdk_utils_AddressMap.AddressMap;
21
22
  exports.AddressSet = require_sdk_utils_AddressSet.AddressSet;
22
23
  exports.AssetsMap = require_sdk_utils_AssetsMap.AssetsMap;
24
+ exports.BigIntMath = require_sdk_utils_bigint_math.BigIntMath;
23
25
  exports.TypedObjectUtils = require_sdk_utils_mappers.TypedObjectUtils;
24
26
  exports.ZodAddress = require_sdk_utils_zod.ZodAddress;
27
+ exports.ZodHex = require_sdk_utils_zod.ZodHex;
25
28
  exports.bytes32ToString = require_sdk_utils_bytes32ToString.bytes32ToString;
26
29
  exports.childLogger = require_sdk_utils_childLogger.childLogger;
27
30
  exports.createRawTx = require_sdk_utils_createRawTx.createRawTx;
@@ -13,5 +13,17 @@ const ZodAddress = () => zod_v4.z.string().transform((val, ctx) => {
13
13
  });
14
14
  return (0, viem.getAddress)(val);
15
15
  });
16
+ /**
17
+ * A `0x`-prefixed hex string, as viem's Hex.
18
+ */
19
+ const ZodHex = () => zod_v4.z.string().transform((val, ctx) => {
20
+ if (!(0, viem.isHex)(val)) ctx.issues.push({
21
+ code: "custom",
22
+ message: `invalid hex string ${val}`,
23
+ input: ctx.value
24
+ });
25
+ return val;
26
+ });
16
27
  //#endregion
17
28
  exports.ZodAddress = ZodAddress;
29
+ exports.ZodHex = ZodHex;
@@ -1,5 +1,6 @@
1
1
  import { AxiosCache } from "./axios-cache/AxiosCache.js";
2
2
  import "./axios-cache/index.js";
3
+ import { BigIntMath } from "../sdk/utils/bigint-math.js";
3
4
  import { ChartsCreditManagerData } from "./charts/credit-manager.js";
4
5
  import { CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CreditSession, CreditSessionFiltered, UserCreditSessionsBuilder } from "./charts/credit-session.js";
5
6
  import { ChartsPoolData, UserPoolData } from "./charts/pool.js";
@@ -11,7 +12,6 @@ import { calculateBorrowRateFromUtilization } from "./utils/apy/calculate-borrow
11
12
  import { PriceUtils } from "./utils/price-math.js";
12
13
  import { calculateEarnings } from "./utils/apy/calculate-earnings.js";
13
14
  import { calculateEffectiveBorrowRate } from "./utils/apy/calculate-effective-borrow-rate.js";
14
- import { BigIntMath } from "./utils/bigint-math.js";
15
15
  import { calculateSafeBorrowRate } from "./utils/apy/calculate-safe-borrow-rate.js";
16
16
  import { getComplexAPYList } from "./utils/apy/get-complex-apy-list.js";
17
17
  import { getRateWithFee } from "./utils/apy/get-rate-with-fee.js";
@@ -1,6 +1,6 @@
1
+ import { BigIntMath } from "../../../sdk/utils/bigint-math.js";
1
2
  import { PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR } from "../../../sdk/constants/math.js";
2
3
  import { calculateBorrowRateFromUtilization } from "./calculate-borrow-rate-from-utilization.js";
3
- import { BigIntMath } from "../bigint-math.js";
4
4
  //#region src/common-utils/utils/apy/calculate-safe-borrow-rate.ts
5
5
  /**
6
6
  * Returns borrow rate multiplied by feeInterest
@@ -1,5 +1,5 @@
1
+ import { BigIntMath } from "../../sdk/utils/bigint-math.js";
1
2
  import { PriceUtils } from "./price-math.js";
2
- import { BigIntMath } from "./bigint-math.js";
3
3
  import { sortBalances } from "./creditAccount/sort.js";
4
4
  //#region src/common-utils/utils/assets-math.ts
5
5
  /**
@@ -1,7 +1,7 @@
1
+ import { BigIntMath } from "../../../sdk/utils/bigint-math.js";
1
2
  import { PERCENTAGE_FACTOR, PRICE_DECIMALS } from "../../../sdk/constants/math.js";
2
3
  import "../../../sdk/index.js";
3
4
  import { PriceUtils } from "../price-math.js";
4
- import { BigIntMath } from "../bigint-math.js";
5
5
  //#region src/common-utils/utils/creditAccount/calc-health-factor.ts
6
6
  const MAX_UINT16 = 65535;
7
7
  /**
@@ -1,7 +1,7 @@
1
+ import { BigIntMath } from "../../../sdk/utils/bigint-math.js";
1
2
  import { PERCENTAGE_FACTOR } from "../../../sdk/constants/math.js";
2
3
  import "../../../sdk/index.js";
3
4
  import { PriceUtils } from "../price-math.js";
4
- import { BigIntMath } from "../bigint-math.js";
5
5
  //#region src/common-utils/utils/creditAccount/debt.ts
6
6
  /**
7
7
  * Calculates additional debt that can be borrowed while targeting
@@ -1,6 +1,6 @@
1
+ import { BigIntMath } from "../../../sdk/utils/bigint-math.js";
1
2
  import { MIN_INT96, PERCENTAGE_FACTOR } from "../../../sdk/constants/math.js";
2
3
  import "../../../sdk/index.js";
3
- import { BigIntMath } from "../bigint-math.js";
4
4
  //#region src/common-utils/utils/creditAccount/quota-utils.ts
5
5
  /**
6
6
  * Rounds quota deltas to protocol precision step (`PERCENTAGE_FACTOR`).