@gearbox-protocol/sdk 14.12.0-next.1 → 14.12.0-next.11

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 (322) hide show
  1. package/dist/cjs/abi/iZapper.js +62 -24
  2. package/dist/cjs/dev/AccountOpener.js +7 -13
  3. package/dist/cjs/history/classifyMulticallOperations.js +2 -0
  4. package/dist/cjs/history/mapOperations.js +7 -0
  5. package/dist/cjs/plugins/adapters/abi/iConvexV1BoosterAdapter.js +143 -0
  6. package/dist/cjs/plugins/adapters/abi/index.js +2 -0
  7. package/dist/cjs/plugins/adapters/contracts/AbstractAdapter.js +36 -0
  8. package/dist/cjs/plugins/adapters/contracts/AbstractCurveAdapter.js +66 -0
  9. package/dist/cjs/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +19 -0
  10. package/dist/cjs/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +15 -0
  11. package/dist/cjs/plugins/adapters/contracts/CamelotV3AdapterContract.js +20 -0
  12. package/dist/cjs/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +18 -0
  13. package/dist/cjs/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +28 -2
  14. package/dist/cjs/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +2 -7
  15. package/dist/cjs/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +2 -7
  16. package/dist/cjs/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +2 -7
  17. package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterDeposit.js +2 -2
  18. package/dist/cjs/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +2 -7
  19. package/dist/cjs/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +2 -7
  20. package/dist/cjs/plugins/adapters/contracts/DaiUsdsAdapterContract.js +14 -0
  21. package/dist/cjs/plugins/adapters/contracts/ERC4626AdapterContract.js +15 -0
  22. package/dist/cjs/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +14 -0
  23. package/dist/cjs/plugins/adapters/contracts/FluidDexAdapterContract.js +15 -0
  24. package/dist/cjs/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +21 -0
  25. package/dist/cjs/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +10 -0
  26. package/dist/cjs/plugins/adapters/contracts/LidoV1AdapterContract.js +11 -0
  27. package/dist/cjs/plugins/adapters/contracts/MellowDVVAdapterContract.js +15 -0
  28. package/dist/cjs/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +15 -0
  29. package/dist/cjs/plugins/adapters/contracts/MellowWrapperAdapterContract.js +11 -0
  30. package/dist/cjs/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +10 -0
  31. package/dist/cjs/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +12 -0
  32. package/dist/cjs/plugins/adapters/contracts/PendleRouterAdapterContract.js +58 -0
  33. package/dist/cjs/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +11 -0
  34. package/dist/cjs/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +22 -1
  35. package/dist/cjs/plugins/adapters/contracts/StakingRewardsAdapterContract.js +17 -0
  36. package/dist/cjs/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +10 -0
  37. package/dist/cjs/plugins/adapters/contracts/UniswapV2AdapterContract.js +10 -0
  38. package/dist/cjs/plugins/adapters/contracts/UniswapV3AdapterContract.js +20 -0
  39. package/dist/cjs/plugins/adapters/contracts/UniswapV4AdapterContract.js +15 -0
  40. package/dist/cjs/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +14 -0
  41. package/dist/cjs/plugins/adapters/contracts/VelodromeV2AdapterContract.js +10 -0
  42. package/dist/cjs/plugins/adapters/contracts/WstETHV1AdapterContract.js +15 -0
  43. package/dist/cjs/preview/index.js +2 -4
  44. package/dist/cjs/preview/parse/classifyInnerOperations.js +14 -1
  45. package/dist/cjs/preview/parse/errors.js +5 -2
  46. package/dist/cjs/preview/parse/index.js +2 -2
  47. package/dist/cjs/preview/parse/parseFacadeOperationCalldata.js +5 -12
  48. package/dist/cjs/preview/parse/parseOperationCalldata.js +40 -1
  49. package/dist/cjs/preview/parse/parsePoolOperationCalldata.js +14 -2
  50. package/dist/cjs/preview/parse/parseRWAFactoryOperationCalldata.js +104 -0
  51. package/dist/cjs/preview/parse/types-rwa.js +16 -0
  52. package/dist/cjs/preview/parse/types.js +9 -2
  53. package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +13 -13
  54. package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +32 -14
  55. package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +66 -0
  56. package/dist/cjs/preview/prerequisites/buildPrerequisites.js +124 -14
  57. package/dist/cjs/preview/prerequisites/index.js +2 -0
  58. package/dist/cjs/preview/preview/applyInnerOperations.js +130 -0
  59. package/dist/cjs/preview/preview/errors.js +52 -0
  60. package/dist/cjs/preview/preview/index.js +30 -0
  61. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +90 -0
  62. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +67 -0
  63. package/dist/cjs/preview/preview/previewOperation.js +45 -0
  64. package/dist/cjs/preview/preview/previewPoolOperation.js +75 -0
  65. package/dist/cjs/preview/preview/types.js +16 -0
  66. package/dist/cjs/{sdk/market/zapper/Zapper.js → preview/preview/unwrapNativeCollateral.js} +20 -22
  67. package/dist/cjs/preview/simulate/errors.js +0 -7
  68. package/dist/cjs/preview/simulate/index.js +5 -5
  69. package/dist/cjs/preview/simulate/simulateOperation.js +4 -0
  70. package/dist/cjs/preview/simulate/simulatePoolOperation.js +60 -31
  71. package/dist/cjs/preview/simulate/{constants.js → simulateRWAOperation.js} +8 -6
  72. package/dist/cjs/sdk/MultichainSDK.js +1 -0
  73. package/dist/cjs/sdk/OnchainSDK.js +7 -3
  74. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +53 -23
  75. package/dist/cjs/sdk/base/BaseContract.js +4 -2
  76. package/dist/cjs/sdk/base/ChainContractsRegister.js +1 -0
  77. package/dist/cjs/sdk/market/MarketRegister.js +10 -5
  78. package/dist/cjs/sdk/market/ZapperRegister.js +54 -0
  79. package/dist/cjs/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +30 -0
  80. package/dist/cjs/sdk/market/rwa/types.js +5 -2
  81. package/dist/cjs/sdk/market/zapper/IERC20ZapperContract.js +3 -38
  82. package/dist/cjs/sdk/market/zapper/IETHZapperContract.js +3 -38
  83. package/dist/cjs/sdk/market/zapper/ZapperContract.js +106 -0
  84. package/dist/cjs/sdk/market/zapper/createZapper.js +12 -4
  85. package/dist/cjs/{preview/simulate/holders.js → sdk/market/zapper/errors.js} +13 -21
  86. package/dist/cjs/sdk/market/zapper/index.js +6 -2
  87. package/dist/cjs/sdk/market/zapper/types.js +16 -0
  88. package/dist/cjs/sdk/options.js +41 -17
  89. package/dist/cjs/sdk/router/AbstractRouterContract.js +21 -27
  90. package/dist/cjs/sdk/router/RouterV310Contract.js +11 -12
  91. package/dist/cjs/sdk/router/helpers.js +0 -5
  92. package/dist/cjs/sdk/utils/AddressMap.js +6 -0
  93. package/dist/cjs/sdk/utils/AssetsMap.js +97 -0
  94. package/dist/cjs/sdk/utils/index.js +2 -0
  95. package/dist/esm/abi/iZapper.js +62 -24
  96. package/dist/esm/dev/AccountOpener.js +8 -13
  97. package/dist/esm/history/classifyMulticallOperations.js +2 -0
  98. package/dist/esm/history/mapOperations.js +7 -0
  99. package/dist/esm/plugins/adapters/abi/iConvexV1BoosterAdapter.js +119 -0
  100. package/dist/esm/plugins/adapters/abi/index.js +1 -0
  101. package/dist/esm/plugins/adapters/contracts/AbstractAdapter.js +36 -0
  102. package/dist/esm/plugins/adapters/contracts/AbstractCurveAdapter.js +42 -0
  103. package/dist/esm/plugins/adapters/contracts/BalancerV3RouterAdapterContract.js +22 -1
  104. package/dist/esm/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.js +18 -1
  105. package/dist/esm/plugins/adapters/contracts/CamelotV3AdapterContract.js +23 -1
  106. package/dist/esm/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.js +22 -1
  107. package/dist/esm/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.js +30 -2
  108. package/dist/esm/plugins/adapters/contracts/Curve2AssetsAdapterContract.js +2 -7
  109. package/dist/esm/plugins/adapters/contracts/Curve3AssetsAdapterContract.js +2 -7
  110. package/dist/esm/plugins/adapters/contracts/Curve4AssetsAdapterContract.js +2 -7
  111. package/dist/esm/plugins/adapters/contracts/CurveV1AdapterDeposit.js +2 -2
  112. package/dist/esm/plugins/adapters/contracts/CurveV1AdapterStETHContract.js +2 -7
  113. package/dist/esm/plugins/adapters/contracts/CurveV1StableNGAdapterContract.js +2 -7
  114. package/dist/esm/plugins/adapters/contracts/DaiUsdsAdapterContract.js +17 -1
  115. package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +19 -1
  116. package/dist/esm/plugins/adapters/contracts/ERC4626ReferralAdapterContract.js +17 -1
  117. package/dist/esm/plugins/adapters/contracts/FluidDexAdapterContract.js +18 -1
  118. package/dist/esm/plugins/adapters/contracts/InfinifiGatewayAdapterContract.js +24 -1
  119. package/dist/esm/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.js +13 -1
  120. package/dist/esm/plugins/adapters/contracts/LidoV1AdapterContract.js +14 -1
  121. package/dist/esm/plugins/adapters/contracts/MellowDVVAdapterContract.js +18 -1
  122. package/dist/esm/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.js +18 -1
  123. package/dist/esm/plugins/adapters/contracts/MellowWrapperAdapterContract.js +14 -1
  124. package/dist/esm/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.js +13 -1
  125. package/dist/esm/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.js +15 -1
  126. package/dist/esm/plugins/adapters/contracts/PendleRouterAdapterContract.js +61 -1
  127. package/dist/esm/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.js +14 -1
  128. package/dist/esm/plugins/adapters/contracts/SecuritizeSwapAdapterContract.js +25 -2
  129. package/dist/esm/plugins/adapters/contracts/StakingRewardsAdapterContract.js +20 -1
  130. package/dist/esm/plugins/adapters/contracts/TraderJoeRouterAdapterContract.js +13 -1
  131. package/dist/esm/plugins/adapters/contracts/UniswapV2AdapterContract.js +10 -0
  132. package/dist/esm/plugins/adapters/contracts/UniswapV3AdapterContract.js +20 -0
  133. package/dist/esm/plugins/adapters/contracts/UniswapV4AdapterContract.js +18 -1
  134. package/dist/esm/plugins/adapters/contracts/UpshiftVaultAdapterContract.js +17 -1
  135. package/dist/esm/plugins/adapters/contracts/VelodromeV2AdapterContract.js +13 -1
  136. package/dist/esm/plugins/adapters/contracts/WstETHV1AdapterContract.js +18 -1
  137. package/dist/esm/preview/index.js +1 -2
  138. package/dist/esm/preview/parse/classifyInnerOperations.js +14 -1
  139. package/dist/esm/preview/parse/errors.js +3 -1
  140. package/dist/esm/preview/parse/index.js +1 -1
  141. package/dist/esm/preview/parse/parseFacadeOperationCalldata.js +5 -12
  142. package/dist/esm/preview/parse/parseOperationCalldata.js +43 -2
  143. package/dist/esm/preview/parse/parsePoolOperationCalldata.js +14 -2
  144. package/dist/esm/preview/parse/parseRWAFactoryOperationCalldata.js +85 -0
  145. package/dist/esm/preview/parse/types-rwa.js +0 -0
  146. package/dist/esm/preview/parse/types.js +6 -1
  147. package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +13 -13
  148. package/dist/esm/preview/prerequisites/BalancePrerequisite.js +32 -14
  149. package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +42 -0
  150. package/dist/esm/preview/prerequisites/buildPrerequisites.js +130 -14
  151. package/dist/esm/preview/prerequisites/index.js +1 -0
  152. package/dist/esm/preview/preview/applyInnerOperations.js +108 -0
  153. package/dist/esm/preview/preview/errors.js +27 -0
  154. package/dist/esm/preview/preview/index.js +5 -0
  155. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +74 -0
  156. package/dist/esm/preview/preview/previewOpenCreditAccount.js +49 -0
  157. package/dist/esm/preview/preview/previewOperation.js +21 -0
  158. package/dist/esm/preview/preview/previewPoolOperation.js +53 -0
  159. package/dist/esm/preview/preview/types.js +0 -0
  160. package/dist/esm/preview/preview/unwrapNativeCollateral.js +21 -0
  161. package/dist/esm/preview/simulate/errors.js +0 -6
  162. package/dist/esm/preview/simulate/index.js +3 -3
  163. package/dist/esm/preview/simulate/simulateOperation.js +8 -1
  164. package/dist/esm/preview/simulate/simulatePoolOperation.js +61 -35
  165. package/dist/esm/preview/simulate/simulateRWAOperation.js +6 -0
  166. package/dist/esm/sdk/MultichainSDK.js +1 -0
  167. package/dist/esm/sdk/OnchainSDK.js +7 -3
  168. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +54 -24
  169. package/dist/esm/sdk/base/BaseContract.js +4 -2
  170. package/dist/esm/sdk/base/ChainContractsRegister.js +1 -0
  171. package/dist/esm/sdk/market/MarketRegister.js +10 -5
  172. package/dist/esm/sdk/market/ZapperRegister.js +54 -0
  173. package/dist/esm/sdk/market/rwa/securitize/SecuritizeRWAFactory.js +33 -1
  174. package/dist/esm/sdk/market/rwa/types.js +5 -2
  175. package/dist/esm/sdk/market/zapper/IERC20ZapperContract.js +3 -38
  176. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +3 -38
  177. package/dist/esm/sdk/market/zapper/ZapperContract.js +82 -0
  178. package/dist/esm/sdk/market/zapper/createZapper.js +12 -4
  179. package/dist/esm/sdk/market/zapper/errors.js +13 -0
  180. package/dist/esm/sdk/market/zapper/index.js +3 -1
  181. package/dist/esm/sdk/market/zapper/types.js +0 -0
  182. package/dist/esm/sdk/options.js +39 -15
  183. package/dist/esm/sdk/router/AbstractRouterContract.js +25 -29
  184. package/dist/esm/sdk/router/RouterV310Contract.js +11 -12
  185. package/dist/esm/sdk/router/helpers.js +0 -4
  186. package/dist/esm/sdk/utils/AddressMap.js +6 -0
  187. package/dist/esm/sdk/utils/AssetsMap.js +73 -0
  188. package/dist/esm/sdk/utils/index.js +1 -0
  189. package/dist/types/abi/iERC20Zapper.d.ts +91 -23
  190. package/dist/types/abi/iETHZapper.d.ts +91 -23
  191. package/dist/types/abi/iZapper.d.ts +91 -23
  192. package/dist/types/common-utils/utils/strategies/assets/assets.d.ts +1 -1
  193. package/dist/types/common-utils/utils/strategies/credit-managers/get-wallet-balances-allowed-on-cm.d.ts +1 -1
  194. package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-apy.d.ts +1 -1
  195. package/dist/types/common-utils/utils/strategies/strategy-info/calculate-total-points.d.ts +1 -1
  196. package/dist/types/common-utils/utils/strategies/tokens/add-amount-in-target.d.ts +1 -1
  197. package/dist/types/common-utils/utils/strategies/tokens/get-list-with-amount-in-target.d.ts +1 -1
  198. package/dist/types/common-utils/utils/strategies/types/strategy-earnings.d.ts +1 -1
  199. package/dist/types/common-utils/utils/validation/validate-balances.d.ts +1 -1
  200. package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +1 -1
  201. package/dist/types/common-utils/utils/validation/validate-quota.d.ts +1 -1
  202. package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +1 -1
  203. package/dist/types/history/types.d.ts +4 -4
  204. package/dist/types/plugins/adapters/abi/iConvexV1BoosterAdapter.d.ts +204 -0
  205. package/dist/types/plugins/adapters/abi/index.d.ts +1 -0
  206. package/dist/types/plugins/adapters/contracts/AbstractAdapter.d.ts +21 -3
  207. package/dist/types/plugins/adapters/contracts/AbstractCurveAdapter.d.ts +18 -0
  208. package/dist/types/plugins/adapters/contracts/BalancerV3RouterAdapterContract.d.ts +4 -2
  209. package/dist/types/plugins/adapters/contracts/BalancerV3WrapperAdapterContract.d.ts +4 -2
  210. package/dist/types/plugins/adapters/contracts/CamelotV3AdapterContract.d.ts +4 -2
  211. package/dist/types/plugins/adapters/contracts/ConvexV1BaseRewardPoolAdapterContract.d.ts +4 -2
  212. package/dist/types/plugins/adapters/contracts/ConvexV1BoosterAdapterContract.d.ts +8 -6
  213. package/dist/types/plugins/adapters/contracts/Curve2AssetsAdapterContract.d.ts +3 -6
  214. package/dist/types/plugins/adapters/contracts/Curve3AssetsAdapterContract.d.ts +3 -6
  215. package/dist/types/plugins/adapters/contracts/Curve4AssetsAdapterContract.d.ts +3 -6
  216. package/dist/types/plugins/adapters/contracts/CurveV1AdapterDeposit.d.ts +2 -2
  217. package/dist/types/plugins/adapters/contracts/CurveV1AdapterStETHContract.d.ts +3 -6
  218. package/dist/types/plugins/adapters/contracts/CurveV1StableNGAdapterContract.d.ts +3 -6
  219. package/dist/types/plugins/adapters/contracts/DaiUsdsAdapterContract.d.ts +4 -2
  220. package/dist/types/plugins/adapters/contracts/ERC4626AdapterContract.d.ts +4 -2
  221. package/dist/types/plugins/adapters/contracts/ERC4626ReferralAdapterContract.d.ts +4 -2
  222. package/dist/types/plugins/adapters/contracts/FluidDexAdapterContract.d.ts +4 -2
  223. package/dist/types/plugins/adapters/contracts/InfinifiGatewayAdapterContract.d.ts +4 -2
  224. package/dist/types/plugins/adapters/contracts/KelpLRTDepositPoolAdapterContract.d.ts +4 -2
  225. package/dist/types/plugins/adapters/contracts/LidoV1AdapterContract.d.ts +4 -2
  226. package/dist/types/plugins/adapters/contracts/MellowDVVAdapterContract.d.ts +4 -2
  227. package/dist/types/plugins/adapters/contracts/MellowERC4626VaultAdapterContract.d.ts +4 -2
  228. package/dist/types/plugins/adapters/contracts/MellowWrapperAdapterContract.d.ts +4 -2
  229. package/dist/types/plugins/adapters/contracts/MidasIssuanceVaultAdapterContract.d.ts +4 -2
  230. package/dist/types/plugins/adapters/contracts/MidasRedemptionVaultAdapterContract.d.ts +4 -2
  231. package/dist/types/plugins/adapters/contracts/PendleRouterAdapterContract.d.ts +4 -2
  232. package/dist/types/plugins/adapters/contracts/SecuritizeOnRampAdapterContract.d.ts +4 -2
  233. package/dist/types/plugins/adapters/contracts/SecuritizeSwapAdapterContract.d.ts +15 -3
  234. package/dist/types/plugins/adapters/contracts/StakingRewardsAdapterContract.d.ts +4 -2
  235. package/dist/types/plugins/adapters/contracts/TraderJoeRouterAdapterContract.d.ts +4 -2
  236. package/dist/types/plugins/adapters/contracts/UniswapV2AdapterContract.d.ts +3 -1
  237. package/dist/types/plugins/adapters/contracts/UniswapV3AdapterContract.d.ts +3 -1
  238. package/dist/types/plugins/adapters/contracts/UniswapV4AdapterContract.d.ts +4 -2
  239. package/dist/types/plugins/adapters/contracts/UpshiftVaultAdapterContract.d.ts +4 -2
  240. package/dist/types/plugins/adapters/contracts/VelodromeV2AdapterContract.d.ts +4 -2
  241. package/dist/types/plugins/adapters/contracts/WstETHV1AdapterContract.d.ts +4 -2
  242. package/dist/types/plugins/adapters/types.d.ts +10 -0
  243. package/dist/types/preview/index.d.ts +1 -2
  244. package/dist/types/preview/parse/classifyInnerOperations.d.ts +0 -2
  245. package/dist/types/preview/parse/errors.d.ts +1 -0
  246. package/dist/types/preview/parse/index.d.ts +1 -1
  247. package/dist/types/preview/parse/parseOperationCalldata.d.ts +3 -3
  248. package/dist/types/preview/parse/parseRWAFactoryOperationCalldata.d.ts +22 -0
  249. package/dist/types/preview/parse/types-adapters.d.ts +5 -1
  250. package/dist/types/preview/parse/types-facades.d.ts +23 -34
  251. package/dist/types/preview/parse/types-pools.d.ts +90 -2
  252. package/dist/types/preview/parse/types-rwa.d.ts +48 -0
  253. package/dist/types/preview/parse/types.d.ts +11 -6
  254. package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +1 -3
  255. package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +9 -6
  256. package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +36 -0
  257. package/dist/types/preview/prerequisites/buildPrerequisites.d.ts +15 -6
  258. package/dist/types/preview/prerequisites/index.d.ts +1 -0
  259. package/dist/types/preview/prerequisites/types.d.ts +10 -8
  260. package/dist/types/preview/preview/applyInnerOperations.d.ts +77 -0
  261. package/dist/types/preview/preview/errors.d.ts +21 -0
  262. package/dist/types/preview/preview/index.d.ts +5 -0
  263. package/dist/types/preview/preview/previewAdjustCreditAccount.d.ts +11 -0
  264. package/dist/types/preview/preview/previewOpenCreditAccount.d.ts +4 -0
  265. package/dist/types/preview/preview/previewOperation.d.ts +7 -0
  266. package/dist/types/preview/preview/previewPoolOperation.d.ts +5 -0
  267. package/dist/types/preview/preview/types.d.ts +177 -0
  268. package/dist/types/preview/preview/unwrapNativeCollateral.d.ts +20 -0
  269. package/dist/types/preview/simulate/errors.d.ts +6 -12
  270. package/dist/types/preview/simulate/index.d.ts +3 -2
  271. package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -2
  272. package/dist/types/preview/simulate/simulateOperation.d.ts +0 -2
  273. package/dist/types/preview/simulate/simulatePoolOperation.d.ts +9 -3
  274. package/dist/types/preview/simulate/simulateRWAOperation.d.ts +23 -0
  275. package/dist/types/preview/simulate/types.d.ts +12 -39
  276. package/dist/types/sdk/MultichainSDK.d.ts +5 -0
  277. package/dist/types/sdk/OnchainSDK.d.ts +4 -0
  278. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +11 -3
  279. package/dist/types/sdk/accounts/types.d.ts +66 -8
  280. package/dist/types/sdk/base/BaseContract.d.ts +1 -1
  281. package/dist/types/sdk/base/TokensMeta.d.ts +1 -1
  282. package/dist/types/sdk/base/types.d.ts +18 -0
  283. package/dist/types/sdk/market/MarketRegister.d.ts +15 -6
  284. package/dist/types/sdk/market/ZapperRegister.d.ts +25 -4
  285. package/dist/types/sdk/market/rwa/securitize/SecuritizeRWAFactory.d.ts +6 -1
  286. package/dist/types/sdk/market/rwa/types.d.ts +13 -5
  287. package/dist/types/sdk/market/zapper/IERC20ZapperContract.d.ts +93 -39
  288. package/dist/types/sdk/market/zapper/IETHZapperContract.d.ts +93 -39
  289. package/dist/types/sdk/market/zapper/ZapperContract.d.ts +35 -0
  290. package/dist/types/sdk/market/zapper/createZapper.d.ts +2 -4
  291. package/dist/types/sdk/market/zapper/errors.d.ts +10 -0
  292. package/dist/types/sdk/market/zapper/index.d.ts +3 -1
  293. package/dist/types/sdk/market/zapper/types.d.ts +64 -0
  294. package/dist/types/sdk/options.d.ts +10 -5
  295. package/dist/types/sdk/pools/types.d.ts +4 -4
  296. package/dist/types/sdk/router/AbstractRouterContract.d.ts +5 -5
  297. package/dist/types/sdk/router/helpers.d.ts +1 -2
  298. package/dist/types/sdk/router/types.d.ts +1 -15
  299. package/dist/types/sdk/types/state-human.d.ts +9 -0
  300. package/dist/types/sdk/types/state.d.ts +7 -0
  301. package/dist/types/sdk/utils/AddressMap.d.ts +4 -0
  302. package/dist/types/sdk/utils/AssetsMap.d.ts +44 -0
  303. package/dist/types/sdk/utils/index.d.ts +1 -0
  304. package/package.json +3 -3
  305. package/dist/cjs/preview/parse/extractExpectedBalanceChanges.js +0 -48
  306. package/dist/cjs/preview/simulate/extractERC20Transfers.js +0 -47
  307. package/dist/cjs/preview/simulate/simulatePoolOpMulticall.js +0 -155
  308. package/dist/cjs/preview/simulate/simulatePoolOpV1.js +0 -106
  309. package/dist/esm/preview/parse/extractExpectedBalanceChanges.js +0 -24
  310. package/dist/esm/preview/simulate/constants.js +0 -4
  311. package/dist/esm/preview/simulate/extractERC20Transfers.js +0 -23
  312. package/dist/esm/preview/simulate/holders.js +0 -21
  313. package/dist/esm/preview/simulate/simulatePoolOpMulticall.js +0 -130
  314. package/dist/esm/preview/simulate/simulatePoolOpV1.js +0 -82
  315. package/dist/esm/sdk/market/zapper/Zapper.js +0 -23
  316. package/dist/types/preview/parse/extractExpectedBalanceChanges.d.ts +0 -22
  317. package/dist/types/preview/simulate/constants.d.ts +0 -6
  318. package/dist/types/preview/simulate/extractERC20Transfers.d.ts +0 -11
  319. package/dist/types/preview/simulate/holders.d.ts +0 -7
  320. package/dist/types/preview/simulate/simulatePoolOpMulticall.d.ts +0 -28
  321. package/dist/types/preview/simulate/simulatePoolOpV1.d.ts +0 -14
  322. package/dist/types/sdk/market/zapper/Zapper.d.ts +0 -13
