@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
@@ -2,6 +2,24 @@ import { AddressMap } from "../../../utils/AddressMap.js";
2
2
  //#region src/onchain/accounts/intents/utils/common.ts
3
3
  /** Case-insensitive address equality. */
4
4
  const eq = (a, b) => a.toLowerCase() === b.toLowerCase();
5
+ /**
6
+ * The suite and market behind a credit manager, or nothing where the register
7
+ * has no entry for it.
8
+ *
9
+ * For the reads a form calls on every keystroke, including before the SDK has
10
+ * finished attaching: a question the register cannot answer yet is not an
11
+ * error. Everything that prepares a transaction wants the throw instead.
12
+ */
13
+ function resolveCreditManager(sdk, creditManager) {
14
+ try {
15
+ return {
16
+ suite: sdk.marketRegister.findCreditManager(creditManager),
17
+ market: sdk.marketRegister.findByCreditManager(creditManager)
18
+ };
19
+ } catch {
20
+ return;
21
+ }
22
+ }
5
23
  function toTargetDecimals(fromAmount, fromToken, toToken, sdk) {
6
24
  const fromDecimals = sdk.tokensMeta.get(fromToken)?.decimals ?? 18;
7
25
  const toDecimals = sdk.tokensMeta.get(toToken)?.decimals ?? 18;
@@ -37,4 +55,4 @@ function toRouterCaSlice(creditAccount, expectedBalances = []) {
37
55
  };
38
56
  }
39
57
  //#endregion
40
- export { eq, toRouterCaSlice, toTargetDecimals };
58
+ export { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals };
@@ -26,6 +26,26 @@ function toCreditAccountSlice(ca) {
26
26
  };
27
27
  }
