@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
@@ -19,7 +19,7 @@ const adapterConstructorAbi = {
19
19
  ["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
20
20
  ["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
21
21
  ["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
22
- ["MIDAS_GATEWAY"]: { 311: REFERER_ID_ADAPTER_ABI },
22
+ ["MIDAS_GATEWAY"]: { 311: BASIC_ADAPTER_ABI },
23
23
  ["MIDAS_REDEMPTION_VAULT"]: {
24
24
  310: BASIC_ADAPTER_ABI,
25
25
  311: BASIC_ADAPTER_ABI
@@ -65,7 +65,7 @@ const adapterConstructorAbi = {
65
65
  ["INFINIFI_UNWINDING"]: { 310: PHANTOM_TOKEN_ADAPTER_ABI },
66
66
  ["SECURITIZE_REDEMPTION"]: {
67
67
  310: PHANTOM_TOKEN_ADAPTER_ABI,
68
- 311: PHANTOM_TOKEN_ADAPTER_ABI
68
+ 311: BASIC_ADAPTER_ABI
69
69
  },
70
70
  ["STAKING_REWARDS"]: { 312: STAKING_REWARDS_ADAPTER_ABI },
71
71
  ["MIDAS_ISSUANCE_VAULT"]: {
@@ -128,6 +128,12 @@ var AbstractAdapterContract = class extends BaseContract {
128
128
  return false;
129
129
  }
130
130
  /**
131
+ * {@inheritDoc IAdapterContract.openingCalls}
132
+ */
133
+ async openingCalls() {
134
+ return [];
135
+ }
136
+ /**
131
137
  * Applies the balance changes of a decoded adapter call to the running
132
138
  * balances, mutating them in place. Overrides should express changes via
133
139
  * {@link setLeftover} (diff-style calls) and {@link spendExact}
@@ -5,7 +5,7 @@ import "../abi/adapters/index.js";
5
5
  import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
6
6
  import "../abi/index.js";
7
7
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
8
- import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, isAddressEqual, zeroAddress } from "viem";
8
+ import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, getAddress, isAddressEqual, zeroAddress } from "viem";
9
9
  //#region src/onchain/market/adapters/contracts/MidasGatewayAdapterContract.ts
10
10
  const abi = iMidasGatewayAdapterV311Abi;
11
11
  const protocolAbi = iMidasGatewayV311Abi;
@@ -13,6 +13,12 @@ const receiveGreenlistCalldata = encodeFunctionData({
13
13
  abi,
14
14
  functionName: "receiveGreenlist"
15
15
  });
16
+ const MGLOBAL_MTOKEN = getAddress("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
17
+ /**
18
+ * Permissionless gateways have no greenlist and reject `receiveGreenlist`,
19
+ * see MidasMode in integrations-v3
20
+ */
21
+ const MIDAS_MODE_PERMISSIONLESS = 0;
16
22
  var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
17
23
  #version;
18
24
  #gateway;
@@ -20,6 +26,7 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
20
26
  #quoteToken;
21
27
  #phantomToken;
22
28
  #referrerId;
29
+ #mode;
23
30
  constructor(sdk, args) {
24
31
  super(sdk, {
25
32
  ...args,
@@ -125,6 +132,35 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
125
132
  if (this.#referrerId === void 0) throw new MissingSerializedParamsError("referrerId");
126
133
  return this.#referrerId;
127
134
  }
135
+ /**
136
+ * Gateway `mode` is immutable on-chain, so the first read is reused.
137
+ */
138
+ async mode() {
139
+ if (!this.#mode) this.#mode = this.client.readContract({
140
+ address: this.targetContract,
141
+ abi: this.protocolAbi,
142
+ functionName: "mode"
143
+ });
144
+ return this.#mode;
145
+ }
146
+ /**
147
+ * {@inheritDoc IAdapterContract.openingCalls}
148
+ */
149
+ async openingCalls() {
150
+ if (isAddressEqual(this.mToken, MGLOBAL_MTOKEN)) {
151
+ this.logger?.debug(`midas: skipping receiveGreenlist for mGLOBAL ${this.mToken}`);
152
+ return [];
153
+ }
154
+ if (await this.mode() === MIDAS_MODE_PERMISSIONLESS) {
155
+ this.logger?.debug(`midas: gateway ${this.targetContract} is permissionless, nothing to greenlist`);
156
+ return [];
157
+ }
158
+ this.logger?.debug(`midas: greenlisting the credit account via gateway adapter ${this.address}`);
159
+ return [{
160
+ target: this.address,
161
+ callData: receiveGreenlistCalldata
162
+ }];
163
+ }
128
164
  stateHuman(raw) {
129
165
  return {
130
166
  ...super.stateHuman(raw),
@@ -169,14 +205,22 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
169
205
  return { redeemer };
170
206
  }
171
207
  /**
172
- * `receiveGreenlist()` is prepended by `prependMidasReceiveGreenlist`
173
- * before the balance bracket when the multicall mints a permissioned
174
- * mToken: it only greenlists the credit account and is balance-neutral,
175
- * so it is legal outside a bracket and leaves balances untouched.
208
+ * Whether `calldata` is `receiveGreenlist()`, the call that grants the
209
+ * Midas greenlisted role to the credit account.
176
210
  */
177
- replayOutOfBracketCall(_balances, calldata) {
211
+ isReceiveGreenlist(calldata) {
178
212
  return calldata === receiveGreenlistCalldata;
179
213
  }
214
+ /**
215
+ * `receiveGreenlist()` is prepended by {@link openingCalls} before the
216
+ * balance bracket when a permissioned mToken is minted: it only grants
217
+ * the Midas greenlisted role to the credit account and is
218
+ * balance-neutral, so it is legal outside a bracket and leaves balances
219
+ * untouched.
220
+ */
221
+ replayOutOfBracketCall(_balances, calldata) {
222
+ return this.isReceiveGreenlist(calldata);
223
+ }
180
224
  applyBalanceChanges(balances, decoded) {
181
225
  switch (decoded.functionName) {
182
226
  case "depositInstantDiff": {
@@ -7,8 +7,6 @@ import "../../utils/index.js";
7
7
  import { SDKConstruct } from "../../base/SDKConstruct.js";
8
8
  import "../../base/index.js";
9
9
  import { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
10
- import { KYC_REGISTRATION_LINKS } from "../../../model/rwa.js";
11
- import "../../../model/index.js";
12
10
  import { createDegenNFT } from "../rwa/createDegenNFT.js";
13
11
  import { strategyName } from "../strategyName.js";
14
12
  import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
@@ -125,25 +123,37 @@ var CreditSuite = class extends SDKConstruct {
125
123
  degenNFT() {
126
124
  const address = this.creditFacade.degenNFT;
127
125
  if (isAddressEqual(address, "0x0000000000000000000000000000000000000000")) return Promise.resolve(void 0);
126
+ const factoryNft = this.rwaFactory?.degenNFT;
127
+ if (factoryNft && isAddressEqual(factoryNft.address, address)) return Promise.resolve(factoryNft);
128
128
  if (!this.#degenNFT) this.#degenNFT = createDegenNFT(this.sdk, address);
129
129
  return this.#degenNFT;
130
130
  }
131
131
  /**
132
- * What `wallet` still has to do before the facade lets it open an account;
133
- * `null` when nothing (no degen NFT, not a KYC gate, or already eligible).
132
+ * The KYC gate of this suite's strategy; `null` when there is none.
133
+ * Wallet-independent.
134
134
  */
135
- async kycRequirement(wallet, targetCollateral) {
135
+ async kycRequirement(targetCollateral) {
136
136
  const nft = await this.degenNFT();
137
137
  if (!nft) return null;
138
- const { eligible, token } = await nft.checkKyc(wallet, targetCollateral);
139
- if (eligible) return null;
138
+ const tokens = await nft.getTokens();
139
+ const token = tokens.find((t) => isAddressEqual(t, targetCollateral)) ?? tokens[0];
140
140
  return {
141
141
  protocol: nft.protocol,
142
- token: this.tokensMeta.getToken(token),
143
- registrationLink: KYC_REGISTRATION_LINKS[nft.protocol]
142
+ token: token ? this.tokensMeta.getToken(token) : void 0,
143
+ registrationLink: nft.registrationLink
144
144
  };
145
145
  }
146
146
  /**
147
+ * Whether `wallet` may open this suite's strategy today; `true` when there
148
+ * is no KYC gate.
149
+ */
150
+ async isEligibleForStrategy(wallet, targetCollateral) {
151
+ const nft = await this.degenNFT();
152
+ if (!nft) return true;
153
+ const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: targetCollateral });
154
+ return nft.isRegistered(requirements);
155
+ }
156
+ /**
147
157
  * Builds a transaction that executes a multicall on one of this suite's
148
158
  * credit accounts.
149
159
  *
@@ -168,6 +178,13 @@ var CreditSuite = class extends SDKConstruct {
168
178
  return rwaFactory ? rwaFactory.openCreditAccount(this.creditManager.address, calls, rwaOptions) : this.creditFacade.openCreditAccount(to, calls, referralCode ?? 0n);
169
179
  }
170
180
  /**
181
+ * Calls to run first in the multicall of a freshly opened account on this
182
+ * suite; use before {@link openCreditAccountTx}.
183
+ */
184
+ async openingCalls() {
185
+ return (await Promise.all(this.creditManager.adapters.values().map((a) => a.openingCalls()))).flat();
186
+ }
187
+ /**
171
188
  * Router configured for this credit suite.
172
189
  */
173
190
  get router() {
@@ -98,29 +98,34 @@ import { CreditSuite } from "./credit/CreditSuite.js";
98
98
  import { expectedBalanceDeltas } from "./credit/expectedBalanceDeltas.js";
99
99
  import "./credit/index.js";
100
100
  import { collateralPriceInUnderlying } from "./oracle/collateralPriceInUnderlying.js";
101
- import { isUpdatablePriceFeed } from "./pricefeeds/isUpdatablePriceFeed.js";
102
101
  import { PriceFeedRef } from "./pricefeeds/PriceFeedRef.js";
103
102
  import { AbstractPriceFeedContract, PartialPriceFeedInitError } from "./pricefeeds/AbstractPriceFeed.js";
104
103
  import { AbstractLPPriceFeedContract, isLPPriceFeed } from "./pricefeeds/AbstractLPPriceFeed.js";
105
- import { BalancerStablePriceFeedContract } from "./pricefeeds/BalancerStablePriceFeed.js";
106
- import { BalancerWeightedPriceFeedContract } from "./pricefeeds/BalancerWeightedPriceFeed.js";
107
- import { BoundedPriceFeedContract } from "./pricefeeds/BoundedPriceFeed.js";
108
- import { CompositePriceFeedContract } from "./pricefeeds/CompositePriceFeed.js";
109
- import { CurveCryptoPriceFeedContract } from "./pricefeeds/CurveCryptoPriceFeed.js";
110
- import { CurveStablePriceFeedContract } from "./pricefeeds/CurveStablePriceFeed.js";
111
- import { CurveUSDPriceFeedContract } from "./pricefeeds/CurveUSDPriceFeed.js";
112
- import { Erc4626PriceFeedContract } from "./pricefeeds/Erc4626PriceFeed.js";
113
- import { ExternalPriceFeedContract } from "./pricefeeds/ExternalPriceFeed.js";
114
- import { getRawPriceUpdates } from "./pricefeeds/getRawPriceUpdates.js";
115
- import { MellowLRTPriceFeedContract } from "./pricefeeds/MellowLRTPriceFeed.js";
116
- import { PendleTWAPPTPriceFeed } from "./pricefeeds/PendleTWAPPTPriceFeed.js";
117
- import { PythPriceFeed } from "./pricefeeds/PythPriceFeed.js";
118
- import { RedstonePriceFeedContract } from "./pricefeeds/RedstonePriceFeed.js";
104
+ import { BalancerStablePriceFeedContract } from "./pricefeeds/feeds/BalancerStablePriceFeed.js";
105
+ import { BalancerWeightedPriceFeedContract } from "./pricefeeds/feeds/BalancerWeightedPriceFeed.js";
106
+ import { BoundedPriceFeedContract } from "./pricefeeds/feeds/BoundedPriceFeed.js";
107
+ import { CompositePriceFeedContract } from "./pricefeeds/feeds/CompositePriceFeed.js";
108
+ import { ConstantPriceFeedContract } from "./pricefeeds/feeds/ConstantPriceFeed.js";
109
+ import { CurveCryptoPriceFeedContract } from "./pricefeeds/feeds/CurveCryptoPriceFeed.js";
110
+ import { CurveStablePriceFeedContract } from "./pricefeeds/feeds/CurveStablePriceFeed.js";
111
+ import { CurveUSDPriceFeedContract } from "./pricefeeds/feeds/CurveUSDPriceFeed.js";
112
+ import { Erc4626PriceFeedContract } from "./pricefeeds/feeds/Erc4626PriceFeed.js";
113
+ import { ExternalPriceFeedContract } from "./pricefeeds/feeds/ExternalPriceFeed.js";
114
+ import { MellowLRTPriceFeedContract } from "./pricefeeds/feeds/MellowLRTPriceFeed.js";
115
+ import { PendleTWAPPTPriceFeed } from "./pricefeeds/feeds/PendleTWAPPTPriceFeed.js";
116
+ import { PythPriceFeed } from "./pricefeeds/feeds/PythPriceFeed.js";
117
+ import { RedstonePriceFeedContract } from "./pricefeeds/feeds/RedstonePriceFeed.js";
118
+ import { WstETHPriceFeedContract } from "./pricefeeds/feeds/WstETHPriceFeed.js";
119
+ import { YearnPriceFeedContract } from "./pricefeeds/feeds/YearnPriceFeed.js";
120
+ import { ZeroPriceFeedContract } from "./pricefeeds/feeds/ZeroPriceFeed.js";
121
+ import { PriceFeedRegistry } from "./pricefeeds/PriceFeedRegistry.js";
119
122
  import { fetchRedstonePayloads } from "./pricefeeds/updates/fetchRedstonePayloads.js";
120
- import { WstETHPriceFeedContract } from "./pricefeeds/WstETHPriceFeed.js";
121
- import { YearnPriceFeedContract } from "./pricefeeds/YearnPriceFeed.js";
122
- import { ZeroPriceFeedContract } from "./pricefeeds/ZeroPriceFeed.js";
123
- import { PriceFeedRegister } from "./pricefeeds/PriceFeedsRegister.js";
123
+ import { getRawPriceUpdates } from "./pricefeeds/updates/getRawPriceUpdates.js";
124
+ import { isUpdatablePriceFeed } from "./pricefeeds/updates/isUpdatablePriceFeed.js";
125
+ import { PriceUpdatesCache } from "./pricefeeds/updates/PriceUpdatesCache.js";
126
+ import { RedstoneOptions, RedstoneUpdater } from "./pricefeeds/updates/RedstoneUpdater.js";
127
+ import { updatableDependencies } from "./pricefeeds/updates/updatableDependencies.js";
128
+ import { UpdatablePriceFeedRegistry } from "./pricefeeds/updates/UpdatablePriceFeedRegistry.js";
124
129
  import "./pricefeeds/index.js";
125
130
  import { PriceOracleV310Contract } from "./oracle/PriceOracleV310Contract.js";
126
131
  import { createPriceOracle } from "./oracle/createPriceOracle.js";
@@ -141,8 +146,8 @@ import { MidasLiquidatorContract } from "./rwa/midas/MidasLiquidatorContract.js"
141
146
  import { SecuritizeDegenNFT } from "./rwa/securitize/SecuritizeDegenNFT.js";
142
147
  import { SecuritizeLiquidatorContract } from "./rwa/securitize/SecuritizeLiquidatorContract.js";
143
148
  import { SecuritizeRWAFactory } from "./rwa/securitize/SecuritizeRWAFactory.js";
144
- import { RWARegistry } from "./rwa/RWARegistry.js";
149
+ import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./rwa/RWARegistry.js";
145
150
  import { isRWAFactory } from "./rwa/types.js";
146
151
  import "./rwa/index.js";
147
152
  import "./types.js";
148
- export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
153
+ export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConstantPriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstoneOptions, RedstonePriceFeedContract, RedstoneUpdater, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, bpsToRay, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, calcUtilizationRaw, classifyCurveOperation, collateralPriceInUnderlying, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, updatableDependencies, usdToNumber };
@@ -16,7 +16,7 @@ import { safeValue } from "../../../model/result.js";
16
16
  import "../../../model/index.js";
17
17
  import { priceFeedCompressorAbi } from "../../../abi/compressors/priceFeedCompressor.js";
18
18
  import { PriceFeedRef } from "../pricefeeds/PriceFeedRef.js";
19
- import { getRawPriceUpdates } from "../pricefeeds/getRawPriceUpdates.js";
19
+ import { getRawPriceUpdates } from "../pricefeeds/updates/getRawPriceUpdates.js";
20
20
  import "../pricefeeds/index.js";
21
21
  import PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
22
22
  import { isAddressEqual, stringToHex } from "viem";
@@ -1,6 +1,5 @@
1
1
  import { BaseContract } from "../../base/BaseContract.js";
2
2
  import "../../base/index.js";
3
- import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
4
3
  import { PriceFeedRef } from "./PriceFeedRef.js";
5
4
  //#region src/onchain/market/pricefeeds/AbstractPriceFeed.ts
6
5
  var PartialPriceFeedInitError = class extends Error {
@@ -84,10 +83,6 @@ var AbstractPriceFeedContract = class extends BaseContract {
84
83
  pricefeeds: this.underlyingPriceFeeds.map((f) => f.stateHuman(raw))
85
84
  };
86
85
  }
87
- updatableDependencies() {
88
- const underlying = this.underlyingPriceFeeds.flatMap((f) => f.priceFeed.updatableDependencies());
89
- return isUpdatablePriceFeed(this) ? [this, ...underlying] : underlying;
90
- }
91
86
  /**
92
87
  * {@inheritDoc IPriceFeedContract.describe}
93
88
  */
@@ -0,0 +1,126 @@
1
+ import { AddressMap } from "../../utils/AddressMap.js";
2
+ import { bytes32ToString } from "../../utils/bytes32ToString.js";
3
+ import "../../utils/index.js";
4
+ import { SDKConstruct } from "../../base/SDKConstruct.js";
5
+ import "../../base/index.js";
6
+ import { PartialPriceFeedInitError } from "./AbstractPriceFeed.js";
7
+ import { BalancerStablePriceFeedContract } from "./feeds/BalancerStablePriceFeed.js";
8
+ import { BalancerWeightedPriceFeedContract } from "./feeds/BalancerWeightedPriceFeed.js";
9
+ import { BoundedPriceFeedContract } from "./feeds/BoundedPriceFeed.js";
10
+ import { CompositePriceFeedContract } from "./feeds/CompositePriceFeed.js";
11
+ import { ConstantPriceFeedContract } from "./feeds/ConstantPriceFeed.js";
12
+ import { CurveCryptoPriceFeedContract } from "./feeds/CurveCryptoPriceFeed.js";
13
+ import { CurveStablePriceFeedContract } from "./feeds/CurveStablePriceFeed.js";
14
+ import { CurveUSDPriceFeedContract } from "./feeds/CurveUSDPriceFeed.js";
15
+ import { Erc4626PriceFeedContract } from "./feeds/Erc4626PriceFeed.js";
16
+ import { ExternalPriceFeedContract } from "./feeds/ExternalPriceFeed.js";
17
+ import { MellowLRTPriceFeedContract } from "./feeds/MellowLRTPriceFeed.js";
18
+ import { PendleTWAPPTPriceFeed } from "./feeds/PendleTWAPPTPriceFeed.js";
19
+ import { PythPriceFeed } from "./feeds/PythPriceFeed.js";
20
+ import { RedstonePriceFeedContract } from "./feeds/RedstonePriceFeed.js";
21
+ import { WstETHPriceFeedContract } from "./feeds/WstETHPriceFeed.js";
22
+ import { YearnPriceFeedContract } from "./feeds/YearnPriceFeed.js";
23
+ import { ZeroPriceFeedContract } from "./feeds/ZeroPriceFeed.js";
24
+ //#region src/onchain/market/pricefeeds/PriceFeedRegistry.ts
25
+ /**
26
+ * Chain-level cache of price feed contract instances.
27
+ *
28
+ * All {@link IPriceOracleContract}s across different markets share a single
29
+ * `PriceFeedRegistry`, avoiding duplicate contract wrappers for the same
30
+ * on-chain feed.
31
+ **/
32
+ var PriceFeedRegistry = class extends SDKConstruct {
33
+ #feeds = new AddressMap(void 0, "priceFeeds");
34
+ /**
35
+ * Returns all price feeds known to sdk
36
+ */
37
+ get feeds() {
38
+ return this.#feeds.values();
39
+ }
40
+ /**
41
+ * Checks whether a price feed is already registered at the given address.
42
+ * @param address - On-chain address to look up.
43
+ **/
44
+ has(address) {
45
+ return this.#feeds.has(address);
46
+ }
47
+ /**
48
+ * Returns the cached price feed contract at the given address, if any.
49
+ * @param address - On-chain address to look up.
50
+ **/
51
+ get(address) {
52
+ return this.#feeds.get(address);
53
+ }
54
+ /**
55
+ * Returns the cached price feed contract at the given address.
56
+ * @param address - On-chain address to look up.
57
+ * @throws If no feed is registered at that address.
58
+ **/
59
+ mustGet(address) {
60
+ return this.#feeds.mustGet(address);
61
+ }
62
+ /**
63
+ * Inserts or updates a price feed from a full tree node.
64
+ *
65
+ * If a fully loaded feed already exists at the same address, only the
66
+ * answer is refreshed. Otherwise a new contract wrapper is created and
67
+ * cached.
68
+ *
69
+ * @param data - Full price feed tree node from the compressor.
70
+ * @returns The cached (or newly created) feed instance.
71
+ * @throws If the created feed is only partially initialized.
72
+ **/
73
+ upsert(data) {
74
+ const existing = this.#feeds.get(data.baseParams.addr);
75
+ if (existing?.loaded) {
76
+ existing.updateAnswer(data.answer);
77
+ return existing;
78
+ }
79
+ const feed = this.create(data);
80
+ if (!feed.loaded) throw new PartialPriceFeedInitError({
81
+ ...data,
82
+ abi: [],
83
+ name: ""
84
+ });
85
+ this.#feeds.upsert(data.baseParams.addr, feed);
86
+ return feed;
87
+ }
88
+ /**
89
+ * Instantiates the appropriate price feed contract wrapper based on
90
+ * the `contractType` discriminator in the node's base params.
91
+ *
92
+ * @param data - Partial or full price feed tree node.
93
+ * @returns A new (uncached) feed contract instance.
94
+ * @throws If the contract type is unsupported and strict mode is enabled.
95
+ **/
96
+ create(data) {
97
+ const contractType = bytes32ToString(data.baseParams.contractType);
98
+ switch (contractType) {
99
+ case "PRICE_FEED::BALANCER_STABLE": return new BalancerStablePriceFeedContract(this.sdk, data);
100
+ case "PRICE_FEED::BALANCER_WEIGHTED": return new BalancerWeightedPriceFeedContract(this.sdk, data);
101
+ case "PRICE_FEED::BOUNDED": return new BoundedPriceFeedContract(this.sdk, data);
102
+ case "PRICE_FEED::COMPOSITE": return new CompositePriceFeedContract(this.sdk, data);
103
+ case "PRICE_FEED::CONSTANT": return new ConstantPriceFeedContract(this.sdk, data);
104
+ case "PRICE_FEED::CURVE_CRYPTO": return new CurveCryptoPriceFeedContract(this.sdk, data);
105
+ case "PRICE_FEED::CURVE_STABLE": return new CurveStablePriceFeedContract(this.sdk, data);
106
+ case "PRICE_FEED::CURVE_USD": return new CurveUSDPriceFeedContract(this.sdk, data);
107
+ case "PRICE_FEED::ERC4626": return new Erc4626PriceFeedContract(this.sdk, data);
108
+ case "PRICE_FEED::EXTERNAL": return new ExternalPriceFeedContract(this.sdk, data);
109
+ case "PRICE_FEED::MELLOW_LRT": return new MellowLRTPriceFeedContract(this.sdk, data);
110
+ case "PRICE_FEED::PENDLE_PT_TWAP": return new PendleTWAPPTPriceFeed(this.sdk, data);
111
+ case "PRICE_FEED::PYTH": return new PythPriceFeed(this.sdk, data);
112
+ case "PRICE_FEED::REDSTONE": return new RedstonePriceFeedContract(this.sdk, data);
113
+ case "PRICE_FEED::WSTETH": return new WstETHPriceFeedContract(this.sdk, data);
114
+ case "PRICE_FEED::YEARN": return new YearnPriceFeedContract(this.sdk, data);
115
+ case "PRICE_FEED::ZERO": return new ZeroPriceFeedContract(this.sdk, data);
116
+ default: {
117
+ const err = /* @__PURE__ */ new Error(`Price feed type ${contractType} not supported for price feed at ${data.baseParams.addr}`);
118
+ if (this.sdk.strictContractTypes) throw err;
119
+ this.logger?.error(err);
120
+ return new ExternalPriceFeedContract(this.sdk, data);
121
+ }
122
+ }
123
+ }
124
+ };
125
+ //#endregion
126
+ export { PriceFeedRegistry };
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { bptStablePriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/BalancerStablePriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { bptStablePriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.ts
5
5
  var BalancerStablePriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,8 +1,8 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { bptWeightedPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { bptWeightedPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
4
  import { decodeAbiParameters, hexToBytes } from "viem";
5
- //#region src/onchain/market/pricefeeds/BalancerWeightedPriceFeed.ts
5
+ //#region src/onchain/market/pricefeeds/feeds/BalancerWeightedPriceFeed.ts
6
6
  var BalancerWeightedPriceFeedContract = class extends AbstractLPPriceFeedContract {
7
7
  vault;
8
8
  poolId;
@@ -1,8 +1,8 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { boundedPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { boundedPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
4
  import { decodeAbiParameters } from "viem";
5
- //#region src/onchain/market/pricefeeds/BoundedPriceFeed.ts
5
+ //#region src/onchain/market/pricefeeds/feeds/BoundedPriceFeed.ts
6
6
  var BoundedPriceFeedContract = class extends AbstractPriceFeedContract {
7
7
  upperBound;
8
8
  constructor(options, args) {
@@ -1,7 +1,7 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { compositePriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/CompositePriceFeed.ts
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { compositePriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/CompositePriceFeed.ts
5
5
  var CompositePriceFeedContract = class extends AbstractPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { constantPriceFeedAbi } from "../../abi/oracles.js";
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { constantPriceFeedAbi } from "../../../abi/oracles.js";
3
3
  import { decodeAbiParameters } from "viem";
4
- //#region src/onchain/market/pricefeeds/ConstantPriceFeed.ts
4
+ //#region src/onchain/market/pricefeeds/feeds/ConstantPriceFeed.ts
5
5
  var ConstantPriceFeedContract = class extends AbstractPriceFeedContract {
6
6
  price;
7
7
  constructor(options, args) {
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { curveCryptoLpPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/CurveCryptoPriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { curveCryptoLpPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.ts
5
5
  var CurveCryptoPriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { curveStableLpPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/CurveStablePriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { curveStableLpPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.ts
5
5
  var CurveStablePriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { curveUsdPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/CurveUSDPriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { curveUsdPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.ts
5
5
  var CurveUSDPriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { erc4626PriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/Erc4626PriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { erc4626PriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.ts
5
5
  var Erc4626PriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { chainlinkReadableAggregatorAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/ExternalPriceFeed.ts
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { chainlinkReadableAggregatorAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/ExternalPriceFeed.ts
5
5
  var ExternalPriceFeedContract = class extends AbstractPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,7 +1,7 @@
1
- import { AbstractLPPriceFeedContract } from "./AbstractLPPriceFeed.js";
2
- import { mellowLrtPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
4
- //#region src/onchain/market/pricefeeds/MellowLRTPriceFeed.ts
1
+ import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
2
+ import { mellowLrtPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
+ //#region src/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.ts
5
5
  var MellowLRTPriceFeedContract = class extends AbstractLPPriceFeedContract {
6
6
  constructor(options, args) {
7
7
  super(options, {
@@ -1,8 +1,8 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { pendleTWAPPTPriceFeedAbi } from "../../abi/oracles.js";
3
- import "../../abi/index.js";
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { pendleTWAPPTPriceFeedAbi } from "../../../abi/oracles.js";
3
+ import "../../../abi/index.js";
4
4
  import { decodeAbiParameters } from "viem";
5
- //#region src/onchain/market/pricefeeds/PendleTWAPPTPriceFeed.ts
5
+ //#region src/onchain/market/pricefeeds/feeds/PendleTWAPPTPriceFeed.ts
6
6
  const abi = pendleTWAPPTPriceFeedAbi;
7
7
  var PendleTWAPPTPriceFeed = class extends AbstractPriceFeedContract {
8
8
  market;
@@ -1,7 +1,7 @@
1
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
2
- import { pythPriceFeedAbi } from "../../abi/oracles.js";
1
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
2
+ import { pythPriceFeedAbi } from "../../../abi/oracles.js";
3
3
  import { decodeAbiParameters } from "viem";
4
- //#region src/onchain/market/pricefeeds/PythPriceFeed.ts
4
+ //#region src/onchain/market/pricefeeds/feeds/PythPriceFeed.ts
5
5
  const abi = pythPriceFeedAbi;
6
6
  var PythPriceFeed = class extends AbstractPriceFeedContract {
7
7
  token;
@@ -1,10 +1,10 @@
1
- import { ADDRESS_0X0 } from "../../constants/addresses.js";
2
- import "../../constants/index.js";
3
- import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
4
- import { redstonePriceFeedAbi } from "../../abi/oracles.js";
5
- import "../../abi/index.js";
1
+ import { ADDRESS_0X0 } from "../../../constants/addresses.js";
2
+ import "../../../constants/index.js";
3
+ import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
4
+ import { redstonePriceFeedAbi } from "../../../abi/oracles.js";
5
+ import "../../../abi/index.js";
6
6
  import { bytesToString, decodeAbiParameters, toBytes } from "viem";
7
- //#region src/onchain/market/pricefeeds/RedstonePriceFeed.ts
7
+ //#region src/onchain/market/pricefeeds/feeds/RedstonePriceFeed.ts
8
8
  var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
9
9
  token;
10
10
  dataServiceId;