@gearbox-protocol/sdk 17.0.0-next.3 → 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 (370) 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 +19 -7
  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 +33 -12
  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 +12 -10
  89. package/dist/cjs/onchain/validation/bundles/checkIncreaseDebt.js +28 -0
  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/checkSimulation.js +1 -1
  97. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
  98. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +2 -5
  99. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  100. package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
  101. package/dist/cjs/onchain/validation/checks/index.js +2 -0
  102. package/dist/cjs/onchain/validation/index.js +8 -4
  103. package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +2 -2
  104. package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -2
  105. package/dist/cjs/sdk/execute/ExecuteApi.js +67 -7
  106. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  107. package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
  108. package/dist/esm/dev/abi.js +14 -15
  109. package/dist/esm/dev/claimFromFaucet.js +4 -8
  110. package/dist/esm/dev/createAnvilClient.js +36 -19
  111. package/dist/esm/dev/index.js +4 -4
  112. package/dist/esm/dev/kycUtils.js +66 -59
  113. package/dist/esm/dev/midasUtils.js +112 -18
  114. package/dist/esm/dev/securitizeUtils.js +84 -44
  115. package/dist/esm/dev/withdrawalUtils.js +3 -6
  116. package/dist/esm/model/errors/index.js +2 -2
  117. package/dist/esm/model/errors/operation-errors.js +18 -2
  118. package/dist/esm/model/index.js +4 -4
  119. package/dist/esm/model/rwa.js +4 -4
  120. package/dist/esm/model/rwa.schema.js +5 -5
  121. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  122. package/dist/esm/onchain/OnchainSDK.js +3 -3
  123. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -17
  124. package/dist/esm/onchain/accounts/intents/borrow.js +138 -0
  125. package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
  126. package/dist/esm/onchain/accounts/intents/guards.js +19 -7
  127. package/dist/esm/onchain/accounts/intents/index.js +107 -20
  128. package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
  129. package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
  130. package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
  131. package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -46
  132. package/dist/esm/onchain/accounts/intents/operations.js +0 -1
  133. package/dist/esm/onchain/accounts/intents/realize.js +61 -4
  134. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  135. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  136. package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
  137. package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
  138. package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
  139. package/dist/esm/onchain/accounts/intents/utils/price-impact.js +12 -9
  140. package/dist/esm/onchain/accounts/intents/utils/router-path.js +4 -5
  141. package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
  142. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  143. package/dist/esm/onchain/constants/address-provider.js +1 -2
  144. package/dist/esm/onchain/constants/index.js +2 -2
  145. package/dist/esm/onchain/core/createAddressProvider.js +2 -5
  146. package/dist/esm/onchain/index.js +32 -24
  147. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -2
  148. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  149. package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +50 -6
  150. package/dist/esm/onchain/market/credit/CreditSuite.js +33 -12
  151. package/dist/esm/onchain/market/index.js +26 -21
  152. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
  153. package/dist/esm/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
  154. package/dist/esm/onchain/market/pricefeeds/PriceFeedRegistry.js +126 -0
  155. package/dist/esm/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
  156. package/dist/esm/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
  157. package/dist/esm/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
  158. package/dist/esm/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
  159. package/dist/esm/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
  160. package/dist/esm/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
  161. package/dist/esm/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
  162. package/dist/esm/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
  163. package/dist/esm/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
  164. package/dist/esm/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
  165. package/dist/esm/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
  166. package/dist/esm/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
  167. package/dist/esm/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
  168. package/dist/esm/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
  169. package/dist/esm/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
  170. package/dist/esm/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
  171. package/dist/esm/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
  172. package/dist/esm/onchain/market/pricefeeds/feeds/index.js +18 -0
  173. package/dist/esm/onchain/market/pricefeeds/index.js +27 -21
  174. package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +188 -0
  175. package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
  176. package/dist/esm/onchain/market/pricefeeds/updates/index.js +5 -1
  177. package/dist/esm/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
  178. package/dist/esm/onchain/market/pricefeeds/updates/updatableDependencies.js +13 -0
  179. package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
  180. package/dist/esm/onchain/market/rwa/index.js +2 -2
  181. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  182. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
  183. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  184. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  185. package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
  186. package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
  187. package/dist/esm/onchain/preview/index.js +2 -1
  188. package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  189. package/dist/esm/onchain/preview/preview/index.js +2 -1
  190. package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
  191. package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
  192. package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
  193. package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
  194. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  195. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +12 -10
  196. package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
  197. package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  198. package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
  199. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  200. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +18 -8
  201. package/dist/esm/onchain/validation/bundles/index.js +4 -3
  202. package/dist/esm/onchain/validation/checkOperation.js +0 -1
  203. package/dist/esm/onchain/validation/checkSimulation.js +1 -1
  204. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
  205. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +2 -5
  206. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +1 -1
  207. package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
  208. package/dist/esm/onchain/validation/checks/index.js +2 -1
  209. package/dist/esm/onchain/validation/index.js +5 -3
  210. package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
  211. package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +1 -1
  212. package/dist/esm/sdk/execute/ExecuteApi.js +67 -7
  213. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  214. package/dist/esm/sdk/prepare/PrepareApi.js +94 -19
  215. package/dist/types/dev/abi.d.ts +13 -15
  216. package/dist/types/dev/claimFromFaucet.d.ts +0 -1
  217. package/dist/types/dev/createAnvilClient.d.ts +10 -3
  218. package/dist/types/dev/index.d.ts +4 -4
  219. package/dist/types/dev/kycUtils.d.ts +15 -24
  220. package/dist/types/dev/midasUtils.d.ts +35 -4
  221. package/dist/types/dev/securitizeUtils.d.ts +3 -9
  222. package/dist/types/model/errors/index.d.ts +2 -2
  223. package/dist/types/model/errors/operation-errors.d.ts +65 -11
  224. package/dist/types/model/index.d.ts +5 -5
  225. package/dist/types/model/opportunities.d.ts +6 -7
  226. package/dist/types/model/previews.d.ts +25 -19
  227. package/dist/types/model/rwa.d.ts +47 -27
  228. package/dist/types/model/rwa.schema.d.ts +3 -3
  229. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
  230. package/dist/types/offchain/opportunities/types.d.ts +1 -4
  231. package/dist/types/onchain/OnchainSDK.d.ts +2 -2
  232. package/dist/types/onchain/accounts/index.d.ts +5 -4
  233. package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
  234. package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
  235. package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
  236. package/dist/types/onchain/accounts/intents/index.d.ts +103 -15
  237. package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
  238. package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
  239. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
  240. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
  241. package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
  242. package/dist/types/onchain/accounts/intents/types.d.ts +51 -6
  243. package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
  244. package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
  245. package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
  246. package/dist/types/onchain/accounts/intents/utils/price-impact.d.ts +4 -1
  247. package/dist/types/onchain/accounts/intents/utils/router-path.d.ts +2 -5
  248. package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
  249. package/dist/types/onchain/accounts/types.d.ts +4 -2
  250. package/dist/types/onchain/constants/address-provider.d.ts +1 -2
  251. package/dist/types/onchain/constants/index.d.ts +2 -2
  252. package/dist/types/onchain/index.d.ts +40 -31
  253. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
  254. package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +20 -4
  255. package/dist/types/onchain/market/adapters/types.d.ts +8 -0
  256. package/dist/types/onchain/market/credit/CreditSuite.d.ts +13 -3
  257. package/dist/types/onchain/market/credit/types.d.ts +2 -2
  258. package/dist/types/onchain/market/index.d.ts +29 -24
  259. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +2 -1
  260. package/dist/types/onchain/market/oracle/types.d.ts +2 -1
  261. package/dist/types/onchain/market/pool/types.d.ts +1 -1
  262. package/dist/types/onchain/market/pricefeeds/AbstractPriceFeed.d.ts +1 -2
  263. package/dist/types/onchain/market/pricefeeds/PriceFeedRegistry.d.ts +60 -0
  264. package/dist/types/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.d.ts +12 -0
  265. package/dist/types/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.d.ts → feeds/BalancerWeightedPriceFeed.d.ts} +7 -7
  266. package/dist/types/onchain/market/pricefeeds/feeds/BoundedPriceFeed.d.ts +15 -0
  267. package/dist/types/onchain/market/pricefeeds/{CompositePriceFeed.d.ts → feeds/CompositePriceFeed.d.ts} +6 -6
  268. package/dist/types/onchain/market/pricefeeds/{ConstantPriceFeed.d.ts → feeds/ConstantPriceFeed.d.ts} +6 -6
  269. package/dist/types/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.d.ts +12 -0
  270. package/dist/types/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.d.ts +12 -0
  271. package/dist/types/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.d.ts +12 -0
  272. package/dist/types/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.d.ts +12 -0
  273. package/dist/types/onchain/market/pricefeeds/feeds/ExternalPriceFeed.d.ts +11 -0
  274. package/dist/types/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.d.ts +12 -0
  275. package/dist/types/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.d.ts → feeds/PendleTWAPPTPriceFeed.d.ts} +3 -3
  276. package/dist/types/onchain/market/pricefeeds/{PythPriceFeed.d.ts → feeds/PythPriceFeed.d.ts} +3 -3
  277. package/dist/types/onchain/market/pricefeeds/{RedstonePriceFeed.d.ts → feeds/RedstonePriceFeed.d.ts} +9 -9
  278. package/dist/types/onchain/market/pricefeeds/feeds/WstETHPriceFeed.d.ts +12 -0
  279. package/dist/types/onchain/market/pricefeeds/feeds/YearnPriceFeed.d.ts +12 -0
  280. package/dist/types/onchain/market/pricefeeds/feeds/ZeroPriceFeed.d.ts +11 -0
  281. package/dist/types/onchain/market/pricefeeds/feeds/index.d.ts +18 -0
  282. package/dist/types/onchain/market/pricefeeds/index.d.ts +28 -22
  283. package/dist/types/onchain/market/pricefeeds/types.d.ts +1 -31
  284. package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
  285. package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +106 -0
  286. package/dist/types/onchain/market/pricefeeds/updates/getRawPriceUpdates.d.ts +6 -0
  287. package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +7 -3
  288. package/dist/types/onchain/market/pricefeeds/updates/isUpdatablePriceFeed.d.ts +6 -0
  289. package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +56 -2
  290. package/dist/types/onchain/market/pricefeeds/updates/updatableDependencies.d.ts +10 -0
  291. package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
  292. package/dist/types/onchain/market/rwa/index.d.ts +3 -3
  293. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
  294. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
  295. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
  296. package/dist/types/onchain/market/rwa/types.d.ts +39 -37
  297. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
  298. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
  299. package/dist/types/onchain/opportunities/types.d.ts +6 -1
  300. package/dist/types/onchain/preview/index.d.ts +2 -1
  301. package/dist/types/onchain/preview/preview/index.d.ts +2 -1
  302. package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
  303. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
  304. package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
  305. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +5 -4
  306. package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
  307. package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
  308. package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
  309. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
  310. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +9 -7
  311. package/dist/types/onchain/validation/bundles/index.d.ts +5 -4
  312. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
  313. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +3 -3
  314. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -1
  315. package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
  316. package/dist/types/onchain/validation/checks/index.d.ts +2 -1
  317. package/dist/types/onchain/validation/index.d.ts +6 -4
  318. package/dist/types/onchain/validation/raise.d.ts +2 -2
  319. package/dist/types/sdk/execute/index.d.ts +2 -2
  320. package/dist/types/sdk/execute/types.d.ts +48 -6
  321. package/dist/types/sdk/index.d.ts +5 -4
  322. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
  323. package/dist/types/sdk/opportunities/types.d.ts +9 -3
  324. package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
  325. package/dist/types/sdk/prepare/index.d.ts +4 -3
  326. package/dist/types/sdk/prepare/types.d.ts +200 -66
  327. package/package.json +1 -1
  328. package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -70
  329. package/dist/cjs/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -301
  330. package/dist/cjs/onchain/validation/bundles/checkDraw.js +0 -28
  331. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
  332. package/dist/cjs/plugins/degen-distributors/index.js +0 -4
  333. package/dist/cjs/plugins/degen-distributors/package.json +0 -1
  334. package/dist/cjs/plugins/degen-distributors/types.js +0 -1
  335. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
  336. package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
  337. package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
  338. package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
  339. package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -69
  340. package/dist/esm/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -300
  341. package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
  342. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
  343. package/dist/esm/plugins/degen-distributors/index.js +0 -3
  344. package/dist/esm/plugins/degen-distributors/package.json +0 -1
  345. package/dist/esm/plugins/degen-distributors/types.js +0 -1
  346. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
  347. package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
  348. package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
  349. package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
  350. package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -38
  351. package/dist/types/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts +0 -12
  352. package/dist/types/onchain/market/pricefeeds/BoundedPriceFeed.d.ts +0 -15
  353. package/dist/types/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts +0 -12
  354. package/dist/types/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts +0 -12
  355. package/dist/types/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts +0 -12
  356. package/dist/types/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts +0 -12
  357. package/dist/types/onchain/market/pricefeeds/ExternalPriceFeed.d.ts +0 -11
  358. package/dist/types/onchain/market/pricefeeds/MellowLRTPriceFeed.d.ts +0 -12
  359. package/dist/types/onchain/market/pricefeeds/PriceFeedsRegister.d.ts +0 -180
  360. package/dist/types/onchain/market/pricefeeds/WstETHPriceFeed.d.ts +0 -12
  361. package/dist/types/onchain/market/pricefeeds/YearnPriceFeed.d.ts +0 -12
  362. package/dist/types/onchain/market/pricefeeds/ZeroPriceFeed.d.ts +0 -11
  363. package/dist/types/onchain/market/pricefeeds/getRawPriceUpdates.d.ts +0 -5
  364. package/dist/types/onchain/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -5
  365. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
  366. package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
  367. package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
  368. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
  369. package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
  370. package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