28
28
  /**
29
+ * The slice a flow that has no account yet quotes against.
30
+ *
31
+ * Nothing of it exists on chain until the transaction lands, and nothing has
32
+ * to: the pathfinder is asked about the credit manager, and every balance the
33
+ * flow reasons about is one the transaction itself puts there. The zero
34
+ * address stands in for the account so the shape is complete.
35
+ */
36
+ function unopenedAccountSlice(args) {
37
+ return {
38
+ creditAccount: "0x0000000000000000000000000000000000000000",
39
+ creditManager: args.creditManager.toLowerCase(),
40
+ creditFacade: args.creditFacade.toLowerCase(),
41
+ underlying: args.underlying.toLowerCase(),
42
+ enabledTokensMask: 0n,
43
+ totalDebtUSD: 0n,
44
+ totalDebt: 0n,
45
+ tokens: []
46
+ };
47
+ }
48
+ /**
29
49
  * Reads an account by address and narrows it to {@link CreditAccountSlice}.
30
50
  *
31
51
  * The shared read model's `StrategyPosition` carries neither `tokens` nor
@@ -40,4 +60,4 @@ async function fetchCreditAccountSlice(sdk, creditAccount) {
40
60
  return toCreditAccountSlice(data);
41
61
  }
42
62
  //#endregion
43
- export { fetchCreditAccountSlice, toCreditAccountSlice };
63
+ export { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice };
@@ -1,11 +1,11 @@
1
- import { eq, toRouterCaSlice, toTargetDecimals } from "./common.js";
1
+ import { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals } from "./common.js";
2
2
  import { isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, rankAccountTokens } from "./pick-token.js";
3
3
  import { adjustStateToSnapshot } from "./adjust-state-to-snapshot.js";
4
4
  import { assembleOperationCalls } from "./assemble-operation-calls.js";
5
5
  import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-interest-and-fees.js";
6
- import { fetchCreditAccountSlice, toCreditAccountSlice } from "./credit-account-slice.js";
6
+ import { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice } from "./credit-account-slice.js";
7
7
  import { OperationLedger } from "./ledger.js";
8
8
  import { collectPriceImpact, lossRate, startProbe } from "./price-impact.js";
9
9
  import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./quotas-for-update.js";
10
10
  import { createOraclePaths, createRouterPaths } from "./router-path.js";
11
- export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals };
11
+ export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice };
@@ -18,12 +18,12 @@ function probeBasket(balances, oracle) {
18
18
  if (usd > 0n) basketWad += usd * WAD / PRICE_DECIMALS;
19
19
  }
20
20
  if (basketWad <= 0n) return;
21
- const probeWad = PROBE_UNIT_USD_WAD;
22
21
  const scaled = balances.map((asset) => ({
23
22
  token: asset.token,
24
- balance: asset.balance * probeWad / basketWad
23
+ balance: asset.balance * PROBE_UNIT_USD_WAD / basketWad
25
24
  }));
26
- if (!scaled.some((a) => a.balance > 0n)) return;
25
+ const probeWad = scaled.reduce((sum, a) => sum + oracle.safeConvertToUSD(a.token, a.balance).value * WAD / PRICE_DECIMALS, 0n);
26
+ if (probeWad <= 0n) return;
27
27
  return {
28
28
  balances: scaled,
29
29
  basketWad,
@@ -85,12 +85,15 @@ async function collectPriceImpact(probes, ctx) {
85
85
  lossUnd += loss;
86
86
  }
87
87
  if (expectedUnd <= 0n) return;
88
- return lossRate({
89
- lossUnd,
90
- expectedUnd,
91
- totalValue: ctx.totalValue,
92
- netValue: ctx.netValue
93
- });
88
+ return {
89
+ ...lossRate({
90
+ lossUnd,
91
+ expectedUnd,
92
+ totalValue: ctx.totalValue,
93
+ netValue: ctx.netValue
94
+ }),
95
+ absolutePriceImpact: ctx.toUnderlyingAmount(-lossUnd)
96
+ };
94
97
  }
95
98
  //#endregion
96
99
  export { collectPriceImpact, lossRate, startProbe };
@@ -2,11 +2,8 @@ import { toRouterCaSlice } from "./common.js";
2
2
  import { startProbe } from "./price-impact.js";
3
3
  //#region src/onchain/accounts/intents/utils/router-path.ts
4
4
  /**
5
- * The engine's only door to the pathfinder.
6
- *
7
- * Deliberately not a quoter abstraction with an oracle-priced twin: paths are
8
- * always resolved on-chain, because a preview whose swap amounts came from
9
- * oracle prices could not produce the calldata that realises them.
5
+ * The engine's only door to the pathfinder, and the only quoter whose legs can
6
+ * be sent. {@link createOraclePaths} is the twin for a walk that only projects.
10
7
  */
11
8
  function createRouterPaths(args) {
12
9
  const { sdk, creditAccount, slippage } = args;
@@ -91,6 +88,7 @@ function createRouterPaths(args) {
91
88
  amount,
92
89
  keep
93
90
  });
