@gearbox-protocol/sdk 17.0.0-next.4 → 17.0.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 (364) hide show
  1. package/dist/cjs/dev/abi.js +14 -15
  2. package/dist/cjs/dev/claimFromFaucet.js +4 -8
  3. package/dist/cjs/dev/createAnvilClient.js +35 -17
  4. package/dist/cjs/dev/index.js +7 -2
  5. package/dist/cjs/dev/kycUtils.js +66 -58
  6. package/dist/cjs/dev/midasUtils.js +113 -16
  7. package/dist/cjs/dev/securitizeUtils.js +82 -42
  8. package/dist/cjs/dev/withdrawalUtils.js +3 -6
  9. package/dist/cjs/model/errors/index.js +2 -0
  10. package/dist/cjs/model/errors/operation-errors.js +19 -1
  11. package/dist/cjs/model/index.js +4 -2
  12. package/dist/cjs/model/rwa.js +4 -4
  13. package/dist/cjs/model/rwa.schema.js +4 -4
  14. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
  15. package/dist/cjs/onchain/OnchainSDK.js +3 -3
  16. package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -17
  17. package/dist/cjs/onchain/accounts/intents/borrow.js +140 -0
  18. package/dist/cjs/onchain/accounts/intents/collateral-valuation.js +41 -0
  19. package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
  20. package/dist/cjs/onchain/accounts/intents/index.js +107 -20
  21. package/dist/cjs/onchain/accounts/intents/leverage-band.js +2 -12
  22. package/dist/cjs/onchain/accounts/intents/maxBorrow.js +89 -0
  23. package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
  24. package/dist/cjs/onchain/accounts/intents/open-strategy.js +8 -46
  25. package/dist/cjs/onchain/accounts/intents/operations.js +0 -1
  26. package/dist/cjs/onchain/accounts/intents/realize.js +61 -4
  27. package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
  28. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  29. package/dist/cjs/onchain/accounts/intents/utils/common.js +19 -0
  30. package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +21 -0
  31. package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
  32. package/dist/cjs/onchain/accounts/intents/utils/price-impact.js +12 -9
  33. package/dist/cjs/onchain/accounts/intents/utils/router-path.js +4 -5
  34. package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
  35. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  36. package/dist/cjs/onchain/constants/address-provider.js +0 -2
  37. package/dist/cjs/onchain/constants/index.js +0 -1
  38. package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
  39. package/dist/cjs/onchain/index.js +60 -43
  40. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -2
  41. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  42. package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +49 -5
  43. package/dist/cjs/onchain/market/credit/CreditSuite.js +26 -9
  44. package/dist/cjs/onchain/market/index.js +50 -38
  45. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +3 -3
  46. package/dist/cjs/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
  47. package/dist/cjs/onchain/market/pricefeeds/PriceFeedRegistry.js +127 -0
  48. package/dist/cjs/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
  49. package/dist/cjs/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
  50. package/dist/cjs/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
  51. package/dist/cjs/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
  52. package/dist/cjs/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
  53. package/dist/cjs/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
  54. package/dist/cjs/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
  55. package/dist/cjs/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
  56. package/dist/cjs/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
  57. package/dist/cjs/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
  58. package/dist/cjs/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
  59. package/dist/cjs/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
  60. package/dist/cjs/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
  61. package/dist/cjs/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
  62. package/dist/cjs/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
  63. package/dist/cjs/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
  64. package/dist/cjs/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
  65. package/dist/cjs/onchain/market/pricefeeds/feeds/index.js +35 -0
  66. package/dist/cjs/onchain/market/pricefeeds/index.js +51 -39
  67. package/dist/cjs/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +189 -0
  68. package/dist/cjs/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
  69. package/dist/cjs/onchain/market/pricefeeds/updates/index.js +8 -0
  70. package/dist/cjs/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
  71. package/dist/cjs/onchain/market/pricefeeds/updates/updatableDependencies.js +14 -0
  72. package/dist/cjs/onchain/market/rwa/RWARegistry.js +4 -7
  73. package/dist/cjs/onchain/market/rwa/index.js +1 -0
  74. package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  75. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
  76. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  77. package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  78. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
  79. package/dist/cjs/onchain/positions/calcHealthFactor.js +3 -3
  80. package/dist/cjs/onchain/preview/index.js +2 -0
  81. package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  82. package/dist/cjs/onchain/preview/preview/index.js +2 -0
  83. package/dist/cjs/onchain/preview/preview/midasGreenlistsAccount.js +17 -0
  84. package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +13 -16
  85. package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
  86. package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
  87. package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  88. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +11 -9
  89. package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
  90. package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  91. package/dist/cjs/onchain/validation/bundles/checkMidasAccountGreenlist.js +44 -0
  92. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  93. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +18 -8
  94. package/dist/cjs/onchain/validation/bundles/index.js +6 -4
  95. package/dist/cjs/onchain/validation/checkOperation.js +0 -1
  96. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
  97. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  98. package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
  99. package/dist/cjs/onchain/validation/checks/index.js +2 -0
  100. package/dist/cjs/onchain/validation/index.js +8 -4
  101. package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +2 -2
  102. package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -2
  103. package/dist/cjs/sdk/execute/ExecuteApi.js +67 -7
  104. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  105. package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
  106. package/dist/esm/dev/abi.js +14 -15
  107. package/dist/esm/dev/claimFromFaucet.js +4 -8
  108. package/dist/esm/dev/createAnvilClient.js +36 -19
  109. package/dist/esm/dev/index.js +4 -4
  110. package/dist/esm/dev/kycUtils.js +66 -59
  111. package/dist/esm/dev/midasUtils.js +112 -18
  112. package/dist/esm/dev/securitizeUtils.js +84 -44
  113. package/dist/esm/dev/withdrawalUtils.js +3 -6
  114. package/dist/esm/model/errors/index.js +2 -2
  115. package/dist/esm/model/errors/operation-errors.js +18 -2
  116. package/dist/esm/model/index.js +4 -4
  117. package/dist/esm/model/rwa.js +4 -4
  118. package/dist/esm/model/rwa.schema.js +5 -5
  119. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  120. package/dist/esm/onchain/OnchainSDK.js +3 -3
  121. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -17
  122. package/dist/esm/onchain/accounts/intents/borrow.js +138 -0
  123. package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
  124. package/dist/esm/onchain/accounts/intents/guards.js +15 -3
  125. package/dist/esm/onchain/accounts/intents/index.js +107 -20
  126. package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
  127. package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
  128. package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
  129. package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -46
  130. package/dist/esm/onchain/accounts/intents/operations.js +0 -1
  131. package/dist/esm/onchain/accounts/intents/realize.js +61 -4
  132. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  133. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  134. package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
  135. package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
  136. package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
  137. package/dist/esm/onchain/accounts/intents/utils/price-impact.js +12 -9
  138. package/dist/esm/onchain/accounts/intents/utils/router-path.js +4 -5
  139. package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
  140. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  141. package/dist/esm/onchain/constants/address-provider.js +1 -2
  142. package/dist/esm/onchain/constants/index.js +2 -2
  143. package/dist/esm/onchain/core/createAddressProvider.js +2 -5
  144. package/dist/esm/onchain/index.js +32 -24
  145. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -2
  146. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  147. package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +50 -6
  148. package/dist/esm/onchain/market/credit/CreditSuite.js +26 -9
  149. package/dist/esm/onchain/market/index.js +26 -21
  150. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
  151. package/dist/esm/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
  152. package/dist/esm/onchain/market/pricefeeds/PriceFeedRegistry.js +126 -0
  153. package/dist/esm/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
  154. package/dist/esm/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
  155. package/dist/esm/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
  156. package/dist/esm/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
  157. package/dist/esm/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
  158. package/dist/esm/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
  159. package/dist/esm/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
  160. package/dist/esm/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
  161. package/dist/esm/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
  162. package/dist/esm/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
  163. package/dist/esm/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
  164. package/dist/esm/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
  165. package/dist/esm/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
  166. package/dist/esm/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
  167. package/dist/esm/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
  168. package/dist/esm/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
  169. package/dist/esm/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
  170. package/dist/esm/onchain/market/pricefeeds/feeds/index.js +18 -0
  171. package/dist/esm/onchain/market/pricefeeds/index.js +27 -21
  172. package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +188 -0
  173. package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
  174. package/dist/esm/onchain/market/pricefeeds/updates/index.js +5 -1
  175. package/dist/esm/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
  176. package/dist/esm/onchain/market/pricefeeds/updates/updatableDependencies.js +13 -0
  177. package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
  178. package/dist/esm/onchain/market/rwa/index.js +2 -2
  179. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  180. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
  181. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  182. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  183. package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
  184. package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
  185. package/dist/esm/onchain/preview/index.js +2 -1
  186. package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  187. package/dist/esm/onchain/preview/preview/index.js +2 -1
  188. package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
  189. package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
  190. package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
  191. package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
  192. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  193. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +11 -9
  194. package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
  195. package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  196. package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
  197. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  198. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +18 -8
  199. package/dist/esm/onchain/validation/bundles/index.js +4 -3
  200. package/dist/esm/onchain/validation/checkOperation.js +0 -1
  201. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
  202. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  203. package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
  204. package/dist/esm/onchain/validation/checks/index.js +2 -1
  205. package/dist/esm/onchain/validation/index.js +5 -3
  206. package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
  207. package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +1 -1
  208. package/dist/esm/sdk/execute/ExecuteApi.js +67 -7
  209. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  210. package/dist/esm/sdk/prepare/PrepareApi.js +94 -19
  211. package/dist/types/dev/abi.d.ts +13 -15
  212. package/dist/types/dev/claimFromFaucet.d.ts +0 -1
  213. package/dist/types/dev/createAnvilClient.d.ts +10 -3
  214. package/dist/types/dev/index.d.ts +4 -4
  215. package/dist/types/dev/kycUtils.d.ts +15 -24
  216. package/dist/types/dev/midasUtils.d.ts +35 -4
  217. package/dist/types/dev/securitizeUtils.d.ts +3 -9
  218. package/dist/types/model/errors/index.d.ts +2 -2
  219. package/dist/types/model/errors/operation-errors.d.ts +62 -7
  220. package/dist/types/model/index.d.ts +5 -5
  221. package/dist/types/model/opportunities.d.ts +6 -7
  222. package/dist/types/model/previews.d.ts +25 -19
  223. package/dist/types/model/rwa.d.ts +47 -27
  224. package/dist/types/model/rwa.schema.d.ts +3 -3
  225. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
  226. package/dist/types/offchain/opportunities/types.d.ts +1 -4
  227. package/dist/types/onchain/OnchainSDK.d.ts +2 -2
  228. package/dist/types/onchain/accounts/index.d.ts +5 -4
  229. package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
  230. package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
  231. package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
  232. package/dist/types/onchain/accounts/intents/index.d.ts +103 -15
  233. package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
  234. package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
  235. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
  236. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
  237. package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
  238. package/dist/types/onchain/accounts/intents/types.d.ts +51 -6
  239. package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
  240. package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
  241. package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
  242. package/dist/types/onchain/accounts/intents/utils/price-impact.d.ts +4 -1
  243. package/dist/types/onchain/accounts/intents/utils/router-path.d.ts +2 -5
  244. package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
  245. package/dist/types/onchain/accounts/types.d.ts +4 -2
  246. package/dist/types/onchain/constants/address-provider.d.ts +1 -2
  247. package/dist/types/onchain/constants/index.d.ts +2 -2
  248. package/dist/types/onchain/index.d.ts +40 -31
  249. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
  250. package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +20 -4
  251. package/dist/types/onchain/market/adapters/types.d.ts +8 -0
  252. package/dist/types/onchain/market/credit/CreditSuite.d.ts +13 -3
  253. package/dist/types/onchain/market/index.d.ts +29 -24
  254. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +2 -1
  255. package/dist/types/onchain/market/oracle/types.d.ts +2 -1
  256. package/dist/types/onchain/market/pool/types.d.ts +1 -1
  257. package/dist/types/onchain/market/pricefeeds/AbstractPriceFeed.d.ts +1 -2
  258. package/dist/types/onchain/market/pricefeeds/PriceFeedRegistry.d.ts +60 -0
  259. package/dist/types/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.d.ts +12 -0
  260. package/dist/types/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.d.ts → feeds/BalancerWeightedPriceFeed.d.ts} +7 -7
  261. package/dist/types/onchain/market/pricefeeds/feeds/BoundedPriceFeed.d.ts +15 -0
  262. package/dist/types/onchain/market/pricefeeds/{CompositePriceFeed.d.ts → feeds/CompositePriceFeed.d.ts} +6 -6
  263. package/dist/types/onchain/market/pricefeeds/{ConstantPriceFeed.d.ts → feeds/ConstantPriceFeed.d.ts} +6 -6
  264. package/dist/types/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.d.ts +12 -0
  265. package/dist/types/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.d.ts +12 -0
  266. package/dist/types/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.d.ts +12 -0
  267. package/dist/types/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.d.ts +12 -0
  268. package/dist/types/onchain/market/pricefeeds/feeds/ExternalPriceFeed.d.ts +11 -0
  269. package/dist/types/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.d.ts +12 -0
  270. package/dist/types/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.d.ts → feeds/PendleTWAPPTPriceFeed.d.ts} +3 -3
  271. package/dist/types/onchain/market/pricefeeds/{PythPriceFeed.d.ts → feeds/PythPriceFeed.d.ts} +3 -3
  272. package/dist/types/onchain/market/pricefeeds/{RedstonePriceFeed.d.ts → feeds/RedstonePriceFeed.d.ts} +9 -9
  273. package/dist/types/onchain/market/pricefeeds/feeds/WstETHPriceFeed.d.ts +12 -0
  274. package/dist/types/onchain/market/pricefeeds/feeds/YearnPriceFeed.d.ts +12 -0
  275. package/dist/types/onchain/market/pricefeeds/feeds/ZeroPriceFeed.d.ts +11 -0
  276. package/dist/types/onchain/market/pricefeeds/feeds/index.d.ts +18 -0
  277. package/dist/types/onchain/market/pricefeeds/index.d.ts +28 -22
  278. package/dist/types/onchain/market/pricefeeds/types.d.ts +1 -31
  279. package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
  280. package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +106 -0
  281. package/dist/types/onchain/market/pricefeeds/updates/getRawPriceUpdates.d.ts +6 -0
  282. package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +7 -3
  283. package/dist/types/onchain/market/pricefeeds/updates/isUpdatablePriceFeed.d.ts +6 -0
  284. package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +56 -2
  285. package/dist/types/onchain/market/pricefeeds/updates/updatableDependencies.d.ts +10 -0
  286. package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
  287. package/dist/types/onchain/market/rwa/index.d.ts +3 -3
  288. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
  289. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
  290. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
  291. package/dist/types/onchain/market/rwa/types.d.ts +39 -37
  292. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
  293. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
  294. package/dist/types/onchain/opportunities/types.d.ts +6 -1
  295. package/dist/types/onchain/preview/index.d.ts +2 -1
  296. package/dist/types/onchain/preview/preview/index.d.ts +2 -1
  297. package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
  298. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
  299. package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
  300. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +5 -4
  301. package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
  302. package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
  303. package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
  304. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
  305. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +9 -7
  306. package/dist/types/onchain/validation/bundles/index.d.ts +5 -4
  307. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
  308. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
  309. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
  310. package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
  311. package/dist/types/onchain/validation/checks/index.d.ts +2 -1
  312. package/dist/types/onchain/validation/index.d.ts +6 -4
  313. package/dist/types/onchain/validation/raise.d.ts +2 -2
  314. package/dist/types/sdk/execute/index.d.ts +2 -2
  315. package/dist/types/sdk/execute/types.d.ts +48 -6
  316. package/dist/types/sdk/index.d.ts +5 -4
  317. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
  318. package/dist/types/sdk/opportunities/types.d.ts +9 -3
  319. package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
  320. package/dist/types/sdk/prepare/index.d.ts +4 -3
  321. package/dist/types/sdk/prepare/types.d.ts +200 -66
  322. package/package.json +1 -1
  323. package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -70
  324. package/dist/cjs/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -301
  325. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
  326. package/dist/cjs/plugins/degen-distributors/index.js +0 -4
  327. package/dist/cjs/plugins/degen-distributors/package.json +0 -1
  328. package/dist/cjs/plugins/degen-distributors/types.js +0 -1
  329. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
  330. package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
  331. package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
  332. package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
  333. package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -69
  334. package/dist/esm/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -300
  335. package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
  336. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
  337. package/dist/esm/plugins/degen-distributors/index.js +0 -3
  338. package/dist/esm/plugins/degen-distributors/package.json +0 -1
  339. package/dist/esm/plugins/degen-distributors/types.js +0 -1
  340. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
  341. package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
  342. package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
  343. package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
  344. package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -38
  345. package/dist/types/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts +0 -12
  346. package/dist/types/onchain/market/pricefeeds/BoundedPriceFeed.d.ts +0 -15
  347. package/dist/types/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts +0 -12
  348. package/dist/types/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts +0 -12
  349. package/dist/types/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts +0 -12
  350. package/dist/types/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts +0 -12
  351. package/dist/types/onchain/market/pricefeeds/ExternalPriceFeed.d.ts +0 -11
  352. package/dist/types/onchain/market/pricefeeds/MellowLRTPriceFeed.d.ts +0 -12
  353. package/dist/types/onchain/market/pricefeeds/PriceFeedsRegister.d.ts +0 -180
  354. package/dist/types/onchain/market/pricefeeds/WstETHPriceFeed.d.ts +0 -12
  355. package/dist/types/onchain/market/pricefeeds/YearnPriceFeed.d.ts +0 -12
  356. package/dist/types/onchain/market/pricefeeds/ZeroPriceFeed.d.ts +0 -11
  357. package/dist/types/onchain/market/pricefeeds/getRawPriceUpdates.d.ts +0 -5
  358. package/dist/types/onchain/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -5
  359. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
  360. package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
  361. package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
  362. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
  363. package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
  364. package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
