@oakagentkit/core 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/build/dist/api/history.js +1 -1
  2. package/build/dist/api/modules/beefy/clm.d.ts +9 -0
  3. package/build/dist/api/modules/beefy/clm.js +1 -1
  4. package/build/dist/api/modules/beefy/guard.js +1 -1
  5. package/build/dist/api/modules/beefy/index.js +1 -1
  6. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  7. package/build/dist/api/modules/borro/index.js +1 -1
  8. package/build/dist/api/modules/borro/positions.js +1 -1
  9. package/build/dist/api/modules/borro/reader.js +1 -1
  10. package/build/dist/api/modules/chop/actions.js +1 -1
  11. package/build/dist/api/modules/chop/checks.js +1 -1
  12. package/build/dist/api/modules/chop/copy.js +1 -1
  13. package/build/dist/api/modules/chop/guard.js +1 -1
  14. package/build/dist/api/modules/chop/index.js +1 -1
  15. package/build/dist/api/modules/chop/pins.d.ts +13 -0
  16. package/build/dist/api/modules/chop/pins.js +1 -1
  17. package/build/dist/api/modules/chop/positions.js +1 -1
  18. package/build/dist/api/modules/chop/reader.js +1 -1
  19. package/build/dist/api/modules/clanker/index.js +1 -1
  20. package/build/dist/api/modules/earn/index.js +1 -1
  21. package/build/dist/api/modules/fobo/client.d.ts +9 -0
  22. package/build/dist/api/modules/fobo/client.js +1 -0
  23. package/build/dist/api/modules/fobo/index.d.ts +16 -0
  24. package/build/dist/api/modules/fobo/index.js +1 -0
  25. package/build/dist/api/modules/fobo/intent.d.ts +243 -0
  26. package/build/dist/api/modules/fobo/intent.js +1 -0
  27. package/build/dist/api/modules/fobo/pins.d.ts +178 -0
  28. package/build/dist/api/modules/fobo/pins.js +1 -0
  29. package/build/dist/api/modules/fobo/steps.d.ts +25 -0
  30. package/build/dist/api/modules/fobo/steps.js +1 -0
  31. package/build/dist/api/modules/fobo/verify.d.ts +89 -0
  32. package/build/dist/api/modules/fobo/verify.js +1 -0
  33. package/build/dist/api/modules/gloam/copy.d.ts +1 -1
  34. package/build/dist/api/modules/gloam/copy.js +1 -1
  35. package/build/dist/api/modules/gloam/index.js +1 -1
  36. package/build/dist/api/modules/grove/index.js +1 -1
  37. package/build/dist/api/modules/heyresearch/index.js +1 -1
  38. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  39. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  40. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  41. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  42. package/build/dist/api/modules/hoodlock/index.js +1 -1
  43. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  44. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  45. package/build/dist/api/modules/hoodlock/public.js +1 -1
  46. package/build/dist/api/modules/hookr/actions.js +1 -1
  47. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  48. package/build/dist/api/modules/hookr/discovery.js +1 -1
  49. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  50. package/build/dist/api/modules/hookr/index.js +1 -1
  51. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  52. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  53. package/build/dist/api/modules/hookr/launch.js +1 -1
  54. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  55. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  56. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  57. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  58. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  59. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  60. package/build/dist/api/modules/hookr/relay.js +1 -1
  61. package/build/dist/api/modules/kyberswap/index.js +1 -1
  62. package/build/dist/api/modules/layerbank/actions.js +1 -1
  63. package/build/dist/api/modules/layerbank/index.js +1 -1
  64. package/build/dist/api/modules/layerbank/reader.js +1 -1
  65. package/build/dist/api/modules/longbow/administration.js +1 -1
  66. package/build/dist/api/modules/longbow/fixed.js +1 -1
  67. package/build/dist/api/modules/longbow/index.js +1 -1
  68. package/build/dist/api/modules/meridian/index.js +1 -1
  69. package/build/dist/api/modules/meridian/rfq.js +1 -1
  70. package/build/dist/api/modules/merkl/discovery.js +1 -1
  71. package/build/dist/api/modules/merkl/index.js +1 -1
  72. package/build/dist/api/modules/merkl/manage.js +1 -1
  73. package/build/dist/api/modules/morpho/bundles.js +1 -1
  74. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  75. package/build/dist/api/modules/morpho/index.js +1 -1
  76. package/build/dist/api/modules/morpho/local-guard.d.ts +2 -1
  77. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  78. package/build/dist/api/modules/morpho/midnight.js +1 -1
  79. package/build/dist/api/modules/morpho/protocol.js +1 -1
  80. package/build/dist/api/modules/morpho/surface.js +1 -1
  81. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  82. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  83. package/build/dist/api/modules/netnet/card-read.js +1 -1
  84. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  85. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  86. package/build/dist/api/modules/netnet/financial.js +1 -1
  87. package/build/dist/api/modules/netnet/index.js +1 -1
  88. package/build/dist/api/modules/orbio/index.js +1 -1
  89. package/build/dist/api/modules/pendle/index.js +1 -1
  90. package/build/dist/api/modules/pendle/reader.js +1 -1
  91. package/build/dist/api/modules/pons/claim.js +1 -1
  92. package/build/dist/api/modules/pons/index.js +1 -1
  93. package/build/dist/api/modules/pons/launch-status.js +1 -1
  94. package/build/dist/api/modules/pons/reads.js +1 -1
  95. package/build/dist/api/modules/pons/swap-terms.d.ts +2 -8
  96. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  97. package/build/dist/api/modules/pons/trade.js +1 -1
  98. package/build/dist/api/modules/poolstrade/index.js +1 -1
  99. package/build/dist/api/modules/priors/coverage.js +1 -1
  100. package/build/dist/api/modules/priors/discovery.js +1 -1
  101. package/build/dist/api/modules/priors/holdings.js +1 -1
  102. package/build/dist/api/modules/priors/index.js +1 -1
  103. package/build/dist/api/modules/priors/integration.js +1 -1
  104. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  105. package/build/dist/api/modules/raeto/index.js +1 -1
  106. package/build/dist/api/modules/relay/discovery.js +1 -1
  107. package/build/dist/api/modules/relay/inbound.js +1 -1
  108. package/build/dist/api/modules/relay/index.js +1 -1
  109. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  110. package/build/dist/api/modules/spark/index.js +1 -1
  111. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  112. package/build/dist/api/modules/steakhouse/index.js +1 -1
  113. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  114. package/build/dist/api/modules/steakhouse/management.js +1 -1
  115. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  116. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  117. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  118. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  119. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  120. package/build/dist/api/modules/tickerspring/index.js +1 -1
  121. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  122. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  123. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  124. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  125. package/build/dist/api/modules/tickerspring/research.js +1 -1
  126. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  127. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  128. package/build/dist/api/modules/uniswap/auction.js +1 -1
  129. package/build/dist/api/modules/uniswap/batch.js +1 -1
  130. package/build/dist/api/modules/uniswap/common.js +1 -1
  131. package/build/dist/api/modules/uniswap/fees.js +1 -1
  132. package/build/dist/api/modules/uniswap/index.js +1 -1
  133. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  134. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  135. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  136. package/build/dist/api/modules/uniswap/pools.js +1 -1
  137. package/build/dist/api/modules/uniswap/position.js +1 -1
  138. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  139. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  140. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  141. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  142. package/build/dist/api/modules/uniswap/trade.js +1 -1
  143. package/build/dist/api/modules/uniswap/v2.js +1 -1
  144. package/build/dist/api/modules/uniswap/v3.js +1 -1
  145. package/build/dist/api/modules/uniswap/v4.js +1 -1
  146. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  147. package/build/dist/api/modules/velora/claims.js +1 -1
  148. package/build/dist/api/modules/velora/index.js +1 -1
  149. package/build/dist/api/modules/wormhole/index.js +1 -1
  150. package/build/dist/api/prices.d.ts +5 -0
  151. package/build/dist/api/prices.js +1 -1
  152. package/build/dist/api/signing-registry.js +1 -1
  153. package/build/dist/api/swap.d.ts +1 -0
  154. package/build/dist/api/swap.js +1 -1
  155. package/build/dist/api/tokens.js +1 -1
  156. package/build/dist/api/universal-router.d.ts +45 -0
  157. package/build/dist/api/universal-router.js +1 -0
  158. package/build/dist/api/usd-estimate.js +1 -1
  159. package/build/dist/chunks/{ROQQ62LP.js → 22TU5PFT.js} +1 -1
  160. package/build/dist/chunks/{2WRXH6BL.js → 257N7343.js} +1 -1
  161. package/build/dist/chunks/{B2HSLY5F.js → 27PVS6BU.js} +1 -1
  162. package/build/dist/chunks/{25C4DTVA.js → 2JWAFLJU.js} +1 -1
  163. package/build/dist/chunks/{24Q3FNGX.js → 35LXCSHY.js} +1 -1
  164. package/build/dist/chunks/{OYDKAIS2.js → 3BMM3V4P.js} +1 -1
  165. package/build/dist/chunks/{VZVW5J7J.js → 3FU6XP6S.js} +1 -1
  166. package/build/dist/chunks/{KH4QFN72.js → 3PHJUFU2.js} +1 -1
  167. package/build/dist/chunks/43BG2JRB.js +1 -0
  168. package/build/dist/chunks/{KMSAUFYV.js → 47HSRR7G.js} +1 -1
  169. package/build/dist/chunks/{2ZBSE2LD.js → 4NDIYRH5.js} +1 -1
  170. package/build/dist/chunks/{M7BUKZW2.js → 4RCYYN6O.js} +1 -1
  171. package/build/dist/chunks/4ZD5D2UP.js +1 -0
  172. package/build/dist/chunks/{X5AL3DUK.js → 6D3XNCOX.js} +1 -1
  173. package/build/dist/chunks/{W4RYRLL5.js → 6GWXPQZ6.js} +1 -1
  174. package/build/dist/chunks/{KBU3PYP7.js → 73BZPPRS.js} +1 -1
  175. package/build/dist/chunks/{XV3YJ4P6.js → 7FIEBJOZ.js} +1 -1
  176. package/build/dist/chunks/{CI5ENLYA.js → 7FZXSYFD.js} +1 -1
  177. package/build/dist/chunks/{K4P5VYDP.js → 7TSIF3F4.js} +1 -1
  178. package/build/dist/chunks/AG2G7BHH.js +6 -0
  179. package/build/dist/chunks/{QMEGAKLI.js → AIYNFIG6.js} +1 -1
  180. package/build/dist/chunks/{KZA5GYZR.js → AWV24X7F.js} +1 -1
  181. package/build/dist/chunks/{JPPQDELB.js → AXHFNE6L.js} +1 -1
  182. package/build/dist/chunks/{WOGWLFAL.js → BGVC5NI6.js} +1 -1
  183. package/build/dist/chunks/BJK75C7G.js +1 -0
  184. package/build/dist/chunks/BSX4LFYI.js +1 -0
  185. package/build/dist/chunks/{OTYB6BHK.js → BZPFPQ2I.js} +1 -1
  186. package/build/dist/chunks/{PQXYTOV5.js → DCGNVMKG.js} +1 -1
  187. package/build/dist/chunks/{OTLUQWLF.js → DLNA5272.js} +1 -1
  188. package/build/dist/chunks/{VMZYFO6I.js → DXAPKN7H.js} +1 -1
  189. package/build/dist/chunks/{NMQBOBWJ.js → EHGH646D.js} +1 -1
  190. package/build/dist/chunks/{PZEF5LBL.js → ETMD747Y.js} +1 -1
  191. package/build/dist/chunks/{XEBMS5KU.js → GGMVT5A6.js} +1 -1
  192. package/build/dist/chunks/GK3D7OKG.js +1 -0
  193. package/build/dist/chunks/GYPMUYB5.js +1 -0
  194. package/build/dist/chunks/{U7UPLF4F.js → H64QC4QR.js} +1 -1
  195. package/build/dist/chunks/{HS5HWBMU.js → HIG7JY3J.js} +1 -1
  196. package/build/dist/chunks/{NWPAQER2.js → HOBIXKGO.js} +1 -1
  197. package/build/dist/chunks/HQIS3QI7.js +3 -0
  198. package/build/dist/chunks/{C6VJAL5B.js → HUKDISRE.js} +1 -1
  199. package/build/dist/chunks/{XPWGPZ2C.js → HZSYMGJ2.js} +1 -1
  200. package/build/dist/chunks/{YARZE7SJ.js → I4473OC6.js} +1 -1
  201. package/build/dist/chunks/{DMB64UIN.js → IJ4HZIDG.js} +1 -1
  202. package/build/dist/chunks/{YBLJ75U5.js → IPU656WB.js} +1 -1
  203. package/build/dist/chunks/{QLAOBULN.js → JTPHZCO3.js} +1 -1
  204. package/build/dist/chunks/{CSOO4SW7.js → K4GUZ5QS.js} +1 -1
  205. package/build/dist/chunks/{WBNFRPAT.js → KLEJ3W4T.js} +1 -1
  206. package/build/dist/chunks/{ACH4BSME.js → KOKLM63Q.js} +1 -1
  207. package/build/dist/chunks/{VB36EHIR.js → KVVBT43U.js} +1 -1
  208. package/build/dist/chunks/{6MDYKE2O.js → KXX7ZBFY.js} +1 -1
  209. package/build/dist/chunks/{I6PQW2JI.js → L2AE32SL.js} +1 -1
  210. package/build/dist/chunks/{KOTGFD2V.js → LGLWEGPY.js} +1 -1
  211. package/build/dist/chunks/{2HN3U6OG.js → LQSPWRHN.js} +1 -1
  212. package/build/dist/chunks/{C3WBHFLX.js → LTDF2LNP.js} +1 -1
  213. package/build/dist/chunks/{RNCMXKKS.js → M4AGEGWW.js} +1 -1
  214. package/build/dist/chunks/{HVFMIURK.js → M6SQPOOL.js} +1 -1
  215. package/build/dist/chunks/{XBNZ7GTY.js → M7CQPTRK.js} +1 -1
  216. package/build/dist/chunks/{OODSXDIH.js → MGVX5EUH.js} +1 -1
  217. package/build/dist/chunks/{D2IYA4LP.js → MQ37QX6U.js} +1 -1
  218. package/build/dist/chunks/{TMRAF2L2.js → NDSNE6PS.js} +1 -1
  219. package/build/dist/chunks/{6OCLWSMZ.js → NTUXDIY6.js} +1 -1
  220. package/build/dist/chunks/{CZQ2CGYV.js → NUERUFH7.js} +1 -1
  221. package/build/dist/chunks/NV6FDIYT.js +1 -0
  222. package/build/dist/chunks/{A2V4NFVA.js → O3CC5SRM.js} +1 -1
  223. package/build/dist/chunks/{JI5DXDMY.js → ODV3XT5U.js} +1 -1
  224. package/build/dist/chunks/OLDQV43V.js +1 -0
  225. package/build/dist/chunks/{B7BNDW35.js → OY5W7ZSL.js} +1 -1
  226. package/build/dist/chunks/{CD2JQ32C.js → PDGYM2WG.js} +1 -1
  227. package/build/dist/chunks/{5R576SDB.js → PKYQ3XVA.js} +1 -1
  228. package/build/dist/chunks/{FN6GNTPR.js → PWJVC2FV.js} +1 -1
  229. package/build/dist/chunks/{Q7L3BX6U.js → QHV5GORV.js} +1 -1
  230. package/build/dist/chunks/{PSGRZWES.js → QN45T4N3.js} +1 -1
  231. package/build/dist/chunks/{LJJYYUEG.js → QPY6UTLU.js} +1 -1
  232. package/build/dist/chunks/{ATEVAJ5Y.js → RA7DOR7F.js} +1 -1
  233. package/build/dist/chunks/{U762746N.js → RUSXMQSJ.js} +1 -1
  234. package/build/dist/chunks/{UPKVD7WG.js → RXP7ZUPY.js} +1 -1
  235. package/build/dist/chunks/{2QGLPY2D.js → SMKO7GKX.js} +1 -1
  236. package/build/dist/chunks/{EHK7CDTU.js → SNCV6HV7.js} +1 -1
  237. package/build/dist/chunks/{2ZQ7X223.js → SOJHYMD7.js} +1 -1
  238. package/build/dist/chunks/{ORG6LVKJ.js → UBI3HBXD.js} +1 -1
  239. package/build/dist/chunks/{N64JJN37.js → UEHN2IDF.js} +1 -1
  240. package/build/dist/chunks/{FTMA24EC.js → UHIJMDD2.js} +1 -1
  241. package/build/dist/chunks/UJQYOTO5.js +1 -0
  242. package/build/dist/chunks/{GP6YO24Z.js → UYULQHZJ.js} +1 -1
  243. package/build/dist/chunks/{MMCM3GSM.js → V4UJMUIB.js} +1 -1
  244. package/build/dist/chunks/{ZNPVBNC5.js → VC5ZCQYZ.js} +1 -1
  245. package/build/dist/chunks/{FGEGJOAA.js → VDJPDIBV.js} +1 -1
  246. package/build/dist/chunks/{TGFQQCRY.js → VFM2BICB.js} +1 -1
  247. package/build/dist/chunks/{MSMHS456.js → VOJULRNU.js} +1 -1
  248. package/build/dist/chunks/{5W74Z4WZ.js → W3DGFMQE.js} +1 -1
  249. package/build/dist/chunks/W7OCS4AM.js +6 -0
  250. package/build/dist/chunks/{QLFPAN6S.js → W7QNSNOH.js} +1 -1
  251. package/build/dist/chunks/{OQFNUDMQ.js → XVOW6UCI.js} +1 -1
  252. package/build/dist/chunks/{P6OB2AFW.js → Y7HBFQYG.js} +1 -1
  253. package/build/dist/chunks/{LDJI2JAL.js → YGW4ODAP.js} +1 -1
  254. package/build/dist/chunks/{U243AWCH.js → YW4W3LPQ.js} +1 -1
  255. package/build/dist/chunks/{65356YKW.js → Z2QV6EZY.js} +1 -1
  256. package/build/dist/chunks/{S4UJDZGN.js → ZDCCFEVL.js} +1 -1
  257. package/build/dist/chunks/{D7QXZM3S.js → ZOLHVZDK.js} +1 -1
  258. package/build/dist/chunks/{SMSXZ3FN.js → ZSVAGOF2.js} +1 -1
  259. package/package.json +1 -1
  260. package/build/dist/chunks/4R3G3H42.js +0 -1
  261. package/build/dist/chunks/LKX5WDOQ.js +0 -1
  262. package/build/dist/chunks/ND32LJWI.js +0 -1
  263. package/build/dist/chunks/URBEK2VV.js +0 -1
  264. package/build/dist/chunks/UVAR6BHU.js +0 -1
  265. package/build/dist/chunks/V6SDKPZS.js +0 -1