91
+ if (leg.calls.length === 0) throw new Error("swap: missing router calls");
94
92
  return {
95
93
  ...leg,
96
94
  probe: probe && {
@@ -107,6 +105,7 @@ function createRouterPaths(args) {
107
105
  route: async (quoted) => (await quoteClose(quoted)).amount
108
106
  });
109
107
  const { amount, minAmount, calls } = await quoteClose(balances);
108
+ if (calls.length === 0 && minAmount > 0n) throw new Error("closeAll: missing router calls");
110
109
  const leg = {
111
110
  amount,
112
111
  minAmount,
@@ -0,0 +1,95 @@
1
+ import { BigIntMath } from "../../utils/bigint-math.js";
2
+ import "../../utils/index.js";
3
+ import { MIN_HEALTH_FACTOR_FACADE } from "../../validation/helpers/health-factor-limits.js";
4
+ import "../../validation/index.js";
5
+ import { eq } from "./utils/common.js";
6
+ import { maxProportionalWithdrawal } from "./math.js";
7
+ import { collateralValuation } from "./collateral-valuation.js";
8
+ import { accountView } from "./view.js";
9
+ //#region src/onchain/accounts/intents/withdraw-limits.ts
10
+ /**
11
+ * Every limit a `WITHDRAW` answers to, in underlying units.
12
+ *
13
+ * The one place they are assembled, so the figure a form is offered and the
14
+ * figure the collateral guard names when it turns a withdrawal down cannot
15
+ * drift apart: `CreditAccountOperationsService` reports this, and the guard
16
+ * quotes it back.
17
+ *
18
+ * @param props - Account slice, the SDK holding its market, and optionally the
19
+ * collateral the withdrawal would be funded from
20
+ * @returns The three limits, see {@link WithdrawCeilings}
21
+ **/
22
+ function withdrawLimits(props) {
23
+ const { creditAccount, sdk } = props;
24
+ const view = accountView(creditAccount, sdk);
25
+ const partial = maxProportionalWithdrawal(view, view.debtLimits);
26
+ const safe = maxSafeWithdrawal({
27
+ ...props,
28
+ targetHF: BigInt(MIN_HEALTH_FACTOR_FACADE)
29
+ });
30
+ return {
31
+ partial,
32
+ safePartial: BigIntMath.min(partial, safe),
33
+ exit: view.collateral > 0n ? view.collateral : 0n
34
+ };
35
+ }
36
+ /**
37
+ * Largest proportional withdrawal the safe-price collateral check still clears,
38
+ * in underlying units.
39
+ *
40
+ * A withdrawal hands funds over, so the facade weighs the account it leaves
41
+ * behind at safe prices rather than main ones — see {@link collateralValuation}.
42
+ * That is a second limit on top of the facade's `debtLimits`, and the two are
43
+ * independent: a caller wanting the amount a form may actually offer takes the
44
+ * lesser of this and `maxProportionalWithdrawal`.
45
+ *
46
+ * The arithmetic is the check solved for the amount. Taking `W` out at fixed
47
+ * leverage repays `dD = D·W/C`, so `W·TVL/C` of value is sold out of the source
48
+ * token; each dollar of that sale costs the check the source's threshold times
49
+ * its safe-to-main price ratio, while the repayment relieves `targetHF` per
50
+ * dollar of debt. Both terms are linear in `W`, which is why one division
51
+ * answers instead of a search — and why the answer is exact rather than a
52
+ * bound, as long as the plan really does fund itself from `sourceToken`.
53
+ *
54
+ * Two consequences worth stating, because they surprise:
55
+ *
56
+ * - An account whose collateral is entirely a token the reserve feed marks
57
+ * down cannot withdraw at all once it is under the threshold. A proportional
58
+ * withdrawal scales collateral and debt together, so it leaves the safe-price
59
+ * factor exactly where it found it — no amount climbs back over.
60
+ * - Leaving entirely is never refused for this reason: the exit settles the
61
+ * debt instead of shrinking it, and a check with no debt to divide by has
62
+ * nothing to refuse.
63
+ *
64
+ * @returns Amount in underlying units. The account's net value when safe prices
65
+ * do not limit the withdrawal at all, so the caller's `min` is a no-op; `0n`
66
+ * when the account already sits below `targetHF` at safe prices, and only the
67
+ * exit is left
68
+ **/
69
+ function maxSafeWithdrawal(props) {
70
+ const { creditAccount, sdk, targetHF } = props;
71
+ const view = accountView(creditAccount, sdk);
72
+ if (view.collateral <= 0n) return 0n;
73
+ if (view.debt === 0n) return view.collateral;
74
+ const valuation = collateralValuation(creditAccount, sdk);
75
+ const source = props.sourceToken ?? view.fattest();
76
+ const holding = source === void 0 ? void 0 : creditAccount.tokens.find((t) => eq(t.token, source));
77
+ if (!holding) return view.collateral;
78
+ let total = 0n;
79
+ for (const t of creditAccount.tokens) if (valuation.counts(t)) total += valuation.weigh(t);
80
+ const debtUsd = valuation.mainUsd(valuation.underlying, view.debt);
81
+ if (debtUsd === void 0 || debtUsd <= 0n) return view.collateral;
82
+ const slack = total - debtUsd * targetHF;
83
+ if (slack < 0n) return 0n;
84
+ const sourceMainUsd = valuation.mainUsd(holding.token, holding.balance);
85
+ if (sourceMainUsd === void 0 || sourceMainUsd <= 0n) return view.collateral;
86
+ const sourceRate = valuation.lt(holding.token) * valuation.checkedUsd(holding);
87
+ const tvlUsd = valuation.mainUsd(valuation.underlying, view.collateral + view.debt);
88
+ if (tvlUsd === void 0) return view.collateral;
89
+ const drain = sourceRate * tvlUsd - targetHF * debtUsd * sourceMainUsd;
90
+ if (drain <= 0n) return view.collateral;
91
+ const limit = view.collateral * slack * sourceMainUsd / drain;
92
+ return limit < view.collateral ? limit : view.collateral;
93
+ }
94
+ //#endregion
95
+ export { maxSafeWithdrawal, withdrawLimits };
@@ -9,9 +9,9 @@ import "../../utils/index.js";
9
9
  import { SDKConstruct } from "../../base/SDKConstruct.js";
10
10
  import "../../base/index.js";
11
11
  import { usdToNumber } from "../../market/math.js";
12
+ import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
12
13
  import { matchesLiquidatableAccountFilter } from "../../../model/liquidations.js";
13
14
  import "../../../model/index.js";
14
- import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
15
15
  import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
16
16
  import { dominantCollateral } from "../../market/credit/collateralUtils.js";
17
17
  import { MidasLiquidatorContract } from "../../market/rwa/midas/MidasLiquidatorContract.js";
@@ -32,7 +32,6 @@ const AP_WETH_GATEWAY = "WETH_GATEWAY";
32
32
  const AP_WETH_TOKEN = "WETH_TOKEN";
33
33
  const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
34
34
  const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
35
- const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
36
35
  const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
37
36
  /**
38
37
  * Default address provider address for v3.1.0
@@ -40,4 +39,4 @@ const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
40
39
  */
41
40
  const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
42
41
  //#endregion
43
- export { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION };
42
+ export { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION };
@@ -1,8 +1,8 @@
1
- import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./address-provider.js";
1
+ import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./address-provider.js";
2
2
  import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./addresses.js";
3
3
  import { BotPermissions, botPermissionsToString } from "./bot-permissions.js";
4
4
  import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance } from "./math.js";
5
5
  import { BLOCKS_PER_WEEK_BY_NETWORK, RAMP_DURATION_BY_NETWORK } from "./networks.js";
6
6
  import { PERIPHERY_CONTRACTS } from "./periphery.js";
7
7
  import { VERSION_RANGE_310, isV310, isVersionRange } from "./versions.js";
8
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange, isZeroBalance };
8
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange, isZeroBalance };
@@ -1,14 +1,11 @@
1
1
  import { iVersionAbi } from "../../abi/iVersion.js";
