@oakagentkit/core 0.3.3 → 0.3.5

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 (302) hide show
  1. package/build/dist/api/canonical.js +1 -1
  2. package/build/dist/api/history.d.ts +0 -3
  3. package/build/dist/api/history.js +1 -1
  4. package/build/dist/api/merkle.d.ts +1 -27
  5. package/build/dist/api/merkle.js +1 -1
  6. package/build/dist/api/modules/borro/actions.js +1 -1
  7. package/build/dist/api/modules/borro/checks.js +1 -1
  8. package/build/dist/api/modules/borro/index.js +1 -1
  9. package/build/dist/api/modules/borro/liquidity.js +1 -1
  10. package/build/dist/api/modules/borro/positions.js +1 -1
  11. package/build/dist/api/modules/borro/reader.js +1 -1
  12. package/build/dist/api/modules/chop/actions.d.ts +13 -1
  13. package/build/dist/api/modules/chop/actions.js +1 -1
  14. package/build/dist/api/modules/chop/checks.js +1 -1
  15. package/build/dist/api/modules/chop/copy.d.ts +2 -1
  16. package/build/dist/api/modules/chop/copy.js +1 -1
  17. package/build/dist/api/modules/chop/display.d.ts +36 -0
  18. package/build/dist/api/modules/chop/display.js +1 -0
  19. package/build/dist/api/modules/chop/guard.js +1 -1
  20. package/build/dist/api/modules/chop/index.js +1 -1
  21. package/build/dist/api/modules/chop/pins.d.ts +6 -0
  22. package/build/dist/api/modules/chop/pins.js +1 -1
  23. package/build/dist/api/modules/chop/positions.js +1 -1
  24. package/build/dist/api/modules/chop/reader.d.ts +6 -1
  25. package/build/dist/api/modules/chop/reader.js +1 -1
  26. package/build/dist/api/modules/chop/types.d.ts +7 -0
  27. package/build/dist/api/modules/chop/unfarm.d.ts +16 -0
  28. package/build/dist/api/modules/chop/unfarm.js +1 -0
  29. package/build/dist/api/modules/clanker/index.js +1 -1
  30. package/build/dist/api/modules/earn/index.js +1 -1
  31. package/build/dist/api/modules/erc8004/index.js +1 -1
  32. package/build/dist/api/modules/factor/actions.js +1 -1
  33. package/build/dist/api/modules/factor/api.js +1 -1
  34. package/build/dist/api/modules/factor/checks.js +1 -1
  35. package/build/dist/api/modules/factor/copy.d.ts +11 -11
  36. package/build/dist/api/modules/factor/copy.js +1 -1
  37. package/build/dist/api/modules/factor/guard.js +1 -1
  38. package/build/dist/api/modules/factor/index.js +1 -1
  39. package/build/dist/api/modules/factor/reader.js +1 -1
  40. package/build/dist/api/modules/fobo/client.d.ts +5 -0
  41. package/build/dist/api/modules/fobo/client.js +1 -1
  42. package/build/dist/api/modules/fobo/health.d.ts +4 -0
  43. package/build/dist/api/modules/fobo/health.js +1 -0
  44. package/build/dist/api/modules/fobo/index.js +1 -1
  45. package/build/dist/api/modules/fobo/referral.d.ts +2 -0
  46. package/build/dist/api/modules/fobo/referral.js +1 -0
  47. package/build/dist/api/modules/fobo/steps.js +1 -1
  48. package/build/dist/api/modules/gloam/index.js +1 -1
  49. package/build/dist/api/modules/grove/index.js +1 -1
  50. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  51. package/build/dist/api/modules/heyresearch/index.js +1 -1
  52. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  53. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  54. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  55. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  56. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  57. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  58. package/build/dist/api/modules/hoodlock/index.js +1 -1
  59. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  60. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  61. package/build/dist/api/modules/hoodlock/public.js +1 -1
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  64. package/build/dist/api/modules/hookr/discovery.js +1 -1
  65. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  66. package/build/dist/api/modules/hookr/index.js +1 -1
  67. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  68. package/build/dist/api/modules/hookr/launch.js +1 -1
  69. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  70. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  71. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  72. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  73. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  74. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  75. package/build/dist/api/modules/hookr/relay.js +1 -1
  76. package/build/dist/api/modules/layerbank/actions.js +1 -1
  77. package/build/dist/api/modules/layerbank/index.js +1 -1
  78. package/build/dist/api/modules/layerbank/reader.js +1 -1
  79. package/build/dist/api/modules/longbow/administration.js +1 -1
  80. package/build/dist/api/modules/longbow/fixed.js +1 -1
  81. package/build/dist/api/modules/longbow/index.js +1 -1
  82. package/build/dist/api/modules/meridian/index.js +1 -1
  83. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  84. package/build/dist/api/modules/merkl/discovery.js +1 -1
  85. package/build/dist/api/modules/merkl/index.js +1 -1
  86. package/build/dist/api/modules/merkl/manage.js +1 -1
  87. package/build/dist/api/modules/morpho/bundles.js +1 -1
  88. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  89. package/build/dist/api/modules/morpho/index.js +1 -1
  90. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  91. package/build/dist/api/modules/morpho/midnight.js +1 -1
  92. package/build/dist/api/modules/morpho/protocol.js +1 -1
  93. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  94. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  95. package/build/dist/api/modules/netnet/card-read.js +1 -1
  96. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  97. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  98. package/build/dist/api/modules/netnet/financial.js +1 -1
  99. package/build/dist/api/modules/netnet/index.js +1 -1
  100. package/build/dist/api/modules/pendle/index.js +1 -1
  101. package/build/dist/api/modules/pendle/reader.js +1 -1
  102. package/build/dist/api/modules/pons/index.js +1 -1
  103. package/build/dist/api/modules/priors/coverage.js +1 -1
  104. package/build/dist/api/modules/priors/discovery.js +1 -1
  105. package/build/dist/api/modules/priors/index.js +1 -1
  106. package/build/dist/api/modules/priors/integration.js +1 -1
  107. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  108. package/build/dist/api/modules/raeto/authorization.js +1 -1
  109. package/build/dist/api/modules/raeto/copy.js +1 -1
  110. package/build/dist/api/modules/raeto/errors.js +1 -1
  111. package/build/dist/api/modules/raeto/estimate.js +1 -1
  112. package/build/dist/api/modules/raeto/index.js +1 -1
  113. package/build/dist/api/modules/raeto/terms.js +1 -1
  114. package/build/dist/api/modules/relay/index.js +1 -1
  115. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  116. package/build/dist/api/modules/spark/index.js +1 -1
  117. package/build/dist/api/modules/steakhouse/index.js +1 -1
  118. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  119. package/build/dist/api/modules/steakhouse/management.js +1 -1
  120. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  121. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  122. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  123. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  124. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  125. package/build/dist/api/modules/tickerspring/index.js +1 -1
  126. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  127. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  128. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  129. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  130. package/build/dist/api/modules/tickerspring/research.js +1 -1
  131. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  132. package/build/dist/api/modules/transfer/stocks.d.ts +18 -0
  133. package/build/dist/api/modules/transfer/stocks.js +1 -0
  134. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  135. package/build/dist/api/modules/uniswap/auction.js +1 -1
  136. package/build/dist/api/modules/uniswap/batch.js +1 -1
  137. package/build/dist/api/modules/uniswap/common.js +1 -1
  138. package/build/dist/api/modules/uniswap/fees.js +1 -1
  139. package/build/dist/api/modules/uniswap/index.js +1 -1
  140. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  141. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  142. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  143. package/build/dist/api/modules/uniswap/pools.js +1 -1
  144. package/build/dist/api/modules/uniswap/position.js +1 -1
  145. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  146. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  147. package/build/dist/api/modules/uniswap/stock-prices.d.ts +9 -0
  148. package/build/dist/api/modules/uniswap/stock-prices.js +1 -0
  149. package/build/dist/api/modules/uniswap/stocks.d.ts +17 -0
  150. package/build/dist/api/modules/uniswap/stocks.js +1 -0
  151. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  152. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  153. package/build/dist/api/modules/uniswap/trade.js +1 -1
  154. package/build/dist/api/modules/uniswap/v2.js +1 -1
  155. package/build/dist/api/modules/uniswap/v3.js +1 -1
  156. package/build/dist/api/modules/uniswap/v4.js +1 -1
  157. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  158. package/build/dist/api/modules/upoch/index.js +1 -1
  159. package/build/dist/api/modules/upoch/reads.js +1 -1
  160. package/build/dist/api/modules/wormhole/index.js +1 -1
  161. package/build/dist/api/prices.d.ts +13 -11
  162. package/build/dist/api/prices.js +1 -1
  163. package/build/dist/api/pricing.d.ts +0 -6
  164. package/build/dist/api/pricing.js +1 -1
  165. package/build/dist/api/send.js +1 -1
  166. package/build/dist/api/signing-registry.js +1 -1
  167. package/build/dist/api/stocks.d.ts +6 -0
  168. package/build/dist/api/stocks.js +1 -0
  169. package/build/dist/api/tokens.d.ts +23 -1
  170. package/build/dist/api/tokens.js +1 -1
  171. package/build/dist/api/tool-policy.js +1 -1
  172. package/build/dist/api/types.d.ts +0 -26
  173. package/build/dist/api/usd-estimate.d.ts +2 -0
  174. package/build/dist/api/usd-estimate.js +1 -1
  175. package/build/dist/chunks/{ODV3XT5U.js → 2FOI2625.js} +1 -1
  176. package/build/dist/chunks/{73BZPPRS.js → 2I7XHRTI.js} +1 -1
  177. package/build/dist/chunks/{257N7343.js → 2PS4GCOZ.js} +1 -1
  178. package/build/dist/chunks/{RA7DOR7F.js → 3BQ5XHDJ.js} +1 -1
  179. package/build/dist/chunks/{5UAXLWJ2.js → 3UC42OJX.js} +1 -1
  180. package/build/dist/chunks/{KVVBT43U.js → 3YH5B5NQ.js} +1 -1
  181. package/build/dist/chunks/{VVJO6OYK.js → 4CEV4FDG.js} +1 -1
  182. package/build/dist/chunks/{RUSXMQSJ.js → 4HQEJHCD.js} +1 -1
  183. package/build/dist/chunks/{HIG7JY3J.js → 4IOHSX3Z.js} +1 -1
  184. package/build/dist/chunks/4UOVKEV4.js +1 -0
  185. package/build/dist/chunks/5H7NVE6O.js +1 -0
  186. package/build/dist/chunks/{JJGZ7W3V.js → 6AS3TGOX.js} +1 -1
  187. package/build/dist/chunks/{AWV24X7F.js → 6CKCZJ3F.js} +1 -1
  188. package/build/dist/chunks/{35LXCSHY.js → 6LVHN33V.js} +1 -1
  189. package/build/dist/chunks/7OOCAZBE.js +1 -0
  190. package/build/dist/chunks/{75SULXNT.js → 7TRO6MBQ.js} +1 -1
  191. package/build/dist/chunks/{EHGH646D.js → A4FLWHLP.js} +1 -1
  192. package/build/dist/chunks/{XVOW6UCI.js → A4K5GXVO.js} +1 -1
  193. package/build/dist/chunks/AL6UXNGH.js +6 -0
  194. package/build/dist/chunks/BJ2U2VXJ.js +1 -0
  195. package/build/dist/chunks/{4TTDAF4B.js → C4XK764N.js} +1 -1
  196. package/build/dist/chunks/{3BMM3V4P.js → C57DITTF.js} +1 -1
  197. package/build/dist/chunks/CFPJDLTZ.js +1 -0
  198. package/build/dist/chunks/{CXH46MHJ.js → CNDIAF3P.js} +1 -1
  199. package/build/dist/chunks/{K4GUZ5QS.js → CW37EGPL.js} +1 -1
  200. package/build/dist/chunks/{22TU5PFT.js → E47UYYK4.js} +1 -1
  201. package/build/dist/chunks/EPOIAXCV.js +3 -0
  202. package/build/dist/chunks/{RXP7ZUPY.js → FCVH4FYH.js} +1 -1
  203. package/build/dist/chunks/{ZSVAGOF2.js → FHB7QYJO.js} +1 -1
  204. package/build/dist/chunks/FRT6AC6M.js +1 -0
  205. package/build/dist/chunks/{NUERUFH7.js → FRVCSDKU.js} +1 -1
  206. package/build/dist/chunks/{LEV5SNNC.js → FUP53K6G.js} +1 -1
  207. package/build/dist/chunks/{5DPJQCKJ.js → FWOGOWUM.js} +2 -2
  208. package/build/dist/chunks/{5CPB33XA.js → G5AMH4IP.js} +1 -1
  209. package/build/dist/chunks/{JDSSYT6R.js → GBPB7JIB.js} +1 -1
  210. package/build/dist/chunks/{MGVX5EUH.js → GDUKZYE2.js} +1 -1
  211. package/build/dist/chunks/{47HSRR7G.js → GKUPC4DO.js} +1 -1
  212. package/build/dist/chunks/{K7HTDKAT.js → GMMTHTCP.js} +1 -1
  213. package/build/dist/chunks/{27PVS6BU.js → HDBZZOHJ.js} +1 -1
  214. package/build/dist/chunks/{FHTNMGFR.js → HKHCN4A2.js} +1 -1
  215. package/build/dist/chunks/{VC5ZCQYZ.js → HPS4KOU4.js} +1 -1
  216. package/build/dist/chunks/IZP3EKKS.js +1 -0
  217. package/build/dist/chunks/{VFM2BICB.js → J7OZLXSG.js} +1 -1
  218. package/build/dist/chunks/{6D3XNCOX.js → JDHPMS7X.js} +1 -1
  219. package/build/dist/chunks/JFC2QCMW.js +1 -0
  220. package/build/dist/chunks/{OFWTO4N6.js → JJSCDDQO.js} +1 -1
  221. package/build/dist/chunks/{EFESPGA2.js → KCZUJ57H.js} +1 -1
  222. package/build/dist/chunks/KHOUBQJK.js +1 -0
  223. package/build/dist/chunks/{UEHN2IDF.js → KKTOBXIT.js} +1 -1
  224. package/build/dist/chunks/KNROSKUG.js +1 -0
  225. package/build/dist/chunks/{SO6O7JK2.js → KO7ANIKY.js} +1 -1
  226. package/build/dist/chunks/{DLNA5272.js → LKUZAJPZ.js} +1 -1
  227. package/build/dist/chunks/{5GQJVKVY.js → LZM3DO5Q.js} +1 -1
  228. package/build/dist/chunks/M267JEDO.js +1 -0
  229. package/build/dist/chunks/M6JNGU4E.js +1 -0
  230. package/build/dist/chunks/{SNCV6HV7.js → M7OVMIIE.js} +1 -1
  231. package/build/dist/chunks/{VDJPDIBV.js → MJGEGNDU.js} +1 -1
  232. package/build/dist/chunks/{XKLXVTSE.js → MQXSCNUL.js} +1 -1
  233. package/build/dist/chunks/N624NR7Y.js +1 -0
  234. package/build/dist/chunks/{M4AGEGWW.js → N65J3L2H.js} +1 -1
  235. package/build/dist/chunks/{3UQXTZ5R.js → N742W5KX.js} +1 -1
  236. package/build/dist/chunks/NIWAVMDR.js +1 -0
  237. package/build/dist/chunks/O2QBSINK.js +1 -0
  238. package/build/dist/chunks/{7TSIF3F4.js → O4P5IQCP.js} +1 -1
  239. package/build/dist/chunks/{HUKDISRE.js → OB3YMTDI.js} +1 -1
  240. package/build/dist/chunks/{GGMVT5A6.js → PV7FEVBD.js} +1 -1
  241. package/build/dist/chunks/{PDGYM2WG.js → Q3Q3YHEX.js} +1 -1
  242. package/build/dist/chunks/QA6Z2CYP.js +2 -0
  243. package/build/dist/chunks/{HPY2ONAS.js → QBNASL3T.js} +1 -1
  244. package/build/dist/chunks/{AHUCYDBC.js → QKIQ7ZKD.js} +1 -1
  245. package/build/dist/chunks/{O3CC5SRM.js → QMIH6HXH.js} +1 -1
  246. package/build/dist/chunks/{3FU6XP6S.js → QQD4PV64.js} +1 -1
  247. package/build/dist/chunks/{VOJULRNU.js → R66NSNNQ.js} +1 -1
  248. package/build/dist/chunks/{SMKO7GKX.js → RP5VCG54.js} +1 -1
  249. package/build/dist/chunks/{7FZXSYFD.js → RUHNLNVX.js} +1 -1
  250. package/build/dist/chunks/{QN45T4N3.js → S37D7HOK.js} +1 -1
  251. package/build/dist/chunks/S47M3IPR.js +1 -0
  252. package/build/dist/chunks/S65KXMZ7.js +3 -0
  253. package/build/dist/chunks/{UBI3HBXD.js → SX5YNFHG.js} +1 -1
  254. package/build/dist/chunks/{SOJHYMD7.js → TGXEKBLV.js} +1 -1
  255. package/build/dist/chunks/{H64QC4QR.js → TJU644I7.js} +1 -1
  256. package/build/dist/chunks/{FSYYD3OM.js → TOIKOIY6.js} +1 -1
  257. package/build/dist/chunks/{I3ZBOSSH.js → TZ7S5KRB.js} +1 -1
  258. package/build/dist/chunks/{XEPCDGN2.js → UCFVPTE2.js} +1 -1
  259. package/build/dist/chunks/UEOS6SHR.js +1 -0
  260. package/build/dist/chunks/{BZPFPQ2I.js → USGMGKAG.js} +1 -1
  261. package/build/dist/chunks/{PKYQ3XVA.js → UUF4Z6K6.js} +1 -1
  262. package/build/dist/chunks/{PMFR47H3.js → VREGY7E6.js} +1 -1
  263. package/build/dist/chunks/{Y7HBFQYG.js → W7BFM6CK.js} +1 -1
  264. package/build/dist/chunks/{72EV7TGI.js → WQ2XTDHO.js} +1 -1
  265. package/build/dist/chunks/WRA3ZC6W.js +1 -0
  266. package/build/dist/chunks/WWYAAIE2.js +1 -0
  267. package/build/dist/chunks/{WCI3FHWT.js → XADHV2DT.js} +1 -1
  268. package/build/dist/chunks/{LVFI74ST.js → XNJ6NDQQ.js} +1 -1
  269. package/build/dist/chunks/{7FIEBJOZ.js → XTXXWRN2.js} +1 -1
  270. package/build/dist/chunks/{PWJVC2FV.js → XWC6IC5E.js} +1 -1
  271. package/build/dist/chunks/{THL4TMQW.js → Y76VZQ26.js} +232 -17
  272. package/build/dist/chunks/{IJ4HZIDG.js → YWVPK3DV.js} +1 -1
  273. package/build/dist/chunks/{WNWRF4HE.js → YZHJ4BAP.js} +1 -1
  274. package/build/dist/chunks/{ZDCCFEVL.js → ZKBOPZH5.js} +1 -1
  275. package/build/dist/chunks/{UCHJYWGU.js → ZQPC54J5.js} +1 -1
  276. package/build/dist/chunks/{6GWXPQZ6.js → ZVY7GGSP.js} +1 -1
  277. package/build/dist/chunks/{LQSPWRHN.js → ZX43P4BK.js} +1 -1
  278. package/build/dist/chunks/{YAVWSW3G.js → ZXFJKW6H.js} +1 -1
  279. package/build/dist/chunks/{QPY6UTLU.js → ZXRIJG6H.js} +1 -1
  280. package/package.json +1 -1
  281. package/build/dist/abi/IOakSubscription.json +0 -1
  282. package/build/dist/api/grandfather.d.ts +0 -56
  283. package/build/dist/api/grandfather.js +0 -1
  284. package/build/dist/chunks/43BG2JRB.js +0 -1
  285. package/build/dist/chunks/5CAAFU7R.js +0 -1
  286. package/build/dist/chunks/7EACRKFV.js +0 -1
  287. package/build/dist/chunks/BGVC5NI6.js +0 -3
  288. package/build/dist/chunks/BJK75C7G.js +0 -1
  289. package/build/dist/chunks/CM4DP2EZ.js +0 -1
  290. package/build/dist/chunks/CU4PWGMJ.js +0 -6
  291. package/build/dist/chunks/DGCJZ3HO.js +0 -1
  292. package/build/dist/chunks/ETMD747Y.js +0 -2
  293. package/build/dist/chunks/KLEJ3W4T.js +0 -1
  294. package/build/dist/chunks/KOKLM63Q.js +0 -3
  295. package/build/dist/chunks/KXX7ZBFY.js +0 -1
  296. package/build/dist/chunks/L2AE32SL.js +0 -1
  297. package/build/dist/chunks/LTDF2LNP.js +0 -1
  298. package/build/dist/chunks/NV6FDIYT.js +0 -1
  299. package/build/dist/chunks/OOPMZIG7.js +0 -1
  300. package/build/dist/chunks/UNJJRQIU.js +0 -1
  301. package/build/dist/chunks/W7QNSNOH.js +0 -1
  302. package/build/dist/chunks/ZOLHVZDK.js +0 -1