@@ -1,2 +1,2 @@
1
- import{a as r}from"./I6PQW2JI.js";import{formatUnits as c}from"viem";var s="Oak x Chop. Chop's own team runs its product and contracts; Oak didn't build them and doesn't run them.",i="Chop's upgrade key can replace log code without a timelock.",u="Chop's unwrap has no on-chain minimum output. Oak checks the simulated net output, but the contract itself will not stop a worse result if state moves before inclusion.",p="Farming pairs tokens 50/50 with impermanent loss and pays in $CHOP, which can fall in price or be paused by Chop. Stake and newly earned rewards can be locked for 10 minutes.",y=[s,i,u,p],g="Wrapping $OAK moves it out of your wallet. If you are on Oak's Holder plan and your wallet balance drops below your signup amount, Oak's action tools pause until you unwrap or top up.",k="Oak checks that CHOP actually reached your wallet; a successful transaction alone does not prove a payout.",l=e=>(e.bond+e.debond)/100;function m(e){return`Wrap fee ${e.fees.bond/100}%; unwrap fee ${e.fees.debond/100}%. A short round trip loses about ${l(e.fees)}%. Caller exemptions and rounding can change the actual fee.`}function $(e){return[s,i,m(e),u,p,...e.underlying.address.toLowerCase()===r.oak.toLowerCase()?[g]:[],...e.drift.length?[`Warning: Chop code changed since Oak checked it (${e.drift.join(", ")}). New wraps and farms are refused; this exit uses the changed code.`]:[]].join(`
1
+ import{a as r}from"./L2AE32SL.js";import{formatUnits as c}from"viem";var s="Oak x Chop. Chop's own team runs its product and contracts; Oak didn't build them and doesn't run them.",i="Chop's upgrade key can replace log code without a timelock.",u="Chop's unwrap has no on-chain minimum output. Oak checks the simulated net output, but the contract itself will not stop a worse result if state moves before inclusion.",p="Farming pairs tokens 50/50 with impermanent loss and pays in $CHOP, which can fall in price or be paused by Chop. Stake and newly earned rewards can be locked for 10 minutes.",y=[s,i,u,p],g="Wrapping $OAK moves it out of your wallet. If you are on Oak's Holder plan and your wallet balance drops below your signup amount, Oak's action tools pause until you unwrap or top up.",k="Oak checks that CHOP actually reached your wallet; a successful transaction alone does not prove a payout.",l=e=>(e.bond+e.debond)/100;function m(e){return`Wrap fee ${e.fees.bond/100}%; unwrap fee ${e.fees.debond/100}%. A short round trip loses about ${l(e.fees)}%. Caller exemptions and rounding can change the actual fee.`}function $(e){return[s,i,m(e),u,p,...e.underlying.address.toLowerCase()===r.oak.toLowerCase()?[g]:[],...e.drift.length?[`Warning: Chop code changed since Oak checked it (${e.drift.join(", ")}). New wraps and farms are refused; this exit uses the changed code.`]:[]].join(`
2
2
  `)}function f(e){let o=e.underlying.symbol;return[`A log is a wrapped version of one token. You hand in ${o} and receive a log token that stays worth a share of the ${o} the log holds.`,"You can earn two ways: the log's backing can grow from other people's trading fees, and you can farm the log for CHOP rewards. Neither is a promised rate.",`Getting in and out costs about ${l(e.fees)}% together: the wrap fee plus the unwrap fee. Other fees set by the log can also apply.`,"The biggest risk: Chop's team holds a key that can replace the log's code at any time, with no waiting period."].join(" ")}function C(e,o,n,t){let a=o.usdEstimate===null?`price unavailable: ${o.estimateReason}`:`$${o.usdEstimate}, estimate, not a quote`,d=n.usdEstimate===null?"The pool's full USD depth has price unavailable; each reserve shows its amount and available estimate.":`The pool holds about $${n.usdEstimate} (estimate, not a quote).`,h=t.pct===null?`A rough $100 price move is unavailable: ${t.reason}.`:`A rough $100 trade using ${t.inputToken.symbol} to buy the log would move its price about ${t.pct}%.`;return[f(e),`This farm's whole CHOP reward pot is about ${o.humanAmount} CHOP (${a}). Oak can't read a reward rate, so it shows no yield.`,d,h,t.assumptions].join(" ")}var x=e=>`You hold 0 ${e}, so there is nothing to unwrap. Unwrapping needs a balance of that log. Nothing was signed.`;function O(e,o,n){let t=a=>c(a,e.decimals);return`You asked to unwrap ${t(o)} ${e.symbol} but hold ${t(n)} ${e.symbol}. Ask for ${t(n)} or less ("${n}" in base units).`}export{s as a,i as b,u as c,p as d,y as e,g as f,k as g,l as h,m as i,$ as j,f as k,C as l,x as m,O as n};
@@ -1 +1 @@
1
- import{d as N}from"./UNJJRQIU.js";import{b as W}from"./QLFPAN6S.js";import{c as K}from"./SCG5HWMN.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{b as q,j as z}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
1
+ import{d as N}from"./UNJJRQIU.js";import{b as W}from"./W7QNSNOH.js";import{c as K}from"./SCG5HWMN.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{b as q,j as z}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
@@ -0,0 +1 @@
1
+ import{g as k,h as A}from"./BSX4LFYI.js";import{g as i}from"./NWNYJ26T.js";import{b as l,j as m,n as y}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{decodeFunctionData as P,parseAbi as g}from"viem";var x=g(["function buy(uint256 quoteIn,uint256 minTokensOut,address recipient) payable returns (uint256)","function sell(uint256 tokensIn,uint256 minQuoteOut,address recipient) returns (uint256)"]);function f(s){return k(s)}function K(s,e,o,t){let d=f(s),c=f(e),[p,n]=BigInt(d)<BigInt(c)?[d,c]:[c,d];return{currency0:p,currency1:n,fee:o,tickSpacing:t,hooks:m[l].pons.memeHook.address}}function h(s){let e=A(s,[y]),o=e.legs[0];if(e.permit||e.legs.length!==1||!o)throw new r("Pons router must contain one canonical v4 swap command.");return{swap:{poolKey:o.poolKey,zeroForOne:o.zeroForOne,amountIn:e.amountIn,amountOutMinimum:e.amountOutMinimum,minHopPriceX36:0n,hookData:"0x"},deadline:e.deadline}}function H(s,e){let o=(n,w,a)=>{if(!i(n,w))throw new r(`Built swap ${a} does not match the accepted quote.`)},t=e.ponsPoolToken??e.ponsCurveToken;if(!t||e.ponsPoolToken&&e.ponsCurveToken)throw new r("Pons quote must name exactly one curve or pool token.");let d=i(e.to,t);if(!d&&!i(e.from,t))throw new r("Pons quote must trade its launch token.");let c=d?e.from:e.to;if(i(f(c),t))throw new r("Pons quote pair must differ from its launch token.");if(e.ponsPoolToken){if(o(e.router,m[l].ponsTrade.universal_router.address,"Pons router"),o(e.spender??e.router,m[l].ponsTrade.permit2.address,"Pons spender"),!e.data)throw new r("Pons pool quote must include locally reconstructed calldata.");let{swap:n,deadline:w}=h(s.data),a=h(e.data),u=K(c,t,a.swap.poolKey.fee,a.swap.poolKey.tickSpacing);if(o(n.poolKey.currency0,u.currency0,"pool currency0"),o(n.poolKey.currency1,u.currency1,"pool currency1"),o(n.poolKey.hooks,u.hooks,"pool hook"),n.zeroForOne!==i(f(e.from),u.currency0)||n.poolKey.fee!==a.swap.poolKey.fee||n.poolKey.tickSpacing!==a.swap.poolKey.tickSpacing||w!==a.deadline)throw new r("Pons pool direction, parameters or deadline differ from the accepted quote.");return{from:e.from,to:e.to,wallet:e.wallet,amount:n.amountIn}}let p=P({abi:x,data:s.data});if(p.functionName!==(d?"buy":"sell"))throw new r("Pons curve direction does not match the accepted quote.");return o(e.spender??e.router,e.router,"curve spender"),{from:e.from,to:e.to,wallet:p.args[2],amount:p.args[0]}}export{x as a,f as b,K as c,h as d,H as e};
@@ -0,0 +1 @@
1
+ import{b as N}from"./CQ5WRWV4.js";import{a as O,b as R,c as Z,d as ue}from"./IV4K7FMD.js";import{a as Ae,e as ge}from"./GK3D7OKG.js";import{d as he}from"./OIQTZOBN.js";import{b as x}from"./Z7FGEWO2.js";import{a as de,b as ce,d as le,f as V,g as J,h as M,j as me,k as pe,l as fe,m as we}from"./BSX4LFYI.js";import{a as f,b as X,c as ie}from"./43LI5NKJ.js";import{c as Y}from"./5TUXSOMI.js";import{g as G}from"./NWNYJ26T.js";import{b as r,e as ae}from"./IX3GZMTM.js";import{A as se,b as F,j as W,x as j,y as Q}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{decodeFunctionData as C,encodeFunctionData as U,parseAbi as Oe}from"viem";var Be=60,te=50,tt=200;var De="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",ne="0x0000000000000000000000000000000000000000",D=W[4663].routes.kyberswap.address,y=W[4663].routes.velora.address,oe=j[4663].kyberswap.toLowerCase(),Se=j[4663].velora.toLowerCase(),Te="0x0000000000000000000000000000000000000000000000000000000000000000",Re=[le.pons,...V],$=Oe(["function swap((address callTarget, address approveTarget, bytes targetData, (address srcToken, address dstToken, address[] srcReceivers, uint256[] srcAmounts, address[] feeReceivers, uint256[] feeAmounts, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags, bytes permit) desc, bytes clientData) execution) payable returns (uint256 returnAmount, uint256 gasUsed)"]),H=Oe(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]),E=class extends o{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},L=class extends o{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},Ce=1e3,I=new Map;function be(e){for(let[t,n]of I)BigInt(e)>=r(n.expiresAt)&&I.delete(t)}function ee(e){return{...e,...e.sourcePoolRoute!==void 0?{sourcePoolRoute:structuredClone(e.sourcePoolRoute)}:{},...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function ve(e){let t=ee(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var ye=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","ponsPoolToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund","oakFee","oakFeeBps","oakFeeToken","grossAmountOut","venueFee","venueFeeBps"];function K(e,t,n=!1){for(let s of ye)if(!(s==="expiresAt"&&n&&r(e.expiresAt)<=r(t.expiresAt))&&e[s]!==void 0&&String(e[s]).toLowerCase()!==String(t[s]).toLowerCase())throw new o(`Quote ${s} does not match the accepted quote.`)}function z(e=Date.now){let t=e();if(!Number.isFinite(t)||t<0)throw new o("Clock must return a non-negative timestamp.");return t>1e11?Math.floor(t/1e3):Math.floor(t)}function _(e){let t=e.toLowerCase();return t===De.toLowerCase()||t===ne.toLowerCase()}function Le(e,t=te){if(!Number.isInteger(t)||t<0||t>=1e4)throw new o("Slippage must be an integer from 0 to 9999 bps.");return ae(e,String(1e4-t),"10000","floor")}var _e=200;function nt(e){if(typeof e!="number"||!Number.isFinite(e)||!/^\d+(?:\.\d{1,2})?$/.test(String(e)))throw new o("Velora returned an unsupported venue fee. Request a fresh quote.");let[t,n=""]=String(e).split("."),s=Number(t)*100+Number(n.padEnd(2,"0"));return re(s),s}function re(e){if(!Number.isInteger(e)||e<0||e>_e)throw new o("Velora returned an unsupported venue fee. Request a fresh quote.")}function ke(e,t=O.bps){return re(t),r(e)*10000n/BigInt(1e4-t)+1n}function Pe(e,t){if(re(t),t!==O.bps||e!==Z)throw new o("Velora partnerAndFee must match the pinned Oak fee, recipient and flags.")}function Ie(e){if(e.oakFeeBps===O.bps)return`${ue()} ${e.provider==="velora"?"Oak\u2019s share is paid to the Oak treasury.":"Paid to the Oak treasury."} Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${e.provider??"venue"}. Output and minimum are net.${e.provider==="velora"?" Velora retains 15% of the partner fee; Oak receives 85% (about 21.25 bps).":""}`;if(e.oakFee!==void 0&&r(e.oakFee)!==0n)throw new o("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");let t=e.provider??"venue";return`Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${t}; Oak swap fee: 0 (venue fee is never Oak income).`}function Qe(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??Q[F].kyberswap.address,n=e.approveTarget??ne;f(t),f(n);let s=r(e.amountIn),a=r(e.minAmountOut);return U({abi:$,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:_(e.from)?[]:[t],srcAmounts:_(e.from)?[]:[s-BigInt(R(e.amountIn))],feeReceivers:[O.recipient],feeAmounts:[BigInt(O.bps)],dstReceiver:e.wallet,amount:s,minReturnAmount:a,flags:640n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Ne(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??Q[F].velora.address;return f(t),U({abi:H,functionName:"swapExactAmountIn",args:[t,{srcToken:e.from,destToken:e.to,fromAmount:r(e.amountIn),toAmount:r(e.minAmountOut),quotedAmount:r(e.amountOut),metadata:e.metadata??Te,beneficiary:e.wallet},e.partnerAndFee??Z,"0x",e.executorData??"0x"]})}function Ve(e){if(typeof e!="string"||!/^0x([0-9a-fA-F]{2})+$/.test(e)||e.length<10)throw new o("Swap calldata must contain a 4-byte function selector.");let t=e.slice(0,10).toLowerCase();if(t===oe)return C({abi:$,data:e}).args[0].desc.minReturnAmount;if(t===Se)return C({abi:H,data:e}).args[1].toAmount;if(t==="0x3593564c")return M(e,Re).amountOutMinimum;let n=C({abi:Ae,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new o(`Unsupported swap router selector ${t}.`)}function Fe(e,t,n=!1){let s=r(t),a=Ve(e);if(a<=0n||s<=0n||a!==s&&!(n&&(a>s||e.slice(0,10).toLowerCase()===oe&&a+1n===s)))throw new o(`Built swap calldata minimum output (${a}) does not match the accepted quote minimum (${s}).`);return a}function xe(e,t){let{from:n,to:s,wallet:a,amountIn:d}=t;if(!n||!s||!a||d===void 0)throw new o("Accepted quote must include input, output, amount and wallet.");for(let u of[n,s,a,t.router,e.to])f(u);let m=(u,l,w)=>{if(u.toLowerCase()!==l.toLowerCase())throw new o(`Built swap ${w} does not match the accepted quote.`)};if(m(e.to,t.router,"router"),e.chainId!==(t.chainId??F))throw new o("Built swap chain does not match the accepted quote.");let A=_(n)?r(d):0n;if(r(e.value)!==A||t.value!==void 0&&r(t.value)!==A)throw new o("Built swap value does not match the accepted quote input.");let g=e.data.slice(0,10).toLowerCase(),i=t.router.toLowerCase();if(i===D.toLowerCase()||i===y.toLowerCase()){let u=i===D.toLowerCase(),l=u?d:t.grossAmountOut,w=u?n:s;if(t.oakFeeBps!==O.bps||l===void 0||t.oakFee!==R(l)||t.oakFeeToken?.toLowerCase()!==x(w).toLowerCase())throw new o("Oak fee must match the pinned rate, token and amount.")}let c;if(i===D.toLowerCase()&&g===oe){m(t.spender??t.router,D,"spender");let u=C({abi:$,data:e.data});if(U({abi:$,...u}).toLowerCase()!==e.data.toLowerCase())throw new o("KyberSwap calldata must be canonically decodable.");let{callTarget:l,approveTarget:w,desc:p}=u.args[0];m(l,Q[F].kyberswap.address,"executor"),m(w,ne,"executor approval target");let S=_(n);if(p.srcReceivers.length!==p.srcAmounts.length||(S?p.srcReceivers.length!==0:p.srcReceivers.length===0||p.srcAmounts.some(h=>h<=0n)||p.srcAmounts.reduce((h,b)=>h+b,0n)!==r(d)-BigInt(R(d))))throw new o("KyberSwap source transfers must send the exact input less the pinned fee to the pinned executor or verified input pool.");for(let h of p.srcReceivers)if(h.toLowerCase()!==l.toLowerCase()&&!he(n,h,e.data))throw new o(`KyberSwap source transfers: receiver ${h} is not a verified input pool or the pinned executor.`);if(p.feeReceivers.length!==1||p.feeAmounts.length!==1||p.feeReceivers[0].toLowerCase()!==O.recipient.toLowerCase()||p.feeAmounts[0]!==BigInt(O.bps)||p.flags!==640n||p.permit!=="0x")throw new o("KyberSwap fee recipients, fee amounts, flags and permit must match the pinned Oak input-fee policy.");c={from:p.srcToken,to:p.dstToken,wallet:p.dstReceiver,amount:p.amount}}else if(i===y.toLowerCase()&&g===Se){m(t.spender??t.router,y,"spender");let u=C({abi:H,data:e.data});if(U({abi:H,...u}).toLowerCase()!==e.data.toLowerCase())throw new o("Velora calldata must be canonically decodable.");let[l,w,p,S]=u.args;if(!se.some(h=>h.toLowerCase()===l.toLowerCase()))throw new o("Built swap executor does not match the accepted quote.");if(S!=="0x")throw new o("Velora permit must match the pinned empty-permit policy.");if(Pe(p,t.oakFeeBps??O.bps),t.calldataMinAmountOut!==void 0&&r(t.calldataMinAmountOut)!==ke(t.minAmountOut,O.bps))throw new o("Velora calldata minimum must cover the accepted net output, venue fee and router dust.");if(t.calldataMinAmountOut!==void 0&&(w.quotedAmount!==r(t.grossAmountOut??"0")||w.quotedAmount<r(t.calldataMinAmountOut)))throw new o("Velora quoted gross output must match the accepted quote and cover its calldata minimum.");if(p!==0n&&t.calldataMinAmountOut===void 0)throw new o("Velora venue fee requires a fee-adjusted calldata minimum.");c={from:w.srcToken,to:w.destToken,wallet:w.beneficiary,amount:w.fromAmount}}else if(t.provider==="pons"&&(t.ponsPoolToken||t.ponsCurveToken))c=ge(e,{...t,from:n,to:s,wallet:a});else if(t.provider==="fobo")c=Ue(e,{...t,from:n,to:s,wallet:a});else throw new o("Built swap selector does not match the accepted router.");if(m(c.from,n,"input token"),m(c.to,s,"output token"),m(c.wallet,a,"recipient"),c.amount!==r(d))throw new o("Built swap input amount does not match the accepted quote.");Fe(e.data,t.calldataMinAmountOut??t.minAmountOut,i===D.toLowerCase())}var Me="FOBO route: the quoted output is already net of FOBO's pool taxes (2.5% per pool after a coin's first minute, higher during it). Oak swap fee: 0 on FOBO's route.";function Ue(e,t){let n=(d,m,A)=>{if(!G(d,m))throw new o(`Built swap ${A} does not match the accepted quote.`)};if(n(t.router,de,"FOBO router"),n(t.spender??t.router,ce,"FOBO spender"),t.oakFeeBps!==void 0||t.oakFee!==void 0&&r(t.oakFee)!==0n)throw new o("FOBO route trades carry no Oak fee.");let s=M(e.data,V);we(s),n(s.currencyIn,J(t.from),"input token"),n(s.currencyOut,J(t.to),"output token");let a=r(t.expiresAt);if(s.deadline>a+BigInt(pe))throw new o("FOBO swap deadline is more than 20 minutes past the accepted quote. Request a fresh quote.");if(s.permit&&(s.permit.amount!==s.amountIn||BigInt(s.permit.expiration)>s.permit.sigDeadline||s.permit.sigDeadline>a+BigInt(fe)))throw new o("FOBO permit must be for the exact swap input, expire no later than its signature deadline, and end within 30 minutes of the quote.");if(t.data!==void 0&&!G(t.data,e.data)&&!me(M(t.data,V).legs,s.legs))throw new o("Built swap FOBO pools or direction differ from the accepted quote.");return{from:t.from,to:t.to,wallet:t.wallet,amount:s.amountIn}}function q(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new o("Quote must include a non-empty quoteId.");if(f(e.router),e.oakFeeBps!==void 0){let v=t.provider??e.provider,k=v==="kyberswap"?t.amountIn??e.amountIn:e.grossAmountOut,P=v==="kyberswap"?t.from??e.from:t.to??e.to;if(!["kyberswap","velora"].includes(v??"")||e.oakFeeBps!==O.bps||k===void 0||e.oakFee!==R(k)||!P||e.oakFeeToken?.toLowerCase()!==x(P).toLowerCase())throw new o("Oak fee must match the pinned rate, token and amount.")}else if(e.oakFee!==void 0&&r(e.oakFee)!==0n)throw new o("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");let n=r(e.amountOut),s=e.destAmountAfterFee??e.netAmountOut,a,d,m;if(s!==void 0){if(d=r(s),a=e.grossAmountOut!==void 0?r(e.grossAmountOut):n>=d?n:d,a<d)throw new o("Gross output cannot be less than net output.");m=e.venueFee!==void 0?r(e.venueFee):a-d}else if(e.grossAmountOut!==void 0){if(a=r(e.grossAmountOut),d=n,a<d)throw new o("Gross output cannot be less than net output.");m=e.venueFee!==void 0?r(e.venueFee):a-d}else e.venueFee!==void 0?(m=r(e.venueFee),d=n,a=d+m):(d=n,a=n,m=0n);if(d<=0n)throw new E("Quote output amount must be positive.");let A=t.slippageBps??e.slippageBps??te,g=e.minAmountOut!==void 0?r(e.minAmountOut):r(Le(d.toString(),A));if(g<=0n||g>a)throw new o("Quote minAmountOut must be positive and not exceed gross output.");if((t.provider??e.provider)==="velora"&&e.calldataMinAmountOut!==void 0){if(r(e.calldataMinAmountOut)!==ke(g.toString(),O.bps)||r(e.calldataMinAmountOut)>a)throw new o("Velora calldata minimum must cover the accepted net output, venue fee and router dust.")}else if(e.calldataMinAmountOut!==void 0||e.ponsCurveToken!==void 0){if((t.provider??e.provider)!=="pons"||!e.ponsCurveToken)throw new o("Curve minimum requires a Pons curve quote.");f(e.ponsCurveToken);let v=r(t.amountIn??e.amountIn??"0"),k=r(e.expectedSpend??"0"),P=r(e.expectedRefund??"0"),Ee=r(e.calldataMinAmountOut??"0");if(v<=0n||k<=0n||k+P!==v||Ee*k/v!==g)throw new o("Pons actual minimum and refund do not match the encoded minimum.")}let i=z(t.now),c=BigInt(i+Be),u=e.expiresAt!==void 0?r(e.expiresAt):c,l=(u>c?c:u).toString(),w=m.toString(),p=e.venueFeeBps??(a>0n&&m>0n?Number((m*10000n+a/2n)/a):0),S=t.provider??e.provider??(e.router.toLowerCase()===y.toLowerCase()?"velora":"kyberswap"),h=S==="fobo"?Me:S==="pons"&&e.feeDisclosure?e.feeDisclosure:Ie({provider:S,venueFee:w,venueFeeBps:p,oakFee:e.oakFee??"0",oakFeeBps:e.oakFeeBps}),b={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:g.toString(),router:e.router,expiresAt:l,provider:S,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:w,venueFeeBps:p,oakFee:e.oakFee??"0",feeDisclosure:h,...t.from??e.from?{from:x(t.from??e.from)}:{},...t.to??e.to?{to:x(t.to??e.to)}:{},...t.amountIn??e.amountIn?{amountIn:t.amountIn??e.amountIn}:{},...t.wallet??e.wallet?{wallet:t.wallet??e.wallet}:{},slippageBps:A,chainId:t.chainId??e.chainId??F,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(i)>=r(l))throw new L;if(t.cache===!1)return b;if(be(i),BigInt(i)>=r(l))throw new L;let T=I.get(b.quoteId);if(T){K(b,T,!0);let v=ve({...T,expiresAt:b.expiresAt});return I.set(v.quoteId,v),ee(v)}for(;I.size>=Ce;)I.delete(I.keys().next().value);let B=ve(b);return I.set(B.quoteId,B),ee(B)}async function ot(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=x(e.from),e.to=x(e.to);let s=r(e.amountIn);if(s<=0n)throw new o("Swap amountIn must be greater than zero.");let a=e.slippageBps??te;if(!Number.isInteger(a)||a<0||a>=1e4)throw new o("Slippage must be an integer from 0 to 9999 bps.");if(!Array.isArray(t)||t.length===0)throw new E;let d={from:e.from,to:e.to,amountIn:s.toString(),slippageBps:a},m=await Promise.allSettled(t.map(async i=>{let c=await(i.quotePrices??i.quote).call(i,{...d},e.wallet);return{quote:q(c,{provider:i.name,from:e.from,to:e.to,amountIn:s.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??F,allowance:e.allowance,now:e.now,cache:!1}),provider:i}})),A,g=[];for(let i of m)i.status==="rejected"&&(A??=Y(i.reason)),i.status==="fulfilled"&&r(i.value.quote.expiresAt)>BigInt(z(e.now))&&g.push(i.value);if(g.length===0){let i=m.some(c=>c.status==="rejected"&&c.reason instanceof Error&&c.reason.message===N)&&m.every(c=>c.status==="rejected"&&(c.reason instanceof E||c.reason instanceof Error&&c.reason.message===N));throw A??new E(i?N:void 0)}g.sort((i,c)=>{let l=r(c.quote.amountOut)-r(i.quote.amountOut)||r(c.quote.minAmountOut)-r(i.quote.minAmountOut);return l>0n?1:l<0n?-1:0});for(let{quote:i,provider:c}of g)try{if(BigInt(z(e.now))>=r(i.expiresAt))continue;if(n.deferBuild||!c.prepareQuote)return q(i,{now:e.now});let u=await c.prepareQuote(i.quoteId,e.wallet);if(u.quoteId!==i.quoteId)throw new o("Prepared quote ID does not match the selected route.");if(K(u,i,!0),!u.data)throw new o("Selected route did not return swap calldata.");let l={...i,expiresAt:u.expiresAt,data:u.data,value:u.value,allowance:u.allowance??i.allowance};return xe(X({to:l.router,data:u.data,value:u.value??"0",chainId:l.chainId??F,description:"Selected swap route"}),l),q(l,{now:e.now})}catch(u){A??=Y(u);continue}throw A??new E}function rt(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new o("Provide a valid quote to build a swap.");f(e.router);let n=I.get(e.quoteId),s=z(t.now);if(be(s),!n||BigInt(s)>=r(n.expiresAt))throw I.delete(e.quoteId),new L;if(e.oakFeeBps===void 0&&e.oakFee!==void 0&&r(e.oakFee)!==0n)throw new o("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");K(e,n),K({...n,...t},n);let a=n.from,d=n.to,m=n.amountIn,A=n.wallet;if(!a||!d||!A||m===void 0)throw new o("Accepted quote must include input, output, amount and wallet.");let g=n.chainId??F,i=n.spender??n.router,c=t.allowance??e.allowance??n?.allowance??"0";f(a),f(d),f(A),f(i);let u=r(m);if(u<=0n)throw new o("Swap amountIn must be greater than zero.");let l=r(n.minAmountOut);if(l<=0n)throw new o("Swap minAmountOut must be greater than zero.");let w=e.router.toLowerCase()===y.toLowerCase(),p=t.data??e.data??n?.data??(w?Ne({from:a,to:d,amountIn:u.toString(),amountOut:n.grossAmountOut??n.amountOut,minAmountOut:n.calldataMinAmountOut??l.toString(),wallet:A}):Qe({from:a,to:d,amountIn:u.toString(),minAmountOut:l.toString(),wallet:A}));Fe(p,n.calldataMinAmountOut??l.toString(),n.router.toLowerCase()===D.toLowerCase());let S=n.venueFee??"0",h=n.venueFeeBps??0,b=n.provider??(w?"velora":"kyberswap"),T=n.feeDisclosure??Ie({provider:b,venueFee:S,venueFeeBps:h,oakFee:n.oakFee??"0",oakFeeBps:n.oakFeeBps}),B=_(a),v=t.value??e.value??n?.value??(B?u.toString():"0"),k=X({to:e.router,data:p,value:v,chainId:g,description:`Swap ${u} base units of ${a} for at least ${l} base units of ${d} via ${b} (${e.router}). ${T}`});return xe(k,n),B||r(c)>=u?[k]:[ie(a,i,u.toString(),g),k]}export{Be as a,te as b,tt as c,De as d,ne as e,$ as f,E as g,L as h,Ce as i,ee as j,ve as k,K as l,z as m,_ as n,Le as o,_e as p,nt as q,ke as r,Pe as s,Ie as t,Qe as u,Ne as v,Ve as w,Fe as x,xe as y,Me as z,q as A,ot as B,rt as C};
@@ -1 +1 @@
1
- import{a as A}from"./JI5DXDMY.js";import{a as i,b as w,c as b,e as C,f as x,g as h}from"./LJJYYUEG.js";import{a as o}from"./66F5ZH34.js";import{c as y}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as g,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as B,parseAbiParameters as D,zeroAddress as R}from"viem";var L=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),N=D("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=B(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),O=B(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:{...y,description:"Address of the ERC-20 sale token to distribute in this auction."},amount:o('Amount of sale token in base units; use sale token decimals. Example: "1000000" = 1 sale token at 6 decimals.'),currency:{...y,description:"Payment currency address; the zero address means native ETH."},startBlock:o("Future block number at which auction bidding starts, as a decimal string."),endBlock:o("Block number at which auction bidding ends, as a decimal string."),claimBlock:o("First block number at which auction tokens can be claimed, as a decimal string."),tickSpacing:o("Auction price tick spacing in Q96 payment-currency base units per sale-token base unit."),floorPrice:o("Auction floor price in Q96 payment-currency base units per sale-token base unit."),requiredCurrencyRaised:o('Minimum amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),salt:{description:"Deployment salt as a 32-byte hex string; choose a fresh value for a new deployment.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{description:"Auction issuance steps; durations must cover endBlock minus startBlock and mps times duration must total 10000000.",type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:o("Issuance rate per block in MPS units; sum of mps times duration across steps must equal 10000000."),duration:o("Duration of this issuance step in blocks, as a decimal string.")}}}};function $(e,t){let r=i(e.startBlock,"startBlock",64),n=i(e.endBlock,"endBlock",64),c=i(e.claimBlock,"claimBlock",64);if(n<=r||c<n)throw new s("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new s("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new s("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let a=d,k=i(a.mps,"mps",24,!0),m=i(a.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(m)]).slice(2)}`,l+=k*m,p+=m}if(l!==10000000n||p!==n-r)throw new s("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S(N,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:r,endBlock:n,claimBlock:c,tickSpacing:i(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:i(e.floorPrice,"floorPrice"),requiredCurrencyRaised:i(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function z(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,r){h(t,Object.keys(v));let n=w(t.token),c=i(t.amount,"amount",128);if(n===R||n===b(t.currency))throw new s("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=$(t,r);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new s("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(f),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new s("Choose a future auction startBlock with time for confirmation and approvals.");let a=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[n,c,u,p,r]});if((await l.getCode({address:a})??"0x")!=="0x")throw new s("This auction already exists; choose a fresh salt or configuration.");let k=await C(e,n),m=[e.unsignedTx({to:A,data:g({abi:P,functionName:"create",args:[n,c,u,p]}),value:"0",chainId:f,description:`Create CCA ${a}; proceeds and unsold tokens go to ${r}.`}),e.unsignedTx({to:n,data:g({abi:I,functionName:"transfer",args:[a,c]}),value:"0",chainId:f,description:`Fund the factory-predicted auction ${a} with exactly ${c} base units of ${n}.`}),e.unsignedTx({to:a,data:g({abi:B(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:f,description:`Activate CCA ${a} after its sale tokens arrive.`})];return{...await x(e,m,r,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:a,sale:{token:k,amount:c.toString()}}}}]}}export{L as a,N as b,P as c,O as d,$ as e,z as f};
1
+ import{a as A}from"./ODV3XT5U.js";import{a as i,b as w,c as b,e as C,f as x,g as h}from"./QPY6UTLU.js";import{a as o}from"./66F5ZH34.js";import{c as y}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as g,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as B,parseAbiParameters as D,zeroAddress as R}from"viem";var L=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),N=D("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=B(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),O=B(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:{...y,description:"Address of the ERC-20 sale token to distribute in this auction."},amount:o('Amount of sale token in base units; use sale token decimals. Example: "1000000" = 1 sale token at 6 decimals.'),currency:{...y,description:"Payment currency address; the zero address means native ETH."},startBlock:o("Future block number at which auction bidding starts, as a decimal string."),endBlock:o("Block number at which auction bidding ends, as a decimal string."),claimBlock:o("First block number at which auction tokens can be claimed, as a decimal string."),tickSpacing:o("Auction price tick spacing in Q96 payment-currency base units per sale-token base unit."),floorPrice:o("Auction floor price in Q96 payment-currency base units per sale-token base unit."),requiredCurrencyRaised:o('Minimum amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),salt:{description:"Deployment salt as a 32-byte hex string; choose a fresh value for a new deployment.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{description:"Auction issuance steps; durations must cover endBlock minus startBlock and mps times duration must total 10000000.",type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:o("Issuance rate per block in MPS units; sum of mps times duration across steps must equal 10000000."),duration:o("Duration of this issuance step in blocks, as a decimal string.")}}}};function $(e,t){let r=i(e.startBlock,"startBlock",64),n=i(e.endBlock,"endBlock",64),c=i(e.claimBlock,"claimBlock",64);if(n<=r||c<n)throw new s("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new s("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new s("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let a=d,k=i(a.mps,"mps",24,!0),m=i(a.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(m)]).slice(2)}`,l+=k*m,p+=m}if(l!==10000000n||p!==n-r)throw new s("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S(N,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:r,endBlock:n,claimBlock:c,tickSpacing:i(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:i(e.floorPrice,"floorPrice"),requiredCurrencyRaised:i(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function z(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,r){h(t,Object.keys(v));let n=w(t.token),c=i(t.amount,"amount",128);if(n===R||n===b(t.currency))throw new s("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=$(t,r);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new s("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(f),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new s("Choose a future auction startBlock with time for confirmation and approvals.");let a=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[n,c,u,p,r]});if((await l.getCode({address:a})??"0x")!=="0x")throw new s("This auction already exists; choose a fresh salt or configuration.");let k=await C(e,n),m=[e.unsignedTx({to:A,data:g({abi:P,functionName:"create",args:[n,c,u,p]}),value:"0",chainId:f,description:`Create CCA ${a}; proceeds and unsold tokens go to ${r}.`}),e.unsignedTx({to:n,data:g({abi:I,functionName:"transfer",args:[a,c]}),value:"0",chainId:f,description:`Fund the factory-predicted auction ${a} with exactly ${c} base units of ${n}.`}),e.unsignedTx({to:a,data:g({abi:B(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:f,description:`Activate CCA ${a} after its sale tokens arrive.`})];return{...await x(e,m,r,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:a,sale:{token:k,amount:c.toString()}}}}]}}export{L as a,N as b,P as c,O as d,$ as e,z as f};
@@ -1 +1 @@
1
- import{i as Y}from"./UVAR6BHU.js";import{b as V,c as W,d as G}from"./QLFPAN6S.js";import{d as de,e as L}from"./LKX5WDOQ.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{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 +1 @@
1
- import{e as g,f as T,g as k,i as E}from"./JPPQDELB.js";import{c as _,d as S}from"./QLFPAN6S.js";import{g as h}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.js";import{a as i}from"./XSD5NL7J.js";import{decodeAbiParameters as P,encodeAbiParameters as B,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),H=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=l=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50,description:"Maximum number of offers to return, 1 to 50 (default 20). Newest-expiring offers come first."},marketId:{type:"string",description:"Optional Midnight market id as 0x followed by 64 hex digits (bytes32); only offers in that market are returned."}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let p=await l.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!p.ok)throw new i(`Longbow fixed order book returned HTTP ${p.status}; offers are unavailable.`);let x=await p.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==f||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[w]=P(H,n);if(w.length!==r.items)throw new i("Publication count mismatch.");for(let b of w){y++;let e=b.offer;if(e.market.chainId!==BigInt(f)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let I=E(e.market);if(o.marketId!==void 0&&!h(I,String(o.marketId)))continue;let N=[_,S].find(O=>h(O.address,e.market.loanToken));c.push({marketId:I,offer:B(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:l.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:f,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(l.plainError(a))}}}]});export{D as a,H as b,G as c};
1
+ import{e as g,f as T,g as k,i as E}from"./AXHFNE6L.js";import{c as _,d as S}from"./W7QNSNOH.js";import{g as h}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.js";import{a as i}from"./XSD5NL7J.js";import{decodeAbiParameters as P,encodeAbiParameters as B,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),H=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=l=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50,description:"Maximum number of offers to return, 1 to 50 (default 20). Newest-expiring offers come first."},marketId:{type:"string",description:"Optional Midnight market id as 0x followed by 64 hex digits (bytes32); only offers in that market are returned."}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let p=await l.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!p.ok)throw new i(`Longbow fixed order book returned HTTP ${p.status}; offers are unavailable.`);let x=await p.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==f||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[w]=P(H,n);if(w.length!==r.items)throw new i("Publication count mismatch.");for(let b of w){y++;let e=b.offer;if(e.market.chainId!==BigInt(f)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let I=E(e.market);if(o.marketId!==void 0&&!h(I,String(o.marketId)))continue;let N=[_,S].find(O=>h(O.address,e.market.loanToken));c.push({marketId:I,offer:B(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:l.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:f,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(l.plainError(a))}}}]});export{D as a,H as b,G as c};
@@ -0,0 +1,3 @@
1
+ import{a as o,b as C,c as K,d as O,e as E,f as D}from"./4ZD5D2UP.js";import{h as H}from"./BSX4LFYI.js";import{c as U}from"./43LI5NKJ.js";import{e as N,g as R,h as l}from"./NWNYJ26T.js";import{a as P}from"./XSD5NL7J.js";import{decodeFunctionData as y,encodeFunctionData as k,erc20Abi as _,getAddress as q,isAddress as G,zeroAddress as h}from"viem";var X=15000000n,j=1200,L="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",w=n=>(1n<<BigInt(n))-1n;function S(n){throw new P(`FOBO ${n}. Nothing was signed. Ask for a fresh summary.`)}function i(n,e){n||S(e)}function I(n,e){return i(typeof n=="string"&&G(n,{strict:!1}),e),q(n)}function m(n,e,s){i(l(I(n,s),I(e,s)),s)}function T(n,e,s=256){i(typeof n=="string"&&n.length<=80&&/^(?:[0-9]+|0x[0-9a-fA-F]+)$/.test(n),`${e} must be an unsigned integer`);let r=BigInt(n);return i(r<=w(s),`${e} is too large`),r}function p(n,e,s=256){return i(typeof n=="bigint"&&n>=0n&&n<=w(s),`${e} is invalid`),n}function B(n){i(Number.isSafeInteger(n)&&n>=0&&n<=Number(w(48))-1800,"clock is invalid")}var $=120;function v(n,e){i(R(n,e),"calldata must be canonical")}function M(n,e){return l(n.currency0,e.currency0)&&l(n.currency1,e.currency1)&&l(n.hooks,e.hooks)&&n.fee===e.fee&&n.tickSpacing===e.tickSpacing}function z(n){i([o.permit2,o.factory,o.limitOrders].some(e=>l(n,e)),"approval spender is not pinned")}function J(n,e,s){let r=I(n,"approval token is invalid");return i(r!==h&&!l(r,L),"approval token cannot be native ETH"),z(I(e,"approval spender is invalid")),i(p(s,"approval amount")<w(256),"approval amount cannot be unlimited"),U(r,q(e),s.toString(),o.chainId)}function oe(n){let e=I(n.token,"permit token is invalid");i(e!==h&&!l(e,L),"permit token cannot be native ETH"),i(p(n.amount,"permit amount",160)>0n&&n.amount<w(160),"permit amount must be exact and positive"),i(Number.isSafeInteger(n.nonce)&&n.nonce>=0&&n.nonce<=Number(w(48)),"permit nonce is invalid"),B(n.now);let s=n.now+j;return{domain:{name:"Permit2",chainId:o.chainId,verifyingContract:o.permit2},types:{PermitDetails:[{name:"token",type:"address"},{name:"amount",type:"uint160"},{name:"expiration",type:"uint48"},{name:"nonce",type:"uint48"}],PermitSingle:[{name:"details",type:"PermitDetails"},{name:"spender",type:"address"},{name:"sigDeadline",type:"uint256"}]},primaryType:"PermitSingle",message:{details:{token:e,amount:n.amount.toString(),expiration:s,nonce:n.nonce},spender:o.router,sigDeadline:s.toString()}}}function re(n,e,s){try{return Q(n,e,s)}catch(r){if(r instanceof P&&r.message.startsWith("FOBO ")&&r.message.includes("Nothing was signed."))throw r;S("transaction could not be decoded and verified")}}function Q(n,e,s){i(N(n),"transaction is invalid"),i(n.chainId===o.chainId||n.chainId==="0x1237","chain must be 4663"),m(n.from,s,"wallet does not match the transaction sender");let r=I(n.to,"contract address is invalid");i(typeof n.data=="string"&&/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(n.data),"selector or calldata is invalid");let d=T(n.value,"value"),u=T(n.gas,"gas");i(u>=21000n&&u<=X,"gas is outside the signing ceiling");let F=n.data.slice(0,10).toLowerCase(),f=(t,a)=>{m(r,t,"contract does not match the approved action"),i(F===a,"selector is not pinned for this contract")},A;switch(e.kind){case"approval":{i(l(r,e.token),"approval token differs from the approved input"),i(F===o.selectors.approve,"selector is not an ERC-20 approval"),i(d===0n,"approval value must be zero");let t=y({abi:_,data:n.data});i(t.functionName==="approve","selector is not an ERC-20 approval"),v(n.data,k({abi:_,functionName:"approve",args:t.args}));let[a]=t.args;return z(a),m(a,e.spender,"approval spender differs from the approved action"),{...J(r,a,e.amount),gasLimit:u.toString()}}case"trade":{f(o.router,o.selectors.execute),B(e.now);let t=H(n.data,[o.hook,h]);i(e.pools.length>0&&t.legs.length===e.pools.length&&t.legs.some(c=>l(c.poolKey.hooks,o.hook))&&t.legs.every((c,b)=>M(c.poolKey,e.pools[b])),"swap pools differ from the approved route");let a={currency0:h,currency1:o.usdg,fee:500,tickSpacing:10,hooks:h};if(i(t.legs.every(c=>l(c.poolKey.hooks,o.hook)||M(c.poolKey,a)),"swap contains an unsupported hookless pool"),m(t.currencyIn,e.currencyIn,"swap input currency differs"),m(t.currencyOut,e.currencyOut,"swap output currency differs"),i(t.amountIn===p(e.amountIn,"swap amount")&&t.amountIn>0n,"swap input amount differs"),i(t.amountOutMinimum>=p(e.minOut,"minimum output")&&e.minOut>0n,"swap minimum output is below the approved minimum"),i(t.deadline>BigInt(e.now)&&t.deadline<=BigInt(e.now+1200+$),"swap deadline must be within 20 minutes"),i(d===(l(e.currencyIn,h)?e.amountIn:0n),"swap ETH value differs from the approved input"),t.permit){let c=e.permit;i(c,"swap encodes an unexpected permit"),m(c.details.token,e.currencyIn,"permit token differs from the trade input"),i(T(c.details.amount,"permit amount",160)===e.amountIn&&e.amountIn<w(160),"permit amount differs from the exact trade input"),m(c.spender,o.router,"permit spender must be the Universal Router");let b=T(c.sigDeadline,"permit deadline");i(Number.isSafeInteger(c.details.expiration)&&c.details.expiration>e.now&&BigInt(c.details.expiration)<=b&&b>=BigInt(e.now+300)&&b<=BigInt(e.now+1800),"permit expiration or signature deadline is outside the signing window");let g=t.permit;i(l(g.token,c.details.token)&&g.amount===e.amountIn&&g.expiration===c.details.expiration&&g.nonce===c.details.nonce&&l(g.spender,c.spender)&&g.sigDeadline===b,"swap permit differs from the locally signed exact permit")}else i(!e.permit,"swap omitted the locally signed permit");A=`FOBO swap: exact input ${t.amountIn}; minimum output ${t.amountOutMinimum}.`;break}case"launch":{f(o.factory,o.selectors.launch),B(e.now);let t=y({abi:C,data:n.data});v(n.data,k({abi:C,...t}));let[a]=t.args;i(a.name===e.name&&a.ticker===e.ticker,"launch name or ticker differs from the approved launch"),m(a.quote,e.pair,"launch pair differs from the approved launch"),i(a.devBuyTokens===p(e.devBuyTokens,"initial buy")&&a.devBuyTokens<=50000000n*10n**18n&&a.devBuyMaxCost===p(e.devBuyMaxCost,"initial buy cost"),"launch initial buy or cost differs"),i(a.vestMonths===e.vestMonths&&[0,1,3,6,12].includes(a.vestMonths)&&(a.vestMonths===0||a.devBuyTokens>0n),"launch lock months differ"),i(a.deadline>BigInt(e.now)&&a.deadline<=BigInt(e.now+900+$),"launch deadline must be within 15 minutes"),i(d===p(e.launchFeeWei,"launch fee")+(l(a.quote,h)?a.devBuyMaxCost:0n),"launch ETH value differs from its fee plus initial buy"),A="Launch the approved FOBO token with its approved initial buy and lock.";break}case"limitOrder":{f(o.limitOrders,o.selectors.place);let t=y({abi:O,data:n.data});i(t.functionName==="place","selector is not place"),v(n.data,k({abi:O,...t}));let[a,c,b,g,W,V,Z]=t.args;i((a===0||a===1)&&a===e.side,"limit order side differs"),m(c,e.token,"limit order token differs"),m(b,e.payToken,"limit order pay token differs"),i(g===p(e.amount,"order amount")&&g>0n&&W===p(e.limitPriceUsdE18,"limit price")&&V===p(e.expiry,"order expiry")&&Z===p(e.maxFeePerFill,"keeper fee"),"limit order amount, price, expiry or keeper fee differs"),i(d===(a===0&&l(b,h)?g:0n),"limit order ETH value differs from its native escrow"),A="Place the approved FOBO limit order; escrow refunds and fills belong to this wallet.";break}case"cancel":{f(o.limitOrders,o.selectors.cancel),i(d===0n,"cancel value must be zero");let t=y({abi:O,data:n.data});i(t.functionName==="cancel","selector is not cancel"),v(n.data,k({abi:O,...t})),i(t.args[0]===p(e.orderId,"order id"),"cancel order differs"),m(t.args[1],s,"cancel recipient must be this wallet"),A="Cancel the approved FOBO order and refund this wallet.";break}case"claim":{if(i(d===0n,"claim value must be zero"),e.claimKind==="creator"){f(o.hook,o.selectors.claimCreator);let t=y({abi:K,data:n.data});v(n.data,k({abi:K,...t})),i(M(t.args[0],e.poolKey)&&l(t.args[0].hooks,o.hook),"creator claim pool differs"),m(t.args[1],s,"creator claim recipient must be this wallet")}else if(e.claimKind==="referral"){f(o.revenue,o.selectors.claimReferral);let t=y({abi:E,data:n.data});v(n.data,k({abi:E,...t})),m(t.args[0],s,"referral claim account must be this wallet"),m(t.args[1],e.currency,"referral claim currency differs"),m(t.args[2],e.recipient??s,"referral claim recipient differs from the approved recipient")}else{i(e.claimKind==="vesting","claim kind is unsupported"),f(o.vesting,o.selectors.claimVesting);let t=y({abi:D,data:n.data});v(n.data,k({abi:D,...t})),i(t.args[0]===p(e.lockId,"vesting lock"),"vesting lock differs"),m(e.beneficiary,s,"vesting beneficiary must be this wallet")}A="Claim the approved FOBO earnings to their approved recipient.";break}default:S("transaction expectation is unsupported")}return{to:r,data:n.data,value:d.toString(),chainId:o.chainId,gasLimit:u.toString(),description:A}}function ae(n,e,s){let r="sign-in message is not a fresh fobo.fun sign-in for this wallet";try{B(s),i(typeof n=="string"&&n.length<=2048&&!/[\r\p{Cc}\p{Cf}]/u.test(n.replaceAll(`
2
+ `,"")),r);let d=n.split(`
3
+ `);i(d[0]==="fobo.fun wants you to sign in with your Ethereum account:"&&d[2]==="",r),m(d[1],e,r);let u=3;d[u]!=="URI: https://fobo.fun"&&d[u]!=="URI: https://fobo.fun/"&&(i(["Sign in to fobo.fun","Sign in to fobo.fun.","Sign in to FOBO.","Sign in to fobo."].includes(d[u]??"")&&d[u+1]==="",r),u+=2),i(["URI: https://fobo.fun","URI: https://fobo.fun/"].includes(d[u]??"")&&d[u+1]==="Version: 1",r),u+=2,d[u]?.startsWith("Chain ID:")&&(i(d[u]==="Chain ID: 4663",r),u++),i(/^Nonce: [a-zA-Z0-9]{8,128}$/.test(d[u]??""),r);let F=d[u+1]?.match(/^Issued At: (\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z)$/)?.[1];i(F&&d.length===u+2,r);let f=Date.parse(F)/1e3;i(Number.isFinite(f)&&f<=s&&f>=s-300,r)}catch{S(r)}}export{X as a,J as b,oe as c,re as d,ae as e};
@@ -1 +1 @@
1
- import{b as I}from"./7VH6JQ2H.js";import{b as M}from"./7U62MMUQ.js";import{a as G}from"./DRLBTB4E.js";import{h as C}from"./2GXHYI23.js";import{b as W}from"./SPJCSEKP.js";import{a as U}from"./43LI5NKJ.js";import{a as P}from"./66F5ZH34.js";import{g as $}from"./NWNYJ26T.js";import{b as R}from"./IX3GZMTM.js";import{b as h,e as y,j as T,k as b}from"./TI727O2H.js";import{a as p}from"./XSD5NL7J.js";import{encodeFunctionData as A,erc20Abi as E,parseAbi as N}from"viem";var f=T[h].vaults.spark.address,i={address:b,chainId:h,symbol:"USDG",decimals:y},m={address:f,chainId:h,symbol:"spUSDG",decimals:6},_=(1n<<256n)-1n,k=N(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","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)"]),t=(s,l)=>({token:{...s},amount:l.toString()});function D(s,l,v=!1){if(!s||typeof s!="object"||Array.isArray(s)||Object.keys(s).some(g=>!l||g!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&s.amount==="max")return"max";if(typeof s.amount!="string")throw new p("Amount must be a positive integer string in base units.");let n=R(s.amount);if(n===0n||n>_)throw new p("Amount must be positive and within the uint256 range.");return n}var F=s=>{async function l(a){try{return await a()}catch(e){throw new p(s.plainError(e))}}async function v(a){U(a);let e=s.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,d,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:E,functionName:"decimals"})]);if(typeof r!="string"||!$(r,b))throw new p("Spark does not report the expected USDG asset on chain 4663.");if(d!==m.decimals||o!==i.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(u,x=[])=>{let c=await e.readContract({address:f,abi:k,functionName:u,args:x});if(typeof c!="bigint"||c<0n||c>_)throw new p(`Spark returned an invalid ${u} value.`);return c}}function n(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${s.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function g(a,e,r,d){let o=await s.preview(a,e),u=o.changes.map(n).join(", ");return{txs:a,amounts:r,preview:o,summary:`${d} Preview values can change before execution. ${o.summary}${u?` Changes: ${u}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[d,o,u]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(m,r)],economics:{principal:d===0n?[]:[C("redeemable",{token:{...i},amount:d.toString(),source:"spark.previewRedeem",heldAs:m.address})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`${n(t(m,r))}; redeem preview ${n(t(i,d))} (rounded down). Current maximum redeem ${n(t(m,o))}; maximum withdrawal ${n(t(i,u))}.`}]}),tools:[I(s),...M(s),...G(s),{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{D(a,!1);let r=await v(e),d=await r("totalAssets"),[o,u,x,c,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),S=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...i},shareToken:{...m},totalAssets:t(i,d),balance:t(m,o),maxDeposit:t(i,u),maxWithdraw:t(i,x),maxRedeem:t(m,c),previewDepositAssets:t(i,1000000n),previewDeposit:t(m,w),previewRedeemShares:t(m,o),previewRedeem:t(i,S),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:P('Amount of USDG in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.')},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=D(a,!0),d=await v(e),[o,u]=await Promise.all([d("maxDeposit",[e]),d("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(u===0n)throw new p("This deposit would return zero Spark shares.");let x=[s.approval(b,f,r.toString(),h),s.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${n(t(i,r))} into Spark for this wallet.`})];return g(x,e,{assets:t(i,r),shares:t(m,u),maxDeposit:t(i,o)},`Approve exactly ${n(t(i,r))} for Spark ${f}, then deposit. Expected ${n(t(m,u))}, rounded down; current maximum deposit ${n(t(i,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:'Amount of USDG in base units (USDG has 6 decimals; "1000000" = 1 USDG), or "max" to redeem all held shares.'}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=D(a,!0,!0),d=await v(e),[o,u,x]=await Promise.all([d("balanceOf",[e]),d("maxWithdraw",[e]),d("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let c,w,S;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");c=await d("previewRedeem",[w]),S=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(c=r,c>u)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await d("previewWithdraw",[c]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");S=A({abi:k,functionName:"withdraw",args:[c,e,e]})}if(c===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let j=r==="max"?`Redeem all ${n(t(m,w))} from Spark to this wallet.`:`Withdraw ${n(t(i,c))} from Spark to this wallet.`,O=[s.unsignedTx({to:f,data:S,value:"0",chainId:h,description:j})];return g(O,e,{assets:t(i,c),shares:t(m,w),maxWithdraw:t(i,u),maxRedeem:t(m,x)},r==="max"?`Redeem all ${n(t(m,w))} for an expected ${n(t(i,c))}, rounded down. Current maximum redeem ${n(t(m,x))}.`:`Withdraw ${n(t(i,c))} using an expected ${n(t(m,w))}, rounded up. Current maximum withdrawal ${n(t(i,u))}.`)})}]}};function te(s){return W("spark",[F(s)])}export{F as a,te as b};
1
+ import{b as M}from"./7U62MMUQ.js";import{a as G}from"./DRLBTB4E.js";import{b as I}from"./7VH6JQ2H.js";import{h as C}from"./2GXHYI23.js";import{b as W}from"./SPJCSEKP.js";import{a as U}from"./43LI5NKJ.js";import{a as P}from"./66F5ZH34.js";import{g as $}from"./NWNYJ26T.js";import{b as R}from"./IX3GZMTM.js";import{b as h,e as y,j as T,k as b}from"./TI727O2H.js";import{a as p}from"./XSD5NL7J.js";import{encodeFunctionData as A,erc20Abi as E,parseAbi as N}from"viem";var f=T[h].vaults.spark.address,i={address:b,chainId:h,symbol:"USDG",decimals:y},m={address:f,chainId:h,symbol:"spUSDG",decimals:6},_=(1n<<256n)-1n,k=N(["function asset() view returns (address)","function decimals() view returns (uint8)","function totalAssets() view returns (uint256)","function balanceOf(address owner) view returns (uint256)","function maxDeposit(address receiver) view returns (uint256)","function maxWithdraw(address owner) view returns (uint256)","function maxRedeem(address owner) view returns (uint256)","function previewDeposit(uint256 assets) view returns (uint256)","function previewWithdraw(uint256 assets) view returns (uint256)","function previewRedeem(uint256 shares) view returns (uint256)","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)"]),t=(s,l)=>({token:{...s},amount:l.toString()});function D(s,l,v=!1){if(!s||typeof s!="object"||Array.isArray(s)||Object.keys(s).some(g=>!l||g!=="amount"))throw new p(l?"Provide only the amount for this Spark action.":"Spark listing takes no arguments.");if(!l)return 0n;if(v&&s.amount==="max")return"max";if(typeof s.amount!="string")throw new p("Amount must be a positive integer string in base units.");let n=R(s.amount);if(n===0n||n>_)throw new p("Amount must be positive and within the uint256 range.");return n}var F=s=>{async function l(a){try{return await a()}catch(e){throw new p(s.plainError(e))}}async function v(a){U(a);let e=s.clientFor(h);if(await e.getChainId()!==h)throw new p("Spark requires an endpoint on chain 4663.");let[r,d,o]=await Promise.all([e.readContract({address:f,abi:k,functionName:"asset"}),e.readContract({address:f,abi:k,functionName:"decimals"}),e.readContract({address:b,abi:E,functionName:"decimals"})]);if(typeof r!="string"||!$(r,b))throw new p("Spark does not report the expected USDG asset on chain 4663.");if(d!==m.decimals||o!==i.decimals)throw new p("Spark shares and USDG must both have 6 decimals.");return async(u,x=[])=>{let c=await e.readContract({address:f,abi:k,functionName:u,args:x});if(typeof c!="bigint"||c<0n||c>_)throw new p(`Spark returned an invalid ${u} value.`);return c}}function n(a){let e=a.amount.startsWith("-"),r=e?a.amount.slice(1):a.amount;return`${e?"-":""}${s.formatAmount(r,a.token.decimals)} ${a.token.symbol}`}async function g(a,e,r,d){let o=await s.preview(a,e),u=o.changes.map(n).join(", ");return{txs:a,amounts:r,preview:o,summary:`${d} Preview values can change before execution. ${o.summary}${u?` Changes: ${u}.`:""}`}}return{positions:a=>l(async()=>{let e=await v(a),r=await e("balanceOf",[a]);if(r===0n)return[];let[d,o,u]=await Promise.all([e("previewRedeem",[r]),e("maxRedeem",[a]),e("maxWithdraw",[a])]);return[{module:"spark",id:`${h}:${f}`,chainId:h,assets:[t(m,r)],economics:{principal:d===0n?[]:[C("redeemable",{token:{...i},amount:d.toString(),source:"spark.previewRedeem",heldAs:m.address})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`${n(t(m,r))}; redeem preview ${n(t(i,d))} (rounded down). Current maximum redeem ${n(t(m,o))}; maximum withdrawal ${n(t(i,u))}.`}]}),tools:[I(s),...M(s),...G(s),{name:"spark_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(a,e)=>l(async()=>{D(a,!1);let r=await v(e),d=await r("totalAssets"),[o,u,x,c,w]=await Promise.all([r("balanceOf",[e]),r("maxDeposit",[e]),r("maxWithdraw",[e]),r("maxRedeem",[e]),r("previewDeposit",[1000000n])]),S=await r("previewRedeem",[o]);return[{chainId:h,address:f,name:"Spark Savings USDG",asset:{...i},shareToken:{...m},totalAssets:t(i,d),balance:t(m,o),maxDeposit:t(i,u),maxWithdraw:t(i,x),maxRedeem:t(m,c),previewDepositAssets:t(i,1000000n),previewDeposit:t(m,w),previewRedeemShares:t(m,o),previewRedeem:t(i,S),rounding:"Deposit shares and redeemed assets round down; exact-asset withdrawals round shares up. Previews can change before execution."}]})},{name:"spark_deposit",inputSchema:{type:"object",properties:{amount:P('Amount of USDG in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.')},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=D(a,!0),d=await v(e),[o,u]=await Promise.all([d("maxDeposit",[e]),d("previewDeposit",[r])]);if(r>o)throw new p("The deposit exceeds Spark\u2019s current maximum deposit.");if(u===0n)throw new p("This deposit would return zero Spark shares.");let x=[s.approval(b,f,r.toString(),h),s.unsignedTx({to:f,data:A({abi:k,functionName:"deposit",args:[r,e]}),value:"0",chainId:h,description:`Deposit ${n(t(i,r))} into Spark for this wallet.`})];return g(x,e,{assets:t(i,r),shares:t(m,u),maxDeposit:t(i,o)},`Approve exactly ${n(t(i,r))} for Spark ${f}, then deposit. Expected ${n(t(m,u))}, rounded down; current maximum deposit ${n(t(i,o))}.`)})},{name:"spark_withdraw",inputSchema:{type:"object",properties:{amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:'Amount of USDG in base units (USDG has 6 decimals; "1000000" = 1 USDG), or "max" to redeem all held shares.'}},required:["amount"],additionalProperties:!1},execute:(a,e)=>l(async()=>{let r=D(a,!0,!0),d=await v(e),[o,u,x]=await Promise.all([d("balanceOf",[e]),d("maxWithdraw",[e]),d("maxRedeem",[e])]);if(o===0n)throw new p("This wallet has no Spark shares to withdraw.");let c,w,S;if(r==="max"){if(w=o,w>x)throw new p("The full share balance exceeds Spark\u2019s current maximum redeem. Request an asset amount within the current maximum withdrawal.");c=await d("previewRedeem",[w]),S=A({abi:k,functionName:"redeem",args:[w,e,e]})}else{if(c=r,c>u)throw new p("The withdrawal exceeds Spark\u2019s current maximum withdrawal.");if(w=await d("previewWithdraw",[c]),w>o)throw new p("This wallet has insufficient Spark shares for the withdrawal.");S=A({abi:k,functionName:"withdraw",args:[c,e,e]})}if(c===0n||w===0n)throw new p("Spark returned a zero asset or share preview for this withdrawal.");let j=r==="max"?`Redeem all ${n(t(m,w))} from Spark to this wallet.`:`Withdraw ${n(t(i,c))} from Spark to this wallet.`,O=[s.unsignedTx({to:f,data:S,value:"0",chainId:h,description:j})];return g(O,e,{assets:t(i,c),shares:t(m,w),maxWithdraw:t(i,u),maxRedeem:t(m,x)},r==="max"?`Redeem all ${n(t(m,w))} for an expected ${n(t(i,c))}, rounded down. Current maximum redeem ${n(t(m,x))}.`:`Withdraw ${n(t(i,c))} using an expected ${n(t(m,w))}, rounded up. Current maximum withdrawal ${n(t(i,u))}.`)})}]}};function te(s){return W("spark",[F(s)])}export{F as a,te as b};
@@ -1 +1 @@
1
- import{c as ee}from"./URBEK2VV.js";import{a as B}from"./Z7FGEWO2.js";import{a as q}from"./IOYRL6AY.js";import{c as J,d as X,j as Y,l as Z}from"./NWNYJ26T.js";import{b as w,j as G}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{a as Q}from"./JXOEJPJ4.js";import{encodeAbiParameters as de,encodeFunctionData as N,erc20Abi as ne,keccak256 as ue,parseAbi as oe,zeroAddress as le}from"viem";var s=oe(["function launchFactory() view returns (address)","function curve() view returns (address)","function factory() view returns (address)","function feeEscrow() view returns (address)","function memeHook() view returns (address)","function buybackVault() view returns (address)","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))","function balanceOf(address) view returns (uint256)","function balanceOfToken(address account,address token) view returns (uint256)","function quoteFeeBalance() view returns (uint256)","function creatorTaxBalance() view returns (uint256)","function pendingFees(bytes32,address) view returns (uint256)","function pendingCreatorTax(bytes32,address) view returns (uint256)","function releasable(address token) view returns (uint256)","function vestedAmount(address token) view returns (uint256)"]),h=oe(["function sweepFees(uint256 minBuybackTokensOut)","function sweepPoolFees(bytes32 poolId,uint256 minConversionQuoteOut,uint256 minBuybackTokensOut)","function claim()","function claimToken(address token)","function release(address token)","error InternalSwapRequiresOperator()"]),ae={address:B,chainId:w,symbol:"ETH",decimals:18},te=G[w].pons;function c(o){let d=Y(o,"Provide a valid Pons coin address.",X);return Z(d,"Provide a nonzero Pons coin or contract address.")}function pe(o){let d=new Set;for(;o&&typeof o=="object"&&!d.has(o)&&d.size<16;){d.add(o);let l=o;if(l.data==="0x31cdb504"||l.data&&typeof l.data=="object"&&l.data.errorName==="InternalSwapRequiresOperator")return!0;o=l.cause}return!1}async function fe(o,d,l,k=!1,t){let i=c(d),b=c(l),e=o.clientFor(w);if(t===void 0&&await e.getChainId()!==w)throw new f(`Pons claims require chain ${w}.`);let n=t??await e.getBlockNumber(),[R,se]=await Promise.all([e.readContract({address:i,abi:s,functionName:"launchFactory",blockNumber:n}),e.readContract({address:i,abi:s,functionName:"curve",blockNumber:n})]),P=c(te.factory.address);if(c(R)!==P)throw new f("The coin must belong to the pinned Pons factory.");let y=c(se),[r,re,ie]=await Promise.all([e.readContract({address:P,abi:s,functionName:"getLaunchedToken",args:[i],blockNumber:n}),e.readContract({address:y,abi:s,functionName:"factory",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"feeEscrow",blockNumber:n})]);if(!r.exists||c(r.token)!==i||c(r.curve)!==y||c(re)!==P)throw new f("The coin does not resolve to a consistent Pons launch.");if(r.phase<0||r.phase>3)throw new f("This Pons launch phase is unsupported.");let H=c(r.creatorFeeRecipient),A=H===b;if(k&&!A)throw new f("Only the current creator fee recipient can claim these fees. Use the recipient wallet or Safe.");let g=r.pairToken.toLowerCase(),S=g===le,m=c(ie),M=async a=>{let[u,p]=await Promise.all([e.readContract({address:a,abi:ne,functionName:"symbol",blockNumber:n}),e.readContract({address:a,abi:ne,functionName:"decimals",blockNumber:n})]);return{address:a,chainId:w,symbol:Q(u),decimals:p}},[v,T,_,j,$]=await Promise.all([M(i),S?ae:M(g),e.readContract({address:m,abi:s,functionName:"balanceOf",args:[b],blockNumber:n}),S?0n:e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,g],blockNumber:n}),e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,i],blockNumber:n})]),x=[],F=[],E,C=(a,u,p)=>o.unsignedTx({to:a,data:u,value:"0",chainId:w,description:p});if(r.phase===0){let[a,u]=await Promise.all([e.readContract({address:y,abi:s,functionName:"quoteFeeBalance",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"creatorTaxBalance",blockNumber:n})]);a+u>0n&&(F.push({token:T,amount:(a+u).toString()}),r.buybackEnabled?E="buyback":A&&(await e.simulateContract({address:y,abi:h,functionName:"sweepFees",args:[0n],account:b,gas:q,blockNumber:n}),x.push(C(y,N({abi:h,functionName:"sweepFees",args:[0n]}),`Sweep ${T.symbol} curve fees into the recipient escrow.`))))}else if(r.phase===2){let a=c(await e.readContract({address:P,abi:s,functionName:"memeHook",blockNumber:n})),u=ee(g,i,r.poolFee,r.tickSpacing),p=ue(de([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[u.currency0,u.currency1,r.poolFee,r.tickSpacing,a])),[V,z,W,U]=await Promise.all([e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,i],blockNumber:n})]);if(V+z>0n&&F.push({token:T,amount:(V+z).toString()}),W+U>0n&&F.push({token:v,amount:(W+U).toString()}),F.length)if(r.buybackEnabled)E="buyback";else if(A)try{await e.simulateContract({address:a,abi:h,functionName:"sweepPoolFees",args:[p,0n,0n],account:b,gas:q,blockNumber:n}),x.push(C(a,N({abi:h,functionName:"sweepPoolFees",args:[p,0n,0n]}),`Sweep ${T.symbol} pool fees into the recipient escrow.`))}catch(K){if(!pe(K))throw K;E="conversion"}else W+U>0n&&(E="conversion")}let I=0n,L=0n,D;if(r.buybackEnabled||$>0n||A){let a=c(await e.readContract({address:P,abi:s,functionName:"buybackVault",blockNumber:n}));if(a===c(te.buybackVault.address)){let[u,p,V]=await Promise.all([e.readContract({address:a,abi:s,functionName:"feeEscrow",blockNumber:n}),e.readContract({address:a,abi:s,functionName:"releasable",args:[i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"vestedAmount",args:[i],blockNumber:n})]);if(c(u)!==m)throw new f("The Pons buyback vault credits a different escrow than this coin.");[D,I,L]=[a,p,V]}else if(k)throw new f("The Pons factory reports a buyback vault outside the pinned deployment.")}let O=[...x];if(k){I>0n&&O.push(C(D,N({abi:h,functionName:"release",args:[i]}),`Release the vested ${v.symbol} buyback into the recipient escrow.`));let a=S&&x.length>0,u=!S&&x.length>0;(_>0n||a)&&O.push(C(m,N({abi:h,functionName:"claim"}),"Claim the caller\u2019s full native ETH escrow balance across all coins.")),(j>0n||u)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[g]}),`Claim the caller\u2019s full ${T.symbol} escrow balance across all coins.`)),($>0n||I>0n)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[i]}),`Claim the caller\u2019s released ${v.symbol} escrow balance.`))}let ce=[{token:ae,amount:_.toString()},...S?[]:[{token:T,amount:j.toString()}],{token:v,amount:$.toString()}];return{coin:v,pair:T,phase:r.phase,recipient:H,holder:b,isRecipient:A,escrow:m,blockNumber:n.toString(),credited:ce,pendingBeforeSweep:F,operatorWait:E,txs:O,buybackVest:{enabled:r.buybackEnabled,vault:D??null,releasable:{token:v,amount:I.toString()},vested:{token:v,amount:L.toString()},note:"Releasable is the gross vested amount; the release splits it with the Pons protocol before crediting the recipient escrow, and the preview shows the net claim."}}}function be(o){return o==="buyback"?"Buyback-enabled fee sweeps are not built here; pending fees await Pons\u2019s operator.":o==="conversion"?"Pending token-side conversion is awaiting Pons\u2019s keeper; the hook sweep was skipped.":""}async function me(o,d,l){if(!d||Object.keys(d).some(R=>R!=="token"))throw new f("Unsupported input. Provide only the Pons coin token address.");let k=c(d.token),t=await fe(o,k,c(l),!0),{txs:i}=t,b=await o.preview(i,l),e=t.credited[t.pair.address===B?0:1],n=[i.length?`Unsigned Pons fee claim prepared for the current recipient. Claims withdraw every ${t.pair.address===B?"native ETH":`native ETH and ${t.pair.symbol}`} balance owed to this wallet on this escrow across its coins.`:"No claim is available from this escrow.",be(t.operatorWait),BigInt(t.buybackVest.releasable.amount)>0n?`The buyback vest has ${t.buybackVest.releasable.amount} ${t.coin.symbol} base units releasable (gross); the release credits the escrow and the claim withdraws it.`:"","Pending amounts are pre-sweep fee and tax totals, not a guaranteed creator payout. Preview excludes gas. No transaction was sent."].filter(Boolean).join(" ");return{txs:i,summary:n,preview:b,claimable:e,credited:t.credited,pendingBeforeSweep:t.pendingBeforeSweep,waitingForKeeper:t.operatorWait!==void 0,operatorWait:t.operatorWait??null,buybackVest:t.buybackVest,recipient:t.recipient,escrow:t.escrow,phase:t.phase,blockNumber:t.blockNumber}}var Ne=o=>({tools:[{name:"pons_claim",inputSchema:{type:"object",additionalProperties:!1,required:["token"],properties:{token:{...J,description:"Pons coin address on chain 4663."}}},execute:async(d,l)=>{try{return await me(o,d,l)}catch(k){throw new f(o.plainError(k))}}}]});export{fe as a,be as b,Ne as c};
1
+ import{c as ee}from"./GK3D7OKG.js";import{a as B}from"./Z7FGEWO2.js";import{a as q}from"./IOYRL6AY.js";import{c as J,d as X,j as Y,l as Z}from"./NWNYJ26T.js";import{b as w,j as G}from"./TI727O2H.js";import{a as f}from"./XSD5NL7J.js";import{a as Q}from"./JXOEJPJ4.js";import{encodeAbiParameters as de,encodeFunctionData as N,erc20Abi as ne,keccak256 as ue,parseAbi as oe,zeroAddress as le}from"viem";var s=oe(["function launchFactory() view returns (address)","function curve() view returns (address)","function factory() view returns (address)","function feeEscrow() view returns (address)","function memeHook() view returns (address)","function buybackVault() view returns (address)","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))","function balanceOf(address) view returns (uint256)","function balanceOfToken(address account,address token) view returns (uint256)","function quoteFeeBalance() view returns (uint256)","function creatorTaxBalance() view returns (uint256)","function pendingFees(bytes32,address) view returns (uint256)","function pendingCreatorTax(bytes32,address) view returns (uint256)","function releasable(address token) view returns (uint256)","function vestedAmount(address token) view returns (uint256)"]),h=oe(["function sweepFees(uint256 minBuybackTokensOut)","function sweepPoolFees(bytes32 poolId,uint256 minConversionQuoteOut,uint256 minBuybackTokensOut)","function claim()","function claimToken(address token)","function release(address token)","error InternalSwapRequiresOperator()"]),ae={address:B,chainId:w,symbol:"ETH",decimals:18},te=G[w].pons;function c(o){let d=Y(o,"Provide a valid Pons coin address.",X);return Z(d,"Provide a nonzero Pons coin or contract address.")}function pe(o){let d=new Set;for(;o&&typeof o=="object"&&!d.has(o)&&d.size<16;){d.add(o);let l=o;if(l.data==="0x31cdb504"||l.data&&typeof l.data=="object"&&l.data.errorName==="InternalSwapRequiresOperator")return!0;o=l.cause}return!1}async function fe(o,d,l,k=!1,t){let i=c(d),b=c(l),e=o.clientFor(w);if(t===void 0&&await e.getChainId()!==w)throw new f(`Pons claims require chain ${w}.`);let n=t??await e.getBlockNumber(),[R,se]=await Promise.all([e.readContract({address:i,abi:s,functionName:"launchFactory",blockNumber:n}),e.readContract({address:i,abi:s,functionName:"curve",blockNumber:n})]),P=c(te.factory.address);if(c(R)!==P)throw new f("The coin must belong to the pinned Pons factory.");let y=c(se),[r,re,ie]=await Promise.all([e.readContract({address:P,abi:s,functionName:"getLaunchedToken",args:[i],blockNumber:n}),e.readContract({address:y,abi:s,functionName:"factory",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"feeEscrow",blockNumber:n})]);if(!r.exists||c(r.token)!==i||c(r.curve)!==y||c(re)!==P)throw new f("The coin does not resolve to a consistent Pons launch.");if(r.phase<0||r.phase>3)throw new f("This Pons launch phase is unsupported.");let H=c(r.creatorFeeRecipient),A=H===b;if(k&&!A)throw new f("Only the current creator fee recipient can claim these fees. Use the recipient wallet or Safe.");let g=r.pairToken.toLowerCase(),S=g===le,m=c(ie),M=async a=>{let[u,p]=await Promise.all([e.readContract({address:a,abi:ne,functionName:"symbol",blockNumber:n}),e.readContract({address:a,abi:ne,functionName:"decimals",blockNumber:n})]);return{address:a,chainId:w,symbol:Q(u),decimals:p}},[v,T,_,j,$]=await Promise.all([M(i),S?ae:M(g),e.readContract({address:m,abi:s,functionName:"balanceOf",args:[b],blockNumber:n}),S?0n:e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,g],blockNumber:n}),e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,i],blockNumber:n})]),x=[],F=[],E,C=(a,u,p)=>o.unsignedTx({to:a,data:u,value:"0",chainId:w,description:p});if(r.phase===0){let[a,u]=await Promise.all([e.readContract({address:y,abi:s,functionName:"quoteFeeBalance",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"creatorTaxBalance",blockNumber:n})]);a+u>0n&&(F.push({token:T,amount:(a+u).toString()}),r.buybackEnabled?E="buyback":A&&(await e.simulateContract({address:y,abi:h,functionName:"sweepFees",args:[0n],account:b,gas:q,blockNumber:n}),x.push(C(y,N({abi:h,functionName:"sweepFees",args:[0n]}),`Sweep ${T.symbol} curve fees into the recipient escrow.`))))}else if(r.phase===2){let a=c(await e.readContract({address:P,abi:s,functionName:"memeHook",blockNumber:n})),u=ee(g,i,r.poolFee,r.tickSpacing),p=ue(de([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[u.currency0,u.currency1,r.poolFee,r.tickSpacing,a])),[V,z,W,U]=await Promise.all([e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,i],blockNumber:n})]);if(V+z>0n&&F.push({token:T,amount:(V+z).toString()}),W+U>0n&&F.push({token:v,amount:(W+U).toString()}),F.length)if(r.buybackEnabled)E="buyback";else if(A)try{await e.simulateContract({address:a,abi:h,functionName:"sweepPoolFees",args:[p,0n,0n],account:b,gas:q,blockNumber:n}),x.push(C(a,N({abi:h,functionName:"sweepPoolFees",args:[p,0n,0n]}),`Sweep ${T.symbol} pool fees into the recipient escrow.`))}catch(K){if(!pe(K))throw K;E="conversion"}else W+U>0n&&(E="conversion")}let I=0n,L=0n,D;if(r.buybackEnabled||$>0n||A){let a=c(await e.readContract({address:P,abi:s,functionName:"buybackVault",blockNumber:n}));if(a===c(te.buybackVault.address)){let[u,p,V]=await Promise.all([e.readContract({address:a,abi:s,functionName:"feeEscrow",blockNumber:n}),e.readContract({address:a,abi:s,functionName:"releasable",args:[i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"vestedAmount",args:[i],blockNumber:n})]);if(c(u)!==m)throw new f("The Pons buyback vault credits a different escrow than this coin.");[D,I,L]=[a,p,V]}else if(k)throw new f("The Pons factory reports a buyback vault outside the pinned deployment.")}let O=[...x];if(k){I>0n&&O.push(C(D,N({abi:h,functionName:"release",args:[i]}),`Release the vested ${v.symbol} buyback into the recipient escrow.`));let a=S&&x.length>0,u=!S&&x.length>0;(_>0n||a)&&O.push(C(m,N({abi:h,functionName:"claim"}),"Claim the caller\u2019s full native ETH escrow balance across all coins.")),(j>0n||u)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[g]}),`Claim the caller\u2019s full ${T.symbol} escrow balance across all coins.`)),($>0n||I>0n)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[i]}),`Claim the caller\u2019s released ${v.symbol} escrow balance.`))}let ce=[{token:ae,amount:_.toString()},...S?[]:[{token:T,amount:j.toString()}],{token:v,amount:$.toString()}];return{coin:v,pair:T,phase:r.phase,recipient:H,holder:b,isRecipient:A,escrow:m,blockNumber:n.toString(),credited:ce,pendingBeforeSweep:F,operatorWait:E,txs:O,buybackVest:{enabled:r.buybackEnabled,vault:D??null,releasable:{token:v,amount:I.toString()},vested:{token:v,amount:L.toString()},note:"Releasable is the gross vested amount; the release splits it with the Pons protocol before crediting the recipient escrow, and the preview shows the net claim."}}}function be(o){return o==="buyback"?"Buyback-enabled fee sweeps are not built here; pending fees await Pons\u2019s operator.":o==="conversion"?"Pending token-side conversion is awaiting Pons\u2019s keeper; the hook sweep was skipped.":""}async function me(o,d,l){if(!d||Object.keys(d).some(R=>R!=="token"))throw new f("Unsupported input. Provide only the Pons coin token address.");let k=c(d.token),t=await fe(o,k,c(l),!0),{txs:i}=t,b=await o.preview(i,l),e=t.credited[t.pair.address===B?0:1],n=[i.length?`Unsigned Pons fee claim prepared for the current recipient. Claims withdraw every ${t.pair.address===B?"native ETH":`native ETH and ${t.pair.symbol}`} balance owed to this wallet on this escrow across its coins.`:"No claim is available from this escrow.",be(t.operatorWait),BigInt(t.buybackVest.releasable.amount)>0n?`The buyback vest has ${t.buybackVest.releasable.amount} ${t.coin.symbol} base units releasable (gross); the release credits the escrow and the claim withdraws it.`:"","Pending amounts are pre-sweep fee and tax totals, not a guaranteed creator payout. Preview excludes gas. No transaction was sent."].filter(Boolean).join(" ");return{txs:i,summary:n,preview:b,claimable:e,credited:t.credited,pendingBeforeSweep:t.pendingBeforeSweep,waitingForKeeper:t.operatorWait!==void 0,operatorWait:t.operatorWait??null,buybackVest:t.buybackVest,recipient:t.recipient,escrow:t.escrow,phase:t.phase,blockNumber:t.blockNumber}}var Ne=o=>({tools:[{name:"pons_claim",inputSchema:{type:"object",additionalProperties:!1,required:["token"],properties:{token:{...J,description:"Pons coin address on chain 4663."}}},execute:async(d,l)=>{try{return await me(o,d,l)}catch(k){throw new f(o.plainError(k))}}}]});export{fe as a,be as b,Ne as c};
@@ -1 +1 @@
1
- import{a as ie,b as le,c as de,d as Z}from"./VST6LFUB.js";import{a as D,b as Y}from"./KH4QFN72.js";import{c as ae}from"./SCG5HWMN.js";import{a as X}from"./66F5ZH34.js";import{b as C,c as P,d as re,e as h,g,i as oe}from"./NWNYJ26T.js";import{b as v,j as ne,m as F,o as se}from"./TI727O2H.js";import{a as T}from"./XSD5NL7J.js";import{a as I}from"./JXOEJPJ4.js";import{erc20Abi as E,getAddress as f,parseAbi as L,zeroAddress as ee}from"viem";var x="https://ponsfamily.com/api",ce="https://balancesapi.ponsfamily.com/v1",Q=L(["function sellableTokens() view returns (uint256)","function reservedTokens() view returns (uint256)","function readyToGraduate() view returns (bool)","function graduated() view returns (bool)","function currentSnipeTaxBps(address) view returns (uint256)"]),be=L(["event CurveBuy(address indexed buyer, address indexed recipient, uint256 quoteIn, uint256 tokensOut, uint256 fee, uint256 tax)","event CurveSell(address indexed seller, address indexed recipient, uint256 tokensIn, uint256 quoteOut, uint256 fee, uint256 tax)"]),ye=L(["function pendingCreatorFeeRecipient(address) view returns (address,uint256,uint256)"]),he=L(["function getTokenInfo() view returns (address,string,string,(string,string,string,string,string))"]),ue=L(["function totalLocked(address) view returns (uint256)","function totalReleased(address) view returns (uint256)","function vestedAmount(address) view returns (uint256)","function releasable(address) view returns (uint256)","function vestingStart(address) view returns (uint256)","function VESTING_DURATION() view returns (uint256)"]),ge=10000n,pe=2000n,ke=/^[0-9]{1,78}$/,p=e=>typeof e=="number"&&Number.isFinite(e)?e:null,$=(e,t=80)=>typeof e=="string"?I(e.slice(0,t)):null;function N(e,t="address"){return oe(e,`Provide a ${t}.`,re)}function j(e,t,o){let s=e??t;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>o)throw new T(`Choose a limit from 1 to ${o}.`);return s}function O(e,t=0,o=3){return e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="string"?I(e.slice(0,80)):t>=o?null:Array.isArray(e)?{total:e.length,items:e.slice(0,10).map(s=>O(s,t+1,o))}:h(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,d])=>[s,O(d,t+1,o)])):null}async function U(e,t,o){return ae(e.http,t,{method:"GET",redirect:"error",headers:{accept:"application/json"}},o)}async function W(e,t,o){let s=e.clientFor(v),[d,a]=await Promise.all([s.readContract({address:t,abi:E,functionName:"symbol",blockNumber:o}),s.readContract({address:t,abi:E,functionName:"decimals",blockNumber:o})]);return{address:t,chainId:v,symbol:I(d),decimals:a}}async function we(e,t){let o=N(t.token,"Pons launch token address"),s=t.holder===void 0?void 0:N(t.holder,"holder address"),d=j(t.limit,20,50),{offset:a,fingerprint:l}=de(t.cursor),r=e.clientFor(v),m=await r.getBlockNumber({cacheTime:0}),k=await D(e,o,m),i=await le(e,o),n=await r.getBlockNumber({cacheTime:0});if(l&&l!==i.fingerprint)throw new T("The Pons holder index changed. Retry pons_holders without a cursor.");let u=i.body,w=[{wallet:ee,reason:"burn (zero address)"},{wallet:f("0x000000000000000000000000000000000000dead"),reason:"burn (dead address)"},{wallet:f(k.curve),reason:"Pons bonding curve"},{wallet:f(se),reason:"Uniswap v4 pool manager (shared pool custody)"}],_=new Map(w.map(c=>[c.wallet,c.reason])),R=i.rows.filter(c=>!_.has(f(c.wallet))),[G,q]=await Promise.all([W(e,o,n),r.readContract({address:o,abi:E,functionName:"totalSupply",blockNumber:n})]),J=c=>1+R.filter(b=>BigInt(b.balance)>BigInt(c)).length,B=async(c,b)=>{let M=await r.readContract({address:o,abi:E,functionName:"balanceOf",args:[c],blockNumber:n});return{wallet:c,indexedBalance:b,indexedRank:b===null||_.has(c)?null:J(b),indexedShareOfSupply:b===null?null:Z(b,u.supply),shareOfSupply:Z(M.toString(),q.toString()),balance:{token:G,amount:M.toString()},matchesIndex:b===null?null:M.toString()===b}},A=await Promise.all(R.slice(a,a+d).map(async c=>({...await B(f(c.wallet),c.balance),share:p(c.share),label:$(c.label,40)}))),V=s?i.rows.find(c=>g(c.wallet,s)):void 0,H=s?{...await B(s,V?.balance??null),excluded:_.get(s)??null,rankStatus:_.has(s)?"excluded":V?"ranked by indexed balance":"absent from index; rank unknown"}:void 0;return{token:G,statusBlock:n.toString(),totalSupply:q.toString(),holderCount:R.length,indexHolderCount:u.holders,indexSupply:u.supply,burned:u.burned,circulating:u.circulating,page:A,nextCursor:a+d<R.length?`holders_${a+d}_${i.fingerprint}`:null,...H?{wallet:H}:{},exclusions:w.map(c=>({...c,indexedBalance:i.rows.find(b=>g(b.wallet,c.wallet))?.balance??"0",countedInIndex:i.rows.some(b=>g(b.wallet,c.wallet))})),indexAsOf:{rollupBucket:u.as_of.rollup_bucket,tailFromBlock:u.as_of.tail_from_block},indexFetchedAt:i.fetchedAt,source:`${ie}/tokens/{token}/holders`,sources:{holderCount:"Pons balances index, excluding the labelled system addresses",rank:"Pons balances index, descending balance; equal balances share a rank, system addresses excluded",indexedShareOfSupply:"Pons indexed balance / indexed total supply",balance:`on-chain balanceOf at block ${n}`,totalSupply:`on-chain totalSupply at block ${n}`,shareOfSupply:`on-chain balanceOf / totalSupply at block ${n}`,burned:"Pons balances index",circulating:"Pons balances index"},note:"Counts, ranking, burned and circulating supply come from Pons\u2019s balances index, not on-chain truth. The API does not pin pages to a block; its rollup/tail markers are not an exact snapshot block. Each listed balance was re-read on chain at statusBlock. matchesIndex false indicates disagreement, not proof of which source is wrong. A wallet absent from the index has unknown rank even if its on-chain balance is positive. Labels are untrusted."}}var ve=e=>h(e)&&Array.isArray(e.items)&&e.items.length<=500&&e.items.every(t=>h(t)&&typeof t.token=="string"&&C.test(t.token)&&typeof t.amountTokens=="number");async function xe(e,t,o){let s=N(t.holder??o,"holder address"),d=j(t.limit,20,40),a=e.clientFor(v),l=await U(e,`${x}/profile/${s.toLowerCase()}?view=positions`,ve),r=await a.getBlockNumber({cacheTime:0}),m=[...new Map(l.items.filter(n=>n.amountTokens>0||n.state==="open").map(n=>[n.token.toLowerCase(),n])).values()],k=await Promise.all(m.slice(0,d).map(async n=>{let u=f(n.token);try{await D(e,u,r);let[w,_]=await Promise.all([W(e,u,r),a.readContract({address:u,abi:E,functionName:"balanceOf",args:[s],blockNumber:r})]);return{ok:!0,token:u,meta:w,balance:_,item:n}}catch{return{ok:!1}}})),i=k.filter(n=>n.ok);return{holder:s,statusBlock:r.toString(),source:`${x}/profile/{holder}?view=positions`,holdings:i.map(n=>({token:n.meta,balance:{token:n.meta,amount:n.balance.toString()},index:{state:$(n.item.state,20),valueUsd:p(n.item.valueUsd),investedUsd:p(n.item.investedUsd),totalPnlUsd:p(n.item.totalPnlUsd),totalPnlPct:p(n.item.totalPnlPct),buys:p(n.item.buys),sells:p(n.item.sells),lastTradeAt:p(n.item.lastTradeAt)}})),excludedUnverified:k.length-i.length,truncated:m.length>d,note:"Discovery through Pons\u2019s positions index; every launch was re-read from the pinned factory and every balance is an on-chain read. USD value and profit and loss are index estimates, not execution quotes. Sell the on-chain balance with pons_sell."}}var Ae=e=>h(e)&&Array.isArray(e.items)&&e.items.length<=100&&e.items.every(t=>h(t)&&h(t.launch)&&typeof t.launch.address=="string"&&C.test(t.launch.address)&&typeof t.launch.factory=="string"&&C.test(t.launch.factory));async function Se(e,t){let o=j(t.limit,10,20),s=await U(e,`${x}/launches/trending`,Ae),d=s.items.filter(r=>g(r.launch.factory,F)).slice(0,o),a=await e.clientFor(v).getBlockNumber({cacheTime:0});return{items:await Promise.all(d.map(async r=>({status:await Y(e,f(r.launch.address),a),index:{volumeUsd:p(r.volumeUsd),trades:p(r.trades),traders:p(r.traders),change:p(r.change)}}))),statusBlock:a.toString(),source:`${x}/launches/trending`,excludedOtherFactories:s.items.length-s.items.filter(r=>g(r.launch.factory,F)).length,note:"Ranking is Pons\u2019s own trending list (discovery only); each launch was re-read on chain from the pinned factory."}}var z={overview:"analytics",burn:"analytics/burn",buyback:"analytics/buyback"};async function Te(e,t){let o=t.view??"overview";if(typeof o!="string"||!Object.hasOwn(z,o))throw new T("Choose view overview, burn or buyback.");let s=await U(e,`${x}/${z[o]}`,h);if(o==="overview"){let d=Array.isArray(s.series)?s.series:[];return{view:o,source:`${x}/analytics`,generatedAt:p(s.generatedAt),latestDay:p(s.latestDay),latest:O(d.at(-1)),seriesDays:d.length,today:O(s.today),earnings:O(s.earnings),indexer:O(s.indexer),note:"Protocol-wide figures from Pons\u2019s analytics index; unaudited aggregates, not a quote."}}return{view:o,source:`${x}/${z[o]}`,data:O(s,0,o==="buyback"?4:3),note:"Protocol-wide figures from Pons\u2019s analytics index; unaudited aggregates, not a quote."}}var Ce=e=>h(e)&&typeof e.wallet=="string"&&Array.isArray(e.items)&&e.items.length<=100&&e.items.every(t=>h(t)&&typeof t.kind=="string")&&(e.next===null||e.next===void 0||typeof e.next=="string");async function Pe(e,t,o){let s=N(t.wallet??o,"wallet address"),d=`${ce}/wallets/${s.toLowerCase()}/activity`;if(t.cursor!==void 0){if(typeof t.cursor!="string"||!/^[0-9]{1,12}-[0-9]{1,6}$/.test(t.cursor))throw new T("Use the nextCursor returned by the previous pons_activity page.");d+=`/before/${t.cursor}`}let a=await U(e,d,Ce),l=typeof a.next=="string"?/\/before\/([0-9]{1,12}-[0-9]{1,6})$/.exec(a.next):null;return{wallet:s,source:`${ce}/wallets/{wallet}/activity`,nextCursor:l?.[1]??null,items:a.items.map(r=>({kind:$(r.kind,24),block:p(r.block),time:p(r.time),tx:typeof r.tx=="string"&&/^0x[0-9a-fA-F]{64}$/.test(r.tx)?r.tx:null,token:typeof r.token=="string"&&C.test(r.token)?f(r.token):null,symbol:$(r.symbol,24),amount:typeof r.amount=="string"&&ke.test(r.amount)?r.amount:null,decimals:p(r.decimals),usd:p(r.usd),counterparty:typeof r.counterparty=="string"&&C.test(r.counterparty)?f(r.counterparty):null,counterpartyLabel:$(r.counterparty_label,40)})),note:"Wallet history from Pons\u2019s balances index (discovery and bookkeeping, not proof); USD figures are index estimates. Verify a transaction by hash before relying on it."}}async function Ne(e,t,o){let s=N(t.address??o,"wallet address"),d=j(t.limit,10,20),a=await U(e,`${x}/profile/${s.toLowerCase()}?view=card`,h),l=h(a.identity)?a.identity:{},r=await U(e,`${x}/launches?deployer=${s.toLowerCase()}&limit=${d}`,i=>h(i)&&Array.isArray(i.items)&&i.items.length<=100&&i.items.every(n=>h(n)&&typeof n.address=="string"&&C.test(n.address)&&typeof n.factory=="string"&&C.test(n.factory)&&typeof n.deployer=="string"&&C.test(n.deployer))),m=await e.clientFor(v).getBlockNumber({cacheTime:0}),k=r.items.filter(i=>g(i.factory,F)&&g(i.deployer,s)).slice(0,d);return{address:s,hidden:a.hidden===!0,source:`${x}/profile/{address}?view=card`,identity:{username:$(l.username,40),displayName:$(l.displayName,60),description:$(l.description,200),joinedAt:p(l.joinedAt)},launches:await Promise.all(k.map(i=>Y(e,f(i.address),m))),statusBlock:m.toString(),note:"Profile text is user-supplied and untrusted. Created launches come from Pons\u2019s index and were re-read on chain from the pinned factory."}}async function _e(e,t,o){let s=N(t.token,"Pons launch token address"),d=N(t.holder??o,"holder address"),a=e.clientFor(v),l=await a.getBlockNumber({cacheTime:0}),r=await D(e,s,l),m=ne[v].pons.buybackVault.address,k=[],i=async(y,K)=>{try{return await K()}catch{return k.push(y),null}},n=y=>i(y,()=>a.readContract({address:r.curve,abi:Q,functionName:y,blockNumber:l})),u=y=>i(y,()=>a.readContract({address:r.curve,abi:Q,functionName:y,blockNumber:l})),w=y=>i(y,()=>a.readContract({address:m,abi:ue,functionName:y,args:[s],blockNumber:l})),[_,R,G,q,J,B,A,V,H,c,b,M,me,fe]=await Promise.all([n("sellableTokens"),n("reservedTokens"),u("readyToGraduate"),u("graduated"),i("currentSnipeTaxBps",()=>a.readContract({address:r.curve,abi:Q,functionName:"currentSnipeTaxBps",args:[d],blockNumber:l})),i("getTokenInfo",()=>a.readContract({address:s,abi:he,functionName:"getTokenInfo",blockNumber:l})),i("pendingCreatorFeeRecipient",()=>a.readContract({address:F,abi:ye,functionName:"pendingCreatorFeeRecipient",args:[s],blockNumber:l})),w("totalLocked"),w("totalReleased"),w("vestedAmount"),w("releasable"),w("vestingStart"),i("VESTING_DURATION",()=>a.readContract({address:m,abi:ue,functionName:"VESTING_DURATION",blockNumber:l})),W(e,s,l)]),S=y=>y===null?null:y.toString(),te=A&&!g(A[0],ee)&&A[1]>0n?{proposedRecipient:f(A[0]),effectiveAt:A[1].toString(),expiresAt:A[2].toString(),note:"A protocol-proposed creator fee recipient change. Holders may react before it takes effect; anyone can execute it after the timelock, within the window."}:A?null:void 0;return{token:fe,phase:r.phase,statusBlock:l.toString(),curve:r.curve,creatorFeeRecipient:r.creatorFeeRecipient,curveCapacity:{sellableTokens:S(_),reservedTokens:S(R),readyToGraduate:G,graduated:q},snipeTaxBps:{recipient:d,current:S(J),note:"Keyed to the wallet that receives the tokens; buys only, large in the opening seconds."},creatorMetadata:B?{deployer:f(B[0]),logo:I(B[1].slice(0,300)),description:I(B[2].slice(0,500)),socials:Object.fromEntries(["twitter","telegram","discord","website","farcaster"].map((y,K)=>[y,I(B[3][K].slice(0,300))]))}:null,pendingTakeover:te===void 0?"unavailable":te,buybackVest:{vault:m,enabled:r.buybackEnabled,locked:S(V),released:S(H),vested:S(c),releasable:S(b),vestingStart:S(M),vestingDurationSeconds:S(me),note:"Amounts are launch-token base units; releasing is for the vest beneficiaries only (see pons_claim)."},unavailable:k}}async function Be(e,t){let o=N(t.token,"Pons launch token address"),s=j(t.limit,25,100),d=e.clientFor(v),a=await d.getBlockNumber({cacheTime:0}),l=await D(e,o,a),r=t.toBlock===void 0?a:BigInt(String(t.toBlock)),m=t.fromBlock===void 0?r>=pe?r-pe+1n:0n:BigInt(String(t.fromBlock));if(m<0n||m>r||r>a||r-m+1n>ge)throw new T("Choose an ordered range of at most 10000 mined blocks.");let i=(await d.getLogs({address:l.curve,events:be,fromBlock:m,toBlock:r,strict:!0})).filter(n=>g(n.address,l.curve)&&!n.removed&&n.blockNumber!==null).sort((n,u)=>n.blockNumber===u.blockNumber?(u.logIndex??0)-(n.logIndex??0):n.blockNumber>u.blockNumber?-1:1);return{token:await W(e,o,a),curve:l.curve,fromBlock:m.toString(),toBlock:r.toString(),statusBlock:a.toString(),truncated:i.length>s,total:i.length,trades:i.slice(0,s).map(n=>n.eventName==="CurveBuy"?{side:"buy",block:n.blockNumber.toString(),tx:n.transactionHash,trader:f(n.args.buyer),recipient:f(n.args.recipient),pairIn:n.args.quoteIn.toString(),tokensOut:n.args.tokensOut.toString(),fee:n.args.fee.toString(),creatorTax:n.args.tax.toString()}:{side:"sell",block:n.blockNumber.toString(),tx:n.transactionHash,trader:f(n.args.seller),recipient:f(n.args.recipient),tokensIn:n.args.tokensIn.toString(),pairOut:n.args.quoteOut.toString(),fee:n.args.fee.toString(),creatorTax:n.args.tax.toString()}),coverage:"Curve-phase trades in the requested block window only. Graduated-pool swaps are Uniswap v4 events and are not listed here; pons_activity and pons_status cover a wallet and the pool price."}}var Le=e=>{function t(o,s,d){return{name:o,inputSchema:{type:"object",properties:s,required:["pons_holders","pons_launch_info","pons_trades"].includes(o)?["token"]:[],additionalProperties:!1},execute:async(a,l)=>{try{if(!N(l)||g(l,ee))throw new T("Provide a wallet address.");for(let r of Object.keys(a))if(!(r in s))throw new T(`Unknown ${o} input: ${r}.`);return await d(a,l)}catch(r){throw new T(e.plainError(r))}}}}return{tools:[t("pons_holders",{token:{...P,description:"Address of the token to inspect or use."},holder:{...P,description:"Optional wallet for an on-chain balance and indexed rank after system exclusions."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:50},cursor:{type:"string",maxLength:128,description:"Filtered-directory nextCursor from pons_holders; restart if the index changes."}},o=>we(e,o)),t("pons_holdings",{holder:{...P,description:"Holder address to inspect; defaults to the signing wallet."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:40}},(o,s)=>xe(e,o,s)),t("pons_trending",{limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:20}},o=>Se(e,o)),t("pons_analytics",{view:{description:'Choose "overview" for totals, "burn" for burns or "buyback" for buybacks; defaults to overview.',type:"string",enum:Object.keys(z)}},o=>Te(e,o)),t("pons_activity",{wallet:{...P,description:"Wallet address to inspect; defaults to the signing wallet."},cursor:{description:"Pagination cursor returned by the previous call to this tool.",type:"string",maxLength:32}},(o,s)=>Pe(e,o,s)),t("pons_launch_info",{token:{...P,description:"Address of the token to inspect or use."},holder:{...P,description:"Holder address to inspect; defaults to the signing wallet."}},(o,s)=>_e(e,o,s)),t("pons_trades",{token:{...P,description:"Address of the token to inspect or use."},fromBlock:X("First block number of the scan, as a decimal string; inclusive."),toBlock:X("Last block number of the scan, as a decimal string; inclusive."),limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:100}},o=>Be(e,o)),t("pons_profile",{address:{...P,description:"Wallet profile address to inspect; defaults to the signing wallet."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:20}},(o,s)=>Ne(e,o,s))]}};export{O as a,xe as b,Le as c};
1
+ import{a as ie,b as le,c as de,d as Z}from"./VST6LFUB.js";import{a as D,b as Y}from"./3PHJUFU2.js";import{c as ae}from"./SCG5HWMN.js";import{a as X}from"./66F5ZH34.js";import{b as C,c as P,d as re,e as h,g,i as oe}from"./NWNYJ26T.js";import{b as v,j as ne,m as F,o as se}from"./TI727O2H.js";import{a as T}from"./XSD5NL7J.js";import{a as I}from"./JXOEJPJ4.js";import{erc20Abi as E,getAddress as f,parseAbi as L,zeroAddress as ee}from"viem";var x="https://ponsfamily.com/api",ce="https://balancesapi.ponsfamily.com/v1",Q=L(["function sellableTokens() view returns (uint256)","function reservedTokens() view returns (uint256)","function readyToGraduate() view returns (bool)","function graduated() view returns (bool)","function currentSnipeTaxBps(address) view returns (uint256)"]),be=L(["event CurveBuy(address indexed buyer, address indexed recipient, uint256 quoteIn, uint256 tokensOut, uint256 fee, uint256 tax)","event CurveSell(address indexed seller, address indexed recipient, uint256 tokensIn, uint256 quoteOut, uint256 fee, uint256 tax)"]),ye=L(["function pendingCreatorFeeRecipient(address) view returns (address,uint256,uint256)"]),he=L(["function getTokenInfo() view returns (address,string,string,(string,string,string,string,string))"]),ue=L(["function totalLocked(address) view returns (uint256)","function totalReleased(address) view returns (uint256)","function vestedAmount(address) view returns (uint256)","function releasable(address) view returns (uint256)","function vestingStart(address) view returns (uint256)","function VESTING_DURATION() view returns (uint256)"]),ge=10000n,pe=2000n,ke=/^[0-9]{1,78}$/,p=e=>typeof e=="number"&&Number.isFinite(e)?e:null,$=(e,t=80)=>typeof e=="string"?I(e.slice(0,t)):null;function N(e,t="address"){return oe(e,`Provide a ${t}.`,re)}function j(e,t,o){let s=e??t;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>o)throw new T(`Choose a limit from 1 to ${o}.`);return s}function O(e,t=0,o=3){return e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:typeof e=="string"?I(e.slice(0,80)):t>=o?null:Array.isArray(e)?{total:e.length,items:e.slice(0,10).map(s=>O(s,t+1,o))}:h(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,d])=>[s,O(d,t+1,o)])):null}async function U(e,t,o){return ae(e.http,t,{method:"GET",redirect:"error",headers:{accept:"application/json"}},o)}async function W(e,t,o){let s=e.clientFor(v),[d,a]=await Promise.all([s.readContract({address:t,abi:E,functionName:"symbol",blockNumber:o}),s.readContract({address:t,abi:E,functionName:"decimals",blockNumber:o})]);return{address:t,chainId:v,symbol:I(d),decimals:a}}async function we(e,t){let o=N(t.token,"Pons launch token address"),s=t.holder===void 0?void 0:N(t.holder,"holder address"),d=j(t.limit,20,50),{offset:a,fingerprint:l}=de(t.cursor),r=e.clientFor(v),m=await r.getBlockNumber({cacheTime:0}),k=await D(e,o,m),i=await le(e,o),n=await r.getBlockNumber({cacheTime:0});if(l&&l!==i.fingerprint)throw new T("The Pons holder index changed. Retry pons_holders without a cursor.");let u=i.body,w=[{wallet:ee,reason:"burn (zero address)"},{wallet:f("0x000000000000000000000000000000000000dead"),reason:"burn (dead address)"},{wallet:f(k.curve),reason:"Pons bonding curve"},{wallet:f(se),reason:"Uniswap v4 pool manager (shared pool custody)"}],_=new Map(w.map(c=>[c.wallet,c.reason])),R=i.rows.filter(c=>!_.has(f(c.wallet))),[G,q]=await Promise.all([W(e,o,n),r.readContract({address:o,abi:E,functionName:"totalSupply",blockNumber:n})]),J=c=>1+R.filter(b=>BigInt(b.balance)>BigInt(c)).length,B=async(c,b)=>{let M=await r.readContract({address:o,abi:E,functionName:"balanceOf",args:[c],blockNumber:n});return{wallet:c,indexedBalance:b,indexedRank:b===null||_.has(c)?null:J(b),indexedShareOfSupply:b===null?null:Z(b,u.supply),shareOfSupply:Z(M.toString(),q.toString()),balance:{token:G,amount:M.toString()},matchesIndex:b===null?null:M.toString()===b}},A=await Promise.all(R.slice(a,a+d).map(async c=>({...await B(f(c.wallet),c.balance),share:p(c.share),label:$(c.label,40)}))),V=s?i.rows.find(c=>g(c.wallet,s)):void 0,H=s?{...await B(s,V?.balance??null),excluded:_.get(s)??null,rankStatus:_.has(s)?"excluded":V?"ranked by indexed balance":"absent from index; rank unknown"}:void 0;return{token:G,statusBlock:n.toString(),totalSupply:q.toString(),holderCount:R.length,indexHolderCount:u.holders,indexSupply:u.supply,burned:u.burned,circulating:u.circulating,page:A,nextCursor:a+d<R.length?`holders_${a+d}_${i.fingerprint}`:null,...H?{wallet:H}:{},exclusions:w.map(c=>({...c,indexedBalance:i.rows.find(b=>g(b.wallet,c.wallet))?.balance??"0",countedInIndex:i.rows.some(b=>g(b.wallet,c.wallet))})),indexAsOf:{rollupBucket:u.as_of.rollup_bucket,tailFromBlock:u.as_of.tail_from_block},indexFetchedAt:i.fetchedAt,source:`${ie}/tokens/{token}/holders`,sources:{holderCount:"Pons balances index, excluding the labelled system addresses",rank:"Pons balances index, descending balance; equal balances share a rank, system addresses excluded",indexedShareOfSupply:"Pons indexed balance / indexed total supply",balance:`on-chain balanceOf at block ${n}`,totalSupply:`on-chain totalSupply at block ${n}`,shareOfSupply:`on-chain balanceOf / totalSupply at block ${n}`,burned:"Pons balances index",circulating:"Pons balances index"},note:"Counts, ranking, burned and circulating supply come from Pons\u2019s balances index, not on-chain truth. The API does not pin pages to a block; its rollup/tail markers are not an exact snapshot block. Each listed balance was re-read on chain at statusBlock. matchesIndex false indicates disagreement, not proof of which source is wrong. A wallet absent from the index has unknown rank even if its on-chain balance is positive. Labels are untrusted."}}var ve=e=>h(e)&&Array.isArray(e.items)&&e.items.length<=500&&e.items.every(t=>h(t)&&typeof t.token=="string"&&C.test(t.token)&&typeof t.amountTokens=="number");async function xe(e,t,o){let s=N(t.holder??o,"holder address"),d=j(t.limit,20,40),a=e.clientFor(v),l=await U(e,`${x}/profile/${s.toLowerCase()}?view=positions`,ve),r=await a.getBlockNumber({cacheTime:0}),m=[...new Map(l.items.filter(n=>n.amountTokens>0||n.state==="open").map(n=>[n.token.toLowerCase(),n])).values()],k=await Promise.all(m.slice(0,d).map(async n=>{let u=f(n.token);try{await D(e,u,r);let[w,_]=await Promise.all([W(e,u,r),a.readContract({address:u,abi:E,functionName:"balanceOf",args:[s],blockNumber:r})]);return{ok:!0,token:u,meta:w,balance:_,item:n}}catch{return{ok:!1}}})),i=k.filter(n=>n.ok);return{holder:s,statusBlock:r.toString(),source:`${x}/profile/{holder}?view=positions`,holdings:i.map(n=>({token:n.meta,balance:{token:n.meta,amount:n.balance.toString()},index:{state:$(n.item.state,20),valueUsd:p(n.item.valueUsd),investedUsd:p(n.item.investedUsd),totalPnlUsd:p(n.item.totalPnlUsd),totalPnlPct:p(n.item.totalPnlPct),buys:p(n.item.buys),sells:p(n.item.sells),lastTradeAt:p(n.item.lastTradeAt)}})),excludedUnverified:k.length-i.length,truncated:m.length>d,note:"Discovery through Pons\u2019s positions index; every launch was re-read from the pinned factory and every balance is an on-chain read. USD value and profit and loss are index estimates, not execution quotes. Sell the on-chain balance with pons_sell."}}var Ae=e=>h(e)&&Array.isArray(e.items)&&e.items.length<=100&&e.items.every(t=>h(t)&&h(t.launch)&&typeof t.launch.address=="string"&&C.test(t.launch.address)&&typeof t.launch.factory=="string"&&C.test(t.launch.factory));async function Se(e,t){let o=j(t.limit,10,20),s=await U(e,`${x}/launches/trending`,Ae),d=s.items.filter(r=>g(r.launch.factory,F)).slice(0,o),a=await e.clientFor(v).getBlockNumber({cacheTime:0});return{items:await Promise.all(d.map(async r=>({status:await Y(e,f(r.launch.address),a),index:{volumeUsd:p(r.volumeUsd),trades:p(r.trades),traders:p(r.traders),change:p(r.change)}}))),statusBlock:a.toString(),source:`${x}/launches/trending`,excludedOtherFactories:s.items.length-s.items.filter(r=>g(r.launch.factory,F)).length,note:"Ranking is Pons\u2019s own trending list (discovery only); each launch was re-read on chain from the pinned factory."}}var z={overview:"analytics",burn:"analytics/burn",buyback:"analytics/buyback"};async function Te(e,t){let o=t.view??"overview";if(typeof o!="string"||!Object.hasOwn(z,o))throw new T("Choose view overview, burn or buyback.");let s=await U(e,`${x}/${z[o]}`,h);if(o==="overview"){let d=Array.isArray(s.series)?s.series:[];return{view:o,source:`${x}/analytics`,generatedAt:p(s.generatedAt),latestDay:p(s.latestDay),latest:O(d.at(-1)),seriesDays:d.length,today:O(s.today),earnings:O(s.earnings),indexer:O(s.indexer),note:"Protocol-wide figures from Pons\u2019s analytics index; unaudited aggregates, not a quote."}}return{view:o,source:`${x}/${z[o]}`,data:O(s,0,o==="buyback"?4:3),note:"Protocol-wide figures from Pons\u2019s analytics index; unaudited aggregates, not a quote."}}var Ce=e=>h(e)&&typeof e.wallet=="string"&&Array.isArray(e.items)&&e.items.length<=100&&e.items.every(t=>h(t)&&typeof t.kind=="string")&&(e.next===null||e.next===void 0||typeof e.next=="string");async function Pe(e,t,o){let s=N(t.wallet??o,"wallet address"),d=`${ce}/wallets/${s.toLowerCase()}/activity`;if(t.cursor!==void 0){if(typeof t.cursor!="string"||!/^[0-9]{1,12}-[0-9]{1,6}$/.test(t.cursor))throw new T("Use the nextCursor returned by the previous pons_activity page.");d+=`/before/${t.cursor}`}let a=await U(e,d,Ce),l=typeof a.next=="string"?/\/before\/([0-9]{1,12}-[0-9]{1,6})$/.exec(a.next):null;return{wallet:s,source:`${ce}/wallets/{wallet}/activity`,nextCursor:l?.[1]??null,items:a.items.map(r=>({kind:$(r.kind,24),block:p(r.block),time:p(r.time),tx:typeof r.tx=="string"&&/^0x[0-9a-fA-F]{64}$/.test(r.tx)?r.tx:null,token:typeof r.token=="string"&&C.test(r.token)?f(r.token):null,symbol:$(r.symbol,24),amount:typeof r.amount=="string"&&ke.test(r.amount)?r.amount:null,decimals:p(r.decimals),usd:p(r.usd),counterparty:typeof r.counterparty=="string"&&C.test(r.counterparty)?f(r.counterparty):null,counterpartyLabel:$(r.counterparty_label,40)})),note:"Wallet history from Pons\u2019s balances index (discovery and bookkeeping, not proof); USD figures are index estimates. Verify a transaction by hash before relying on it."}}async function Ne(e,t,o){let s=N(t.address??o,"wallet address"),d=j(t.limit,10,20),a=await U(e,`${x}/profile/${s.toLowerCase()}?view=card`,h),l=h(a.identity)?a.identity:{},r=await U(e,`${x}/launches?deployer=${s.toLowerCase()}&limit=${d}`,i=>h(i)&&Array.isArray(i.items)&&i.items.length<=100&&i.items.every(n=>h(n)&&typeof n.address=="string"&&C.test(n.address)&&typeof n.factory=="string"&&C.test(n.factory)&&typeof n.deployer=="string"&&C.test(n.deployer))),m=await e.clientFor(v).getBlockNumber({cacheTime:0}),k=r.items.filter(i=>g(i.factory,F)&&g(i.deployer,s)).slice(0,d);return{address:s,hidden:a.hidden===!0,source:`${x}/profile/{address}?view=card`,identity:{username:$(l.username,40),displayName:$(l.displayName,60),description:$(l.description,200),joinedAt:p(l.joinedAt)},launches:await Promise.all(k.map(i=>Y(e,f(i.address),m))),statusBlock:m.toString(),note:"Profile text is user-supplied and untrusted. Created launches come from Pons\u2019s index and were re-read on chain from the pinned factory."}}async function _e(e,t,o){let s=N(t.token,"Pons launch token address"),d=N(t.holder??o,"holder address"),a=e.clientFor(v),l=await a.getBlockNumber({cacheTime:0}),r=await D(e,s,l),m=ne[v].pons.buybackVault.address,k=[],i=async(y,K)=>{try{return await K()}catch{return k.push(y),null}},n=y=>i(y,()=>a.readContract({address:r.curve,abi:Q,functionName:y,blockNumber:l})),u=y=>i(y,()=>a.readContract({address:r.curve,abi:Q,functionName:y,blockNumber:l})),w=y=>i(y,()=>a.readContract({address:m,abi:ue,functionName:y,args:[s],blockNumber:l})),[_,R,G,q,J,B,A,V,H,c,b,M,me,fe]=await Promise.all([n("sellableTokens"),n("reservedTokens"),u("readyToGraduate"),u("graduated"),i("currentSnipeTaxBps",()=>a.readContract({address:r.curve,abi:Q,functionName:"currentSnipeTaxBps",args:[d],blockNumber:l})),i("getTokenInfo",()=>a.readContract({address:s,abi:he,functionName:"getTokenInfo",blockNumber:l})),i("pendingCreatorFeeRecipient",()=>a.readContract({address:F,abi:ye,functionName:"pendingCreatorFeeRecipient",args:[s],blockNumber:l})),w("totalLocked"),w("totalReleased"),w("vestedAmount"),w("releasable"),w("vestingStart"),i("VESTING_DURATION",()=>a.readContract({address:m,abi:ue,functionName:"VESTING_DURATION",blockNumber:l})),W(e,s,l)]),S=y=>y===null?null:y.toString(),te=A&&!g(A[0],ee)&&A[1]>0n?{proposedRecipient:f(A[0]),effectiveAt:A[1].toString(),expiresAt:A[2].toString(),note:"A protocol-proposed creator fee recipient change. Holders may react before it takes effect; anyone can execute it after the timelock, within the window."}:A?null:void 0;return{token:fe,phase:r.phase,statusBlock:l.toString(),curve:r.curve,creatorFeeRecipient:r.creatorFeeRecipient,curveCapacity:{sellableTokens:S(_),reservedTokens:S(R),readyToGraduate:G,graduated:q},snipeTaxBps:{recipient:d,current:S(J),note:"Keyed to the wallet that receives the tokens; buys only, large in the opening seconds."},creatorMetadata:B?{deployer:f(B[0]),logo:I(B[1].slice(0,300)),description:I(B[2].slice(0,500)),socials:Object.fromEntries(["twitter","telegram","discord","website","farcaster"].map((y,K)=>[y,I(B[3][K].slice(0,300))]))}:null,pendingTakeover:te===void 0?"unavailable":te,buybackVest:{vault:m,enabled:r.buybackEnabled,locked:S(V),released:S(H),vested:S(c),releasable:S(b),vestingStart:S(M),vestingDurationSeconds:S(me),note:"Amounts are launch-token base units; releasing is for the vest beneficiaries only (see pons_claim)."},unavailable:k}}async function Be(e,t){let o=N(t.token,"Pons launch token address"),s=j(t.limit,25,100),d=e.clientFor(v),a=await d.getBlockNumber({cacheTime:0}),l=await D(e,o,a),r=t.toBlock===void 0?a:BigInt(String(t.toBlock)),m=t.fromBlock===void 0?r>=pe?r-pe+1n:0n:BigInt(String(t.fromBlock));if(m<0n||m>r||r>a||r-m+1n>ge)throw new T("Choose an ordered range of at most 10000 mined blocks.");let i=(await d.getLogs({address:l.curve,events:be,fromBlock:m,toBlock:r,strict:!0})).filter(n=>g(n.address,l.curve)&&!n.removed&&n.blockNumber!==null).sort((n,u)=>n.blockNumber===u.blockNumber?(u.logIndex??0)-(n.logIndex??0):n.blockNumber>u.blockNumber?-1:1);return{token:await W(e,o,a),curve:l.curve,fromBlock:m.toString(),toBlock:r.toString(),statusBlock:a.toString(),truncated:i.length>s,total:i.length,trades:i.slice(0,s).map(n=>n.eventName==="CurveBuy"?{side:"buy",block:n.blockNumber.toString(),tx:n.transactionHash,trader:f(n.args.buyer),recipient:f(n.args.recipient),pairIn:n.args.quoteIn.toString(),tokensOut:n.args.tokensOut.toString(),fee:n.args.fee.toString(),creatorTax:n.args.tax.toString()}:{side:"sell",block:n.blockNumber.toString(),tx:n.transactionHash,trader:f(n.args.seller),recipient:f(n.args.recipient),tokensIn:n.args.tokensIn.toString(),pairOut:n.args.quoteOut.toString(),fee:n.args.fee.toString(),creatorTax:n.args.tax.toString()}),coverage:"Curve-phase trades in the requested block window only. Graduated-pool swaps are Uniswap v4 events and are not listed here; pons_activity and pons_status cover a wallet and the pool price."}}var Le=e=>{function t(o,s,d){return{name:o,inputSchema:{type:"object",properties:s,required:["pons_holders","pons_launch_info","pons_trades"].includes(o)?["token"]:[],additionalProperties:!1},execute:async(a,l)=>{try{if(!N(l)||g(l,ee))throw new T("Provide a wallet address.");for(let r of Object.keys(a))if(!(r in s))throw new T(`Unknown ${o} input: ${r}.`);return await d(a,l)}catch(r){throw new T(e.plainError(r))}}}}return{tools:[t("pons_holders",{token:{...P,description:"Address of the token to inspect or use."},holder:{...P,description:"Optional wallet for an on-chain balance and indexed rank after system exclusions."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:50},cursor:{type:"string",maxLength:128,description:"Filtered-directory nextCursor from pons_holders; restart if the index changes."}},o=>we(e,o)),t("pons_holdings",{holder:{...P,description:"Holder address to inspect; defaults to the signing wallet."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:40}},(o,s)=>xe(e,o,s)),t("pons_trending",{limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:20}},o=>Se(e,o)),t("pons_analytics",{view:{description:'Choose "overview" for totals, "burn" for burns or "buyback" for buybacks; defaults to overview.',type:"string",enum:Object.keys(z)}},o=>Te(e,o)),t("pons_activity",{wallet:{...P,description:"Wallet address to inspect; defaults to the signing wallet."},cursor:{description:"Pagination cursor returned by the previous call to this tool.",type:"string",maxLength:32}},(o,s)=>Pe(e,o,s)),t("pons_launch_info",{token:{...P,description:"Address of the token to inspect or use."},holder:{...P,description:"Holder address to inspect; defaults to the signing wallet."}},(o,s)=>_e(e,o,s)),t("pons_trades",{token:{...P,description:"Address of the token to inspect or use."},fromBlock:X("First block number of the scan, as a decimal string; inclusive."),toBlock:X("Last block number of the scan, as a decimal string; inclusive."),limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:100}},o=>Be(e,o)),t("pons_profile",{address:{...P,description:"Wallet profile address to inspect; defaults to the signing wallet."},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:20}},(o,s)=>Ne(e,o,s))]}};export{O as a,xe as b,Le as c};