2
- import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
2
+ import "../constants/address-provider.js";
3
3
  import { isV310 } from "../constants/versions.js";
4
4
  import "../constants/index.js";
5
5
  import { hexEq } from "../utils/hex.js";
6
6
  import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
7
7
  //#region src/onchain/core/createAddressProvider.ts
8
- const OVERRIDE_ADDRESSES = { Mainnet: {
9
- [AP_PRICE_FEED_COMPRESSOR]: { 311: "0x1fA2637B9fab0CD14290A7EE908DDc9688a15120" },
10
- [AP_MARKET_COMPRESSOR]: { 311: "0x0C27F242f6e9F2A9AD3261bE6e439De3B948bcA2" }
11
- } };
8
+ const OVERRIDE_ADDRESSES = {};
12
9
  async function createAddressProvider(sdk, address) {
13
10
  let v;
14
11
  if (hexEq(address, "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38")) v = 310n;
@@ -11,7 +11,7 @@ import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator,
11
11
  import { detectNetwork } from "./chain/detectNetwork.js";
12
12
  import "./chain/index.js";
13
13
  import { etherscanApiUrl, etherscanUrl } from "./utils/etherscan.js";
14
- import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./constants/address-provider.js";
14
+ import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./constants/address-provider.js";
15
15
  import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./constants/addresses.js";
16
16
  import { BotPermissions, botPermissionsToString } from "./constants/bot-permissions.js";
17
17
  import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance } from "./constants/math.js";