@@ -3,11 +3,12 @@ const require_onchain_validation_bundles_checkAccountQuotas = require("./checkAc
3
3
  const require_onchain_validation_bundles_checkWalletAllowance = require("./checkWalletAllowance.js");
4
4
  const require_onchain_validation_bundles_checkWalletBalance = require("./checkWalletBalance.js");
5
5
  const require_onchain_validation_bundles_checkCollateralFunding = require("./checkCollateralFunding.js");
6
- const require_onchain_validation_bundles_checkDraw = require("./checkDraw.js");
7
6
  const require_onchain_validation_bundles_checkHealthFactors = require("./checkHealthFactors.js");
7
+ const require_onchain_validation_bundles_checkIncreaseDebt = require("./checkIncreaseDebt.js");
8
+ const require_onchain_validation_bundles_checkIncreaseQuota = require("./checkIncreaseQuota.js");
8
9
  const require_onchain_validation_bundles_checkMarket = require("./checkMarket.js");
9
10
  const require_onchain_validation_bundles_checkObtained = require("./checkObtained.js");
10
- const require_onchain_validation_bundles_checkQuotasAsked = require("./checkQuotasAsked.js");
11
+ const require_onchain_validation_bundles_checkMidasAccountGreenlist = require("./checkMidasAccountGreenlist.js");
11
12
  const require_onchain_validation_bundles_checkRWAOpenRequirements = require("./checkRWAOpenRequirements.js");
12
13
  const require_onchain_validation_bundles_checkRWAOpening = require("./checkRWAOpening.js");
13
14
  const require_onchain_validation_bundles_checkCreditOperation = require("./checkCreditOperation.js");
@@ -19,15 +20,16 @@ const require_onchain_validation_bundles_checkPoolOperation = require("./checkPo
19
20
  exports.checkAccountQuotas = require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas;
20
21
  exports.checkCollateralFunding = require_onchain_validation_bundles_checkCollateralFunding.checkCollateralFunding;
21
22
  exports.checkCreditOperation = require_onchain_validation_bundles_checkCreditOperation.checkCreditOperation;
22
- exports.checkDraw = require_onchain_validation_bundles_checkDraw.checkDraw;
23
23
  exports.checkHealthFactors = require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors;
24
+ exports.checkIncreaseDebt = require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt;
25
+ exports.checkIncreaseQuota = require_onchain_validation_bundles_checkIncreaseQuota.checkIncreaseQuota;
24
26
  exports.checkLiquidationEligibility = require_onchain_validation_bundles_checkLiquidationEligibility.checkLiquidationEligibility;
25
27
  exports.checkLiquidationFunding = require_onchain_validation_bundles_checkLiquidationFunding.checkLiquidationFunding;
26
28
  exports.checkMarket = require_onchain_validation_bundles_checkMarket.checkMarket;
29
+ exports.checkMidasAccountGreenlist = require_onchain_validation_bundles_checkMidasAccountGreenlist.checkMidasAccountGreenlist;
27
30
  exports.checkObtained = require_onchain_validation_bundles_checkObtained.checkObtained;
28
31
  exports.checkPoolFunding = require_onchain_validation_bundles_checkPoolFunding.checkPoolFunding;
29
32
  exports.checkPoolOperation = require_onchain_validation_bundles_checkPoolOperation.checkPoolOperation;
30
- exports.checkQuotasAsked = require_onchain_validation_bundles_checkQuotasAsked.checkQuotasAsked;
31
33
  exports.checkRWAOpenRequirements = require_onchain_validation_bundles_checkRWAOpenRequirements.checkRWAOpenRequirements;
32
34
  exports.checkRWAOpening = require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening;
33
35
  exports.checkWallet = require_onchain_validation_bundles_checkWallet.checkWallet;
@@ -43,7 +43,6 @@ async function checkOperation(input, options = {}) {
43
43
  sender
44
44
  }, options);
45
45
  case "OpenCreditAccount":
46
- case "RWAOpenCreditAccount":
47
46
  case "AdjustCreditAccount": return require_onchain_validation_bundles_checkCreditOperation.checkCreditOperation({
48
47
  sdk,
49
48
  preview,
@@ -44,7 +44,7 @@ function checkSimulation(sdk, input, options = {}) {
44
44
  maxDebt: suite.creditFacade.maxDebt,
45
45
  underlying: require_onchain_validation_helpers_token.toToken(sdk, suite.market.pool.underlying),
46
46
  allowZero: true,
47
- ceiling: suite.maxBorrowAmount()
47
+ maxBorrowAmount: suite.maxBorrowAmount()
48
48
  }),
49
49
  ..."averageQuota" in state ? require_onchain_validation_checks_checkQuotaCount.checkQuotaCount({
50
50
  count: state.averageQuota.filter((q) => q.balance > 0n).length,
@@ -5,7 +5,7 @@ const require_onchain_validation_helpers_amount = require("../helpers/amount.js"
5
5
  require("../helpers/index.js");
6
6
  //#region src/onchain/validation/checks/checkBorrowLimit.ts
7
7
  /**
8
- * What the pool will hand over, against what is asked for.
8
+ * What the pool will hand over, against the amount requested.
9
9
  *
10
10
  * `available` and `limit` are the caller's reading of which limit is in the
11
11
  * way; this check only compares. `maxBorrowAmount` is the largest debt still
@@ -6,16 +6,13 @@ require("../helpers/index.js");
6
6
  //#region src/onchain/validation/checks/checkDebtLimits.ts
7
7
  /** A debt the facade would revert on. */
8
8
  function checkDebtLimits(args) {
9
- const { debt, minDebt, maxDebt, underlying, allowZero, ceiling } = args;
9
+ const { debt, minDebt, maxDebt, underlying, allowZero, maxBorrowAmount } = args;
10
10
  if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return [];
11
11
  return [require_model_errors_operation_errors.debtOutOfRange({
12
12
  requested: require_onchain_validation_helpers_amount.amountOf(underlying, debt),
13
13
  minDebt: require_onchain_validation_helpers_amount.amountOf(underlying, minDebt),
14
14
  maxDebt: require_onchain_validation_helpers_amount.amountOf(underlying, maxDebt),
15
- ceiling: ceiling && {
16
- amount: require_onchain_validation_helpers_amount.amountOf(underlying, ceiling.value),
17
- limit: ceiling.limit
18
- }
15
+ maxBorrowAmount
19
16
  })];
20
17
  }
21
18
  //#endregion
@@ -8,7 +8,7 @@ require("../helpers/index.js");
8
8
  * What the pool holds, against what is being taken out of it.
9
9
  *
10
10
  * The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
11
- * asked for still cannot serve it, so equality is already a refusal. That is
11
+ * requested still cannot serve it, so equality is already a refusal. That is
12
12
  * the rule the legacy withdrawal validator enforced and it is preserved to the
13
13
  * unit.
14
14
  */
@@ -0,0 +1,30 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_model_errors_operation_errors = require("../../../model/errors/operation-errors.js");
3
+ require("../../../model/index.js");
4
+ //#region src/onchain/validation/checks/checkReservePriceLimited.ts
5
+ /**
6
+ * Whether a failed collateral check is the reserve price feed's doing.
7
+ *
8
+ * A call that hands funds over is weighed at safe prices — `min` of a token's
9
+ * two feeds, and nothing at all where governance registered no reserve feed —
10
+ * so an account that covers its debt at the main feed can still be refused.
11
+ * The two are worth telling apart: a position that is genuinely too small is
12
+ * fixed by adding collateral or requesting less, while this one is a valuation
13
+ * the account does not control, and requesting less only helps as far as
14
+ * `withdrawable` says it does.
15
+ *
16
+ * Runs after `checkCollateralised` and answers only when that one refused, so
17
+ * the caller keeps its own threshold rather than restating it here.
18
+ */
19
+ function checkReservePriceLimited(args) {
20
+ const { healthFactor, atMainPrices, healthFactorThreshold, withdrawable } = args;
21
+ if (healthFactor >= healthFactorThreshold || atMainPrices < healthFactorThreshold) return [];
22
+ return [require_model_errors_operation_errors.reservePriceLimited({
23
+ healthFactor,
24
+ atMainPrices,
25
+ healthFactorThreshold,
26
+ withdrawable
27
+ })];
28
+ }
29
+ //#endregion
30
+ exports.checkReservePriceLimited = checkReservePriceLimited;
@@ -14,6 +14,7 @@ const require_onchain_validation_checks_checkPoolPaused = require("./checkPoolPa
14
14
  const require_onchain_validation_checks_checkPoolSunset = require("./checkPoolSunset.js");
15
15
  const require_onchain_validation_checks_checkQuotaCount = require("./checkQuotaCount.js");
16
16
  const require_onchain_validation_checks_checkQuotaLimit = require("./checkQuotaLimit.js");
17
+ const require_onchain_validation_checks_checkReservePriceLimited = require("./checkReservePriceLimited.js");
17
18
  exports.checkBorrowLimit = require_onchain_validation_checks_checkBorrowLimit.checkBorrowLimit;
18
19
  exports.checkCollateralised = require_onchain_validation_checks_checkCollateralised.checkCollateralised;
19
20
  exports.checkCreditAccountFrozen = require_onchain_validation_checks_checkCreditAccountFrozen.checkCreditAccountFrozen;
@@ -29,3 +30,4 @@ exports.checkPoolPaused = require_onchain_validation_checks_checkPoolPaused.chec
29
30
  exports.checkPoolSunset = require_onchain_validation_checks_checkPoolSunset.checkPoolSunset;
30
31
  exports.checkQuotaCount = require_onchain_validation_checks_checkQuotaCount.checkQuotaCount;
31
32
  exports.checkQuotaLimit = require_onchain_validation_checks_checkQuotaLimit.checkQuotaLimit;
33
+ exports.checkReservePriceLimited = require_onchain_validation_checks_checkReservePriceLimited.checkReservePriceLimited;
@@ -18,16 +18,18 @@ const require_onchain_validation_checks_checkPoolPaused = require("./checks/chec
18
18
  const require_onchain_validation_checks_checkPoolSunset = require("./checks/checkPoolSunset.js");
19
19
  const require_onchain_validation_checks_checkQuotaCount = require("./checks/checkQuotaCount.js");
20
20
  const require_onchain_validation_checks_checkQuotaLimit = require("./checks/checkQuotaLimit.js");
21
+ const require_onchain_validation_checks_checkReservePriceLimited = require("./checks/checkReservePriceLimited.js");
21
22
  require("./checks/index.js");
22
23
  const require_onchain_validation_bundles_checkAccountQuotas = require("./bundles/checkAccountQuotas.js");
23
24
  const require_onchain_validation_bundles_checkWalletAllowance = require("./bundles/checkWalletAllowance.js");
24
25
  const require_onchain_validation_bundles_checkWalletBalance = require("./bundles/checkWalletBalance.js");
25
26
  const require_onchain_validation_bundles_checkCollateralFunding = require("./bundles/checkCollateralFunding.js");
26
- const require_onchain_validation_bundles_checkDraw = require("./bundles/checkDraw.js");
27
27
  const require_onchain_validation_bundles_checkHealthFactors = require("./bundles/checkHealthFactors.js");
28
+ const require_onchain_validation_bundles_checkIncreaseDebt = require("./bundles/checkIncreaseDebt.js");
29
+ const require_onchain_validation_bundles_checkIncreaseQuota = require("./bundles/checkIncreaseQuota.js");
28
30
  const require_onchain_validation_bundles_checkMarket = require("./bundles/checkMarket.js");
29
31
  const require_onchain_validation_bundles_checkObtained = require("./bundles/checkObtained.js");
30
- const require_onchain_validation_bundles_checkQuotasAsked = require("./bundles/checkQuotasAsked.js");
32
+ const require_onchain_validation_bundles_checkMidasAccountGreenlist = require("./bundles/checkMidasAccountGreenlist.js");
31
33
  const require_onchain_validation_bundles_checkRWAOpenRequirements = require("./bundles/checkRWAOpenRequirements.js");
32
34
  const require_onchain_validation_bundles_checkRWAOpening = require("./bundles/checkRWAOpening.js");
33
35
  const require_onchain_validation_bundles_checkCreditOperation = require("./bundles/checkCreditOperation.js");
@@ -54,10 +56,11 @@ exports.checkCreditAccountFrozen = require_onchain_validation_checks_checkCredit
54
56
  exports.checkCreditManagerPaused = require_onchain_validation_checks_checkCreditManagerPaused.checkCreditManagerPaused;
55
57
  exports.checkCreditOperation = require_onchain_validation_bundles_checkCreditOperation.checkCreditOperation;
56
58
  exports.checkDebtLimits = require_onchain_validation_checks_checkDebtLimits.checkDebtLimits;
57
- exports.checkDraw = require_onchain_validation_bundles_checkDraw.checkDraw;
58
59
  exports.checkEmergencyLiquidator = require_onchain_validation_checks_checkEmergencyLiquidator.checkEmergencyLiquidator;
59
60
  exports.checkForbiddenToken = require_onchain_validation_checks_checkForbiddenToken.checkForbiddenToken;
60
61
  exports.checkHealthFactors = require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors;
62
+ exports.checkIncreaseDebt = require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt;
63
+ exports.checkIncreaseQuota = require_onchain_validation_bundles_checkIncreaseQuota.checkIncreaseQuota;
61
64
  exports.checkLeverage = require_onchain_validation_checks_checkLeverage.checkLeverage;
62
65
  exports.checkLiquidation = require_onchain_validation_checkLiquidation.checkLiquidation;
63
66
  exports.checkLiquidationEligibility = require_onchain_validation_bundles_checkLiquidationEligibility.checkLiquidationEligibility;
@@ -65,6 +68,7 @@ exports.checkLiquidationFunding = require_onchain_validation_bundles_checkLiquid
65
68
  exports.checkLiquidatorEligible = require_onchain_validation_checks_checkLiquidatorEligible.checkLiquidatorEligible;
66
69
  exports.checkMarket = require_onchain_validation_bundles_checkMarket.checkMarket;
67
70
  exports.checkMarketExpired = require_onchain_validation_checks_checkMarketExpired.checkMarketExpired;
71
+ exports.checkMidasAccountGreenlist = require_onchain_validation_bundles_checkMidasAccountGreenlist.checkMidasAccountGreenlist;
68
72
  exports.checkObtained = require_onchain_validation_bundles_checkObtained.checkObtained;
69
73
  exports.checkOperation = require_onchain_validation_checkOperation.checkOperation;
70
74
  exports.checkPoolFunding = require_onchain_validation_bundles_checkPoolFunding.checkPoolFunding;
@@ -74,9 +78,9 @@ exports.checkPoolPaused = require_onchain_validation_checks_checkPoolPaused.chec
74
78
  exports.checkPoolSunset = require_onchain_validation_checks_checkPoolSunset.checkPoolSunset;
75
79
  exports.checkQuotaCount = require_onchain_validation_checks_checkQuotaCount.checkQuotaCount;
76
80
  exports.checkQuotaLimit = require_onchain_validation_checks_checkQuotaLimit.checkQuotaLimit;
77
- exports.checkQuotasAsked = require_onchain_validation_bundles_checkQuotasAsked.checkQuotasAsked;
78
81
  exports.checkRWAOpenRequirements = require_onchain_validation_bundles_checkRWAOpenRequirements.checkRWAOpenRequirements;
79
82
  exports.checkRWAOpening = require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening;
83
+ exports.checkReservePriceLimited = require_onchain_validation_checks_checkReservePriceLimited.checkReservePriceLimited;
80
84
  exports.checkSimulation = require_onchain_validation_checkSimulation.checkSimulation;
81
85
  exports.checkWallet = require_onchain_validation_bundles_checkWallet.checkWallet;
82
86
  exports.checkWalletAllowance = require_onchain_validation_bundles_checkWalletAllowance.checkWalletAllowance;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_onchain_utils_createRawTx = require("../../../onchain/utils/createRawTx.js");
3
- const require_onchain_market_pricefeeds_getRawPriceUpdates = require("../../../onchain/market/pricefeeds/getRawPriceUpdates.js");
3
+ const require_onchain_market_pricefeeds_updates_getRawPriceUpdates = require("../../../onchain/market/pricefeeds/updates/getRawPriceUpdates.js");
4
4
  const require_onchain_OnchainSDK = require("../../../onchain/OnchainSDK.js");
5
5
  require("../../../onchain/index.js");
6
6
  require("../../deployment/addresses.js");
@@ -31,7 +31,7 @@ async function getPriceUpdateTx({ client, priceFeeds, useMulticall3 = false, gas
31
31
  args: [multicallCalls]
32
32
  });
33
33
  }
34
- const priceUpdates = require_onchain_market_pricefeeds_getRawPriceUpdates.getRawPriceUpdates(updateTxs);
34
+ const priceUpdates = require_onchain_market_pricefeeds_updates_getRawPriceUpdates.getRawPriceUpdates(updateTxs);
35
35
  if (priceUpdates.length === 0) return;
36
36
  return pfStore.updatePrices(priceUpdates);
37
37
  }
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_onchain_utils_bytes32ToString = require("../../../onchain/utils/bytes32ToString.js");
3
3
  const require_abi_compressors_priceFeedCompressor = require("../../../abi/compressors/priceFeedCompressor.js");
4
- const require_onchain_market_pricefeeds_RedstonePriceFeed = require("../../../onchain/market/pricefeeds/RedstonePriceFeed.js");
4
+ const require_onchain_market_pricefeeds_feeds_RedstonePriceFeed = require("../../../onchain/market/pricefeeds/feeds/RedstonePriceFeed.js");
5
5
  require("../../../onchain/index.js");
6
6
  let viem = require("viem");
7
7
  //#region src/permissionless/utils/price-update/get-updatable-feeds.ts
@@ -11,7 +11,7 @@ async function getUpdatablePriceFeeds(args) {
11
11
  address: pfCompressor,
12
12
  abi: require_abi_compressors_priceFeedCompressor.priceFeedCompressorAbi,
13
13
  client
14
- }).read.loadPriceFeedTree([priceFeeds])).filter((data) => require_onchain_utils_bytes32ToString.bytes32ToString(data.baseParams.contractType) === "PRICE_FEED::REDSTONE").map((data) => new require_onchain_market_pricefeeds_RedstonePriceFeed.RedstonePriceFeedContract(sdk, data));
14
+ }).read.loadPriceFeedTree([priceFeeds])).filter((data) => require_onchain_utils_bytes32ToString.bytes32ToString(data.baseParams.contractType) === "PRICE_FEED::REDSTONE").map((data) => new require_onchain_market_pricefeeds_feeds_RedstonePriceFeed.RedstonePriceFeedContract(sdk, data));
15
15
  }