@@ -1,300 +0,0 @@
1
- import { AddressMap } from "../../utils/AddressMap.js";
2
- import { bytes32ToString } from "../../utils/bytes32ToString.js";
3
- import { createRawTx } from "../../utils/createRawTx.js";
4
- import { AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE } from "../../constants/address-provider.js";
5
- import { ADDRESS_0X0 } from "../../constants/addresses.js";
6
- import { VERSION_RANGE_310 } from "../../constants/versions.js";
7
- import "../../constants/index.js";
8
- import "../../utils/index.js";
9
- import { SDKConstruct } from "../../base/SDKConstruct.js";
10
- import "../../base/index.js";
11
- import { priceFeedCompressorAbi } from "../../../abi/compressors/priceFeedCompressor.js";
12
- import { PartialPriceFeedInitError } from "./AbstractPriceFeed.js";
13
- import { BalancerStablePriceFeedContract } from "./BalancerStablePriceFeed.js";
14
- import { BalancerWeightedPriceFeedContract } from "./BalancerWeightedPriceFeed.js";
15
- import { BoundedPriceFeedContract } from "./BoundedPriceFeed.js";
16
- import { CompositePriceFeedContract } from "./CompositePriceFeed.js";
17
- import { CurveCryptoPriceFeedContract } from "./CurveCryptoPriceFeed.js";
18
- import { CurveStablePriceFeedContract } from "./CurveStablePriceFeed.js";
19
- import { CurveUSDPriceFeedContract } from "./CurveUSDPriceFeed.js";
20
- import { Erc4626PriceFeedContract } from "./Erc4626PriceFeed.js";
21
- import { ExternalPriceFeedContract } from "./ExternalPriceFeed.js";
22
- import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
23
- import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
24
- import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
25
- import { Hooks } from "../../utils/internal/Hooks.js";
26
- import "../../utils/internal/index.js";
27
- import { ConstantPriceFeedContract } from "./ConstantPriceFeed.js";
28
- import { PythPriceFeed } from "./PythPriceFeed.js";
29
- import { RedstonePriceFeedContract } from "./RedstonePriceFeed.js";
30
- import { RedstoneUpdater } from "./updates/RedstoneUpdater.js";
31
- import "./updates/index.js";
32
- import { WstETHPriceFeedContract } from "./WstETHPriceFeed.js";
33
- import { YearnPriceFeedContract } from "./YearnPriceFeed.js";
34
- import { ZeroPriceFeedContract } from "./ZeroPriceFeed.js";
35
- import { parseAbi } from "viem";
36
- //#region src/onchain/market/pricefeeds/PriceFeedsRegister.ts
37
- /**
38
- * Chain-level cache of price feed contract instances.
39
- *
40
- * All {@link IPriceOracleContract}s across different markets share a single
41
- * `PriceFeedRegister`, avoiding duplicate contract wrappers for the same
42
- * on-chain feed. The register also orchestrates off-chain price updates
43
- * (Redstone, etc.).
44
- **/
45
- var PriceFeedRegister = class extends SDKConstruct {
46
- #hooks = new Hooks();
47
- #updaters;
48
- #feeds = new AddressMap(void 0, "priceFeeds");
49
- #latestUpdate;
50
- constructor(sdk, opts = {}) {
51
- super(sdk);
52
- this.#updaters = [new RedstoneUpdater(sdk, opts?.redstone)];
53
- }
54
- /**
55
- * @internal
56
- * Registers a callback for price-feed register lifecycle events.
57
- * @param event - Event name.
58
- * @param handler - Callback to invoke.
59
- **/
60
- addHook = this.#hooks.addHook.bind(this.#hooks);
61
- /**
62
- * @internal
63
- * Removes a previously registered hook.
64
- * @param event - Event name.
65
- * @param handler - Callback to remove.
66
- **/
67
- removeHook = this.#hooks.removeHook.bind(this.#hooks);
68
- /**
69
- * Returns all price feeds known to sdk
70
- */
71
- get feeds() {
72
- return this.#feeds.values();
73
- }
74
- /**
75
- * Generates transactions to push fresh off-chain prices to updatable feeds.
76
- *
77
- * @param priceFeeds - Top-level price feeds whose updatable dependencies
78
- * will be resolved, or a filter (`{ main: true }` / `{ reserve: true }`)
79
- * to gather feeds from all oracles. When omitted, all registered feeds
80
- * are used.
81
- **/
82
- async generatePriceFeedsUpdateTxs(priceFeeds) {
83
- let updateables = this.#feeds.values();
84
- let filterRemark = "";
85
- if (priceFeeds) {
86
- if (Array.isArray(priceFeeds)) updateables = priceFeeds.flatMap((pf) => pf.updatableDependencies());
87
- else if ("main" in priceFeeds && priceFeeds.main) {
88
- filterRemark = " main";
89
- updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.mainPriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
90
- } else if ("reserve" in priceFeeds && priceFeeds.reserve) {
91
- filterRemark = " reserve";
92
- updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.reservePriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
93
- }
94
- }
95
- if (updateables.length === 0) return {
96
- txs: [],
97
- timestamp: 0
98
- };
99
- const txs = [];
100
- const latestUpdate = {
101
- updates: [],
102
- timestamp: Math.floor(Date.now() / 1e3)
103
- };
104
- const updates = (await Promise.all(this.#updaters.map((u) => u.getUpdateTxs(updateables).catch(() => [])))).flat();
105
- let maxTimestamp = 0;
106
- for (const tx of updates) {
107
- const { data } = tx;
108
- const { timestamp } = data;
109
- if (timestamp > maxTimestamp) maxTimestamp = timestamp;
110
- txs.push(tx);
111
- latestUpdate.updates.push(data);
112
- }
113
- txs.sort((a, b) => a.raw.to.toLowerCase().localeCompare(b.raw.to.toLowerCase()));
114
- const result = {
115
- txs,
116
- timestamp: maxTimestamp
117
- };
118
- const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
119
- this.logger?.debug(`generated ${txs.length}${filterRemark} price feed update transactions, timestamp: ${maxTimestamp} (delta ${tsDelta})`);
120
- if (txs.length) await this.#hooks.triggerHooks("updatesGenerated", result);
121
- this.#latestUpdate = latestUpdate;
122
- return result;
123
- }
124
- /**
125
- * Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
126
- * @param priceFeeds
127
- * @returns
128
- */
129
- async generatePriceFeedsUpdates(priceFeeds) {
130
- const updates = await this.generatePriceFeedsUpdateTxs(priceFeeds);
131
- return getRawPriceUpdates(updates);
132
- }
133
- /**
134
- * Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
135
- * @param priceFeeds
136
- * @returns
137
- */
138
- async getPriceFeedStoreUpdateTx(priceFeeds) {
139
- const pfs = this.sdk.addressProvider.getAddress(AP_PRICE_FEED_STORE);
140
- const updates = await this.generatePriceFeedsUpdates(priceFeeds);
141
- return createRawTx(pfs, {
142
- abi: parseAbi(["function updatePrices((address,bytes)[])"]),
143
- functionName: "updatePrices",
144
- args: [updates.map((u) => [u.priceFeed, u.data])]
145
- });
146
- }
147
- /**
148
- * Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds (not known to sdk)
149
- * This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
150
- * @param feeds
151
- * @param block
152
- * @returns
153
- */
154
- async generateExternalPriceFeedsUpdateTxs(feeds, block) {
155
- const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_PRICE_FEED_COMPRESSOR, VERSION_RANGE_310);
156
- const blockParam = block ?? { blockNumber: this.sdk.currentBlock };
157
- const feedContracts = (await this.client.readContract({
158
- address: priceFeedCompressorAddress,
159
- abi: priceFeedCompressorAbi,
160
- functionName: "loadPriceFeedTree",
161
- args: [feeds],
162
- ...blockParam,
163
- gas: this.sdk.gasLimit
164
- })).map((data) => this.#createUpdatableProxy(data));
165
- return this.generatePriceFeedsUpdateTxs(feedContracts);
166
- }
167
- /**
168
- * Similar to {@link generateExternalPriceFeedsUpdateTxs}, but returns raw structures instead of transactions
169
- * @param feeds
170
- * @param block
171
- * @returns
172
- */
173
- async generateExternalPriceFeedsUpdates(feeds, block) {
174
- const updates = await this.generateExternalPriceFeedsUpdateTxs(feeds, block);
175
- return getRawPriceUpdates(updates);
176
- }
177
- /**
178
- * Checks whether a price feed is already registered at the given address.
179
- * @param address - On-chain address to look up.
180
- **/
181
- has(address) {
182
- return this.#feeds.has(address);
183
- }
184
- /**
185
- * Returns the cached price feed contract at the given address.
186
- * @param address - On-chain address to look up.
187
- * @throws If no feed is registered at that address.
188
- **/
189
- mustGet(address) {
190
- return this.#feeds.mustGet(address);
191
- }
192
- /**
193
- * Inserts or updates a price feed from a full tree node.
194
- *
195
- * If a fully loaded feed already exists at the same address, only the
196
- * answer is refreshed. Otherwise a new contract wrapper is created and
197
- * cached.
198
- *
199
- * @param data - Full price feed tree node from the compressor.
200
- * @returns The cached (or newly created) feed instance.
201
- * @throws If the created feed is only partially initialized.
202
- **/
203
- upsert(data) {
204
- const existing = this.#feeds.get(data.baseParams.addr);
205
- if (existing?.loaded) {
206
- existing.updateAnswer(data.answer);
207
- return existing;
208
- }
209
- const feed = this.create(data);
210
- if (!feed.loaded) throw new PartialPriceFeedInitError({
211
- ...data,
212
- abi: [],
213
- name: ""
214
- });
215
- this.#feeds.upsert(data.baseParams.addr, feed);
216
- return feed;
217
- }
218
- /**
219
- * Loads PARTIAL information about all updatable price feeds from MarketCompressor
220
- * Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
221
- */
222
- async getPartialUpdatablePriceFeeds(configurators) {
223
- const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_PRICE_FEED_COMPRESSOR, VERSION_RANGE_310);
224
- this.logger?.debug({ configurators }, `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`);
225
- const result = await this.client.readContract({
226
- address: priceFeedCompressorAddress,
227
- abi: priceFeedCompressorAbi,
228
- functionName: "getUpdatablePriceFeeds",
229
- args: [{
230
- configurators,
231
- pools: [],
232
- underlying: ADDRESS_0X0
233
- }],
234
- blockNumber: this.sdk.currentBlock,
235
- gas: this.sdk.gasLimit
236
- });
237
- this.logger?.debug(`loaded ${result.length} partial updatable price feeds in block ${this.sdk.currentBlock}`);
238
- return result.map((baseParams) => this.#createUpdatableProxy({ baseParams }));
239
- }
240
- /**
241
- * Instantiates the appropriate price feed contract wrapper based on
242
- * the `contractType` discriminator in the node's base params.
243
- *
244
- * @param data - Partial or full price feed tree node.
245
- * @returns A new (uncached) feed contract instance.
246
- * @throws If the contract type is unsupported and strict mode is enabled.
247
- **/
248
- create(data) {
249
- const contractType = bytes32ToString(data.baseParams.contractType);
250
- switch (contractType) {
251
- case "PRICE_FEED::BALANCER_STABLE": return new BalancerStablePriceFeedContract(this.sdk, data);
252
- case "PRICE_FEED::BALANCER_WEIGHTED": return new BalancerWeightedPriceFeedContract(this.sdk, data);
253
- case "PRICE_FEED::BOUNDED": return new BoundedPriceFeedContract(this.sdk, data);
254
- case "PRICE_FEED::COMPOSITE": return new CompositePriceFeedContract(this.sdk, data);
255
- case "PRICE_FEED::CONSTANT": return new ConstantPriceFeedContract(this.sdk, data);
256
- case "PRICE_FEED::CURVE_CRYPTO": return new CurveCryptoPriceFeedContract(this.sdk, data);
257
- case "PRICE_FEED::CURVE_STABLE": return new CurveStablePriceFeedContract(this.sdk, data);
258
- case "PRICE_FEED::CURVE_USD": return new CurveUSDPriceFeedContract(this.sdk, data);
259
- case "PRICE_FEED::ERC4626": return new Erc4626PriceFeedContract(this.sdk, data);
260
- case "PRICE_FEED::EXTERNAL": return new ExternalPriceFeedContract(this.sdk, data);
261
- case "PRICE_FEED::MELLOW_LRT": return new MellowLRTPriceFeedContract(this.sdk, data);
262
- case "PRICE_FEED::PENDLE_PT_TWAP": return new PendleTWAPPTPriceFeed(this.sdk, data);
263
- case "PRICE_FEED::PYTH": return new PythPriceFeed(this.sdk, data);
264
- case "PRICE_FEED::REDSTONE": return new RedstonePriceFeedContract(this.sdk, data);
265
- case "PRICE_FEED::WSTETH": return new WstETHPriceFeedContract(this.sdk, data);
266
- case "PRICE_FEED::YEARN": return new YearnPriceFeedContract(this.sdk, data);
267
- case "PRICE_FEED::ZERO": return new ZeroPriceFeedContract(this.sdk, data);
268
- default: {
269
- const err = /* @__PURE__ */ new Error(`Price feed type ${contractType} not supported for price feed at ${data.baseParams.addr}`);
270
- if (this.sdk.strictContractTypes) throw err;
271
- this.logger?.error(err);
272
- return new ExternalPriceFeedContract(this.sdk, data);
273
- }
274
- }
275
- }
276
- #createUpdatableProxy(data) {
277
- const contract = this.#feeds.get(data.baseParams.addr) ?? this.create(data);
278
- return new Proxy(contract, { get(target, prop) {
279
- if (prop === "updatableDependencies") return () => [target];
280
- return target[prop];
281
- } });
282
- }
283
- /**
284
- * @internal
285
- * Diagnostic snapshot of the most recent price-update round, or
286
- * `undefined` if no updates have been generated yet.
287
- **/
288
- get latestUpdate() {
289
- return this.#latestUpdate;
290
- }
291
- /**
292
- * @internal
293
- * Returns true if any of the updaters are in historical mode
294
- */
295
- get historical() {
296
- return this.#updaters.some((u) => u.historical);
297
- }
298
- };
299
- //#endregion
300
- export { PriceFeedRegister };
@@ -1,27 +0,0 @@
1
- import { checkBorrowLimit } from "../checks/checkBorrowLimit.js";
2
- import "../checks/index.js";
3
- //#region src/onchain/validation/bundles/checkDraw.ts
4
- /**
5
- * What the transaction draws, against what the market can lend right now.
6
- *
7
- * Only a draw is weighed: repaying, or leaving the debt alone, can never exceed
8
- * a ceiling. Opening borrows the whole debt; adjusting borrows
9
- * `totalDebtChange`.
10
- *
11
- * The engine holds every simulation to this already (`assertCanBorrow`), so
12
- * this is here for the transactions it never saw — a pasted calldata reaches
13
- * the confirm screen with nothing else standing between it and a revert.
14
- */
15
- function checkDraw(suite, preview, underlying) {
16
- const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
17
- if (drawn <= 0n) return [];
18
- const maxBorrowAmount = suite.maxBorrowAmount();
19
- return checkBorrowLimit({
20
- requested: drawn,
21
- available: maxBorrowAmount.amount.value,
22
- limit: maxBorrowAmount.limit,
23
- underlying
24
- });
25
- }
26
- //#endregion
27
- export { checkDraw };
@@ -1,60 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { MarketConfiguratorContract } from "../../onchain/market/MarketConfiguratorContract.js";
3
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
4
- import "../../onchain/index.js";
5
- //#region src/plugins/degen-distributors/DegenDistributorsPlugin.ts
6
- const MAP_LABEL = "degenDistributors";
7
- var DegenDistributorsPlugin = class extends BasePlugin {
8
- #distributors;
9
- async load(force) {
10
- if (!force && this.loaded) return this.state;
11
- const configurators = Object.values(this.sdk.marketRegister.markets.reduce((acc, market) => {
12
- const cfgLC = market.configurator.address.toLowerCase();
13
- acc[cfgLC] = market.configurator;
14
- return acc;
15
- }, {}));
16
- this.sdk.logger?.debug(`loading degen distributors for ${this.sdk.networkType}`);
17
- const distributors = await MarketConfiguratorContract.getPeripheryContractBatch(Object.values(configurators), this.sdk.client, "DEGEN_DISTRIBUTOR", this.sdk.currentBlock);
18
- const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
19
- const cfgLC = cfg.address.toLowerCase();
20
- acc[cfgLC] = distributors[index];
21
- return acc;
22
- }, {});
23
- this.#distributors = new AddressMap(void 0, MAP_LABEL);
24
- this.sdk.marketRegister.markets.forEach((m) => {
25
- const pool = m.pool.pool.address;
26
- const cfg = m.configurator.address;
27
- const cfgLC = cfg.toLowerCase();
28
- const r = distributorByConfigurator?.[cfgLC];
29
- if (r.status === "success" && r.result.length > 0) this.#distributors?.upsert(pool, r.result[0]);
30
- else this.sdk.logger?.warn(`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`);
31
- });
32
- return this.state;
33
- }
34
- get loaded() {
35
- return !!this.#distributors;
36
- }
37
- /**
38
- * Returns a map of pool addresses to degen distributor addresses
39
- * @throws if degen distributor plugin is not attached
40
- */
41
- get distributors() {
42
- if (!this.#distributors) throw new Error("degen distributor plugin not attached");
43
- return this.#distributors;
44
- }
45
- stateHuman(_) {
46
- return this.distributors.entries().flatMap(([pool, distributor]) => ({
47
- address: distributor,
48
- version: this.version,
49
- pool
50
- }));
51
- }
52
- get state() {
53
- return { distributors: this.distributors.asRecord() };
54
- }
55
- hydrate(state) {
56
- this.#distributors = new AddressMap(Object.entries(state.distributors), MAP_LABEL);
57
- }
58
- };
59
- //#endregion
60
- export { DegenDistributorsPlugin };
@@ -1,3 +0,0 @@
1
- import { DegenDistributorsPlugin } from "./DegenDistributorsPlugin.js";
2
- import "./types.js";
3
- export { DegenDistributorsPlugin };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1 +0,0 @@
1
- export {};
@@ -1,113 +0,0 @@
1
- import { AddressMap } from "../../onchain/utils/AddressMap.js";
2
- import { BasePlugin } from "../../onchain/plugins/BasePlugin.js";
3
- import "../../onchain/index.js";
4
- //#region src/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.ts
5
- const MAP_LABEL = "delayedWithdrawal";
6
- var DelayedWithdrawalPlugin = class extends BasePlugin {
7
- async load(force) {
8
- if (!force && this.loaded) return this.state;
9
- await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(force);
10
- return this.state;
11
- }
12
- get loaded() {
13
- return !!this.sdk.withdrawalCompressor?.state;
14
- }
15
- /**
16
- * Returns a map of cmAddress -> array of delayed assets
17
- * @throws if withdrawable assets have not been loaded
18
- */
19
- get withdrawableAssets() {
20
- const compressor = this.sdk.withdrawalCompressor;
21
- if (!compressor?.state) throw new Error("withdrawable assets are not loaded");
22
- const result = new AddressMap(void 0, MAP_LABEL);
23
- for (const cfg of compressor.getWithdrawableAssets()) {
24
- const assets = result.get(cfg.creditManager) ?? [];
25
- assets.push({
26
- ...cfg,
27
- disabled: isConfigToOmit({
28
- creditManager: cfg.creditManager,
29
- token: cfg.token,
30
- withdrawalPhantomToken: cfg.withdrawalPhantomToken,
31
- underlying: cfg.underlying
32
- })
33
- });
34
- result.upsert(cfg.creditManager, assets);
35
- }
36
- return result;
37
- }
38
- stateHuman(_) {
39
- return this.withdrawableAssets.values().flatMap((cm) => {
40
- return cm.map((a) => {
41
- return {
42
- address: a.creditManager,
43
- version: this.version,
44
- ...a
45
- };
46
- });
47
- });
48
- }
49
- get state() {
50
- return {};
51
- }
52
- };
53
- function getConfigKey(config) {
54
- return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
55
- }
56
- function isConfigToOmit(config) {
57
- return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
58
- }
59
- const CONFIGS_TO_OMIT_RECORD = [
60
- {
61
- creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
62
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
63
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
64
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
65
- },
66
- {
67
- creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
68
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
69
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
70
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
71
- },
72
- {
73
- creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
74
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
75
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
76
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
77
- },
78
- {
79
- creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
80
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
81
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
82
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
83
- },
84
- {
85
- creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
86
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
87
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
88
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
89
- },
90
- {
91
- creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
92
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
93
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
94
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
95
- },
96
- {
97
- creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
98
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
99
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
100
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
101
- },
102
- {
103
- creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
104
- token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
105
- withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
106
- underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
107
- }
108
- ].reduce((acc, config) => {
109
- acc[getConfigKey(config)] = config;
110
- return acc;
111
- }, {});
112
- //#endregion
113
- export { DelayedWithdrawalPlugin };
@@ -1,3 +0,0 @@
1
- import { DelayedWithdrawalPlugin } from "./DelayedWithdrawalPlugin.js";
2
- import "./types.js";
3
- export { DelayedWithdrawalPlugin };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1 +0,0 @@
1
- export {};
@@ -1,38 +0,0 @@
1
- import { ILogger } from "../../types/logger.js";
2
- import { CreditSuite } from "../../market/credit/CreditSuite.js";
3
- import { MultiCall } from "../../types/transactions.js";
4
- import "../../types/index.js";
5
- import { PublicClient } from "viem";
6
- //#region src/onchain/accounts/utils/midasUtils.d.ts
7
- interface PrependMidasReceiveGreenlistProps {
8
- /**
9
- * Credit manager the account is opened on
10
- */
11
- cm: CreditSuite;
12
- /**
13
- * Client to read gateway `mode` with
14
- */
15
- client: PublicClient;
16
- /**
17
- * Calls to run in the credit facade multicall, as produced by the router
18
- */
19
- calls: MultiCall[];
20
- logger?: ILogger;
21
- }
22
- /**
23
- * Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
24
- * multicall that mints an mToken through a Midas issuance vault.
25
- *
26
- * Permissioned and restricted-interface mTokens can only be held by greenlisted
27
- * accounts, and a freshly opened credit account is never greenlisted, so the
28
- * mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
29
- * the greenlist first. Greenlisting the borrower is not enough — the role is
30
- * checked on the token holder, which is the credit account.
31
- *
32
- * Returns `calls` unchanged when nothing has to be greenlisted: no issuance
33
- * vault is called, its mToken has no gateway adapter on this credit manager,
34
- * the gateway is permissionless, or the call is already there.
35
- */
36
- declare function prependMidasReceiveGreenlist(props: PrependMidasReceiveGreenlistProps): Promise<MultiCall[]>;
37
- //#endregion
38
- export { PrependMidasReceiveGreenlistProps, prependMidasReceiveGreenlist };
@@ -1,12 +0,0 @@
1
- import { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
3
- import { bptStablePriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- //#region src/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts
7
- type abi = typeof bptStablePriceFeedAbi;
8
- declare class BalancerStablePriceFeedContract extends AbstractLPPriceFeedContract<abi> {
9
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
10
- }
11
- //#endregion
12
- export { BalancerStablePriceFeedContract };
@@ -1,15 +0,0 @@
1
- import { BoundedOracleStateHuman } from "../../types/state-human.js";
2
- import { AbstractPriceFeedContract, PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
3
- import { boundedPriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- import "../../types/index.js";
7
- //#region src/onchain/market/pricefeeds/BoundedPriceFeed.d.ts
8
- type abi = typeof boundedPriceFeedAbi;
9
- declare class BoundedPriceFeedContract extends AbstractPriceFeedContract<abi> {
10
- readonly upperBound: bigint;
11
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
12
- stateHuman(raw?: boolean): Omit<BoundedOracleStateHuman, "stalenessPeriod">;
13
- }
14
- //#endregion
15
- export { BoundedPriceFeedContract };
@@ -1,12 +0,0 @@
1
- import { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
3
- import { curveCryptoLpPriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- //#region src/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts
7
- type abi = typeof curveCryptoLpPriceFeedAbi;
8
- declare class CurveCryptoPriceFeedContract extends AbstractLPPriceFeedContract<abi> {
9
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
10
- }
11
- //#endregion
12
- export { CurveCryptoPriceFeedContract };
@@ -1,12 +0,0 @@
1
- import { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
3
- import { curveStableLpPriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- //#region src/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts
7
- type abi = typeof curveStableLpPriceFeedAbi;
8
- declare class CurveStablePriceFeedContract extends AbstractLPPriceFeedContract<abi> {
9
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
10
- }
11
- //#endregion
12
- export { CurveStablePriceFeedContract };
@@ -1,12 +0,0 @@
1
- import { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
3
- import { curveUsdPriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- //#region src/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts
7
- type abi = typeof curveUsdPriceFeedAbi;
8
- declare class CurveUSDPriceFeedContract extends AbstractLPPriceFeedContract<abi> {
9
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
10
- }
11
- //#endregion
12
- export { CurveUSDPriceFeedContract };
@@ -1,12 +0,0 @@
1
- import { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
3
- import { erc4626PriceFeedAbi } from "../../abi/oracles.js";
4
- import "../../abi/index.js";
5
- import { ConstructOptions } from "../../base/Construct.js";
6
- //#region src/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts
7
- type abi = typeof erc4626PriceFeedAbi;
8
- declare class Erc4626PriceFeedContract extends AbstractLPPriceFeedContract<abi> {
9
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
10
- }
11
- //#endregion
12
- export { Erc4626PriceFeedContract };
@@ -1,11 +0,0 @@
1
- import { AbstractPriceFeedContract, PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
2
- import { chainlinkReadableAggregatorAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- import { ConstructOptions } from "../../base/Construct.js";
5
- //#region src/onchain/market/pricefeeds/ExternalPriceFeed.d.ts
6
- type abi = typeof chainlinkReadableAggregatorAbi;
7
- declare class ExternalPriceFeedContract extends AbstractPriceFeedContract<abi> {
8
- constructor(options: ConstructOptions, args: PartialPriceFeedTreeNode);
9
- }
10
- //#endregion
11
- export { ExternalPriceFeedContract };