@@ -149,29 +149,34 @@ import { estimateRawTxGas, sendRawTx } from "./utils/viem/sendRawTx.js";
149
149
  import { watchBlocksAsync } from "./utils/viem/watchBlocksAsync.js";
150
150
  import "./utils/viem/index.js";
151
151
  import { collateralPriceInUnderlying } from "./market/oracle/collateralPriceInUnderlying.js";
152
- import { isUpdatablePriceFeed } from "./market/pricefeeds/isUpdatablePriceFeed.js";
153
152
  import { PriceFeedRef } from "./market/pricefeeds/PriceFeedRef.js";
154
153
  import { AbstractPriceFeedContract, PartialPriceFeedInitError } from "./market/pricefeeds/AbstractPriceFeed.js";
155
154
  import { AbstractLPPriceFeedContract, isLPPriceFeed } from "./market/pricefeeds/AbstractLPPriceFeed.js";
156
- import { BalancerStablePriceFeedContract } from "./market/pricefeeds/BalancerStablePriceFeed.js";
157
- import { BalancerWeightedPriceFeedContract } from "./market/pricefeeds/BalancerWeightedPriceFeed.js";
158
- import { BoundedPriceFeedContract } from "./market/pricefeeds/BoundedPriceFeed.js";
159
- import { CompositePriceFeedContract } from "./market/pricefeeds/CompositePriceFeed.js";
160
- import { CurveCryptoPriceFeedContract } from "./market/pricefeeds/CurveCryptoPriceFeed.js";
161
- import { CurveStablePriceFeedContract } from "./market/pricefeeds/CurveStablePriceFeed.js";
162
- import { CurveUSDPriceFeedContract } from "./market/pricefeeds/CurveUSDPriceFeed.js";
163
- import { Erc4626PriceFeedContract } from "./market/pricefeeds/Erc4626PriceFeed.js";
164
- import { ExternalPriceFeedContract } from "./market/pricefeeds/ExternalPriceFeed.js";
165
- import { getRawPriceUpdates } from "./market/pricefeeds/getRawPriceUpdates.js";
166
- import { MellowLRTPriceFeedContract } from "./market/pricefeeds/MellowLRTPriceFeed.js";
167
- import { PendleTWAPPTPriceFeed } from "./market/pricefeeds/PendleTWAPPTPriceFeed.js";
168
- import { PythPriceFeed } from "./market/pricefeeds/PythPriceFeed.js";
169
- import { RedstonePriceFeedContract } from "./market/pricefeeds/RedstonePriceFeed.js";
155
+ import { BalancerStablePriceFeedContract } from "./market/pricefeeds/feeds/BalancerStablePriceFeed.js";
156
+ import { BalancerWeightedPriceFeedContract } from "./market/pricefeeds/feeds/BalancerWeightedPriceFeed.js";
157
+ import { BoundedPriceFeedContract } from "./market/pricefeeds/feeds/BoundedPriceFeed.js";
158
+ import { CompositePriceFeedContract } from "./market/pricefeeds/feeds/CompositePriceFeed.js";
159
+ import { ConstantPriceFeedContract } from "./market/pricefeeds/feeds/ConstantPriceFeed.js";
160
+ import { CurveCryptoPriceFeedContract } from "./market/pricefeeds/feeds/CurveCryptoPriceFeed.js";
161
+ import { CurveStablePriceFeedContract } from "./market/pricefeeds/feeds/CurveStablePriceFeed.js";
162
+ import { CurveUSDPriceFeedContract } from "./market/pricefeeds/feeds/CurveUSDPriceFeed.js";
163
+ import { Erc4626PriceFeedContract } from "./market/pricefeeds/feeds/Erc4626PriceFeed.js";
164
+ import { ExternalPriceFeedContract } from "./market/pricefeeds/feeds/ExternalPriceFeed.js";
165
+ import { MellowLRTPriceFeedContract } from "./market/pricefeeds/feeds/MellowLRTPriceFeed.js";
166
+ import { PendleTWAPPTPriceFeed } from "./market/pricefeeds/feeds/PendleTWAPPTPriceFeed.js";
167
+ import { PythPriceFeed } from "./market/pricefeeds/feeds/PythPriceFeed.js";
168
+ import { RedstonePriceFeedContract } from "./market/pricefeeds/feeds/RedstonePriceFeed.js";
169
+ import { WstETHPriceFeedContract } from "./market/pricefeeds/feeds/WstETHPriceFeed.js";
170
+ import { YearnPriceFeedContract } from "./market/pricefeeds/feeds/YearnPriceFeed.js";
171
+ import { ZeroPriceFeedContract } from "./market/pricefeeds/feeds/ZeroPriceFeed.js";
172
+ import { PriceFeedRegistry } from "./market/pricefeeds/PriceFeedRegistry.js";
170
173
  import { fetchRedstonePayloads } from "./market/pricefeeds/updates/fetchRedstonePayloads.js";