16
16
  //#endregion
17
17
  exports.getUpdatablePriceFeeds = getUpdatablePriceFeeds;
@@ -17,6 +17,8 @@ var ExecuteApi = class {
17
17
  switch (request.kind) {
18
18
  case "pool": return poolTx(sdk, request);
19
19
  case "open": return openTx(sdk, request);
20
+ case "openEmpty": return openEmptyTx(sdk, request);
21
+ case "borrow": return borrowTx(sdk, request);
20
22
  case "account": return accountTx(sdk, request);
21
23
  }
22
24
  }
@@ -63,20 +65,78 @@ async function openTx(sdk, request) {
63
65
  reopenCreditAccount: state.creditAccount,
64
66
  permits: {},
65
67
  referralCode: 0n,
66
- rwaOptions: await openRwaOptions(sdk, request)
68
+ rwaOptions: await openRwaOptions(sdk, request, request.targetToken)
69
+ });
70
+ }
71
+ /**
72
+ * The opening with nothing in it: no debt to draw, no collateral to take, no
73
+ * path to run and no quota to buy, so `openCA` is left with the price updates
74
+ * the market demands and the facade's own `openCreditAccount`.
75
+ *
76
+ * Nothing is read off the preparation because there is nothing on it. The
77
+ * account holds no token, so an RWA market has none to gate on either.
78
+ **/
79
+ function openEmptyTx(sdk, request) {
80
+ return sdk.accounts.openCA({
81
+ creditManager: request.creditManager,
82
+ to: request.wallet,
83
+ collateral: [],
84
+ ethAmount: 0n,
85
+ debt: 0n,
86
+ calls: [],
87
+ averageQuota: [],
88
+ minQuota: [],
89
+ permits: {},
90
+ referralCode: 0n
91
+ });
92
+ }
93
+ /**
94
+ * A loan is an opening whose debt leaves again, so it is the same `openCA`
95
+ * with `withdrawToken` set: the facade draws the debt, takes the collateral,
96
+ * runs whatever path buys the payout, and sweeps that payout to the wallet.
97
+ *
98
+ * Both quota branches are the one the state carries. An opening has two
99
+ * because the balances it lands on are a router quote; here the account is
100
+ * left holding the collateral the caller named, and a named amount has no
101
+ * floor to differ from.
102
+ **/
103
+ async function borrowTx(sdk, request) {
104
+ const { creditManager, wallet, ethAmount, sim } = request;
105
+ const { state } = sim.data;
106
+ const collateral = {
107
+ token: state.collateral.token.address,
108
+ balance: state.collateral.value
109
+ };
110
+ return sdk.accounts.openCA({
111
+ creditManager,
112
+ to: wallet,
113
+ collateral: [collateral],
114
+ ethAmount,
115
+ debt: state.totalDebt.value,
116
+ calls: state.calls,
117
+ withdrawToken: state.borrowed.token.address,
118
+ averageQuota: state.quotaIncrease,
119
+ minQuota: state.quotaIncrease,
120
+ reopenCreditAccount: state.creditAccount,
121
+ permits: {},
122
+ referralCode: 0n,
123
+ rwaOptions: await openRwaOptions(sdk, request, collateral.token)
67
124
  });
68
125
  }
