@gauntlet-xyz/sdk 2.5.0 → 3.0.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 (346) hide show
  1. package/README.md +89 -6
  2. package/dist/api/activity.d.ts +1 -1
  3. package/dist/api/activity.d.ts.map +1 -1
  4. package/dist/api/caip.d.ts +1 -1
  5. package/dist/api/caip.d.ts.map +1 -1
  6. package/dist/api/client.d.ts +43 -5
  7. package/dist/api/client.d.ts.map +1 -1
  8. package/dist/api/errors.d.ts +1 -1
  9. package/dist/api/errors.d.ts.map +1 -1
  10. package/dist/api/generated.d.ts +570 -7
  11. package/dist/api/generated.d.ts.map +1 -1
  12. package/dist/api/index.d.ts +13 -13
  13. package/dist/api/index.d.ts.map +1 -1
  14. package/dist/api/index.js +48 -8
  15. package/dist/api/index.js.map +7 -1
  16. package/dist/api/positionHistory.d.ts +1 -1
  17. package/dist/api/positionHistory.d.ts.map +1 -1
  18. package/dist/attribution/index.d.ts +3 -3
  19. package/dist/attribution/index.d.ts.map +1 -1
  20. package/dist/chunk-7TA2OJUK.js +4364 -0
  21. package/dist/chunk-7TA2OJUK.js.map +7 -0
  22. package/dist/chunk-HC2BS7MK.js +439 -0
  23. package/dist/chunk-HC2BS7MK.js.map +7 -0
  24. package/dist/chunk-S2TTA45N.js +2009 -0
  25. package/dist/chunk-S2TTA45N.js.map +7 -0
  26. package/dist/chunk-STIV2CC4.js +57 -0
  27. package/dist/chunk-STIV2CC4.js.map +7 -0
  28. package/dist/chunk-SU6JAKIA.js +283 -0
  29. package/dist/chunk-SU6JAKIA.js.map +7 -0
  30. package/dist/cjs/api/activity.d.ts +70 -0
  31. package/dist/cjs/api/activity.d.ts.map +1 -0
  32. package/dist/cjs/api/activity.js +136 -0
  33. package/dist/cjs/api/activity.js.map +7 -0
  34. package/dist/cjs/api/caip.d.ts +29 -0
  35. package/dist/cjs/api/caip.d.ts.map +1 -0
  36. package/dist/cjs/api/caip.js +59 -0
  37. package/dist/cjs/api/caip.js.map +7 -0
  38. package/dist/cjs/api/client.d.ts +173 -0
  39. package/dist/cjs/api/client.d.ts.map +1 -0
  40. package/dist/cjs/api/client.js +171 -0
  41. package/dist/cjs/api/client.js.map +7 -0
  42. package/dist/cjs/api/decimal.d.ts +21 -0
  43. package/dist/cjs/api/decimal.d.ts.map +1 -0
  44. package/dist/cjs/api/decimal.js +60 -0
  45. package/dist/cjs/api/decimal.js.map +7 -0
  46. package/dist/cjs/api/errors.d.ts +32 -0
  47. package/dist/cjs/api/errors.d.ts.map +1 -0
  48. package/dist/cjs/api/errors.js +80 -0
  49. package/dist/cjs/api/errors.js.map +7 -0
  50. package/dist/cjs/api/generated.d.ts +2068 -0
  51. package/dist/cjs/api/generated.d.ts.map +1 -0
  52. package/dist/cjs/api/generated.js +17 -0
  53. package/dist/cjs/api/generated.js.map +7 -0
  54. package/dist/cjs/api/http.d.ts +16 -0
  55. package/dist/cjs/api/http.d.ts.map +1 -0
  56. package/dist/cjs/api/http.js +64 -0
  57. package/dist/cjs/api/http.js.map +7 -0
  58. package/dist/cjs/api/index.d.ts +14 -0
  59. package/dist/cjs/api/index.d.ts.map +1 -0
  60. package/dist/cjs/api/index.js +73 -0
  61. package/dist/cjs/api/index.js.map +7 -0
  62. package/dist/cjs/api/positionHistory.d.ts +44 -0
  63. package/dist/cjs/api/positionHistory.d.ts.map +1 -0
  64. package/dist/cjs/api/positionHistory.js +131 -0
  65. package/dist/cjs/api/positionHistory.js.map +7 -0
  66. package/dist/cjs/attribution/erc8021.d.ts +9 -0
  67. package/dist/cjs/attribution/erc8021.d.ts.map +1 -0
  68. package/dist/cjs/attribution/erc8021.js +37 -0
  69. package/dist/cjs/attribution/erc8021.js.map +7 -0
  70. package/dist/cjs/attribution/index.d.ts +25 -0
  71. package/dist/cjs/attribution/index.d.ts.map +1 -0
  72. package/dist/cjs/attribution/index.js +68 -0
  73. package/dist/cjs/attribution/index.js.map +7 -0
  74. package/dist/cjs/client.d.ts +72 -0
  75. package/dist/cjs/client.d.ts.map +1 -0
  76. package/dist/cjs/client.js +80 -0
  77. package/dist/cjs/client.js.map +7 -0
  78. package/dist/cjs/constants.d.ts +16 -0
  79. package/dist/cjs/constants.d.ts.map +1 -0
  80. package/dist/cjs/constants.js +83 -0
  81. package/dist/cjs/constants.js.map +7 -0
  82. package/dist/cjs/errors.d.ts +85 -0
  83. package/dist/cjs/errors.d.ts.map +1 -0
  84. package/dist/cjs/errors.js +210 -0
  85. package/dist/cjs/errors.js.map +7 -0
  86. package/dist/cjs/evm/abis/erc20.d.ts +41 -0
  87. package/dist/cjs/evm/abis/erc20.d.ts.map +1 -0
  88. package/dist/cjs/evm/abis/erc20.js +57 -0
  89. package/dist/cjs/evm/abis/erc20.js.map +7 -0
  90. package/dist/cjs/evm/abis/erc4626.d.ts +105 -0
  91. package/dist/cjs/evm/abis/erc4626.d.ts.map +1 -0
  92. package/dist/cjs/evm/abis/erc4626.js +97 -0
  93. package/dist/cjs/evm/abis/erc4626.js.map +7 -0
  94. package/dist/cjs/evm/abis/multiDepositorVault.d.ts +1048 -0
  95. package/dist/cjs/evm/abis/multiDepositorVault.d.ts.map +1 -0
  96. package/dist/cjs/evm/abis/multiDepositorVault.js +614 -0
  97. package/dist/cjs/evm/abis/multiDepositorVault.js.map +7 -0
  98. package/dist/cjs/evm/abis/priceAndFeeCalculator.d.ts +910 -0
  99. package/dist/cjs/evm/abis/priceAndFeeCalculator.d.ts.map +1 -0
  100. package/dist/cjs/evm/abis/priceAndFeeCalculator.js +517 -0
  101. package/dist/cjs/evm/abis/priceAndFeeCalculator.js.map +7 -0
  102. package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.d.ts +277 -0
  103. package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.d.ts.map +1 -0
  104. package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.js +166 -0
  105. package/dist/cjs/evm/abis/priceAndFeeCalculatorV2.js.map +7 -0
  106. package/dist/cjs/evm/abis/provisioner.d.ts +4984 -0
  107. package/dist/cjs/evm/abis/provisioner.d.ts.map +1 -0
  108. package/dist/cjs/evm/abis/provisioner.js +2785 -0
  109. package/dist/cjs/evm/abis/provisioner.js.map +7 -0
  110. package/dist/cjs/evm/abis/provisionerV2.d.ts +740 -0
  111. package/dist/cjs/evm/abis/provisionerV2.d.ts.map +1 -0
  112. package/dist/cjs/evm/abis/provisionerV2.js +320 -0
  113. package/dist/cjs/evm/abis/provisionerV2.js.map +7 -0
  114. package/dist/cjs/evm/adapters/aera.d.ts +6 -0
  115. package/dist/cjs/evm/adapters/aera.d.ts.map +1 -0
  116. package/dist/cjs/evm/adapters/aera.js +491 -0
  117. package/dist/cjs/evm/adapters/aera.js.map +7 -0
  118. package/dist/cjs/evm/adapters/index.d.ts +3 -0
  119. package/dist/cjs/evm/adapters/index.d.ts.map +1 -0
  120. package/dist/cjs/evm/adapters/index.js +41 -0
  121. package/dist/cjs/evm/adapters/index.js.map +7 -0
  122. package/dist/cjs/evm/adapters/morpho.d.ts +3 -0
  123. package/dist/cjs/evm/adapters/morpho.d.ts.map +1 -0
  124. package/dist/cjs/evm/adapters/morpho.js +103 -0
  125. package/dist/cjs/evm/adapters/morpho.js.map +7 -0
  126. package/dist/cjs/evm/adapters/types.d.ts +84 -0
  127. package/dist/cjs/evm/adapters/types.d.ts.map +1 -0
  128. package/dist/cjs/evm/adapters/types.js +17 -0
  129. package/dist/cjs/evm/adapters/types.js.map +7 -0
  130. package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.d.ts +46 -0
  131. package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.d.ts.map +1 -0
  132. package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.js +223 -0
  133. package/dist/cjs/evm/aeraContracts/priceAndFeeCalculator.js.map +7 -0
  134. package/dist/cjs/evm/aeraContracts/readOptions.d.ts +8 -0
  135. package/dist/cjs/evm/aeraContracts/readOptions.d.ts.map +1 -0
  136. package/dist/cjs/evm/aeraContracts/readOptions.js +31 -0
  137. package/dist/cjs/evm/aeraContracts/readOptions.js.map +7 -0
  138. package/dist/cjs/evm/aeraContracts/v1.d.ts +2317 -0
  139. package/dist/cjs/evm/aeraContracts/v1.d.ts.map +1 -0
  140. package/dist/cjs/evm/aeraContracts/v1.js +120 -0
  141. package/dist/cjs/evm/aeraContracts/v1.js.map +7 -0
  142. package/dist/cjs/evm/aeraContracts/v2.d.ts +4538 -0
  143. package/dist/cjs/evm/aeraContracts/v2.d.ts.map +1 -0
  144. package/dist/cjs/evm/aeraContracts/v2.js +449 -0
  145. package/dist/cjs/evm/aeraContracts/v2.js.map +7 -0
  146. package/dist/cjs/evm/aeraContracts.d.ts +33 -0
  147. package/dist/cjs/evm/aeraContracts.d.ts.map +1 -0
  148. package/dist/cjs/evm/aeraContracts.js +224 -0
  149. package/dist/cjs/evm/aeraContracts.js.map +7 -0
  150. package/dist/cjs/evm/deposit.d.ts +50 -0
  151. package/dist/cjs/evm/deposit.d.ts.map +1 -0
  152. package/dist/cjs/evm/deposit.js +112 -0
  153. package/dist/cjs/evm/deposit.js.map +7 -0
  154. package/dist/cjs/evm/depositQuote.d.ts +32 -0
  155. package/dist/cjs/evm/depositQuote.d.ts.map +1 -0
  156. package/dist/cjs/evm/depositQuote.js +96 -0
  157. package/dist/cjs/evm/depositQuote.js.map +7 -0
  158. package/dist/cjs/evm/depositReceiverApproval.d.ts +17 -0
  159. package/dist/cjs/evm/depositReceiverApproval.d.ts.map +1 -0
  160. package/dist/cjs/evm/depositReceiverApproval.js +66 -0
  161. package/dist/cjs/evm/depositReceiverApproval.js.map +7 -0
  162. package/dist/cjs/evm/index.d.ts +28 -0
  163. package/dist/cjs/evm/index.d.ts.map +1 -0
  164. package/dist/cjs/evm/index.js +116 -0
  165. package/dist/cjs/evm/index.js.map +7 -0
  166. package/dist/cjs/evm/operationMode.d.ts +9 -0
  167. package/dist/cjs/evm/operationMode.d.ts.map +1 -0
  168. package/dist/cjs/evm/operationMode.js +65 -0
  169. package/dist/cjs/evm/operationMode.js.map +7 -0
  170. package/dist/cjs/evm/tokenModes.d.ts +22 -0
  171. package/dist/cjs/evm/tokenModes.d.ts.map +1 -0
  172. package/dist/cjs/evm/tokenModes.js +47 -0
  173. package/dist/cjs/evm/tokenModes.js.map +7 -0
  174. package/dist/cjs/evm/types.d.ts +34 -0
  175. package/dist/cjs/evm/types.d.ts.map +1 -0
  176. package/dist/cjs/evm/types.js +32 -0
  177. package/dist/cjs/evm/types.js.map +7 -0
  178. package/dist/cjs/evm/userCurrentBalance.d.ts +55 -0
  179. package/dist/cjs/evm/userCurrentBalance.d.ts.map +1 -0
  180. package/dist/cjs/evm/userCurrentBalance.js +225 -0
  181. package/dist/cjs/evm/userCurrentBalance.js.map +7 -0
  182. package/dist/cjs/evm/vaults.d.ts +44 -0
  183. package/dist/cjs/evm/vaults.d.ts.map +1 -0
  184. package/dist/cjs/evm/vaults.js +78 -0
  185. package/dist/cjs/evm/vaults.js.map +7 -0
  186. package/dist/cjs/evm/withdraw.d.ts +73 -0
  187. package/dist/cjs/evm/withdraw.d.ts.map +1 -0
  188. package/dist/cjs/evm/withdraw.js +161 -0
  189. package/dist/cjs/evm/withdraw.js.map +7 -0
  190. package/dist/cjs/evm/withdrawQuote.d.ts +135 -0
  191. package/dist/cjs/evm/withdrawQuote.d.ts.map +1 -0
  192. package/dist/cjs/evm/withdrawQuote.js +256 -0
  193. package/dist/cjs/evm/withdrawQuote.js.map +7 -0
  194. package/dist/cjs/index.d.ts +31 -0
  195. package/dist/cjs/index.d.ts.map +1 -0
  196. package/dist/cjs/index.js +128 -0
  197. package/dist/cjs/index.js.map +7 -0
  198. package/dist/cjs/package.json +1 -0
  199. package/dist/cjs/privy/index.d.ts +52 -0
  200. package/dist/cjs/privy/index.d.ts.map +1 -0
  201. package/dist/cjs/privy/index.js +57 -0
  202. package/dist/cjs/privy/index.js.map +7 -0
  203. package/dist/client.d.ts +4 -2
  204. package/dist/client.d.ts.map +1 -1
  205. package/dist/constants.d.ts.map +1 -1
  206. package/dist/errors.d.ts +4 -1
  207. package/dist/errors.d.ts.map +1 -1
  208. package/dist/evm/adapters/aera.d.ts +1 -1
  209. package/dist/evm/adapters/aera.d.ts.map +1 -1
  210. package/dist/evm/adapters/index.d.ts +1 -1
  211. package/dist/evm/adapters/index.d.ts.map +1 -1
  212. package/dist/evm/adapters/morpho.d.ts +1 -1
  213. package/dist/evm/adapters/morpho.d.ts.map +1 -1
  214. package/dist/evm/adapters/types.d.ts +5 -3
  215. package/dist/evm/adapters/types.d.ts.map +1 -1
  216. package/dist/evm/aeraContracts/priceAndFeeCalculator.d.ts +1 -1
  217. package/dist/evm/aeraContracts/priceAndFeeCalculator.d.ts.map +1 -1
  218. package/dist/evm/aeraContracts/v1.d.ts +2 -2
  219. package/dist/evm/aeraContracts/v1.d.ts.map +1 -1
  220. package/dist/evm/aeraContracts/v2.d.ts +25 -4
  221. package/dist/evm/aeraContracts/v2.d.ts.map +1 -1
  222. package/dist/evm/aeraContracts.d.ts +2 -2
  223. package/dist/evm/aeraContracts.d.ts.map +1 -1
  224. package/dist/evm/deposit.d.ts +4 -2
  225. package/dist/evm/deposit.d.ts.map +1 -1
  226. package/dist/evm/depositQuote.d.ts +32 -0
  227. package/dist/evm/depositQuote.d.ts.map +1 -0
  228. package/dist/evm/depositReceiverApproval.d.ts +2 -2
  229. package/dist/evm/depositReceiverApproval.d.ts.map +1 -1
  230. package/dist/evm/index.d.ts +27 -25
  231. package/dist/evm/index.d.ts.map +1 -1
  232. package/dist/evm/index.js +88 -12
  233. package/dist/evm/index.js.map +7 -1
  234. package/dist/evm/tokenModes.d.ts +2 -2
  235. package/dist/evm/tokenModes.d.ts.map +1 -1
  236. package/dist/evm/userCurrentBalance.d.ts +6 -2
  237. package/dist/evm/userCurrentBalance.d.ts.map +1 -1
  238. package/dist/evm/vaults.d.ts +2 -9
  239. package/dist/evm/vaults.d.ts.map +1 -1
  240. package/dist/evm/withdraw.d.ts +3 -3
  241. package/dist/evm/withdraw.d.ts.map +1 -1
  242. package/dist/evm/withdrawQuote.d.ts +14 -6
  243. package/dist/evm/withdrawQuote.d.ts.map +1 -1
  244. package/dist/index.d.ts +30 -28
  245. package/dist/index.d.ts.map +1 -1
  246. package/dist/index.js +139 -14
  247. package/dist/index.js.map +7 -1
  248. package/dist/manifest/vaults.json +1958 -0
  249. package/dist/privy/index.d.ts +1 -1
  250. package/dist/privy/index.d.ts.map +1 -1
  251. package/dist/privy/index.js +39 -48
  252. package/dist/privy/index.js.map +7 -1
  253. package/manifest/vaults.json +22 -395
  254. package/package.json +43 -9
  255. package/src/api/client.ts +69 -5
  256. package/src/api/generated.ts +570 -7
  257. package/src/api/index.ts +8 -0
  258. package/src/client.ts +4 -1
  259. package/src/constants.ts +2 -0
  260. package/src/errors.ts +7 -0
  261. package/src/evm/adapters/aera.ts +14 -11
  262. package/src/evm/adapters/types.ts +2 -0
  263. package/src/evm/aeraContracts/v2.ts +124 -16
  264. package/src/evm/deposit.ts +19 -7
  265. package/src/evm/depositQuote.ts +137 -0
  266. package/src/evm/index.ts +10 -1
  267. package/src/evm/userCurrentBalance.ts +12 -1
  268. package/src/evm/vaults.ts +0 -7
  269. package/src/evm/withdrawQuote.ts +125 -51
  270. package/src/index.ts +11 -2
  271. package/dist/api/activity.js +0 -154
  272. package/dist/api/activity.js.map +0 -1
  273. package/dist/api/caip.js +0 -38
  274. package/dist/api/caip.js.map +0 -1
  275. package/dist/api/client.js +0 -119
  276. package/dist/api/client.js.map +0 -1
  277. package/dist/api/decimal.js +0 -44
  278. package/dist/api/decimal.js.map +0 -1
  279. package/dist/api/errors.js +0 -41
  280. package/dist/api/errors.js.map +0 -1
  281. package/dist/api/generated.js +0 -6
  282. package/dist/api/generated.js.map +0 -1
  283. package/dist/api/http.js +0 -39
  284. package/dist/api/http.js.map +0 -1
  285. package/dist/api/positionHistory.js +0 -126
  286. package/dist/api/positionHistory.js.map +0 -1
  287. package/dist/attribution/erc8021.js +0 -17
  288. package/dist/attribution/erc8021.js.map +0 -1
  289. package/dist/attribution/index.js +0 -45
  290. package/dist/attribution/index.js.map +0 -1
  291. package/dist/client.js +0 -72
  292. package/dist/client.js.map +0 -1
  293. package/dist/constants.js +0 -28
  294. package/dist/constants.js.map +0 -1
  295. package/dist/errors.js +0 -134
  296. package/dist/errors.js.map +0 -1
  297. package/dist/evm/abis/erc20.js +0 -30
  298. package/dist/evm/abis/erc20.js.map +0 -1
  299. package/dist/evm/abis/erc4626.js +0 -70
  300. package/dist/evm/abis/erc4626.js.map +0 -1
  301. package/dist/evm/abis/multiDepositorVault.js +0 -587
  302. package/dist/evm/abis/multiDepositorVault.js.map +0 -1
  303. package/dist/evm/abis/priceAndFeeCalculator.js +0 -490
  304. package/dist/evm/abis/priceAndFeeCalculator.js.map +0 -1
  305. package/dist/evm/abis/priceAndFeeCalculatorV2.js +0 -141
  306. package/dist/evm/abis/priceAndFeeCalculatorV2.js.map +0 -1
  307. package/dist/evm/abis/provisioner.js +0 -2768
  308. package/dist/evm/abis/provisioner.js.map +0 -1
  309. package/dist/evm/abis/provisionerV2.js +0 -295
  310. package/dist/evm/abis/provisionerV2.js.map +0 -1
  311. package/dist/evm/adapters/aera.js +0 -280
  312. package/dist/evm/adapters/aera.js.map +0 -1
  313. package/dist/evm/adapters/index.js +0 -14
  314. package/dist/evm/adapters/index.js.map +0 -1
  315. package/dist/evm/adapters/morpho.js +0 -79
  316. package/dist/evm/adapters/morpho.js.map +0 -1
  317. package/dist/evm/adapters/types.js +0 -2
  318. package/dist/evm/adapters/types.js.map +0 -1
  319. package/dist/evm/aeraContracts/priceAndFeeCalculator.js +0 -174
  320. package/dist/evm/aeraContracts/priceAndFeeCalculator.js.map +0 -1
  321. package/dist/evm/aeraContracts/readOptions.js +0 -4
  322. package/dist/evm/aeraContracts/readOptions.js.map +0 -1
  323. package/dist/evm/aeraContracts/v1.js +0 -59
  324. package/dist/evm/aeraContracts/v1.js.map +0 -1
  325. package/dist/evm/aeraContracts/v2.js +0 -273
  326. package/dist/evm/aeraContracts/v2.js.map +0 -1
  327. package/dist/evm/aeraContracts.js +0 -195
  328. package/dist/evm/aeraContracts.js.map +0 -1
  329. package/dist/evm/deposit.js +0 -109
  330. package/dist/evm/deposit.js.map +0 -1
  331. package/dist/evm/depositReceiverApproval.js +0 -32
  332. package/dist/evm/depositReceiverApproval.js.map +0 -1
  333. package/dist/evm/operationMode.js +0 -41
  334. package/dist/evm/operationMode.js.map +0 -1
  335. package/dist/evm/tokenModes.js +0 -34
  336. package/dist/evm/tokenModes.js.map +0 -1
  337. package/dist/evm/types.js +0 -5
  338. package/dist/evm/types.js.map +0 -1
  339. package/dist/evm/userCurrentBalance.js +0 -211
  340. package/dist/evm/userCurrentBalance.js.map +0 -1
  341. package/dist/evm/vaults.js +0 -75
  342. package/dist/evm/vaults.js.map +0 -1
  343. package/dist/evm/withdraw.js +0 -177
  344. package/dist/evm/withdraw.js.map +0 -1
  345. package/dist/evm/withdrawQuote.js +0 -164
  346. package/dist/evm/withdrawQuote.js.map +0 -1