171
- import { WstETHPriceFeedContract } from "./market/pricefeeds/WstETHPriceFeed.js";
172
- import { YearnPriceFeedContract } from "./market/pricefeeds/YearnPriceFeed.js";
173
- import { ZeroPriceFeedContract } from "./market/pricefeeds/ZeroPriceFeed.js";
174
- import { PriceFeedRegister } from "./market/pricefeeds/PriceFeedsRegister.js";
174
+ import { getRawPriceUpdates } from "./market/pricefeeds/updates/getRawPriceUpdates.js";
175
+ import { isUpdatablePriceFeed } from "./market/pricefeeds/updates/isUpdatablePriceFeed.js";
176
+ import { PriceUpdatesCache } from "./market/pricefeeds/updates/PriceUpdatesCache.js";
177
+ import { RedstoneOptions, RedstoneUpdater } from "./market/pricefeeds/updates/RedstoneUpdater.js";
178
+ import { updatableDependencies } from "./market/pricefeeds/updates/updatableDependencies.js";
179
+ import { UpdatablePriceFeedRegistry } from "./market/pricefeeds/updates/UpdatablePriceFeedRegistry.js";
175
180
  import { PriceOracleV310Contract } from "./market/oracle/PriceOracleV310Contract.js";
176
181
  import { createPriceOracle } from "./market/oracle/createPriceOracle.js";
177
182
  import { GaugeContract } from "./market/pool/GaugeContract.js";
@@ -188,7 +193,7 @@ import { MidasLiquidatorContract } from "./market/rwa/midas/MidasLiquidatorContr
188
193
  import { SecuritizeDegenNFT } from "./market/rwa/securitize/SecuritizeDegenNFT.js";
189
194
  import { SecuritizeLiquidatorContract } from "./market/rwa/securitize/SecuritizeLiquidatorContract.js";
190
195
  import { SecuritizeRWAFactory } from "./market/rwa/securitize/SecuritizeRWAFactory.js";
191
- import { RWARegistry } from "./market/rwa/RWARegistry.js";
196
+ import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./market/rwa/RWARegistry.js";
192
197
  import { isRWAFactory } from "./market/rwa/types.js";
193
198
  import "./market/index.js";
194
199
  import { CreditAccountCompressorV310Contract } from "./accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js";
@@ -212,15 +217,17 @@ import { checkPoolPaused } from "./validation/checks/checkPoolPaused.js";
212
217
  import { checkPoolSunset } from "./validation/checks/checkPoolSunset.js";
213
218
  import { checkQuotaCount } from "./validation/checks/checkQuotaCount.js";
214
219
  import { checkQuotaLimit } from "./validation/checks/checkQuotaLimit.js";
220
+ import { checkReservePriceLimited } from "./validation/checks/checkReservePriceLimited.js";
215
221
  import { checkAccountQuotas } from "./validation/bundles/checkAccountQuotas.js";
216
222
  import { checkWalletAllowance } from "./validation/bundles/checkWalletAllowance.js";
217
223
  import { checkWalletBalance } from "./validation/bundles/checkWalletBalance.js";
218
224
  import { checkCollateralFunding } from "./validation/bundles/checkCollateralFunding.js";