69
126
  /**
70
127
  * The documented `openCA` contract: ask the market for its open requirements
71
128
  * and hand them back as operation args, with the caller's cached signatures
72
- * attached. `undefined` on non-RWA markets and when no target token is named.
129
+ * attached. `undefined` on non-RWA markets and when no token is named.
130
+ *
131
+ * `token` is the one the account ends up holding, which is what an RWA market
132
+ * gates on: the opening's target, and the borrow's collateral.
73
133
  **/
74
- async function openRwaOptions(sdk, request) {
75
- if (!request.targetToken) return;
76
- const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress: request.targetToken });
77
- if (!requirements) return;
134
+ async function openRwaOptions(sdk, request, token) {
135
+ if (!token) return;
136
+ const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress: token });
137
+ if (requirements?.protocol !== "securitize") return;
78
138
  return {
79
- type: requirements.type,
139
+ protocol: "securitize",
80
140
  tokensToRegister: requirements.tokensToRegister,
81
141
  signaturesToCache: request.signaturesToCache ?? []
82
142
  };
@@ -71,15 +71,21 @@ var OpportunitiesNamespace = class extends require_sdk_AbstractNamespace.Abstrac
71
71
  /**
72
72
  * {@inheritDoc IOpportunitiesBase.getStrategy}
73
73
  **/
