@gearbox-protocol/sdk 17.0.0-next.4 → 17.1.0-next.1

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 (376) 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/math.js +12 -3
  23. package/dist/cjs/onchain/accounts/intents/maxBorrow.js +89 -0
  24. package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
  25. package/dist/cjs/onchain/accounts/intents/open-strategy.js +8 -46
  26. package/dist/cjs/onchain/accounts/intents/operations.js +0 -1
  27. package/dist/cjs/onchain/accounts/intents/plan.js +1 -8
  28. package/dist/cjs/onchain/accounts/intents/realize.js +61 -4
  29. package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
  30. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  31. package/dist/cjs/onchain/accounts/intents/utils/common.js +19 -0
  32. package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +21 -0
  33. package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
  34. package/dist/cjs/onchain/accounts/intents/utils/price-impact.js +12 -9
  35. package/dist/cjs/onchain/accounts/intents/utils/router-path.js +4 -5
  36. package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
  37. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  38. package/dist/cjs/onchain/constants/address-provider.js +0 -2
  39. package/dist/cjs/onchain/constants/index.js +0 -1
  40. package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
  41. package/dist/cjs/onchain/index.js +60 -43
  42. package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -2
  43. package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  44. package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +49 -5
  45. package/dist/cjs/onchain/market/credit/CreditSuite.js +26 -9
  46. package/dist/cjs/onchain/market/index.js +50 -38
  47. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +3 -3
  48. package/dist/cjs/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
  49. package/dist/cjs/onchain/market/pricefeeds/PriceFeedRegistry.js +127 -0
  50. package/dist/cjs/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
  51. package/dist/cjs/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
  52. package/dist/cjs/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
  53. package/dist/cjs/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
  54. package/dist/cjs/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
  55. package/dist/cjs/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
  56. package/dist/cjs/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
  57. package/dist/cjs/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
  58. package/dist/cjs/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
  59. package/dist/cjs/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
  60. package/dist/cjs/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
  61. package/dist/cjs/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
  62. package/dist/cjs/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
  63. package/dist/cjs/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
  64. package/dist/cjs/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
  65. package/dist/cjs/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
  66. package/dist/cjs/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
  67. package/dist/cjs/onchain/market/pricefeeds/feeds/index.js +35 -0
  68. package/dist/cjs/onchain/market/pricefeeds/index.js +51 -39
  69. package/dist/cjs/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +189 -0
  70. package/dist/cjs/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
  71. package/dist/cjs/onchain/market/pricefeeds/updates/index.js +8 -0
  72. package/dist/cjs/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
  73. package/dist/cjs/onchain/market/pricefeeds/updates/updatableDependencies.js +14 -0
  74. package/dist/cjs/onchain/market/rwa/RWARegistry.js +4 -7
  75. package/dist/cjs/onchain/market/rwa/index.js +1 -0
  76. package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  77. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
  78. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  79. package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  80. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
  81. package/dist/cjs/onchain/pools/PoolService.js +7 -8
  82. package/dist/cjs/onchain/positions/calcHealthFactor.js +3 -3
  83. package/dist/cjs/onchain/preview/index.js +2 -0
  84. package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  85. package/dist/cjs/onchain/preview/preview/index.js +2 -0
  86. package/dist/cjs/onchain/preview/preview/midasGreenlistsAccount.js +17 -0
  87. package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +13 -16
  88. package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
  89. package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
  90. package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  91. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +11 -9
  92. package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
  93. package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  94. package/dist/cjs/onchain/validation/bundles/checkMidasAccountGreenlist.js +44 -0
  95. package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +2 -8
  96. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  97. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +18 -8
  98. package/dist/cjs/onchain/validation/bundles/index.js +6 -4
  99. package/dist/cjs/onchain/validation/checkOperation.js +0 -1
  100. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
  101. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +2 -9
  102. package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
  103. package/dist/cjs/onchain/validation/checks/index.js +2 -0
  104. package/dist/cjs/onchain/validation/index.js +8 -4
  105. package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +2 -2
  106. package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -2
  107. package/dist/cjs/sdk/execute/ExecuteApi.js +67 -7
  108. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  109. package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
  110. package/dist/esm/dev/abi.js +14 -15
  111. package/dist/esm/dev/claimFromFaucet.js +4 -8
  112. package/dist/esm/dev/createAnvilClient.js +36 -19
  113. package/dist/esm/dev/index.js +4 -4
  114. package/dist/esm/dev/kycUtils.js +66 -59
  115. package/dist/esm/dev/midasUtils.js +112 -18
  116. package/dist/esm/dev/securitizeUtils.js +84 -44
  117. package/dist/esm/dev/withdrawalUtils.js +3 -6
  118. package/dist/esm/model/errors/index.js +2 -2
  119. package/dist/esm/model/errors/operation-errors.js +18 -2
  120. package/dist/esm/model/index.js +4 -4
  121. package/dist/esm/model/rwa.js +4 -4
  122. package/dist/esm/model/rwa.schema.js +5 -5
  123. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  124. package/dist/esm/onchain/OnchainSDK.js +3 -3
  125. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -17
  126. package/dist/esm/onchain/accounts/intents/borrow.js +138 -0
  127. package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
  128. package/dist/esm/onchain/accounts/intents/guards.js +15 -3
  129. package/dist/esm/onchain/accounts/intents/index.js +107 -20
  130. package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
  131. package/dist/esm/onchain/accounts/intents/math.js +13 -5
  132. package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
  133. package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
  134. package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -46
  135. package/dist/esm/onchain/accounts/intents/operations.js +0 -1
  136. package/dist/esm/onchain/accounts/intents/plan.js +1 -8
  137. package/dist/esm/onchain/accounts/intents/realize.js +61 -4
  138. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  139. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  140. package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
  141. package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
  142. package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
  143. package/dist/esm/onchain/accounts/intents/utils/price-impact.js +12 -9
  144. package/dist/esm/onchain/accounts/intents/utils/router-path.js +4 -5
  145. package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
  146. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  147. package/dist/esm/onchain/constants/address-provider.js +1 -2
  148. package/dist/esm/onchain/constants/index.js +2 -2
  149. package/dist/esm/onchain/core/createAddressProvider.js +2 -5
  150. package/dist/esm/onchain/index.js +32 -24
  151. package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -2
  152. package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
  153. package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +50 -6
  154. package/dist/esm/onchain/market/credit/CreditSuite.js +26 -9
  155. package/dist/esm/onchain/market/index.js +26 -21
  156. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
  157. package/dist/esm/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
  158. package/dist/esm/onchain/market/pricefeeds/PriceFeedRegistry.js +126 -0
  159. package/dist/esm/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
  160. package/dist/esm/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
  161. package/dist/esm/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
  162. package/dist/esm/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
  163. package/dist/esm/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
  164. package/dist/esm/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
  165. package/dist/esm/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
  166. package/dist/esm/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
  167. package/dist/esm/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
  168. package/dist/esm/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
  169. package/dist/esm/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
  170. package/dist/esm/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
  171. package/dist/esm/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
  172. package/dist/esm/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
  173. package/dist/esm/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
  174. package/dist/esm/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
  175. package/dist/esm/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
  176. package/dist/esm/onchain/market/pricefeeds/feeds/index.js +18 -0
  177. package/dist/esm/onchain/market/pricefeeds/index.js +27 -21
  178. package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +188 -0
  179. package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
  180. package/dist/esm/onchain/market/pricefeeds/updates/index.js +5 -1
  181. package/dist/esm/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
  182. package/dist/esm/onchain/market/pricefeeds/updates/updatableDependencies.js +13 -0
  183. package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
  184. package/dist/esm/onchain/market/rwa/index.js +2 -2
  185. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
  186. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
  187. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
  188. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
  189. package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
  190. package/dist/esm/onchain/pools/PoolService.js +7 -8
  191. package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
  192. package/dist/esm/onchain/preview/index.js +2 -1
  193. package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
  194. package/dist/esm/onchain/preview/preview/index.js +2 -1
  195. package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
  196. package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
  197. package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
  198. package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
  199. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
  200. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +11 -9
  201. package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
  202. package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
  203. package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
  204. package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +2 -8
  205. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
  206. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +18 -8
  207. package/dist/esm/onchain/validation/bundles/index.js +4 -3
  208. package/dist/esm/onchain/validation/checkOperation.js +0 -1
  209. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
  210. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +2 -9
  211. package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
  212. package/dist/esm/onchain/validation/checks/index.js +2 -1
  213. package/dist/esm/onchain/validation/index.js +5 -3
  214. package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
  215. package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +1 -1
  216. package/dist/esm/sdk/execute/ExecuteApi.js +67 -7
  217. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
  218. package/dist/esm/sdk/prepare/PrepareApi.js +94 -19
  219. package/dist/types/dev/abi.d.ts +13 -15
  220. package/dist/types/dev/claimFromFaucet.d.ts +0 -1
  221. package/dist/types/dev/createAnvilClient.d.ts +10 -3
  222. package/dist/types/dev/index.d.ts +4 -4
  223. package/dist/types/dev/kycUtils.d.ts +15 -24
  224. package/dist/types/dev/midasUtils.d.ts +35 -4
  225. package/dist/types/dev/securitizeUtils.d.ts +3 -9
  226. package/dist/types/model/errors/index.d.ts +2 -2
  227. package/dist/types/model/errors/operation-errors.d.ts +62 -7
  228. package/dist/types/model/index.d.ts +5 -5
  229. package/dist/types/model/opportunities.d.ts +6 -7
  230. package/dist/types/model/previews.d.ts +25 -19
  231. package/dist/types/model/rwa.d.ts +47 -27
  232. package/dist/types/model/rwa.schema.d.ts +3 -3
  233. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
  234. package/dist/types/offchain/opportunities/types.d.ts +1 -4
  235. package/dist/types/onchain/OnchainSDK.d.ts +2 -2
  236. package/dist/types/onchain/accounts/index.d.ts +5 -4
  237. package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
  238. package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
  239. package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
  240. package/dist/types/onchain/accounts/intents/index.d.ts +103 -15
  241. package/dist/types/onchain/accounts/intents/math.d.ts +11 -3
  242. package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
  243. package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
  244. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
  245. package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
  246. package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
  247. package/dist/types/onchain/accounts/intents/types.d.ts +51 -6
  248. package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
  249. package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
  250. package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
  251. package/dist/types/onchain/accounts/intents/utils/price-impact.d.ts +4 -1
  252. package/dist/types/onchain/accounts/intents/utils/router-path.d.ts +2 -5
  253. package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
  254. package/dist/types/onchain/accounts/types.d.ts +4 -2
  255. package/dist/types/onchain/constants/address-provider.d.ts +1 -2
  256. package/dist/types/onchain/constants/index.d.ts +2 -2
  257. package/dist/types/onchain/index.d.ts +40 -31
  258. package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
  259. package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +20 -4
  260. package/dist/types/onchain/market/adapters/types.d.ts +8 -0
  261. package/dist/types/onchain/market/credit/CreditSuite.d.ts +13 -3
  262. package/dist/types/onchain/market/index.d.ts +29 -24
  263. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +2 -1
  264. package/dist/types/onchain/market/oracle/types.d.ts +2 -1
  265. package/dist/types/onchain/market/pool/types.d.ts +1 -1
  266. package/dist/types/onchain/market/pricefeeds/AbstractPriceFeed.d.ts +1 -2
  267. package/dist/types/onchain/market/pricefeeds/PriceFeedRegistry.d.ts +60 -0
  268. package/dist/types/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.d.ts +12 -0
  269. package/dist/types/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.d.ts → feeds/BalancerWeightedPriceFeed.d.ts} +7 -7
  270. package/dist/types/onchain/market/pricefeeds/feeds/BoundedPriceFeed.d.ts +15 -0
  271. package/dist/types/onchain/market/pricefeeds/{CompositePriceFeed.d.ts → feeds/CompositePriceFeed.d.ts} +6 -6
  272. package/dist/types/onchain/market/pricefeeds/{ConstantPriceFeed.d.ts → feeds/ConstantPriceFeed.d.ts} +6 -6
  273. package/dist/types/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.d.ts +12 -0
  274. package/dist/types/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.d.ts +12 -0
  275. package/dist/types/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.d.ts +12 -0
  276. package/dist/types/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.d.ts +12 -0
  277. package/dist/types/onchain/market/pricefeeds/feeds/ExternalPriceFeed.d.ts +11 -0
  278. package/dist/types/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.d.ts +12 -0
  279. package/dist/types/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.d.ts → feeds/PendleTWAPPTPriceFeed.d.ts} +3 -3
  280. package/dist/types/onchain/market/pricefeeds/{PythPriceFeed.d.ts → feeds/PythPriceFeed.d.ts} +3 -3
  281. package/dist/types/onchain/market/pricefeeds/{RedstonePriceFeed.d.ts → feeds/RedstonePriceFeed.d.ts} +9 -9
  282. package/dist/types/onchain/market/pricefeeds/feeds/WstETHPriceFeed.d.ts +12 -0
  283. package/dist/types/onchain/market/pricefeeds/feeds/YearnPriceFeed.d.ts +12 -0
  284. package/dist/types/onchain/market/pricefeeds/feeds/ZeroPriceFeed.d.ts +11 -0
  285. package/dist/types/onchain/market/pricefeeds/feeds/index.d.ts +18 -0
  286. package/dist/types/onchain/market/pricefeeds/index.d.ts +28 -22
  287. package/dist/types/onchain/market/pricefeeds/types.d.ts +1 -31
  288. package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
  289. package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +106 -0
  290. package/dist/types/onchain/market/pricefeeds/updates/getRawPriceUpdates.d.ts +6 -0
  291. package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +7 -3
  292. package/dist/types/onchain/market/pricefeeds/updates/isUpdatablePriceFeed.d.ts +6 -0
  293. package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +56 -2
  294. package/dist/types/onchain/market/pricefeeds/updates/updatableDependencies.d.ts +10 -0
  295. package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
  296. package/dist/types/onchain/market/rwa/index.d.ts +3 -3
  297. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
  298. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
  299. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
  300. package/dist/types/onchain/market/rwa/types.d.ts +39 -37
  301. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
  302. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
  303. package/dist/types/onchain/opportunities/types.d.ts +6 -1
  304. package/dist/types/onchain/pools/PoolService.d.ts +5 -0
  305. package/dist/types/onchain/pools/types.d.ts +9 -2
  306. package/dist/types/onchain/preview/index.d.ts +2 -1
  307. package/dist/types/onchain/preview/preview/index.d.ts +2 -1
  308. package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
  309. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
  310. package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
  311. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +5 -4
  312. package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
  313. package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
  314. package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
  315. package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +1 -7
  316. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
  317. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +9 -7
  318. package/dist/types/onchain/validation/bundles/index.d.ts +5 -4
  319. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
  320. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
  321. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -8
  322. package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
  323. package/dist/types/onchain/validation/checks/index.d.ts +2 -1
  324. package/dist/types/onchain/validation/index.d.ts +6 -4
  325. package/dist/types/onchain/validation/raise.d.ts +2 -2
  326. package/dist/types/sdk/execute/index.d.ts +2 -2
  327. package/dist/types/sdk/execute/types.d.ts +48 -6
  328. package/dist/types/sdk/index.d.ts +5 -4
  329. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
  330. package/dist/types/sdk/opportunities/types.d.ts +9 -3
  331. package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
  332. package/dist/types/sdk/prepare/index.d.ts +4 -3
  333. package/dist/types/sdk/prepare/types.d.ts +200 -66
  334. package/package.json +1 -1
  335. package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -70
  336. package/dist/cjs/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -301
  337. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
  338. package/dist/cjs/plugins/degen-distributors/index.js +0 -4
  339. package/dist/cjs/plugins/degen-distributors/package.json +0 -1
  340. package/dist/cjs/plugins/degen-distributors/types.js +0 -1
  341. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
  342. package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
  343. package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
  344. package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
  345. package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -69
  346. package/dist/esm/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -300
  347. package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
  348. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
  349. package/dist/esm/plugins/degen-distributors/index.js +0 -3
  350. package/dist/esm/plugins/degen-distributors/package.json +0 -1
  351. package/dist/esm/plugins/degen-distributors/types.js +0 -1
  352. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
  353. package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
  354. package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
  355. package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
  356. package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -38
  357. package/dist/types/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts +0 -12
  358. package/dist/types/onchain/market/pricefeeds/BoundedPriceFeed.d.ts +0 -15
  359. package/dist/types/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts +0 -12
  360. package/dist/types/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts +0 -12
  361. package/dist/types/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts +0 -12
  362. package/dist/types/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts +0 -12
  363. package/dist/types/onchain/market/pricefeeds/ExternalPriceFeed.d.ts +0 -11
  364. package/dist/types/onchain/market/pricefeeds/MellowLRTPriceFeed.d.ts +0 -12
  365. package/dist/types/onchain/market/pricefeeds/PriceFeedsRegister.d.ts +0 -180
  366. package/dist/types/onchain/market/pricefeeds/WstETHPriceFeed.d.ts +0 -12
  367. package/dist/types/onchain/market/pricefeeds/YearnPriceFeed.d.ts +0 -12
  368. package/dist/types/onchain/market/pricefeeds/ZeroPriceFeed.d.ts +0 -11
  369. package/dist/types/onchain/market/pricefeeds/getRawPriceUpdates.d.ts +0 -5
  370. package/dist/types/onchain/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -5
  371. package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
  372. package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
  373. package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
  374. package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
  375. package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
  376. package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