219
- import { checkDraw } from "./validation/bundles/checkDraw.js";
220
225
  import { checkHealthFactors } from "./validation/bundles/checkHealthFactors.js";
226
+ import { checkIncreaseDebt } from "./validation/bundles/checkIncreaseDebt.js";
227
+ import { checkIncreaseQuota } from "./validation/bundles/checkIncreaseQuota.js";
221
228
  import { checkMarket } from "./validation/bundles/checkMarket.js";
222
229
  import { checkObtained } from "./validation/bundles/checkObtained.js";
223
- import { checkQuotasAsked } from "./validation/bundles/checkQuotasAsked.js";
230
+ import { checkMidasAccountGreenlist } from "./validation/bundles/checkMidasAccountGreenlist.js";
224
231
  import { checkRWAOpenRequirements } from "./validation/bundles/checkRWAOpenRequirements.js";
225
232
  import { checkRWAOpening } from "./validation/bundles/checkRWAOpening.js";
226
233
  import { checkCreditOperation } from "./validation/bundles/checkCreditOperation.js";
@@ -291,6 +298,7 @@ import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/preview/detectCl
291
298
  import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/preview/detectDelayedClaim.js";
292
299
  import { detectDelayedOperation } from "./preview/preview/detectDelayedOperation.js";
293
300
  import { estimateClaimableAt } from "./preview/preview/estimateClaimableAt.js";
301
+ import { midasGreenlistsAccount } from "./preview/preview/midasGreenlistsAccount.js";
294
302
  import { previewAdjustStrategyPosition } from "./preview/preview/previewAdjustStrategyPosition.js";
295
303
  import { previewExitOrRepayStrategyPosition } from "./preview/preview/previewExitOrRepayStrategyPosition.js";
296
304
  import { makeReplayState, replayInnerOperations } from "./preview/preview/replayInnerOperations.js";
@@ -298,4 +306,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
298
306
  import { previewOperation } from "./preview/preview/previewOperation.js";
299
307
  import "./preview/index.js";
300
308
  import "./types/index.js";