74
- async getStrategy(key, wallet) {
74
+ async getStrategy(key) {
75
75
  return this.merged("get strategy opportunity", {
76
76
  chainIds: [key.chainId],
77
- fromChain: (source) => source.getStrategy(key, wallet),
78
- fromBackend: (source) => source.getStrategy(key, wallet),
77
+ fromChain: (source) => source.getStrategy(key),
78
+ fromBackend: (source) => source.getStrategy(key),
79
79
  merge: this.merge.strategy
80
80
  });
81
81
  }
82
82
  /**
83
+ * {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
84
+ **/
85
+ async isEligibleForStrategy(key, wallet) {
86
+ return this.onchain.isEligibleForStrategy(key, wallet);
87
+ }
88
+ /**
83
89
  * {@inheritDoc IOpportunitiesBase.filter}
84
90
  **/
85
91
  filter(response, filter) {
@@ -196,26 +196,33 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
196
196
  }
197
197
  }
198
198
  /**
199
+ * {@inheritDoc IOpportunitiesPrepare.openEmptyCreditAccount}
200
+ **/
201
+ async openEmptyCreditAccount(strategy) {
202
+ try {
203
+ const sdk = await this.#chain(strategy.chainId);
204
+ const at = stateBlock(sdk);
205
+ const result = await service(sdk).openEmptyAccountIntent({
206
+ sdk,
207
+ creditManager: strategy.creditManager
208
+ });
209
+ return result.ok ? require_model_result.sdkOk(at) : methodError(result);
210
+ } catch (e) {
211
+ return require_model_result.sdkErr(require_model_errors_prepare_errors.unexpectedFailure(e));
212
+ }
213
+ }
214
+ /**
199
215
  * {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
200
216
  **/