@@ -1 +1 @@
1
- import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o}from"../chunks/W7QNSNOH.js";import"../chunks/DCGNVMKG.js";import"../chunks/3PHJUFU2.js";import"../chunks/HZSYMGJ2.js";import"../chunks/LQSPWRHN.js";import"../chunks/GYPMUYB5.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GK3D7OKG.js";import"../chunks/OIQTZOBN.js";import"../chunks/Z7FGEWO2.js";import"../chunks/LIUXNOLP.js";import"../chunks/BSX4LFYI.js";import"../chunks/ELHRXA5U.js";import"../chunks/DGDMRATN.js";import"../chunks/4Z3IGMU6.js";import"../chunks/C76D54YG.js";import"../chunks/TXGZ6NWN.js";import"../chunks/VVAM3EAK.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/MQ5F2VOK.js";import"../chunks/5RXALTDT.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{k as MULTICALL3_ABI,b as NATIVE_ETH_TOKEN,a as STOCK_ASSETS_URL,e as USDE_TOKEN,c as USDG_TOKEN,d as WETH_TOKEN,h as assertOfficialStockIdentity,j as fetchOfficialStockTokens,n as findToken,l as getBalances,i as getOfficialStockTokens,m as getReceivedTokenBalances,f as parseOfficialStockAssets,o as resolveQuoteToken,g as verifyOfficialStockToken};
1
+ import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q}from"../chunks/N624NR7Y.js";import"../chunks/DCGNVMKG.js";import"../chunks/3PHJUFU2.js";import"../chunks/HZSYMGJ2.js";import"../chunks/ZX43P4BK.js";import"../chunks/GYPMUYB5.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GK3D7OKG.js";import"../chunks/OIQTZOBN.js";import"../chunks/Z7FGEWO2.js";import"../chunks/LIUXNOLP.js";import"../chunks/BSX4LFYI.js";import"../chunks/C76D54YG.js";import"../chunks/ELHRXA5U.js";import"../chunks/DGDMRATN.js";import"../chunks/4Z3IGMU6.js";import"../chunks/TXGZ6NWN.js";import"../chunks/CFPJDLTZ.js";import"../chunks/VVAM3EAK.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/MQ5F2VOK.js";import"../chunks/5RXALTDT.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{f as CHOP_TOKENS,l as MULTICALL3_ABI,b as NATIVE_ETH_TOKEN,a as STOCK_ASSETS_URL,e as USDE_TOKEN,c as USDG_TOKEN,d as WETH_TOKEN,i as assertOfficialStockIdentity,n as discoverReceivedTokenAddresses,k as fetchOfficialStockTokens,p as findToken,m as getBalances,j as getOfficialStockTokens,o as getReceivedTokenBalances,g as parseOfficialStockAssets,q as resolveQuoteToken,h as verifyOfficialStockToken};
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i}from"../chunks/OOPMZIG7.js";import{a}from"../chunks/WRUTW6CG.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{c as COMING_SOON,d as FIND_TOOL,g as LOCAL_TOOLS,e as RUN_TOOL,f as UPOCH_READ_TOOLS,h as VISIBLE_TOOLS,a as isFundingBootstrap,b as isReadDiscovery,i as visibleTools};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i}from"../chunks/M267JEDO.js";import{a}from"../chunks/WRUTW6CG.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{c as COMING_SOON,d as FIND_TOOL,g as LOCAL_TOOLS,e as RUN_TOOL,f as UPOCH_READ_TOOLS,h as VISIBLE_TOOLS,a as isFundingBootstrap,b as isReadDiscovery,i as visibleTools};
@@ -173,24 +173,6 @@ export interface ProjectModulePart {
173
173
  positions?(wallet: Address, options?: PositionReaderOptions): Promise<Position[]>;
174
174
  }
175
175
  export type CreateModulePart = (context: ModuleContext) => ProjectModulePart;