@@ -19,14 +19,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var helpers_exports = {};
20
20
  __export(helpers_exports, {
21
21
  assetsMap: () => assetsMap,
22
- balancesMap: () => balancesMap,
23
22
  limitLeftover: () => limitLeftover
24
23
  });
25
24
  module.exports = __toCommonJS(helpers_exports);
26
25
  var import_utils = require("../utils/index.js");
27
- function balancesMap(assets) {
28
- return new import_utils.AddressMap(assets.map(({ token, balance }) => [token, balance]));
29
- }
30
26
  function assetsMap(assets) {
31
27
  return new import_utils.AddressMap(assets.map((a) => [a.token, a]));
32
28
  }
@@ -42,6 +38,5 @@ function limitLeftover(balance, token) {
42
38
  // Annotate the CommonJS export names for ESM import in node:
43
39
  0 && (module.exports = {
44
40
  assetsMap,
45
- balancesMap,
46
41
  limitLeftover
47
42
  });
@@ -136,6 +136,12 @@ class AddressMap {
136
136
  keys() {
137
137
  return Array.from(this.#map.keys());
138
138
  }
139
+ /**
140
+ * Returns an unfrozen shallow copy of the map.
141
+ **/
142
+ clone() {
143
+ return new AddressMap(this.entries(), this.name);
144
+ }
139
145
  /**
140
146
  * Converts the map to a plain `Record<Address, T>` object.
141
147
  **/
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var AssetsMap_exports = {};
20
+ __export(AssetsMap_exports, {
21
+ AssetsMap: () => AssetsMap
22
+ });
23
+ module.exports = __toCommonJS(AssetsMap_exports);
24
+ var import_AddressMap = require("./AddressMap.js");
25
+ class AssetsMap extends import_AddressMap.AddressMap {
26
+ /**
27
+ * @param entries - Optional initial entries as `[address, balance]` tuples or {@link Asset} objects.
28
+ * @param name - Optional label used in error messages when a lookup fails.
29
+ */
30
+ constructor(entries, name) {
31
+ super(
32
+ entries?.map((e) => Array.isArray(e) ? e : [e.token, e.balance]),
33
+ name
34
+ );
35
+ }
36
+ /**
37
+ * Looks up a token balance, treating a missing key as `0n`.
38
+ */
39
+ getOrZero(address) {
40
+ return this.get(address) ?? 0n;
41
+ }
42
+ /**
43
+ * Adds `amount` to the token balance, treating a missing key as `0n`.
44
+ */
45
+ inc(address, amount) {
46
+ this.upsert(address, this.getOrZero(address) + amount);
47
+ }
48
+ /**
49
+ * Subtracts `amount` from the token balance, treating a missing key as `0n`.
50
+ */
51
+ dec(address, amount) {
52
+ this.inc(address, -amount);
53
+ }
54
+ /**
55
+ * Per-token difference `this - before`, non-zero entries only.
56
+ *
57
+ * Assumes this map's keys are a superset of `before`'s keys; tokens present
58
+ * only in `before` are not reported.
59
+ */
60
+ difference(before) {
61
+ const result = new AssetsMap();
62
+ for (const [token, balance] of this.entries()) {
63
+ const change = balance - before.getOrZero(token);
64
+ if (change !== 0n) {
65
+ result.upsert(token, change);
66
+ }
67
+ }
68
+ return result;
69
+ }
70
+ /**
71
+ * Sums `fn` over all entries.
72
+ */
73
+ sum(fn) {
74
+ return this.entries().reduce(
75
+ (acc, [token, balance]) => acc + fn(token, balance),
76
+ 0n
77
+ );
78
+ }
79
+ /**
80
+ * Converts the map to an array of {@link Asset} objects.
81
+ * @param minBalance - If provided, keeps only entries with a balance
82
+ * strictly greater than this threshold (e.g. `1n` to filter out dust).
83
+ */
84
+ toAssets(minBalance) {
85
+ const abs = (balance) => balance > 0n ? balance : -balance;
86
+ return this.entries().filter(
87
+ ([, balance]) => minBalance === void 0 || abs(balance) > minBalance
88
+ ).map(([token, balance]) => ({ token, balance }));
89
+ }
90
+ clone() {
91
+ return new AssetsMap(this.entries(), this.name);
92
+ }
93
+ }
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ AssetsMap
97
+ });
@@ -17,6 +17,7 @@ var utils_exports = {};
17
17
  module.exports = __toCommonJS(utils_exports);
18
18
  __reExport(utils_exports, require("./AddressMap.js"), module.exports);
19
19
  __reExport(utils_exports, require("./AddressSet.js"), module.exports);
20
+ __reExport(utils_exports, require("./AssetsMap.js"), module.exports);
20
21
  __reExport(utils_exports, require("./abi-decode.js"), module.exports);
21
22
  __reExport(utils_exports, require("./bytes32ToString.js"), module.exports);
22
23
  __reExport(utils_exports, require("./childLogger.js"), module.exports);
@@ -36,6 +37,7 @@ __reExport(utils_exports, require("./zod.js"), module.exports);
36
37
  0 && (module.exports = {
37
38
  ...require("./AddressMap.js"),
38
39
  ...require("./AddressSet.js"),
40
+ ...require("./AssetsMap.js"),
39
41
  ...require("./abi-decode.js"),
40
42
  ...require("./bytes32ToString.js"),
41
43
  ...require("./childLogger.js"),
@@ -1,80 +1,118 @@
1
1
  const iZapperAbi = [
2
2
  {
3
3
  type: "function",
4
+ name: "contractType",
4
5
  inputs: [],
6
+ outputs: [{ name: "", type: "bytes32", internalType: "bytes32" }],
7
+ stateMutability: "view"
8
+ },
9
+ {
10
+ type: "function",
5
11
  name: "pool",
6
- outputs: [{ name: "", internalType: "address", type: "address" }],
12
+ inputs: [],
13
+ outputs: [{ name: "", type: "address", internalType: "address" }],
7
14
  stateMutability: "view"
8
15
  },
9
16
  {
10
17
  type: "function",
18
+ name: "previewDeposit",
11
19
  inputs: [
12
- { name: "tokenInAmount", internalType: "uint256", type: "uint256" }
20
+ { name: "tokenInAmount", type: "uint256", internalType: "uint256" }
13
21
  ],
14
- name: "previewDeposit",
15
22
  outputs: [
16
- { name: "tokenOutAmount", internalType: "uint256", type: "uint256" }
23
+ { name: "tokenOutAmount", type: "uint256", internalType: "uint256" }
17
24
  ],
18
25
  stateMutability: "view"
19
26
  },
20
27
  {
21
28
  type: "function",
29
+ name: "previewRedeem",
22
30
  inputs: [
23
- { name: "tokenOutAmount", internalType: "uint256", type: "uint256" }
31
+ { name: "tokenOutAmount", type: "uint256", internalType: "uint256" }
24
32
  ],
25
- name: "previewRedeem",
26
33
  outputs: [
27
- { name: "tokenInAmount", internalType: "uint256", type: "uint256" }
34
+ { name: "tokenInAmount", type: "uint256", internalType: "uint256" }
28
35
  ],
29
36
  stateMutability: "view"
30
37
  },
31
38
  {
32
39
  type: "function",
40
+ name: "redeem",
33
41
  inputs: [
34
- { name: "tokenOutAmount", internalType: "uint256", type: "uint256" },
35
- { name: "receiver", internalType: "address", type: "address" }
42
+ { name: "tokenOutAmount", type: "uint256", internalType: "uint256" },
43
+ { name: "receiver", type: "address", internalType: "address" }
36
44
  ],
37
- name: "redeem",
38
45
  outputs: [
39
- { name: "tokenInAmount", internalType: "uint256", type: "uint256" }
46
+ { name: "tokenInAmount", type: "uint256", internalType: "uint256" }
40
47
  ],
41
48
  stateMutability: "nonpayable"
42
49
  },
43
50
  {
44
51
  type: "function",
52
+ name: "redeemWithPermit",
45
53
  inputs: [
46
- { name: "tokenOutAmount", internalType: "uint256", type: "uint256" },
47
- { name: "receiver", internalType: "address", type: "address" },
48
- { name: "deadline", internalType: "uint256", type: "uint256" },
49
- { name: "v", internalType: "uint8", type: "uint8" },
50
- { name: "r", internalType: "bytes32", type: "bytes32" },
51
- { name: "s", internalType: "bytes32", type: "bytes32" }
54
+ { name: "tokenOutAmount", type: "uint256", internalType: "uint256" },
55
+ { name: "receiver", type: "address", internalType: "address" },
56
+ { name: "deadline", type: "uint256", internalType: "uint256" },
57
+ { name: "v", type: "uint8", internalType: "uint8" },
58
+ { name: "r", type: "bytes32", internalType: "bytes32" },
59
+ { name: "s", type: "bytes32", internalType: "bytes32" }
52
60
  ],
53
- name: "redeemWithPermit",
54
61
  outputs: [
55
- { name: "tokenInAmount", internalType: "uint256", type: "uint256" }
62
+ { name: "tokenInAmount", type: "uint256", internalType: "uint256" }
56
63
  ],
57
64
  stateMutability: "nonpayable"
58
65
  },
59
66
  {
60
67
  type: "function",
68
+ name: "redeemWithPermitAllowed",
69
+ inputs: [
70
+ { name: "tokenOutAmount", type: "uint256", internalType: "uint256" },
71
+ { name: "receiver", type: "address", internalType: "address" },
72
+ { name: "nonce", type: "uint256", internalType: "uint256" },
73
+ { name: "expiry", type: "uint256", internalType: "uint256" },
74
+ { name: "v", type: "uint8", internalType: "uint8" },
75
+ { name: "r", type: "bytes32", internalType: "bytes32" },
76
+ { name: "s", type: "bytes32", internalType: "bytes32" }
77
+ ],
78
+ outputs: [
79
+ { name: "tokenInAmount", type: "uint256", internalType: "uint256" }
80
+ ],
81
+ stateMutability: "nonpayable"
82
+ },
83
+ {
84
+ type: "function",
85
+ name: "serialize",
61
86
  inputs: [],
62
- name: "tokenIn",
63
- outputs: [{ name: "", internalType: "address", type: "address" }],
87
+ outputs: [{ name: "serializedData", type: "bytes", internalType: "bytes" }],
64
88
  stateMutability: "view"
65
89
  },
66
90
  {
67
91
  type: "function",
92
+ name: "tokenIn",
68
93
  inputs: [],
69
- name: "tokenOut",
70
- outputs: [{ name: "", internalType: "address", type: "address" }],
94
+ outputs: [{ name: "", type: "address", internalType: "address" }],
71
95
  stateMutability: "view"
72
96
  },
73
97
  {
74
98
  type: "function",
99
+ name: "tokenOut",
75
100
  inputs: [],
101
+ outputs: [{ name: "", type: "address", internalType: "address" }],
102
+ stateMutability: "view"
103
+ },
104
+ {
105
+ type: "function",
76
106
  name: "underlying",
77
- outputs: [{ name: "", internalType: "address", type: "address" }],
107
+ inputs: [],
108
+ outputs: [{ name: "", type: "address", internalType: "address" }],
109
+ stateMutability: "view"
110
+ },
111
+ {
112
+ type: "function",
113
+ name: "version",
114
+ inputs: [],
115
+ outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
78
116
  stateMutability: "view"
79
117
  }
80
118
  ];
@@ -12,6 +12,7 @@ import {
12
12
  ADDRESS_0X0,
13
13
  AddressMap,
14
14
  AddressSet,
15
+ AssetsMap,
15
16
  childLogger,
16
17
  MAX_UINT256,
17
18
  PERCENTAGE_FACTOR,
@@ -373,7 +374,7 @@ class AccountOpener extends SDKConstruct {
373
374
  }
374
375
  async #depositIntoPools(targets) {
375
376
  this.#logger?.debug("checking and topping up pools if necessary");
376
- const minAvailableByPool = {};
377
+ const minAvailableByPool = new AssetsMap();
377
378
  for (let i = 0; i < targets.length; i++) {
378
379
  const t = targets[i];
379
380
  const leverage = this.#getLeverage(t);
@@ -381,14 +382,14 @@ class AccountOpener extends SDKConstruct {
381
382
  const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / PERCENTAGE_FACTOR;
382
383
  let amount = minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
383
384
  amount = amount > cm.creditFacade.maxDebt ? cm.creditFacade.maxDebt : amount;
384
- minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + amount;
385
+ minAvailableByPool.inc(cm.pool, amount);
385
386
  this.#logger?.debug(
386
387
  `target #${i + 1} (${this.labelAddress(t.target)}) needs ${this.sdk.tokensMeta.formatBN(cm.underlying, amount, { symbol: true })} in pool (leverage: ${Number(leverage / PERCENTAGE_FACTOR)}%)`
387
388
  );
388
389
  }
389
390
  const deposits = [];
390
- const claims = new AddressMap();
391
- for (const [p, minAvailable] of Object.entries(minAvailableByPool)) {
391
+ const claims = new AssetsMap();
392
+ for (const [p, minAvailable] of minAvailableByPool.entries()) {
392
393
  const market = this.sdk.marketRegister.findByPool(p);
393
394
  const pool = market.pool.pool;
394
395
  let diff = minAvailable - pool.availableLiquidity;
@@ -405,9 +406,7 @@ class AccountOpener extends SDKConstruct {
405
406
  );
406
407
  if (diff > 0n) {
407
408
  deposits.push([pool, diff]);
408
- let claim = claims.get(pool.underlying) ?? 0n;
409
- claim += diff * PERCENTAGE_FACTOR / 8950n;
410
- claims.upsert(pool.underlying, claim);
409
+ claims.inc(pool.underlying, diff * PERCENTAGE_FACTOR / 8950n);
411
410
  }
412
411
  }
413
412
  const depositor = await this.#getDepositor();
@@ -564,18 +563,14 @@ class AccountOpener extends SDKConstruct {
564
563
  async #prepareBorrower(targets) {
565
564
  const borrower = await this.#getBorrower();
566
565
  const degenNFTS = {};
567
- const claims = new AddressMap();
566
+ const claims = new AssetsMap();
568
567
  for (const target of targets) {
569
568
  const cm = this.sdk.marketRegister.findCreditManager(
570
569
  target.creditManager
571
570
  );
572
- const market = this.sdk.marketRegister.findByCreditManager(
573
- target.creditManager
574
- );
575
571
  const { degenNFT } = cm.creditFacade;
576
572
  const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / PERCENTAGE_FACTOR;
577
- const claim = claims.get(cm.underlying) ?? 0n;
578
- claims.upsert(cm.underlying, claim + minDebt * 11n / 10n);
573
+ claims.inc(cm.underlying, minDebt * 11n / 10n);
579
574
  if (isAddress(degenNFT) && degenNFT !== ADDRESS_0X0) {
580
575
  degenNFTS[degenNFT] = (degenNFTS[degenNFT] ?? 0) + 1;
581
576
  }
@@ -45,6 +45,7 @@ function classifyMulticallOperations(input) {
45
45
  label: call.label,
46
46
  adapterFunctionName: call.functionName,
47
47
  adapterArgs: call.rawArgs,
48
+ calldata: call.calldata,
48
49
  protocol,
49
50
  transfers: transfers2,
50
51
  legacy
@@ -80,6 +81,7 @@ function classifyMulticallOperations(input) {
80
81
  label: call.label,
81
82
  adapterFunctionName: call.functionName,
82
83
  adapterArgs: call.rawArgs,
84
+ calldata: call.calldata,
83
85
  // Unknown adapter (non-strict): we have no ABI to decode the protocol
84
86
  // call, so `protocol` is left absent rather than filled with placeholders.
85
87
  protocol: void 0,
@@ -12,6 +12,13 @@ function mapInnerOperation(op, visitor, ctx) {
12
12
  return visitor.WithdrawCollateral(op, ctx);
13
13
  case "UpdateQuota":
14
14
  return visitor.UpdateQuota(op, ctx);
15
+ // The history classifier never emits other InnerOperation variants
16
+ // (e.g. StoreExpectedBalances/CompareBalances, which it drops), so this
17
+ // guards against silently returning undefined if that ever changes.
18
+ default:
19
+ throw new Error(
20
+ `unexpected inner operation: ${op.operation}`
21
+ );
15
22
  }
16
23
  }
17
24
  function mapOuterOperation(op, visitor) {
@@ -0,0 +1,119 @@
1
+ const iConvexV1BoosterAdapterAbi = [
2
+ {
3
+ type: "function",
4
+ inputs: [],
5
+ name: "contractType",
6
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
7
+ stateMutability: "view"
8
+ },
9
+ {
10
+ type: "function",
11
+ inputs: [],
12
+ name: "creditManager",
13
+ outputs: [{ name: "", internalType: "address", type: "address" }],
14
+ stateMutability: "view"
15
+ },
16
+ {
17
+ type: "function",
18
+ inputs: [
19
+ { name: "_pid", internalType: "uint256", type: "uint256" },
20
+ { name: "", internalType: "uint256", type: "uint256" },
21
+ { name: "_stake", internalType: "bool", type: "bool" }
22
+ ],
23
+ name: "deposit",
24
+ outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
25
+ stateMutability: "nonpayable"
26
+ },
27
+ {
28
+ type: "function",
29
+ inputs: [
30
+ { name: "_pid", internalType: "uint256", type: "uint256" },
31
+ { name: "leftoverAmount", internalType: "uint256", type: "uint256" },
32
+ { name: "_stake", internalType: "bool", type: "bool" }
33
+ ],
34
+ name: "depositDiff",
35
+ outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
36
+ stateMutability: "nonpayable"
37
+ },
38
+ {
39
+ type: "function",
40
+ inputs: [{ name: "", internalType: "uint256", type: "uint256" }],
41
+ name: "pidToConvexToken",
42
+ outputs: [{ name: "", internalType: "address", type: "address" }],
43
+ stateMutability: "view"
44
+ },
45
+ {
46
+ type: "function",
47
+ inputs: [{ name: "", internalType: "uint256", type: "uint256" }],
48
+ name: "pidToCurveToken",
49
+ outputs: [{ name: "", internalType: "address", type: "address" }],
50
+ stateMutability: "view"
51
+ },
52
+ {
53
+ type: "function",
54
+ inputs: [{ name: "", internalType: "uint256", type: "uint256" }],
55
+ name: "pidToPhantomToken",
56
+ outputs: [{ name: "", internalType: "address", type: "address" }],
57
+ stateMutability: "view"
58
+ },
59
+ {
60
+ type: "function",
61
+ inputs: [],
62
+ name: "serialize",
63
+ outputs: [{ name: "serializedData", internalType: "bytes", type: "bytes" }],
64
+ stateMutability: "view"
65
+ },
66
+ {
67
+ type: "function",
68
+ inputs: [],
69
+ name: "targetContract",
70
+ outputs: [{ name: "", internalType: "address", type: "address" }],
71
+ stateMutability: "view"
72
+ },
73
+ {
74
+ type: "function",
75
+ inputs: [],
76
+ name: "updateSupportedPids",
77
+ outputs: [],
78
+ stateMutability: "nonpayable"
79
+ },
80
+ {
81
+ type: "function",
82
+ inputs: [],
83
+ name: "version",
84
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
85
+ stateMutability: "view"
86
+ },
87
+ {
88
+ type: "function",
89
+ inputs: [
90
+ { name: "_pid", internalType: "uint256", type: "uint256" },
91
+ { name: "", internalType: "uint256", type: "uint256" }
92
+ ],
93
+ name: "withdraw",
94
+ outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
95
+ stateMutability: "nonpayable"
96
+ },
97
+ {
98
+ type: "function",
99
+ inputs: [
100
+ { name: "_pid", internalType: "uint256", type: "uint256" },
101
+ { name: "leftoverAmount", internalType: "uint256", type: "uint256" }
102
+ ],
103
+ name: "withdrawDiff",
104
+ outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
105
+ stateMutability: "nonpayable"
106
+ },
107
+ {
108
+ type: "event",
109
+ anonymous: false,
110
+ inputs: [
111
+ { name: "pid", internalType: "uint256", type: "uint256", indexed: true }
112
+ ],
113
+ name: "AddSupportedPid"
114
+ },
115
+ { type: "error", inputs: [], name: "UnsupportedPidException" }
116
+ ];
117
+ export {
118
+ iConvexV1BoosterAdapterAbi
119
+ };
@@ -1,5 +1,6 @@
1
1
  export * from "./actionAbi.js";
2
2
  export * from "./conctructorAbi.js";
3
+ export * from "./iConvexV1BoosterAdapter.js";
3
4
  export * from "./securitize/index.js";
4
5
  export * from "./targetContractAbi.js";
5
6
  export * from "./utils.js";
@@ -103,6 +103,42 @@ class AbstractAdapterContract extends BaseContract {
103
103
  return void 0;
104
104
  }
105
105
  }
106
+ /**
107
+ * Applies the balance changes implied by a router-generated diff-style
108
+ * adapter call to a map of credit-account token balances.
109
+ *
110
+ * @param balances - Token balances before the call. Mutated in place.
111
+ * @param calldata - Raw ABI-encoded adapter calldata.
112
+ * @throws When the calldata cannot be decoded or the adapter (or the
113
+ * specific function) has no balance-changes support.
114
+ */
115
+ previewBalanceChanges(balances, calldata) {
116
+ let decoded;
117
+ try {
118
+ decoded = decodeFunctionData({ abi: this.abi, data: calldata });
119
+ } catch (e) {
120
+ throw new Error(
121
+ `previewBalanceChanges: cannot decode selector ${calldata.slice(0, 10)} on ${this.contractType} adapter at ${this.address}`,
122
+ { cause: e }
123
+ );
124
+ }
125
+ const leftovers = this.decodeDiffLeftovers(decoded, balances);
126
+ for (const { tokenIn, leftoverAmount } of leftovers) {
127
+ balances.upsert(tokenIn, leftoverAmount);
128
+ }
129
+ }
130
+ /**
131
+ * Resolves which tokens the diff-style call spends down to which leftovers.
132
+ *
133
+ * @param decoded - The viem-decoded adapter call
134
+ * @param _balances - Token balances before the call
135
+ * @throws When the adapter (or the specific function) has no balance-changes support
136
+ */
137
+ decodeDiffLeftovers(decoded, _balances) {
138
+ throw new Error(
139
+ `previewBalanceChanges is not supported for ${decoded.functionName} on ${this.contractType} adapter at ${this.address}`
140
+ );
141
+ }
106
142
  /**
107
143
  * Classifies an adapter call into a {@link LegacyAdapterOperation} using the
108
144
  * parsed call and credit-account transfer deltas.
@@ -0,0 +1,42 @@
1
+ import { classifyCurveOperation } from "../transferHelpers.js";
2
+ import { AbstractAdapterContract } from "./AbstractAdapter.js";
3
+ class AbstractCurveAdapterContract extends AbstractAdapterContract {
4
+ /** @see https://github.com/Gearbox-protocol/charts_server/blob/master/core/operation_type.go#L132-L164 */
5
+ classifyLegacyOperation(parsed, transfers) {
6
+ return classifyCurveOperation(parsed.functionName, transfers) ?? super.classifyLegacyOperation(parsed, transfers);
7
+ }
8
+ decodeDiffLeftovers(decoded, balances) {
9
+ const { functionName, args } = decoded;
10
+ switch (functionName) {
11
+ case "exchange_diff": {
12
+ const [i, , leftoverAmount] = args;
13
+ return [{ tokenIn: this.curveCoin(i), leftoverAmount }];
14
+ }
15
+ case "add_diff_liquidity_one_coin": {
16
+ const [leftoverAmount, i] = args;
17
+ return [{ tokenIn: this.curveCoin(i), leftoverAmount }];
18
+ }
19
+ case "remove_diff_liquidity_one_coin": {
20
+ const [leftoverAmount] = args;
21
+ return [{ tokenIn: this.lpToken, leftoverAmount }];
22
+ }
23
+ default:
24
+ return super.decodeDiffLeftovers(decoded, balances);
25
+ }
26
+ }
27
+ /**
28
+ * Resolves a Curve pool coin index to its token address.
29
+ *
30
+ * @throws When the index is out of range for the pool.
31
+ */
32
+ curveCoin(i) {
33
+ const token = this.tokens[Number(i)];
34
+ if (!token) {
35
+ throw new Error(`curve coin index ${i} is out of range`);
36
+ }
37
+ return token;
38
+ }
39
+ }
40
+ export {
41
+ AbstractCurveAdapterContract
42
+ };
@@ -1,5 +1,7 @@
1
1
  import { iBalancerV3RouterAdapterAbi } from "@gearbox-protocol/integrations-v3";
2
- import { decodeAbiParameters } from "viem";
2
+ import {
3
+ decodeAbiParameters
4
+ } from "viem";
3
5
  import { MissingSerializedParamsError } from "../../../sdk/index.js";
4
6
  import { iBalancerV3RouterAbi } from "../abi/targetContractAbi.js";
5
7
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -69,6 +71,25 @@ class BalancerV3RouterAdapterContract extends AbstractAdapterContract {
69
71
  }))
70
72
  };
71
73
  }
74
+ decodeDiffLeftovers(decoded, balances) {
75
+ switch (decoded.functionName) {
76
+ case "swapSingleTokenDiffIn": {
77
+ const [, tokenIn, , leftoverAmount] = decoded.args;
78
+ return [{ tokenIn, leftoverAmount }];
79
+ }
80
+ // BPT (pool token) is spent down to the leftover
81
+ case "removeLiquiditySingleTokenDiff": {
82
+ const [pool, leftoverAmount] = decoded.args;
83
+ return [{ tokenIn: pool, leftoverAmount }];
84
+ }
85
+ case "addLiquidityUnbalancedDiff":
86
+ throw new Error(
87
+ `previewBalanceChanges cannot resolve pool tokens for addLiquidityUnbalancedDiff on ${this.contractType} adapter at ${this.address}`
88
+ );
89
+ default:
90
+ return super.decodeDiffLeftovers(decoded, balances);
91
+ }
92
+ }
72
93
  }
73
94
  export {
74
95
  BalancerV3PoolStatus,
@@ -1,5 +1,7 @@
1
1
  import { iBalancerV3WrapperAdapterAbi } from "@gearbox-protocol/integrations-v3";
2
- import { decodeAbiParameters } from "viem";
2
+ import {
3
+ decodeAbiParameters
4
+ } from "viem";
3
5
  import { MissingSerializedParamsError } from "../../../sdk/index.js";
4
6
  import { iBalancerV3WrapperAbi } from "../abi/targetContractAbi.js";
5
7
  import { AbstractAdapterContract } from "./AbstractAdapter.js";
@@ -32,6 +34,21 @@ class BalancerV3WrapperAdapterContract extends AbstractAdapterContract {
32
34
  balancerPoolToken: this.#balancerPoolToken ? this.labelAddress(this.#balancerPoolToken) : void 0
33
35
  };
34
36
  }
37
+ decodeDiffLeftovers(decoded, balances) {
38
+ switch (decoded.functionName) {
39
+ // mint spends the pool token, burn spends the wrapper (target contract)
40
+ case "mintDiff": {
41
+ const [leftoverAmount] = decoded.args;
42
+ return [{ tokenIn: this.balancerPoolToken, leftoverAmount }];
43
+ }
44
+ case "burnDiff": {
45
+ const [leftoverAmount] = decoded.args;
46
+ return [{ tokenIn: this.targetContract, leftoverAmount }];
47
+ }
48
+ default:
49
+ return super.decodeDiffLeftovers(decoded, balances);
50
+ }
51
+ }
35
52
  }
36
53
  export {
37
54
  BalancerV3WrapperAdapterContract