201
217
  async openNewStrategy(strategy, params) {
202
218
  try {
203
219
  const sdk = await this.#chain(strategy.chainId);
204
220
  const at = stateBlock(sdk);
205
- if (params.empty) return opened(await service(sdk).openStrategyIntent({
206
- sdk,
207
- creditManager: strategy.creditManager,
208
- empty: true
209
- }), at);
210
221
  const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
211
222
  if (!targetToken) return require_model_result.sdkErr(require_model_errors_prepare_errors.noStrategyTargetCollateral(strategy.creditManager));
212
- let creditAccount;
213
- if (params.creditAccount) {
214
- const reused = await slice(sdk, params.creditAccount);
215
- if (!reused || !(0, viem.isAddressEqual)(reused.creditManager, strategy.creditManager)) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotFound(params.creditAccount));
216
- if (reused.totalDebt > 0n || reused.tokens.some((t) => t.quota > 0n)) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotEmpty(params.creditAccount));
217
- creditAccount = reused;
218
- }
223
+ const reused = await reusable(sdk, strategy, params.creditAccount);
224
+ if (reused && "error" in reused) return reused;
225
+ const creditAccount = reused?.account;
219
226
  return opened(await service(sdk).openStrategyIntent({
220
227
  sdk,
221
228
  creditManager: strategy.creditManager,
@@ -232,6 +239,30 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
232
239
  }
233
240
  }
234
241
  /**
242
+ * {@inheritDoc IOpportunitiesPrepare.borrow}
243
+ **/
244
+ async borrow(strategy, params) {
245
+ try {
246
+ const sdk = await this.#chain(strategy.chainId);
247
+ const at = stateBlock(sdk);
248
+ const reused = await reusable(sdk, strategy, params.creditAccount);
249
+ if (reused && "error" in reused) return reused;
250
+ return borrowed(await service(sdk).borrowIntent({
251
+ sdk,
252
+ creditManager: strategy.creditManager,
253
+ collateralToken: params.collateralToken,
254
+ collateralAmount: params.collateralAmount,
255
+ borrowToken: params.borrowToken,
256
+ borrowAmount: params.borrowAmount,
257
+ slippage: params.slippage,
258
+ quotaReserve: params.quotaReserve,
259
+ creditAccount: reused?.account
260
+ }), at);
261
+ } catch (e) {
262
+ return require_model_result.sdkErr(require_model_errors_prepare_errors.unexpectedFailure(e));
263
+ }
264
+ }
265
+ /**
235
266
  * {@inheritDoc IOpportunitiesPrepare.depositStrategy}
236
267
  **/
237
268
  async depositStrategy(position, params) {
@@ -259,12 +290,13 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
259
290
  /**
260
291
  * {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
261
292
  **/
262
- async maxWithdraw(position) {
293
+ async maxWithdraw(position, sourceToken) {
263
294
  const sdk = await this.#chain(position.chainId);
264
295
  const creditAccount = await this.#account(sdk, position);
265
296
  return service(sdk).maxWithdraw({
266
297
  creditAccount,
267
- sdk
298
+ sdk,
299
+ sourceToken
268
300
  });
269
301
  }
270
302
  /**
@@ -353,6 +385,21 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
353
385
  });
354
386
  }
355
387
  /**
388
+ * {@inheritDoc IOpportunitiesPrepare.maxBorrow}
389
+ **/
390
+ maxBorrow(strategy, params) {
391
+ const sdk = this.sdk.chain(strategy.chainId);
392
+ return service(sdk).maxBorrow({
393
+ sdk,
394
+ creditManager: strategy.creditManager,
395
+ collateralToken: params.collateralToken,
396
+ collateralAmount: params.collateralAmount,
397
+ borrowToken: params.borrowToken,
398
+ targetHF: params.targetHF,
399
+ quotaReserve: params.quotaReserve
400
+ });
401
+ }
402
+ /**
356
403
  * The account a bare `max*` read weighs. These reads answer a number, not
357
404
  * an envelope, so an account the markets do not hold is thrown rather than
358
405
  * described, see {@link IOpportunitiesPrepare.maxWithdraw}.
@@ -438,6 +485,25 @@ async function slice(sdk, creditAccount) {
438
485
  return data && require_onchain_accounts_intents_utils_credit_account_slice.toCreditAccountSlice(data);
439
486
  }
440
487
  /**
488
+ * The pre-opened account a request asks to be run on, held to what "pre-opened"
489
+ * means: this manager's, owing nothing and holding no quota.
490
+ *
491
+ * Shared by the two flows that put something on a fresh account — an opening
492
+ * and a borrow — so both hold a reused one to the same terms. Whatever
493
+ * balances sit on it are left to the flow: an opening routes them, a borrow
494
+ * leaves them where they are.
495
+ *
496
+ * @returns Nothing when the request named no account, the refusal to answer
497
+ * with when it named one that does not qualify, and the slice otherwise
498
+ **/
499
+ async function reusable(sdk, strategy, creditAccount) {
500
+ if (!creditAccount) return;
501
+ const account = await slice(sdk, creditAccount);
502
+ if (!account || !(0, viem.isAddressEqual)(account.creditManager, strategy.creditManager)) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotFound(creditAccount));
503
+ if (account.totalDebt > 0n || account.tokens.some((t) => t.quota > 0n)) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotEmpty(creditAccount));
504
+ return { account };
505
+ }
506
+ /**
441
507
  * The operation a claim resumes, or `undefined` when there is none to resume:
442
508
  * a withdrawal requested without an intent, or one read through a compressor
443
509
  * too old to report it. Every intent the engine records can be finished,
@@ -537,6 +603,15 @@ function opened(result, at) {
537
603
  }
538
604
  /**
539
605
  * {@inheritDoc planned}
606
+ **/
607
+ function borrowed(result, at) {
608
+ return result.ok ? require_model_result.sdkOk({
609
+ state: result.state,
610
+ ...at
611
+ }) : methodError(result);
612
+ }
613
+ /**
614
+ * {@inheritDoc planned}
540
615
  *
541
616
  * Both routes are payload, error and all: `errors` says why a missing one is
542
617
  * missing, and it stays on the error when neither route answered, since that is
@@ -78,11 +78,7 @@ const iFaucetAbi = [
78
78
  internalType: "uint256"
79
79
  }]
80
80
  }],
81
- outputs: [{
82
- name: "",
83
- type: "bool",
84
- internalType: "bool"
85
- }],
81
+ outputs: [],
86
82
  stateMutability: "nonpayable"
87
83
  },
88
84
  {
@@ -97,11 +93,7 @@ const iFaucetAbi = [
97
93
  type: "uint256",
98
94
  internalType: "uint256"
99
95
  }],
100
- outputs: [{
101
- name: "",
102
- type: "bool",
103
- internalType: "bool"
104
- }],
96
+ outputs: [],
105
97
  stateMutability: "nonpayable"
106
98
  },
107
99
  {
@@ -112,11 +104,7 @@ const iFaucetAbi = [
112
104
  type: "address",
113
105
  internalType: "address"
114
106
  }],
115
- outputs: [{
116
- name: "",
117
- type: "bool",
118
- internalType: "bool"
119
- }],
107
+ outputs: [],
120
108
  stateMutability: "nonpayable"
121
109
  },
122
110
  {
@@ -188,6 +176,17 @@ const iFaucetAbi = [
188
176
  }],
189
177
  stateMutability: "view"
190
178
  },
179
+ {
180
+ type: "function",
181
+ name: "owner",
182
+ inputs: [],
183
+ outputs: [{
184
+ name: "",
185
+ type: "address",
186
+ internalType: "address"
187
+ }],
188
+ stateMutability: "view"
189
+ },
191
190
  {
192
191
  type: "function",
193
192
  name: "prices",
@@ -4,7 +4,7 @@ import { iFaucetAbi } from "./abi.js";
4
4
  import { readContract } from "viem/actions";
5
5
  //#region src/dev/claimFromFaucet.ts
6
6
  async function claimFromFaucet(opts) {
7
- const { sdk, publicClient, wallet, faucet, claimer, role, amount, logger, gasMultiplier = 10n, sync = false } = opts;
7
+ const { sdk, publicClient, wallet, faucet, claimer, role, amount, logger, gasMultiplier = 10n } = opts;
8
8
  let amnt = "default amount";
9
9
  let args;
10
10
  if (Array.isArray(amount)) {
@@ -53,13 +53,9 @@ async function claimFromFaucet(opts) {
53
53
  gas: gas * gasMultiplier
54
54
  });
55
55
  logger?.debug({ request }, "simulated claim tx request");
56
- let receipt;
57
- if (sync) receipt = await wallet.writeContractSync(request);
58
- else {
59
- const hash = await wallet.writeContract(request);
60
- logger?.debug({ hash }, "claim tx hash");
61
- receipt = await publicClient.waitForTransactionReceipt({ hash });
62
- }
56
+ const hash = await wallet.writeContract(request);
57
+ logger?.debug({ hash }, "claim tx hash");
58
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
63
59
  if (receipt.status === "reverted") throw new Error(`${usr} failed to claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`);
64
60
  logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`);
65
61
  }