@@ -0,0 +1,4364 @@
1
+ import {
2
+ resolveVault
3
+ } from "./chunk-STIV2CC4.js";
4
+ import {
5
+ AccountMismatchError,
6
+ AccountRequiredError,
7
+ BLOCKS_3_DAYS,
8
+ CHAIN_NAMES,
9
+ ChainMismatchError,
10
+ DAY,
11
+ DEFAULT_BLOCKS_3_DAYS,
12
+ DEFAULT_BPS,
13
+ DEFAULT_MAX_PRICE_AGE,
14
+ DEFAULT_REQUEST_DEADLINE_BUFFER,
15
+ DEFAULT_SOLVER_TIP,
16
+ InvalidSlippageBPSError,
17
+ InvalidSolverTipError,
18
+ InvalidSyncDepositBoundError,
19
+ InvalidWithdrawParamsError,
20
+ LOG_PAGE_SIZE,
21
+ MAX_BPS,
22
+ StalePriceError,
23
+ UnimplementedFeatureError,
24
+ UnsupportedAssetError,
25
+ UnsupportedDepositModeError,
26
+ UnsupportedFeatureError,
27
+ UnsupportedProtocolError,
28
+ VaultNotFoundError,
29
+ requireNonZeroSyncWithdrawBound
30
+ } from "./chunk-HC2BS7MK.js";
31
+
32
+ // src/evm/types.ts
33
+ var ContractVersion = {
34
+ V1: "v1",
35
+ V2: "v2"
36
+ };
37
+
38
+ // src/evm/aeraContracts.ts
39
+ import {
40
+ ContractFunctionExecutionError,
41
+ ContractFunctionRevertedError,
42
+ ContractFunctionZeroDataError,
43
+ getContract,
44
+ zeroAddress
45
+ } from "viem";
46
+
47
+ // src/evm/abis/multiDepositorVault.ts
48
+ var multiDepositorVaultAbi = [
49
+ { type: "constructor", inputs: [], stateMutability: "nonpayable" },
50
+ { type: "fallback", stateMutability: "nonpayable" },
51
+ { type: "receive", stateMutability: "payable" },
52
+ {
53
+ type: "function",
54
+ inputs: [],
55
+ name: "FEE_TOKEN",
56
+ outputs: [{ name: "", internalType: "contract IERC20", type: "address" }],
57
+ stateMutability: "view"
58
+ },
59
+ {
60
+ type: "function",
61
+ inputs: [],
62
+ name: "WHITELIST",
63
+ outputs: [{ name: "", internalType: "contract IWhitelist", type: "address" }],
64
+ stateMutability: "view"
65
+ },
66
+ {
67
+ type: "function",
68
+ inputs: [],
69
+ name: "acceptOwnership",
70
+ outputs: [],
71
+ stateMutability: "nonpayable"
72
+ },
73
+ {
74
+ type: "function",
75
+ inputs: [
76
+ { name: "owner", internalType: "address", type: "address" },
77
+ { name: "spender", internalType: "address", type: "address" }
78
+ ],
79
+ name: "allowance",
80
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
81
+ stateMutability: "view"
82
+ },
83
+ {
84
+ type: "function",
85
+ inputs: [
86
+ { name: "spender", internalType: "address", type: "address" },
87
+ { name: "value", internalType: "uint256", type: "uint256" }
88
+ ],
89
+ name: "approve",
90
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
91
+ stateMutability: "nonpayable"
92
+ },
93
+ {
94
+ type: "function",
95
+ inputs: [],
96
+ name: "authority",
97
+ outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
98
+ stateMutability: "view"
99
+ },
100
+ {
101
+ type: "function",
102
+ inputs: [{ name: "account", internalType: "address", type: "address" }],
103
+ name: "balanceOf",
104
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
105
+ stateMutability: "view"
106
+ },
107
+ {
108
+ type: "function",
109
+ inputs: [],
110
+ name: "beforeTransferHook",
111
+ outputs: [{ name: "", internalType: "contract IBeforeTransferHook", type: "address" }],
112
+ stateMutability: "view"
113
+ },
114
+ {
115
+ type: "function",
116
+ inputs: [{ name: "guardian", internalType: "address", type: "address" }],
117
+ name: "checkGuardianWhitelist",
118
+ outputs: [{ name: "isRemoved", internalType: "bool", type: "bool" }],
119
+ stateMutability: "nonpayable"
120
+ },
121
+ {
122
+ type: "function",
123
+ inputs: [],
124
+ name: "claimFees",
125
+ outputs: [
126
+ { name: "feeRecipientFees", internalType: "uint256", type: "uint256" },
127
+ { name: "protocolFees", internalType: "uint256", type: "uint256" }
128
+ ],
129
+ stateMutability: "nonpayable"
130
+ },
131
+ {
132
+ type: "function",
133
+ inputs: [],
134
+ name: "claimProtocolFees",
135
+ outputs: [{ name: "protocolFees", internalType: "uint256", type: "uint256" }],
136
+ stateMutability: "nonpayable"
137
+ },
138
+ {
139
+ type: "function",
140
+ inputs: [],
141
+ name: "decimals",
142
+ outputs: [{ name: "", internalType: "uint8", type: "uint8" }],
143
+ stateMutability: "view"
144
+ },
145
+ {
146
+ type: "function",
147
+ inputs: [
148
+ { name: "sender", internalType: "address", type: "address" },
149
+ { name: "token", internalType: "contract IERC20", type: "address" },
150
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
151
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
152
+ { name: "recipient", internalType: "address", type: "address" }
153
+ ],
154
+ name: "enter",
155
+ outputs: [],
156
+ stateMutability: "nonpayable"
157
+ },
158
+ {
159
+ type: "function",
160
+ inputs: [
161
+ { name: "sender", internalType: "address", type: "address" },
162
+ { name: "token", internalType: "contract IERC20", type: "address" },
163
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
164
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
165
+ { name: "recipient", internalType: "address", type: "address" }
166
+ ],
167
+ name: "exit",
168
+ outputs: [],
169
+ stateMutability: "nonpayable"
170
+ },
171
+ {
172
+ type: "function",
173
+ inputs: [],
174
+ name: "feeCalculator",
175
+ outputs: [{ name: "", internalType: "contract IFeeCalculator", type: "address" }],
176
+ stateMutability: "view"
177
+ },
178
+ {
179
+ type: "function",
180
+ inputs: [],
181
+ name: "feeRecipient",
182
+ outputs: [{ name: "", internalType: "address", type: "address" }],
183
+ stateMutability: "view"
184
+ },
185
+ {
186
+ type: "function",
187
+ inputs: [],
188
+ name: "getActiveGuardians",
189
+ outputs: [{ name: "", internalType: "address[]", type: "address[]" }],
190
+ stateMutability: "view"
191
+ },
192
+ {
193
+ type: "function",
194
+ inputs: [],
195
+ name: "getCurrentHookCallType",
196
+ outputs: [{ name: "", internalType: "enum HookCallType", type: "uint8" }],
197
+ stateMutability: "view"
198
+ },
199
+ {
200
+ type: "function",
201
+ inputs: [{ name: "guardian", internalType: "address", type: "address" }],
202
+ name: "getGuardianRoot",
203
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
204
+ stateMutability: "view"
205
+ },
206
+ {
207
+ type: "function",
208
+ inputs: [],
209
+ name: "name",
210
+ outputs: [{ name: "", internalType: "string", type: "string" }],
211
+ stateMutability: "view"
212
+ },
213
+ {
214
+ type: "function",
215
+ inputs: [
216
+ { name: "", internalType: "address", type: "address" },
217
+ { name: "", internalType: "address", type: "address" },
218
+ { name: "", internalType: "uint256", type: "uint256" },
219
+ { name: "", internalType: "bytes", type: "bytes" }
220
+ ],
221
+ name: "onERC721Received",
222
+ outputs: [{ name: "", internalType: "bytes4", type: "bytes4" }],
223
+ stateMutability: "pure"
224
+ },
225
+ {
226
+ type: "function",
227
+ inputs: [],
228
+ name: "owner",
229
+ outputs: [{ name: "", internalType: "address", type: "address" }],
230
+ stateMutability: "view"
231
+ },
232
+ { type: "function", inputs: [], name: "pause", outputs: [], stateMutability: "nonpayable" },
233
+ {
234
+ type: "function",
235
+ inputs: [],
236
+ name: "paused",
237
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
238
+ stateMutability: "view"
239
+ },
240
+ {
241
+ type: "function",
242
+ inputs: [],
243
+ name: "pendingOwner",
244
+ outputs: [{ name: "", internalType: "address", type: "address" }],
245
+ stateMutability: "view"
246
+ },
247
+ {
248
+ type: "function",
249
+ inputs: [],
250
+ name: "provisioner",
251
+ outputs: [{ name: "", internalType: "address", type: "address" }],
252
+ stateMutability: "view"
253
+ },
254
+ {
255
+ type: "function",
256
+ inputs: [{ name: "guardian", internalType: "address", type: "address" }],
257
+ name: "removeGuardian",
258
+ outputs: [],
259
+ stateMutability: "nonpayable"
260
+ },
261
+ {
262
+ type: "function",
263
+ inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
264
+ name: "setAuthority",
265
+ outputs: [],
266
+ stateMutability: "nonpayable"
267
+ },
268
+ {
269
+ type: "function",
270
+ inputs: [{ name: "hook", internalType: "contract IBeforeTransferHook", type: "address" }],
271
+ name: "setBeforeTransferHook",
272
+ outputs: [],
273
+ stateMutability: "nonpayable"
274
+ },
275
+ {
276
+ type: "function",
277
+ inputs: [
278
+ { name: "newFeeCalculator", internalType: "contract IFeeCalculator", type: "address" }
279
+ ],
280
+ name: "setFeeCalculator",
281
+ outputs: [],
282
+ stateMutability: "nonpayable"
283
+ },
284
+ {
285
+ type: "function",
286
+ inputs: [{ name: "newFeeRecipient", internalType: "address", type: "address" }],
287
+ name: "setFeeRecipient",
288
+ outputs: [],
289
+ stateMutability: "nonpayable"
290
+ },
291
+ {
292
+ type: "function",
293
+ inputs: [
294
+ { name: "guardian", internalType: "address", type: "address" },
295
+ { name: "root", internalType: "bytes32", type: "bytes32" }
296
+ ],
297
+ name: "setGuardianRoot",
298
+ outputs: [],
299
+ stateMutability: "nonpayable"
300
+ },
301
+ {
302
+ type: "function",
303
+ inputs: [{ name: "provisioner_", internalType: "address", type: "address" }],
304
+ name: "setProvisioner",
305
+ outputs: [],
306
+ stateMutability: "nonpayable"
307
+ },
308
+ {
309
+ type: "function",
310
+ inputs: [{ name: "newSubmitHooks", internalType: "contract ISubmitHooks", type: "address" }],
311
+ name: "setSubmitHooks",
312
+ outputs: [],
313
+ stateMutability: "nonpayable"
314
+ },
315
+ {
316
+ type: "function",
317
+ inputs: [{ name: "data", internalType: "bytes", type: "bytes" }],
318
+ name: "submit",
319
+ outputs: [],
320
+ stateMutability: "nonpayable"
321
+ },
322
+ {
323
+ type: "function",
324
+ inputs: [],
325
+ name: "submitHooks",
326
+ outputs: [{ name: "", internalType: "contract ISubmitHooks", type: "address" }],
327
+ stateMutability: "view"
328
+ },
329
+ {
330
+ type: "function",
331
+ inputs: [],
332
+ name: "symbol",
333
+ outputs: [{ name: "", internalType: "string", type: "string" }],
334
+ stateMutability: "view"
335
+ },
336
+ {
337
+ type: "function",
338
+ inputs: [],
339
+ name: "totalSupply",
340
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
341
+ stateMutability: "view"
342
+ },
343
+ {
344
+ type: "function",
345
+ inputs: [
346
+ { name: "to", internalType: "address", type: "address" },
347
+ { name: "value", internalType: "uint256", type: "uint256" }
348
+ ],
349
+ name: "transfer",
350
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
351
+ stateMutability: "nonpayable"
352
+ },
353
+ {
354
+ type: "function",
355
+ inputs: [
356
+ { name: "from", internalType: "address", type: "address" },
357
+ { name: "to", internalType: "address", type: "address" },
358
+ { name: "value", internalType: "uint256", type: "uint256" }
359
+ ],
360
+ name: "transferFrom",
361
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
362
+ stateMutability: "nonpayable"
363
+ },
364
+ {
365
+ type: "function",
366
+ inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
367
+ name: "transferOwnership",
368
+ outputs: [],
369
+ stateMutability: "nonpayable"
370
+ },
371
+ { type: "function", inputs: [], name: "unpause", outputs: [], stateMutability: "nonpayable" },
372
+ {
373
+ type: "event",
374
+ anonymous: false,
375
+ inputs: [
376
+ { name: "owner", internalType: "address", type: "address", indexed: true },
377
+ { name: "spender", internalType: "address", type: "address", indexed: true },
378
+ { name: "value", internalType: "uint256", type: "uint256", indexed: false }
379
+ ],
380
+ name: "Approval"
381
+ },
382
+ {
383
+ type: "event",
384
+ anonymous: false,
385
+ inputs: [
386
+ { name: "user", internalType: "address", type: "address", indexed: true },
387
+ { name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
388
+ ],
389
+ name: "AuthorityUpdated"
390
+ },
391
+ {
392
+ type: "event",
393
+ anonymous: false,
394
+ inputs: [
395
+ { name: "beforeTransferHook", internalType: "address", type: "address", indexed: true }
396
+ ],
397
+ name: "BeforeTransferHookSet"
398
+ },
399
+ {
400
+ type: "event",
401
+ anonymous: false,
402
+ inputs: [
403
+ { name: "sender", internalType: "address", type: "address", indexed: true },
404
+ { name: "recipient", internalType: "address", type: "address", indexed: true },
405
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
406
+ { name: "tokenAmount", internalType: "uint256", type: "uint256", indexed: false },
407
+ { name: "unitsAmount", internalType: "uint256", type: "uint256", indexed: false }
408
+ ],
409
+ name: "Enter"
410
+ },
411
+ {
412
+ type: "event",
413
+ anonymous: false,
414
+ inputs: [
415
+ { name: "sender", internalType: "address", type: "address", indexed: true },
416
+ { name: "recipient", internalType: "address", type: "address", indexed: true },
417
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
418
+ { name: "tokenAmount", internalType: "uint256", type: "uint256", indexed: false },
419
+ { name: "unitsAmount", internalType: "uint256", type: "uint256", indexed: false }
420
+ ],
421
+ name: "Exit"
422
+ },
423
+ {
424
+ type: "event",
425
+ anonymous: false,
426
+ inputs: [{ name: "newFeeCalculator", internalType: "address", type: "address", indexed: true }],
427
+ name: "FeeCalculatorUpdated"
428
+ },
429
+ {
430
+ type: "event",
431
+ anonymous: false,
432
+ inputs: [{ name: "newFeeRecipient", internalType: "address", type: "address", indexed: true }],
433
+ name: "FeeRecipientUpdated"
434
+ },
435
+ {
436
+ type: "event",
437
+ anonymous: false,
438
+ inputs: [
439
+ { name: "feeRecipient", internalType: "address", type: "address", indexed: true },
440
+ { name: "fees", internalType: "uint256", type: "uint256", indexed: false }
441
+ ],
442
+ name: "FeesClaimed"
443
+ },
444
+ {
445
+ type: "event",
446
+ anonymous: false,
447
+ inputs: [
448
+ { name: "guardian", internalType: "address", type: "address", indexed: true },
449
+ { name: "root", internalType: "bytes32", type: "bytes32", indexed: true }
450
+ ],
451
+ name: "GuardianRootSet"
452
+ },
453
+ {
454
+ type: "event",
455
+ anonymous: false,
456
+ inputs: [
457
+ { name: "previousOwner", internalType: "address", type: "address", indexed: true },
458
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
459
+ ],
460
+ name: "OwnershipTransferStarted"
461
+ },
462
+ {
463
+ type: "event",
464
+ anonymous: false,
465
+ inputs: [
466
+ { name: "user", internalType: "address", type: "address", indexed: true },
467
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
468
+ ],
469
+ name: "OwnershipTransferred"
470
+ },
471
+ {
472
+ type: "event",
473
+ anonymous: false,
474
+ inputs: [{ name: "account", internalType: "address", type: "address", indexed: false }],
475
+ name: "Paused"
476
+ },
477
+ {
478
+ type: "event",
479
+ anonymous: false,
480
+ inputs: [
481
+ { name: "protocolFeeRecipient", internalType: "address", type: "address", indexed: true },
482
+ { name: "protocolEarnedFees", internalType: "uint256", type: "uint256", indexed: false }
483
+ ],
484
+ name: "ProtocolFeesClaimed"
485
+ },
486
+ {
487
+ type: "event",
488
+ anonymous: false,
489
+ inputs: [{ name: "provisioner", internalType: "address", type: "address", indexed: true }],
490
+ name: "ProvisionerSet"
491
+ },
492
+ {
493
+ type: "event",
494
+ anonymous: false,
495
+ inputs: [
496
+ { name: "submitHooksAddress", internalType: "address", type: "address", indexed: true }
497
+ ],
498
+ name: "SubmitHooksSet"
499
+ },
500
+ {
501
+ type: "event",
502
+ anonymous: false,
503
+ inputs: [
504
+ { name: "from", internalType: "address", type: "address", indexed: true },
505
+ { name: "to", internalType: "address", type: "address", indexed: true },
506
+ { name: "value", internalType: "uint256", type: "uint256", indexed: false }
507
+ ],
508
+ name: "Transfer"
509
+ },
510
+ {
511
+ type: "event",
512
+ anonymous: false,
513
+ inputs: [{ name: "account", internalType: "address", type: "address", indexed: false }],
514
+ name: "Unpaused"
515
+ },
516
+ {
517
+ type: "error",
518
+ inputs: [
519
+ { name: "index", internalType: "uint256", type: "uint256" },
520
+ { name: "result", internalType: "bytes", type: "bytes" }
521
+ ],
522
+ name: "Aera__AfterOperationHooksFailed"
523
+ },
524
+ {
525
+ type: "error",
526
+ inputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
527
+ name: "Aera__AfterSubmitHooksFailed"
528
+ },
529
+ {
530
+ type: "error",
531
+ inputs: [
532
+ { name: "token", internalType: "address", type: "address" },
533
+ { name: "spender", internalType: "address", type: "address" }
534
+ ],
535
+ name: "Aera__AllowanceIsNotZero"
536
+ },
537
+ {
538
+ type: "error",
539
+ inputs: [
540
+ { name: "index", internalType: "uint256", type: "uint256" },
541
+ { name: "result", internalType: "bytes", type: "bytes" }
542
+ ],
543
+ name: "Aera__BeforeOperationHooksFailed"
544
+ },
545
+ { type: "error", inputs: [], name: "Aera__BeforeOperationHooksWithConfigurableHooks" },
546
+ {
547
+ type: "error",
548
+ inputs: [{ name: "result", internalType: "bytes", type: "bytes" }],
549
+ name: "Aera__BeforeSubmitHooksFailed"
550
+ },
551
+ { type: "error", inputs: [], name: "Aera__CalldataTooShort" },
552
+ { type: "error", inputs: [], name: "Aera__CallerIsNotAuthOrGuardian" },
553
+ { type: "error", inputs: [], name: "Aera__CallerIsNotFeeRecipient" },
554
+ { type: "error", inputs: [], name: "Aera__CallerIsNotGuardian" },
555
+ { type: "error", inputs: [], name: "Aera__CallerIsNotProtocolFeeRecipient" },
556
+ { type: "error", inputs: [], name: "Aera__CallerIsNotProvisioner" },
557
+ { type: "error", inputs: [], name: "Aera__CopyOffsetOutOfBounds" },
558
+ { type: "error", inputs: [], name: "Aera__ExpectedCallbackNotReceived" },
559
+ { type: "error", inputs: [], name: "Aera__ExtractionNumberTooLarge" },
560
+ { type: "error", inputs: [], name: "Aera__GuardianNotWhitelisted" },
561
+ { type: "error", inputs: [], name: "Aera__InvalidBeforeOperationHooksReturnDataLength" },
562
+ { type: "error", inputs: [], name: "Aera__NoFeesToClaim" },
563
+ { type: "error", inputs: [], name: "Aera__NoResults" },
564
+ { type: "error", inputs: [], name: "Aera__OffsetOutOfBounds" },
565
+ { type: "error", inputs: [], name: "Aera__PasteOffsetOutOfBounds" },
566
+ { type: "error", inputs: [], name: "Aera__ProofVerificationFailed" },
567
+ {
568
+ type: "error",
569
+ inputs: [
570
+ { name: "index", internalType: "uint256", type: "uint256" },
571
+ { name: "result", internalType: "bytes", type: "bytes" }
572
+ ],
573
+ name: "Aera__SubmissionFailed"
574
+ },
575
+ { type: "error", inputs: [], name: "Aera__Unauthorized" },
576
+ { type: "error", inputs: [], name: "Aera__UnauthorizedCallback" },
577
+ { type: "error", inputs: [], name: "Aera__UnitsLocked" },
578
+ { type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
579
+ { type: "error", inputs: [], name: "Aera__ZeroAddressFeeCalculator" },
580
+ { type: "error", inputs: [], name: "Aera__ZeroAddressFeeRecipient" },
581
+ { type: "error", inputs: [], name: "Aera__ZeroAddressFeeToken" },
582
+ { type: "error", inputs: [], name: "Aera__ZeroAddressGuardian" },
583
+ { type: "error", inputs: [], name: "Aera__ZeroAddressMerkleRoot" },
584
+ { type: "error", inputs: [], name: "Aera__ZeroAddressOwner" },
585
+ { type: "error", inputs: [], name: "Aera__ZeroAddressProvisioner" },
586
+ {
587
+ type: "error",
588
+ inputs: [
589
+ { name: "spender", internalType: "address", type: "address" },
590
+ { name: "allowance", internalType: "uint256", type: "uint256" },
591
+ { name: "needed", internalType: "uint256", type: "uint256" }
592
+ ],
593
+ name: "ERC20InsufficientAllowance"
594
+ },
595
+ {
596
+ type: "error",
597
+ inputs: [
598
+ { name: "sender", internalType: "address", type: "address" },
599
+ { name: "balance", internalType: "uint256", type: "uint256" },
600
+ { name: "needed", internalType: "uint256", type: "uint256" }
601
+ ],
602
+ name: "ERC20InsufficientBalance"
603
+ },
604
+ {
605
+ type: "error",
606
+ inputs: [{ name: "approver", internalType: "address", type: "address" }],
607
+ name: "ERC20InvalidApprover"
608
+ },
609
+ {
610
+ type: "error",
611
+ inputs: [{ name: "receiver", internalType: "address", type: "address" }],
612
+ name: "ERC20InvalidReceiver"
613
+ },
614
+ {
615
+ type: "error",
616
+ inputs: [{ name: "sender", internalType: "address", type: "address" }],
617
+ name: "ERC20InvalidSender"
618
+ },
619
+ {
620
+ type: "error",
621
+ inputs: [{ name: "spender", internalType: "address", type: "address" }],
622
+ name: "ERC20InvalidSpender"
623
+ },
624
+ { type: "error", inputs: [], name: "EnforcedPause" },
625
+ { type: "error", inputs: [], name: "ExpectedPause" },
626
+ { type: "error", inputs: [], name: "ReaderNotAtEnd" },
627
+ { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
628
+ {
629
+ type: "error",
630
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
631
+ name: "SafeERC20FailedOperation"
632
+ }
633
+ ];
634
+
635
+ // src/evm/abis/provisioner.ts
636
+ var provisionerAbi = [
637
+ {
638
+ type: "constructor",
639
+ inputs: [
640
+ {
641
+ name: "priceAndFeeCalculator",
642
+ internalType: "contract IPriceAndFeeCalculator",
643
+ type: "address"
644
+ },
645
+ { name: "multiDepositorVault", internalType: "address", type: "address" },
646
+ { name: "owner_", internalType: "address", type: "address" },
647
+ { name: "authority_", internalType: "contract Authority", type: "address" }
648
+ ],
649
+ stateMutability: "nonpayable"
650
+ },
651
+ {
652
+ type: "function",
653
+ inputs: [],
654
+ name: "MULTI_DEPOSITOR_VAULT",
655
+ outputs: [{ name: "", internalType: "address", type: "address" }],
656
+ stateMutability: "view"
657
+ },
658
+ {
659
+ type: "function",
660
+ inputs: [],
661
+ name: "PRICE_FEE_CALCULATOR",
662
+ outputs: [{ name: "", internalType: "contract IPriceAndFeeCalculator", type: "address" }],
663
+ stateMutability: "view"
664
+ },
665
+ {
666
+ type: "function",
667
+ inputs: [],
668
+ name: "acceptOwnership",
669
+ outputs: [],
670
+ stateMutability: "nonpayable"
671
+ },
672
+ {
673
+ type: "function",
674
+ inputs: [{ name: "user", internalType: "address", type: "address" }],
675
+ name: "areUserUnitsLocked",
676
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
677
+ stateMutability: "view"
678
+ },
679
+ {
680
+ type: "function",
681
+ inputs: [{ name: "asyncDepositHash", internalType: "bytes32", type: "bytes32" }],
682
+ name: "asyncDepositHashes",
683
+ outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
684
+ stateMutability: "view"
685
+ },
686
+ {
687
+ type: "function",
688
+ inputs: [{ name: "asyncRedeemHash", internalType: "bytes32", type: "bytes32" }],
689
+ name: "asyncRedeemHashes",
690
+ outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
691
+ stateMutability: "view"
692
+ },
693
+ {
694
+ type: "function",
695
+ inputs: [],
696
+ name: "authority",
697
+ outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
698
+ stateMutability: "view"
699
+ },
700
+ {
701
+ type: "function",
702
+ inputs: [
703
+ { name: "token", internalType: "contract IERC20", type: "address" },
704
+ { name: "tokensIn", internalType: "uint256", type: "uint256" },
705
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256" }
706
+ ],
707
+ name: "deposit",
708
+ outputs: [{ name: "unitsOut", internalType: "uint256", type: "uint256" }],
709
+ stateMutability: "nonpayable"
710
+ },
711
+ {
712
+ type: "function",
713
+ inputs: [],
714
+ name: "depositCap",
715
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
716
+ stateMutability: "view"
717
+ },
718
+ {
719
+ type: "function",
720
+ inputs: [],
721
+ name: "depositRefundTimeout",
722
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
723
+ stateMutability: "view"
724
+ },
725
+ {
726
+ type: "function",
727
+ inputs: [
728
+ { name: "user", internalType: "address", type: "address" },
729
+ { name: "token", internalType: "contract IERC20", type: "address" },
730
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
731
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
732
+ { name: "refundableUntil", internalType: "uint256", type: "uint256" }
733
+ ],
734
+ name: "getDepositHash",
735
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
736
+ stateMutability: "pure"
737
+ },
738
+ {
739
+ type: "function",
740
+ inputs: [
741
+ { name: "token", internalType: "contract IERC20", type: "address" },
742
+ {
743
+ name: "request",
744
+ internalType: "struct Request",
745
+ type: "tuple",
746
+ components: [
747
+ { name: "requestType", internalType: "enum RequestType", type: "uint8" },
748
+ { name: "user", internalType: "address", type: "address" },
749
+ { name: "units", internalType: "uint256", type: "uint256" },
750
+ { name: "tokens", internalType: "uint256", type: "uint256" },
751
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
752
+ { name: "deadline", internalType: "uint256", type: "uint256" },
753
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" }
754
+ ]
755
+ }
756
+ ],
757
+ name: "getRequestHash",
758
+ outputs: [{ name: "", internalType: "bytes32", type: "bytes32" }],
759
+ stateMutability: "pure"
760
+ },
761
+ {
762
+ type: "function",
763
+ inputs: [],
764
+ name: "maxDeposit",
765
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
766
+ stateMutability: "view"
767
+ },
768
+ {
769
+ type: "function",
770
+ inputs: [
771
+ { name: "token", internalType: "contract IERC20", type: "address" },
772
+ { name: "unitsOut", internalType: "uint256", type: "uint256" },
773
+ { name: "maxTokensIn", internalType: "uint256", type: "uint256" }
774
+ ],
775
+ name: "mint",
776
+ outputs: [{ name: "tokensIn", internalType: "uint256", type: "uint256" }],
777
+ stateMutability: "nonpayable"
778
+ },
779
+ {
780
+ type: "function",
781
+ inputs: [],
782
+ name: "owner",
783
+ outputs: [{ name: "", internalType: "address", type: "address" }],
784
+ stateMutability: "view"
785
+ },
786
+ {
787
+ type: "function",
788
+ inputs: [],
789
+ name: "pendingOwner",
790
+ outputs: [{ name: "", internalType: "address", type: "address" }],
791
+ stateMutability: "view"
792
+ },
793
+ {
794
+ type: "function",
795
+ inputs: [
796
+ { name: "sender", internalType: "address", type: "address" },
797
+ { name: "token", internalType: "contract IERC20", type: "address" },
798
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
799
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
800
+ { name: "refundableUntil", internalType: "uint256", type: "uint256" }
801
+ ],
802
+ name: "refundDeposit",
803
+ outputs: [],
804
+ stateMutability: "nonpayable"
805
+ },
806
+ {
807
+ type: "function",
808
+ inputs: [
809
+ { name: "token", internalType: "contract IERC20", type: "address" },
810
+ {
811
+ name: "request",
812
+ internalType: "struct Request",
813
+ type: "tuple",
814
+ components: [
815
+ { name: "requestType", internalType: "enum RequestType", type: "uint8" },
816
+ { name: "user", internalType: "address", type: "address" },
817
+ { name: "units", internalType: "uint256", type: "uint256" },
818
+ { name: "tokens", internalType: "uint256", type: "uint256" },
819
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
820
+ { name: "deadline", internalType: "uint256", type: "uint256" },
821
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" }
822
+ ]
823
+ }
824
+ ],
825
+ name: "refundRequest",
826
+ outputs: [],
827
+ stateMutability: "nonpayable"
828
+ },
829
+ {
830
+ type: "function",
831
+ inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
832
+ name: "removeToken",
833
+ outputs: [],
834
+ stateMutability: "nonpayable"
835
+ },
836
+ {
837
+ type: "function",
838
+ inputs: [
839
+ { name: "token", internalType: "contract IERC20", type: "address" },
840
+ { name: "tokensIn", internalType: "uint256", type: "uint256" },
841
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256" },
842
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
843
+ { name: "deadline", internalType: "uint256", type: "uint256" },
844
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" },
845
+ { name: "isFixedPrice", internalType: "bool", type: "bool" }
846
+ ],
847
+ name: "requestDeposit",
848
+ outputs: [],
849
+ stateMutability: "nonpayable"
850
+ },
851
+ {
852
+ type: "function",
853
+ inputs: [
854
+ { name: "token", internalType: "contract IERC20", type: "address" },
855
+ { name: "unitsIn", internalType: "uint256", type: "uint256" },
856
+ { name: "minTokensOut", internalType: "uint256", type: "uint256" },
857
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
858
+ { name: "deadline", internalType: "uint256", type: "uint256" },
859
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" },
860
+ { name: "isFixedPrice", internalType: "bool", type: "bool" }
861
+ ],
862
+ name: "requestRedeem",
863
+ outputs: [],
864
+ stateMutability: "nonpayable"
865
+ },
866
+ {
867
+ type: "function",
868
+ inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
869
+ name: "setAuthority",
870
+ outputs: [],
871
+ stateMutability: "nonpayable"
872
+ },
873
+ {
874
+ type: "function",
875
+ inputs: [
876
+ { name: "depositCap_", internalType: "uint256", type: "uint256" },
877
+ { name: "depositRefundTimeout_", internalType: "uint256", type: "uint256" }
878
+ ],
879
+ name: "setDepositDetails",
880
+ outputs: [],
881
+ stateMutability: "nonpayable"
882
+ },
883
+ {
884
+ type: "function",
885
+ inputs: [
886
+ { name: "token", internalType: "contract IERC20", type: "address" },
887
+ {
888
+ name: "details",
889
+ internalType: "struct TokenDetails",
890
+ type: "tuple",
891
+ components: [
892
+ { name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
893
+ { name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
894
+ { name: "syncDepositEnabled", internalType: "bool", type: "bool" },
895
+ { name: "depositMultiplier", internalType: "uint16", type: "uint16" },
896
+ { name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
897
+ ]
898
+ }
899
+ ],
900
+ name: "setTokenDetails",
901
+ outputs: [],
902
+ stateMutability: "nonpayable"
903
+ },
904
+ {
905
+ type: "function",
906
+ inputs: [
907
+ { name: "token", internalType: "contract IERC20", type: "address" },
908
+ {
909
+ name: "requests",
910
+ internalType: "struct Request[]",
911
+ type: "tuple[]",
912
+ components: [
913
+ { name: "requestType", internalType: "enum RequestType", type: "uint8" },
914
+ { name: "user", internalType: "address", type: "address" },
915
+ { name: "units", internalType: "uint256", type: "uint256" },
916
+ { name: "tokens", internalType: "uint256", type: "uint256" },
917
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
918
+ { name: "deadline", internalType: "uint256", type: "uint256" },
919
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" }
920
+ ]
921
+ }
922
+ ],
923
+ name: "solveRequestsDirect",
924
+ outputs: [],
925
+ stateMutability: "nonpayable"
926
+ },
927
+ {
928
+ type: "function",
929
+ inputs: [
930
+ { name: "token", internalType: "contract IERC20", type: "address" },
931
+ {
932
+ name: "requests",
933
+ internalType: "struct Request[]",
934
+ type: "tuple[]",
935
+ components: [
936
+ { name: "requestType", internalType: "enum RequestType", type: "uint8" },
937
+ { name: "user", internalType: "address", type: "address" },
938
+ { name: "units", internalType: "uint256", type: "uint256" },
939
+ { name: "tokens", internalType: "uint256", type: "uint256" },
940
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
941
+ { name: "deadline", internalType: "uint256", type: "uint256" },
942
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" }
943
+ ]
944
+ }
945
+ ],
946
+ name: "solveRequestsVault",
947
+ outputs: [],
948
+ stateMutability: "nonpayable"
949
+ },
950
+ {
951
+ type: "function",
952
+ inputs: [{ name: "syncDepositHash", internalType: "bytes32", type: "bytes32" }],
953
+ name: "syncDepositHashes",
954
+ outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
955
+ stateMutability: "view"
956
+ },
957
+ {
958
+ type: "function",
959
+ inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
960
+ name: "tokensDetails",
961
+ outputs: [
962
+ { name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
963
+ { name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
964
+ { name: "syncDepositEnabled", internalType: "bool", type: "bool" },
965
+ { name: "depositMultiplier", internalType: "uint16", type: "uint16" },
966
+ { name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
967
+ ],
968
+ stateMutability: "view"
969
+ },
970
+ {
971
+ type: "function",
972
+ inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
973
+ name: "transferOwnership",
974
+ outputs: [],
975
+ stateMutability: "nonpayable"
976
+ },
977
+ {
978
+ type: "function",
979
+ inputs: [{ name: "user", internalType: "address", type: "address" }],
980
+ name: "userUnitsRefundableUntil",
981
+ outputs: [{ name: "unitsLockedUntil", internalType: "uint256", type: "uint256" }],
982
+ stateMutability: "view"
983
+ },
984
+ {
985
+ type: "event",
986
+ anonymous: false,
987
+ inputs: [
988
+ { name: "index", internalType: "uint256", type: "uint256", indexed: true },
989
+ { name: "amount", internalType: "uint256", type: "uint256", indexed: false },
990
+ { name: "bound", internalType: "uint256", type: "uint256", indexed: false }
991
+ ],
992
+ name: "AmountBoundExceeded"
993
+ },
994
+ {
995
+ type: "event",
996
+ anonymous: false,
997
+ inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
998
+ name: "AsyncDepositDisabled"
999
+ },
1000
+ {
1001
+ type: "event",
1002
+ anonymous: false,
1003
+ inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
1004
+ name: "AsyncRedeemDisabled"
1005
+ },
1006
+ {
1007
+ type: "event",
1008
+ anonymous: false,
1009
+ inputs: [
1010
+ { name: "user", internalType: "address", type: "address", indexed: true },
1011
+ { name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
1012
+ ],
1013
+ name: "AuthorityUpdated"
1014
+ },
1015
+ {
1016
+ type: "event",
1017
+ anonymous: false,
1018
+ inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
1019
+ name: "DepositCapExceeded"
1020
+ },
1021
+ {
1022
+ type: "event",
1023
+ anonymous: false,
1024
+ inputs: [
1025
+ { name: "depositCap", internalType: "uint256", type: "uint256", indexed: false },
1026
+ { name: "depositRefundTimeout", internalType: "uint256", type: "uint256", indexed: false }
1027
+ ],
1028
+ name: "DepositDetailsUpdated"
1029
+ },
1030
+ {
1031
+ type: "event",
1032
+ anonymous: false,
1033
+ inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1034
+ name: "DepositRefunded"
1035
+ },
1036
+ {
1037
+ type: "event",
1038
+ anonymous: false,
1039
+ inputs: [
1040
+ { name: "user", internalType: "address", type: "address", indexed: true },
1041
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1042
+ { name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
1043
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256", indexed: false },
1044
+ { name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
1045
+ { name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
1046
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
1047
+ { name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
1048
+ { name: "depositRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
1049
+ ],
1050
+ name: "DepositRequested"
1051
+ },
1052
+ {
1053
+ type: "event",
1054
+ anonymous: false,
1055
+ inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1056
+ name: "DepositSolved"
1057
+ },
1058
+ {
1059
+ type: "event",
1060
+ anonymous: false,
1061
+ inputs: [
1062
+ { name: "user", internalType: "address", type: "address", indexed: true },
1063
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1064
+ { name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
1065
+ { name: "unitsOut", internalType: "uint256", type: "uint256", indexed: false },
1066
+ { name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: false }
1067
+ ],
1068
+ name: "Deposited"
1069
+ },
1070
+ {
1071
+ type: "event",
1072
+ anonymous: false,
1073
+ inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1074
+ name: "DirectDepositRefunded"
1075
+ },
1076
+ {
1077
+ type: "event",
1078
+ anonymous: false,
1079
+ inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
1080
+ name: "InsufficientTokensForTip"
1081
+ },
1082
+ {
1083
+ type: "event",
1084
+ anonymous: false,
1085
+ inputs: [{ name: "depositHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1086
+ name: "InvalidRequestHash"
1087
+ },
1088
+ {
1089
+ type: "event",
1090
+ anonymous: false,
1091
+ inputs: [
1092
+ { name: "previousOwner", internalType: "address", type: "address", indexed: true },
1093
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
1094
+ ],
1095
+ name: "OwnershipTransferStarted"
1096
+ },
1097
+ {
1098
+ type: "event",
1099
+ anonymous: false,
1100
+ inputs: [
1101
+ { name: "user", internalType: "address", type: "address", indexed: true },
1102
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
1103
+ ],
1104
+ name: "OwnershipTransferred"
1105
+ },
1106
+ {
1107
+ type: "event",
1108
+ anonymous: false,
1109
+ inputs: [{ name: "index", internalType: "uint256", type: "uint256", indexed: true }],
1110
+ name: "PriceAgeExceeded"
1111
+ },
1112
+ {
1113
+ type: "event",
1114
+ anonymous: false,
1115
+ inputs: [{ name: "redeemHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1116
+ name: "RedeemRefunded"
1117
+ },
1118
+ {
1119
+ type: "event",
1120
+ anonymous: false,
1121
+ inputs: [
1122
+ { name: "user", internalType: "address", type: "address", indexed: true },
1123
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1124
+ { name: "minTokensOut", internalType: "uint256", type: "uint256", indexed: false },
1125
+ { name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
1126
+ { name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
1127
+ { name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
1128
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
1129
+ { name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
1130
+ { name: "redeemRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
1131
+ ],
1132
+ name: "RedeemRequested"
1133
+ },
1134
+ {
1135
+ type: "event",
1136
+ anonymous: false,
1137
+ inputs: [{ name: "redeemHash", internalType: "bytes32", type: "bytes32", indexed: true }],
1138
+ name: "RedeemSolved"
1139
+ },
1140
+ {
1141
+ type: "event",
1142
+ anonymous: false,
1143
+ inputs: [
1144
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1145
+ {
1146
+ name: "tokensDetails",
1147
+ internalType: "struct TokenDetails",
1148
+ type: "tuple",
1149
+ components: [
1150
+ { name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
1151
+ { name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
1152
+ { name: "syncDepositEnabled", internalType: "bool", type: "bool" },
1153
+ { name: "depositMultiplier", internalType: "uint16", type: "uint16" },
1154
+ { name: "redeemMultiplier", internalType: "uint16", type: "uint16" }
1155
+ ],
1156
+ indexed: false
1157
+ }
1158
+ ],
1159
+ name: "TokenDetailsSet"
1160
+ },
1161
+ {
1162
+ type: "event",
1163
+ anonymous: false,
1164
+ inputs: [{ name: "token", internalType: "contract IERC20", type: "address", indexed: true }],
1165
+ name: "TokenRemoved"
1166
+ },
1167
+ { type: "error", inputs: [], name: "Aera__AsyncDepositDisabled" },
1168
+ { type: "error", inputs: [], name: "Aera__AsyncRedeemDisabled" },
1169
+ { type: "error", inputs: [], name: "Aera__AutoPriceSolveNotAllowed" },
1170
+ { type: "error", inputs: [], name: "Aera__CallerIsVault" },
1171
+ { type: "error", inputs: [], name: "Aera__DeadlineInFutureAndUnauthorized" },
1172
+ { type: "error", inputs: [], name: "Aera__DeadlineInPast" },
1173
+ { type: "error", inputs: [], name: "Aera__DeadlineTooFarInFuture" },
1174
+ { type: "error", inputs: [], name: "Aera__DepositCapExceeded" },
1175
+ { type: "error", inputs: [], name: "Aera__DepositCapZero" },
1176
+ { type: "error", inputs: [], name: "Aera__DepositHashNotFound" },
1177
+ { type: "error", inputs: [], name: "Aera__DepositMultiplierTooHigh" },
1178
+ { type: "error", inputs: [], name: "Aera__DepositMultiplierTooLow" },
1179
+ { type: "error", inputs: [], name: "Aera__FixedPriceSolverTipNotAllowed" },
1180
+ { type: "error", inputs: [], name: "Aera__HashCollision" },
1181
+ { type: "error", inputs: [], name: "Aera__HashNotFound" },
1182
+ { type: "error", inputs: [], name: "Aera__InvalidToken" },
1183
+ { type: "error", inputs: [], name: "Aera__MaxDepositRefundTimeoutExceeded" },
1184
+ { type: "error", inputs: [], name: "Aera__MaxTokensInExceeded" },
1185
+ { type: "error", inputs: [], name: "Aera__MaxTokensInZero" },
1186
+ { type: "error", inputs: [], name: "Aera__MinTokenOutZero" },
1187
+ { type: "error", inputs: [], name: "Aera__MinUnitsOutNotMet" },
1188
+ { type: "error", inputs: [], name: "Aera__MinUnitsOutZero" },
1189
+ { type: "error", inputs: [], name: "Aera__PriceAndFeeCalculatorVaultPaused" },
1190
+ { type: "error", inputs: [], name: "Aera__RedeemMultiplierTooHigh" },
1191
+ { type: "error", inputs: [], name: "Aera__RedeemMultiplierTooLow" },
1192
+ { type: "error", inputs: [], name: "Aera__RefundPeriodExpired" },
1193
+ { type: "error", inputs: [], name: "Aera__SyncDepositDisabled" },
1194
+ { type: "error", inputs: [], name: "Aera__TokenCantBePriced" },
1195
+ { type: "error", inputs: [], name: "Aera__TokensInZero" },
1196
+ { type: "error", inputs: [], name: "Aera__Unauthorized" },
1197
+ { type: "error", inputs: [], name: "Aera__UnitsInZero" },
1198
+ { type: "error", inputs: [], name: "Aera__UnitsOutZero" },
1199
+ { type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
1200
+ { type: "error", inputs: [], name: "Aera__ZeroAddressMultiDepositorVault" },
1201
+ { type: "error", inputs: [], name: "Aera__ZeroAddressPriceAndFeeCalculator" },
1202
+ { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
1203
+ {
1204
+ type: "error",
1205
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
1206
+ name: "SafeERC20FailedOperation"
1207
+ }
1208
+ ];
1209
+
1210
+ // src/evm/abis/provisionerV2.ts
1211
+ var provisionerV2Abi = [
1212
+ {
1213
+ type: "function",
1214
+ inputs: [],
1215
+ name: "SOLVING_GATE_ENABLED",
1216
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
1217
+ stateMutability: "view"
1218
+ },
1219
+ {
1220
+ type: "function",
1221
+ inputs: [
1222
+ { name: "token", internalType: "contract IERC20", type: "address" },
1223
+ { name: "tokensIn", internalType: "uint256", type: "uint256" },
1224
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256" },
1225
+ { name: "receiver", internalType: "address", type: "address" }
1226
+ ],
1227
+ name: "deposit",
1228
+ outputs: [{ name: "unitsOut", internalType: "uint256", type: "uint256" }],
1229
+ stateMutability: "nonpayable"
1230
+ },
1231
+ {
1232
+ type: "function",
1233
+ inputs: [
1234
+ { name: "receiver", internalType: "address", type: "address" },
1235
+ { name: "depositor", internalType: "address", type: "address" }
1236
+ ],
1237
+ name: "depositReceiverApprovals",
1238
+ outputs: [{ name: "approved", internalType: "bool", type: "bool" }],
1239
+ stateMutability: "view"
1240
+ },
1241
+ {
1242
+ type: "function",
1243
+ inputs: [
1244
+ { name: "token", internalType: "contract IERC20", type: "address" },
1245
+ { name: "tokensIn", internalType: "uint256", type: "uint256" },
1246
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256" },
1247
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
1248
+ { name: "deadline", internalType: "uint256", type: "uint256" },
1249
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" },
1250
+ { name: "isFixedPrice", internalType: "bool", type: "bool" },
1251
+ { name: "receiver", internalType: "address", type: "address" }
1252
+ ],
1253
+ name: "requestDeposit",
1254
+ outputs: [{ name: "depositRequestHash", internalType: "bytes32", type: "bytes32" }],
1255
+ stateMutability: "nonpayable"
1256
+ },
1257
+ {
1258
+ type: "function",
1259
+ inputs: [],
1260
+ name: "getSyncRedeemDetails",
1261
+ outputs: [
1262
+ { name: "maxPriceAge", internalType: "uint24", type: "uint24" },
1263
+ { name: "relativeCapBps", internalType: "uint16", type: "uint16" },
1264
+ { name: "maxDynamicPremiumBps", internalType: "uint16", type: "uint16" },
1265
+ { name: "epochTimestamp", internalType: "uint32", type: "uint32" },
1266
+ { name: "absoluteCapNumeraire", internalType: "uint80", type: "uint80" },
1267
+ { name: "epochRedeemedNumeraire", internalType: "uint80", type: "uint80" }
1268
+ ],
1269
+ stateMutability: "view"
1270
+ },
1271
+ {
1272
+ type: "function",
1273
+ inputs: [],
1274
+ name: "getSyncRedeemEpochState",
1275
+ outputs: [
1276
+ { name: "epochTimestamp", internalType: "uint256", type: "uint256" },
1277
+ { name: "epochStartTvlNumeraire", internalType: "uint256", type: "uint256" },
1278
+ { name: "epochRedeemedNumeraire", internalType: "uint256", type: "uint256" },
1279
+ { name: "epochCapNumeraire", internalType: "uint256", type: "uint256" }
1280
+ ],
1281
+ stateMutability: "view"
1282
+ },
1283
+ {
1284
+ type: "function",
1285
+ inputs: [{ name: "user", internalType: "address", type: "address" }],
1286
+ name: "userUnitsRefundableUntil",
1287
+ outputs: [{ name: "unitsLockedUntil", internalType: "uint256", type: "uint256" }],
1288
+ stateMutability: "view"
1289
+ },
1290
+ {
1291
+ type: "function",
1292
+ inputs: [
1293
+ { name: "depositor", internalType: "address", type: "address" },
1294
+ { name: "approved", internalType: "bool", type: "bool" }
1295
+ ],
1296
+ name: "setDepositReceiverApproval",
1297
+ outputs: [],
1298
+ stateMutability: "nonpayable"
1299
+ },
1300
+ {
1301
+ type: "function",
1302
+ inputs: [],
1303
+ name: "solvingGate",
1304
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1305
+ stateMutability: "view"
1306
+ },
1307
+ {
1308
+ type: "function",
1309
+ inputs: [{ name: "token", internalType: "contract IERC20", type: "address" }],
1310
+ name: "tokensDetails",
1311
+ outputs: [
1312
+ { name: "asyncDepositEnabled", internalType: "bool", type: "bool" },
1313
+ { name: "asyncRedeemEnabled", internalType: "bool", type: "bool" },
1314
+ { name: "syncDepositEnabled", internalType: "bool", type: "bool" },
1315
+ { name: "syncRedeemEnabled", internalType: "bool", type: "bool" },
1316
+ { name: "asyncDepositMultiplier", internalType: "uint16", type: "uint16" },
1317
+ { name: "asyncRedeemMultiplier", internalType: "uint16", type: "uint16" },
1318
+ { name: "syncDepositMultiplier", internalType: "uint16", type: "uint16" },
1319
+ { name: "syncRedeemMultiplier", internalType: "uint16", type: "uint16" },
1320
+ {
1321
+ name: "pushFundsSubmitDataPointer",
1322
+ internalType: "address",
1323
+ type: "address"
1324
+ },
1325
+ {
1326
+ name: "pullFundsSubmitDataPointer",
1327
+ internalType: "address",
1328
+ type: "address"
1329
+ }
1330
+ ],
1331
+ stateMutability: "view"
1332
+ },
1333
+ {
1334
+ type: "function",
1335
+ inputs: [
1336
+ { name: "token", internalType: "contract IERC20", type: "address" },
1337
+ { name: "unitsIn", internalType: "uint256", type: "uint256" },
1338
+ { name: "minTokensOut", internalType: "uint256", type: "uint256" },
1339
+ { name: "solverTip", internalType: "uint256", type: "uint256" },
1340
+ { name: "deadline", internalType: "uint256", type: "uint256" },
1341
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256" },
1342
+ { name: "isFixedPrice", internalType: "bool", type: "bool" },
1343
+ { name: "receiver", internalType: "address", type: "address" }
1344
+ ],
1345
+ name: "requestRedeem",
1346
+ outputs: [{ name: "redeemRequestHash", internalType: "bytes32", type: "bytes32" }],
1347
+ stateMutability: "nonpayable"
1348
+ },
1349
+ {
1350
+ type: "function",
1351
+ inputs: [
1352
+ { name: "token", internalType: "contract IERC20", type: "address" },
1353
+ { name: "unitsIn", internalType: "uint256", type: "uint256" },
1354
+ { name: "minTokensOut", internalType: "uint256", type: "uint256" },
1355
+ { name: "receiver", internalType: "address", type: "address" }
1356
+ ],
1357
+ name: "redeem",
1358
+ outputs: [{ name: "tokensOut", internalType: "uint256", type: "uint256" }],
1359
+ stateMutability: "nonpayable"
1360
+ },
1361
+ {
1362
+ type: "function",
1363
+ inputs: [
1364
+ { name: "token", internalType: "contract IERC20", type: "address" },
1365
+ { name: "tokensOut", internalType: "uint256", type: "uint256" },
1366
+ { name: "maxUnitsIn", internalType: "uint256", type: "uint256" },
1367
+ { name: "receiver", internalType: "address", type: "address" }
1368
+ ],
1369
+ name: "withdraw",
1370
+ outputs: [{ name: "unitsIn", internalType: "uint256", type: "uint256" }],
1371
+ stateMutability: "nonpayable"
1372
+ },
1373
+ {
1374
+ type: "function",
1375
+ inputs: [{ name: "asyncRequestHash", internalType: "bytes32", type: "bytes32" }],
1376
+ name: "asyncRequestHashes",
1377
+ outputs: [{ name: "exists", internalType: "bool", type: "bool" }],
1378
+ stateMutability: "view"
1379
+ },
1380
+ {
1381
+ type: "function",
1382
+ inputs: [],
1383
+ name: "version",
1384
+ outputs: [{ name: "", internalType: "string", type: "string" }],
1385
+ stateMutability: "pure"
1386
+ },
1387
+ {
1388
+ type: "event",
1389
+ inputs: [
1390
+ { name: "user", internalType: "address", type: "address", indexed: true },
1391
+ { name: "receiver", internalType: "address", type: "address", indexed: true },
1392
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1393
+ { name: "tokensIn", internalType: "uint256", type: "uint256", indexed: false },
1394
+ { name: "minUnitsOut", internalType: "uint256", type: "uint256", indexed: false },
1395
+ { name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
1396
+ { name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
1397
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
1398
+ { name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
1399
+ { name: "depositRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
1400
+ ],
1401
+ name: "DepositRequested",
1402
+ anonymous: false
1403
+ },
1404
+ {
1405
+ type: "event",
1406
+ inputs: [
1407
+ { name: "receiver", internalType: "address", type: "address", indexed: true },
1408
+ { name: "depositor", internalType: "address", type: "address", indexed: true },
1409
+ { name: "approved", internalType: "bool", type: "bool", indexed: false }
1410
+ ],
1411
+ name: "DepositReceiverApprovalSet",
1412
+ anonymous: false
1413
+ },
1414
+ {
1415
+ type: "event",
1416
+ inputs: [
1417
+ { name: "user", internalType: "address", type: "address", indexed: true },
1418
+ { name: "receiver", internalType: "address", type: "address", indexed: true },
1419
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1420
+ { name: "minTokensOut", internalType: "uint256", type: "uint256", indexed: false },
1421
+ { name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
1422
+ { name: "solverTip", internalType: "uint256", type: "uint256", indexed: false },
1423
+ { name: "deadline", internalType: "uint256", type: "uint256", indexed: false },
1424
+ { name: "maxPriceAge", internalType: "uint256", type: "uint256", indexed: false },
1425
+ { name: "isFixedPrice", internalType: "bool", type: "bool", indexed: false },
1426
+ { name: "redeemRequestHash", internalType: "bytes32", type: "bytes32", indexed: false }
1427
+ ],
1428
+ name: "RedeemRequested",
1429
+ anonymous: false
1430
+ },
1431
+ {
1432
+ type: "event",
1433
+ inputs: [
1434
+ { name: "user", internalType: "address", type: "address", indexed: true },
1435
+ { name: "receiver", internalType: "address", type: "address", indexed: true },
1436
+ { name: "token", internalType: "contract IERC20", type: "address", indexed: true },
1437
+ { name: "unitsIn", internalType: "uint256", type: "uint256", indexed: false },
1438
+ { name: "tokensOut", internalType: "uint256", type: "uint256", indexed: false }
1439
+ ],
1440
+ name: "Redeemed",
1441
+ anonymous: false
1442
+ },
1443
+ { type: "error", inputs: [], name: "Aera__AsyncDepositDisabled" },
1444
+ { type: "error", inputs: [], name: "Aera__AsyncRedeemDisabled" },
1445
+ { type: "error", inputs: [], name: "Aera__AutoPriceSolveNotAllowed" },
1446
+ { type: "error", inputs: [], name: "Aera__CallerIsNotRequestUser" },
1447
+ { type: "error", inputs: [], name: "Aera__CallerIsVault" },
1448
+ { type: "error", inputs: [], name: "Aera__CancellationFeeExceedsRequestAmount" },
1449
+ { type: "error", inputs: [], name: "Aera__DeadlineInFutureAndUnauthorized" },
1450
+ { type: "error", inputs: [], name: "Aera__DeadlineInPast" },
1451
+ { type: "error", inputs: [], name: "Aera__DeadlineTooFarInFuture" },
1452
+ { type: "error", inputs: [], name: "Aera__DepositCancellationDetailsNotZero" },
1453
+ { type: "error", inputs: [], name: "Aera__DepositCapExceeded" },
1454
+ { type: "error", inputs: [], name: "Aera__DepositCapZero" },
1455
+ { type: "error", inputs: [], name: "Aera__DepositHashNotFound" },
1456
+ { type: "error", inputs: [], name: "Aera__DepositRequestCancellationDisabled" },
1457
+ { type: "error", inputs: [], name: "Aera__FixedPriceSolverTipNotAllowed" },
1458
+ { type: "error", inputs: [], name: "Aera__HashCollision" },
1459
+ { type: "error", inputs: [], name: "Aera__HashNotFound" },
1460
+ { type: "error", inputs: [], name: "Aera__InvalidToken" },
1461
+ { type: "error", inputs: [], name: "Aera__MaxDepositRefundTimeoutExceeded" },
1462
+ { type: "error", inputs: [], name: "Aera__MaxTokensInExceeded" },
1463
+ { type: "error", inputs: [], name: "Aera__MaxUnitsInExceeded" },
1464
+ { type: "error", inputs: [], name: "Aera__MinTokensOutNotMet" },
1465
+ { type: "error", inputs: [], name: "Aera__MinUnitsOutNotMet" },
1466
+ { type: "error", inputs: [], name: "Aera__MultiplierOutOfRange" },
1467
+ { type: "error", inputs: [], name: "Aera__PriceAndFeeCalculatorVaultPaused" },
1468
+ { type: "error", inputs: [], name: "Aera__PullFundsSubmitDataNotSet" },
1469
+ { type: "error", inputs: [], name: "Aera__ReceiverNotApproved" },
1470
+ { type: "error", inputs: [], name: "Aera__RedeemCancellationCapNumeraireZero" },
1471
+ { type: "error", inputs: [], name: "Aera__RedeemCancellationDetailsNotZero" },
1472
+ { type: "error", inputs: [], name: "Aera__RedeemRequestCancellationDisabled" },
1473
+ { type: "error", inputs: [], name: "Aera__RefundPeriodExpired" },
1474
+ { type: "error", inputs: [], name: "Aera__RequestAmountExceedsRefundCap" },
1475
+ { type: "error", inputs: [], name: "Aera__SolvingGateDisabled" },
1476
+ { type: "error", inputs: [], name: "Aera__SolvingPaused" },
1477
+ { type: "error", inputs: [], name: "Aera__SyncDepositDisabled" },
1478
+ { type: "error", inputs: [], name: "Aera__SyncRedeemAbsoluteCapNumeraireZero" },
1479
+ { type: "error", inputs: [], name: "Aera__SyncRedeemDisabled" },
1480
+ { type: "error", inputs: [], name: "Aera__SyncRedeemEpochCapExceeded" },
1481
+ { type: "error", inputs: [], name: "Aera__SyncRedeemMaxDynamicPremiumBpsTooHigh" },
1482
+ { type: "error", inputs: [], name: "Aera__SyncRedeemMaxPriceAgeExceeded" },
1483
+ { type: "error", inputs: [], name: "Aera__SyncRedeemMaxPriceAgeZero" },
1484
+ { type: "error", inputs: [], name: "Aera__SyncRedeemNotConfigured" },
1485
+ { type: "error", inputs: [], name: "Aera__SyncRedeemRelativeCapBpsTooHigh" },
1486
+ { type: "error", inputs: [], name: "Aera__SyncRedeemRelativeCapBpsZero" },
1487
+ { type: "error", inputs: [], name: "Aera__TokenCantBePriced" },
1488
+ { type: "error", inputs: [], name: "Aera__TokensZero" },
1489
+ { type: "error", inputs: [], name: "Aera__Unauthorized" },
1490
+ { type: "error", inputs: [], name: "Aera__UnitsLocked" },
1491
+ { type: "error", inputs: [], name: "Aera__UnitsZero" },
1492
+ { type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
1493
+ { type: "error", inputs: [], name: "Aera__ZeroAddressMultiDepositorVault" },
1494
+ { type: "error", inputs: [], name: "Aera__ZeroAddressPriceAndFeeCalculator" },
1495
+ { type: "error", inputs: [], name: "Aera__ZeroAddressReceiver" },
1496
+ { type: "error", inputs: [], name: "ReentrancyGuardReentrantCall" },
1497
+ {
1498
+ type: "error",
1499
+ inputs: [{ name: "token", internalType: "address", type: "address" }],
1500
+ name: "SafeERC20FailedOperation"
1501
+ }
1502
+ ];
1503
+
1504
+ // src/evm/aeraContracts/readOptions.ts
1505
+ function readAtBlock(options = {}) {
1506
+ return options.blockNumber === void 0 ? {} : { blockNumber: options.blockNumber };
1507
+ }
1508
+
1509
+ // src/evm/aeraContracts.ts
1510
+ var contractVersionCache = /* @__PURE__ */ new Map();
1511
+ var contractVersionAbi = [
1512
+ {
1513
+ type: "function",
1514
+ inputs: [],
1515
+ name: "version",
1516
+ outputs: [{ name: "", internalType: "string", type: "string" }],
1517
+ stateMutability: "view"
1518
+ }
1519
+ ];
1520
+ var solvingGateAbi = [
1521
+ {
1522
+ type: "function",
1523
+ inputs: [
1524
+ { name: "provisioner", internalType: "address", type: "address" },
1525
+ { name: "token", internalType: "address", type: "address" }
1526
+ ],
1527
+ name: "paused",
1528
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
1529
+ stateMutability: "view"
1530
+ }
1531
+ ];
1532
+ function requireAeraSyncRedeemRuntime(runtime) {
1533
+ if (runtime.provisioner.version !== ContractVersion.V2) {
1534
+ throw new UnsupportedFeatureError("Aera: sync redeem requires a V2 provisioner");
1535
+ }
1536
+ if (runtime.feeCalculator.version !== ContractVersion.V2) {
1537
+ throw new UnsupportedFeatureError("Aera: sync redeem requires a V2 price and fee calculator");
1538
+ }
1539
+ }
1540
+ function applySlippageDown(amount, slippageBps) {
1541
+ return amount * (MAX_BPS - BigInt(slippageBps)) / MAX_BPS;
1542
+ }
1543
+ function applySlippageUp(amount, slippageBps) {
1544
+ return (amount * (MAX_BPS + BigInt(slippageBps)) + MAX_BPS - 1n) / MAX_BPS;
1545
+ }
1546
+ function contractVersionCacheKey(client, address) {
1547
+ return `${client.chain?.id ?? "unknown"}:${address.toLowerCase()}`;
1548
+ }
1549
+ function isVersionUnavailableError(error) {
1550
+ if (!(error instanceof ContractFunctionExecutionError) || error.functionName !== "version") {
1551
+ return false;
1552
+ }
1553
+ if (error.cause instanceof ContractFunctionRevertedError) {
1554
+ const hasDecodedError = error.cause.signature !== void 0 || error.cause.data !== void 0 || error.cause.raw !== void 0 && error.cause.raw !== "0x";
1555
+ return !hasDecodedError && (error.cause.reason === void 0 || error.cause.reason === "execution reverted");
1556
+ }
1557
+ return error.cause instanceof ContractFunctionZeroDataError;
1558
+ }
1559
+ function getMultiDepositorVault(client, vaultAddress) {
1560
+ return getContract({
1561
+ address: vaultAddress,
1562
+ abi: multiDepositorVaultAbi,
1563
+ client
1564
+ });
1565
+ }
1566
+ async function resolveContractVersion(client, address, options = {}) {
1567
+ const cacheKey = contractVersionCacheKey(client, address);
1568
+ const cached = contractVersionCache.get(cacheKey);
1569
+ if (cached) return cached;
1570
+ try {
1571
+ const versionString = await client.readContract({
1572
+ address,
1573
+ abi: contractVersionAbi,
1574
+ functionName: "version",
1575
+ ...readAtBlock(options)
1576
+ });
1577
+ const version = versionString.startsWith("2.") ? ContractVersion.V2 : ContractVersion.V1;
1578
+ contractVersionCache.set(cacheKey, version);
1579
+ return version;
1580
+ } catch (error) {
1581
+ if (!isVersionUnavailableError(error)) throw error;
1582
+ contractVersionCache.set(cacheKey, ContractVersion.V1);
1583
+ return ContractVersion.V1;
1584
+ }
1585
+ }
1586
+ async function resolveAeraRuntimeContracts(client, vault, options = {}) {
1587
+ if (vault.vaultType !== "multi-depositor") {
1588
+ throw new UnimplementedFeatureError("Aera: single depositor vaults");
1589
+ }
1590
+ const [provisionerAddress, feeCalculatorAddress] = await Promise.all([
1591
+ client.readContract({
1592
+ address: vault.vaultAddress,
1593
+ abi: multiDepositorVaultAbi,
1594
+ functionName: "provisioner",
1595
+ ...readAtBlock(options)
1596
+ }),
1597
+ client.readContract({
1598
+ address: vault.vaultAddress,
1599
+ abi: multiDepositorVaultAbi,
1600
+ functionName: "feeCalculator",
1601
+ ...readAtBlock(options)
1602
+ })
1603
+ ]);
1604
+ if (provisionerAddress === zeroAddress) {
1605
+ throw new UnsupportedFeatureError("Aera: vault without provisioner");
1606
+ }
1607
+ if (feeCalculatorAddress === zeroAddress) {
1608
+ throw new UnsupportedFeatureError("Aera: vault without price and fee calculator");
1609
+ }
1610
+ const [provisionerVersion, feeCalculatorVersion] = await Promise.all([
1611
+ resolveContractVersion(client, provisionerAddress, options),
1612
+ resolveContractVersion(client, feeCalculatorAddress, options)
1613
+ ]);
1614
+ return {
1615
+ provisioner: {
1616
+ address: provisionerAddress,
1617
+ version: provisionerVersion
1618
+ },
1619
+ feeCalculator: {
1620
+ address: feeCalculatorAddress,
1621
+ version: feeCalculatorVersion
1622
+ }
1623
+ };
1624
+ }
1625
+ async function resolveAeraTokenModeSupport(client, runtime, token, options = {}) {
1626
+ if (runtime.provisioner.version === ContractVersion.V2) {
1627
+ const tokenDetailsPromise = client.readContract({
1628
+ address: runtime.provisioner.address,
1629
+ abi: provisionerV2Abi,
1630
+ functionName: "tokensDetails",
1631
+ args: [token],
1632
+ ...readAtBlock(options)
1633
+ });
1634
+ if (options.includeSyncModes === false) {
1635
+ const tokenDetails3 = await tokenDetailsPromise;
1636
+ return {
1637
+ asyncDeposit: Boolean(tokenDetails3[0]),
1638
+ asyncRedeem: Boolean(tokenDetails3[1]),
1639
+ syncDeposit: false,
1640
+ syncRedeem: false
1641
+ };
1642
+ }
1643
+ const [tokenDetails2, solvingGateEnabled, solvingGate] = await Promise.all([
1644
+ tokenDetailsPromise,
1645
+ client.readContract({
1646
+ address: runtime.provisioner.address,
1647
+ abi: provisionerV2Abi,
1648
+ functionName: "SOLVING_GATE_ENABLED",
1649
+ ...readAtBlock(options)
1650
+ }),
1651
+ client.readContract({
1652
+ address: runtime.provisioner.address,
1653
+ abi: provisionerV2Abi,
1654
+ functionName: "solvingGate",
1655
+ ...readAtBlock(options)
1656
+ })
1657
+ ]);
1658
+ const solvingPaused = solvingGateEnabled && solvingGate !== zeroAddress ? await client.readContract({
1659
+ address: solvingGate,
1660
+ abi: solvingGateAbi,
1661
+ functionName: "paused",
1662
+ args: [runtime.provisioner.address, token],
1663
+ ...readAtBlock(options)
1664
+ }) : false;
1665
+ return {
1666
+ asyncDeposit: Boolean(tokenDetails2[0]),
1667
+ asyncRedeem: Boolean(tokenDetails2[1]),
1668
+ syncDeposit: Boolean(tokenDetails2[2]) && !solvingPaused,
1669
+ syncRedeem: Boolean(tokenDetails2[3]) && !solvingPaused && runtime.feeCalculator.version === ContractVersion.V2
1670
+ };
1671
+ }
1672
+ const tokenDetails = await client.readContract({
1673
+ address: runtime.provisioner.address,
1674
+ abi: provisionerAbi,
1675
+ functionName: "tokensDetails",
1676
+ args: [token],
1677
+ ...readAtBlock(options)
1678
+ });
1679
+ return {
1680
+ asyncDeposit: Boolean(tokenDetails[0]),
1681
+ asyncRedeem: Boolean(tokenDetails[1]),
1682
+ syncDeposit: false,
1683
+ syncRedeem: false
1684
+ };
1685
+ }
1686
+
1687
+ // src/evm/abis/priceAndFeeCalculator.ts
1688
+ var priceAndFeeCalculatorAbi = [
1689
+ {
1690
+ type: "constructor",
1691
+ inputs: [
1692
+ { name: "numeraire", internalType: "contract IERC20", type: "address" },
1693
+ { name: "oracleRegistry", internalType: "contract IOracleRegistry", type: "address" },
1694
+ { name: "owner_", internalType: "address", type: "address" },
1695
+ { name: "authority_", internalType: "contract Authority", type: "address" }
1696
+ ],
1697
+ stateMutability: "nonpayable"
1698
+ },
1699
+ {
1700
+ type: "function",
1701
+ inputs: [],
1702
+ name: "NUMERAIRE",
1703
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1704
+ stateMutability: "view"
1705
+ },
1706
+ {
1707
+ type: "function",
1708
+ inputs: [],
1709
+ name: "ORACLE_REGISTRY",
1710
+ outputs: [{ name: "", internalType: "contract IOracleRegistry", type: "address" }],
1711
+ stateMutability: "view"
1712
+ },
1713
+ {
1714
+ type: "function",
1715
+ inputs: [],
1716
+ name: "acceptOwnership",
1717
+ outputs: [],
1718
+ stateMutability: "nonpayable"
1719
+ },
1720
+ {
1721
+ type: "function",
1722
+ inputs: [],
1723
+ name: "authority",
1724
+ outputs: [{ name: "", internalType: "contract Authority", type: "address" }],
1725
+ stateMutability: "view"
1726
+ },
1727
+ {
1728
+ type: "function",
1729
+ inputs: [{ name: "feeTokenBalance", internalType: "uint256", type: "uint256" }],
1730
+ name: "claimFees",
1731
+ outputs: [
1732
+ { name: "", internalType: "uint256", type: "uint256" },
1733
+ { name: "", internalType: "uint256", type: "uint256" },
1734
+ { name: "", internalType: "address", type: "address" }
1735
+ ],
1736
+ stateMutability: "nonpayable"
1737
+ },
1738
+ {
1739
+ type: "function",
1740
+ inputs: [{ name: "feeTokenBalance", internalType: "uint256", type: "uint256" }],
1741
+ name: "claimProtocolFees",
1742
+ outputs: [
1743
+ { name: "", internalType: "uint256", type: "uint256" },
1744
+ { name: "", internalType: "address", type: "address" }
1745
+ ],
1746
+ stateMutability: "nonpayable"
1747
+ },
1748
+ {
1749
+ type: "function",
1750
+ inputs: [
1751
+ { name: "vault", internalType: "address", type: "address" },
1752
+ { name: "token", internalType: "contract IERC20", type: "address" },
1753
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" }
1754
+ ],
1755
+ name: "convertTokenToUnits",
1756
+ outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
1757
+ stateMutability: "view"
1758
+ },
1759
+ {
1760
+ type: "function",
1761
+ inputs: [
1762
+ { name: "vault", internalType: "address", type: "address" },
1763
+ { name: "token", internalType: "contract IERC20", type: "address" },
1764
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
1765
+ { name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
1766
+ ],
1767
+ name: "convertTokenToUnitsIfActive",
1768
+ outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
1769
+ stateMutability: "view"
1770
+ },
1771
+ {
1772
+ type: "function",
1773
+ inputs: [
1774
+ { name: "vault", internalType: "address", type: "address" },
1775
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" }
1776
+ ],
1777
+ name: "convertUnitsToNumeraire",
1778
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1779
+ stateMutability: "view"
1780
+ },
1781
+ {
1782
+ type: "function",
1783
+ inputs: [
1784
+ { name: "vault", internalType: "address", type: "address" },
1785
+ { name: "token", internalType: "contract IERC20", type: "address" },
1786
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" }
1787
+ ],
1788
+ name: "convertUnitsToToken",
1789
+ outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
1790
+ stateMutability: "view"
1791
+ },
1792
+ {
1793
+ type: "function",
1794
+ inputs: [
1795
+ { name: "vault", internalType: "address", type: "address" },
1796
+ { name: "token", internalType: "contract IERC20", type: "address" },
1797
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
1798
+ { name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
1799
+ ],
1800
+ name: "convertUnitsToTokenIfActive",
1801
+ outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
1802
+ stateMutability: "view"
1803
+ },
1804
+ {
1805
+ type: "function",
1806
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
1807
+ name: "getVaultState",
1808
+ outputs: [
1809
+ {
1810
+ name: "",
1811
+ internalType: "struct VaultPriceState",
1812
+ type: "tuple",
1813
+ components: [
1814
+ { name: "paused", internalType: "bool", type: "bool" },
1815
+ { name: "maxPriceAge", internalType: "uint8", type: "uint8" },
1816
+ { name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
1817
+ { name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
1818
+ { name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
1819
+ { name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" },
1820
+ { name: "timestamp", internalType: "uint32", type: "uint32" },
1821
+ { name: "accrualLag", internalType: "uint24", type: "uint24" },
1822
+ { name: "unitPrice", internalType: "uint128", type: "uint128" },
1823
+ { name: "highestPrice", internalType: "uint128", type: "uint128" },
1824
+ { name: "lastTotalSupply", internalType: "uint128", type: "uint128" }
1825
+ ]
1826
+ },
1827
+ {
1828
+ name: "",
1829
+ internalType: "struct VaultAccruals",
1830
+ type: "tuple",
1831
+ components: [
1832
+ {
1833
+ name: "fees",
1834
+ internalType: "struct Fee",
1835
+ type: "tuple",
1836
+ components: [
1837
+ { name: "tvl", internalType: "uint16", type: "uint16" },
1838
+ { name: "performance", internalType: "uint16", type: "uint16" }
1839
+ ]
1840
+ },
1841
+ { name: "accruedFees", internalType: "uint112", type: "uint112" },
1842
+ { name: "accruedProtocolFees", internalType: "uint112", type: "uint112" }
1843
+ ]
1844
+ }
1845
+ ],
1846
+ stateMutability: "view"
1847
+ },
1848
+ {
1849
+ type: "function",
1850
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
1851
+ name: "getVaultsPriceAge",
1852
+ outputs: [{ name: "", internalType: "uint256", type: "uint256" }],
1853
+ stateMutability: "view"
1854
+ },
1855
+ {
1856
+ type: "function",
1857
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
1858
+ name: "isVaultPaused",
1859
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
1860
+ stateMutability: "view"
1861
+ },
1862
+ {
1863
+ type: "function",
1864
+ inputs: [],
1865
+ name: "owner",
1866
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1867
+ stateMutability: "view"
1868
+ },
1869
+ {
1870
+ type: "function",
1871
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
1872
+ name: "pauseVault",
1873
+ outputs: [],
1874
+ stateMutability: "nonpayable"
1875
+ },
1876
+ {
1877
+ type: "function",
1878
+ inputs: [],
1879
+ name: "pendingOwner",
1880
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1881
+ stateMutability: "view"
1882
+ },
1883
+ {
1884
+ type: "function",
1885
+ inputs: [
1886
+ { name: "vault", internalType: "address", type: "address" },
1887
+ { name: "feeTokenBalance", internalType: "uint256", type: "uint256" }
1888
+ ],
1889
+ name: "previewFees",
1890
+ outputs: [
1891
+ { name: "", internalType: "uint256", type: "uint256" },
1892
+ { name: "", internalType: "uint256", type: "uint256" }
1893
+ ],
1894
+ stateMutability: "view"
1895
+ },
1896
+ {
1897
+ type: "function",
1898
+ inputs: [],
1899
+ name: "protocolFeeRecipient",
1900
+ outputs: [{ name: "", internalType: "address", type: "address" }],
1901
+ stateMutability: "view"
1902
+ },
1903
+ {
1904
+ type: "function",
1905
+ inputs: [],
1906
+ name: "protocolFees",
1907
+ outputs: [
1908
+ { name: "tvl", internalType: "uint16", type: "uint16" },
1909
+ { name: "performance", internalType: "uint16", type: "uint16" }
1910
+ ],
1911
+ stateMutability: "view"
1912
+ },
1913
+ {
1914
+ type: "function",
1915
+ inputs: [],
1916
+ name: "registerVault",
1917
+ outputs: [],
1918
+ stateMutability: "nonpayable"
1919
+ },
1920
+ {
1921
+ type: "function",
1922
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
1923
+ name: "resetHighestPrice",
1924
+ outputs: [],
1925
+ stateMutability: "nonpayable"
1926
+ },
1927
+ {
1928
+ type: "function",
1929
+ inputs: [{ name: "newAuthority", internalType: "contract Authority", type: "address" }],
1930
+ name: "setAuthority",
1931
+ outputs: [],
1932
+ stateMutability: "nonpayable"
1933
+ },
1934
+ {
1935
+ type: "function",
1936
+ inputs: [
1937
+ { name: "vault", internalType: "address", type: "address" },
1938
+ { name: "price", internalType: "uint128", type: "uint128" },
1939
+ { name: "timestamp", internalType: "uint32", type: "uint32" }
1940
+ ],
1941
+ name: "setInitialPrice",
1942
+ outputs: [],
1943
+ stateMutability: "nonpayable"
1944
+ },
1945
+ {
1946
+ type: "function",
1947
+ inputs: [{ name: "feeRecipient", internalType: "address", type: "address" }],
1948
+ name: "setProtocolFeeRecipient",
1949
+ outputs: [],
1950
+ stateMutability: "nonpayable"
1951
+ },
1952
+ {
1953
+ type: "function",
1954
+ inputs: [
1955
+ { name: "tvl", internalType: "uint16", type: "uint16" },
1956
+ { name: "performance", internalType: "uint16", type: "uint16" }
1957
+ ],
1958
+ name: "setProtocolFees",
1959
+ outputs: [],
1960
+ stateMutability: "nonpayable"
1961
+ },
1962
+ {
1963
+ type: "function",
1964
+ inputs: [
1965
+ { name: "vault", internalType: "address", type: "address" },
1966
+ { name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
1967
+ { name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
1968
+ { name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
1969
+ { name: "maxPriceAge", internalType: "uint8", type: "uint8" },
1970
+ { name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" }
1971
+ ],
1972
+ name: "setThresholds",
1973
+ outputs: [],
1974
+ stateMutability: "nonpayable"
1975
+ },
1976
+ {
1977
+ type: "function",
1978
+ inputs: [
1979
+ { name: "vault", internalType: "address", type: "address" },
1980
+ { name: "price", internalType: "uint128", type: "uint128" },
1981
+ { name: "timestamp", internalType: "uint32", type: "uint32" }
1982
+ ],
1983
+ name: "setUnitPrice",
1984
+ outputs: [],
1985
+ stateMutability: "nonpayable"
1986
+ },
1987
+ {
1988
+ type: "function",
1989
+ inputs: [
1990
+ { name: "vault", internalType: "address", type: "address" },
1991
+ { name: "accountant", internalType: "address", type: "address" }
1992
+ ],
1993
+ name: "setVaultAccountant",
1994
+ outputs: [],
1995
+ stateMutability: "nonpayable"
1996
+ },
1997
+ {
1998
+ type: "function",
1999
+ inputs: [
2000
+ { name: "vault", internalType: "address", type: "address" },
2001
+ { name: "tvl", internalType: "uint16", type: "uint16" },
2002
+ { name: "performance", internalType: "uint16", type: "uint16" }
2003
+ ],
2004
+ name: "setVaultFees",
2005
+ outputs: [],
2006
+ stateMutability: "nonpayable"
2007
+ },
2008
+ {
2009
+ type: "function",
2010
+ inputs: [{ name: "newOwner", internalType: "address", type: "address" }],
2011
+ name: "transferOwnership",
2012
+ outputs: [],
2013
+ stateMutability: "nonpayable"
2014
+ },
2015
+ {
2016
+ type: "function",
2017
+ inputs: [
2018
+ { name: "vault", internalType: "address", type: "address" },
2019
+ { name: "price", internalType: "uint128", type: "uint128" },
2020
+ { name: "timestamp", internalType: "uint32", type: "uint32" }
2021
+ ],
2022
+ name: "unpauseVault",
2023
+ outputs: [],
2024
+ stateMutability: "nonpayable"
2025
+ },
2026
+ {
2027
+ type: "function",
2028
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
2029
+ name: "vaultAccountant",
2030
+ outputs: [{ name: "accountant", internalType: "address", type: "address" }],
2031
+ stateMutability: "view"
2032
+ },
2033
+ {
2034
+ type: "event",
2035
+ anonymous: false,
2036
+ inputs: [
2037
+ { name: "user", internalType: "address", type: "address", indexed: true },
2038
+ { name: "newAuthority", internalType: "contract Authority", type: "address", indexed: true }
2039
+ ],
2040
+ name: "AuthorityUpdated"
2041
+ },
2042
+ {
2043
+ type: "event",
2044
+ anonymous: false,
2045
+ inputs: [
2046
+ { name: "vault", internalType: "address", type: "address", indexed: true },
2047
+ { name: "newHighestPrice", internalType: "uint128", type: "uint128", indexed: false }
2048
+ ],
2049
+ name: "HighestPriceReset"
2050
+ },
2051
+ {
2052
+ type: "event",
2053
+ anonymous: false,
2054
+ inputs: [
2055
+ { name: "previousOwner", internalType: "address", type: "address", indexed: true },
2056
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
2057
+ ],
2058
+ name: "OwnershipTransferStarted"
2059
+ },
2060
+ {
2061
+ type: "event",
2062
+ anonymous: false,
2063
+ inputs: [
2064
+ { name: "user", internalType: "address", type: "address", indexed: true },
2065
+ { name: "newOwner", internalType: "address", type: "address", indexed: true }
2066
+ ],
2067
+ name: "OwnershipTransferred"
2068
+ },
2069
+ {
2070
+ type: "event",
2071
+ anonymous: false,
2072
+ inputs: [{ name: "feeRecipient", internalType: "address", type: "address", indexed: true }],
2073
+ name: "ProtocolFeeRecipientSet"
2074
+ },
2075
+ {
2076
+ type: "event",
2077
+ anonymous: false,
2078
+ inputs: [
2079
+ { name: "tvlFee", internalType: "uint16", type: "uint16", indexed: false },
2080
+ { name: "performanceFee", internalType: "uint16", type: "uint16", indexed: false }
2081
+ ],
2082
+ name: "ProtocolFeesSet"
2083
+ },
2084
+ {
2085
+ type: "event",
2086
+ anonymous: false,
2087
+ inputs: [
2088
+ { name: "vault", internalType: "address", type: "address", indexed: true },
2089
+ { name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16", indexed: false },
2090
+ { name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16", indexed: false },
2091
+ { name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16", indexed: false },
2092
+ { name: "maxPriceAge", internalType: "uint8", type: "uint8", indexed: false }
2093
+ ],
2094
+ name: "ThresholdsSet"
2095
+ },
2096
+ {
2097
+ type: "event",
2098
+ anonymous: false,
2099
+ inputs: [
2100
+ { name: "vault", internalType: "address", type: "address", indexed: true },
2101
+ { name: "price", internalType: "uint128", type: "uint128", indexed: false },
2102
+ { name: "timestamp", internalType: "uint32", type: "uint32", indexed: false }
2103
+ ],
2104
+ name: "UnitPriceUpdated"
2105
+ },
2106
+ {
2107
+ type: "event",
2108
+ anonymous: false,
2109
+ inputs: [
2110
+ { name: "vault", internalType: "address", type: "address", indexed: false },
2111
+ { name: "accountant", internalType: "address", type: "address", indexed: false }
2112
+ ],
2113
+ name: "VaultAccountantSet"
2114
+ },
2115
+ {
2116
+ type: "event",
2117
+ anonymous: false,
2118
+ inputs: [
2119
+ { name: "vault", internalType: "address", type: "address", indexed: true },
2120
+ { name: "tvlFee", internalType: "uint16", type: "uint16", indexed: false },
2121
+ { name: "performanceFee", internalType: "uint16", type: "uint16", indexed: false }
2122
+ ],
2123
+ name: "VaultFeesSet"
2124
+ },
2125
+ {
2126
+ type: "event",
2127
+ anonymous: false,
2128
+ inputs: [
2129
+ { name: "vault", internalType: "address", type: "address", indexed: true },
2130
+ { name: "paused", internalType: "bool", type: "bool", indexed: false }
2131
+ ],
2132
+ name: "VaultPausedChanged"
2133
+ },
2134
+ {
2135
+ type: "event",
2136
+ anonymous: false,
2137
+ inputs: [{ name: "vault", internalType: "address", type: "address", indexed: true }],
2138
+ name: "VaultRegistered"
2139
+ },
2140
+ { type: "error", inputs: [], name: "Aera__CallerIsNotAuthorized" },
2141
+ { type: "error", inputs: [], name: "Aera__CallerIsNotVaultAccountant" },
2142
+ { type: "error", inputs: [], name: "Aera__CallerIsNotVaultOwner" },
2143
+ { type: "error", inputs: [], name: "Aera__CurrentPriceAboveHighestPrice" },
2144
+ { type: "error", inputs: [], name: "Aera__InvalidMaxPriceAge" },
2145
+ { type: "error", inputs: [], name: "Aera__InvalidMaxPriceToleranceRatio" },
2146
+ { type: "error", inputs: [], name: "Aera__InvalidMaxUpdateDelayDays" },
2147
+ { type: "error", inputs: [], name: "Aera__InvalidMinPriceToleranceRatio" },
2148
+ { type: "error", inputs: [], name: "Aera__InvalidPrice" },
2149
+ { type: "error", inputs: [], name: "Aera__PerformanceFeeTooHigh" },
2150
+ { type: "error", inputs: [], name: "Aera__StalePrice" },
2151
+ { type: "error", inputs: [], name: "Aera__ThresholdNotSet" },
2152
+ { type: "error", inputs: [], name: "Aera__TimestampCantBeInFuture" },
2153
+ { type: "error", inputs: [], name: "Aera__TimestampMismatch" },
2154
+ { type: "error", inputs: [], name: "Aera__TimestampMustBeAfterLastUpdate" },
2155
+ { type: "error", inputs: [], name: "Aera__TvlFeeTooHigh" },
2156
+ { type: "error", inputs: [], name: "Aera__Unauthorized" },
2157
+ { type: "error", inputs: [], name: "Aera__UnitPriceMismatch" },
2158
+ { type: "error", inputs: [], name: "Aera__VaultAlreadyInitialized" },
2159
+ { type: "error", inputs: [], name: "Aera__VaultAlreadyRegistered" },
2160
+ { type: "error", inputs: [], name: "Aera__VaultNotInitialized" },
2161
+ { type: "error", inputs: [], name: "Aera__VaultNotPaused" },
2162
+ { type: "error", inputs: [], name: "Aera__VaultNotRegistered" },
2163
+ { type: "error", inputs: [], name: "Aera__VaultPaused" },
2164
+ { type: "error", inputs: [], name: "Aera__ZeroAddressAuthority" },
2165
+ { type: "error", inputs: [], name: "Aera__ZeroAddressNumeraire" },
2166
+ { type: "error", inputs: [], name: "Aera__ZeroAddressOracleRegistry" },
2167
+ { type: "error", inputs: [], name: "Aera__ZeroAddressProtocolFeeRecipient" },
2168
+ {
2169
+ type: "error",
2170
+ inputs: [
2171
+ { name: "bits", internalType: "uint8", type: "uint8" },
2172
+ { name: "value", internalType: "uint256", type: "uint256" }
2173
+ ],
2174
+ name: "SafeCastOverflowedUintDowncast"
2175
+ }
2176
+ ];
2177
+
2178
+ // src/evm/abis/priceAndFeeCalculatorV2.ts
2179
+ var priceAndFeeCalculatorV2Abi = [
2180
+ {
2181
+ type: "function",
2182
+ inputs: [
2183
+ { name: "vault", internalType: "address", type: "address" },
2184
+ { name: "token", internalType: "contract IERC20", type: "address" },
2185
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" }
2186
+ ],
2187
+ name: "convertTokenToUnits",
2188
+ outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
2189
+ stateMutability: "view"
2190
+ },
2191
+ {
2192
+ type: "function",
2193
+ inputs: [
2194
+ { name: "vault", internalType: "address", type: "address" },
2195
+ { name: "token", internalType: "contract IERC20", type: "address" },
2196
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" },
2197
+ { name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
2198
+ ],
2199
+ name: "convertTokenToUnitsIfActive",
2200
+ outputs: [{ name: "unitsAmount", internalType: "uint256", type: "uint256" }],
2201
+ stateMutability: "view"
2202
+ },
2203
+ {
2204
+ type: "function",
2205
+ inputs: [
2206
+ { name: "vault", internalType: "address", type: "address" },
2207
+ { name: "token", internalType: "contract IERC20", type: "address" },
2208
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" }
2209
+ ],
2210
+ name: "convertUnitsToToken",
2211
+ outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
2212
+ stateMutability: "view"
2213
+ },
2214
+ {
2215
+ type: "function",
2216
+ inputs: [
2217
+ { name: "vault", internalType: "address", type: "address" },
2218
+ { name: "token", internalType: "contract IERC20", type: "address" },
2219
+ { name: "unitsAmount", internalType: "uint256", type: "uint256" },
2220
+ { name: "rounding", internalType: "enum Math.Rounding", type: "uint8" }
2221
+ ],
2222
+ name: "convertUnitsToTokenIfActive",
2223
+ outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
2224
+ stateMutability: "view"
2225
+ },
2226
+ {
2227
+ type: "function",
2228
+ inputs: [
2229
+ { name: "vault", internalType: "address", type: "address" },
2230
+ { name: "token", internalType: "contract IERC20", type: "address" },
2231
+ { name: "tokenAmount", internalType: "uint256", type: "uint256" }
2232
+ ],
2233
+ name: "convertTokenToNumeraire",
2234
+ outputs: [{ name: "numeraireAmount", internalType: "uint256", type: "uint256" }],
2235
+ stateMutability: "view"
2236
+ },
2237
+ {
2238
+ type: "function",
2239
+ inputs: [
2240
+ { name: "vault", internalType: "address", type: "address" },
2241
+ { name: "token", internalType: "contract IERC20", type: "address" },
2242
+ { name: "numeraireAmount", internalType: "uint256", type: "uint256" }
2243
+ ],
2244
+ name: "convertNumeraireToToken",
2245
+ outputs: [{ name: "tokenAmount", internalType: "uint256", type: "uint256" }],
2246
+ stateMutability: "view"
2247
+ },
2248
+ {
2249
+ type: "function",
2250
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
2251
+ name: "getAnchorTimestamp",
2252
+ outputs: [{ name: "timestamp", internalType: "uint32", type: "uint32" }],
2253
+ stateMutability: "view"
2254
+ },
2255
+ {
2256
+ type: "function",
2257
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
2258
+ name: "getVaultState",
2259
+ outputs: [
2260
+ {
2261
+ name: "",
2262
+ internalType: "struct VaultPriceStateV2",
2263
+ type: "tuple",
2264
+ components: [
2265
+ { name: "paused", internalType: "bool", type: "bool" },
2266
+ { name: "pauseOnBadAnchorUpdate", internalType: "bool", type: "bool" },
2267
+ { name: "maxPriceAge", internalType: "uint16", type: "uint16" },
2268
+ { name: "minUpdateIntervalMinutes", internalType: "uint16", type: "uint16" },
2269
+ { name: "maxPriceToleranceRatio", internalType: "uint16", type: "uint16" },
2270
+ { name: "minPriceToleranceRatio", internalType: "uint16", type: "uint16" },
2271
+ { name: "maxUpdateDelayDays", internalType: "uint8", type: "uint8" },
2272
+ { name: "accrualLag", internalType: "uint32", type: "uint32" },
2273
+ { name: "anchorTimestamp", internalType: "uint32", type: "uint32" },
2274
+ { name: "driftTimestamp", internalType: "uint32", type: "uint32" },
2275
+ { name: "anchorPrice", internalType: "uint128", type: "uint128" },
2276
+ { name: "driftPrice", internalType: "uint128", type: "uint128" },
2277
+ { name: "highestPrice", internalType: "uint128", type: "uint128" },
2278
+ { name: "lastTotalSupply", internalType: "uint128", type: "uint128" }
2279
+ ]
2280
+ },
2281
+ {
2282
+ name: "",
2283
+ internalType: "struct VaultAccruals",
2284
+ type: "tuple",
2285
+ components: [
2286
+ {
2287
+ name: "fees",
2288
+ internalType: "struct Fee",
2289
+ type: "tuple",
2290
+ components: [
2291
+ { name: "tvl", internalType: "uint16", type: "uint16" },
2292
+ { name: "performance", internalType: "uint16", type: "uint16" }
2293
+ ]
2294
+ },
2295
+ { name: "accruedFees", internalType: "uint112", type: "uint112" },
2296
+ { name: "accruedProtocolFees", internalType: "uint112", type: "uint112" }
2297
+ ]
2298
+ }
2299
+ ],
2300
+ stateMutability: "view"
2301
+ },
2302
+ {
2303
+ type: "function",
2304
+ inputs: [{ name: "vault", internalType: "address", type: "address" }],
2305
+ name: "isVaultPaused",
2306
+ outputs: [{ name: "", internalType: "bool", type: "bool" }],
2307
+ stateMutability: "view"
2308
+ },
2309
+ {
2310
+ type: "function",
2311
+ inputs: [],
2312
+ name: "version",
2313
+ outputs: [{ name: "", internalType: "string", type: "string" }],
2314
+ stateMutability: "pure"
2315
+ }
2316
+ ];
2317
+
2318
+ // src/evm/aeraContracts/priceAndFeeCalculator.ts
2319
+ var ROUNDING_FLOOR = 0;
2320
+ var ROUNDING_CEIL = 1;
2321
+ function toNumber(value) {
2322
+ return typeof value === "bigint" ? Number(value) : value;
2323
+ }
2324
+ function normalizeVaultPriceState(priceState) {
2325
+ if ("unitPrice" in priceState) {
2326
+ return {
2327
+ ...priceState,
2328
+ unitPrice: priceState.unitPrice,
2329
+ timestamp: toNumber(priceState.timestamp)
2330
+ };
2331
+ }
2332
+ const anchorTimestamp = toNumber(priceState.anchorTimestamp);
2333
+ const driftTimestamp = toNumber(priceState.driftTimestamp);
2334
+ const useDriftPrice = driftTimestamp >= anchorTimestamp;
2335
+ return {
2336
+ ...priceState,
2337
+ unitPrice: useDriftPrice ? priceState.driftPrice : priceState.anchorPrice,
2338
+ timestamp: useDriftPrice ? driftTimestamp : anchorTimestamp
2339
+ };
2340
+ }
2341
+ async function convertTokenToUnitsIfActive(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, rounding, options = {}) {
2342
+ if (feeCalculatorVersion === ContractVersion.V2) {
2343
+ return client.readContract({
2344
+ address: feeCalculator,
2345
+ abi: priceAndFeeCalculatorV2Abi,
2346
+ functionName: "convertTokenToUnitsIfActive",
2347
+ args: [vault, token, tokenAmount, rounding],
2348
+ ...readAtBlock(options)
2349
+ });
2350
+ }
2351
+ return client.readContract({
2352
+ address: feeCalculator,
2353
+ abi: priceAndFeeCalculatorAbi,
2354
+ functionName: "convertTokenToUnitsIfActive",
2355
+ args: [vault, token, tokenAmount, rounding],
2356
+ ...readAtBlock(options)
2357
+ });
2358
+ }
2359
+ async function convertUnitsToTokenIfActive(client, feeCalculator, feeCalculatorVersion, vault, token, unitsAmount, rounding, options = {}) {
2360
+ if (feeCalculatorVersion === ContractVersion.V2) {
2361
+ return client.readContract({
2362
+ address: feeCalculator,
2363
+ abi: priceAndFeeCalculatorV2Abi,
2364
+ functionName: "convertUnitsToTokenIfActive",
2365
+ args: [vault, token, unitsAmount, rounding],
2366
+ ...readAtBlock(options)
2367
+ });
2368
+ }
2369
+ return client.readContract({
2370
+ address: feeCalculator,
2371
+ abi: priceAndFeeCalculatorAbi,
2372
+ functionName: "convertUnitsToTokenIfActive",
2373
+ args: [vault, token, unitsAmount, rounding],
2374
+ ...readAtBlock(options)
2375
+ });
2376
+ }
2377
+ async function convertTokenToUnits(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, options = {}) {
2378
+ if (feeCalculatorVersion === ContractVersion.V2) {
2379
+ return client.readContract({
2380
+ address: feeCalculator,
2381
+ abi: priceAndFeeCalculatorV2Abi,
2382
+ functionName: "convertTokenToUnits",
2383
+ args: [vault, token, tokenAmount],
2384
+ ...readAtBlock(options)
2385
+ });
2386
+ }
2387
+ return client.readContract({
2388
+ address: feeCalculator,
2389
+ abi: priceAndFeeCalculatorAbi,
2390
+ functionName: "convertTokenToUnits",
2391
+ args: [vault, token, tokenAmount],
2392
+ ...readAtBlock(options)
2393
+ });
2394
+ }
2395
+ async function convertUnitsToToken(client, feeCalculator, feeCalculatorVersion, vault, token, unitsAmount, options = {}) {
2396
+ if (feeCalculatorVersion === ContractVersion.V2) {
2397
+ return client.readContract({
2398
+ address: feeCalculator,
2399
+ abi: priceAndFeeCalculatorV2Abi,
2400
+ functionName: "convertUnitsToToken",
2401
+ args: [vault, token, unitsAmount],
2402
+ ...readAtBlock(options)
2403
+ });
2404
+ }
2405
+ return client.readContract({
2406
+ address: feeCalculator,
2407
+ abi: priceAndFeeCalculatorAbi,
2408
+ functionName: "convertUnitsToToken",
2409
+ args: [vault, token, unitsAmount],
2410
+ ...readAtBlock(options)
2411
+ });
2412
+ }
2413
+ async function convertTokenToNumeraire(client, feeCalculator, feeCalculatorVersion, vault, token, tokenAmount, options = {}) {
2414
+ if (feeCalculatorVersion !== ContractVersion.V2) {
2415
+ throw new UnsupportedFeatureError(
2416
+ "Aera: numeraire conversion requires V2 price and fee calculator"
2417
+ );
2418
+ }
2419
+ return client.readContract({
2420
+ address: feeCalculator,
2421
+ abi: priceAndFeeCalculatorV2Abi,
2422
+ functionName: "convertTokenToNumeraire",
2423
+ args: [vault, token, tokenAmount],
2424
+ ...readAtBlock(options)
2425
+ });
2426
+ }
2427
+ async function convertNumeraireToToken(client, feeCalculator, feeCalculatorVersion, vault, token, numeraireAmount, options = {}) {
2428
+ if (feeCalculatorVersion !== ContractVersion.V2) {
2429
+ throw new UnsupportedFeatureError(
2430
+ "Aera: numeraire conversion requires V2 price and fee calculator"
2431
+ );
2432
+ }
2433
+ return client.readContract({
2434
+ address: feeCalculator,
2435
+ abi: priceAndFeeCalculatorV2Abi,
2436
+ functionName: "convertNumeraireToToken",
2437
+ args: [vault, token, numeraireAmount],
2438
+ ...readAtBlock(options)
2439
+ });
2440
+ }
2441
+ async function getAnchorTimestamp(client, feeCalculator, feeCalculatorVersion, vault, options = {}) {
2442
+ if (feeCalculatorVersion !== ContractVersion.V2) {
2443
+ throw new UnsupportedFeatureError("Aera: sync redeem requires V2 price and fee calculator");
2444
+ }
2445
+ return client.readContract({
2446
+ address: feeCalculator,
2447
+ abi: priceAndFeeCalculatorV2Abi,
2448
+ functionName: "getAnchorTimestamp",
2449
+ args: [vault],
2450
+ ...readAtBlock(options)
2451
+ });
2452
+ }
2453
+ async function getVaultState(client, feeCalculator, feeCalculatorVersion, vault) {
2454
+ if (feeCalculatorVersion === ContractVersion.V2) {
2455
+ const [priceState2, accruals2] = await client.readContract({
2456
+ address: feeCalculator,
2457
+ abi: priceAndFeeCalculatorV2Abi,
2458
+ functionName: "getVaultState",
2459
+ args: [vault]
2460
+ });
2461
+ return [normalizeVaultPriceState(priceState2), accruals2];
2462
+ }
2463
+ const [priceState, accruals] = await client.readContract({
2464
+ address: feeCalculator,
2465
+ abi: priceAndFeeCalculatorAbi,
2466
+ functionName: "getVaultState",
2467
+ args: [vault]
2468
+ });
2469
+ return [normalizeVaultPriceState(priceState), accruals];
2470
+ }
2471
+ async function isVaultPaused(client, feeCalculator, feeCalculatorVersion, vault) {
2472
+ if (feeCalculatorVersion === ContractVersion.V2) {
2473
+ return client.readContract({
2474
+ address: feeCalculator,
2475
+ abi: priceAndFeeCalculatorV2Abi,
2476
+ functionName: "isVaultPaused",
2477
+ args: [vault]
2478
+ });
2479
+ }
2480
+ return client.readContract({
2481
+ address: feeCalculator,
2482
+ abi: priceAndFeeCalculatorAbi,
2483
+ functionName: "isVaultPaused",
2484
+ args: [vault]
2485
+ });
2486
+ }
2487
+ var Rounding = {
2488
+ Floor: ROUNDING_FLOOR,
2489
+ Ceil: ROUNDING_CEIL
2490
+ };
2491
+
2492
+ // src/evm/abis/erc20.ts
2493
+ var erc20Abi = [
2494
+ {
2495
+ type: "function",
2496
+ name: "approve",
2497
+ inputs: [
2498
+ { name: "spender", type: "address" },
2499
+ { name: "amount", type: "uint256" }
2500
+ ],
2501
+ outputs: [{ type: "bool" }],
2502
+ stateMutability: "nonpayable"
2503
+ },
2504
+ {
2505
+ type: "function",
2506
+ name: "allowance",
2507
+ inputs: [
2508
+ { name: "owner", type: "address" },
2509
+ { name: "spender", type: "address" }
2510
+ ],
2511
+ outputs: [{ type: "uint256" }],
2512
+ stateMutability: "view"
2513
+ },
2514
+ {
2515
+ type: "function",
2516
+ name: "balanceOf",
2517
+ inputs: [{ name: "account", type: "address" }],
2518
+ outputs: [{ type: "uint256" }],
2519
+ stateMutability: "view"
2520
+ }
2521
+ ];
2522
+
2523
+ // src/evm/aeraContracts/v1.ts
2524
+ import {
2525
+ getContract as getContract2
2526
+ } from "viem";
2527
+ function getProvisioner(client, address) {
2528
+ return getContract2({
2529
+ address,
2530
+ abi: provisionerAbi,
2531
+ client
2532
+ });
2533
+ }
2534
+ async function getTokenDetails(client, provisioner, token) {
2535
+ return getProvisioner(client, provisioner).read.tokensDetails([token]);
2536
+ }
2537
+ async function getAsyncDepositUnitsOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
2538
+ const tokenDetails = await getTokenDetails(client, provisioner, token);
2539
+ const depositMultiplier = BigInt(tokenDetails[3]);
2540
+ const adjustedTokensIn = tokensIn * depositMultiplier / MAX_BPS;
2541
+ return convertTokenToUnitsIfActive(
2542
+ client,
2543
+ feeCalculator,
2544
+ feeCalculatorVersion,
2545
+ vault,
2546
+ token,
2547
+ adjustedTokensIn,
2548
+ Rounding.Floor
2549
+ );
2550
+ }
2551
+ async function getAsyncRedeemTokenOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn) {
2552
+ const tokenDetails = await getTokenDetails(client, provisioner, token);
2553
+ const redeemMultiplier = BigInt(tokenDetails[4]);
2554
+ const tokensOut = await convertUnitsToTokenIfActive(
2555
+ client,
2556
+ feeCalculator,
2557
+ feeCalculatorVersion,
2558
+ vault,
2559
+ token,
2560
+ unitsIn,
2561
+ Rounding.Floor
2562
+ );
2563
+ return tokensOut * redeemMultiplier / MAX_BPS;
2564
+ }
2565
+ async function getAsyncWithdrawUnitsIn(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut) {
2566
+ const tokenDetails = await getTokenDetails(client, provisioner, token);
2567
+ const redeemMultiplier = BigInt(tokenDetails[4]);
2568
+ const preMultiplierTokensOut = (tokensOut * MAX_BPS + redeemMultiplier - 1n) / redeemMultiplier;
2569
+ return convertTokenToUnitsIfActive(
2570
+ client,
2571
+ feeCalculator,
2572
+ feeCalculatorVersion,
2573
+ vault,
2574
+ token,
2575
+ preMultiplierTokensOut,
2576
+ Rounding.Ceil
2577
+ );
2578
+ }
2579
+ function requestDepositTxRequest(provisioner, token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice, account) {
2580
+ return {
2581
+ address: provisioner,
2582
+ abi: provisionerAbi,
2583
+ functionName: "requestDeposit",
2584
+ args: [token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice],
2585
+ account
2586
+ };
2587
+ }
2588
+ function requestRedeemTxRequest(provisioner, token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice, account) {
2589
+ return {
2590
+ address: provisioner,
2591
+ abi: provisionerAbi,
2592
+ functionName: "requestRedeem",
2593
+ args: [token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice],
2594
+ account
2595
+ };
2596
+ }
2597
+
2598
+ // src/evm/aeraContracts/v2.ts
2599
+ import {
2600
+ getContract as getContract3,
2601
+ zeroAddress as zeroAddress2
2602
+ } from "viem";
2603
+ async function resolveReadContext(client, options = {}) {
2604
+ if (options.blockNumber !== void 0 && options.blockTimestamp !== void 0) {
2605
+ return { blockNumber: options.blockNumber, blockTimestamp: options.blockTimestamp };
2606
+ }
2607
+ const block = options.blockNumber === void 0 ? await client.getBlock() : await client.getBlock(options);
2608
+ if (block.number === null) {
2609
+ throw new UnsupportedFeatureError("Aera: sync redeem reads require a numbered block");
2610
+ }
2611
+ return {
2612
+ blockNumber: options.blockNumber ?? block.number,
2613
+ blockTimestamp: options.blockTimestamp ?? BigInt(block.timestamp)
2614
+ };
2615
+ }
2616
+ async function getTokenDetails2(client, provisioner, token, options = {}) {
2617
+ return client.readContract({
2618
+ address: provisioner,
2619
+ abi: provisionerV2Abi,
2620
+ functionName: "tokensDetails",
2621
+ args: [token],
2622
+ ...readAtBlock(options)
2623
+ });
2624
+ }
2625
+ async function getKnownSyncRedeemLiquidityTokens(client, vault, token, hasPullFundsSubmitData, options = {}) {
2626
+ if (hasPullFundsSubmitData) return void 0;
2627
+ return client.readContract({
2628
+ address: token,
2629
+ abi: erc20Abi,
2630
+ functionName: "balanceOf",
2631
+ args: [vault],
2632
+ ...readAtBlock(options)
2633
+ });
2634
+ }
2635
+ async function getDepositQuote({
2636
+ client,
2637
+ provisioner,
2638
+ feeCalculator,
2639
+ feeCalculatorVersion,
2640
+ vault,
2641
+ token,
2642
+ tokensIn,
2643
+ multiplierIndex,
2644
+ options
2645
+ }) {
2646
+ const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
2647
+ const multiplierBps = BigInt(tokenDetails[multiplierIndex]);
2648
+ const adjustedTokensIn = tokensIn * multiplierBps / MAX_BPS;
2649
+ const unitsOut = await convertTokenToUnitsIfActive(
2650
+ client,
2651
+ feeCalculator,
2652
+ feeCalculatorVersion,
2653
+ vault,
2654
+ token,
2655
+ adjustedTokensIn,
2656
+ Rounding.Floor,
2657
+ options
2658
+ );
2659
+ return { unitsOut, multiplierBps };
2660
+ }
2661
+ async function getRedeemTokenOut({
2662
+ client,
2663
+ provisioner,
2664
+ feeCalculator,
2665
+ feeCalculatorVersion,
2666
+ vault,
2667
+ token,
2668
+ unitsIn,
2669
+ multiplierIndex,
2670
+ options
2671
+ }) {
2672
+ const [tokenDetails, tokensOut] = await Promise.all([
2673
+ getTokenDetails2(client, provisioner, token, options),
2674
+ convertUnitsToTokenIfActive(
2675
+ client,
2676
+ feeCalculator,
2677
+ feeCalculatorVersion,
2678
+ vault,
2679
+ token,
2680
+ unitsIn,
2681
+ Rounding.Floor,
2682
+ options
2683
+ )
2684
+ ]);
2685
+ const multiplier = BigInt(tokenDetails[multiplierIndex]);
2686
+ return tokensOut * multiplier / MAX_BPS;
2687
+ }
2688
+ async function getWithdrawUnitsIn({
2689
+ client,
2690
+ provisioner,
2691
+ feeCalculator,
2692
+ feeCalculatorVersion,
2693
+ vault,
2694
+ token,
2695
+ tokensOut,
2696
+ multiplierIndex,
2697
+ options
2698
+ }) {
2699
+ const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
2700
+ const multiplier = BigInt(tokenDetails[multiplierIndex]);
2701
+ const preMultiplierTokens = (tokensOut * MAX_BPS + multiplier - 1n) / multiplier;
2702
+ return convertTokenToUnitsIfActive(
2703
+ client,
2704
+ feeCalculator,
2705
+ feeCalculatorVersion,
2706
+ vault,
2707
+ token,
2708
+ preMultiplierTokens,
2709
+ Rounding.Ceil,
2710
+ options
2711
+ );
2712
+ }
2713
+ async function getSyncRedeemRateContext(client, provisioner, vault, token, feeCalculator, options = {}) {
2714
+ const readContext = await resolveReadContext(client, options);
2715
+ const [tokenDetails, syncRedeemDetails, anchorTimestamp] = await client.multicall({
2716
+ contracts: [
2717
+ {
2718
+ address: provisioner,
2719
+ abi: provisionerV2Abi,
2720
+ functionName: "tokensDetails",
2721
+ args: [token]
2722
+ },
2723
+ {
2724
+ address: provisioner,
2725
+ abi: provisionerV2Abi,
2726
+ functionName: "getSyncRedeemDetails"
2727
+ },
2728
+ {
2729
+ address: feeCalculator,
2730
+ abi: priceAndFeeCalculatorV2Abi,
2731
+ functionName: "getAnchorTimestamp",
2732
+ args: [vault]
2733
+ }
2734
+ ],
2735
+ allowFailure: false,
2736
+ blockNumber: readContext.blockNumber
2737
+ });
2738
+ const baseMultiplierBps = BigInt(tokenDetails[7]);
2739
+ const maxPriceAge = BigInt(syncRedeemDetails[0]);
2740
+ const maxDynamicPremiumBps = BigInt(syncRedeemDetails[2]);
2741
+ const blockTimestamp = readContext.blockTimestamp;
2742
+ const priceTimestamp = BigInt(anchorTimestamp);
2743
+ if (priceTimestamp + maxPriceAge < blockTimestamp) {
2744
+ throw new StalePriceError({
2745
+ blockTimestamp,
2746
+ maxPriceAge,
2747
+ priceTimestamp
2748
+ });
2749
+ }
2750
+ const dynamicPremiumBps = maxDynamicPremiumBps === 0n || maxPriceAge === 0n ? 0n : ((blockTimestamp - priceTimestamp) * maxDynamicPremiumBps + maxPriceAge - 1n) / maxPriceAge;
2751
+ return {
2752
+ rate: {
2753
+ baseMultiplierBps,
2754
+ dynamicPremiumBps,
2755
+ effectiveMultiplierBps: baseMultiplierBps - dynamicPremiumBps
2756
+ },
2757
+ hasPullFundsSubmitData: tokenDetails[9] !== zeroAddress2
2758
+ };
2759
+ }
2760
+ async function getSyncRedeemRate(client, provisioner, vault, token, feeCalculator, options = {}) {
2761
+ return (await getSyncRedeemRateContext(client, provisioner, vault, token, feeCalculator, options)).rate;
2762
+ }
2763
+ async function getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, options = {}) {
2764
+ return (await getSyncRedeemRate(client, provisioner, vault, token, feeCalculator, options)).effectiveMultiplierBps;
2765
+ }
2766
+ async function getSyncRedeemTokenOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn, effectiveMultiplierBps, options = {}) {
2767
+ const readContext = effectiveMultiplierBps === void 0 ? await resolveReadContext(client, options) : options;
2768
+ const [tokenAmount, multiplier] = await Promise.all([
2769
+ convertUnitsToTokenIfActive(
2770
+ client,
2771
+ feeCalculator,
2772
+ feeCalculatorVersion,
2773
+ vault,
2774
+ token,
2775
+ unitsIn,
2776
+ Rounding.Floor,
2777
+ readContext
2778
+ ),
2779
+ effectiveMultiplierBps !== void 0 ? Promise.resolve(effectiveMultiplierBps) : getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, readContext)
2780
+ ]);
2781
+ return tokenAmount * multiplier / MAX_BPS;
2782
+ }
2783
+ async function getAsyncDepositUnitsOut2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
2784
+ const quote = await getDepositQuote({
2785
+ client,
2786
+ provisioner,
2787
+ feeCalculator,
2788
+ feeCalculatorVersion,
2789
+ vault,
2790
+ token,
2791
+ tokensIn,
2792
+ multiplierIndex: 4
2793
+ });
2794
+ return quote.unitsOut;
2795
+ }
2796
+ var getSyncDepositQuote = (client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) => getDepositQuote({
2797
+ client,
2798
+ provisioner,
2799
+ feeCalculator,
2800
+ feeCalculatorVersion,
2801
+ vault,
2802
+ token,
2803
+ tokensIn,
2804
+ multiplierIndex: 6
2805
+ });
2806
+ async function getSyncDepositUnitsOut(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
2807
+ const quote = await getSyncDepositQuote(
2808
+ client,
2809
+ provisioner,
2810
+ feeCalculator,
2811
+ feeCalculatorVersion,
2812
+ vault,
2813
+ token,
2814
+ tokensIn
2815
+ );
2816
+ return quote.unitsOut;
2817
+ }
2818
+ async function getSyncDepositQuoteValues(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensIn) {
2819
+ const { unitsOut, multiplierBps } = await getSyncDepositQuote(
2820
+ client,
2821
+ provisioner,
2822
+ feeCalculator,
2823
+ feeCalculatorVersion,
2824
+ vault,
2825
+ token,
2826
+ tokensIn
2827
+ );
2828
+ const numeraireOut = await convertTokenToNumeraire(
2829
+ client,
2830
+ feeCalculator,
2831
+ feeCalculatorVersion,
2832
+ vault,
2833
+ token,
2834
+ tokensIn * multiplierBps / MAX_BPS
2835
+ );
2836
+ return { unitsOut, feeBps: MAX_BPS - multiplierBps, numeraireOut };
2837
+ }
2838
+ async function getSyncDepositFeeBps(client, provisioner, token, options = {}) {
2839
+ const tokenDetails = await getTokenDetails2(client, provisioner, token, options);
2840
+ return MAX_BPS - BigInt(tokenDetails[6]);
2841
+ }
2842
+ async function getAsyncRedeemTokenOut2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, unitsIn) {
2843
+ return getRedeemTokenOut({
2844
+ client,
2845
+ provisioner,
2846
+ feeCalculator,
2847
+ feeCalculatorVersion,
2848
+ vault,
2849
+ token,
2850
+ unitsIn,
2851
+ multiplierIndex: 5
2852
+ });
2853
+ }
2854
+ async function getAsyncWithdrawUnitsIn2(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut) {
2855
+ return getWithdrawUnitsIn({
2856
+ client,
2857
+ provisioner,
2858
+ feeCalculator,
2859
+ feeCalculatorVersion,
2860
+ vault,
2861
+ token,
2862
+ tokensOut,
2863
+ multiplierIndex: 5
2864
+ });
2865
+ }
2866
+ async function getSyncWithdrawUnitsIn(client, provisioner, feeCalculator, feeCalculatorVersion, vault, token, tokensOut, effectiveMultiplierBps, options = {}) {
2867
+ const readContext = effectiveMultiplierBps === void 0 ? await resolveReadContext(client, options) : options;
2868
+ const multiplier = effectiveMultiplierBps ?? await getSyncRedeemMultiplier(client, provisioner, vault, token, feeCalculator, readContext);
2869
+ const prePremiumTokens = (tokensOut * MAX_BPS + multiplier - 1n) / multiplier;
2870
+ return convertTokenToUnitsIfActive(
2871
+ client,
2872
+ feeCalculator,
2873
+ feeCalculatorVersion,
2874
+ vault,
2875
+ token,
2876
+ prePremiumTokens,
2877
+ Rounding.Ceil,
2878
+ readContext
2879
+ );
2880
+ }
2881
+ async function getSyncRedeemEpochState(client, provisioner, options = {}) {
2882
+ const [epochTimestamp, epochStartTvlNumeraire, epochRedeemedNumeraire, epochCapNumeraire] = await client.readContract({
2883
+ address: provisioner,
2884
+ abi: provisionerV2Abi,
2885
+ functionName: "getSyncRedeemEpochState",
2886
+ ...readAtBlock(options)
2887
+ });
2888
+ return { epochTimestamp, epochStartTvlNumeraire, epochRedeemedNumeraire, epochCapNumeraire };
2889
+ }
2890
+ async function getUserUnitsRefundableUntil(client, provisioner, user, options = {}) {
2891
+ return client.readContract({
2892
+ address: provisioner,
2893
+ abi: provisionerV2Abi,
2894
+ functionName: "userUnitsRefundableUntil",
2895
+ args: [user],
2896
+ ...readAtBlock(options)
2897
+ });
2898
+ }
2899
+ function depositTxRequest(provisioner, token, tokensIn, minUnitsOut, receiver, account) {
2900
+ return {
2901
+ address: provisioner,
2902
+ abi: provisionerV2Abi,
2903
+ functionName: "deposit",
2904
+ args: [token, tokensIn, minUnitsOut, receiver],
2905
+ account
2906
+ };
2907
+ }
2908
+ function requestDepositTxRequest2(provisioner, token, tokensIn, minUnitsOut, solverTip, deadline, maxPriceAge, isFixedPrice, receiver, account) {
2909
+ return {
2910
+ address: provisioner,
2911
+ abi: provisionerV2Abi,
2912
+ functionName: "requestDeposit",
2913
+ args: [
2914
+ token,
2915
+ tokensIn,
2916
+ minUnitsOut,
2917
+ solverTip,
2918
+ deadline,
2919
+ maxPriceAge,
2920
+ isFixedPrice,
2921
+ receiver
2922
+ ],
2923
+ account
2924
+ };
2925
+ }
2926
+ function setDepositReceiverApprovalTxRequest(provisioner, depositor, approved, receiver) {
2927
+ return {
2928
+ address: provisioner,
2929
+ abi: provisionerV2Abi,
2930
+ functionName: "setDepositReceiverApproval",
2931
+ args: [depositor, approved],
2932
+ account: receiver
2933
+ };
2934
+ }
2935
+ function requestRedeemTxRequest2(provisioner, token, unitsIn, minTokenOut, solverTip, deadline, maxPriceAge, isFixedPrice, receiver, account) {
2936
+ return {
2937
+ address: provisioner,
2938
+ abi: provisionerV2Abi,
2939
+ functionName: "requestRedeem",
2940
+ args: [
2941
+ token,
2942
+ unitsIn,
2943
+ minTokenOut,
2944
+ solverTip,
2945
+ deadline,
2946
+ maxPriceAge,
2947
+ isFixedPrice,
2948
+ receiver
2949
+ ],
2950
+ account
2951
+ };
2952
+ }
2953
+ function redeemTxRequest(provisioner, token, unitsIn, minTokenOut, receiver, account) {
2954
+ return {
2955
+ address: provisioner,
2956
+ abi: provisionerV2Abi,
2957
+ functionName: "redeem",
2958
+ args: [token, unitsIn, minTokenOut, receiver],
2959
+ account
2960
+ };
2961
+ }
2962
+ function withdrawTxRequest(provisioner, token, tokensOut, maxUnitsIn, receiver, account) {
2963
+ return {
2964
+ address: provisioner,
2965
+ abi: provisionerV2Abi,
2966
+ functionName: "withdraw",
2967
+ args: [token, tokensOut, maxUnitsIn, receiver],
2968
+ account
2969
+ };
2970
+ }
2971
+
2972
+ // src/evm/adapters/aera.ts
2973
+ function subtractSolverTip(tokenAmount, solverTip) {
2974
+ if (solverTip === 0n) return tokenAmount;
2975
+ if (solverTip >= tokenAmount) {
2976
+ throw new InvalidSolverTipError(solverTip, tokenAmount);
2977
+ }
2978
+ return tokenAmount - solverTip;
2979
+ }
2980
+ function getRequestDeadline(expirationDays) {
2981
+ const deadlineBuffer = expirationDays === void 0 ? DEFAULT_REQUEST_DEADLINE_BUFFER : DAY * expirationDays;
2982
+ return BigInt(Math.ceil((/* @__PURE__ */ new Date()).getTime() / 1e3) + deadlineBuffer);
2983
+ }
2984
+ async function getDepositUnitsOut({
2985
+ publicClient,
2986
+ runtime,
2987
+ vault,
2988
+ token,
2989
+ tokensIn,
2990
+ isAsync
2991
+ }) {
2992
+ if (runtime.provisioner.version === ContractVersion.V2) {
2993
+ return isAsync ? getAsyncDepositUnitsOut2(
2994
+ publicClient,
2995
+ runtime.provisioner.address,
2996
+ runtime.feeCalculator.address,
2997
+ runtime.feeCalculator.version,
2998
+ vault,
2999
+ token,
3000
+ tokensIn
3001
+ ) : getSyncDepositUnitsOut(
3002
+ publicClient,
3003
+ runtime.provisioner.address,
3004
+ runtime.feeCalculator.address,
3005
+ runtime.feeCalculator.version,
3006
+ vault,
3007
+ token,
3008
+ tokensIn
3009
+ );
3010
+ }
3011
+ return getAsyncDepositUnitsOut(
3012
+ publicClient,
3013
+ runtime.provisioner.address,
3014
+ runtime.feeCalculator.address,
3015
+ runtime.feeCalculator.version,
3016
+ vault,
3017
+ token,
3018
+ tokensIn
3019
+ );
3020
+ }
3021
+ function getAsyncRedeemTokenOut3(publicClient, runtime, vault, token, unitsIn) {
3022
+ return runtime.provisioner.version === ContractVersion.V2 ? getAsyncRedeemTokenOut2(
3023
+ publicClient,
3024
+ runtime.provisioner.address,
3025
+ runtime.feeCalculator.address,
3026
+ runtime.feeCalculator.version,
3027
+ vault,
3028
+ token,
3029
+ unitsIn
3030
+ ) : getAsyncRedeemTokenOut(
3031
+ publicClient,
3032
+ runtime.provisioner.address,
3033
+ runtime.feeCalculator.address,
3034
+ runtime.feeCalculator.version,
3035
+ vault,
3036
+ token,
3037
+ unitsIn
3038
+ );
3039
+ }
3040
+ function getAsyncWithdrawUnitsIn3(publicClient, runtime, vault, token, tokensOut) {
3041
+ return runtime.provisioner.version === ContractVersion.V2 ? getAsyncWithdrawUnitsIn2(
3042
+ publicClient,
3043
+ runtime.provisioner.address,
3044
+ runtime.feeCalculator.address,
3045
+ runtime.feeCalculator.version,
3046
+ vault,
3047
+ token,
3048
+ tokensOut
3049
+ ) : getAsyncWithdrawUnitsIn(
3050
+ publicClient,
3051
+ runtime.provisioner.address,
3052
+ runtime.feeCalculator.address,
3053
+ runtime.feeCalculator.version,
3054
+ vault,
3055
+ token,
3056
+ tokensOut
3057
+ );
3058
+ }
3059
+ function requireAeraRuntime(runtime) {
3060
+ if (!runtime) {
3061
+ throw new UnsupportedFeatureError("Aera: runtime contracts were not resolved");
3062
+ }
3063
+ return runtime;
3064
+ }
3065
+ var aeraAdapter = {
3066
+ async buildDeposit(params) {
3067
+ const {
3068
+ vault,
3069
+ receiver,
3070
+ amount,
3071
+ account,
3072
+ publicClient,
3073
+ asset,
3074
+ async: isAsync,
3075
+ slippageBps = DEFAULT_BPS,
3076
+ solverTip = DEFAULT_SOLVER_TIP,
3077
+ maxPriceAge = DEFAULT_MAX_PRICE_AGE,
3078
+ aeraRuntime,
3079
+ minUnitsOut: requestedMinUnitsOut
3080
+ } = params;
3081
+ const runtime = requireAeraRuntime(aeraRuntime);
3082
+ const provisionerAddress = runtime.provisioner.address;
3083
+ const isContractV2 = runtime.provisioner.version === ContractVersion.V2;
3084
+ if (receiver !== account && !isContractV2) {
3085
+ throw new UnsupportedFeatureError("Aera: separate receiver address on V1");
3086
+ }
3087
+ if (!isAsync && !isContractV2) {
3088
+ throw new UnsupportedFeatureError("Aera: sync operations on V1");
3089
+ }
3090
+ const minUnitsOut = requestedMinUnitsOut ?? applySlippageDown(
3091
+ await getDepositUnitsOut({
3092
+ publicClient,
3093
+ runtime,
3094
+ vault: vault.vaultAddress,
3095
+ token: asset.address,
3096
+ tokensIn: isAsync ? subtractSolverTip(amount, solverTip) : amount,
3097
+ isAsync
3098
+ }),
3099
+ slippageBps
3100
+ );
3101
+ if (isAsync) {
3102
+ const deadline = getRequestDeadline(vault.expirationDays);
3103
+ return [
3104
+ {
3105
+ type: "requestDeposit",
3106
+ ...isContractV2 ? requestDepositTxRequest2(
3107
+ provisionerAddress,
3108
+ asset.address,
3109
+ amount,
3110
+ minUnitsOut,
3111
+ solverTip,
3112
+ deadline,
3113
+ maxPriceAge,
3114
+ false,
3115
+ receiver,
3116
+ account
3117
+ ) : requestDepositTxRequest(
3118
+ provisionerAddress,
3119
+ asset.address,
3120
+ amount,
3121
+ minUnitsOut,
3122
+ solverTip,
3123
+ deadline,
3124
+ maxPriceAge,
3125
+ false,
3126
+ account
3127
+ )
3128
+ }
3129
+ ];
3130
+ }
3131
+ if (isContractV2) {
3132
+ return [
3133
+ {
3134
+ type: "deposit",
3135
+ ...depositTxRequest(
3136
+ provisionerAddress,
3137
+ asset.address,
3138
+ amount,
3139
+ minUnitsOut,
3140
+ receiver,
3141
+ account
3142
+ )
3143
+ }
3144
+ ];
3145
+ }
3146
+ throw new UnimplementedFeatureError("Aera Sync Operations");
3147
+ },
3148
+ async buildWithdraw(params) {
3149
+ const {
3150
+ vault,
3151
+ receiver,
3152
+ account,
3153
+ asset,
3154
+ publicClient,
3155
+ async: isAsync,
3156
+ slippageBps = DEFAULT_BPS,
3157
+ solverTip = DEFAULT_SOLVER_TIP,
3158
+ maxPriceAge = DEFAULT_MAX_PRICE_AGE,
3159
+ aeraRuntime
3160
+ } = params;
3161
+ const runtime = requireAeraRuntime(aeraRuntime);
3162
+ const provisionerAddress = runtime.provisioner.address;
3163
+ const isContractV2 = runtime.provisioner.version === ContractVersion.V2;
3164
+ if (receiver !== account && !isContractV2) {
3165
+ throw new UnsupportedFeatureError("Aera: separate receiver address on V1");
3166
+ }
3167
+ if (!isAsync) requireAeraSyncRedeemRuntime(runtime);
3168
+ const isV2ExactTokenWithdraw = isContractV2 && !isAsync && "amount" in params && params.amount != null;
3169
+ let minTokenOut;
3170
+ let maxUnitsIn;
3171
+ let shares;
3172
+ if (isContractV2 && !isAsync) {
3173
+ const quote = params.syncWithdrawQuote;
3174
+ if ("entireAmount" in params && params.entireAmount) {
3175
+ const balance = await publicClient.readContract({
3176
+ address: vault.vaultAddress,
3177
+ abi: multiDepositorVaultAbi,
3178
+ functionName: "balanceOf",
3179
+ args: [account]
3180
+ });
3181
+ if (quote !== void 0) {
3182
+ if (quote.kind !== "redeem" || quote.shares !== balance) {
3183
+ throw new InvalidWithdrawParamsError();
3184
+ }
3185
+ }
3186
+ shares = balance;
3187
+ } else if ("shares" in params && params.shares != null) {
3188
+ if (quote !== void 0 && (quote.kind !== "redeem" || quote.shares !== params.shares)) {
3189
+ throw new InvalidWithdrawParamsError();
3190
+ }
3191
+ shares = params.shares;
3192
+ } else if (!("amount" in params && params.amount != null)) {
3193
+ throw new InvalidWithdrawParamsError();
3194
+ }
3195
+ if (isV2ExactTokenWithdraw) {
3196
+ requireNonZeroSyncWithdrawBound(params.amount, "tokensOut");
3197
+ if (quote !== void 0) {
3198
+ if (quote.kind !== "withdraw" || quote.tokensOut !== params.amount) {
3199
+ throw new InvalidWithdrawParamsError();
3200
+ }
3201
+ minTokenOut = quote.tokensOut;
3202
+ maxUnitsIn = quote.maxUnitsIn;
3203
+ } else {
3204
+ minTokenOut = params.amount;
3205
+ maxUnitsIn = applySlippageUp(
3206
+ await getSyncWithdrawUnitsIn(
3207
+ publicClient,
3208
+ provisionerAddress,
3209
+ runtime.feeCalculator.address,
3210
+ runtime.feeCalculator.version,
3211
+ vault.vaultAddress,
3212
+ asset.address,
3213
+ params.amount
3214
+ ),
3215
+ slippageBps
3216
+ );
3217
+ }
3218
+ requireNonZeroSyncWithdrawBound(maxUnitsIn, "maxUnitsIn");
3219
+ } else {
3220
+ if (shares === void 0) {
3221
+ throw new InvalidWithdrawParamsError();
3222
+ }
3223
+ requireNonZeroSyncWithdrawBound(shares, "unitsIn");
3224
+ if (quote !== void 0) {
3225
+ if (quote.kind !== "redeem" || quote.shares !== shares) {
3226
+ throw new InvalidWithdrawParamsError();
3227
+ }
3228
+ minTokenOut = quote.minTokensOut;
3229
+ } else {
3230
+ const tokensOut = await getSyncRedeemTokenOut(
3231
+ publicClient,
3232
+ provisionerAddress,
3233
+ runtime.feeCalculator.address,
3234
+ runtime.feeCalculator.version,
3235
+ vault.vaultAddress,
3236
+ asset.address,
3237
+ shares
3238
+ );
3239
+ minTokenOut = applySlippageDown(tokensOut, slippageBps);
3240
+ }
3241
+ requireNonZeroSyncWithdrawBound(minTokenOut, "minTokensOut");
3242
+ maxUnitsIn = shares;
3243
+ }
3244
+ } else {
3245
+ if ("entireAmount" in params && params.entireAmount) {
3246
+ shares = await publicClient.readContract({
3247
+ address: vault.vaultAddress,
3248
+ abi: multiDepositorVaultAbi,
3249
+ functionName: "balanceOf",
3250
+ args: [account]
3251
+ });
3252
+ } else if ("amount" in params && params.amount != null) {
3253
+ shares = await getAsyncWithdrawUnitsIn3(
3254
+ publicClient,
3255
+ runtime,
3256
+ vault.vaultAddress,
3257
+ asset.address,
3258
+ params.amount + solverTip
3259
+ );
3260
+ } else if ("shares" in params && params.shares != null) {
3261
+ shares = params.shares;
3262
+ } else {
3263
+ throw new InvalidWithdrawParamsError();
3264
+ }
3265
+ const tokenOutBeforeTip = await getAsyncRedeemTokenOut3(
3266
+ publicClient,
3267
+ runtime,
3268
+ vault.vaultAddress,
3269
+ asset.address,
3270
+ shares
3271
+ );
3272
+ minTokenOut = applySlippageDown(subtractSolverTip(tokenOutBeforeTip, solverTip), slippageBps);
3273
+ maxUnitsIn = shares;
3274
+ }
3275
+ const steps = [];
3276
+ if (isAsync) {
3277
+ if (shares === void 0) {
3278
+ throw new InvalidWithdrawParamsError();
3279
+ }
3280
+ const { sufficient } = await this.checkAllowance({
3281
+ publicClient,
3282
+ token: vault.vaultAddress,
3283
+ owner: account,
3284
+ spender: provisionerAddress,
3285
+ amount: shares
3286
+ });
3287
+ if (!sufficient) {
3288
+ steps.push(
3289
+ this.buildApproval({
3290
+ token: vault.vaultAddress,
3291
+ spender: provisionerAddress,
3292
+ amount: shares,
3293
+ account
3294
+ })
3295
+ );
3296
+ }
3297
+ const deadline = getRequestDeadline(vault.expirationDays);
3298
+ return [
3299
+ ...steps,
3300
+ {
3301
+ type: "requestRedeem",
3302
+ ...isContractV2 ? requestRedeemTxRequest2(
3303
+ provisionerAddress,
3304
+ asset.address,
3305
+ shares,
3306
+ minTokenOut,
3307
+ solverTip,
3308
+ deadline,
3309
+ maxPriceAge,
3310
+ false,
3311
+ receiver,
3312
+ account
3313
+ ) : requestRedeemTxRequest(
3314
+ provisionerAddress,
3315
+ asset.address,
3316
+ shares,
3317
+ minTokenOut,
3318
+ solverTip,
3319
+ deadline,
3320
+ maxPriceAge,
3321
+ false,
3322
+ account
3323
+ )
3324
+ }
3325
+ ];
3326
+ }
3327
+ if ("amount" in params && params.amount != null) {
3328
+ return [
3329
+ ...steps,
3330
+ {
3331
+ type: "withdraw",
3332
+ ...withdrawTxRequest(
3333
+ provisionerAddress,
3334
+ asset.address,
3335
+ params.amount,
3336
+ maxUnitsIn,
3337
+ receiver,
3338
+ account
3339
+ )
3340
+ }
3341
+ ];
3342
+ }
3343
+ if (shares === void 0) {
3344
+ throw new InvalidWithdrawParamsError();
3345
+ }
3346
+ return [
3347
+ ...steps,
3348
+ {
3349
+ type: "redeem",
3350
+ ...redeemTxRequest(
3351
+ provisionerAddress,
3352
+ asset.address,
3353
+ shares,
3354
+ minTokenOut,
3355
+ receiver,
3356
+ account
3357
+ )
3358
+ }
3359
+ ];
3360
+ },
3361
+ async checkAllowance(params) {
3362
+ const { publicClient, token, owner, spender, amount } = params;
3363
+ const current = await publicClient.readContract({
3364
+ address: token,
3365
+ abi: erc20Abi,
3366
+ functionName: "allowance",
3367
+ args: [owner, spender]
3368
+ });
3369
+ return { sufficient: current >= amount, current };
3370
+ },
3371
+ buildApproval(params) {
3372
+ return {
3373
+ type: "approve",
3374
+ address: params.token,
3375
+ abi: erc20Abi,
3376
+ functionName: "approve",
3377
+ args: [params.spender, params.amount],
3378
+ account: params.account
3379
+ };
3380
+ }
3381
+ };
3382
+
3383
+ // src/evm/abis/erc4626.ts
3384
+ var erc4626Abi = [
3385
+ {
3386
+ type: "function",
3387
+ name: "deposit",
3388
+ inputs: [
3389
+ { name: "assets", type: "uint256" },
3390
+ { name: "receiver", type: "address" }
3391
+ ],
3392
+ outputs: [{ type: "uint256" }],
3393
+ stateMutability: "nonpayable"
3394
+ },
3395
+ {
3396
+ type: "function",
3397
+ name: "redeem",
3398
+ inputs: [
3399
+ { name: "shares", type: "uint256" },
3400
+ { name: "receiver", type: "address" },
3401
+ { name: "owner", type: "address" }
3402
+ ],
3403
+ outputs: [{ type: "uint256" }],
3404
+ stateMutability: "nonpayable"
3405
+ },
3406
+ {
3407
+ type: "function",
3408
+ name: "convertToShares",
3409
+ inputs: [{ name: "assets", type: "uint256" }],
3410
+ outputs: [{ type: "uint256" }],
3411
+ stateMutability: "view"
3412
+ },
3413
+ {
3414
+ type: "function",
3415
+ name: "convertToAssets",
3416
+ inputs: [{ name: "shares", type: "uint256" }],
3417
+ outputs: [{ type: "uint256" }],
3418
+ stateMutability: "view"
3419
+ },
3420
+ {
3421
+ type: "function",
3422
+ name: "balanceOf",
3423
+ inputs: [{ name: "account", type: "address" }],
3424
+ outputs: [{ type: "uint256" }],
3425
+ stateMutability: "view"
3426
+ },
3427
+ {
3428
+ type: "function",
3429
+ name: "maxDeposit",
3430
+ inputs: [{ name: "receiver", type: "address" }],
3431
+ outputs: [{ type: "uint256" }],
3432
+ stateMutability: "view"
3433
+ },
3434
+ {
3435
+ type: "function",
3436
+ name: "maxRedeem",
3437
+ inputs: [{ name: "owner", type: "address" }],
3438
+ outputs: [{ type: "uint256" }],
3439
+ stateMutability: "view"
3440
+ },
3441
+ {
3442
+ type: "function",
3443
+ name: "withdraw",
3444
+ inputs: [
3445
+ { name: "assets", type: "uint256" },
3446
+ { name: "receiver", type: "address" },
3447
+ { name: "owner", type: "address" }
3448
+ ],
3449
+ outputs: [{ type: "uint256" }],
3450
+ stateMutability: "nonpayable"
3451
+ }
3452
+ ];
3453
+
3454
+ // src/evm/adapters/morpho.ts
3455
+ var morphoAdapter = {
3456
+ async buildDeposit(params) {
3457
+ const { vault, amount, receiver, account } = params;
3458
+ return [
3459
+ {
3460
+ type: "deposit",
3461
+ address: vault.vaultAddress,
3462
+ abi: erc4626Abi,
3463
+ functionName: "deposit",
3464
+ args: [amount, receiver],
3465
+ account
3466
+ }
3467
+ ];
3468
+ },
3469
+ async buildWithdraw(params) {
3470
+ const { vault, receiver, account, publicClient } = params;
3471
+ let shares;
3472
+ if ("entireAmount" in params && params.entireAmount) {
3473
+ shares = await publicClient.readContract({
3474
+ address: vault.vaultAddress,
3475
+ abi: erc4626Abi,
3476
+ functionName: "balanceOf",
3477
+ args: [account]
3478
+ });
3479
+ } else if ("amount" in params && params.amount != null) {
3480
+ return [
3481
+ {
3482
+ type: "withdraw",
3483
+ address: vault.vaultAddress,
3484
+ abi: erc4626Abi,
3485
+ functionName: "withdraw",
3486
+ args: [params.amount, receiver, account],
3487
+ account
3488
+ }
3489
+ ];
3490
+ } else if ("shares" in params && params.shares != null) {
3491
+ shares = params.shares;
3492
+ } else {
3493
+ throw new InvalidWithdrawParamsError();
3494
+ }
3495
+ return [
3496
+ {
3497
+ type: "redeem",
3498
+ address: vault.vaultAddress,
3499
+ abi: erc4626Abi,
3500
+ functionName: "redeem",
3501
+ args: [shares, receiver, account],
3502
+ account
3503
+ }
3504
+ ];
3505
+ },
3506
+ async checkAllowance(params) {
3507
+ const { publicClient, token, owner, spender, amount } = params;
3508
+ const current = await publicClient.readContract({
3509
+ address: token,
3510
+ abi: erc20Abi,
3511
+ functionName: "allowance",
3512
+ args: [owner, spender]
3513
+ });
3514
+ return { sufficient: current >= amount, current };
3515
+ },
3516
+ buildApproval(params) {
3517
+ return {
3518
+ type: "approve",
3519
+ address: params.token,
3520
+ abi: erc20Abi,
3521
+ functionName: "approve",
3522
+ args: [params.spender, params.amount],
3523
+ account: params.account
3524
+ };
3525
+ }
3526
+ };
3527
+
3528
+ // src/evm/adapters/index.ts
3529
+ function getAdapter(protocol) {
3530
+ switch (protocol) {
3531
+ case "aera":
3532
+ return aeraAdapter;
3533
+ case "morpho":
3534
+ return morphoAdapter;
3535
+ default:
3536
+ throw new UnsupportedProtocolError(protocol);
3537
+ }
3538
+ }
3539
+
3540
+ // src/attribution/index.ts
3541
+ import { encodeFunctionData } from "viem";
3542
+
3543
+ // src/attribution/erc8021.ts
3544
+ import { toHex } from "viem";
3545
+ var ERC8021_MARKER = "80218021802180218021802180218021";
3546
+ var ERC8021_SCHEMA_ID = "00";
3547
+ function encodeBuilderCode(builderCode) {
3548
+ const codeHex = toHex(builderCode).slice(2);
3549
+ const codeByteLen = codeHex.length / 2;
3550
+ const codeLengthHex = codeByteLen.toString(16).padStart(2, "0");
3551
+ return `0x${codeHex}${codeLengthHex}${ERC8021_SCHEMA_ID}${ERC8021_MARKER}`;
3552
+ }
3553
+
3554
+ // src/attribution/index.ts
3555
+ async function buildAttribution(client) {
3556
+ switch (client.attributionMode) {
3557
+ case "public" /* PUBLIC */:
3558
+ return client.builderCode ? encodeBuilderCode(client.builderCode) : "0x";
3559
+ case "encoded" /* ENCODED */:
3560
+ throw new UnimplementedFeatureError("AttributionMode.ENCODED");
3561
+ case "private" /* PRIVATE */:
3562
+ throw new UnimplementedFeatureError("AttributionMode.PRIVATE");
3563
+ }
3564
+ }
3565
+ async function encodeTransactionWithAttribution(client, transaction) {
3566
+ const customAttribution = await buildAttribution(client);
3567
+ const encodedTx = encodeFunctionData({
3568
+ abi: transaction.abi,
3569
+ functionName: transaction.functionName,
3570
+ args: transaction.args
3571
+ });
3572
+ const encodedTxWithAttribution = `${encodedTx}${customAttribution.replace("0x", "")}`;
3573
+ return {
3574
+ payload: {
3575
+ type: transaction.type,
3576
+ account: transaction.account,
3577
+ to: transaction.address,
3578
+ data: encodedTxWithAttribution
3579
+ },
3580
+ tx: {
3581
+ ...transaction,
3582
+ attribution: customAttribution
3583
+ }
3584
+ };
3585
+ }
3586
+
3587
+ // src/evm/operationMode.ts
3588
+ function formatAvailableModes(support) {
3589
+ if (support.async && support.sync) return "both";
3590
+ if (support.async) return "async";
3591
+ if (support.sync) return "sync";
3592
+ return "none";
3593
+ }
3594
+ function parseOperationMode(vaultId, requested) {
3595
+ if (requested === void 0 || requested === "sync" || requested === "async") {
3596
+ return requested;
3597
+ }
3598
+ throw new UnsupportedDepositModeError(vaultId, requested, "sync, async");
3599
+ }
3600
+ function resolveOperationMode(vaultId, requested, support) {
3601
+ const available = formatAvailableModes(support);
3602
+ if (requested === "sync") {
3603
+ if (!support.sync) throw new UnsupportedDepositModeError(vaultId, "sync", available);
3604
+ return "sync";
3605
+ }
3606
+ if (requested === "async") {
3607
+ if (!support.async) throw new UnsupportedDepositModeError(vaultId, "async", available);
3608
+ return "async";
3609
+ }
3610
+ if (support.async) return "async";
3611
+ if (support.sync) return "sync";
3612
+ throw new UnsupportedDepositModeError(vaultId, "async", available);
3613
+ }
3614
+ function resolveSyncOnlyOperationMode(vaultId, requested) {
3615
+ if (requested === "async") {
3616
+ throw new UnsupportedDepositModeError(vaultId, "async", "sync");
3617
+ }
3618
+ return "sync";
3619
+ }
3620
+
3621
+ // src/evm/deposit.ts
3622
+ async function getDepositTx(client, params) {
3623
+ const slippageBps = params.slippageBps ?? DEFAULT_BPS;
3624
+ if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > Number(MAX_BPS)) {
3625
+ throw new InvalidSlippageBPSError(slippageBps);
3626
+ }
3627
+ if (params.minUnitsOut !== void 0 && (typeof params.minUnitsOut !== "bigint" || params.minUnitsOut <= 0n)) {
3628
+ throw new InvalidSyncDepositBoundError();
3629
+ }
3630
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
3631
+ if (!resolved) throw new VaultNotFoundError(params.vaultId);
3632
+ const chainId = params.chainId ?? resolved.vault.chainId;
3633
+ const account = client.wallet?.account?.address;
3634
+ if (!account) throw new AccountRequiredError();
3635
+ const { vault, protocol } = resolved;
3636
+ const adapter = getAdapter(protocol);
3637
+ const publicClient = client.getPublicClient(chainId);
3638
+ const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
3639
+ if (token === void 0) {
3640
+ throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
3641
+ }
3642
+ const requestedDepositMode = parseOperationMode(params.vaultId, params.depositMode);
3643
+ if (params.minUnitsOut !== void 0 && (protocol !== "aera" || requestedDepositMode !== "sync")) {
3644
+ throw new InvalidSyncDepositBoundError();
3645
+ }
3646
+ let modifiedDepositMode;
3647
+ let aeraRuntime;
3648
+ if (protocol === "aera") {
3649
+ aeraRuntime = await resolveAeraRuntimeContracts(publicClient, vault);
3650
+ const tokenModeSupport = await resolveAeraTokenModeSupport(
3651
+ publicClient,
3652
+ aeraRuntime,
3653
+ token.address,
3654
+ { includeSyncModes: requestedDepositMode !== "async" }
3655
+ );
3656
+ modifiedDepositMode = resolveOperationMode(params.vaultId, requestedDepositMode, {
3657
+ async: tokenModeSupport.asyncDeposit,
3658
+ sync: tokenModeSupport.syncDeposit
3659
+ });
3660
+ } else {
3661
+ modifiedDepositMode = resolveSyncOnlyOperationMode(params.vaultId, requestedDepositMode);
3662
+ }
3663
+ const spender = protocol === "aera" && modifiedDepositMode === "async" ? aeraRuntime.provisioner.address : vault.vaultAddress;
3664
+ const { sufficient } = await adapter.checkAllowance({
3665
+ publicClient,
3666
+ token: token.address,
3667
+ owner: account,
3668
+ spender,
3669
+ amount: params.amount
3670
+ });
3671
+ const steps = [];
3672
+ if (!sufficient) {
3673
+ steps.push(
3674
+ adapter.buildApproval({
3675
+ token: token.address,
3676
+ spender,
3677
+ amount: params.amount,
3678
+ account
3679
+ })
3680
+ );
3681
+ }
3682
+ const depositSteps = await adapter.buildDeposit({
3683
+ vault,
3684
+ amount: params.amount,
3685
+ receiver: params.receiver ?? account,
3686
+ account,
3687
+ async: modifiedDepositMode === "async",
3688
+ asset: token,
3689
+ publicClient,
3690
+ slippageBps,
3691
+ solverTip: params.solverTip,
3692
+ maxPriceAge: params.maxPriceAge,
3693
+ aeraRuntime,
3694
+ minUnitsOut: params.minUnitsOut
3695
+ });
3696
+ steps.push(...depositSteps);
3697
+ return Promise.all(steps.map((step) => encodeTransactionWithAttribution(client, step)));
3698
+ }
3699
+
3700
+ // src/evm/depositReceiverApproval.ts
3701
+ async function getDepositReceiverApprovalTx(client, params) {
3702
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
3703
+ if (!resolved) throw new VaultNotFoundError(params.vaultId);
3704
+ const chainId = params.chainId ?? resolved.vault.chainId;
3705
+ const receiver = client.wallet?.account?.address;
3706
+ if (!receiver) throw new AccountRequiredError();
3707
+ const { vault } = resolved;
3708
+ const publicClient = client.getPublicClient(chainId);
3709
+ const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
3710
+ if (runtime.provisioner.version !== ContractVersion.V2) {
3711
+ throw new UnsupportedFeatureError("Aera: deposit receiver approval on V1");
3712
+ }
3713
+ return encodeTransactionWithAttribution(client, {
3714
+ type: "setDepositReceiverApproval",
3715
+ ...setDepositReceiverApprovalTxRequest(
3716
+ runtime.provisioner.address,
3717
+ params.depositor,
3718
+ params.approved ?? true,
3719
+ receiver
3720
+ )
3721
+ });
3722
+ }
3723
+
3724
+ // src/evm/depositQuote.ts
3725
+ async function resolveSyncDepositContext(client, params, readKind) {
3726
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
3727
+ if (!resolved) throw new VaultNotFoundError(params.vaultId, params.chainId);
3728
+ if (resolved.protocol !== "aera") {
3729
+ throw new UnsupportedFeatureError(
3730
+ readKind === "quote" ? "Sync deposit quote is only available for Aera vaults" : "Sync deposit rate is only available for Aera vaults"
3731
+ );
3732
+ }
3733
+ const { vault } = resolved;
3734
+ const token = vault.supplyToken.length > 1 ? vault.supplyToken.find(({ symbol }) => symbol === params.assetSymbol) : vault.supplyToken[0];
3735
+ if (!token) throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
3736
+ const publicClient = client.getPublicClient(params.chainId ?? vault.chainId);
3737
+ const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
3738
+ if (runtime.provisioner.version !== ContractVersion.V2) {
3739
+ throw new UnsupportedFeatureError(
3740
+ readKind === "quote" ? "Sync deposit quote requires an Aera V2 provisioner" : "Sync deposit rate requires an Aera V2 provisioner"
3741
+ );
3742
+ }
3743
+ const tokenModeSupport = await resolveAeraTokenModeSupport(publicClient, runtime, token.address, {
3744
+ includeSyncModes: true
3745
+ });
3746
+ resolveOperationMode(params.vaultId, "sync", {
3747
+ async: tokenModeSupport.asyncDeposit,
3748
+ sync: tokenModeSupport.syncDeposit
3749
+ });
3750
+ return { publicClient, vault, token, runtime };
3751
+ }
3752
+ async function getSyncDepositQuote2(client, params) {
3753
+ const slippageBps = params.slippageBps ?? DEFAULT_BPS;
3754
+ if (!Number.isInteger(slippageBps) || slippageBps < 0 || slippageBps > Number(MAX_BPS)) {
3755
+ throw new InvalidSlippageBPSError(slippageBps);
3756
+ }
3757
+ const { publicClient, vault, token, runtime } = await resolveSyncDepositContext(
3758
+ client,
3759
+ params,
3760
+ "quote"
3761
+ );
3762
+ const { unitsOut, feeBps, numeraireOut } = await getSyncDepositQuoteValues(
3763
+ publicClient,
3764
+ runtime.provisioner.address,
3765
+ runtime.feeCalculator.address,
3766
+ runtime.feeCalculator.version,
3767
+ vault.vaultAddress,
3768
+ token.address,
3769
+ params.amount
3770
+ );
3771
+ const minUnitsOut = applySlippageDown(unitsOut, slippageBps);
3772
+ if (minUnitsOut <= 0n) throw new InvalidSyncDepositBoundError();
3773
+ return { unitsOut, minUnitsOut, numeraireOut, feeBps, slippageBps };
3774
+ }
3775
+ async function getSyncDepositRate(client, params) {
3776
+ const { publicClient, runtime, token } = await resolveSyncDepositContext(client, params, "rate");
3777
+ const feeBps = await getSyncDepositFeeBps(
3778
+ publicClient,
3779
+ runtime.provisioner.address,
3780
+ token.address
3781
+ );
3782
+ return { feeBps };
3783
+ }
3784
+
3785
+ // src/evm/withdraw.ts
3786
+ function validateWithdrawParams(params) {
3787
+ const modes = [
3788
+ "amount" in params && params.amount != null,
3789
+ "shares" in params && params.shares != null,
3790
+ "entireAmount" in params && params.entireAmount === true
3791
+ ].filter(Boolean).length;
3792
+ if (modes !== 1) throw new InvalidWithdrawParamsError();
3793
+ }
3794
+ function sameAddress(left, right) {
3795
+ return left.toLowerCase() === right.toLowerCase();
3796
+ }
3797
+ function validateSyncWithdrawQuote({
3798
+ params,
3799
+ account,
3800
+ chainId,
3801
+ slippageBps,
3802
+ tokenAddress
3803
+ }) {
3804
+ const quote = params.syncWithdrawQuote;
3805
+ if (quote === void 0) return;
3806
+ const { context } = quote;
3807
+ if (context.vaultId !== params.vaultId || context.chainId !== chainId || !sameAddress(context.tokenAddress, tokenAddress) || context.slippageBps !== slippageBps) {
3808
+ throw new InvalidWithdrawParamsError();
3809
+ }
3810
+ if (context.account !== void 0 && !sameAddress(context.account, account)) {
3811
+ throw new InvalidWithdrawParamsError();
3812
+ }
3813
+ switch (context.request.mode) {
3814
+ case "amount":
3815
+ if (quote.kind !== "withdraw" || !("amount" in params && params.amount != null) || context.request.amount !== params.amount || quote.tokensOut !== params.amount) {
3816
+ throw new InvalidWithdrawParamsError();
3817
+ }
3818
+ return;
3819
+ case "shares":
3820
+ if (quote.kind !== "redeem" || !("shares" in params && params.shares != null) || context.request.shares !== params.shares || quote.shares !== params.shares) {
3821
+ throw new InvalidWithdrawParamsError();
3822
+ }
3823
+ return;
3824
+ case "entireAmount":
3825
+ if (quote.kind !== "redeem" || !("entireAmount" in params && params.entireAmount) || !sameAddress(context.request.account, account)) {
3826
+ throw new InvalidWithdrawParamsError();
3827
+ }
3828
+ return;
3829
+ }
3830
+ }
3831
+ async function getWithdrawTx(client, params) {
3832
+ validateWithdrawParams(params);
3833
+ if (params.slippageBps !== void 0 && (!Number.isInteger(params.slippageBps) || params.slippageBps < 0 || params.slippageBps > Number(MAX_BPS))) {
3834
+ throw new InvalidSlippageBPSError(params.slippageBps);
3835
+ }
3836
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
3837
+ if (!resolved) throw new VaultNotFoundError(params.vaultId);
3838
+ const chainId = params.chainId ?? resolved.vault.chainId;
3839
+ const account = client.wallet?.account?.address;
3840
+ if (!account) throw new AccountRequiredError();
3841
+ if ("entireAmount" in params && params.entireAmount && params.account !== void 0) {
3842
+ if (!sameAddress(params.account, account)) {
3843
+ throw new AccountMismatchError(account, params.account);
3844
+ }
3845
+ }
3846
+ const { vault, protocol } = resolved;
3847
+ const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
3848
+ if (token === void 0) {
3849
+ throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
3850
+ }
3851
+ const adapter = getAdapter(protocol);
3852
+ const publicClient = client.getPublicClient(chainId);
3853
+ const requestedWithdrawMode = parseOperationMode(params.vaultId, params.depositMode);
3854
+ const slippageBps = params.slippageBps ?? params.syncWithdrawQuote?.context.slippageBps ?? DEFAULT_BPS;
3855
+ let modifiedDepositMode;
3856
+ let aeraRuntime;
3857
+ if (params.syncWithdrawQuote !== void 0) {
3858
+ if (protocol !== "aera" || requestedWithdrawMode === "async") {
3859
+ throw new InvalidWithdrawParamsError();
3860
+ }
3861
+ validateSyncWithdrawQuote({
3862
+ params,
3863
+ account,
3864
+ chainId,
3865
+ slippageBps,
3866
+ tokenAddress: token.address
3867
+ });
3868
+ }
3869
+ if (protocol === "aera") {
3870
+ aeraRuntime = await resolveAeraRuntimeContracts(publicClient, vault);
3871
+ if (aeraRuntime.provisioner.version === ContractVersion.V2 && (requestedWithdrawMode === "sync" || params.syncWithdrawQuote !== void 0)) {
3872
+ requireAeraSyncRedeemRuntime(aeraRuntime);
3873
+ }
3874
+ const tokenModeSupport = await resolveAeraTokenModeSupport(
3875
+ publicClient,
3876
+ aeraRuntime,
3877
+ token.address,
3878
+ { includeSyncModes: requestedWithdrawMode !== "async" }
3879
+ );
3880
+ modifiedDepositMode = resolveOperationMode(
3881
+ params.vaultId,
3882
+ params.syncWithdrawQuote !== void 0 ? "sync" : requestedWithdrawMode,
3883
+ {
3884
+ async: tokenModeSupport.asyncRedeem,
3885
+ sync: tokenModeSupport.syncRedeem
3886
+ }
3887
+ );
3888
+ if (modifiedDepositMode === "sync") requireAeraSyncRedeemRuntime(aeraRuntime);
3889
+ } else {
3890
+ modifiedDepositMode = resolveSyncOnlyOperationMode(params.vaultId, requestedWithdrawMode);
3891
+ }
3892
+ const withdrawParams = {
3893
+ vault,
3894
+ receiver: params.receiver ?? account,
3895
+ account,
3896
+ async: modifiedDepositMode === "async",
3897
+ asset: token,
3898
+ publicClient,
3899
+ slippageBps,
3900
+ solverTip: params.solverTip,
3901
+ maxPriceAge: params.maxPriceAge,
3902
+ aeraRuntime,
3903
+ syncWithdrawQuote: params.syncWithdrawQuote,
3904
+ ..."shares" in params && params.shares != null ? { shares: params.shares } : {},
3905
+ ..."amount" in params && params.amount != null ? { amount: params.amount } : {},
3906
+ ..."entireAmount" in params && params.entireAmount ? { entireAmount: true } : {}
3907
+ };
3908
+ const steps = await adapter.buildWithdraw(withdrawParams);
3909
+ return await Promise.all(steps.map((step) => encodeTransactionWithAttribution(client, step)));
3910
+ }
3911
+
3912
+ // src/evm/withdrawQuote.ts
3913
+ function validateSyncWithdrawQuoteParams(params) {
3914
+ const modes = [
3915
+ "amount" in params && params.amount != null,
3916
+ "shares" in params && params.shares != null,
3917
+ "entireAmount" in params && params.entireAmount === true
3918
+ ].filter(Boolean).length;
3919
+ if (modes !== 1) throw new InvalidWithdrawParamsError();
3920
+ if ("entireAmount" in params && params.entireAmount === true && !params.account) {
3921
+ throw new AccountRequiredError();
3922
+ }
3923
+ }
3924
+ async function resolveSyncWithdrawContext(client, params, readKind) {
3925
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
3926
+ if (!resolved) throw new VaultNotFoundError(params.vaultId);
3927
+ const { vault, protocol } = resolved;
3928
+ if (protocol !== "aera") {
3929
+ throw new UnsupportedFeatureError(
3930
+ readKind === "quote" ? "Sync withdraw quote is only available for Aera vaults" : "Sync withdraw rate is only available for Aera vaults"
3931
+ );
3932
+ }
3933
+ const chainId = params.chainId ?? vault.chainId;
3934
+ const publicClient = client.getPublicClient(chainId);
3935
+ const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
3936
+ if (token === void 0) {
3937
+ throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
3938
+ }
3939
+ const quoteBlock = await publicClient.getBlock();
3940
+ if (quoteBlock.number === null) {
3941
+ throw new UnsupportedFeatureError(
3942
+ readKind === "quote" ? "Aera: sync withdraw quote requires a numbered block" : "Aera: sync withdraw rate requires a numbered block"
3943
+ );
3944
+ }
3945
+ const readContext = {
3946
+ blockNumber: quoteBlock.number,
3947
+ blockTimestamp: BigInt(quoteBlock.timestamp)
3948
+ };
3949
+ const runtime = await resolveAeraRuntimeContracts(publicClient, vault, readContext);
3950
+ requireAeraSyncRedeemRuntime(runtime);
3951
+ const support = await resolveAeraTokenModeSupport(
3952
+ publicClient,
3953
+ runtime,
3954
+ token.address,
3955
+ readContext
3956
+ );
3957
+ resolveOperationMode(params.vaultId, "sync", {
3958
+ async: support.asyncRedeem,
3959
+ sync: support.syncRedeem
3960
+ });
3961
+ return { publicClient, vault, token, runtime, chainId, readContext };
3962
+ }
3963
+ async function getSyncWithdrawRate(client, params) {
3964
+ const { publicClient, vault, token, runtime, readContext } = await resolveSyncWithdrawContext(
3965
+ client,
3966
+ params,
3967
+ "rate"
3968
+ );
3969
+ return getSyncRedeemRate(
3970
+ publicClient,
3971
+ runtime.provisioner.address,
3972
+ vault.vaultAddress,
3973
+ token.address,
3974
+ runtime.feeCalculator.address,
3975
+ readContext
3976
+ );
3977
+ }
3978
+ async function getSyncWithdrawQuote(client, params) {
3979
+ validateSyncWithdrawQuoteParams(params);
3980
+ if (params.slippageBps !== void 0 && (!Number.isInteger(params.slippageBps) || params.slippageBps < 0 || params.slippageBps > Number(MAX_BPS))) {
3981
+ throw new InvalidSlippageBPSError(params.slippageBps);
3982
+ }
3983
+ const slippageBps = params.slippageBps ?? DEFAULT_BPS;
3984
+ const {
3985
+ publicClient,
3986
+ vault,
3987
+ token,
3988
+ runtime,
3989
+ chainId,
3990
+ readContext: quoteReadContext
3991
+ } = await resolveSyncWithdrawContext(client, params, "quote");
3992
+ const provisioner = runtime.provisioner.address;
3993
+ const feeCalculator = runtime.feeCalculator.address;
3994
+ const feeVersion = runtime.feeCalculator.version;
3995
+ const vaultAddress = vault.vaultAddress;
3996
+ const { rate, hasPullFundsSubmitData } = await getSyncRedeemRateContext(
3997
+ publicClient,
3998
+ provisioner,
3999
+ vaultAddress,
4000
+ token.address,
4001
+ feeCalculator,
4002
+ quoteReadContext
4003
+ );
4004
+ let kind;
4005
+ let shares;
4006
+ let tokensOut;
4007
+ let minTokensOut;
4008
+ let maxUnitsIn;
4009
+ let request;
4010
+ let shareSafeTokensOut;
4011
+ if ("amount" in params && params.amount != null) {
4012
+ kind = "withdraw";
4013
+ request = { mode: "amount", amount: params.amount };
4014
+ tokensOut = params.amount;
4015
+ requireNonZeroSyncWithdrawBound(tokensOut, "tokensOut");
4016
+ minTokensOut = params.amount;
4017
+ shares = await getSyncWithdrawUnitsIn(
4018
+ publicClient,
4019
+ provisioner,
4020
+ feeCalculator,
4021
+ feeVersion,
4022
+ vaultAddress,
4023
+ token.address,
4024
+ params.amount,
4025
+ rate.effectiveMultiplierBps,
4026
+ quoteReadContext
4027
+ );
4028
+ maxUnitsIn = applySlippageUp(shares, slippageBps);
4029
+ requireNonZeroSyncWithdrawBound(maxUnitsIn, "maxUnitsIn");
4030
+ } else {
4031
+ kind = "redeem";
4032
+ if ("entireAmount" in params && params.entireAmount) {
4033
+ if (!params.account) throw new AccountRequiredError();
4034
+ request = { mode: "entireAmount", account: params.account };
4035
+ shares = await publicClient.readContract({
4036
+ address: vaultAddress,
4037
+ abi: multiDepositorVaultAbi,
4038
+ functionName: "balanceOf",
4039
+ args: [params.account],
4040
+ blockNumber: quoteReadContext.blockNumber
4041
+ });
4042
+ } else if ("shares" in params && params.shares != null) {
4043
+ request = { mode: "shares", shares: params.shares };
4044
+ shares = params.shares;
4045
+ } else {
4046
+ throw new InvalidWithdrawParamsError();
4047
+ }
4048
+ requireNonZeroSyncWithdrawBound(shares, "unitsIn");
4049
+ const getTokensOut = (unitsIn) => getSyncRedeemTokenOut(
4050
+ publicClient,
4051
+ provisioner,
4052
+ feeCalculator,
4053
+ feeVersion,
4054
+ vaultAddress,
4055
+ token.address,
4056
+ unitsIn,
4057
+ rate.effectiveMultiplierBps,
4058
+ quoteReadContext
4059
+ );
4060
+ const shareSafeUnitsIn = shares * MAX_BPS / (MAX_BPS + BigInt(slippageBps));
4061
+ const tokensOutPromise = getTokensOut(shares);
4062
+ const shareSafeTokensOutPromise = shareSafeUnitsIn === shares ? tokensOutPromise : getTokensOut(shareSafeUnitsIn);
4063
+ [tokensOut, shareSafeTokensOut] = await Promise.all([
4064
+ tokensOutPromise,
4065
+ shareSafeTokensOutPromise
4066
+ ]);
4067
+ minTokensOut = applySlippageDown(tokensOut, slippageBps);
4068
+ requireNonZeroSyncWithdrawBound(minTokensOut, "minTokensOut");
4069
+ maxUnitsIn = shares;
4070
+ }
4071
+ const [epoch, requestNumeraire, unitsLockedUntil, knownLiquidityTokens] = await Promise.all([
4072
+ getSyncRedeemEpochState(publicClient, provisioner, quoteReadContext),
4073
+ convertTokenToNumeraire(
4074
+ publicClient,
4075
+ feeCalculator,
4076
+ feeVersion,
4077
+ vaultAddress,
4078
+ token.address,
4079
+ tokensOut,
4080
+ quoteReadContext
4081
+ ),
4082
+ params.account ? getUserUnitsRefundableUntil(publicClient, provisioner, params.account, quoteReadContext) : Promise.resolve(void 0),
4083
+ getKnownSyncRedeemLiquidityTokens(
4084
+ publicClient,
4085
+ vaultAddress,
4086
+ token.address,
4087
+ hasPullFundsSubmitData,
4088
+ quoteReadContext
4089
+ )
4090
+ ]);
4091
+ const remainingNumeraire = epoch.epochCapNumeraire > epoch.epochRedeemedNumeraire ? epoch.epochCapNumeraire - epoch.epochRedeemedNumeraire : 0n;
4092
+ const remainingTokens = await convertNumeraireToToken(
4093
+ publicClient,
4094
+ feeCalculator,
4095
+ feeVersion,
4096
+ vaultAddress,
4097
+ token.address,
4098
+ remainingNumeraire,
4099
+ quoteReadContext
4100
+ );
4101
+ const quoteDetails = {
4102
+ shares,
4103
+ maxUnitsIn,
4104
+ tokensOut,
4105
+ minTokensOut,
4106
+ shareSafeTokensOut,
4107
+ rate,
4108
+ capacity: {
4109
+ epochCapNumeraire: epoch.epochCapNumeraire,
4110
+ epochRedeemedNumeraire: epoch.epochRedeemedNumeraire,
4111
+ remainingNumeraire,
4112
+ remainingTokens,
4113
+ knownLiquidityTokens,
4114
+ requestNumeraire,
4115
+ exceedsCapacity: requestNumeraire > remainingNumeraire
4116
+ },
4117
+ unitsLockedUntil,
4118
+ context: {
4119
+ vaultId: params.vaultId,
4120
+ chainId,
4121
+ tokenAddress: token.address,
4122
+ ...params.account ? { account: params.account } : {},
4123
+ slippageBps,
4124
+ blockNumber: quoteReadContext.blockNumber,
4125
+ request
4126
+ }
4127
+ };
4128
+ if (kind === "redeem") return { kind, ...quoteDetails };
4129
+ return { kind, ...quoteDetails };
4130
+ }
4131
+
4132
+ // src/evm/tokenModes.ts
4133
+ async function getAeraTokenModeSupport(client, params) {
4134
+ const resolved = await resolveVault(client, params.vaultId, params.chainId);
4135
+ if (!resolved) throw new VaultNotFoundError(params.vaultId);
4136
+ const { vault, protocol } = resolved;
4137
+ if (protocol !== "aera") {
4138
+ throw new UnsupportedFeatureError("Token mode support is only available for Aera vaults");
4139
+ }
4140
+ const chainId = params.chainId ?? vault.chainId;
4141
+ const publicClient = client.getPublicClient(chainId);
4142
+ const token = vault.supplyToken.length > 1 ? vault.supplyToken.find((tInfo) => tInfo.symbol === params.assetSymbol) : vault.supplyToken[0];
4143
+ if (token === void 0) {
4144
+ throw new UnsupportedAssetError(params.assetSymbol ?? "unknown", params.vaultId);
4145
+ }
4146
+ const runtime = await resolveAeraRuntimeContracts(publicClient, vault);
4147
+ return resolveAeraTokenModeSupport(publicClient, runtime, token.address);
4148
+ }
4149
+
4150
+ // src/evm/userCurrentBalance.ts
4151
+ import { parseAbi } from "viem";
4152
+ var DEPOSIT_REQUESTED_V1_ABI = [
4153
+ {
4154
+ type: "event",
4155
+ name: "DepositRequested",
4156
+ inputs: [
4157
+ { type: "address", name: "user", indexed: true },
4158
+ { type: "address", name: "token", indexed: true },
4159
+ { type: "uint256", name: "tokensIn", indexed: false },
4160
+ { type: "uint256", name: "minUnitsOut", indexed: false },
4161
+ { type: "uint256", name: "solverTip", indexed: false },
4162
+ { type: "uint256", name: "deadline", indexed: false },
4163
+ { type: "uint256", name: "maxPriceAge", indexed: false },
4164
+ { type: "bool", name: "isFixedPrice", indexed: false },
4165
+ { type: "bytes32", name: "depositRequestHash", indexed: false }
4166
+ ]
4167
+ }
4168
+ ];
4169
+ var REDEEM_REQUESTED_V1_ABI = [
4170
+ {
4171
+ type: "event",
4172
+ name: "RedeemRequested",
4173
+ inputs: [
4174
+ { type: "address", name: "user", indexed: true },
4175
+ { type: "address", name: "token", indexed: true },
4176
+ { type: "uint256", name: "minTokensOut", indexed: false },
4177
+ { type: "uint256", name: "unitsIn", indexed: false },
4178
+ { type: "uint256", name: "solverTip", indexed: false },
4179
+ { type: "uint256", name: "deadline", indexed: false },
4180
+ { type: "uint256", name: "maxPriceAge", indexed: false },
4181
+ { type: "bool", name: "isFixedPrice", indexed: false },
4182
+ { type: "bytes32", name: "redeemRequestHash", indexed: false }
4183
+ ]
4184
+ }
4185
+ ];
4186
+ var provisionerV1StateAbi = parseAbi([
4187
+ "function asyncDepositHashes(bytes32 asyncDepositHash) view returns (bool exists)",
4188
+ "function asyncRedeemHashes(bytes32 asyncRedeemHash) view returns (bool exists)"
4189
+ ]);
4190
+ function dedupeByRequestHash(logs, hashKey) {
4191
+ const seen = /* @__PURE__ */ new Set();
4192
+ return logs.filter((log) => {
4193
+ const hash = log.args[hashKey];
4194
+ if (hash == null || seen.has(hash)) return false;
4195
+ seen.add(hash);
4196
+ return true;
4197
+ });
4198
+ }
4199
+ async function queryDeploymentBalance(client, deployment, address) {
4200
+ const publicClient = client.getPublicClient(deployment.chainId);
4201
+ const token = deployment.supplyToken[0];
4202
+ const vaultContract = getMultiDepositorVault(publicClient, deployment.vaultAddress);
4203
+ const [runtime, units] = await Promise.all([
4204
+ resolveAeraRuntimeContracts(publicClient, deployment),
4205
+ vaultContract.read.balanceOf([address])
4206
+ ]);
4207
+ const provisionerAddress = runtime.provisioner.address;
4208
+ const isV2 = runtime.provisioner.version === ContractVersion.V2;
4209
+ const unitsLockedUntilPromise = isV2 ? getUserUnitsRefundableUntil(publicClient, provisionerAddress, address) : Promise.resolve(void 0);
4210
+ const balance = await convertUnitsToToken(
4211
+ publicClient,
4212
+ runtime.feeCalculator.address,
4213
+ runtime.feeCalculator.version,
4214
+ deployment.vaultAddress,
4215
+ token.address,
4216
+ units
4217
+ );
4218
+ const currentBlock = await publicClient.getBlockNumber();
4219
+ const lookback = BLOCKS_3_DAYS[deployment.chainId] ?? DEFAULT_BLOCKS_3_DAYS;
4220
+ const fromBlock = currentBlock > lookback ? currentBlock - lookback : 0n;
4221
+ const chunks = [];
4222
+ for (let cursor = fromBlock; cursor <= currentBlock; cursor += LOG_PAGE_SIZE + 1n) {
4223
+ const end = cursor + LOG_PAGE_SIZE <= currentBlock ? cursor + LOG_PAGE_SIZE : currentBlock;
4224
+ chunks.push([cursor, end]);
4225
+ }
4226
+ const [depositPages, redeemPages] = await Promise.all([
4227
+ Promise.all(
4228
+ chunks.map(
4229
+ ([from, to]) => isV2 ? publicClient.getContractEvents({
4230
+ address: provisionerAddress,
4231
+ abi: provisionerV2Abi,
4232
+ eventName: "DepositRequested",
4233
+ args: { receiver: address },
4234
+ fromBlock: from,
4235
+ toBlock: to
4236
+ }) : publicClient.getContractEvents({
4237
+ address: provisionerAddress,
4238
+ abi: DEPOSIT_REQUESTED_V1_ABI,
4239
+ eventName: "DepositRequested",
4240
+ args: { user: address },
4241
+ fromBlock: from,
4242
+ toBlock: to
4243
+ })
4244
+ )
4245
+ ),
4246
+ Promise.all(
4247
+ chunks.map(
4248
+ ([from, to]) => isV2 ? publicClient.getContractEvents({
4249
+ address: provisionerAddress,
4250
+ abi: provisionerV2Abi,
4251
+ eventName: "RedeemRequested",
4252
+ args: { user: address },
4253
+ fromBlock: from,
4254
+ toBlock: to
4255
+ }) : publicClient.getContractEvents({
4256
+ address: provisionerAddress,
4257
+ abi: REDEEM_REQUESTED_V1_ABI,
4258
+ eventName: "RedeemRequested",
4259
+ args: { user: address },
4260
+ fromBlock: from,
4261
+ toBlock: to
4262
+ })
4263
+ )
4264
+ )
4265
+ ]);
4266
+ const depositLogs = dedupeByRequestHash(depositPages.flat(), "depositRequestHash");
4267
+ const redeemLogs = dedupeByRequestHash(redeemPages.flat(), "redeemRequestHash");
4268
+ const pendingChecks = await publicClient.multicall({
4269
+ contracts: [
4270
+ ...depositLogs.map((log) => ({
4271
+ address: provisionerAddress,
4272
+ abi: isV2 ? provisionerV2Abi : provisionerV1StateAbi,
4273
+ functionName: isV2 ? "asyncRequestHashes" : "asyncDepositHashes",
4274
+ args: [log.args.depositRequestHash]
4275
+ })),
4276
+ ...redeemLogs.map((log) => ({
4277
+ address: provisionerAddress,
4278
+ abi: isV2 ? provisionerV2Abi : provisionerV1StateAbi,
4279
+ functionName: isV2 ? "asyncRequestHashes" : "asyncRedeemHashes",
4280
+ args: [log.args.redeemRequestHash]
4281
+ }))
4282
+ ],
4283
+ allowFailure: false
4284
+ });
4285
+ const depositChecks = pendingChecks.slice(0, depositLogs.length);
4286
+ const redeemChecks = pendingChecks.slice(depositLogs.length);
4287
+ let pendingDeposit = 0n;
4288
+ for (let i = 0; i < depositLogs.length; i++) {
4289
+ if (depositChecks[i]) {
4290
+ pendingDeposit += depositLogs[i].args.tokensIn ?? 0n;
4291
+ }
4292
+ }
4293
+ let pendingWithdrawUnits = 0n;
4294
+ for (let i = 0; i < redeemLogs.length; i++) {
4295
+ if (redeemChecks[i]) {
4296
+ pendingWithdrawUnits += redeemLogs[i].args.unitsIn ?? 0n;
4297
+ }
4298
+ }
4299
+ const pendingWithdraw = pendingWithdrawUnits > 0n ? await convertUnitsToToken(
4300
+ publicClient,
4301
+ runtime.feeCalculator.address,
4302
+ runtime.feeCalculator.version,
4303
+ deployment.vaultAddress,
4304
+ token.address,
4305
+ pendingWithdrawUnits
4306
+ ) : 0n;
4307
+ const unitsLockedUntil = await unitsLockedUntilPromise;
4308
+ return {
4309
+ chain: CHAIN_NAMES[deployment.chainId] ?? `chain-${deployment.chainId}`,
4310
+ chainId: deployment.chainId,
4311
+ token: token.address,
4312
+ decimals: token.decimals,
4313
+ pendingDeposit,
4314
+ balance,
4315
+ pendingWithdraw,
4316
+ ...unitsLockedUntil !== void 0 ? { unitsLockedUntil } : {}
4317
+ };
4318
+ }
4319
+ async function getUserCurrentBalance(client, params) {
4320
+ const manifest = await client.manifest;
4321
+ const vaultInfo = manifest.vaults.find((v) => v.vaultId === params.vaultId);
4322
+ if (!vaultInfo) throw new VaultNotFoundError(params.vaultId);
4323
+ const evmDeployments = vaultInfo.deployments.filter(
4324
+ (d) => d.chain === "evm" && d.vaultType === "multi-depositor"
4325
+ );
4326
+ if (vaultInfo.protocol !== "aera" || evmDeployments.length === 0) {
4327
+ throw new UnsupportedProtocolError(vaultInfo.protocol);
4328
+ }
4329
+ if (params.chainId !== void 0) {
4330
+ const deployment = evmDeployments.find((d) => d.chainId === params.chainId);
4331
+ if (!deployment) {
4332
+ throw new ChainMismatchError(
4333
+ `${params.chainId}`,
4334
+ evmDeployments.map((d) => `${d.chainId}`).join(", ")
4335
+ );
4336
+ }
4337
+ return [await queryDeploymentBalance(client, deployment, params.address)];
4338
+ }
4339
+ return Promise.all(evmDeployments.map((d) => queryDeploymentBalance(client, d, params.address)));
4340
+ }
4341
+
4342
+ export {
4343
+ ContractVersion,
4344
+ resolveContractVersion,
4345
+ resolveAeraRuntimeContracts,
4346
+ convertTokenToUnitsIfActive,
4347
+ convertUnitsToTokenIfActive,
4348
+ convertTokenToUnits,
4349
+ convertUnitsToToken,
4350
+ getAnchorTimestamp,
4351
+ getVaultState,
4352
+ isVaultPaused,
4353
+ Rounding,
4354
+ getDepositTx,
4355
+ getDepositReceiverApprovalTx,
4356
+ getSyncDepositQuote2 as getSyncDepositQuote,
4357
+ getSyncDepositRate,
4358
+ getWithdrawTx,
4359
+ getSyncWithdrawRate,
4360
+ getSyncWithdrawQuote,
4361
+ getAeraTokenModeSupport,
4362
+ getUserCurrentBalance
4363
+ };
4364
+ //# sourceMappingURL=chunk-7TA2OJUK.js.map