@@ -79,11 +79,7 @@ const iFaucetAbi = [
79
79
  internalType: "uint256"
80
80
  }]
81
81
  }],
82
- outputs: [{
83
- name: "",
84
- type: "bool",
85
- internalType: "bool"
86
- }],
82
+ outputs: [],
87
83
  stateMutability: "nonpayable"
88
84
  },
89
85
  {
@@ -98,11 +94,7 @@ const iFaucetAbi = [
98
94
  type: "uint256",
99
95
  internalType: "uint256"
100
96
  }],
101
- outputs: [{
102
- name: "",
103
- type: "bool",
104
- internalType: "bool"
105
- }],
97
+ outputs: [],
106
98
  stateMutability: "nonpayable"
107
99
  },
108
100
  {
@@ -113,11 +105,7 @@ const iFaucetAbi = [
113
105
  type: "address",
114
106
  internalType: "address"
115
107
  }],
116
- outputs: [{
117
- name: "",
118
- type: "bool",
119
- internalType: "bool"
120
- }],
108
+ outputs: [],
121
109
  stateMutability: "nonpayable"
122
110
  },
123
111
  {
@@ -189,6 +177,17 @@ const iFaucetAbi = [
189
177
  }],
190
178
  stateMutability: "view"
191
179
  },
180
+ {
181
+ type: "function",
182
+ name: "owner",
183
+ inputs: [],
184
+ outputs: [{
185
+ name: "",
186
+ type: "address",
187
+ internalType: "address"
188
+ }],
189
+ stateMutability: "view"
190
+ },
192
191
  {
193
192
  type: "function",
194
193
  name: "prices",
@@ -5,7 +5,7 @@ const require_dev_abi = require("./abi.js");
5
5
  let viem_actions = require("viem/actions");
6
6
  //#region src/dev/claimFromFaucet.ts
7
7
  async function claimFromFaucet(opts) {
8
- const { sdk, publicClient, wallet, faucet, claimer, role, amount, logger, gasMultiplier = 10n, sync = false } = opts;
8
+ const { sdk, publicClient, wallet, faucet, claimer, role, amount, logger, gasMultiplier = 10n } = opts;
9
9
  let amnt = "default amount";
10
10
  let args;
11
11
  if (Array.isArray(amount)) {
@@ -54,13 +54,9 @@ async function claimFromFaucet(opts) {
54
54
  gas: gas * gasMultiplier
55
55
  });
56
56
  logger?.debug({ request }, "simulated claim tx request");
57
- let receipt;
58
- if (sync) receipt = await wallet.writeContractSync(request);
59
- else {
60
- const hash = await wallet.writeContract(request);
61
- logger?.debug({ hash }, "claim tx hash");
62
- receipt = await publicClient.waitForTransactionReceipt({ hash });
63
- }
57
+ const hash = await wallet.writeContract(request);
58
+ logger?.debug({ hash }, "claim tx hash");
59
+ const receipt = await publicClient.waitForTransactionReceipt({ hash });
64
60
  if (receipt.status === "reverted") throw new Error(`${usr} failed to claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`);
65
61
  logger?.debug(`${usr} claimed ${amnt} from faucet, tx: ${receipt.transactionHash}`);
66
62
  }
@@ -1,5 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  let viem = require("viem");
3
+ let viem_utils = require("viem/utils");
4
+ let viem_actions = require("viem/actions");
3
5
  //#region src/dev/createAnvilClient.ts
4
6
  let dealModulePromise;
5
7
  async function loadDeal() {
@@ -8,23 +10,27 @@ async function loadDeal() {
8
10
  if (!mod) throw new Error("createAnvilClient: deal action requires the 'viem-deal' package; install it as a dependency");
9
11
  return mod.deal;
10
12
  }
13
+ function anvilActions(client) {
14
+ return {
15
+ anvilNodeInfo: () => anvilNodeInfo(client),
16
+ isAnvil: () => isAnvil(client),
17
+ evmMineDetailed: (timestamp) => evmMineDetailed(client, timestamp),
18
+ deal: async (params) => {
19
+ await (await loadDeal())(client, params);
20
+ },
21
+ writeContractSync: (parameters) => writeContractSync(client, parameters)
22
+ };
23
+ }
11
24
  /**
12
25
  * Extends an arbitrary viem `PublicClient` with anvil + wallet actions plus
13
26
  * the SDK's bonus actions (`anvilNodeInfo`, `isAnvil`, `evmMineDetailed`,
14
- * `deal`).
27
+ * `deal`, `writeContractSync`).
15
28
  *
16
29
  * Used to lift `sdk.client` into an `AnvilClient` shape on the fly when test
17
30
  * RPCs (impersonateAccount, setBalance, setStorageAt, ...) are needed.
18
31
  */
19
32
  function extendAnvilClient(client) {
20
- return client.extend(() => ({ mode: "anvil" })).extend((0, viem.testActions)({ mode: "anvil" })).extend(viem.walletActions).extend((c) => ({
21
- anvilNodeInfo: () => anvilNodeInfo(c),
22
- isAnvil: () => isAnvil(c),
23
- evmMineDetailed: (timestamp) => evmMineDetailed(c, timestamp),
24
- deal: async (params) => {
25
- await (await loadDeal())(c, params);
26
- }
27
- }));
33
+ return client.extend(() => ({ mode: "anvil" })).extend((0, viem.testActions)({ mode: "anvil" })).extend(viem.walletActions).extend((c) => anvilActions(c));
28
34
  }
29
35
  function createAnvilClient({ chain, transport, cacheTime = 0, pollingInterval = 50 }) {
30
36
  return (0, viem.createTestClient)({
@@ -33,14 +39,7 @@ function createAnvilClient({ chain, transport, cacheTime = 0, pollingInterval =
33
39
  transport,
34
40
  cacheTime,
35
41
  pollingInterval
36
- }).extend(viem.publicActions).extend(viem.walletActions).extend((c) => ({
37
- anvilNodeInfo: () => anvilNodeInfo(c),
38
- isAnvil: () => isAnvil(c),
39
- evmMineDetailed: (timestamp) => evmMineDetailed(c, timestamp),
40
- deal: async (params) => {
41
- await (await loadDeal())(c, params);
42
- }
43
- }));
42
+ }).extend(viem.publicActions).extend(viem.walletActions).extend((c) => anvilActions(c));
44
43
  }
45
44
  /**
46
45
  * View action to detect if client is an anvil client
@@ -85,9 +84,28 @@ async function evmMineDetailed(client, timestamp) {
85
84
  return;
86
85
  }
87
86
  }
87
+ /**
88
+ * Anvil-compatible `writeContractSync`: send via `writeContract` (Anvil
89
+ * supports `eth_sendTransaction` / `eth_sendRawTransaction`) then wait for
90
+ * the receipt. Viem's own action uses `eth_sendRawTransactionSync`, which
91
+ * Anvil does not implement.
92
+ */
93
+ async function writeContractSync(client, parameters) {
94
+ const { throwOnReceiptRevert, pollingInterval, timeout, ...writeParams } = parameters;
95
+ const hash = await (0, viem_utils.getAction)(client, viem_actions.writeContract, "writeContract")(writeParams);
96
+ const receipt = await (0, viem_utils.getAction)(client, viem_actions.waitForTransactionReceipt, "waitForTransactionReceipt")({
97
+ checkReplacement: false,
98
+ hash,
99
+ pollingInterval,
100
+ timeout
101
+ });
102
+ if (throwOnReceiptRevert && receipt.status === "reverted") throw new viem.BaseError(`Transaction with hash "${receipt.transactionHash}" reverted.`, { name: "TransactionReceiptRevertedError" });
103
+ return receipt;
104
+ }
88
105
  //#endregion
89
106
  exports.anvilNodeInfo = anvilNodeInfo;
90
107
  exports.createAnvilClient = createAnvilClient;
91
108
  exports.evmMineDetailed = evmMineDetailed;
92
109
  exports.extendAnvilClient = extendAnvilClient;
93
110
  exports.isAnvil = isAnvil;
111
+ exports.writeContractSync = writeContractSync;
@@ -14,10 +14,10 @@ const require_dev_detectChain = require("./detectChain.js");
14
14
  const require_dev_isOutOfSyncError = require("./isOutOfSyncError.js");
15
15
  const require_dev_isRateLimitError = require("./isRateLimitError.js");
16
16
  const require_dev_isTransientError = require("./isTransientError.js");
17
+ const require_dev_midasUtils = require("./midasUtils.js");
17
18
  const require_dev_kycUtils = require("./kycUtils.js");
18
19
  const require_dev_logSplitterTransport = require("./logSplitterTransport.js");
19
20
  const require_dev_ltUtils = require("./ltUtils.js");
20
- const require_dev_midasUtils = require("./midasUtils.js");
21
21
  const require_dev_migrateFaucet = require("./migrateFaucet.js");
22
22
  const require_dev_providers = require("./providers.js");
23
23
  const require_dev_replaceStorage = require("./replaceStorage.js");
@@ -29,6 +29,7 @@ const require_dev_withdrawalUtils = require("./withdrawalUtils.js");
29
29
  exports.AccountOpener = require_dev_AccountOpener.AccountOpener;
30
30
  exports.Create2Deployer = require_dev_create2.Create2Deployer;
31
31
  exports.DEFAULT_CREATE2_SALT = require_dev_create2.DEFAULT_CREATE2_SALT;
32
+ exports.DEFAULT_MIDAS_ADMIN = require_dev_kycUtils.DEFAULT_MIDAS_ADMIN;
32
33
  exports.EthCallSpy = require_dev_EthCallSpy.EthCallSpy;
33
34
  exports.NoAvailableTransportsError = require_dev_RevolverTransport.NoAvailableTransportsError;
34
35
  exports.ONCHAIN_EXECUTION_ID_ADDRESS = require_dev_verifyTestnet.ONCHAIN_EXECUTION_ID_ADDRESS;
@@ -46,6 +47,9 @@ exports.createAnvilClient = require_dev_createAnvilClient.createAnvilClient;
46
47
  exports.createMinter = require_dev_mint_factory.createMinter;
47
48
  exports.deployUsingPublicCreate2 = require_dev_create2.deployUsingPublicCreate2;
48
49
  exports.detectChain = require_dev_detectChain.detectChain;
50
+ exports.discoverMidasCreditSuites = require_dev_midasUtils.discoverMidasCreditSuites;
51
+ exports.discoverMidasGateways = require_dev_midasUtils.discoverMidasGateways;
52
+ exports.discoverMidasMTokens = require_dev_midasUtils.discoverMidasMTokens;
49
53
  exports.enableDSTokenBackDating = require_dev_securitizeUtils.enableDSTokenBackDating;
50
54
  exports.evmMineDetailed = require_dev_createAnvilClient.evmMineDetailed;
51
55
  exports.extendAnvilClient = require_dev_createAnvilClient.extendAnvilClient;
@@ -55,6 +59,7 @@ exports.getDrpcUrl = require_dev_providers.getDrpcUrl;
55
59
  exports.getErpcKey = require_dev_providers.getErpcKey;
56
60
  exports.getPublicCreate2Address = require_dev_create2.getPublicCreate2Address;
57
61
  exports.getRpcProviderUrl = require_dev_providers.getRpcProviderUrl;
62
+ exports.getSecuritizeAdmin = require_dev_kycUtils.getSecuritizeAdmin;
58
63
  exports.getThirdWebUrl = require_dev_providers.getThirdWebUrl;
59
64
  exports.greenlistMidasGateway = require_dev_kycUtils.greenlistMidasGateway;
60
65
  exports.httpTransportOptionsSchema = require_dev_transports.httpTransportOptionsSchema;
@@ -86,4 +91,4 @@ exports.setLTZero = require_dev_ltUtils.setLTZero;
86
91
  exports.setLTs = require_dev_ltUtils.setLTs;
87
92
  exports.unpauseMidasIssuanceVault = require_dev_midasUtils.unpauseMidasIssuanceVault;
88
93
  exports.verifyTestnet = require_dev_verifyTestnet.verifyTestnet;
89
- exports.writeAndWait = require_dev_kycUtils.writeAndWait;
94
+ exports.writeContractSync = require_dev_createAnvilClient.writeContractSync;
@@ -5,33 +5,52 @@ const require_onchain_OnchainSDK = require("../onchain/OnchainSDK.js");
5
5
  require("../onchain/index.js");
6
6
  const require_abi_rwa_iDSRegistryService = require("../abi/rwa/iDSRegistryService.js");
7
7
  const require_abi_rwa_iDSToken = require("../abi/rwa/iDSToken.js");
8
+ const require_dev_midasUtils = require("./midasUtils.js");
8
9
  const require_dev_withdrawalAbi = require("./withdrawalAbi.js");
9
10
  let viem = require("viem");
10
- let viem_accounts = require("viem/accounts");
11
11
  //#region src/dev/kycUtils.ts
12
+ const iMockDSTokenAdminAbi = (0, viem.parseAbi)(["function admin() view returns (address)"]);
12
13
  /**
13
- * Writes to a contract, mines a block and waits for the receipt
14
+ * DS trust-service master of `token`: Ownable owner at storage slot 0 of the
15
+ * trust service, same as periphery-v3 SecuritizeAttachHelper. MockDSToken
16
+ * returns itself as the trust service, so `admin()` is used instead.
14
17
  */
15
- async function writeAndWait(anvil, params) {
16
- const hash = await anvil.writeContract(params);
17
- await anvil.mine({ blocks: 1 });
18
- await anvil.waitForTransactionReceipt({
19
- hash,
20
- pollingInterval: 100
18
+ async function getSecuritizeAdmin(anvil, token, logger) {
19
+ const trustServiceId = await anvil.readContract({
20
+ address: token,
21
+ abi: require_abi_rwa_iDSToken.iDSTokenAbi,
22
+ functionName: "TRUST_SERVICE"
21
23
  });
22
- return hash;
24
+ const trustService = await anvil.readContract({
25
+ address: token,
26
+ abi: require_abi_rwa_iDSToken.iDSTokenAbi,
27
+ functionName: "getDSService",
28
+ args: [trustServiceId]
29
+ });
30
+ if ((0, viem.isAddressEqual)(trustService, token)) {
31
+ const admin = await anvil.readContract({
32
+ address: token,
33
+ abi: iMockDSTokenAdminAbi,
34
+ functionName: "admin"
35
+ });
36
+ logger?.debug(`securitize: found admin ${admin} for ${token} (token.admin)`);
37
+ return admin;
38
+ }
39
+ const word = await anvil.getStorageAt({
40
+ address: trustService,
41
+ slot: (0, viem.toHex)(0, { size: 32 })
42
+ });
43
+ if (!word) throw new Error(`securitize: empty trust-service owner slot on ${trustService}`);
44
+ const admin = (0, viem.getAddress)((0, viem.slice)(word, 12));
45
+ logger?.debug(`securitize: found admin ${admin} for ${token} (trust service ${trustService})`);
46
+ return admin;
23
47
  }
24
48
  /**
25
- * Resolves the account that performs the DS registry writes: either the admin
26
- * private key, or the admin address impersonated on the fork
49
+ * Impersonates the DS trust-service admin of `token` on the fork
27
50
  */
28
51
  async function useSecuritizeAdmin(props) {
29
- const { anvil, adminPrivateKey, admin, logger } = props;
30
- if (adminPrivateKey) return {
31
- account: (0, viem_accounts.privateKeyToAccount)(adminPrivateKey),
32
- release: async () => {}
33
- };
34
- if (!admin) throw new Error("securitize: either adminPrivateKey or admin address is required");
52
+ const { anvil, token, logger } = props;
53
+ const admin = await getSecuritizeAdmin(anvil, token, logger);
35
54
  await anvil.impersonateAccount({ address: admin });
36
55
  await anvil.setBalance({
37
56
  address: admin,
@@ -99,36 +118,39 @@ async function registerSecuritizeInvestor(props) {
99
118
  const { account, release } = await useSecuritizeAdmin(props);
100
119
  try {
101
120
  if (!investorExists) {
102
- await writeAndWait(anvil, {
121
+ await anvil.writeContractSync({
103
122
  account,
104
123
  chain: anvil.chain,
105
124
  address: registryService,
106
125
  abi: require_abi_rwa_iDSRegistryService.iDSRegistryServiceAbi,
107
126
  functionName: "registerInvestor",
108
- args: [investorId, investorId]
127
+ args: [investorId, investorId],
128
+ throwOnReceiptRevert: true
109
129
  });
110
130
  logger?.debug(`Registered investor "${investorId}"`);
111
131
  }
112
- await writeAndWait(anvil, {
132
+ await anvil.writeContractSync({
113
133
  account,
114
134
  chain: anvil.chain,
115
135
  address: registryService,
116
136
  abi: require_abi_rwa_iDSRegistryService.iDSRegistryServiceAbi,
117
137
  functionName: "addWallet",
118
- args: [investor, investorId]
138
+ args: [investor, investorId],
139
+ throwOnReceiptRevert: true
119
140
  });
120
141
  logger?.debug(`Added wallet ${investor} for investor "${investorId}"`);
121
142
  try {
122
- await writeAndWait(anvil, {
143
+ await anvil.writeContractSync({
123
144
  account,
124
145
  chain: anvil.chain,
125
146
  address: registryService,
126
147
  abi: require_abi_rwa_iDSRegistryService.iDSRegistryServiceAbi,
127
148
  functionName: "setCountry",
128
- args: [investorId, "US"]
149
+ args: [investorId, "US"],
150
+ throwOnReceiptRevert: true
129
151
  });
130
152
  logger?.debug(`Set country for investor "${investorId}" to "US"`);
131
- await writeAndWait(anvil, {
153
+ await anvil.writeContractSync({
132
154
  account,
133
155
  chain: anvil.chain,
134
156
  address: registryService,
@@ -140,7 +162,8 @@ async function registerSecuritizeInvestor(props) {
140
162
  BigInt(APPROVED),
141
163
  require_onchain_constants_math.MAX_UINT256,
142
164
  "fake proof"
143
- ]
165
+ ],
166
+ throwOnReceiptRevert: true
144
167
  });
145
168
  logger?.debug(`Set attributes for investor "${investorId}"`);
146
169
  } catch (e) {
@@ -242,13 +265,14 @@ async function greenlistMidasGateway(props) {
242
265
  logger?.debug(`midas: ${account} already has role ${role}`);
243
266
  continue;
244
267
  }
245
- await writeAndWait(anvil, {
268
+ await anvil.writeContractSync({
246
269
  account: admin,
247
270
  chain: anvil.chain,
248
271
  address: accessControl,
249
272
  abi: iMidasAccessControlAbi,
250
273
  functionName: "grantRole",
251
- args: [role, account]
274
+ args: [role, account],
275
+ throwOnReceiptRevert: true
252
276
  });
253
277
  logger?.debug(`midas: granted role ${role} to ${account}`);
254
278
  }
@@ -266,9 +290,7 @@ async function greenlistMidasGateway(props) {
266
290
  }
267
291
  }
268
292
  /**
269
- * Finds the Midas gateway that issues `token` by scanning the Midas gateway
270
- * adapters of all loaded credit managers, same as the foundry tests do with
271
- * `ICreditConfiguratorV3.allowedAdapters`
293
+ * Finds the Midas gateway that issues `token` among the loaded credit managers.
272
294
  */
273
295
  async function findMidasGateway(props) {
274
296
  const { anvil, token, marketConfigurators, logger } = props;
@@ -280,30 +302,18 @@ async function findMidasGateway(props) {
280
302
  });
281
303
  await sdk.attach({ marketConfigurators });
282
304
  }
283
- const candidates = collectMidasGateways(sdk);
284
- if (candidates.length === 0) throw new Error("no midas gateway adapters found in loaded markets");
285
- const index = (await anvil.multicall({
286
- allowFailure: false,
287
- contracts: candidates.map((address) => ({
288
- address,
289
- abi: require_dev_withdrawalAbi.midasGatewayAbi,
290
- functionName: "mToken"
291
- }))
292
- })).findIndex((mToken) => (0, viem.isAddressEqual)(mToken, token));
293
- if (index === -1) throw new Error(`no midas gateway found for token ${token}`);
294
- logger?.debug(`midas: gateway for ${token} is ${candidates[index]}`);
295
- return candidates[index];
305
+ const suites = await require_dev_midasUtils.discoverMidasCreditSuites(sdk);
306
+ if (suites.length === 0) throw new Error("no midas gateway adapters or midas degen NFTs found in loaded markets");
307
+ const suite = suites.find(({ mToken }) => (0, viem.isAddressEqual)(mToken, token));
308
+ if (!suite) throw new Error(`no midas gateway found for token ${token}`);
309
+ logger?.debug(`midas: gateway for ${token} is ${suite.gateway}`);
310
+ return suite.gateway;
296
311
  }
297
312
  /**
298
- * Collects the target contracts of all Midas gateway adapters of the loaded
299
- * credit managers, same as the foundry tests do with
300
- * `ICreditConfiguratorV3.allowedAdapters`
313
+ * Midas access control admin on mainnet. Holds the admin role of the greenlist
314
+ * operator role.
301
315
  */
302
- function collectMidasGateways(sdk) {
303
- const gateways = new require_onchain_utils_AddressSet.AddressSet();
304
- for (const cm of sdk.marketRegister.creditManagers) for (const adapter of cm.creditManager.adapters.values()) if (adapter.contractType === "ADAPTER::MIDAS_GATEWAY") gateways.add(adapter.targetContract);
305
- return gateways.asArray();
306
- }
316
+ const DEFAULT_MIDAS_ADMIN = "0xd4195CF4df289a4748C1A7B6dDBE770e27bA1227";
307
317
  /**
308
318
  * Registers a wallet as an investor (fake KYC) in every Securitize DSToken and
309
319
  * every Midas gateway of the markets loaded by `sdk`.
@@ -312,17 +322,15 @@ function collectMidasGateways(sdk) {
312
322
  * result instead of aborting the whole run.
313
323
  */
314
324
  async function registerRWAInvestor(props) {
315
- const { anvil, sdk, investor, adminPrivateKey, securitizeAdmin, midasAdmin = "0xd4195CF4df289a4748C1A7B6dDBE770e27bA1227", logger } = props;
325
+ const { anvil, sdk, investor, midasAdmin = DEFAULT_MIDAS_ADMIN, logger } = props;
316
326
  const securitizeTokens = [];
317
327
  const midasGateways = [];
318
328
  const failed = [];
319
329
  const dsTokens = new require_onchain_utils_AddressSet.AddressSet(sdk.rwa.factories.flatMap((factory) => factory.getTokens()));
320
- if (adminPrivateKey || securitizeAdmin) for (const token of dsTokens) try {
330
+ for (const token of dsTokens) try {
321
331
  await registerSecuritizeInvestor({
322
332
  anvil,
323
333
  investor,
324
- adminPrivateKey,
325
- admin: securitizeAdmin,
326
334
  token,
327
335
  logger
328
336
  });
@@ -335,8 +343,7 @@ async function registerRWAInvestor(props) {
335
343
  error: e
336
344
  });
337
345
  }
338
- else if (dsTokens.size > 0) logger?.warn(`securitize: no registry admin, skipping ${dsTokens.size} DSToken(s)`);
339
- const gateways = collectMidasGateways(sdk);
346
+ const gateways = await require_dev_midasUtils.discoverMidasGateways(sdk);
340
347
  for (const gateway of gateways) try {
341
348
  await greenlistMidasGateway({
342
349
  anvil,
@@ -362,8 +369,9 @@ async function registerRWAInvestor(props) {
362
369
  };
363
370
  }
364
371
  //#endregion
372
+ exports.DEFAULT_MIDAS_ADMIN = DEFAULT_MIDAS_ADMIN;
373
+ exports.getSecuritizeAdmin = getSecuritizeAdmin;
365
374
  exports.greenlistMidasGateway = greenlistMidasGateway;
366
375
  exports.registerMidasInvestor = registerMidasInvestor;
367
376
  exports.registerRWAInvestor = registerRWAInvestor;
368
377
  exports.registerSecuritizeInvestor = registerSecuritizeInvestor;
369
- exports.writeAndWait = writeAndWait;
@@ -1,5 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_dev_kycUtils = require("./kycUtils.js");
2
+ const require_onchain_utils_AddressSet = require("../onchain/utils/AddressSet.js");
3
+ const require_onchain_market_adapters_contracts_MidasGatewayAdapterContract = require("../onchain/market/adapters/contracts/MidasGatewayAdapterContract.js");
4
+ const require_onchain_market_rwa_midas_MidasDegenNFT = require("../onchain/market/rwa/midas/MidasDegenNFT.js");
5
+ require("../onchain/index.js");
3
6
  let viem = require("viem");
4
7
  //#region src/dev/midasUtils.ts
5
8
  /**
@@ -10,14 +13,24 @@ const iMidasPausableVaultAbi = (0, viem.parseAbi)([
10
13
  "function paused() external view returns (bool)",
11
14
  "function pause() external",
12
15
  "function unpause() external",
16
+ "function fnPaused(bytes4 fn) external view returns (bool)",
17
+ "function pauseFn(bytes4 fn) external",
18
+ "function unpauseFn(bytes4 fn) external",
13
19
  "function pauseAdminRole() external view returns (bytes32)",
14
20
  "function accessControl() external view returns (address)"
15
21
  ]);
16
22
  const iMidasAccessControlAbi = (0, viem.parseAbi)(["function hasRole(bytes32 role, address account) external view returns (bool)", "function grantRole(bytes32 role, address account) external"]);
17
23
  /**
18
- * Unpauses a globally paused Midas issuance vault on an anvil fork, so that
19
- * `depositInstant` stops reverting with `Pausable: paused`, and returns a
20
- * callback that restores the original pause state.
24
+ * Selector for `DepositVault.depositInstant(address,uint256,uint256,bytes32)`,
25
+ * the 4-arg mint Gearbox adapters encode. Distinct from the custom-recipient
26
+ * overload.
27
+ */
28
+ const DEPOSIT_INSTANT_SELECTOR = (0, viem.toFunctionSelector)("depositInstant(address,uint256,uint256,bytes32)");
29
+ /**
30
+ * Unpauses a Midas issuance vault on an anvil fork so that `depositInstant`
31
+ * stops reverting with `Pausable: paused` (global) or `Pausable: fn paused`
32
+ * (per-selector), and returns a callback that restores the original pause
33
+ * state of each layer that was cleared.
21
34
  *
22
35
  * Impersonates `admin` and grants it `pauseAdminRole()` when missing, same as
23
36
  * `greenlistMidasGateway` does with the greenlist roles. The grant is not
@@ -25,11 +38,20 @@ const iMidasAccessControlAbi = (0, viem.parseAbi)(["function hasRole(bytes32 rol
25
38
  */
26
39
  async function unpauseMidasIssuanceVault(props) {
27
40
  const { anvil, vault, admin, logger } = props;
28
- if (!await anvil.readContract({
29
- address: vault,
30
- abi: iMidasPausableVaultAbi,
31
- functionName: "paused"
32
- })) {
41
+ const [paused, depositInstantPaused] = await anvil.multicall({
42
+ allowFailure: false,
43
+ contracts: [{
44
+ address: vault,
45
+ abi: iMidasPausableVaultAbi,
46
+ functionName: "paused"
47
+ }, {
48
+ address: vault,
49
+ abi: iMidasPausableVaultAbi,
50
+ functionName: "fnPaused",
51
+ args: [DEPOSIT_INSTANT_SELECTOR]
52
+ }]
53
+ });
54
+ if (!paused && !depositInstantPaused) {
33
55
  logger?.debug(`midas: issuance vault ${vault} is not paused`);
34
56
  return async () => {};
35
57
  }
@@ -51,7 +73,7 @@ async function unpauseMidasIssuanceVault(props) {
51
73
  functionName: "hasRole",
52
74
  args: [pauseAdminRole, admin]
53
75
  });
54
- logger?.debug(`midas: unpausing issuance vault ${vault} as ${admin}, access control ${accessControl}, pause admin role ${pauseAdminRole}`);
76
+ logger?.debug(`midas: unpausing issuance vault ${vault} as ${admin}, access control ${accessControl}, pause admin role ${pauseAdminRole}` + (paused ? ", global" : "") + (depositInstantPaused ? ", depositInstant" : ""));
55
77
  await anvil.impersonateAccount({ address: admin });
56
78
  try {
57
79
  await anvil.setBalance({
@@ -59,22 +81,33 @@ async function unpauseMidasIssuanceVault(props) {
59
81
  value: (0, viem.parseEther)("100")
60
82
  });
61
83
  if (!isPauseAdmin) {
62
- await require_dev_kycUtils.writeAndWait(anvil, {
84
+ await anvil.writeContractSync({
63
85
  account: admin,
64
86
  chain: anvil.chain,
65
87
  address: accessControl,
66
88
  abi: iMidasAccessControlAbi,
67
89
  functionName: "grantRole",
68
- args: [pauseAdminRole, admin]
90
+ args: [pauseAdminRole, admin],
91
+ throwOnReceiptRevert: true
69
92
  });
70
93
  logger?.debug(`midas: granted pause admin role to ${admin}`);
71
94
  }
72
- await require_dev_kycUtils.writeAndWait(anvil, {
95
+ if (paused) await anvil.writeContractSync({
73
96
  account: admin,
74
97
  chain: anvil.chain,
75
98
  address: vault,
76
99
  abi: iMidasPausableVaultAbi,
77
- functionName: "unpause"
100
+ functionName: "unpause",
101
+ throwOnReceiptRevert: true
102
+ });
103
+ if (depositInstantPaused) await anvil.writeContractSync({
104
+ account: admin,
105
+ chain: anvil.chain,
106
+ address: vault,
107
+ abi: iMidasPausableVaultAbi,
108
+ functionName: "unpauseFn",
109
+ args: [DEPOSIT_INSTANT_SELECTOR],
110
+ throwOnReceiptRevert: true
78
111
  });
79
112
  } finally {
80
113
  await anvil.stopImpersonatingAccount({ address: admin });
@@ -90,12 +123,22 @@ async function unpauseMidasIssuanceVault(props) {
90
123
  address: admin,
91
124
  value: (0, viem.parseEther)("100")
92
125
  });
93
- await require_dev_kycUtils.writeAndWait(anvil, {
126
+ if (paused) await anvil.writeContractSync({
94
127
  account: admin,
95
128
  chain: anvil.chain,
96
129
  address: vault,
97
130
  abi: iMidasPausableVaultAbi,
98
- functionName: "pause"
131
+ functionName: "pause",
132
+ throwOnReceiptRevert: true
133
+ });
134
+ if (depositInstantPaused) await anvil.writeContractSync({
135
+ account: admin,
136
+ chain: anvil.chain,
137
+ address: vault,
138
+ abi: iMidasPausableVaultAbi,
139
+ functionName: "pauseFn",
140
+ args: [DEPOSIT_INSTANT_SELECTOR],
141
+ throwOnReceiptRevert: true
99
142
  });
100
143
  } catch (e) {
101
144
  logger?.warn(`midas: failed to pause issuance vault ${vault} back: ${e}`);
@@ -104,5 +147,59 @@ async function unpauseMidasIssuanceVault(props) {
104
147
  }
105
148
  };
106
149
  }
150
+ /**
151
+ * Midas credit suites of the loaded credit managers.
152
+ *
153
+ * A manager with a gateway adapter is a suite on its own, so its degen NFT
154
+ * is not consulted. Suites that only have a Midas degen NFT read `mToken`
155
+ * from the gateway.
156
+ */
157
+ async function discoverMidasCreditSuites(sdk) {
158
+ const suites = [];
159
+ for (const cm of sdk.marketRegister.creditManagers) {
160
+ const creditManager = cm.creditManager.address;
161
+ let hasAdapter = false;
162
+ for (const adapter of cm.creditManager.adapters.values()) if (adapter instanceof require_onchain_market_adapters_contracts_MidasGatewayAdapterContract.MidasGatewayAdapterContract) {
163
+ hasAdapter = true;
164
+ suites.push({
165
+ creditManager,
166
+ gateway: adapter.gateway,
167
+ mToken: adapter.mToken
168
+ });
169
+ }
170
+ if (hasAdapter) continue;
171
+ const nft = await cm.degenNFT();
172
+ if (nft instanceof require_onchain_market_rwa_midas_MidasDegenNFT.MidasDegenNFT) {
173
+ const [mToken] = await nft.getTokens();
174
+ suites.push({
175
+ creditManager,
176
+ gateway: nft.gateway,
177
+ mToken
178
+ });
179
+ }
180
+ }
181
+ return suites;
182
+ }
183
+ /**
184
+ * Gateways of the Midas credit suites of the loaded credit managers.
185
+ */
186
+ async function discoverMidasGateways(sdk) {
187
+ const suites = await discoverMidasCreditSuites(sdk);
188
+ return new require_onchain_utils_AddressSet.AddressSet(suites.map((suite) => suite.gateway)).asArray();
189
+ }
190
+ /**
191
+ * mTokens of the Midas credit suites of the loaded credit managers.
192
+ *
193
+ * A manager with a gateway adapter contributes that adapter's mToken, so its
194
+ * degen NFT is not consulted. Suites that only have a Midas degen NFT
195
+ * contribute the mToken read from the gateway.
196
+ */
197
+ async function discoverMidasMTokens(sdk) {
198
+ const suites = await discoverMidasCreditSuites(sdk);
199
+ return new require_onchain_utils_AddressSet.AddressSet(suites.map((suite) => suite.mToken)).asArray();
200
+ }
107
201
  //#endregion
202
+ exports.discoverMidasCreditSuites = discoverMidasCreditSuites;
203
+ exports.discoverMidasGateways = discoverMidasGateways;
204
+ exports.discoverMidasMTokens = discoverMidasMTokens;
108
205
  exports.unpauseMidasIssuanceVault = unpauseMidasIssuanceVault;