176
- export interface BuilderGrant {
177
- project: string;
178
- startsAt: DecimalString;
179
- endsAt: DecimalString;
180
- }
181
- export interface Account {
182
- plan: 'none' | 'holder' | 'nohold';
183
- contract: Address;
184
- paidUntil: DecimalString;
185
- oakHeld: DecimalString;
186
- oakRequired: DecimalString;
187
- phase: 'curve' | 'warmup' | 'ready';
188
- holderOpen: boolean;
189
- noHoldPrice: DecimalString | 'unavailable';
190
- priceError?: string;
191
- grant?: BuilderGrant;
192
- nextPaymentAt?: DecimalString;
193
- }
194
176
  export interface PriceNote {
195
177
  wallet: Address;
196
178
  oakPerEthE18: DecimalString;
@@ -212,11 +194,6 @@ export interface SwapTrade {
212
194
  sqrtPriceX96: DecimalString;
213
195
  oakPerEthE18: DecimalString;
214
196
  }
215
- export interface GrandfatherEntry {
216
- wallet: Address;
217
- count: DecimalString;
218
- source: Address;
219
- }
220
197
  export interface SignedPriceNote {
221
198
  note: PriceNote;
222
199
  signature: Hex;
@@ -231,9 +208,6 @@ export interface NoteRefusal {
231
208
  retryAt?: DecimalString;
232
209
  }
233
210
  export type NoteTarget = {
234
- for: 'subscription';
235
- wallet: Address;
236
- } | {
237
211
  for: 'burner';
238
212
  wallet?: Address;
239
213
  };
@@ -1,4 +1,5 @@
1
1
  import { type Address } from 'viem';
2
+ import type { VerifiedLog } from './modules/chop/types.js';
2
3
  import type { ModuleContext, Token, TokenAmount } from './types.js';
3
4
  export interface UsdEstimateFields {
4
5
  usdEstimate: string | null;
@@ -19,5 +20,6 @@ export type UsdEstimateContext = Pick<ModuleContext, 'clientFor'> & {
19
20
  export interface UsdEstimateOptions {
20
21
  budgetMs?: number;
21
22
  chopShareTokens?: readonly Address[];
23
+ chopShareFacts?: readonly VerifiedLog[];
22
24
  }
23
25
  export declare function estimateUsd<T extends TokenAmount>(context: UsdEstimateContext, rows: readonly T[], options?: UsdEstimateOptions): Promise<(T & UsdEstimateFields)[]>;
@@ -1 +1 @@
1
- import{a}from"../chunks/43BG2JRB.js";import"../chunks/NV6FDIYT.js";import"../chunks/WSILNJS2.js";import"../chunks/7EACRKFV.js";import"../chunks/Y2QADJOB.js";import"../chunks/W7QNSNOH.js";import"../chunks/DCGNVMKG.js";import"../chunks/3PHJUFU2.js";import"../chunks/HZSYMGJ2.js";import"../chunks/LQSPWRHN.js";import"../chunks/GYPMUYB5.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GK3D7OKG.js";import"../chunks/OIQTZOBN.js";import"../chunks/Z7FGEWO2.js";import"../chunks/LIUXNOLP.js";import"../chunks/BSX4LFYI.js";import"../chunks/ELHRXA5U.js";import"../chunks/DGDMRATN.js";import"../chunks/4Z3IGMU6.js";import"../chunks/C76D54YG.js";import"../chunks/TXGZ6NWN.js";import"../chunks/L2AE32SL.js";import"../chunks/VVAM3EAK.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/MQ5F2VOK.js";import"../chunks/5RXALTDT.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{a as estimateUsd};
1
+ import{a}from"../chunks/5H7NVE6O.js";import"../chunks/7OOCAZBE.js";import"../chunks/WSILNJS2.js";import"../chunks/KHOUBQJK.js";import"../chunks/JFC2QCMW.js";import"../chunks/Y2QADJOB.js";import"../chunks/N624NR7Y.js";import"../chunks/DCGNVMKG.js";import"../chunks/3PHJUFU2.js";import"../chunks/HZSYMGJ2.js";import"../chunks/ZX43P4BK.js";import"../chunks/GYPMUYB5.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GK3D7OKG.js";import"../chunks/OIQTZOBN.js";import"../chunks/Z7FGEWO2.js";import"../chunks/LIUXNOLP.js";import"../chunks/BSX4LFYI.js";import"../chunks/C76D54YG.js";import"../chunks/ELHRXA5U.js";import"../chunks/DGDMRATN.js";import"../chunks/4Z3IGMU6.js";import"../chunks/TXGZ6NWN.js";import"../chunks/S65KXMZ7.js";import"../chunks/CW37EGPL.js";import"../chunks/K6D6SDIG.js";import"../chunks/QA6Z2CYP.js";import"../chunks/CFPJDLTZ.js";import"../chunks/VVAM3EAK.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/MQ5F2VOK.js";import"../chunks/5RXALTDT.js";import"../chunks/TI727O2H.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{a as estimateUsd};
@@ -1 +1 @@
1
- import{a as c,b as F,e as P,f as T,g as I}from"./QPY6UTLU.js";import{a as l}from"./66F5ZH34.js";import{c as N,g,h as S}from"./NWNYJ26T.js";import{b as h}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as _,parseAbi as Q,parseAbiItem as j,zeroAddress as H}from"viem";var x=_("0x000000001f26a0044baa66024e7b6599c61963f8"),M=j("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),o=Q(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function D(s,y){let n=F(y.auction),t=c(y.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:M,args:{auction:n},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,n))throw new u("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return n}async function E(s,y){let n=s.clientFor(h),t=await D(n,y),e=await n.getBlockNumber(),[a,b,i,k,m,v,d,B]=await Promise.all([n.readContract({address:t,abi:o,functionName:"currency",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"token",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"startBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"endBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"claimBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"validationHook",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"clearingPrice",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:b,startBlock:i,endBlock:k,claimBlock:m,validationHook:v,clearingPrice:d,graduated:B,blockNumber:e}}var L={auction:{...N,description:"Address of the continuous clearing auction to verify against the pinned factory."},creationBlock:l("Auction creation block number, as a decimal string, used to verify the factory event."),bidId:l('Identifier of the auction bid, as a decimal string. Example: "1".'),amount:l('Amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),maxPrice:l("Maximum bid price in Q96 payment-currency base units per sale-token base unit."),prevTickPrice:l("Previous auction price tick in Q96 payment-currency base units per sale-token base unit; zero for the first tick."),lastFullyFilledCheckpointBlock:l("Last fully filled checkpoint block number for a partial bid exit, as a decimal string."),outbidBlock:l("Block number at which the bid was outbid, as a decimal string."),mode:{description:'Choose "full" to exit a bid, or "partial" to exit using checkpoint and outbid block hints.',type:"string",enum:["full","partial"]},bidIds:{description:'One to fifty unique auction bid identifiers as decimal strings. Example: ["1", "2"].',type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let n=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:L},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await E(s,e),k=s.clientFor(h),[m,v]=await Promise.all([P(s,i.currency,i.blockNumber),P(s,i.saleToken,i.blockNumber)]),d=e.bidId===void 0?void 0:await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:v,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...d?{bid:{...d,startBlock:d.startBlock.toString(),exitedBlock:d.exitedBlock.toString(),maxPrice:d.maxPrice.toString(),amountQ96:d.amountQ96.toString(),tokensFilled:d.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let B=[],f,A=0n;if(t==="bid"){if(i.validationHook!==H)throw new u("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new u("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),C=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new u("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?A=r:B.push(s.approval(i.currency,i.auction,r.toString(),h)),f=w({abi:o,functionName:"submitBid",args:[p,r,a,C,"0x"]})}else if(t==="exit"){if(!d||!g(d.owner,a))throw new u("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new u("Full exit takes no checkpoint hints.");f=w({abi:o,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=w({abi:o,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new u("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new u("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new u("Provide 1 to 50 unique bid IDs.");for(let p of r){let C=await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(C.owner,a))throw new u("Claimed tokens must belong to the signing wallet.")}f=w({abi:o,functionName:"claimTokensBatch",args:[a,r]})}else f=w({abi:o,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return B.push(s.unsignedTx({to:i.auction,data:f,value:A.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),T(s,B,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return n.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l("First block number of the scan, as a decimal string; inclusive."),toBlock:l("Last block number of the scan, as a decimal string; inclusive.")}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),b=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(b>i||i>a||i-b>=10000n)throw new u("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let k=await e.getLogs({address:x,event:M,fromBlock:b,toBlock:i,strict:!0});return{factory:x,fromBlock:b.toString(),toBlock:i.toString(),auctions:k.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:n}}export{x as a,M as b,o as c,D as d,E as e,R as f};
1
+ import{a as c,b as F,e as P,f as T,g as I}from"./ZXRIJG6H.js";import{a as l}from"./66F5ZH34.js";import{c as N,g,h as S}from"./NWNYJ26T.js";import{b as h}from"./TI727O2H.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as _,parseAbi as Q,parseAbiItem as j,zeroAddress as H}from"viem";var x=_("0x000000001f26a0044baa66024e7b6599c61963f8"),M=j("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),o=Q(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function D(s,y){let n=F(y.auction),t=c(y.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:M,args:{auction:n},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,n))throw new u("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return n}async function E(s,y){let n=s.clientFor(h),t=await D(n,y),e=await n.getBlockNumber(),[a,b,i,k,m,v,d,B]=await Promise.all([n.readContract({address:t,abi:o,functionName:"currency",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"token",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"startBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"endBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"claimBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"validationHook",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"clearingPrice",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:b,startBlock:i,endBlock:k,claimBlock:m,validationHook:v,clearingPrice:d,graduated:B,blockNumber:e}}var L={auction:{...N,description:"Address of the continuous clearing auction to verify against the pinned factory."},creationBlock:l("Auction creation block number, as a decimal string, used to verify the factory event."),bidId:l('Identifier of the auction bid, as a decimal string. Example: "1".'),amount:l('Amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),maxPrice:l("Maximum bid price in Q96 payment-currency base units per sale-token base unit."),prevTickPrice:l("Previous auction price tick in Q96 payment-currency base units per sale-token base unit; zero for the first tick."),lastFullyFilledCheckpointBlock:l("Last fully filled checkpoint block number for a partial bid exit, as a decimal string."),outbidBlock:l("Block number at which the bid was outbid, as a decimal string."),mode:{description:'Choose "full" to exit a bid, or "partial" to exit using checkpoint and outbid block hints.',type:"string",enum:["full","partial"]},bidIds:{description:'One to fifty unique auction bid identifiers as decimal strings. Example: ["1", "2"].',type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let n=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:L},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await E(s,e),k=s.clientFor(h),[m,v]=await Promise.all([P(s,i.currency,i.blockNumber),P(s,i.saleToken,i.blockNumber)]),d=e.bidId===void 0?void 0:await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:v,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...d?{bid:{...d,startBlock:d.startBlock.toString(),exitedBlock:d.exitedBlock.toString(),maxPrice:d.maxPrice.toString(),amountQ96:d.amountQ96.toString(),tokensFilled:d.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let B=[],f,A=0n;if(t==="bid"){if(i.validationHook!==H)throw new u("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new u("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),C=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new u("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?A=r:B.push(s.approval(i.currency,i.auction,r.toString(),h)),f=w({abi:o,functionName:"submitBid",args:[p,r,a,C,"0x"]})}else if(t==="exit"){if(!d||!g(d.owner,a))throw new u("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new u("Full exit takes no checkpoint hints.");f=w({abi:o,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=w({abi:o,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new u("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new u("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new u("Provide 1 to 50 unique bid IDs.");for(let p of r){let C=await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(C.owner,a))throw new u("Claimed tokens must belong to the signing wallet.")}f=w({abi:o,functionName:"claimTokensBatch",args:[a,r]})}else f=w({abi:o,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return B.push(s.unsignedTx({to:i.auction,data:f,value:A.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),T(s,B,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return n.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l("First block number of the scan, as a decimal string; inclusive."),toBlock:l("Last block number of the scan, as a decimal string; inclusive.")}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),b=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(b>i||i>a||i-b>=10000n)throw new u("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let k=await e.getLogs({address:x,event:M,fromBlock:b,toBlock:i,strict:!0});return{factory:x,fromBlock:b.toString(),toBlock:i.toString(),auctions:k.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:n}}export{x as a,M as b,o as c,D as d,E as e,R as f};
@@ -1 +1 @@
1
- import{e as v,h as W,i as j,n as z}from"./6D3XNCOX.js";import{a as B,e as F,g as R}from"./QPY6UTLU.js";import{A as D,b as C,c as O,t as X}from"./KLEJ3W4T.js";import{a as H}from"./66F5ZH34.js";import{g as U}from"./NWNYJ26T.js";import{b as L}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{decodeEventLog as J,parseAbi as V,toEventSelector as Z,toHex as x}from"viem";var K=V(["function getPositionInfo(bytes32 poolId,address owner,int24 tickLower,int24 tickUpper,bytes32 salt) view returns (uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128)","function getFeeGrowthInside(bytes32 poolId,int24 tickLower,int24 tickUpper) view returns (uint256,uint256)"]),Q=V(["function ownerOf(uint256) view returns (address)","function getPoolAndPositionInfo(uint256) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint256)"]),P=V(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function feeGrowthGlobal0X128() view returns (uint256)","function feeGrowthGlobal1X128() view returns (uint256)","function ticks(int24) view returns (uint128,int128,uint256,uint256,int56,uint160,uint32,bool)"]),$=(1n<<256n)-1n,ee=1n<<128n,A=(s,t)=>s-t&$;function G(s,t,r,n=0n){return A(s,t)*r/ee+n}function ue(s){return{tools:[{name:"uniswap_fees",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenId"],properties:{includeHistory:{type:"boolean",description:"V3 only: read the complete NFT collect/decrease event history for lifetime fees. This can require multiple RPC log windows."},version:{description:'Uniswap version: "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v3","v4"]},tokenId:H('Identifier of the position NFT, as a decimal string. Example: "1".')}},async execute(t){if(R(t,["version","tokenId","includeHistory"]),t.includeHistory!==void 0&&typeof t.includeHistory!="boolean")throw new c("includeHistory must be a boolean.");if(t.includeHistory===!0&&t.version!=="v3")throw new c("V4 position lifetime fees need historical liquidity/fee-growth checkpoints; no verified history source is configured.");let r=B(t.tokenId,"tokenId"),n=s.clientFor(L),i=await n.getBlockNumber();if(t.version!=="v3"&&t.version!=="v4")throw new c("Provide version v3 or v4 for fee reads.");let _=await n.readContract({address:t.version==="v4"?C:v.positionManager,abi:Q,functionName:"ownerOf",args:[r],blockNumber:i}),b,m,a,d,u,w=0n,p=0n;if(t.version==="v4"){let[e,f]=await n.readContract({address:C,abi:Q,functionName:"getPoolAndPositionInfo",args:[r],blockNumber:i}),{tickLower:h,tickUpper:N}=D(f),S=X(e),[k,I]=await Promise.all([n.readContract({address:O,abi:K,functionName:"getPositionInfo",args:[S,C,h,N,x(r,{size:32})],blockNumber:i}),n.readContract({address:O,abi:K,functionName:"getFeeGrowthInside",args:[S,h,N],blockNumber:i})]);[b,m,a]=[e.currency0,e.currency1,k[0]],[d,u]=[G(I[0],k[1],a),G(I[1],k[2],a)]}else if(t.version==="v3"){let e=z(await n.readContract({address:v.positionManager,abi:W,functionName:"positions",args:[r],blockNumber:i})),f=await n.readContract({address:v.factory,abi:j,functionName:"getPool",args:[e.token0,e.token1,e.fee],blockNumber:i}),[h,N,S,k,I]=await Promise.all([n.readContract({address:f,abi:P,functionName:"slot0",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal0X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal1X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickLower],blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickUpper],blockNumber:i})]),M=(q,E,T)=>A(A(q,h[1]>=e.tickLower?E:A(q,E)),h[1]<e.tickUpper?T:A(q,T));[b,m,a]=[e.token0,e.token1,e.liquidity],[w,p]=[e.tokensOwed0,e.tokensOwed1],[d,u]=[G(M(N,k[2],I[2]),e.feeGrowthInside0LastX128,a,e.tokensOwed0),G(M(S,k[3],I[3]),e.feeGrowthInside1LastX128,a,e.tokensOwed1)]}else throw new c('Provide version "v3" or "v4" for fee reads.');let[o,g]=await Promise.all([F(s,b,i),F(s,m,i)]),y=[{token:o,amount:d.toString()},{token:g,amount:u.toString()}],l=t.includeHistory===!0?await te(s,r,i,d,u):void 0;return{version:t.version,tokenId:r.toString(),owner:_,blockNumber:i.toString(),liquidity:a.toString(),...t.version==="v4"?{uncollected:y}:{},collectable:y,feeGrowthAccrual:[{token:o,amount:(d-w).toString()},{token:g,amount:(u-p).toString()}],tokensOwed:[{token:o,amount:w.toString()},{token:g,amount:p.toString()}],...l?{lifetimeFees:[{token:o,amount:l[0].toString()},{token:g,amount:l[1].toString()}]}:{},summary:"One-block collectable estimate, excluding gas. V3 tokensOwed may include withdrawn principal; feeGrowthAccrual excludes those stored amounts. V4 hook accounting can change actual collections. V4 current liquidity times lifetime range growth is not lifetime position earnings."}}}]}}var Y=V(["event IncreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event DecreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event Collect(uint256 indexed tokenId,address recipient,uint256 amount0,uint256 amount1)"]);async function te(s,t,r,n,i){let _=s.clientFor(L),b=Y.map(o=>Z(o)),m=0n,a=0n,d=0n,u=0n,w=0;for(let o=0n;o<=r;o+=10000000n){let g=o+9999999n<r?o+9999999n:r,y=await _.request({method:"eth_getLogs",params:[{address:v.positionManager,topics:[b,x(t,{size:32})],fromBlock:x(o),toBlock:x(g)}]});if(!Array.isArray(y))throw new c("V3 lifetime fee history is unavailable; do not treat missing history as zero earnings.");for(let l of y){if(!U(l.address,v.positionManager))throw new c("Unexpected contract in v3 lifetime fee history.");let e=J({abi:Y,data:l.data,topics:l.topics});if(e.args.tokenId!==t)throw new c("Unexpected NFT in v3 fee history.");e.eventName==="Collect"?(m+=e.args.amount0,a+=e.args.amount1):e.eventName==="DecreaseLiquidity"?(d+=e.args.amount0,u+=e.args.amount1):w++}}if(w===0)throw new c("V3 mint/increase history is missing for this existing NFT; lifetime earnings are unknown.");let p=[m+n-d,a+i-u];if(p.some(o=>o<0n))throw new c("V3 fee history is incomplete or inconsistent; lifetime earnings are unknown.");return p}export{K as a,A as b,G as c,ue as d};
1
+ import{e as v,h as W,i as j,n as z}from"./JDHPMS7X.js";import{a as B,e as F,g as R}from"./ZXRIJG6H.js";import{A as D,b as C,c as O,t as X}from"./FRT6AC6M.js";import{a as H}from"./66F5ZH34.js";import{g as U}from"./NWNYJ26T.js";import{b as L}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{decodeEventLog as J,parseAbi as V,toEventSelector as Z,toHex as x}from"viem";var K=V(["function getPositionInfo(bytes32 poolId,address owner,int24 tickLower,int24 tickUpper,bytes32 salt) view returns (uint128 liquidity,uint256 feeGrowthInside0LastX128,uint256 feeGrowthInside1LastX128)","function getFeeGrowthInside(bytes32 poolId,int24 tickLower,int24 tickUpper) view returns (uint256,uint256)"]),Q=V(["function ownerOf(uint256) view returns (address)","function getPoolAndPositionInfo(uint256) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint256)"]),P=V(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function feeGrowthGlobal0X128() view returns (uint256)","function feeGrowthGlobal1X128() view returns (uint256)","function ticks(int24) view returns (uint128,int128,uint256,uint256,int56,uint160,uint32,bool)"]),$=(1n<<256n)-1n,ee=1n<<128n,A=(s,t)=>s-t&$;function G(s,t,r,n=0n){return A(s,t)*r/ee+n}function ue(s){return{tools:[{name:"uniswap_fees",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenId"],properties:{includeHistory:{type:"boolean",description:"V3 only: read the complete NFT collect/decrease event history for lifetime fees. This can require multiple RPC log windows."},version:{description:'Uniswap version: "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v3","v4"]},tokenId:H('Identifier of the position NFT, as a decimal string. Example: "1".')}},async execute(t){if(R(t,["version","tokenId","includeHistory"]),t.includeHistory!==void 0&&typeof t.includeHistory!="boolean")throw new c("includeHistory must be a boolean.");if(t.includeHistory===!0&&t.version!=="v3")throw new c("V4 position lifetime fees need historical liquidity/fee-growth checkpoints; no verified history source is configured.");let r=B(t.tokenId,"tokenId"),n=s.clientFor(L),i=await n.getBlockNumber();if(t.version!=="v3"&&t.version!=="v4")throw new c("Provide version v3 or v4 for fee reads.");let _=await n.readContract({address:t.version==="v4"?C:v.positionManager,abi:Q,functionName:"ownerOf",args:[r],blockNumber:i}),b,m,a,d,u,w=0n,p=0n;if(t.version==="v4"){let[e,f]=await n.readContract({address:C,abi:Q,functionName:"getPoolAndPositionInfo",args:[r],blockNumber:i}),{tickLower:h,tickUpper:N}=D(f),S=X(e),[k,I]=await Promise.all([n.readContract({address:O,abi:K,functionName:"getPositionInfo",args:[S,C,h,N,x(r,{size:32})],blockNumber:i}),n.readContract({address:O,abi:K,functionName:"getFeeGrowthInside",args:[S,h,N],blockNumber:i})]);[b,m,a]=[e.currency0,e.currency1,k[0]],[d,u]=[G(I[0],k[1],a),G(I[1],k[2],a)]}else if(t.version==="v3"){let e=z(await n.readContract({address:v.positionManager,abi:W,functionName:"positions",args:[r],blockNumber:i})),f=await n.readContract({address:v.factory,abi:j,functionName:"getPool",args:[e.token0,e.token1,e.fee],blockNumber:i}),[h,N,S,k,I]=await Promise.all([n.readContract({address:f,abi:P,functionName:"slot0",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal0X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"feeGrowthGlobal1X128",blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickLower],blockNumber:i}),n.readContract({address:f,abi:P,functionName:"ticks",args:[e.tickUpper],blockNumber:i})]),M=(q,E,T)=>A(A(q,h[1]>=e.tickLower?E:A(q,E)),h[1]<e.tickUpper?T:A(q,T));[b,m,a]=[e.token0,e.token1,e.liquidity],[w,p]=[e.tokensOwed0,e.tokensOwed1],[d,u]=[G(M(N,k[2],I[2]),e.feeGrowthInside0LastX128,a,e.tokensOwed0),G(M(S,k[3],I[3]),e.feeGrowthInside1LastX128,a,e.tokensOwed1)]}else throw new c('Provide version "v3" or "v4" for fee reads.');let[o,g]=await Promise.all([F(s,b,i),F(s,m,i)]),y=[{token:o,amount:d.toString()},{token:g,amount:u.toString()}],l=t.includeHistory===!0?await te(s,r,i,d,u):void 0;return{version:t.version,tokenId:r.toString(),owner:_,blockNumber:i.toString(),liquidity:a.toString(),...t.version==="v4"?{uncollected:y}:{},collectable:y,feeGrowthAccrual:[{token:o,amount:(d-w).toString()},{token:g,amount:(u-p).toString()}],tokensOwed:[{token:o,amount:w.toString()},{token:g,amount:p.toString()}],...l?{lifetimeFees:[{token:o,amount:l[0].toString()},{token:g,amount:l[1].toString()}]}:{},summary:"One-block collectable estimate, excluding gas. V3 tokensOwed may include withdrawn principal; feeGrowthAccrual excludes those stored amounts. V4 hook accounting can change actual collections. V4 current liquidity times lifetime range growth is not lifetime position earnings."}}}]}}var Y=V(["event IncreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event DecreaseLiquidity(uint256 indexed tokenId,uint128 liquidity,uint256 amount0,uint256 amount1)","event Collect(uint256 indexed tokenId,address recipient,uint256 amount0,uint256 amount1)"]);async function te(s,t,r,n,i){let _=s.clientFor(L),b=Y.map(o=>Z(o)),m=0n,a=0n,d=0n,u=0n,w=0;for(let o=0n;o<=r;o+=10000000n){let g=o+9999999n<r?o+9999999n:r,y=await _.request({method:"eth_getLogs",params:[{address:v.positionManager,topics:[b,x(t,{size:32})],fromBlock:x(o),toBlock:x(g)}]});if(!Array.isArray(y))throw new c("V3 lifetime fee history is unavailable; do not treat missing history as zero earnings.");for(let l of y){if(!U(l.address,v.positionManager))throw new c("Unexpected contract in v3 lifetime fee history.");let e=J({abi:Y,data:l.data,topics:l.topics});if(e.args.tokenId!==t)throw new c("Unexpected NFT in v3 fee history.");e.eventName==="Collect"?(m+=e.args.amount0,a+=e.args.amount1):e.eventName==="DecreaseLiquidity"?(d+=e.args.amount0,u+=e.args.amount1):w++}}if(w===0)throw new c("V3 mint/increase history is missing for this existing NFT; lifetime earnings are unknown.");let p=[m+n-d,a+i-u];if(p.some(o=>o<0n))throw new c("V3 fee history is incomplete or inconsistent; lifetime earnings are unknown.");return p}export{K as a,A as b,G as c,ue as d};
@@ -1 +1 @@
1
- import{a as N}from"./6F527FLN.js";import{a as M}from"./BJK75C7G.js";import{b as _,c as q,d as F,e as O}from"./VDJPDIBV.js";import{a as I}from"./IPU656WB.js";import{c as E}from"./X24YTJST.js";import{b as P}from"./SPJCSEKP.js";import{a as b}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,e as $,j as C,k as y}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as D,parseAbi as W}from"viem";var i=C[r].vaults.steakhouse.address,R=(1n<<256n)-1n,l=W(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>R)throw new o("The vault returned an invalid base-unit amount.");return e}function k(e){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let c=G(e);if(c===0n)throw new o("Amount must be positive.");if(c>R)throw new o("Amount exceeds the uint256 range.");return c}function U(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new o("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new o(e.plainError(s))}}async function h(){let t=e.clientFor(r);if(await t.getChainId()!==r)throw new o("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new o("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:D,functionName:"decimals"}),t.readContract({address:i,abi:D,functionName:"decimals"})]);if(a!==$||!Number.isInteger(n)||n<0||n>255)throw new o("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:r},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:r}}}async function w(t,s){return S(await t.readContract({address:i,abi:D,functionName:"balanceOf",args:[s]}))}async function x(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new o("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),M(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{U(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...T(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{U(t,!0);let a=k(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),r),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return x(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...T(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...T(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.'},minAmountOut:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: least USDG you must receive, in base units (6 decimals). Example: "1000000" = 1 USDG.'}}},execute:async(t,s)=>c(async()=>{U(t,!0,!0);let a=t.amount==="max"?null:k(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new o("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new o("force must be a boolean.");if(t.force===!0){if(a!==null)throw new o("Force exit currently requires amount max.");let p=E(t.maxPenaltyAssets),j=k(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return O(A.changes,i,d,j),{txs:[v.tx],preview:A,summary:`${F(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new o("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new o("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return x([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${i.toLowerCase()}`,chainId:r,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function T(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`Amount of USDG in base units (USDG has 6 decimals)${e?", or max to redeem every share":""}. Example: "1000000" = 1 USDG.`}}}}var te=e=>P("steakhouse",[L(e)]);export{L as a,te as b};
1
+ import{a as M}from"./M6JNGU4E.js";import{b as _,c as q,d as F,e as O}from"./MJGEGNDU.js";import{a as N}from"./6F527FLN.js";import{a as I}from"./IPU656WB.js";import{c as E}from"./X24YTJST.js";import{b as P}from"./SPJCSEKP.js";import{a as b}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,e as $,j as C,k as y}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as D,parseAbi as W}from"viem";var i=C[r].vaults.steakhouse.address,R=(1n<<256n)-1n,l=W(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>R)throw new o("The vault returned an invalid base-unit amount.");return e}function k(e){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let c=G(e);if(c===0n)throw new o("Amount must be positive.");if(c>R)throw new o("Amount exceeds the uint256 range.");return c}function U(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new o("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new o(e.plainError(s))}}async function h(){let t=e.clientFor(r);if(await t.getChainId()!==r)throw new o("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new o("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:D,functionName:"decimals"}),t.readContract({address:i,abi:D,functionName:"decimals"})]);if(a!==$||!Number.isInteger(n)||n<0||n>255)throw new o("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:r},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:r}}}async function w(t,s){return S(await t.readContract({address:i,abi:D,functionName:"balanceOf",args:[s]}))}async function x(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new o("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),M(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{U(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...T(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{U(t,!0);let a=k(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),r),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return x(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...T(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...T(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.'},minAmountOut:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: least USDG you must receive, in base units (6 decimals). Example: "1000000" = 1 USDG.'}}},execute:async(t,s)=>c(async()=>{U(t,!0,!0);let a=t.amount==="max"?null:k(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new o("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new o("force must be a boolean.");if(t.force===!0){if(a!==null)throw new o("Force exit currently requires amount max.");let p=E(t.maxPenaltyAssets),j=k(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return O(A.changes,i,d,j),{txs:[v.tx],preview:A,summary:`${F(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new o("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new o("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return x([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${i.toLowerCase()}`,chainId:r,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function T(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`Amount of USDG in base units (USDG has 6 decimals)${e?", or max to redeem every share":""}. Example: "1000000" = 1 USDG.`}}}}var te=e=>P("steakhouse",[L(e)]);export{L as a,te as b};
@@ -1 +1 @@
1
- import{k as l}from"./NV6FDIYT.js";import{a}from"./XSD5NL7J.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
1
+ import{m as l}from"./7OOCAZBE.js";import{a}from"./XSD5NL7J.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
@@ -1 +1 @@
1
- import{a as m}from"./5DPJQCKJ.js";var d=1000000n,p=(t,e)=>(t+e-1n)/e;function a(t){if(typeof t!="string"||t.length>256||!/^(0|[1-9][0-9]*)(?:\.[0-9]+)?$/.test(t))throw new Error("Invalid Raeto price.");let[e,s=""]=t.split(".");return BigInt(e)*d+BigInt((s+"000000").slice(0,6))+(/[1-9]/.test(s.slice(6))?1n:0n)}function l(t){return`${t/d}.${(t%d).toString().padStart(6,"0")}`}function r(t){return{refused:t,screen:t==="unpriced"?m.unpriced:m.autoUnbounded}}function _(t){if(!Number.isSafeInteger(t.promptBytes)||t.promptBytes<0||!Number.isSafeInteger(t.maxTokens)||t.maxTokens<0)throw new Error("Invalid Raeto token or byte bound.");if(t.tool==="raeto_search"||t.tool==="raeto_read_page"){let i=t.tool==="raeto_search"?"web_search":"fetch_page",n=t.prices.tools[i];try{if(!n)return r("unpriced");let o=a(n.priceUsd),c=n.maxUsd===void 0?o:a(n.maxUsd);return{usd:l(o>c?o:c),basis:"flat"}}catch{return r("unpriced")}}if(t.tool!=="raeto_ask")return r("unpriced");let e=!t.model||t.model==="raeto/auto",s=BigInt(t.promptBytes)+256n,u=0n;try{let i=e?t.modelIds:[t.model];if(!i.length)return r("auto_unbounded");for(let n of i){let o=t.prices.models[n];if(!o)return r(e?"auto_unbounded":"unpriced");let c=a(o.inputPerMTok),g=a(o.outputPerMTok),f=p(s*c+BigInt(t.maxTokens)*g,d);f>u&&(u=f)}}catch{return r(e?"auto_unbounded":"unpriced")}return{usd:l(u),basis:e?"auto":"model"}}export{_ as a};
1
+ import{a as m}from"./FWOGOWUM.js";var d=1000000n,p=(t,e)=>(t+e-1n)/e;function a(t){if(typeof t!="string"||t.length>256||!/^(0|[1-9][0-9]*)(?:\.[0-9]+)?$/.test(t))throw new Error("Invalid Raeto price.");let[e,s=""]=t.split(".");return BigInt(e)*d+BigInt((s+"000000").slice(0,6))+(/[1-9]/.test(s.slice(6))?1n:0n)}function l(t){return`${t/d}.${(t%d).toString().padStart(6,"0")}`}function r(t){return{refused:t,screen:t==="unpriced"?m.unpriced:m.autoUnbounded}}function _(t){if(!Number.isSafeInteger(t.promptBytes)||t.promptBytes<0||!Number.isSafeInteger(t.maxTokens)||t.maxTokens<0)throw new Error("Invalid Raeto token or byte bound.");if(t.tool==="raeto_search"||t.tool==="raeto_read_page"){let i=t.tool==="raeto_search"?"web_search":"fetch_page",n=t.prices.tools[i];try{if(!n)return r("unpriced");let o=a(n.priceUsd),c=n.maxUsd===void 0?o:a(n.maxUsd);return{usd:l(o>c?o:c),basis:"flat"}}catch{return r("unpriced")}}if(t.tool!=="raeto_ask")return r("unpriced");let e=!t.model||t.model==="raeto/auto",s=BigInt(t.promptBytes)+256n,u=0n;try{let i=e?t.modelIds:[t.model];if(!i.length)return r("auto_unbounded");for(let n of i){let o=t.prices.models[n];if(!o)return r(e?"auto_unbounded":"unpriced");let c=a(o.inputPerMTok),g=a(o.outputPerMTok),f=p(s*c+BigInt(t.maxTokens)*g,d);f>u&&(u=f)}}catch{return r(e?"auto_unbounded":"unpriced")}return{usd:l(u),basis:e?"auto":"model"}}export{_ as a};
@@ -1 +1 @@
1
- import{a as v}from"./OVM4QIET.js";import{h as w}from"./2GXHYI23.js";import{a as y}from"./MSRCJ2BS.js";import{b as P,c as k,d as l}from"./WAKZWSHB.js";import{m as h}from"./NV6FDIYT.js";import{a as f}from"./43LI5NKJ.js";import{m as b,n as B}from"./NWNYJ26T.js";import{b as d}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as R}from"viem";var U=70515n,C=250202n,S=568341n;function N(a,r){return{token:{...a},amount:r.toString()}}function A(a){if(a.network!==void 0&&a.network!=="mainnet")throw new s("LayerBank requires chain 4663.")}async function g(a,r,n,e){try{return b(await a.readContract({address:r.address,abi:L,functionName:"balanceOf",args:[n],blockNumber:e}),"LayerBank returned a malformed wallet balance read.")}catch(t){throw t instanceof s?t:new s("LayerBank wallet balance could not be read. Please try again.")}}async function T(a,r,n){try{let[e,t]=await Promise.all([r.getGasPrice(),h("ETH",{client:r,http:a.http,chainId:d,blockNumber:n})]),i=B(t.usdE18,"LayerBank gas reference is unavailable.",{positive:!0}),c=b(e,"LayerBank gas reference is unavailable.");if(c===0n)throw new s("LayerBank gas reference is unavailable.");let u=m=>Number(R(m*c*i/10n**18n,18)),o=u(U+C),p=u(S);if(![o,p].every(m=>Number.isFinite(m)&&m>0))throw new s("LayerBank gas reference is unavailable.");return{gasInUsd:o,gasOutUsd:p}}catch{throw new s("LayerBank gas costs could not be checked against a fresh ETH/USD reference. Please try again.")}}async function x(a,r){A(a),f(r);let n=a.clientFor(d),e=await y(n),[t,i,c,u]=await Promise.all([g(n,k,r,e.blockNumber),g(n,l,r,e.blockNumber),v(a.http),T(a,n,e.blockNumber)]),o=[...c.checks,"Gas costs use measured USDG calls plus 20% headroom; entry includes approval and supply."];e.active||o.push("LayerBank reserve is inactive."),e.frozen&&o.push("LayerBank reserve is frozen for deposits."),e.paused&&o.push("LayerBank reserve is paused."),e.capRoomBase===0n&&o.push("LayerBank supply cap has no room left.");let p={rateBasePct:e.rateBasePct,...c.bonus==="unavailable"?{}:{bonus:c.bonus},cashUsdgBase:e.cashUsdgBase,capRoomBase:e.capRoomBase,open:e.active&&!e.frozen&&!e.paused&&e.capRoomBase>0n,walletUsdgBase:t,walletReceiptBase:i,...u,checks:o};return{reserve:e,reading:p}}function F(a){return async r=>{try{return(await x(a,r)).reading}catch(n){return{rateBasePct:0,cashUsdgBase:0n,capRoomBase:0n,open:!1,walletUsdgBase:0n,walletReceiptBase:0n,gasInUsd:0,gasOutUsd:0,checks:[n instanceof s?a.plainError(n):"LayerBank could not be checked right now. Please try again."]}}}}async function W(a,r){A(a),f(r);let n=a.clientFor(d),e=await y(n),t=await g(n,l,r,e.blockNumber);if(t===0n)return[];let i=a.formatAmount(t.toString(),6);return[{module:"layerbank",id:`${d}:${P}`,chainId:d,assets:[N(l,t)],economics:{principal:[w("redeemable",{token:{...k},amount:t.toString(),source:"layerbank.receiptBalance",heldAs:l.address,measuredAtBlock:e.blockNumber.toString()})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`${i} lRobUSDG = ${i} USDG; base supply rate ${e.rateBasePct}% a year, read now.`}]}export{U as a,C as b,S as c,N as d,A as e,g as f,x as g,F as h,W as i};
1
+ import{a as v}from"./OVM4QIET.js";import{h as w}from"./2GXHYI23.js";import{a as y}from"./MSRCJ2BS.js";import{b as P,c as k,d as l}from"./WAKZWSHB.js";import{o as h}from"./7OOCAZBE.js";import{a as f}from"./43LI5NKJ.js";import{m as b,n as B}from"./NWNYJ26T.js";import{b as d}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as R}from"viem";var U=70515n,C=250202n,S=568341n;function N(a,r){return{token:{...a},amount:r.toString()}}function A(a){if(a.network!==void 0&&a.network!=="mainnet")throw new s("LayerBank requires chain 4663.")}async function g(a,r,n,e){try{return b(await a.readContract({address:r.address,abi:L,functionName:"balanceOf",args:[n],blockNumber:e}),"LayerBank returned a malformed wallet balance read.")}catch(t){throw t instanceof s?t:new s("LayerBank wallet balance could not be read. Please try again.")}}async function T(a,r,n){try{let[e,t]=await Promise.all([r.getGasPrice(),h("ETH",{client:r,http:a.http,chainId:d,blockNumber:n})]),i=B(t.usdE18,"LayerBank gas reference is unavailable.",{positive:!0}),c=b(e,"LayerBank gas reference is unavailable.");if(c===0n)throw new s("LayerBank gas reference is unavailable.");let u=m=>Number(R(m*c*i/10n**18n,18)),o=u(U+C),p=u(S);if(![o,p].every(m=>Number.isFinite(m)&&m>0))throw new s("LayerBank gas reference is unavailable.");return{gasInUsd:o,gasOutUsd:p}}catch{throw new s("LayerBank gas costs could not be checked against a fresh ETH/USD reference. Please try again.")}}async function x(a,r){A(a),f(r);let n=a.clientFor(d),e=await y(n),[t,i,c,u]=await Promise.all([g(n,k,r,e.blockNumber),g(n,l,r,e.blockNumber),v(a.http),T(a,n,e.blockNumber)]),o=[...c.checks,"Gas costs use measured USDG calls plus 20% headroom; entry includes approval and supply."];e.active||o.push("LayerBank reserve is inactive."),e.frozen&&o.push("LayerBank reserve is frozen for deposits."),e.paused&&o.push("LayerBank reserve is paused."),e.capRoomBase===0n&&o.push("LayerBank supply cap has no room left.");let p={rateBasePct:e.rateBasePct,...c.bonus==="unavailable"?{}:{bonus:c.bonus},cashUsdgBase:e.cashUsdgBase,capRoomBase:e.capRoomBase,open:e.active&&!e.frozen&&!e.paused&&e.capRoomBase>0n,walletUsdgBase:t,walletReceiptBase:i,...u,checks:o};return{reserve:e,reading:p}}function F(a){return async r=>{try{return(await x(a,r)).reading}catch(n){return{rateBasePct:0,cashUsdgBase:0n,capRoomBase:0n,open:!1,walletUsdgBase:0n,walletReceiptBase:0n,gasInUsd:0,gasOutUsd:0,checks:[n instanceof s?a.plainError(n):"LayerBank could not be checked right now. Please try again."]}}}}async function W(a,r){A(a),f(r);let n=a.clientFor(d),e=await y(n),t=await g(n,l,r,e.blockNumber);if(t===0n)return[];let i=a.formatAmount(t.toString(),6);return[{module:"layerbank",id:`${d}:${P}`,chainId:d,assets:[N(l,t)],economics:{principal:[w("redeemable",{token:{...k},amount:t.toString(),source:"layerbank.receiptBalance",heldAs:l.address,measuredAtBlock:e.blockNumber.toString()})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`${i} lRobUSDG = ${i} USDG; base supply rate ${e.rateBasePct}% a year, read now.`}]}export{U as a,C as b,S as c,N as d,A as e,g as f,x as g,F as h,W as i};
@@ -1 +1 @@
1
- import{a as d,b as D}from"./IBL6TL2Q.js";import{b as N}from"./G2AA73ZE.js";import{ja as T}from"./HHYE42JG.js";import{h as u,i as C,l as I,m as O}from"./NWNYJ26T.js";import{a as n}from"./XSD5NL7J.js";import{erc20Abi as b,isHex as Z,keccak256 as j,parseAbi as G,zeroAddress as J}from"viem";var y=G(["function asset() view returns (address)","function decimals() view returns (uint8)","function symbol() view returns (string)","function owner() view returns (address)","function curator() view returns (address)","function adaptersLength() view returns (uint256)","function adapters(uint256) view returns (address)","function parentVault() view returns (address)","function isVaultV2(address) view returns (bool)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function convertToAssets(uint256) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function getThreshold() view returns (uint256)","function getOwners() view returns (address[])"]),o=T("setup-mismatch",{}),p=e=>I(C(e,o),o),x=e=>O(e,o);function g(e){if(typeof e!="string"||!Z(e,{strict:!0})||e.length<4||e.length%2!==0)throw new n(o);return j(e)}function V(e){if(typeof e!="number"||!Number.isInteger(e)||e<0||e>255)throw new n(o);return e}function H(e,t){return typeof e=="string"&&/^[A-Za-z0-9.$_-]{1,32}$/.test(e)?e:t}async function _(e,t){if(await e.getChainId()!==d.chainId)throw new n("Borro requires chain 4663.");return x(t??await e.getBlockNumber({cacheTime:0}))}async function z(e,t,f){let a=(r,s,l=[])=>e.readContract({address:r,abi:y,functionName:s,args:l,blockNumber:f}),i={ok:!0,drift:[]};for(let r of["owner","curator"])try{i[r]=p(await a(t,r)),u(i[r],d[r])||i.drift.push(r)}catch{i.drift.push(`${r} unreadable`)}try{let r=x(await a(t,"adaptersLength"));if(r>64n)throw new n(o);let s=await Promise.all(Array.from({length:Number(r)},async(l,c)=>{let m=p(await a(t,"adapters",[BigInt(c)]));if(g(await e.getCode({address:m,blockNumber:f})),!u(await a(m,"parentVault"),t))throw new n(o);return m}));if(new Set(s).size!==s.length)throw new n(o);i.adapters=s}catch{i.drift.push("adapters unreadable or invalid")}return i}function M(e=[]){return async(t,f)=>{let a=u(f,d.assetRule.usdg.address)?{...d.assetRule.usdg,chainId:d.chainId}:e.find(i=>i.chainId===d.chainId&&u(i.address,f));return a?{...a,address:p(a.address)}:void 0}}function Q(e={resolveAllowedAsset:M()}){return async(t,f,a,i={})=>{try{let r=p(f),s=await _(t,i.blockNumber),l=a==="deposit"&&!!i.wallet,c=[{address:d.factory.address,abi:y,functionName:"isVaultV2",args:[r]},{address:r,abi:y,functionName:"asset"},{address:r,abi:y,functionName:"decimals"}],[m,k,R,E]=await Promise.all([t.getCode({address:d.factory.address,blockNumber:s}),t.getCode({address:r,blockNumber:s}),l?t.multicall({allowFailure:!1,batchSize:0,blockNumber:s,contracts:[...c,{address:d.builders.address,abi:N,functionName:"vaults",args:[r]},{address:d.builders.address,abi:N,functionName:"builders",args:[D]}]}):Promise.all(c.map(v=>t.readContract({...v,blockNumber:s}))),l?t.getCode({address:d.builders.address,blockNumber:s}):void 0]);if(!Array.isArray(R)||R.length!==(l?5:3))throw new n(o);let[$,F,L,S,q]=R,P=!1;if(l){if(!u(g(E),d.builders.codeHash)||typeof S!="boolean")throw new n(o);let v=C(q,o);P=S&&!u(v,J)}if(!u(g(m),d.factory.codeHash)||$!==!0||V(L)!==18)throw new n(o);let K=g(k),A=p(F),B=V(await t.readContract({address:A,abi:b,functionName:"decimals",blockNumber:s})),w;try{w=await e.resolveAllowedAsset(t,A,s)}catch{}if(w&&(!u(w.address,A)||w.chainId!==4663||w.decimals!==B||H(w.symbol,"")===""))throw new n(o);let h=await z(t,r,s);if(w||h.drift.push("asset identity is outside the available official catalogue"),h.drift.length){if(a!=="withdraw"||!i.wallet)throw new n(o);if(x(await t.readContract({address:r,abi:b,functionName:"balanceOf",args:[p(i.wallet)],blockNumber:s}))===0n)throw new n(o)}let U=H(await t.readContract({address:r,abi:b,functionName:"symbol",blockNumber:s}).catch(()=>{}),"shares");return{vault:r,symbol:w?.symbol??"token",vaultSymbol:U,asset:A,assetDecimals:B,codeHash:K,chainId:4663,shareDecimals:18,...h.owner&&{owner:h.owner},...h.curator&&{curator:h.curator},...h.adapters&&{adapters:h.adapters},setup:h,assetAllowed:!!w,mode:a,...l?{builderEligible:P}:{},source:d.factory.source,measuredAtBlock:s.toString(),provenance:{kind:"factory",factory:d.factory.address,isVaultV2:!0}}}catch(r){throw r instanceof n?r:new n(o)}}}var ae=Q(),se=async(e,t,f)=>{try{let a=await _(e),[i,r,s,l]=await Promise.all([e.getCode({address:t.vault,blockNumber:a}),e.readContract({address:t.vault,abi:y,functionName:"asset",blockNumber:a}),e.readContract({address:t.vault,abi:b,functionName:"decimals",blockNumber:a}),e.readContract({address:t.asset,abi:b,functionName:"decimals",blockNumber:a})]);if(!u(g(i),t.codeHash)||!u(p(r),t.asset)||V(s)!==18||V(l)!==t.assetDecimals)throw new n(o);let c=await z(e,t.vault,a);if(t.adapters&&c.adapters&&(t.adapters.length!==c.adapters.length||t.adapters.some((m,k)=>!u(m,c.adapters[k])))&&c.drift.push("adapters changed"),f==="deposit"&&c.drift.length)throw new n(o);return c}catch(a){throw a instanceof n?a:new n(o)}};export{y as a,o as b,p as c,x as d,g as e,V as f,H as g,_ as h,M as i,Q as j,ae as k,se as l};
1
+ import{b as N}from"./G2AA73ZE.js";import{ja as T}from"./HHYE42JG.js";import{a as d,b as D}from"./IBL6TL2Q.js";import{h as u,i as C,l as I,m as O}from"./NWNYJ26T.js";import{a as n}from"./XSD5NL7J.js";import{erc20Abi as b,isHex as Z,keccak256 as j,parseAbi as G,zeroAddress as J}from"viem";var y=G(["function asset() view returns (address)","function decimals() view returns (uint8)","function symbol() view returns (string)","function owner() view returns (address)","function curator() view returns (address)","function adaptersLength() view returns (uint256)","function adapters(uint256) view returns (address)","function parentVault() view returns (address)","function isVaultV2(address) view returns (bool)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function convertToAssets(uint256) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function getThreshold() view returns (uint256)","function getOwners() view returns (address[])"]),o=T("setup-mismatch",{}),p=e=>I(C(e,o),o),x=e=>O(e,o);function g(e){if(typeof e!="string"||!Z(e,{strict:!0})||e.length<4||e.length%2!==0)throw new n(o);return j(e)}function V(e){if(typeof e!="number"||!Number.isInteger(e)||e<0||e>255)throw new n(o);return e}function H(e,t){return typeof e=="string"&&/^[A-Za-z0-9.$_-]{1,32}$/.test(e)?e:t}async function _(e,t){if(await e.getChainId()!==d.chainId)throw new n("Borro requires chain 4663.");return x(t??await e.getBlockNumber({cacheTime:0}))}async function z(e,t,f){let a=(r,s,l=[])=>e.readContract({address:r,abi:y,functionName:s,args:l,blockNumber:f}),i={ok:!0,drift:[]};for(let r of["owner","curator"])try{i[r]=p(await a(t,r)),u(i[r],d[r])||i.drift.push(r)}catch{i.drift.push(`${r} unreadable`)}try{let r=x(await a(t,"adaptersLength"));if(r>64n)throw new n(o);let s=await Promise.all(Array.from({length:Number(r)},async(l,c)=>{let m=p(await a(t,"adapters",[BigInt(c)]));if(g(await e.getCode({address:m,blockNumber:f})),!u(await a(m,"parentVault"),t))throw new n(o);return m}));if(new Set(s).size!==s.length)throw new n(o);i.adapters=s}catch{i.drift.push("adapters unreadable or invalid")}return i}function M(e=[]){return async(t,f)=>{let a=u(f,d.assetRule.usdg.address)?{...d.assetRule.usdg,chainId:d.chainId}:e.find(i=>i.chainId===d.chainId&&u(i.address,f));return a?{...a,address:p(a.address)}:void 0}}function Q(e={resolveAllowedAsset:M()}){return async(t,f,a,i={})=>{try{let r=p(f),s=await _(t,i.blockNumber),l=a==="deposit"&&!!i.wallet,c=[{address:d.factory.address,abi:y,functionName:"isVaultV2",args:[r]},{address:r,abi:y,functionName:"asset"},{address:r,abi:y,functionName:"decimals"}],[m,k,R,E]=await Promise.all([t.getCode({address:d.factory.address,blockNumber:s}),t.getCode({address:r,blockNumber:s}),l?t.multicall({allowFailure:!1,batchSize:0,blockNumber:s,contracts:[...c,{address:d.builders.address,abi:N,functionName:"vaults",args:[r]},{address:d.builders.address,abi:N,functionName:"builders",args:[D]}]}):Promise.all(c.map(v=>t.readContract({...v,blockNumber:s}))),l?t.getCode({address:d.builders.address,blockNumber:s}):void 0]);if(!Array.isArray(R)||R.length!==(l?5:3))throw new n(o);let[$,F,L,S,q]=R,P=!1;if(l){if(!u(g(E),d.builders.codeHash)||typeof S!="boolean")throw new n(o);let v=C(q,o);P=S&&!u(v,J)}if(!u(g(m),d.factory.codeHash)||$!==!0||V(L)!==18)throw new n(o);let K=g(k),A=p(F),B=V(await t.readContract({address:A,abi:b,functionName:"decimals",blockNumber:s})),w;try{w=await e.resolveAllowedAsset(t,A,s)}catch{}if(w&&(!u(w.address,A)||w.chainId!==4663||w.decimals!==B||H(w.symbol,"")===""))throw new n(o);let h=await z(t,r,s);if(w||h.drift.push("asset identity is outside the available official catalogue"),h.drift.length){if(a!=="withdraw"||!i.wallet)throw new n(o);if(x(await t.readContract({address:r,abi:b,functionName:"balanceOf",args:[p(i.wallet)],blockNumber:s}))===0n)throw new n(o)}let U=H(await t.readContract({address:r,abi:b,functionName:"symbol",blockNumber:s}).catch(()=>{}),"shares");return{vault:r,symbol:w?.symbol??"token",vaultSymbol:U,asset:A,assetDecimals:B,codeHash:K,chainId:4663,shareDecimals:18,...h.owner&&{owner:h.owner},...h.curator&&{curator:h.curator},...h.adapters&&{adapters:h.adapters},setup:h,assetAllowed:!!w,mode:a,...l?{builderEligible:P}:{},source:d.factory.source,measuredAtBlock:s.toString(),provenance:{kind:"factory",factory:d.factory.address,isVaultV2:!0}}}catch(r){throw r instanceof n?r:new n(o)}}}var ae=Q(),se=async(e,t,f)=>{try{let a=await _(e),[i,r,s,l]=await Promise.all([e.getCode({address:t.vault,blockNumber:a}),e.readContract({address:t.vault,abi:y,functionName:"asset",blockNumber:a}),e.readContract({address:t.vault,abi:b,functionName:"decimals",blockNumber:a}),e.readContract({address:t.asset,abi:b,functionName:"decimals",blockNumber:a})]);if(!u(g(i),t.codeHash)||!u(p(r),t.asset)||V(s)!==18||V(l)!==t.assetDecimals)throw new n(o);let c=await z(e,t.vault,a);if(t.adapters&&c.adapters&&(t.adapters.length!==c.adapters.length||t.adapters.some((m,k)=>!u(m,c.adapters[k])))&&c.drift.push("adapters changed"),f==="deposit"&&c.drift.length)throw new n(o);return c}catch(a){throw a instanceof n?a:new n(o)}};export{y as a,o as b,p as c,x as d,g as e,V as f,H as g,_ as h,M as i,Q as j,ae as k,se as l};
@@ -1 +1 @@
1
- import{a as Te}from"./JFWJBZ7M.js";import{c as Se}from"./DXAPKN7H.js";import{a as qe,b as me,c as De}from"./Z3IBPCY4.js";import{h as Re,i as t,j as A,k as d,l as Ce,m as J,n as k,o as ue,p as F,r as O,s as c,t as ce,u as le,v as pe,w as Ae,x as $e}from"./Y64GFBTA.js";import{a as ve,o as de}from"./GYPMUYB5.js";import{a as ke}from"./66F5ZH34.js";import{c as re,e as z,g as M}from"./NWNYJ26T.js";import{b as l,j as be}from"./TI727O2H.js";import{a as m}from"./XSD5NL7J.js";import{decodeFunctionData as Ue,erc20Abi as Me}from"viem";var K="0x0000000000000000000000000000000000000000",_=be[l].relay.depository.address.toLowerCase(),xe=30;function Fe(y){return/HTTP (400|401|403)\b|API key|\bhosted\b|authenticated wallet session/i.test(y)}var Ke=y=>{let L=$e(y);async function he(i){let e;try{e=await L(`/intents/status/v3?requestId=${encodeURIComponent(i)}`)}catch(D){if(y.plainError(D)!=="The request timed out. Please try again.")throw D;return{requestId:i,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof e.status!="string")throw new m("Relay returned an invalid bridge status.");let n=ce(e.inTxHashes),h=ce(e.txHashes),r=e.originChainId===void 0?void 0:J(e.originChainId),u=e.destinationChainId===void 0?void 0:J(e.destinationChainId),o=le(e.failReason),I=le(e.refundFailReason),s=e.status==="success"&&h.length>0&&u!==void 0,p=e.status==="refund"&&h.length>0&&r!==void 0,$=e.status==="failure"&&I!==void 0,f=["waiting","depositing","pending","submitted","failure","refund","success"].includes(e.status)?e.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof e.failReason=="string"?e.failReason:"")?"timeout":e.status:"unknown",q=s?"Relay reports destination fulfillment.":p?"Relay reports a refund on the origin chain; the destination was not fulfilled.":$?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:i,status:f,relayStatus:e.status,fulfilled:s,settled:s||p,pollAgain:!s&&!p&&!$,needsAttention:$,timedOut:!1,inTxHashes:n,txHashes:h,originChainId:r,destinationChainId:u,failReason:o,refundFailReason:I,...e.updatedAt===void 0?{}:{updatedAt:k(String(e.updatedAt))},summary:q}}async function Ee(i,e){let n=o=>({destinationVerified:!1,destinationCheck:o}),h;try{if(h=y.clientFor(i),await h.getChainId()!==i)return n(`The configured RPC does not serve chain ${i}; destination receipts were not checked.`)}catch{return n(`No RPC is available for chain ${i}; destination receipts were not checked.`)}let r=[];for(let o of e)try{let I=await h.getTransactionReceipt({hash:o});r.push({hash:o,status:I.status,blockNumber:I.blockNumber.toString()})}catch{return{...n(`Receipt ${o} is not available on chain ${i} yet; poll again.`),destinationReceipts:r}}let u=r.length>0&&r.every(o=>o.status==="success");return{destinationVerified:u,destinationReceipts:r,destinationCheck:u?`Every Relay destination transaction has a successful receipt on chain ${i}. Amounts are not decoded here; compare the recipient balance for the exact delivered amount.`:`A Relay destination transaction did not succeed on chain ${i}; do not treat this bridge as delivered.`}}async function Pe(i){let e=await y.clientFor(l).readContract({address:i,abi:Me,functionName:"decimals"}),n=typeof e=="bigint"?Number(e):e;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>255)throw new m("Could not read valid ERC-20 decimals() on-chain.");return n}async function Oe(i,e){let n=d(e),h=d(i.recipient??n),r=J(i.destinationChainId);if(r===l)throw new m("Choose a destination chain other than 4663.");let u=Ce(i.originCurrency??K),o=u!==K,I=d(i.destinationCurrency??K),s=k(i.amount);if(s==="0")throw new m("Provide a positive bridge amount.");let p=i.minAmountOut===void 0?void 0:k(i.minAmountOut),$=i.slippageBps??me;if(typeof $!="number")throw new m("Slippage must be an integer from 0 to 9999 bps.");de("0",$);let v=A((await L("/chains")).chains).map(t),f=v.find(a=>a.id===l),q=v.find(a=>a.id===r);if(!f||!q||f.disabled!==!1||q.disabled!==!1||f.depositEnabled!==!0||f.vmType!=="evm"||q.vmType!=="evm")throw new m("Relay does not currently support this outbound chain route.");if(!Se(r))throw new m(`Relay has no supported Oak return path from chain ${r}. Choose a destination supported by relay_bridge_in before bridge-out.`);let D=await qe(y.clientFor,r,n,"server"),H=o?await Pe(u):18,b=Math.floor(Date.now()/1e3)+ve,R=await L("/quote/v2",{user:n,recipient:h,originChainId:l,destinationChainId:r,originCurrency:u,destinationCurrency:I,amount:s,tradeType:"EXACT_INPUT",...o?{explicitDeposit:!0}:{}}),C=F(R.requestId),x=t(R.details),N=O(x.currencyIn),g=O(x.currencyOut),S={token:g.token,amount:k(t(x.currencyOut).minimumAmount)};if(c(d(x.sender)===n&&d(x.recipient)===h&&N.token.chainId===l&&N.token.address===u&&N.token.decimals===H&&N.amount===s&&g.token.chainId===r&&g.token.address===I&&BigInt(S.amount)>0n&&BigInt(S.amount)<=BigInt(g.amount)),I===K&&c(g.token.decimals===t(q.currency).decimals),p!==void 0){if(S.amount!==p)throw new m("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(S.amount)<BigInt(de(g.amount,$)))throw De(g.amount,S.amount);let Z=t(t(R.protocol).v2),G=F(Z.orderId),j=t(Z.orderData),V=t(j.output),ee=ue(V.deadline),X=A(j.inputs).map(t);c(X.length>0);let te=X.flatMap(a=>{let w=A(a.refunds).map(t);return c(w.length>0),w.map(Ie=>{if(d(Ie.recipient)!==n)throw new m("Relay refund recipient does not match the agent wallet. Request a new quote.");return ue(Ie.deadline)})}),_e=te.reduce((a,w)=>Math.min(a,w),ee),ne=Math.min(b,_e-xe),fe=()=>{if(Date.now()/1e3>=ne)throw new m("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};fe();let B=A(V.payments).map(t),ie=t(t(f.protocol).v2),He=t(t(q.protocol).v2),Y=t(Z.paymentDetails);c(V.chainId===He.chainId&&B.length===1&&A(V.calls).length===0&&d(B[0].recipient)===h&&d(B[0].currency)===I&&k(B[0].minimumAmount)===S.amount&&k(B[0].expectedAmount)===g.amount&&Y.chainId===ie.chainId&&d(Y.currency)===u&&k(Y.amount)===s),c(d(Y.depository)===_&&d(ie.depository)===_);let oe=t(X[0].payment);c(X.length===1&&oe.chainId===ie.chainId&&d(oe.currency)===u&&k(oe.amount)===s);let U=A(R.steps).map(t),P=o&&U.length===2?U[0]:void 0;c(U.length===(P?2:1));let Q=U[U.length-1];c(Q.kind==="transaction"&&Q.id==="deposit"&&Q.requestId===C);let W=A(Q.items).map(t);c(W.length===1&&W[0].status==="incomplete");let T=t(W[0].data),ye=t(W[0].check);if(c(ye.method==="GET"&&ye.endpoint===`/intents/status/v3?requestId=${C}`&&T.chainId===l&&d(T.from)===n&&d(T.to)===_&&k(T.value)===(o?"0":s)),typeof T.data!="string"||!(o?/^0x[0-9a-fA-F]{264}$/:/^0x[0-9a-fA-F]{136}$/).test(T.data))throw new m(`Relay returned unexpected ${o?"ERC-20":"native"} deposit calldata.`);let E=Ue({abi:Re,data:T.data});E.functionName==="depositErc20"?c(o&&d(E.args[0])===n&&d(E.args[1])===u&&E.args[2]===BigInt(s)&&M(E.args[3],G)):c(!o&&d(E.args[0])===n&&M(E.args[1],G));let Ne=v.filter(a=>a.vmType==="evm"&&z(a.protocol)&&z(a.protocol.v2)).map(a=>t(t(a.protocol).v2).chainId).filter(a=>typeof a=="string");if(!M(Te(j,Ne),G))throw new m("Relay order ID does not match the checked quote terms. Request a new quote.");let ae=o?y.approval(u,_,s,l):void 0;if(P&&ae){c(P.kind==="transaction"&&P.id==="approve"&&P.requestId===C);let a=A(P.items).map(t);c(a.length===1&&a[0].status==="incomplete");let w=t(a[0].data);c(w.chainId===l&&d(w.from)===n&&d(w.to)===u&&k(w.value)==="0"&&typeof w.data=="string"&&M(w.data,ae.data))}let ge=[...ae?await Ae(y,u,_,s,l,n):[],y.unsignedTx({to:_,data:T.data,value:o?"0":s,chainId:l,description:o?`Deposit ${s} base units of ${u} for Relay request ${C}.`:`Deposit native ETH for Relay request ${C}.`})],we=t(R.fees);for(let a of Object.values(we))O(a);let se=await y.preview(ge,n);fe();let Be=se.changes.map(a=>{let w=a.amount.startsWith("-");return`${w?"-":""}${y.formatAmount(w?a.amount.slice(1):a.amount,a.token.decimals)} ${a.token.symbol}`}).join(", ");return{txs:ge,requestId:C,orderId:G,orderData:structuredClone(j),recipient:h,originChainId:l,destinationChainId:r,expiresAt:String(ne),orderDeadline:String(ee),refundDeadlines:te.map(String),returnPath:D,amountIn:N,amountOut:g,minAmountOut:S,fees:we,expandedPriceImpact:x.expandedPriceImpact,timeEstimate:x.timeEstimate,preview:se,summary:`${D} Bridge to ${h} on chain ${r}; asset ${g.token.address} on chain ${g.token.chainId} (${pe(g.token.symbol)}); expected ${g.amount}, minimum ${S.amount} base units (${g.token.decimals} decimals). Order deadline ${ee} Unix seconds; refund deadlines ${te.join(", ")} Unix seconds; accept before ${ne} Unix seconds to reserve ${xe}s to sign and send. Origin preview: ${Be||se.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${C} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1,description:"Destination chain ID."},amount:{type:"string",pattern:"^[1-9][0-9]*$",description:'Origin token amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG).'},recipient:{...re,description:"Destination recipient address; defaults to your wallet."},originCurrency:{...re,description:"Origin token address; defaults to native ETH."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:me,description:"Slippage in basis points (50 = 0.5%)."},destinationCurrency:{type:"string",description:"Destination token address; defaults to the destination chain\u2019s native token."},minAmountOut:ke('Minimum destination token amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG).')}},execute:async(i,e)=>{try{return await Oe(i,e)}catch(n){throw new m(y.plainError(n))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Relay request ID as a 0x-prefixed 32-byte hex string."},verifyDestination:{type:"boolean",description:"Check destination transactions on their chain when fulfilled."}}},execute:async i=>{let e=await he(F(i.requestId));return i.verifyDestination!==!0||!e.fulfilled||e.destinationChainId===void 0?e:{...e,...await Ee(e.destinationChainId,e.txHashes)}}}],positions:async i=>{let e=d(i),n=new Map,h={module:"relay",id:"relay-discovery-unavailable",chainId:l,assets:[],incomplete:!0,description:`Relay pending bridge discovery is unavailable: it needs the hosted Relay read (Oak's server-held Relay key), which is not available in this setup; no pending bridges were checked, which is not the same as none pending. Ask the operator to enable it, or check a known request with relay_status {"requestId":"<id>"}. Legacy vault shares on other chains can be checked with relay_vault_status {"chainId":1} or {"chainId":42161}.`};for(let r of["outbound","inbound"]){let u=new Set,o;do{let I=new URLSearchParams({user:e,[r==="outbound"?"originChainId":"destinationChainId"]:String(l),limit:"100",includePendingRequests:"true"});o&&I.set("continuation",o);let s;try{s=await L(`/requests/v3?${I}`)}catch(p){if(Fe(y.plainError(p)))return[...n.values(),h];throw p}for(let p of A(s.requests).map(t)){let $=z(p.depositAddress)?p.depositAddress.depositor:void 0;if(![p.user,p.sender,$].some(C=>typeof C=="string"&&C.toLowerCase()===e))throw new m("Relay returned a request for another wallet.");let v=F(p.id);if(n.has(v))continue;let f=await he(v);if(f.settled)continue;let q=t(p.data),D=t(t(q.route).quoted),H=O(t(D.origin).inputCurrency),b={...H,token:{...H.token,symbol:pe(H.token.symbol)??"unknown"}},R=O(t(D.destination).outputCurrency);c(r==="outbound"?b.token.chainId===l&&R.token.chainId!==l:b.token.chainId!==l&&R.token.chainId===l),f.originChainId!==void 0&&c(f.originChainId===b.token.chainId),f.destinationChainId!==void 0&&c(f.destinationChainId===R.token.chainId),n.set(v,{module:"relay",id:v,chainId:b.token.chainId,assets:[b],description:`Relay ${r} ${f.status}: ${b.amount} ${b.token.symbol} base units (${b.token.decimals} decimals) from chain ${b.token.chainId} toward ${d(p.recipient)} on chain ${R.token.chainId}. ${f.summary} Track with relay_status requestId ${v}.`})}if(s.continuation!==void 0&&s.continuation!==null&&typeof s.continuation!="string")throw new m("Relay returned invalid pagination.");if(o=typeof s.continuation=="string"&&s.continuation?s.continuation:void 0,o){if(u.has(o))throw new m("Relay repeated its pagination cursor. Pending positions are incomplete.");u.add(o)}}while(o)}return[...n.values()]}}};export{Ke as a};
1
+ import{c as Se}from"./DXAPKN7H.js";import{a as Te}from"./JFWJBZ7M.js";import{a as qe,b as me,c as De}from"./Z3IBPCY4.js";import{h as Re,i as t,j as A,k as d,l as Ce,m as J,n as k,o as ue,p as F,r as O,s as c,t as ce,u as le,v as pe,w as Ae,x as $e}from"./Y64GFBTA.js";import{a as ve,o as de}from"./GYPMUYB5.js";import{a as ke}from"./66F5ZH34.js";import{c as re,e as z,g as M}from"./NWNYJ26T.js";import{b as l,j as be}from"./TI727O2H.js";import{a as m}from"./XSD5NL7J.js";import{decodeFunctionData as Ue,erc20Abi as Me}from"viem";var K="0x0000000000000000000000000000000000000000",_=be[l].relay.depository.address.toLowerCase(),xe=30;function Fe(y){return/HTTP (400|401|403)\b|API key|\bhosted\b|authenticated wallet session/i.test(y)}var Ke=y=>{let L=$e(y);async function he(i){let e;try{e=await L(`/intents/status/v3?requestId=${encodeURIComponent(i)}`)}catch(D){if(y.plainError(D)!=="The request timed out. Please try again.")throw D;return{requestId:i,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof e.status!="string")throw new m("Relay returned an invalid bridge status.");let n=ce(e.inTxHashes),h=ce(e.txHashes),r=e.originChainId===void 0?void 0:J(e.originChainId),u=e.destinationChainId===void 0?void 0:J(e.destinationChainId),o=le(e.failReason),I=le(e.refundFailReason),s=e.status==="success"&&h.length>0&&u!==void 0,p=e.status==="refund"&&h.length>0&&r!==void 0,$=e.status==="failure"&&I!==void 0,f=["waiting","depositing","pending","submitted","failure","refund","success"].includes(e.status)?e.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof e.failReason=="string"?e.failReason:"")?"timeout":e.status:"unknown",q=s?"Relay reports destination fulfillment.":p?"Relay reports a refund on the origin chain; the destination was not fulfilled.":$?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:i,status:f,relayStatus:e.status,fulfilled:s,settled:s||p,pollAgain:!s&&!p&&!$,needsAttention:$,timedOut:!1,inTxHashes:n,txHashes:h,originChainId:r,destinationChainId:u,failReason:o,refundFailReason:I,...e.updatedAt===void 0?{}:{updatedAt:k(String(e.updatedAt))},summary:q}}async function Ee(i,e){let n=o=>({destinationVerified:!1,destinationCheck:o}),h;try{if(h=y.clientFor(i),await h.getChainId()!==i)return n(`The configured RPC does not serve chain ${i}; destination receipts were not checked.`)}catch{return n(`No RPC is available for chain ${i}; destination receipts were not checked.`)}let r=[];for(let o of e)try{let I=await h.getTransactionReceipt({hash:o});r.push({hash:o,status:I.status,blockNumber:I.blockNumber.toString()})}catch{return{...n(`Receipt ${o} is not available on chain ${i} yet; poll again.`),destinationReceipts:r}}let u=r.length>0&&r.every(o=>o.status==="success");return{destinationVerified:u,destinationReceipts:r,destinationCheck:u?`Every Relay destination transaction has a successful receipt on chain ${i}. Amounts are not decoded here; compare the recipient balance for the exact delivered amount.`:`A Relay destination transaction did not succeed on chain ${i}; do not treat this bridge as delivered.`}}async function Pe(i){let e=await y.clientFor(l).readContract({address:i,abi:Me,functionName:"decimals"}),n=typeof e=="bigint"?Number(e):e;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>255)throw new m("Could not read valid ERC-20 decimals() on-chain.");return n}async function Oe(i,e){let n=d(e),h=d(i.recipient??n),r=J(i.destinationChainId);if(r===l)throw new m("Choose a destination chain other than 4663.");let u=Ce(i.originCurrency??K),o=u!==K,I=d(i.destinationCurrency??K),s=k(i.amount);if(s==="0")throw new m("Provide a positive bridge amount.");let p=i.minAmountOut===void 0?void 0:k(i.minAmountOut),$=i.slippageBps??me;if(typeof $!="number")throw new m("Slippage must be an integer from 0 to 9999 bps.");de("0",$);let v=A((await L("/chains")).chains).map(t),f=v.find(a=>a.id===l),q=v.find(a=>a.id===r);if(!f||!q||f.disabled!==!1||q.disabled!==!1||f.depositEnabled!==!0||f.vmType!=="evm"||q.vmType!=="evm")throw new m("Relay does not currently support this outbound chain route.");if(!Se(r))throw new m(`Relay has no supported Oak return path from chain ${r}. Choose a destination supported by relay_bridge_in before bridge-out.`);let D=await qe(y.clientFor,r,n,"server"),H=o?await Pe(u):18,b=Math.floor(Date.now()/1e3)+ve,R=await L("/quote/v2",{user:n,recipient:h,originChainId:l,destinationChainId:r,originCurrency:u,destinationCurrency:I,amount:s,tradeType:"EXACT_INPUT",...o?{explicitDeposit:!0}:{}}),C=F(R.requestId),x=t(R.details),N=O(x.currencyIn),g=O(x.currencyOut),S={token:g.token,amount:k(t(x.currencyOut).minimumAmount)};if(c(d(x.sender)===n&&d(x.recipient)===h&&N.token.chainId===l&&N.token.address===u&&N.token.decimals===H&&N.amount===s&&g.token.chainId===r&&g.token.address===I&&BigInt(S.amount)>0n&&BigInt(S.amount)<=BigInt(g.amount)),I===K&&c(g.token.decimals===t(q.currency).decimals),p!==void 0){if(S.amount!==p)throw new m("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(S.amount)<BigInt(de(g.amount,$)))throw De(g.amount,S.amount);let Z=t(t(R.protocol).v2),G=F(Z.orderId),j=t(Z.orderData),V=t(j.output),ee=ue(V.deadline),X=A(j.inputs).map(t);c(X.length>0);let te=X.flatMap(a=>{let w=A(a.refunds).map(t);return c(w.length>0),w.map(Ie=>{if(d(Ie.recipient)!==n)throw new m("Relay refund recipient does not match the agent wallet. Request a new quote.");return ue(Ie.deadline)})}),_e=te.reduce((a,w)=>Math.min(a,w),ee),ne=Math.min(b,_e-xe),fe=()=>{if(Date.now()/1e3>=ne)throw new m("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};fe();let B=A(V.payments).map(t),ie=t(t(f.protocol).v2),He=t(t(q.protocol).v2),Y=t(Z.paymentDetails);c(V.chainId===He.chainId&&B.length===1&&A(V.calls).length===0&&d(B[0].recipient)===h&&d(B[0].currency)===I&&k(B[0].minimumAmount)===S.amount&&k(B[0].expectedAmount)===g.amount&&Y.chainId===ie.chainId&&d(Y.currency)===u&&k(Y.amount)===s),c(d(Y.depository)===_&&d(ie.depository)===_);let oe=t(X[0].payment);c(X.length===1&&oe.chainId===ie.chainId&&d(oe.currency)===u&&k(oe.amount)===s);let U=A(R.steps).map(t),P=o&&U.length===2?U[0]:void 0;c(U.length===(P?2:1));let Q=U[U.length-1];c(Q.kind==="transaction"&&Q.id==="deposit"&&Q.requestId===C);let W=A(Q.items).map(t);c(W.length===1&&W[0].status==="incomplete");let T=t(W[0].data),ye=t(W[0].check);if(c(ye.method==="GET"&&ye.endpoint===`/intents/status/v3?requestId=${C}`&&T.chainId===l&&d(T.from)===n&&d(T.to)===_&&k(T.value)===(o?"0":s)),typeof T.data!="string"||!(o?/^0x[0-9a-fA-F]{264}$/:/^0x[0-9a-fA-F]{136}$/).test(T.data))throw new m(`Relay returned unexpected ${o?"ERC-20":"native"} deposit calldata.`);let E=Ue({abi:Re,data:T.data});E.functionName==="depositErc20"?c(o&&d(E.args[0])===n&&d(E.args[1])===u&&E.args[2]===BigInt(s)&&M(E.args[3],G)):c(!o&&d(E.args[0])===n&&M(E.args[1],G));let Ne=v.filter(a=>a.vmType==="evm"&&z(a.protocol)&&z(a.protocol.v2)).map(a=>t(t(a.protocol).v2).chainId).filter(a=>typeof a=="string");if(!M(Te(j,Ne),G))throw new m("Relay order ID does not match the checked quote terms. Request a new quote.");let ae=o?y.approval(u,_,s,l):void 0;if(P&&ae){c(P.kind==="transaction"&&P.id==="approve"&&P.requestId===C);let a=A(P.items).map(t);c(a.length===1&&a[0].status==="incomplete");let w=t(a[0].data);c(w.chainId===l&&d(w.from)===n&&d(w.to)===u&&k(w.value)==="0"&&typeof w.data=="string"&&M(w.data,ae.data))}let ge=[...ae?await Ae(y,u,_,s,l,n):[],y.unsignedTx({to:_,data:T.data,value:o?"0":s,chainId:l,description:o?`Deposit ${s} base units of ${u} for Relay request ${C}.`:`Deposit native ETH for Relay request ${C}.`})],we=t(R.fees);for(let a of Object.values(we))O(a);let se=await y.preview(ge,n);fe();let Be=se.changes.map(a=>{let w=a.amount.startsWith("-");return`${w?"-":""}${y.formatAmount(w?a.amount.slice(1):a.amount,a.token.decimals)} ${a.token.symbol}`}).join(", ");return{txs:ge,requestId:C,orderId:G,orderData:structuredClone(j),recipient:h,originChainId:l,destinationChainId:r,expiresAt:String(ne),orderDeadline:String(ee),refundDeadlines:te.map(String),returnPath:D,amountIn:N,amountOut:g,minAmountOut:S,fees:we,expandedPriceImpact:x.expandedPriceImpact,timeEstimate:x.timeEstimate,preview:se,summary:`${D} Bridge to ${h} on chain ${r}; asset ${g.token.address} on chain ${g.token.chainId} (${pe(g.token.symbol)}); expected ${g.amount}, minimum ${S.amount} base units (${g.token.decimals} decimals). Order deadline ${ee} Unix seconds; refund deadlines ${te.join(", ")} Unix seconds; accept before ${ne} Unix seconds to reserve ${xe}s to sign and send. Origin preview: ${Be||se.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${C} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1,description:"Destination chain ID."},amount:{type:"string",pattern:"^[1-9][0-9]*$",description:'Origin token amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG).'},recipient:{...re,description:"Destination recipient address; defaults to your wallet."},originCurrency:{...re,description:"Origin token address; defaults to native ETH."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:me,description:"Slippage in basis points (50 = 0.5%)."},destinationCurrency:{type:"string",description:"Destination token address; defaults to the destination chain\u2019s native token."},minAmountOut:ke('Minimum destination token amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG).')}},execute:async(i,e)=>{try{return await Oe(i,e)}catch(n){throw new m(y.plainError(n))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Relay request ID as a 0x-prefixed 32-byte hex string."},verifyDestination:{type:"boolean",description:"Check destination transactions on their chain when fulfilled."}}},execute:async i=>{let e=await he(F(i.requestId));return i.verifyDestination!==!0||!e.fulfilled||e.destinationChainId===void 0?e:{...e,...await Ee(e.destinationChainId,e.txHashes)}}}],positions:async i=>{let e=d(i),n=new Map,h={module:"relay",id:"relay-discovery-unavailable",chainId:l,assets:[],incomplete:!0,description:`Relay pending bridge discovery is unavailable: it needs the hosted Relay read (Oak's server-held Relay key), which is not available in this setup; no pending bridges were checked, which is not the same as none pending. Ask the operator to enable it, or check a known request with relay_status {"requestId":"<id>"}. Legacy vault shares on other chains can be checked with relay_vault_status {"chainId":1} or {"chainId":42161}.`};for(let r of["outbound","inbound"]){let u=new Set,o;do{let I=new URLSearchParams({user:e,[r==="outbound"?"originChainId":"destinationChainId"]:String(l),limit:"100",includePendingRequests:"true"});o&&I.set("continuation",o);let s;try{s=await L(`/requests/v3?${I}`)}catch(p){if(Fe(y.plainError(p)))return[...n.values(),h];throw p}for(let p of A(s.requests).map(t)){let $=z(p.depositAddress)?p.depositAddress.depositor:void 0;if(![p.user,p.sender,$].some(C=>typeof C=="string"&&C.toLowerCase()===e))throw new m("Relay returned a request for another wallet.");let v=F(p.id);if(n.has(v))continue;let f=await he(v);if(f.settled)continue;let q=t(p.data),D=t(t(q.route).quoted),H=O(t(D.origin).inputCurrency),b={...H,token:{...H.token,symbol:pe(H.token.symbol)??"unknown"}},R=O(t(D.destination).outputCurrency);c(r==="outbound"?b.token.chainId===l&&R.token.chainId!==l:b.token.chainId!==l&&R.token.chainId===l),f.originChainId!==void 0&&c(f.originChainId===b.token.chainId),f.destinationChainId!==void 0&&c(f.destinationChainId===R.token.chainId),n.set(v,{module:"relay",id:v,chainId:b.token.chainId,assets:[b],description:`Relay ${r} ${f.status}: ${b.amount} ${b.token.symbol} base units (${b.token.decimals} decimals) from chain ${b.token.chainId} toward ${d(p.recipient)} on chain ${R.token.chainId}. ${f.summary} Track with relay_status requestId ${v}.`})}if(s.continuation!==void 0&&s.continuation!==null&&typeof s.continuation!="string")throw new m("Relay returned invalid pagination.");if(o=typeof s.continuation=="string"&&s.continuation?s.continuation:void 0,o){if(u.has(o))throw new m("Relay repeated its pagination cursor. Pending positions are incomplete.");u.add(o)}}while(o)}return[...n.values()]}}};export{Ke as a};
@@ -1 +1 @@
1
- import{k as Y}from"./NV6FDIYT.js";import{b as V,c as W,d as G}from"./W7QNSNOH.js";import{d as de,e as L}from"./GYPMUYB5.js";import{a as B}from"./Z7FGEWO2.js";import{a as N}from"./43LI5NKJ.js";import{b as H,c as se,d as ae,e as j}from"./IX3GZMTM.js";import{b as x,j as D}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{a as S}from"./JXOEJPJ4.js";import{decodeEventLog as $e,encodeAbiParameters as pe,encodeFunctionData as ye,erc20Abi as Z,getAddress as l,isAddress as E,keccak256 as Ee,parseAbi as _e,parseAbiParameters as we,toEventSelector as ge}from"viem";var A=l(D[4663].hookr.HookrLimitOrders.address),ve=l(D[4663].hookr.HookrRoot.address),Ne=l(D[4663].hookr.HookrRouter.address),It=l(D[4663].hookr.HookrRegistry.address),Be=l(D[4663].hookr.HookrForwarder.address),Fe=l(D[4663].hookr.PoolManager.address),At=l(D[4663].hookr.HOOKR_Token.address),Me=l("0x000000000000000000000000000000000000dEaD"),ze=8388608,qe=200,ce=60n,Xe=604800n,ue=31536000n,ht=10,St=100,xt="500000000000000",Ct="10000000000000000",me=4096n,Q=32n,Ke=1e4,Ue=(1n<<127n)-1n,le=(1n<<128n)-1n,je=(1n<<160n)-1n,Ve=(1n<<40n)-1n,We=16777215,Ge=8388607,fe=1n<<192n,ee=0,M=1,Ye=2,Qe=3,Ze=ge("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),Dt=ge("OrderCancelled(uint256,address,address,uint256,uint256)"),P=_e(["function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function F(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ke(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===B.toLowerCase()||t===de.toLowerCase()}function $(e,t){if(typeof e!="string"||!e.trim())throw new o(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!E(n,{strict:!1}))throw new o(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return ke(n)?L:l(n)}function be(e){let t=e===void 0?x:Number(e);if(!Number.isSafeInteger(t)||t!==x)throw new o(`Hookr limit orders are only supported on Robinhood Chain (${x}).`);return x}function Je(e){switch(e){case ee:return"None";case M:return"Open";case Ye:return"Filled";case Qe:return"Cancelled";default:return"Unknown"}}function et(e,t,n=ae){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new o("Signed amount must be an integer string in base units.");let r=e.trim();if(r.startsWith("-")){let i=r.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(r,t)}function Pt(e,t,n="floor"){return se(e,t,n)}function Oe(e){return Ee(pe(we("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Ie(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),Me.toLowerCase(),A.toLowerCase(),Ne.toLowerCase(),Be.toLowerCase(),Fe.toLowerCase(),t.toLowerCase()]).has(n))throw new o(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function J(e,t,n,r){if(ke(e))return{address:B,symbol:V.symbol,decimals:V.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(F(r)){let s=typeof r.decimals=="number"&&Number.isInteger(r.decimals)&&r.decimals>=0&&r.decimals<=255?r.decimals:void 0,a=typeof r.symbol=="string"&&r.symbol.trim()?r.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===W.address.toLowerCase())return{...W,chainId:t};if(u===G.address.toLowerCase())return{...G,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Z,functionName:"symbol"}),n.readContract({address:i,abi:Z,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new o(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new o(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function tt(e){let t=F(e.key)?e.key:F(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??ze,r=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(r)||r<0||r>We)throw new o("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??qe,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>Ge)throw new o("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??ve;if(typeof s!="string"||!E(s,{strict:!1}))throw new o("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=$(t?.currency0??e.currency0,"currency0"),I=$(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===I.toLowerCase())throw new o("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(I))throw new o("Pool currency0 must sort strictly before currency1 by address.");let b;if(typeof e.zeroForOne=="boolean")b=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let C=$(e.tokenIn??e.from,"tokenIn");if(C.toLowerCase()===m.toLowerCase())b=!0;else if(C.toLowerCase()===I.toLowerCase())b=!1;else throw new o("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new o("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:I,fee:r,tickSpacing:u,hooks:a},zeroForOne:b}}let w=e.tokenIn??e.from,f=e.tokenOut??e.to;if(w===void 0||f===void 0)throw new o("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let g=$(w,"tokenIn"),k=$(f,"tokenOut");if(g.toLowerCase()===k.toLowerCase())throw new o("Input and output tokens must have distinct addresses.");let p=BigInt(g)<BigInt(k),y=p?g:k,d=p?k:g;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==p)throw new o("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:y,currency1:d,fee:r,tickSpacing:u,hooks:a},zeroForOne:p}}function nt(e,t,n){let r=Y(t),i=r*r;if(n){let s=j(e.toString(),i.toString(),fe.toString(),"ceil");return BigInt(s)}let u=j(e.toString(),fe.toString(),i.toString(),"ceil");return BigInt(u)}function R(e,t){if(typeof e=="bigint"){if(e<0n)throw new o(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new o(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return H(e.trim());throw new o(`Provide ${t} as a decimal base-unit string.`)}async function ot(e,t){if(t!==void 0)return R(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new o("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new o("Could not read the chain timestamp for Hookr order expiry.")}function Ae(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${et(n.amount,n.token.decimals,t.formatAmount)} ${S(n.token.symbol)}`).join(", ")}function rt(e,t,n,r){if(!e||!Array.isArray(e.logs))throw new o("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!E(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new o(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===A.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+r*64)throw new o(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new o(`Could not find Hookr ${t} event in transaction receipt logs.`)}function he(e){if(e.receipt!==void 0){if(!F(e.receipt)||!Array.isArray(e.receipt.logs))throw new o("Provide a transaction receipt with a logs array.");return st({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new o("Provide receipt logs as an array.");return it(e.logs)}}function Se(e){let t=rt(e,"OrderCreated",Ze,6);try{let n=$e({abi:P,eventName:"OrderCreated",...t,strict:!0});if(pe(we("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new o("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new o("Malformed Hookr OrderCreated receipt log.")}}function it(e){return Se({logs:e}).orderId}function st(e){return Se(e).orderId}function xe(e){if(Array.isArray(e)){let[n,r,i,u,s,a,c,w,f,g,k]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:r,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(w),minAmountOut:BigInt(f),bounty:BigInt(g),sqrtPriceLimitX96:BigInt(k)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Ce(e,t,n){let r=R(t,"orderId");if(r<=0n)throw new o("Order ID must be a positive integer.");let i=e.clientFor(x),u=n?.order??await i.readContract({address:A,abi:P,functionName:"getOrder",args:[r]}).catch(()=>{throw new o(`Could not read Hookr order #${r}. Order coverage is incomplete.`)}),s=xe(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===ee)throw new o(`Hookr order #${r} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},w=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,g=m=>{let I=m.toLowerCase(),b=n?.tokens.get(I);if(b)return b;let C=J(m,x,i);return n?.tokens.set(I,C),C},[k,p]=await Promise.all([g(w),g(f)]),y=!1,d=0n;if(a===M)try{let m=await i.readContract({address:A,abi:P,functionName:"quoteFill",args:[r]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new o(`Invalid quote for Hookr order #${r}.`);y=m[0],d=m[1]}catch{throw new o(`Could not quote Hookr order #${r}. Fillability and output amount are unknown.`)}return{orderId:r.toString(),poolId:Oe(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:Je(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:k,tokenOut:p,fillable:y,quotedAmountOut:d.toString()}}function at(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",description:"Uniswap v4 PoolKey of the pool to place the order in; omitted fee, tickSpacing and hooks use Hookr defaults. tokenIn or zeroForOne picks the direction.",properties:{currency0:{type:"string",description:"Lower-sorted pool token address (0x followed by 40 hex digits)."},currency1:{type:"string",description:"Higher-sorted pool token address (0x followed by 40 hex digits)."},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%); default 8388608, the v4 dynamic-fee flag of Hookr pools."},tickSpacing:{type:"number",description:"Pool tick spacing, a positive integer; defaults to the Hookr pool spacing."},hooks:{type:"string",description:"Address of the pool hook contract; defaults to the Hookr root hook."}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){N(n);let r=l(n),i=be(t.chainId),u=e.clientFor(i),s=he(t),{key:a,zeroForOne:c}=tt(t),w=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[g,k]=await Promise.all([J(w,i,u,t.tokenInMeta),J(f,i,u,t.tokenOutMeta)]),p=t.recipient??r;if(typeof p!="string"||!E(p,{strict:!1}))throw new o("Provide a valid recipient address for the Hookr limit order.");let y=l(p);if(Ie(y,a.hooks),y!==r)throw new o("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new o("Provide amountIn as an integer string in base units.");let d=H(t.amountIn);if(d<=0n||d>Ue)throw new o("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let T=Number(t.tick);Y(T)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new o("Provide minAmountOut as an integer string in base units.");m=H(t.minAmountOut)}else if(t.tick!==void 0)m=nt(d,Number(t.tick),c);else throw new o("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>le)throw new o("minAmountOut must be between 1 and uint128.max base units.");let I=t.sqrtPriceLimitX96!==void 0?R(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(I>je)throw new o("sqrtPriceLimitX96 exceeds uint160 bounds.");let b=await ot(u,t.now),C=t.expiry??t.deadline,O;if(C!==void 0)O=R(C,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let T=R(t.lifetime??t.ttlSeconds,"lifetime");O=b+T}else O=b+Xe;if(O<b+ce)throw new o(`Order expiry (${O}) is expired or below the minimum lifetime of ${ce} seconds from block timestamp ${b}.`);if(O>b+ue||O>Ve)throw new o(`Order expiry (${O}) exceeds the maximum lifetime of ${ue} seconds (365 days).`);let z=await u.readContract({address:A,abi:P,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new o("Could not read Hookr bounty bounds.")}),_=BigInt(z[0]),q=BigInt(z[1]),X=BigInt(z[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new o("Provide bounty as an integer string in base units.");let h=t.bounty!==void 0?H(t.bounty):q,K=_>0n?_:q;if(h<_||K>0n&&h<K)throw new o(`Order keeper bounty (${h} wei) is underbounty: must be at least ${K} wei (default keeper bounty floor).`);if(h>X||h>le)throw new o(`Order keeper bounty (${h} wei) exceeds the maximum allowed bounty of ${X} wei.`);let te=w.toLowerCase()===L.toLowerCase(),v=[];if(!te){let T;try{let U=await u.readContract({address:w,abi:Z,functionName:"allowance",args:[r,A]});if(typeof U!="bigint"||U<0n)throw new o("Invalid token allowance.");T=U}catch{throw new o(`Could not read token allowance for ${w}. No approval was prepared.`)}T<d&&v.push(e.approval(w,A,d.toString(),i))}let Pe=te?d+h:h,Le=ye({abi:P,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:I,recipient:y,expiry:Number(O),bounty:h}]}),ne=e.formatAmount(d.toString(),g.decimals),oe=e.formatAmount(m.toString(),k.decimals),re=e.formatAmount(h.toString(),18),Te=e.unsignedTx({to:A,data:Le,value:Pe.toString(),chainId:i,description:`Create Hookr limit order on ${A}: sell ${ne} ${S(g.symbol)} (${g.address}) for at least ${oe} ${S(k.symbol)} (${k.address}) with ${re} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${O}).`});v.push(Te);let ie=await e.preview(v,r),Re=Ae(ie,e),He=Oe(a);return{txs:v,summary:`Hookr limit order prepared: sell ${ne} ${S(g.symbol)} for at least ${oe} ${S(k.symbol)} (bounty ${re} ETH, expiry ${O}; preview deltas: ${Re}).`,preview:ie,poolId:He,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:h.toString(),bountyBounds:{minBounty:_.toString(),defaultBounty:q.toString(),maxBounty:X.toString()},expiry:O.toString(),recipient:y,sqrtPriceLimitX96:I.toString(),tokenIn:g,tokenOut:k,...s!==void 0?{orderId:s}:{}}}}}function dt(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){N(n);let r=l(n),i=be(t.chainId),u=he(t),s=t.orderId??t.id??u;if(s===void 0)throw new o("Provide orderId to cancel a Hookr limit order.");let a=R(s,"orderId");if(a<=0n)throw new o("orderId must be a positive integer.");let c=await Ce(e,a);if(c.owner.toLowerCase()!==r.toLowerCase())throw new o(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${r}).`);if(c.status!==M)throw new o(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let w=t.to??r;if(typeof w!="string"||!E(w,{strict:!1}))throw new o("Provide a valid refund recipient address for cancel.");let f=l(w);if(Ie(f,c.key.hooks),f!==r)throw new o("Hookr refund recipient must be the signing wallet.");let g=ye({abi:P,functionName:"cancel",args:[a,f]}),k=e.formatAmount(c.amountIn,c.tokenIn.decimals),p=e.formatAmount(c.bounty,18),y=e.unsignedTx({to:A,data:g,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${A} and refund ${k} ${S(c.tokenIn.symbol)} plus ${p} ETH bounty to ${f}.`}),d=await e.preview([y],r),m=Ae(d,e);return{txs:[y],summary:`Cancel Hookr limit order #${a}: refund ${k} ${S(c.tokenIn.symbol)} and ${p} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function ct(e){let t=performance.now()+Ke;return new Proxy(e,{get(n,r,i){return r!=="readContract"?Reflect.get(n,r,i):async(...u)=>{let s=t-performance.now(),a=()=>new o("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((w,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function ut(e){return async t=>{N(t);let n=l(t),r=ct(e.clientFor(x)),i={...e,clientFor:()=>r},u=await r.readContract({address:A,abi:P,functionName:"lastOrderId"}).catch(()=>{throw new o("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new o("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>me?s-me+1n:1n;if(s<=0n)return[];let c=[],w=new Map;for(let f=a;f<=s;f+=Q){let g=Array.from({length:Number(s-f+1n<Q?s-f+1n:Q)},(p,y)=>f+BigInt(y)),k=await Promise.all(g.map(async p=>{let y=await r.readContract({address:A,abi:P,functionName:"getOrder",args:[p]}).catch(()=>{throw new o(`Could not read Hookr order #${p}. Order coverage is incomplete.`)}),d=xe(y);if(d.owner.toLowerCase()===L||Number(d.status)===ee)throw new o(`Hookr order #${p} does not exist. Order coverage is incomplete.`);return{id:p,order:d}}));for(let{id:p,order:y}of k){if(y.owner.toLowerCase()!==n.toLowerCase()||Number(y.status)!==M)continue;let d=await Ce(i,p,{order:y,tokens:w}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:B,symbol:"ETH",decimals:18,chainId:x},amount:d.bounty});let I=e.formatAmount(d.amountIn,d.tokenIn.decimals),b=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),C=e.formatAmount(d.bounty,18),O=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:x,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${I} ${S(d.tokenIn.symbol)} (${d.tokenIn.address}) for at least ${b} ${S(d.tokenOut.symbol)} (${d.tokenOut.address}), bounty ${C} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${O} ${S(d.tokenOut.symbol)}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:x,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}var De=e=>{let t=[at(e),dt(e)],n=ut(e);return{tools:t,positions:n}},Lt=De,Tt=De;export{A as a,ve as b,Ne as c,It as d,Be as e,Fe as f,At as g,Me as h,ze as i,qe as j,ce as k,Xe as l,ue as m,ht as n,St as o,xt as p,Ct as q,me as r,Ke as s,ee as t,M as u,Ye as v,Qe as w,Ze as x,Dt as y,P as z,et as A,Pt as B,Oe as C,rt as D,Se as E,it as F,st as G,xe as H,Ce as I,at as J,dt as K,ct as L,ut as M,De as N,Lt as O,Tt as P};
1
+ import{m as Y}from"./7OOCAZBE.js";import{b as V,c as W,d as G}from"./N624NR7Y.js";import{d as de,e as L}from"./GYPMUYB5.js";import{a as B}from"./Z7FGEWO2.js";import{a as N}from"./43LI5NKJ.js";import{b as H,c as se,d as ae,e as j}from"./IX3GZMTM.js";import{b as x,j as D}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{a as S}from"./JXOEJPJ4.js";import{decodeEventLog as $e,encodeAbiParameters as pe,encodeFunctionData as ye,erc20Abi as Z,getAddress as l,isAddress as E,keccak256 as Ee,parseAbi as _e,parseAbiParameters as we,toEventSelector as ge}from"viem";var A=l(D[4663].hookr.HookrLimitOrders.address),ve=l(D[4663].hookr.HookrRoot.address),Ne=l(D[4663].hookr.HookrRouter.address),It=l(D[4663].hookr.HookrRegistry.address),Be=l(D[4663].hookr.HookrForwarder.address),Fe=l(D[4663].hookr.PoolManager.address),At=l(D[4663].hookr.HOOKR_Token.address),Me=l("0x000000000000000000000000000000000000dEaD"),ze=8388608,qe=200,ce=60n,Xe=604800n,ue=31536000n,ht=10,St=100,xt="500000000000000",Ct="10000000000000000",me=4096n,Q=32n,Ke=1e4,Ue=(1n<<127n)-1n,le=(1n<<128n)-1n,je=(1n<<160n)-1n,Ve=(1n<<40n)-1n,We=16777215,Ge=8388607,fe=1n<<192n,ee=0,M=1,Ye=2,Qe=3,Ze=ge("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),Dt=ge("OrderCancelled(uint256,address,address,uint256,uint256)"),P=_e(["function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function F(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ke(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===B.toLowerCase()||t===de.toLowerCase()}function $(e,t){if(typeof e!="string"||!e.trim())throw new o(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!E(n,{strict:!1}))throw new o(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return ke(n)?L:l(n)}function be(e){let t=e===void 0?x:Number(e);if(!Number.isSafeInteger(t)||t!==x)throw new o(`Hookr limit orders are only supported on Robinhood Chain (${x}).`);return x}function Je(e){switch(e){case ee:return"None";case M:return"Open";case Ye:return"Filled";case Qe:return"Cancelled";default:return"Unknown"}}function et(e,t,n=ae){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new o("Signed amount must be an integer string in base units.");let r=e.trim();if(r.startsWith("-")){let i=r.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(r,t)}function Pt(e,t,n="floor"){return se(e,t,n)}function Oe(e){return Ee(pe(we("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Ie(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),Me.toLowerCase(),A.toLowerCase(),Ne.toLowerCase(),Be.toLowerCase(),Fe.toLowerCase(),t.toLowerCase()]).has(n))throw new o(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function J(e,t,n,r){if(ke(e))return{address:B,symbol:V.symbol,decimals:V.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(F(r)){let s=typeof r.decimals=="number"&&Number.isInteger(r.decimals)&&r.decimals>=0&&r.decimals<=255?r.decimals:void 0,a=typeof r.symbol=="string"&&r.symbol.trim()?r.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===W.address.toLowerCase())return{...W,chainId:t};if(u===G.address.toLowerCase())return{...G,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Z,functionName:"symbol"}),n.readContract({address:i,abi:Z,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new o(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new o(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function tt(e){let t=F(e.key)?e.key:F(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??ze,r=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(r)||r<0||r>We)throw new o("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??qe,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>Ge)throw new o("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??ve;if(typeof s!="string"||!E(s,{strict:!1}))throw new o("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=$(t?.currency0??e.currency0,"currency0"),I=$(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===I.toLowerCase())throw new o("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(I))throw new o("Pool currency0 must sort strictly before currency1 by address.");let b;if(typeof e.zeroForOne=="boolean")b=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let C=$(e.tokenIn??e.from,"tokenIn");if(C.toLowerCase()===m.toLowerCase())b=!0;else if(C.toLowerCase()===I.toLowerCase())b=!1;else throw new o("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new o("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:I,fee:r,tickSpacing:u,hooks:a},zeroForOne:b}}let w=e.tokenIn??e.from,f=e.tokenOut??e.to;if(w===void 0||f===void 0)throw new o("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let g=$(w,"tokenIn"),k=$(f,"tokenOut");if(g.toLowerCase()===k.toLowerCase())throw new o("Input and output tokens must have distinct addresses.");let p=BigInt(g)<BigInt(k),y=p?g:k,d=p?k:g;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==p)throw new o("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:y,currency1:d,fee:r,tickSpacing:u,hooks:a},zeroForOne:p}}function nt(e,t,n){let r=Y(t),i=r*r;if(n){let s=j(e.toString(),i.toString(),fe.toString(),"ceil");return BigInt(s)}let u=j(e.toString(),fe.toString(),i.toString(),"ceil");return BigInt(u)}function R(e,t){if(typeof e=="bigint"){if(e<0n)throw new o(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new o(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return H(e.trim());throw new o(`Provide ${t} as a decimal base-unit string.`)}async function ot(e,t){if(t!==void 0)return R(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new o("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new o("Could not read the chain timestamp for Hookr order expiry.")}function Ae(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${et(n.amount,n.token.decimals,t.formatAmount)} ${S(n.token.symbol)}`).join(", ")}function rt(e,t,n,r){if(!e||!Array.isArray(e.logs))throw new o("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!E(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new o(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===A.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+r*64)throw new o(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new o(`Could not find Hookr ${t} event in transaction receipt logs.`)}function he(e){if(e.receipt!==void 0){if(!F(e.receipt)||!Array.isArray(e.receipt.logs))throw new o("Provide a transaction receipt with a logs array.");return st({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new o("Provide receipt logs as an array.");return it(e.logs)}}function Se(e){let t=rt(e,"OrderCreated",Ze,6);try{let n=$e({abi:P,eventName:"OrderCreated",...t,strict:!0});if(pe(we("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new o("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new o("Malformed Hookr OrderCreated receipt log.")}}function it(e){return Se({logs:e}).orderId}function st(e){return Se(e).orderId}function xe(e){if(Array.isArray(e)){let[n,r,i,u,s,a,c,w,f,g,k]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:r,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(w),minAmountOut:BigInt(f),bounty:BigInt(g),sqrtPriceLimitX96:BigInt(k)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Ce(e,t,n){let r=R(t,"orderId");if(r<=0n)throw new o("Order ID must be a positive integer.");let i=e.clientFor(x),u=n?.order??await i.readContract({address:A,abi:P,functionName:"getOrder",args:[r]}).catch(()=>{throw new o(`Could not read Hookr order #${r}. Order coverage is incomplete.`)}),s=xe(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===ee)throw new o(`Hookr order #${r} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},w=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,g=m=>{let I=m.toLowerCase(),b=n?.tokens.get(I);if(b)return b;let C=J(m,x,i);return n?.tokens.set(I,C),C},[k,p]=await Promise.all([g(w),g(f)]),y=!1,d=0n;if(a===M)try{let m=await i.readContract({address:A,abi:P,functionName:"quoteFill",args:[r]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new o(`Invalid quote for Hookr order #${r}.`);y=m[0],d=m[1]}catch{throw new o(`Could not quote Hookr order #${r}. Fillability and output amount are unknown.`)}return{orderId:r.toString(),poolId:Oe(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:Je(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:k,tokenOut:p,fillable:y,quotedAmountOut:d.toString()}}function at(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",description:"Uniswap v4 PoolKey of the pool to place the order in; omitted fee, tickSpacing and hooks use Hookr defaults. tokenIn or zeroForOne picks the direction.",properties:{currency0:{type:"string",description:"Lower-sorted pool token address (0x followed by 40 hex digits)."},currency1:{type:"string",description:"Higher-sorted pool token address (0x followed by 40 hex digits)."},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%); default 8388608, the v4 dynamic-fee flag of Hookr pools."},tickSpacing:{type:"number",description:"Pool tick spacing, a positive integer; defaults to the Hookr pool spacing."},hooks:{type:"string",description:"Address of the pool hook contract; defaults to the Hookr root hook."}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){N(n);let r=l(n),i=be(t.chainId),u=e.clientFor(i),s=he(t),{key:a,zeroForOne:c}=tt(t),w=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[g,k]=await Promise.all([J(w,i,u,t.tokenInMeta),J(f,i,u,t.tokenOutMeta)]),p=t.recipient??r;if(typeof p!="string"||!E(p,{strict:!1}))throw new o("Provide a valid recipient address for the Hookr limit order.");let y=l(p);if(Ie(y,a.hooks),y!==r)throw new o("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new o("Provide amountIn as an integer string in base units.");let d=H(t.amountIn);if(d<=0n||d>Ue)throw new o("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let T=Number(t.tick);Y(T)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new o("Provide minAmountOut as an integer string in base units.");m=H(t.minAmountOut)}else if(t.tick!==void 0)m=nt(d,Number(t.tick),c);else throw new o("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>le)throw new o("minAmountOut must be between 1 and uint128.max base units.");let I=t.sqrtPriceLimitX96!==void 0?R(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(I>je)throw new o("sqrtPriceLimitX96 exceeds uint160 bounds.");let b=await ot(u,t.now),C=t.expiry??t.deadline,O;if(C!==void 0)O=R(C,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let T=R(t.lifetime??t.ttlSeconds,"lifetime");O=b+T}else O=b+Xe;if(O<b+ce)throw new o(`Order expiry (${O}) is expired or below the minimum lifetime of ${ce} seconds from block timestamp ${b}.`);if(O>b+ue||O>Ve)throw new o(`Order expiry (${O}) exceeds the maximum lifetime of ${ue} seconds (365 days).`);let z=await u.readContract({address:A,abi:P,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new o("Could not read Hookr bounty bounds.")}),_=BigInt(z[0]),q=BigInt(z[1]),X=BigInt(z[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new o("Provide bounty as an integer string in base units.");let h=t.bounty!==void 0?H(t.bounty):q,K=_>0n?_:q;if(h<_||K>0n&&h<K)throw new o(`Order keeper bounty (${h} wei) is underbounty: must be at least ${K} wei (default keeper bounty floor).`);if(h>X||h>le)throw new o(`Order keeper bounty (${h} wei) exceeds the maximum allowed bounty of ${X} wei.`);let te=w.toLowerCase()===L.toLowerCase(),v=[];if(!te){let T;try{let U=await u.readContract({address:w,abi:Z,functionName:"allowance",args:[r,A]});if(typeof U!="bigint"||U<0n)throw new o("Invalid token allowance.");T=U}catch{throw new o(`Could not read token allowance for ${w}. No approval was prepared.`)}T<d&&v.push(e.approval(w,A,d.toString(),i))}let Pe=te?d+h:h,Le=ye({abi:P,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:I,recipient:y,expiry:Number(O),bounty:h}]}),ne=e.formatAmount(d.toString(),g.decimals),oe=e.formatAmount(m.toString(),k.decimals),re=e.formatAmount(h.toString(),18),Te=e.unsignedTx({to:A,data:Le,value:Pe.toString(),chainId:i,description:`Create Hookr limit order on ${A}: sell ${ne} ${S(g.symbol)} (${g.address}) for at least ${oe} ${S(k.symbol)} (${k.address}) with ${re} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${O}).`});v.push(Te);let ie=await e.preview(v,r),Re=Ae(ie,e),He=Oe(a);return{txs:v,summary:`Hookr limit order prepared: sell ${ne} ${S(g.symbol)} for at least ${oe} ${S(k.symbol)} (bounty ${re} ETH, expiry ${O}; preview deltas: ${Re}).`,preview:ie,poolId:He,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:h.toString(),bountyBounds:{minBounty:_.toString(),defaultBounty:q.toString(),maxBounty:X.toString()},expiry:O.toString(),recipient:y,sqrtPriceLimitX96:I.toString(),tokenIn:g,tokenOut:k,...s!==void 0?{orderId:s}:{}}}}}function dt(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){N(n);let r=l(n),i=be(t.chainId),u=he(t),s=t.orderId??t.id??u;if(s===void 0)throw new o("Provide orderId to cancel a Hookr limit order.");let a=R(s,"orderId");if(a<=0n)throw new o("orderId must be a positive integer.");let c=await Ce(e,a);if(c.owner.toLowerCase()!==r.toLowerCase())throw new o(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${r}).`);if(c.status!==M)throw new o(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let w=t.to??r;if(typeof w!="string"||!E(w,{strict:!1}))throw new o("Provide a valid refund recipient address for cancel.");let f=l(w);if(Ie(f,c.key.hooks),f!==r)throw new o("Hookr refund recipient must be the signing wallet.");let g=ye({abi:P,functionName:"cancel",args:[a,f]}),k=e.formatAmount(c.amountIn,c.tokenIn.decimals),p=e.formatAmount(c.bounty,18),y=e.unsignedTx({to:A,data:g,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${A} and refund ${k} ${S(c.tokenIn.symbol)} plus ${p} ETH bounty to ${f}.`}),d=await e.preview([y],r),m=Ae(d,e);return{txs:[y],summary:`Cancel Hookr limit order #${a}: refund ${k} ${S(c.tokenIn.symbol)} and ${p} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function ct(e){let t=performance.now()+Ke;return new Proxy(e,{get(n,r,i){return r!=="readContract"?Reflect.get(n,r,i):async(...u)=>{let s=t-performance.now(),a=()=>new o("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((w,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function ut(e){return async t=>{N(t);let n=l(t),r=ct(e.clientFor(x)),i={...e,clientFor:()=>r},u=await r.readContract({address:A,abi:P,functionName:"lastOrderId"}).catch(()=>{throw new o("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new o("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>me?s-me+1n:1n;if(s<=0n)return[];let c=[],w=new Map;for(let f=a;f<=s;f+=Q){let g=Array.from({length:Number(s-f+1n<Q?s-f+1n:Q)},(p,y)=>f+BigInt(y)),k=await Promise.all(g.map(async p=>{let y=await r.readContract({address:A,abi:P,functionName:"getOrder",args:[p]}).catch(()=>{throw new o(`Could not read Hookr order #${p}. Order coverage is incomplete.`)}),d=xe(y);if(d.owner.toLowerCase()===L||Number(d.status)===ee)throw new o(`Hookr order #${p} does not exist. Order coverage is incomplete.`);return{id:p,order:d}}));for(let{id:p,order:y}of k){if(y.owner.toLowerCase()!==n.toLowerCase()||Number(y.status)!==M)continue;let d=await Ce(i,p,{order:y,tokens:w}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:B,symbol:"ETH",decimals:18,chainId:x},amount:d.bounty});let I=e.formatAmount(d.amountIn,d.tokenIn.decimals),b=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),C=e.formatAmount(d.bounty,18),O=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:x,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${I} ${S(d.tokenIn.symbol)} (${d.tokenIn.address}) for at least ${b} ${S(d.tokenOut.symbol)} (${d.tokenOut.address}), bounty ${C} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${O} ${S(d.tokenOut.symbol)}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:x,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}var De=e=>{let t=[at(e),dt(e)],n=ut(e);return{tools:t,positions:n}},Lt=De,Tt=De;export{A as a,ve as b,Ne as c,It as d,Be as e,Fe as f,At as g,Me as h,ze as i,qe as j,ce as k,Xe as l,ue as m,ht as n,St as o,xt as p,Ct as q,me as r,Ke as s,ee as t,M as u,Ye as v,Qe as w,Ze as x,Dt as y,P as z,et as A,Pt as B,Oe as C,rt as D,Se as E,it as F,st as G,xe as H,Ce as I,at as J,dt as K,ct as L,ut as M,De as N,Lt as O,Tt as P};
@@ -0,0 +1 @@
1
+ var d={chainId:4663,proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7"};export{d as a};
@@ -0,0 +1 @@
1
+ import{d as J,e as Q,f as X,i as Y,n as Z,o as ee}from"./7OOCAZBE.js";import{a as v,d as j}from"./JFC2QCMW.js";import{a as z}from"./Y2QADJOB.js";import{a as G,b as V,c as R}from"./CFPJDLTZ.js";import{b as L,j as W}from"./TI727O2H.js";import{formatUnits as de,getAddress as le,parseAbi as ne}from"viem";var b=10n**18n,F=1n<<192n,te=ne(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function liquidity() view returns (uint128)","function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]),me=ne(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))"]),a=m=>({usdEstimate:null,estimateLabel:"price unavailable",estimateReason:m}),k=m=>`${m.chainId}:${m.address.toLowerCase()}`;async function we(m,P,w={}){let C=Number.isFinite(w.budgetMs)?Math.min(3e3,Math.max(0,w.budgetMs)):3e3,A=`Oak stopped pricing after ${C===3e3?"3 seconds":`${C} milliseconds`}`,E=new Map,O=[...new Map(P.map(e=>[k(e.token),e.token])).values()],h=!1,T=0,S=[];async function I(e){if(h)throw new Error(A);if(T>=6?await new Promise(t=>S.push(t)):T++,h)throw new Error(A);try{return await e()}finally{let t=S.shift();t?t():T--}}let B=new Map,N=new Map,q=new Map,H;function g(e){let t=B.get(e);if(!t){let n=m.clientFor(e);t=new Proxy(n,{get(r,o,c){let p=Reflect.get(r,o,c);return["readContract","getCode","multicall"].includes(String(o))?(...u)=>I(async()=>Reflect.apply(p,r,u)):p}}),B.set(e,t)}return t}function y(e){let t=N.get(e);return t||(t=I(()=>g(e).getBlockNumber({cacheTime:0})),N.set(e,t)),t}function U(e,t){return H??=Z(e,void 0,t).then(n=>{let r=BigInt(n);if(r<=0n)throw new Error("ETH average unavailable");return r}),H}function ie(e,t){let n=`${e}:${t}`,r=q.get(n);return r||(r=I(()=>g(e).getBlock({blockNumber:t})).then(o=>{if(!(o.number!==t||typeof o.timestamp!="bigint"||o.timestamp<=0n))return o.timestamp.toString()}).catch(()=>{}),q.set(n,r)),r}async function re(e,t){let n=g(e.chainId),r=await y(e.chainId),o=await j(e,n,r);if(!o)return a("Oak has no pinned pool with sufficient in-range depth for this token");let c=BigInt(e.address)<BigInt(v.usdg);return{numerator:c?o.sqrt**2n:F,denominator:(c?F:o.sqrt**2n)*10n**6n,source:`current price in the Uniswap USDG/${t.symbol} pool; on-chain trading can differ from the stock market`,block:r}}async function oe(e){let t=g(e.chainId),n=await y(e.chainId),{assets:r,isLog:o}=await Q(e,t,n,w.chopShareFacts),c=10n**BigInt(e.decimals),p=await Promise.all(r.map(d=>M(d.token,!1))),u=0n,s=1n;for(let d=0;d<r.length;d++){let l=p[d];if(!("numerator"in l))return l;u=u*l.denominator+BigInt(r[d].amount)*l.numerator*s,s*=l.denominator}return{numerator:u,denominator:s*c,block:n,source:`Chop ${o?"log":"LP reserves and log"} net backing estimate; default-caller fees may differ; locks and gas excluded`}}async function M(e,t=!0){if(X(e))return{numerator:1n,denominator:10n**6n,source:"USDG counted at $1.00"};if(e.chainId!==L)return a("Oak has no source for this token");let n=[G.oakLog.address,V].some(i=>i.toLowerCase()===e.address.toLowerCase()),r=w.chopShareFacts?.some(i=>[i.log.address,i.staking.address].some(f=>f.toLowerCase()===e.address.toLowerCase())),o=n||r;if(!o&&w.chopShareTokens?.some(i=>i.toLowerCase()===e.address.toLowerCase()))return a("chop_logs shows this log's backing");if(t&&o){if(P.filter(i=>k(i.token)===k(e)).every(i=>i.amount==="0"))return{numerator:0n,denominator:1n,source:"zero Chop share balance"};try{return await oe(e)}catch{return a("chop_logs shows this log's backing")}}let c=e.symbol;if(c.startsWith("untrusted "))try{let i=JSON.parse(c.slice(10));typeof i=="string"&&(c=i)}catch{}if(J(e))try{let i=g(e.chainId),f=await y(e.chainId),_=le(R.stateView),D=R.poolId,[ce,ue]=await Promise.all([i.readContract({address:_,abi:te,functionName:"getSlot0",args:[D],blockNumber:f}),i.readContract({address:_,abi:te,functionName:"getLiquidity",args:[D],blockNumber:f})]),K=ce[0];return K<=0n||ue<=0n?a("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool. A quote is a sale for this amount only; Oak never uses it to value a balance."):{numerator:await U(i,f)*F,denominator:b*K**2n*10n**BigInt(e.decimals),source:"current price in the Uniswap v4 WETH/CHOP pool",block:f}}catch{return a("Oak could not verify the pinned Uniswap v4 WETH/CHOP pool for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.")}if(c==="CHOP")return a("Oak has no pinned market for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.");let p=v.tokens.find(i=>i.token.toLowerCase()===e.address.toLowerCase());if(p)return re(e,p);if(Object.hasOwn(v.notOffered,c))return a("Oak has no pinned market for this token");let u=g(e.chainId),s=await y(e.chainId);if(Y(e))return{numerator:await U(u,s),denominator:b*b,source:"30-minute average of the Uniswap ETH/USDG pool",block:s};let d=(m.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS)?.toLowerCase()===e.address.toLowerCase();if(d)try{let i=m.resolvePrice?await m.resolvePrice(e,s):await ee(e,{client:u,blockNumber:s,oakTokenAddress:e.address,officialStockTokens:[]}),f=BigInt(i.usdE18);if(f<=0n)throw new Error("OAK price unavailable");return{numerator:f,denominator:b*10n**BigInt(e.decimals),source:"OAK price",block:s}}catch{}if(d&&(await u.readContract({address:W[L].pons.factory.address,abi:me,functionName:"getLaunchedToken",args:[e.address],blockNumber:s})).phase!==2)return a("Oak has no graduated Pons pool price for OAK");let l=await z(e,u,s);return l.numerator<=0n||l.denominator<=0n?a("Oak has no source for this token"):{numerator:await U(u,s)*l.numerator,denominator:b*l.denominator*10n**BigInt(e.decimals),source:d?"OAK's current Pons pool price; fewer than enough trades in 30 minutes for a price":"current Pons pool price",block:s}}let x=0;async function se(){for(;!h&&x<O.length;){let e=O[x++],t;try{if(!Number.isInteger(e.decimals)||e.decimals<0||e.decimals>255)throw new Error("Invalid decimals");if(t=await M(e),h||E.set(k(e),t),"numerator"in t&&t.block!==void 0){let n=await ie(e.chainId,t.block);h||(t.observedAt=n)}}catch{t=a("Oak has no source for this token")}h||E.set(k(e),t)}}let $,ae=new Promise(e=>{$=setTimeout(()=>{h=!0;for(let t of S.splice(0))t();e()},C)});try{await Promise.race([Promise.all(Array.from({length:Math.min(6,O.length)},se)),ae])}finally{clearTimeout($),h=!0}return P.map(e=>{let t;try{if(!/^\d+$/.test(e.amount)||!Number.isInteger(e.token.decimals)||e.token.decimals<0||e.token.decimals>255)throw new Error("Invalid amount");t="humanAmount"in e&&typeof e.humanAmount=="string"?e.humanAmount:de(BigInt(e.amount),e.token.decimals);let n=E.get(k(e.token));if(n&&"numerator"in n){let o=(BigInt(e.amount)*n.numerator*100n*2n+n.denominator)/(n.denominator*2n);return{...e,humanAmount:t,usdEstimate:`${o/100n}.${(o%100n).toString().padStart(2,"0")}`,estimateLabel:"estimate, not a quote",estimateSource:n.source,unitUsdE18:(n.numerator*10n**BigInt(e.token.decimals)*b/n.denominator).toString(),...n.observedAt===void 0?{}:{observedAt:n.observedAt},...n.block===void 0?{}:{estimateAsOf:n.block.toString()}}}return{...e,humanAmount:t,...n??a(A)}}catch{return{...e,...t===void 0?{}:{humanAmount:t},...a("Oak cannot format this token amount")}}})}export{we as a};
@@ -1 +1 @@
1
- import{a as f,b as a}from"./CZL6T2ZQ.js";import{a as s,b as c}from"./ZQ6AF3VX.js";import{a as w}from"./DGCJZ3HO.js";import{a as r}from"./XSD5NL7J.js";import{getAddress as d,isAddressEqual as n,keccak256 as b}from"viem";function u(e){if(!/^[0-9]+$/.test(String(e)))throw new r("Provide a Factor job ID as a non-negative integer.");let t=BigInt(e);if(t>=2n**256n)throw new r("The Factor job ID exceeds uint256.");return t}function y(e,t){if(e.codeHash.toLowerCase()!==a.desk.codeHash)throw new r("Factor desk code hash does not match the pin.");if(!n(e.burnPot,a.burnPot.address))throw new r("Factor desk burn pot does not match the pin.");if(!n(e.gateway,a.gateway.address))throw new r("Factor desk gateway does not match the pin.");if(e.stateDesk==="unreachable"){if(t)throw new r(w.stateUnavailable)}else if(!n(e.stateDesk,a.desk.address))throw new r(w.stateMismatch)}async function P(e){if(await e.getChainId()!==f.chainId)throw new r("Factor requires Robinhood Chain 4663.");let[t,o,i,C]=await Promise.all([e.getCode({address:a.desk.address}),e.readContract({address:a.desk.address,abi:s,functionName:"burnPot"}),e.readContract({address:a.desk.address,abi:s,functionName:"gateway"}),e.readContract({address:a.line.address,abi:c,functionName:"desk"})]);if(!n(C,a.desk.address))throw new r("Factor line desk does not match the pin.");return{codeHash:b(t??"0x"),burnPot:d(o),gateway:d(i)}}async function A(e,t){return e.readContract({address:a.desk.address,abi:s,functionName:"job",args:[u(t)]})}async function D(e,t){let[o,i]=await e.readContract({address:a.desk.address,abi:s,functionName:"canDrawOn",args:[u(t)]});return{early:o.toString(),pool:i.toString()}}async function F(e,t){let o=await e.readContract({address:a.line.address,abi:c,functionName:"keyOf",args:[d(t)]});return d(o)}async function I(e,t){let o=await e.getCode({address:d(t)});return o!==void 0&&o!=="0x"}export{y as a,P as b,A as c,D as d,F as e,I as f};
1
+ import{a as f,b as a}from"./CZL6T2ZQ.js";import{a as s,b as c}from"./ZQ6AF3VX.js";import{a as w}from"./UEOS6SHR.js";import{a as r}from"./XSD5NL7J.js";import{getAddress as d,isAddressEqual as n,keccak256 as b}from"viem";function u(e){if(!/^[0-9]+$/.test(String(e)))throw new r("Provide a Factor job ID as a non-negative integer.");let t=BigInt(e);if(t>=2n**256n)throw new r("The Factor job ID exceeds uint256.");return t}function y(e,t){if(e.codeHash.toLowerCase()!==a.desk.codeHash)throw new r("Factor desk code hash does not match the pin.");if(!n(e.burnPot,a.burnPot.address))throw new r("Factor desk burn pot does not match the pin.");if(!n(e.gateway,a.gateway.address))throw new r("Factor desk gateway does not match the pin.");if(e.stateDesk==="unreachable"){if(t)throw new r(w.stateUnavailable)}else if(!n(e.stateDesk,a.desk.address))throw new r(w.stateMismatch)}async function P(e){if(await e.getChainId()!==f.chainId)throw new r("Factor requires Robinhood Chain 4663.");let[t,o,i,C]=await Promise.all([e.getCode({address:a.desk.address}),e.readContract({address:a.desk.address,abi:s,functionName:"burnPot"}),e.readContract({address:a.desk.address,abi:s,functionName:"gateway"}),e.readContract({address:a.line.address,abi:c,functionName:"desk"})]);if(!n(C,a.desk.address))throw new r("Factor line desk does not match the pin.");return{codeHash:b(t??"0x"),burnPot:d(o),gateway:d(i)}}async function A(e,t){return e.readContract({address:a.desk.address,abi:s,functionName:"job",args:[u(t)]})}async function D(e,t){let[o,i]=await e.readContract({address:a.desk.address,abi:s,functionName:"canDrawOn",args:[u(t)]});return{early:o.toString(),pool:i.toString()}}async function F(e,t){let o=await e.readContract({address:a.line.address,abi:c,functionName:"keyOf",args:[d(t)]});return d(o)}async function I(e,t){let o=await e.getCode({address:d(t)});return o!==void 0&&o!=="0x"}export{y as a,P as b,A as c,D as d,F as e,I as f};
@@ -1 +1 @@
1
- import{a as W}from"./6F527FLN.js";import{a as H}from"./BJK75C7G.js";import{b as Z,c as z,d as J,e as K}from"./VDJPDIBV.js";import{a as V}from"./IPU656WB.js";import{a as L}from"./A3PN3PK3.js";import{c as j}from"./X24YTJST.js";import{b as T,o as q}from"./GYPMUYB5.js";import{b as _}from"./SPJCSEKP.js";import{a as A,d as I,e as B}from"./43LI5NKJ.js";import{a as $}from"./66F5ZH34.js";import{g as x,m as E,n as R}from"./NWNYJ26T.js";import{b as h,e as F,j as N,k as S}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),C=$("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:T,description:`Allowed slippage in basis points (50 = 0.5%), 0 to 9999. Sets the minimum output unless you pass it explicitly. Defaults to ${T}.`};function D(t){return R(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return E(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(A(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(A(t.vault),!x(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?T:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:D(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!x(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!x(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,r,s]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||r!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:r,symbol:s}}}async function u(e,a,i,r,s,p){let f=await t.preview(e,a);if(Y(f,i)!==-r)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,s)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${s.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),V(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:r,shareToken:s}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:r,shareToken:s,totalAssets:{token:r,amount:v(p).toString()},totalSupply:{token:s,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:C,minSharesOut:C,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=D(e.amount),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,s.address,i.toString(),a,h),w=[t.approval(s.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,s,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[C,{const:"all",description:"Redeem the fresh full share balance."}],description:'Vault shares to redeem, in base units (shares have 18 decimals; "1000000000000000000" = 1 share), or "all" for the full balance.'},minAmountOut:C,slippageBps:Q,force:{type:"boolean",description:'True plans a full Morpho V2 force exit with penalty disclosure. Needs shares "all", minAmountOut and maxPenaltyAssets.'},maxPenaltyAssets:$('Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.')},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:D(e.shares),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let G=j(e.maxPenaltyAssets),ee=D(e.minAmountOut),k=await Z(t,r,n,a,c,G),P=await t.preview([k.tx],a);return K(P.changes,n,c,ee),{txs:[k.tx],preview:P,summary:`${J(k.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await r.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(G=>t.unsignedTx({...G,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,s,w)})}],positions:e=>d(async()=>{A(e);let{client:a,asset:i,shareToken:r}=await l(),s=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(s===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[s]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(s.toString(),r.decimals)} Grove shares (${s} base units, ${r.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};
1
+ import{a as H}from"./M6JNGU4E.js";import{b as Z,c as z,d as J,e as K}from"./MJGEGNDU.js";import{a as W}from"./6F527FLN.js";import{a as V}from"./IPU656WB.js";import{a as L}from"./A3PN3PK3.js";import{c as j}from"./X24YTJST.js";import{b as T,o as q}from"./GYPMUYB5.js";import{b as _}from"./SPJCSEKP.js";import{a as A,d as I,e as B}from"./43LI5NKJ.js";import{a as $}from"./66F5ZH34.js";import{g as x,m as E,n as R}from"./NWNYJ26T.js";import{b as h,e as F,j as N,k as S}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as O,parseAbi as te}from"viem";var n=O(N[4663].vaults.groveAlm.address),ne="0x29626c2d8ca49a51e4deceec5499e52983c42bd5",m=te(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)","function maxDeposit(address) view returns (uint256)","function maxWithdraw(address) view returns (uint256)","function previewDeposit(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function performanceFee() view returns (uint256)","function managementFee() view returns (uint256)"]),C=$("Positive integer in token base units."),U={type:"string",description:`Public Grove vault only: ${n}. Defaults to this vault.`},Q={type:"integer",minimum:0,maximum:9999,default:T,description:`Allowed slippage in basis points (50 = 0.5%), 0 to 9999. Sets the minimum output unless you pass it explicitly. Defaults to ${T}.`};function D(t){return R(t,"Amount must be positive and within the uint256 range.",{notString:"Amount must be a positive integer string in base units.",positive:!0})}function v(t){return E(t,"Grove returned an invalid integer read.")}function M(t,d,l){if(A(d),Object.keys(t).some(u=>!["vault",...l].includes(u)))throw new o("Unsupported Grove argument.");if(t.vault!==void 0){if(typeof t.vault!="string")throw new o("Provide the public Grove vault address.");if(t.vault.toLowerCase()===ne)throw new o("The Grove ALM proxy is allocator infrastructure, not the public ERC-4626 vault.");if(A(t.vault),!x(t.vault,n))throw new o("Only the public Grove ERC-4626 vault is supported.")}}function X(t,d,l){let u=l===void 0?T:l;if(typeof u!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");let e=BigInt(q(t.toString(),u)),a=d===void 0?e:D(d);if(a<=0n||a>t)throw new o("The minimum output must be positive and no greater than the quoted output.");return a}function Y(t,d){let l=0n;for(let u of t.changes)if(!(u.token.chainId!==d.chainId||!x(u.token.address,d.address))){if(u.token.decimals!==d.decimals||typeof u.amount!="string"||!/^-?\d+$/.test(u.amount))throw new o("Grove preview returned invalid token metadata or amounts.");l+=BigInt(u.amount)}return l}var ae=t=>{async function d(e){try{return await e()}catch(a){throw new o(t.plainError(a))}}async function l(){let e=t.clientFor(h);if(await e.getChainId()!==h)throw new o("Grove requires an RPC endpoint on chain 4663.");let a=await e.readContract({address:n,abi:m,functionName:"asset"});if(typeof a!="string"||!x(a,S))throw new o("The public Grove vault must use canonical USDG on chain 4663.");let[i,r,s]=await Promise.all([e.readContract({address:O(S),abi:m,functionName:"decimals"}),e.readContract({address:n,abi:m,functionName:"decimals"}),L(e,n)]);if(i!==F||r!==18)throw new o("Grove token decimals differ from the evidenced USDG/share interface.");let p={address:O(S),chainId:h,decimals:i,symbol:"USDG"};return{client:e,asset:p,shareToken:{address:n,chainId:h,decimals:r,symbol:s}}}async function u(e,a,i,r,s,p){let f=await t.preview(e,a);if(Y(f,i)!==-r)throw new o("Grove simulation did not show the exact requested token outflow.");if(Y(f,s)<p)throw new o("Grove simulated output is below the minimum.");let g=f.changes.map(({token:w,amount:b})=>{let y=b.startsWith("-");return`${y?"-":"+"}${t.formatAmount(y?b.slice(1):b,w.decimals)} ${w.symbol} (${w.address}, chain ${w.chainId})`}).join("; ");return{txs:e,summary:`${f.summary} ${g}. Minimum ${p} base units of ${s.address} is a preview check, not enforced on-chain by standard ERC-4626. Re-preview before signing; execution output can change.`}}return{tools:[z(t,"grove_details",n),V(t,"grove_analytics",n),H(t,"grove_manage",n),...W(t,"grove",n),{name:"grove_list",inputSchema:{type:"object",properties:{vault:U},additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,[]);let{client:i,asset:r,shareToken:s}=await l(),[p,f,c,g,w,b]=await Promise.all([i.readContract({address:n,abi:m,functionName:"totalAssets"}),i.readContract({address:n,abi:m,functionName:"totalSupply"}),i.readContract({address:n,abi:m,functionName:"maxDeposit",args:[a]}),i.readContract({address:n,abi:m,functionName:"maxWithdraw",args:[a]}),i.readContract({address:n,abi:m,functionName:"performanceFee"}),i.readContract({address:n,abi:m,functionName:"managementFee"})]);return[{vault:n,chainId:h,name:"Grove x Steakhouse USDG",asset:r,shareToken:s,totalAssets:{token:r,amount:v(p).toString()},totalSupply:{token:s,amount:v(f).toString()},maxDeposit:v(c)===0n?null:c.toString(),maxWithdraw:v(g)===0n?null:g.toString(),maxViewCaveat:"Zero Morpho V2 maximum views mean unknown capacity. Simulate the requested action; full exits use the fresh share balance.",fees:{performanceFeeRaw:v(w).toString(),managementFeeRaw:v(b).toString(),scale:"1000000000000000000",managementFeeTimeUnit:"second",performanceFeeBasis:"accrued interest"}}]})},{name:"grove_deposit",inputSchema:{type:"object",description:"Deposit USDG in base units (1 USDG = 1000000) for 18-decimal vault shares. Exit with grove_withdraw; check positions after confirmation.",properties:{vault:U,amount:C,minSharesOut:C,slippageBps:Q},required:["amount"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["amount","minSharesOut","slippageBps"]);let i=D(e.amount),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"previewDeposit",args:[i]})),c=X(f,e.minSharesOut,e.slippageBps),g=I(n,s.address,i.toString(),a,h),w=[t.approval(s.address,n,i.toString(),h),t.unsignedTx(g.txs[1])];return u(w,a,s,i,p,c)})},{name:"grove_withdraw",inputSchema:{type:"object",description:"Redeem shares in 18-decimal base units, or shares all for a full exit to USDG. Check positions after confirmation.",properties:{vault:U,shares:{oneOf:[C,{const:"all",description:"Redeem the fresh full share balance."}],description:'Vault shares to redeem, in base units (shares have 18 decimals; "1000000000000000000" = 1 share), or "all" for the full balance.'},minAmountOut:C,slippageBps:Q,force:{type:"boolean",description:'True plans a full Morpho V2 force exit with penalty disclosure. Needs shares "all", minAmountOut and maxPenaltyAssets.'},maxPenaltyAssets:$('Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.')},required:["shares"],additionalProperties:!1},execute:(e,a)=>d(async()=>{M(e,a,["shares","minAmountOut","slippageBps","force","maxPenaltyAssets"]);let i=e.shares==="all"?void 0:D(e.shares),{client:r,asset:s,shareToken:p}=await l(),f=v(await r.readContract({address:n,abi:m,functionName:"balanceOf",args:[a]})),c=i??f;if(c===0n||c>f)throw new o("The Grove share balance is insufficient for this withdrawal.");if(e.force!==void 0&&typeof e.force!="boolean")throw new o("force must be a boolean.");if(e.force===!0){if(e.shares!=="all"||e.slippageBps!==void 0)throw new o("Force exit requires shares all and an explicit minAmountOut; omit slippageBps.");let G=j(e.maxPenaltyAssets),ee=D(e.minAmountOut),k=await Z(t,r,n,a,c,G),P=await t.preview([k.tx],a);return K(P.changes,n,c,ee),{txs:[k.tx],preview:P,summary:`${J(k.plan)} ${P.summary}`}}if(e.maxPenaltyAssets!==void 0)throw new o("maxPenaltyAssets requires force true.");let g=v(await r.readContract({address:n,abi:m,functionName:"previewRedeem",args:[c]})),w=X(g,e.minAmountOut,e.slippageBps),y=B(n,c.toString(),a,h).txs.map(G=>t.unsignedTx({...G,description:`Redeem ${c} Grove share base units to the wallet.`}));return u(y,a,p,c,s,w)})}],positions:e=>d(async()=>{A(e);let{client:a,asset:i,shareToken:r}=await l(),s=v(await a.readContract({address:n,abi:m,functionName:"balanceOf",args:[e]}));if(s===0n)return[];let p=v(await a.readContract({address:n,abi:m,functionName:"previewRedeem",args:[s]}));return[{module:"grove",id:`${h}:${n.toLowerCase()}`,chainId:h,assets:[{token:i,amount:p.toString()}],description:`${t.formatAmount(s.toString(),r.decimals)} Grove shares (${s} base units, ${r.decimals} decimals, ${n}); estimated USDG redemption, subject to simulation.`}]})}},we=t=>_("grove",[ae(t)]);export{ae as a,we as b};