301
- export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
309
+ export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstoneOptions, RedstonePriceFeedContract, RedstoneUpdater, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
@@ -19,7 +19,7 @@ const adapterConstructorAbi = {
19
19
  ["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
20
20
  ["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
21
21
  ["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
22
- ["MIDAS_GATEWAY"]: { 311: REFERER_ID_ADAPTER_ABI },
22
+ ["MIDAS_GATEWAY"]: { 311: BASIC_ADAPTER_ABI },
23
23
  ["MIDAS_REDEMPTION_VAULT"]: {
24
24
  310: BASIC_ADAPTER_ABI,
25
25
  311: BASIC_ADAPTER_ABI
@@ -65,7 +65,7 @@ const adapterConstructorAbi = {
65
65
  ["INFINIFI_UNWINDING"]: { 310: PHANTOM_TOKEN_ADAPTER_ABI },
66
66
  ["SECURITIZE_REDEMPTION"]: {
67
67
  310: PHANTOM_TOKEN_ADAPTER_ABI,
68
- 311: PHANTOM_TOKEN_ADAPTER_ABI
68
+ 311: BASIC_ADAPTER_ABI
69
69
  },
70
70
  ["STAKING_REWARDS"]: { 312: STAKING_REWARDS_ADAPTER_ABI },
71
71
  ["MIDAS_ISSUANCE_VAULT"]: {
@@ -128,6 +128,12 @@ var AbstractAdapterContract = class extends BaseContract {
128
128
  return false;
129
129
  }
130
130
  /**
131
+ * {@inheritDoc IAdapterContract.openingCalls}
132
+ */
133
+ async openingCalls() {
134
+ return [];
135
+ }
136
+ /**
131
137
  * Applies the balance changes of a decoded adapter call to the running
132
138
  * balances, mutating them in place. Overrides should express changes via
133
139
  * {@link setLeftover} (diff-style calls) and {@link spendExact}
@@ -5,7 +5,7 @@ import "../abi/adapters/index.js";
5
5
  import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
6
6
  import "../abi/index.js";
7
7
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
8
- import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, isAddressEqual, zeroAddress } from "viem";
8
+ import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, getAddress, isAddressEqual, zeroAddress } from "viem";
9
9
  //#region src/onchain/market/adapters/contracts/MidasGatewayAdapterContract.ts
10
10
  const abi = iMidasGatewayAdapterV311Abi;
11
11
  const protocolAbi = iMidasGatewayV311Abi;
@@ -13,6 +13,12 @@ const receiveGreenlistCalldata = encodeFunctionData({
13
13
  abi,
14
14
  functionName: "receiveGreenlist"
15
15
  });
16
+ const MGLOBAL_MTOKEN = getAddress("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
17
+ /**
18
+ * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
19
+ * see MidasMode in integrations-v3
20
+ */
21
+ const MIDAS_MODE_PERMISSIONLESS = 0;
16
22
  var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
17
23
  #version;
18
24
  #gateway;
@@ -20,6 +26,7 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
20
26
  #quoteToken;
21
27
  #phantomToken;
22
28
  #referrerId;
29
+ #mode;
23
30
  constructor(sdk, args) {
24
31
  super(sdk, {
25
32
  ...args,
@@ -125,6 +132,35 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
125
132
  if (this.#referrerId === void 0) throw new MissingSerializedParamsError("referrerId");
126
133
  return this.#referrerId;
127
134
  }
135
+ /**
136
+ * Gateway `mode` is immutable on-chain, so the first read is reused.
137
+ */
138
+ async mode() {
139
+ if (!this.#mode) this.#mode = this.client.readContract({
140
+ address: this.targetContract,
141
+ abi: this.protocolAbi,
142
+ functionName: "mode"
143
+ });
144
+ return this.#mode;
145
+ }
146
+ /**
147
+ * {@inheritDoc IAdapterContract.openingCalls}
148
+ */
149
+ async openingCalls() {
150
+ if (isAddressEqual(this.mToken, MGLOBAL_MTOKEN)) {
151
+ this.logger?.debug(`midas: skipping receiveGreenlist for mGLOBAL ${this.mToken}`);
152
+ return [];
153
+ }
154
+ if (await this.mode() === MIDAS_MODE_PERMISSIONLESS) {
155
+ this.logger?.debug(`midas: gateway ${this.targetContract} is permissionless, nothing to greenlist`);
156
+ return [];
157
+ }
158
+ this.logger?.debug(`midas: greenlisting the credit account via gateway adapter ${this.address}`);
159
+ return [{
160
+ target: this.address,
161
+ callData: receiveGreenlistCalldata
162
+ }];
163
+ }
128
164
  stateHuman(raw) {
129
165
  return {
130
166
  ...super.stateHuman(raw),
@@ -169,14 +205,22 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
169
205
  return { redeemer };
170
206
  }
171
207
  /**
172
- * `receiveGreenlist()` is prepended by `prependMidasReceiveGreenlist`
173
- * before the balance bracket when the multicall mints a permissioned
174
- * mToken: it only greenlists the credit account and is balance-neutral,
175
- * so it is legal outside a bracket and leaves balances untouched.
208
+ * Whether `calldata` is `receiveGreenlist()`, the call that grants the
209
+ * Midas greenlisted role to the credit account.
176
210
  */
177
- replayOutOfBracketCall(_balances, calldata) {
211
+ isReceiveGreenlist(calldata) {
178
212
  return calldata === receiveGreenlistCalldata;
179
213
  }
214
+ /**
215
+ * `receiveGreenlist()` is prepended by {@link openingCalls} before the
216
+ * balance bracket when a permissioned mToken is minted: it only grants
217
+ * the Midas greenlisted role to the credit account and is
218
+ * balance-neutral, so it is legal outside a bracket and leaves balances
219
+ * untouched.
220
+ */
221
+ replayOutOfBracketCall(_balances, calldata) {
222
+ return this.isReceiveGreenlist(calldata);
223
+ }
180
224
  applyBalanceChanges(balances, decoded) {
181
225
  switch (decoded.functionName) {
182
226
  case "depositInstantDiff": {