@oakagentkit/core 0.2.1 → 0.2.3

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 (377) hide show
  1. package/build/dist/api/addresses.d.ts +93 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.js +1 -1
  5. package/build/dist/api/identity-link.js +1 -1
  6. package/build/dist/api/metadata.js +1 -1
  7. package/build/dist/api/modules/beefy/boosts.js +1 -1
  8. package/build/dist/api/modules/beefy/clm.js +1 -1
  9. package/build/dist/api/modules/beefy/guard.js +1 -1
  10. package/build/dist/api/modules/beefy/index.js +1 -1
  11. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  12. package/build/dist/api/modules/beefy/management.js +1 -1
  13. package/build/dist/api/modules/beefy/vaults.js +1 -1
  14. package/build/dist/api/modules/clanker/extensions.js +1 -1
  15. package/build/dist/api/modules/clanker/index.js +1 -1
  16. package/build/dist/api/modules/clanker/manage.js +1 -1
  17. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  18. package/build/dist/api/modules/clanker/protocol.js +1 -1
  19. package/build/dist/api/modules/clanker/state.js +1 -1
  20. package/build/dist/api/modules/erc8004/common.js +1 -1
  21. package/build/dist/api/modules/erc8004/domain.js +1 -1
  22. package/build/dist/api/modules/erc8004/index.js +1 -1
  23. package/build/dist/api/modules/erc8004/management.js +1 -1
  24. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  25. package/build/dist/api/modules/erc8004/services.js +1 -1
  26. package/build/dist/api/modules/erc8004/validation.js +1 -1
  27. package/build/dist/api/modules/grove/index.js +1 -1
  28. package/build/dist/api/modules/heyresearch/backoff.d.ts +6 -0
  29. package/build/dist/api/modules/heyresearch/backoff.js +1 -0
  30. package/build/dist/api/modules/heyresearch/builder-feed.d.ts +62 -0
  31. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -0
  32. package/build/dist/api/modules/heyresearch/index.d.ts +3 -0
  33. package/build/dist/api/modules/heyresearch/index.js +1 -1
  34. package/build/dist/api/modules/heyresearch/proof-reads.d.ts +7 -0
  35. package/build/dist/api/modules/heyresearch/proof-reads.js +1 -0
  36. package/build/dist/api/modules/heyresearch/public-reads.d.ts +1 -0
  37. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  38. package/build/dist/api/modules/heyresearch/scan.d.ts +31 -0
  39. package/build/dist/api/modules/heyresearch/scan.js +1 -0
  40. package/build/dist/api/modules/heyresearch/status-labels.d.ts +5 -0
  41. package/build/dist/api/modules/heyresearch/status-labels.js +1 -0
  42. package/build/dist/api/modules/heyresearch/token-facts.d.ts +123 -0
  43. package/build/dist/api/modules/heyresearch/token-facts.js +1 -0
  44. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  45. package/build/dist/api/modules/hoodag/index.js +1 -1
  46. package/build/dist/api/modules/hoodag/management.js +1 -1
  47. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  49. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  50. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  51. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  52. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  53. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  54. package/build/dist/api/modules/hoodlock/index.js +1 -1
  55. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  56. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  57. package/build/dist/api/modules/hoodlock/public.js +1 -1
  58. package/build/dist/api/modules/hookr/actions.d.ts +1 -1
  59. package/build/dist/api/modules/hookr/actions.js +1 -1
  60. package/build/dist/api/modules/hookr/addons.js +1 -1
  61. package/build/dist/api/modules/hookr/agent-gate.d.ts +63 -0
  62. package/build/dist/api/modules/hookr/agent-gate.js +1 -0
  63. package/build/dist/api/modules/hookr/contracts.js +1 -1
  64. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  65. package/build/dist/api/modules/hookr/discovery.js +1 -1
  66. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  67. package/build/dist/api/modules/hookr/index.d.ts +1 -0
  68. package/build/dist/api/modules/hookr/index.js +1 -1
  69. package/build/dist/api/modules/hookr/launch-options.d.ts +119 -0
  70. package/build/dist/api/modules/hookr/launch-options.js +1 -0
  71. package/build/dist/api/modules/hookr/launch-profile.d.ts +5 -0
  72. package/build/dist/api/modules/hookr/launch-profile.js +1 -0
  73. package/build/dist/api/modules/hookr/launch-receipt.d.ts +144 -0
  74. package/build/dist/api/modules/hookr/launch-receipt.js +1 -0
  75. package/build/dist/api/modules/hookr/launch.d.ts +58 -0
  76. package/build/dist/api/modules/hookr/launch.js +1 -0
  77. package/build/dist/api/modules/hookr/liquidity.d.ts +48 -0
  78. package/build/dist/api/modules/hookr/liquidity.js +1 -0
  79. package/build/dist/api/modules/hookr/lp-positions.d.ts +2 -0
  80. package/build/dist/api/modules/hookr/lp-positions.js +1 -0
  81. package/build/dist/api/modules/hookr/lp-reads.d.ts +52 -0
  82. package/build/dist/api/modules/hookr/lp-reads.js +1 -0
  83. package/build/dist/api/modules/hookr/lp-receipt.d.ts +136 -0
  84. package/build/dist/api/modules/hookr/lp-receipt.js +1 -0
  85. package/build/dist/api/modules/hookr/lp-state.d.ts +33 -0
  86. package/build/dist/api/modules/hookr/lp-state.js +1 -0
  87. package/build/dist/api/modules/hookr/pins.d.ts +43 -0
  88. package/build/dist/api/modules/hookr/pins.js +1 -0
  89. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  90. package/build/dist/api/modules/hookr/read-utils.d.ts +59 -0
  91. package/build/dist/api/modules/hookr/read-utils.js +1 -0
  92. package/build/dist/api/modules/hookr/relay.js +1 -1
  93. package/build/dist/api/modules/hookr/revenue.js +1 -1
  94. package/build/dist/api/modules/kyberswap/index.js +1 -1
  95. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  96. package/build/dist/api/modules/lighter/index.js +1 -1
  97. package/build/dist/api/modules/longbow/administration.js +1 -1
  98. package/build/dist/api/modules/longbow/analytics.js +1 -1
  99. package/build/dist/api/modules/longbow/fixed.js +1 -1
  100. package/build/dist/api/modules/longbow/index.js +1 -1
  101. package/build/dist/api/modules/longbow/nft.js +1 -1
  102. package/build/dist/api/modules/longbow/rebates.js +1 -1
  103. package/build/dist/api/modules/longbow/staking.js +1 -1
  104. package/build/dist/api/modules/meridian/index.js +1 -1
  105. package/build/dist/api/modules/meridian/markets.js +1 -1
  106. package/build/dist/api/modules/meridian/rfq.js +1 -1
  107. package/build/dist/api/modules/merkl/discovery.js +1 -1
  108. package/build/dist/api/modules/merkl/index.js +1 -1
  109. package/build/dist/api/modules/merkl/manage.js +1 -1
  110. package/build/dist/api/modules/merkl/protocol.js +1 -1
  111. package/build/dist/api/modules/morpho/allocator.js +1 -1
  112. package/build/dist/api/modules/morpho/bundles.js +1 -1
  113. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  114. package/build/dist/api/modules/morpho/index.js +1 -1
  115. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  116. package/build/dist/api/modules/morpho/midnight.js +1 -1
  117. package/build/dist/api/modules/morpho/protocol.js +1 -1
  118. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  119. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  120. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  121. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  122. package/build/dist/api/modules/netnet/card-read.js +1 -1
  123. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  124. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  125. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  126. package/build/dist/api/modules/netnet/financial.js +1 -1
  127. package/build/dist/api/modules/netnet/index.js +1 -1
  128. package/build/dist/api/modules/netnet/staking.js +1 -1
  129. package/build/dist/api/modules/orbio/index.js +1 -1
  130. package/build/dist/api/modules/pons/claim.js +1 -1
  131. package/build/dist/api/modules/pons/index.js +1 -1
  132. package/build/dist/api/modules/pons/launch-status.js +1 -1
  133. package/build/dist/api/modules/pons/prices.js +1 -1
  134. package/build/dist/api/modules/pons/reads.js +1 -1
  135. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  136. package/build/dist/api/modules/pons/trade.js +1 -1
  137. package/build/dist/api/modules/poolstrade/index.js +1 -1
  138. package/build/dist/api/modules/priors/coverage.js +1 -1
  139. package/build/dist/api/modules/priors/discovery.js +1 -1
  140. package/build/dist/api/modules/priors/features.js +1 -1
  141. package/build/dist/api/modules/priors/index.js +1 -1
  142. package/build/dist/api/modules/priors/integration.js +1 -1
  143. package/build/dist/api/modules/priors/market.js +1 -1
  144. package/build/dist/api/modules/priors/pt.js +1 -1
  145. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  146. package/build/dist/api/modules/priors/starter-line.js +1 -1
  147. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  148. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  149. package/build/dist/api/modules/relay/discovery.js +1 -1
  150. package/build/dist/api/modules/relay/inbound.js +1 -1
  151. package/build/dist/api/modules/relay/index.js +1 -1
  152. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  153. package/build/dist/api/modules/relay/reads.js +1 -1
  154. package/build/dist/api/modules/spark/actions.js +1 -1
  155. package/build/dist/api/modules/spark/details.js +1 -1
  156. package/build/dist/api/modules/spark/index.js +1 -1
  157. package/build/dist/api/modules/spark/management.js +1 -1
  158. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  159. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  160. package/build/dist/api/modules/steakhouse/index.js +1 -1
  161. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  162. package/build/dist/api/modules/steakhouse/management.js +1 -1
  163. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  164. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  165. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  166. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  167. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  168. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  169. package/build/dist/api/modules/tickerspring/index.js +1 -1
  170. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  171. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  172. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  173. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  174. package/build/dist/api/modules/tickerspring/research.js +1 -1
  175. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  176. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  177. package/build/dist/api/modules/uniswap/auction.js +1 -1
  178. package/build/dist/api/modules/uniswap/batch.js +1 -1
  179. package/build/dist/api/modules/uniswap/common.js +1 -1
  180. package/build/dist/api/modules/uniswap/fees.js +1 -1
  181. package/build/dist/api/modules/uniswap/index.js +1 -1
  182. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  183. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  184. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  185. package/build/dist/api/modules/uniswap/pools.js +1 -1
  186. package/build/dist/api/modules/uniswap/position.js +1 -1
  187. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  188. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  189. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  190. package/build/dist/api/modules/uniswap/trade.js +1 -1
  191. package/build/dist/api/modules/uniswap/v2.js +1 -1
  192. package/build/dist/api/modules/uniswap/v3.js +1 -1
  193. package/build/dist/api/modules/uniswap/v4.js +1 -1
  194. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  195. package/build/dist/api/modules/velora/claims.js +1 -1
  196. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  197. package/build/dist/api/modules/velora/index.js +1 -1
  198. package/build/dist/api/modules/wormhole/index.d.ts +5 -0
  199. package/build/dist/api/modules/wormhole/index.js +1 -0
  200. package/build/dist/api/modules/wormhole/license.d.ts +2 -0
  201. package/build/dist/api/modules/wormhole/license.js +1 -0
  202. package/build/dist/api/modules/wormhole/quotetext.d.ts +36 -0
  203. package/build/dist/api/modules/wormhole/quotetext.js +1 -0
  204. package/build/dist/api/modules/wormhole/scan-text.d.ts +40 -0
  205. package/build/dist/api/modules/wormhole/scan-text.js +1 -0
  206. package/build/dist/api/modules/wormhole/token-check.d.ts +54 -0
  207. package/build/dist/api/modules/wormhole/token-check.js +1 -0
  208. package/build/dist/api/positions.js +1 -1
  209. package/build/dist/api/pricenote.js +1 -1
  210. package/build/dist/api/prices.js +1 -1
  211. package/build/dist/api/pricing.js +1 -1
  212. package/build/dist/api/rpc.js +1 -1
  213. package/build/dist/api/send.js +1 -1
  214. package/build/dist/api/signing-registry.js +1 -1
  215. package/build/dist/api/signing.js +1 -1
  216. package/build/dist/api/simulate.js +1 -1
  217. package/build/dist/api/swap.js +1 -1
  218. package/build/dist/api/tokens.js +1 -1
  219. package/build/dist/api/tool-policy.js +1 -1
  220. package/build/dist/api/types.d.ts +7 -0
  221. package/build/dist/chunks/{QHHZDXRG.js → 2FSX7MMR.js} +1 -1
  222. package/build/dist/chunks/{RTBOMWCB.js → 2LM7U4S7.js} +1 -1
  223. package/build/dist/chunks/{BBVKWG65.js → 2MSQ6JII.js} +1 -1
  224. package/build/dist/chunks/{T6MTTMLQ.js → 2UU5TBBB.js} +1 -1
  225. package/build/dist/chunks/{OW7GOYKA.js → 2W46IRX6.js} +1 -1
  226. package/build/dist/chunks/{6LLOTPH2.js → 3EFV4FQF.js} +1 -1
  227. package/build/dist/chunks/{IAXKPME3.js → 3NDVXEBR.js} +1 -1
  228. package/build/dist/chunks/3SC5UI35.js +1 -0
  229. package/build/dist/chunks/{TCS3ICNE.js → 3WBDHUV2.js} +1 -1
  230. package/build/dist/chunks/{UPPYXY74.js → 4AKIXLXH.js} +1 -1
  231. package/build/dist/chunks/{ZGXNTWYG.js → 4GHVIBL5.js} +1 -1
  232. package/build/dist/chunks/{NHCRJC5X.js → 4KQZTPMS.js} +1 -1
  233. package/build/dist/chunks/{N77ANGBT.js → 4X2JOQ2L.js} +1 -1
  234. package/build/dist/chunks/{ZPM2MFXZ.js → 52DHGSG4.js} +1 -1
  235. package/build/dist/chunks/{2CS3M32D.js → 57HAXNQV.js} +1 -1
  236. package/build/dist/chunks/5IIR3GIN.js +1 -0
  237. package/build/dist/chunks/{CAU44UWP.js → 5O5ZE3ZV.js} +1 -1
  238. package/build/dist/chunks/5OEHZJ6X.js +1 -0
  239. package/build/dist/chunks/{CBA776XQ.js → 5VHH5PW3.js} +1 -1
  240. package/build/dist/chunks/{6HV5BR7P.js → 6AWTAE4Q.js} +1 -1
  241. package/build/dist/chunks/{JRVTSGAT.js → 6UPPUHCL.js} +1 -1
  242. package/build/dist/chunks/{MEMVFR7Z.js → 6ZYLNB2B.js} +1 -1
  243. package/build/dist/chunks/7XLEYOZH.js +1 -0
  244. package/build/dist/chunks/{Q4RZQCDS.js → AAGDMH54.js} +1 -1
  245. package/build/dist/chunks/ACN2BFMA.js +1 -0
  246. package/build/dist/chunks/{L24EOVLT.js → AJP5LDM2.js} +1 -1
  247. package/build/dist/chunks/{F2YH72GF.js → ALK6NKFP.js} +1 -1
  248. package/build/dist/chunks/{EC5W3UZD.js → AMICUXS6.js} +1 -1
  249. package/build/dist/chunks/{BEPSWFJX.js → ASDKY5NX.js} +1 -1
  250. package/build/dist/chunks/{5LQBHXFA.js → BX7XQANB.js} +1 -1
  251. package/build/dist/chunks/{NUTHT4FE.js → CE7D6MUS.js} +1 -1
  252. package/build/dist/chunks/{QNPEKNWM.js → CEIPDEXZ.js} +1 -1
  253. package/build/dist/chunks/{HFQS5344.js → CQCVFRQ5.js} +1 -1
  254. package/build/dist/chunks/{OJLMF5AR.js → CUNQ5RG5.js} +1 -1
  255. package/build/dist/chunks/{IWALIX7Q.js → CXLEQCP3.js} +1 -1
  256. package/build/dist/chunks/{VJ3W2V3B.js → CY75R4FK.js} +1 -1
  257. package/build/dist/chunks/{65QFM4JU.js → DCTUYDWF.js} +1 -1
  258. package/build/dist/chunks/{N37ZLNCT.js → DRWWPBOQ.js} +1 -1
  259. package/build/dist/chunks/{7B5UH2VS.js → DZGEQBO7.js} +1 -1
  260. package/build/dist/chunks/{RFJCG4NA.js → E7R3J4H7.js} +1 -1
  261. package/build/dist/chunks/{7T4BYFD4.js → EGUMOD3A.js} +1 -1
  262. package/build/dist/chunks/ELZNT5Q3.js +1 -0
  263. package/build/dist/chunks/{IUETZH6I.js → EXRKBBX2.js} +1 -1
  264. package/build/dist/chunks/{K7HIKXNT.js → FBSUTF3B.js} +1 -1
  265. package/build/dist/chunks/{LFN3OODW.js → FUXT7GRK.js} +1 -1
  266. package/build/dist/chunks/{7US6PD56.js → G3MHDTGT.js} +1 -1
  267. package/build/dist/chunks/G6HCV67X.js +1 -0
  268. package/build/dist/chunks/GCWA4Z3W.js +1 -0
  269. package/build/dist/chunks/{HNMOB76J.js → GGUEKSR4.js} +1 -1
  270. package/build/dist/chunks/{GZ5TW3WB.js → GIV5JMTE.js} +1 -1
  271. package/build/dist/chunks/{OMTCWXQR.js → GJY3P6OG.js} +1 -1
  272. package/build/dist/chunks/HOEQVPY7.js +1 -0
  273. package/build/dist/chunks/{3R3C3CU5.js → IBXYIN7Q.js} +1 -1
  274. package/build/dist/chunks/{SXX52Y27.js → IUE6RASI.js} +1 -1
  275. package/build/dist/chunks/{AYM5L6L7.js → J3GFCBZZ.js} +1 -1
  276. package/build/dist/chunks/{T3MGNKA6.js → JPOYTTTW.js} +1 -1
  277. package/build/dist/chunks/{AZGMF26W.js → JST5JGAP.js} +1 -1
  278. package/build/dist/chunks/{FBQWTWPT.js → JWCOXLYA.js} +1 -1
  279. package/build/dist/chunks/{G7UKNO2I.js → KHJFXJBU.js} +1 -1
  280. package/build/dist/chunks/{HQVC6X3T.js → KSZMMNXK.js} +1 -1
  281. package/build/dist/chunks/{O7PQDUVT.js → L3ZM77SJ.js} +1 -1
  282. package/build/dist/chunks/{QRUC7EFE.js → L62M7LOB.js} +1 -1
  283. package/build/dist/chunks/{22S4SFD5.js → L7YBCMZU.js} +1 -1
  284. package/build/dist/chunks/LKJBMHCE.js +1 -0
  285. package/build/dist/chunks/{FKAA7VUR.js → LLM5WDM3.js} +1 -1
  286. package/build/dist/chunks/{H6ED3RHF.js → LMVB3B6T.js} +1 -1
  287. package/build/dist/chunks/{UIIJWIR6.js → LQGPMOD2.js} +1 -1
  288. package/build/dist/chunks/{WLACEU2Y.js → LQUDJCAR.js} +1 -1
  289. package/build/dist/chunks/LT5P6PZW.js +1 -0
  290. package/build/dist/chunks/M7U3A4EH.js +3 -0
  291. package/build/dist/chunks/MKQVS3IO.js +1 -0
  292. package/build/dist/chunks/{5XFXH2JT.js → NATG6YA6.js} +1 -1
  293. package/build/dist/chunks/{O47JXRXN.js → NAYRD43N.js} +1 -1
  294. package/build/dist/chunks/{6L6DSMCU.js → NMYGNJIJ.js} +1 -1
  295. package/build/dist/chunks/NRBIXV7V.js +1 -0
  296. package/build/dist/chunks/{D6VP3N27.js → NSOEDRBU.js} +1 -1
  297. package/build/dist/chunks/{HL2MLC3O.js → NU4K3TEZ.js} +1 -1
  298. package/build/dist/chunks/NWSPC3NH.js +1 -0
  299. package/build/dist/chunks/O5IVZHHP.js +1 -0
  300. package/build/dist/chunks/{I7NUTSSX.js → OE3CLZHR.js} +1 -1
  301. package/build/dist/chunks/{2NA6JLEC.js → OQVZVR2S.js} +1 -1
  302. package/build/dist/chunks/{D3OWLDVB.js → OVK4EEOD.js} +1 -1
  303. package/build/dist/chunks/{Q2VMH2LB.js → PARWLWXW.js} +1 -1
  304. package/build/dist/chunks/{NCEJZWGX.js → PEA32CWB.js} +1 -1
  305. package/build/dist/chunks/{DHXVYHT4.js → PTAWEHKB.js} +1 -1
  306. package/build/dist/chunks/{DVKDWXEJ.js → PWBL4WKB.js} +1 -1
  307. package/build/dist/chunks/{PR2QED25.js → PZHR4ITH.js} +1 -1
  308. package/build/dist/chunks/{OG5HRQU4.js → QRDDKA4I.js} +1 -1
  309. package/build/dist/chunks/{YR3QJVJQ.js → QXNPPCOU.js} +1 -1
  310. package/build/dist/chunks/{6NR7SVRO.js → QYYFRAWY.js} +1 -1
  311. package/build/dist/chunks/{QR7ALOR4.js → R53P2K3C.js} +1 -1
  312. package/build/dist/chunks/{5RKWSFD2.js → R7FXNZRM.js} +1 -1
  313. package/build/dist/chunks/{CCEWSOBT.js → R7QPJQP6.js} +1 -1
  314. package/build/dist/chunks/{SLSPWXR6.js → R7SXC74O.js} +1 -1
  315. package/build/dist/chunks/{IHGVCPVA.js → RAKUK5VR.js} +1 -1
  316. package/build/dist/chunks/{7LDAJ6BM.js → S3HNPTXA.js} +1 -1
  317. package/build/dist/chunks/{WIDTTGSH.js → SJPM5ST4.js} +1 -1
  318. package/build/dist/chunks/{QYHJWU5T.js → SJPYXNOK.js} +1 -1
  319. package/build/dist/chunks/{VY3P34PY.js → SKQGLGES.js} +1 -1
  320. package/build/dist/chunks/{ZT67OMLW.js → SOYQOE5P.js} +1 -1
  321. package/build/dist/chunks/{GUBB5P6V.js → SQZRVIVF.js} +1 -1
  322. package/build/dist/chunks/{E24S22BZ.js → SSTROLQM.js} +1 -1
  323. package/build/dist/chunks/{DGGOO4RN.js → SXAIXD56.js} +1 -1
  324. package/build/dist/chunks/{D4WURN33.js → SXX3VTBP.js} +1 -1
  325. package/build/dist/chunks/{UXG67LH3.js → TCPPYBGQ.js} +1 -1
  326. package/build/dist/chunks/{67TJOOBI.js → TLJPVYRJ.js} +1 -1
  327. package/build/dist/chunks/{ULJ6E4HP.js → TMGWXDCZ.js} +1 -1
  328. package/build/dist/chunks/TNLHMDWL.js +1 -0
  329. package/build/dist/chunks/{NMFVXBTL.js → TNSKEHPC.js} +1 -1
  330. package/build/dist/chunks/TPDOUL4N.js +1 -0
  331. package/build/dist/chunks/{C2FEXLMA.js → TQL7UDFL.js} +1 -1
  332. package/build/dist/chunks/{QXFJZGVB.js → TWCSCRFS.js} +1 -1
  333. package/build/dist/chunks/{2EDXKJ3B.js → TWSTOFN3.js} +1 -1
  334. package/build/dist/chunks/{X6G4BD35.js → U3F6DDML.js} +1 -1
  335. package/build/dist/chunks/{XGUKLFBU.js → UFS2RVEZ.js} +1 -1
  336. package/build/dist/chunks/{RM5W63LO.js → UNZRE3YU.js} +1 -1
  337. package/build/dist/chunks/{GECX5U3F.js → USSOVTD5.js} +1 -1
  338. package/build/dist/chunks/V2OOOV6B.js +1 -0
  339. package/build/dist/chunks/{IRWEY7TQ.js → V5LTA42G.js} +1 -1
  340. package/build/dist/chunks/{TAI63P6E.js → VC2RCYQE.js} +1 -1
  341. package/build/dist/chunks/VCLPOU7T.js +1 -0
  342. package/build/dist/chunks/{BG4S6MSN.js → VFKNXQXI.js} +1 -1
  343. package/build/dist/chunks/{3ZVGHC6S.js → VFSRRDLY.js} +1 -1
  344. package/build/dist/chunks/{XW7RH7YY.js → VVEUJ36E.js} +1 -1
  345. package/build/dist/chunks/{5EHQM6DM.js → WQ6H62DM.js} +1 -1
  346. package/build/dist/chunks/{TDN3C4IG.js → WQQJ7UPJ.js} +1 -1
  347. package/build/dist/chunks/{F3TJCOVV.js → WTSMPDT5.js} +1 -1
  348. package/build/dist/chunks/{BYXBS45D.js → WVXW6VL3.js} +1 -1
  349. package/build/dist/chunks/WWFOYZT2.js +1 -0
  350. package/build/dist/chunks/WWNAGOCD.js +1 -0
  351. package/build/dist/chunks/X2NJSQUY.js +203 -0
  352. package/build/dist/chunks/{C3ZZSGSP.js → XQUPZ3GU.js} +1 -1
  353. package/build/dist/chunks/XQXLFF7Y.js +1 -0
  354. package/build/dist/chunks/XUYHMOHS.js +1 -0
  355. package/build/dist/chunks/XV2HQKND.js +1 -0
  356. package/build/dist/chunks/{QZM7CWZW.js → XVFLT275.js} +1 -1
  357. package/build/dist/chunks/{BV3AHLH5.js → XWEFKXKA.js} +1 -1
  358. package/build/dist/chunks/{NKY3DT34.js → YA5WWDEW.js} +1 -1
  359. package/build/dist/chunks/YHB55C5T.js +1 -0
  360. package/build/dist/chunks/YOENHHKI.js +1 -0
  361. package/build/dist/chunks/YQUKU2LS.js +1 -0
  362. package/build/dist/chunks/{72AWP4BM.js → YZSTP2E6.js} +1 -1
  363. package/build/dist/chunks/{T3NPRRTY.js → Z7RL4NGX.js} +1 -1
  364. package/build/dist/chunks/{YMB553OJ.js → ZT47KN7A.js} +1 -1
  365. package/build/dist/chunks/ZXQMF56D.js +1 -0
  366. package/package.json +1 -1
  367. package/build/dist/chunks/6SCCW74G.js +0 -1
  368. package/build/dist/chunks/DD7755AW.js +0 -1
  369. package/build/dist/chunks/EYYUWFUR.js +0 -1
  370. package/build/dist/chunks/JG24LNUI.js +0 -1
  371. package/build/dist/chunks/JRO6WTK4.js +0 -1
  372. package/build/dist/chunks/MNFU7PO3.js +0 -1
  373. package/build/dist/chunks/N3GWFLG6.js +0 -1
  374. package/build/dist/chunks/RRSODRGT.js +0 -1
  375. package/build/dist/chunks/UMK564HS.js +0 -1
  376. package/build/dist/chunks/XPFVT2EA.js +0 -1
  377. package/build/dist/chunks/XUJSQV52.js +0 -1
@@ -1 +1 @@
1
- import{c as g,d as H,m as M}from"./DD7755AW.js";import{d,e as s,y as C}from"./JG24LNUI.js";import{f as _,g as k}from"./IAXKPME3.js";import{g as h}from"./73N3TOJL.js";import{a as w}from"./XPFVT2EA.js";import{a as t}from"./5YS5V2LK.js";import{decodeFunctionData as b,encodeFunctionData as B,erc20Abi as $,getAddress as O}from"viem";function K(u){return{tools:[{name:"uniswap_swap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["routes"],properties:{routes:{type:"array",minItems:1,maxItems:20,items:{type:"object",description:"Complete uniswap_swap arguments, including an absolute minAmountOut or maxAmountIn."}}}},async execute(n,v){if(k(n,["routes"]),!Array.isArray(n.routes)||n.routes.length<1||n.routes.length>20)throw new t("Provide 1 to 20 explicit bounded Uniswap routes.");let c=new Map,i="0x",A=0n,a,m=[],y=new Set;for(let e of n.routes){if(!e||typeof e!="object"||Array.isArray(e))throw new t("Each route must contain uniswap_swap arguments.");let I=await M(u,e,v,!1);if(!("txs"in I))throw new t("Route did not build swap transactions.");let E=I.txs;for(let r of E.slice(0,-1))if(h(r.to,d)){let[o,D,N,S]=b({abi:H,data:r.data}).args;if(D!==s)throw new t("Unexpected route approval spender.");let T=o.toLowerCase(),p=c.get(T),U=(p?.amount??0n)+N;if(U>=1n<<160n)throw new t("Combined input approvals exceed uint160.");c.set(T,{token:o,amount:U,expiration:p&&p.expiration<BigInt(S)?p.expiration:BigInt(S)})}else{let o=b({abi:$,data:r.data});if(o.functionName!=="approve"||!h(o.args[0],d))throw new t("Unexpected route prerequisite.")}let f=E.at(-1);if(f.to!==s)throw new t("Route does not use the pinned Universal Router.");A+=BigInt(f.value);let[j,x,P]=b({abi:g,data:f.data}).args,R=j.slice(2).match(/../g)??[];if(R.length!==x.length)throw new t("Unexpected route command/parameter count.");R.forEach((r,o)=>{r==="04"?y.add(x[o]):(i=`${i}${r}`,m.push(x[o]))}),a=a===void 0||P<a?P:a}for(let e of y)i=`${i}04`,m.push(e);let l=[];for(let e of c.values())l.push(u.approval(O(e.token),d,e.amount.toString(),w),C(e.token,s,e.amount.toString(),e.expiration.toString()));return l.push(u.unsignedTx({to:s,data:B({abi:g,functionName:"execute",args:[i,m,a]}),value:A.toString(),chainId:w,description:`Atomically execute ${n.routes.length} caller-selected v2/v3/v4 routes, preserving each route's trade bound.`})),_(u,l,v,"Explicit mixed-version/split routes; every route must meet its own bound. No automatic best-route search or allow-revert branch. The wallet must fund each independently previewed route.")}}]}}export{K as a};
1
+ import{c as g,d as H,m as M}from"./TPDOUL4N.js";import{f as k,g as C}from"./3NDVXEBR.js";import{d,e as s,y as _}from"./YOENHHKI.js";import{g as h}from"./73N3TOJL.js";import{a as w}from"./G6HCV67X.js";import{a as t}from"./5YS5V2LK.js";import{decodeFunctionData as b,encodeFunctionData as B,erc20Abi as $,getAddress as O}from"viem";function K(u){return{tools:[{name:"uniswap_swap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["routes"],properties:{routes:{type:"array",minItems:1,maxItems:20,items:{type:"object",description:"Complete uniswap_swap arguments, including an absolute minAmountOut or maxAmountIn."}}}},async execute(n,v){if(C(n,["routes"]),!Array.isArray(n.routes)||n.routes.length<1||n.routes.length>20)throw new t("Provide 1 to 20 explicit bounded Uniswap routes.");let c=new Map,i="0x",A=0n,a,m=[],y=new Set;for(let e of n.routes){if(!e||typeof e!="object"||Array.isArray(e))throw new t("Each route must contain uniswap_swap arguments.");let I=await M(u,e,v,!1);if(!("txs"in I))throw new t("Route did not build swap transactions.");let E=I.txs;for(let r of E.slice(0,-1))if(h(r.to,d)){let[o,D,N,S]=b({abi:H,data:r.data}).args;if(D!==s)throw new t("Unexpected route approval spender.");let T=o.toLowerCase(),p=c.get(T),U=(p?.amount??0n)+N;if(U>=1n<<160n)throw new t("Combined input approvals exceed uint160.");c.set(T,{token:o,amount:U,expiration:p&&p.expiration<BigInt(S)?p.expiration:BigInt(S)})}else{let o=b({abi:$,data:r.data});if(o.functionName!=="approve"||!h(o.args[0],d))throw new t("Unexpected route prerequisite.")}let f=E.at(-1);if(f.to!==s)throw new t("Route does not use the pinned Universal Router.");A+=BigInt(f.value);let[j,x,P]=b({abi:g,data:f.data}).args,R=j.slice(2).match(/../g)??[];if(R.length!==x.length)throw new t("Unexpected route command/parameter count.");R.forEach((r,o)=>{r==="04"?y.add(x[o]):(i=`${i}${r}`,m.push(x[o]))}),a=a===void 0||P<a?P:a}for(let e of y)i=`${i}04`,m.push(e);let l=[];for(let e of c.values())l.push(u.approval(O(e.token),d,e.amount.toString(),w),_(e.token,s,e.amount.toString(),e.expiration.toString()));return l.push(u.unsignedTx({to:s,data:B({abi:g,functionName:"execute",args:[i,m,a]}),value:A.toString(),chainId:w,description:`Atomically execute ${n.routes.length} caller-selected v2/v3/v4 routes, preserving each route's trade bound.`})),k(u,l,v,"Explicit mixed-version/split routes; every route must meet its own bound. No automatic best-route search or allow-revert branch. The wallet must fund each independently previewed route.")}}]}}export{K as a};
@@ -1 +1 @@
1
- import{b as z}from"./6NR7SVRO.js";import{c as Q}from"./C2FEXLMA.js";import{b as X}from"./DHXVYHT4.js";import{b as Z}from"./F2YH72GF.js";import{a as Y}from"./Q2VMH2LB.js";import{a as B,b as R,c as S,d as $,g as K,h as I,k as E,l as v,n as q,p as V,r as W,s as U,t as O,v as F,x as J,y as G}from"./2EDXKJ3B.js";import{a as h}from"./X5V2Z2NM.js";import{b as j}from"./AXYOJBX6.js";import{a as N}from"./6IM6A5VA.js";import{c as L,e as k,g as w}from"./73N3TOJL.js";import{a as c}from"./5YS5V2LK.js";import{a as A}from"./JXOEJPJ4.js";import{Buffer as ee}from"node:buffer";import{decodeEventLog as ae,encodeFunctionData as P,getAddress as oe,hexToString as se,parseAbiItem as de,toEventSelector as ne}from"viem";var _e={register:"erc8004_register"},re="https://eips.ethereum.org/EIPS/eip-8004#registration-v1",ce={type:"object",required:["type","name","description","image","services","x402Support","active","registrations"],properties:{type:{const:re},name:{type:"string",minLength:1},description:{type:"string"},image:{type:"string"},services:{type:"array",items:{type:"object",required:["name","endpoint"]}},x402Support:{type:"boolean"},active:{type:"boolean"},registrations:{type:"array"},tags:{type:"array",items:{type:"string"}},supportedTrust:{type:"array",items:{type:"string"}}}};function D(e,t,a=!1){if(typeof e!="string"||!a&&!e.trim())throw new c(`Provide a valid profile ${t}.`)}function ge(e,t){D(e,t);try{let a=new URL(e);if(!["https:","ipfs:"].includes(a.protocol)||!a.hostname||a.username||a.password)throw new Error}catch{throw new c(`Profile ${t} must be an HTTPS or IPFS URI without credentials.`)}}function fe(e,t,a,n){let{registryId:d}=I(e);if(!k(t))throw new c("Provide a registration-v1 profile object.");if(a!==void 0&&typeof a!="boolean")throw new c("The tag option must be a boolean.");if(t.type!==re)throw new c("Use the ERC-8004 registration-v1 profile type.");if(D(t.name,"name"),D(t.description,"description",!0),ge(t.image,"image"),typeof t.active!="boolean"||typeof t.x402Support!="boolean")throw new c("Profile active and x402Support must be booleans.");if(!Array.isArray(t.services)||!Array.isArray(t.registrations))throw new c("Profile services and registrations must be arrays.");for(let r of t.services)Z(r);for(let r of["tags","supportedTrust"])if(t[r]!==void 0&&(!Array.isArray(t[r])||!t[r].every(f=>typeof f=="string"&&f.trim())))throw new c(`Profile ${r} must be an array of nonempty strings.`);let s=t.registrations.map(r=>{if(!k(r)||typeof r.agentRegistry!="string"||!/^eip155:[1-9][0-9]*:0x[0-9a-fA-F]{40}$/.test(r.agentRegistry))throw new c("Provide a valid agentRegistry for every registration.");let f=typeof r.agentId=="number"&&Number.isSafeInteger(r.agentId)?String(r.agentId):r.agentId,p=v(f);if(w(r.agentRegistry,d)){if(n===void 0)throw new c("Do not predict a registration ID; obtain it from the mined Registered receipt.");if(p!==n)throw new c("Profile registration ID does not match the agent being updated.")}return{...r}});n!==void 0&&!s.some(r=>w(r.agentRegistry,d))&&s.push({agentId:n.toString(),agentRegistry:d});let i=[...new Set((t.tags??[]).filter(r=>r!==R))];a!==!1&&i.push(R);let g={...t,registrations:s,...i.length?{tags:i}:{}};i.length||delete g.tags;let o;try{if(o=JSON.stringify(g),ee.byteLength(o)>65536)throw new Error;JSON.parse(o)}catch{throw new c("Profile must be JSON data no larger than 64 KiB.")}return`data:application/json;base64,${ee.from(o,"utf8").toString("base64")}`}async function x(e,t){try{let{chainId:a,registry:n}=I(e),d=v(t),s=e.clientFor(a),i=await s.readContract({address:n,abi:h,functionName:"ownerOf",args:[d]});N(i);let[g,o,r]=await Promise.all([s.readContract({address:n,abi:h,functionName:"tokenURI",args:[d]}),s.readContract({address:n,abi:h,functionName:"getAgentWallet",args:[d]}),s.readContract({address:n,abi:h,functionName:"getMetadata",args:[d,R]})]);if(N(o),typeof g!="string"||typeof r!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(r))throw new c("The registry returned invalid identity data.");return{agentId:d.toString(),chainId:a,registry:n,owner:i,uri:g,agentWallet:o,registrarMetadata:r,registryValidated:!1,summary:B}}catch(a){throw new c(e.plainError(a))}}async function $e(e,t){let a=await x(e,t);return{...a,uri:A(a.uri)}}async function ue(e,t,a,n,d,s){let{registry:i}=I(e),g=await F(e,t,a,d),o=s===void 0?"Registered":"URIUpdated",r=ne(s===void 0?"Registered(uint256,string,address)":"URIUpdated(uint256,string,address)"),f=g.logs.filter(T=>w(T.address,i)&&T.topics[0]===r&&!T.removed);if(f.length!==1)throw new c(`The receipt must contain one matching ${o} event.`);let p=f[0],u=ae({abi:h,eventName:o,topics:p.topics,data:p.data,strict:!0}),b=u.args.agentId,l=u.eventName==="Registered"?u.args.agentURI:u.args.newURI,y=u.eventName==="Registered"?u.args.owner:u.args.updatedBy;if(s!==void 0&&b!==s||l!==n||!w(y,a))throw new c("The registry event does not match the expected agent, URI and wallet.");let m=await x(e,b.toString());if(m.uri!==n||s===void 0&&!w(m.owner,a))throw new c("The current agent owner or URI does not match the confirmed operation.");return m}function H(e,t){let{chainId:a,registry:n}=I(e);return e.unsignedTx({to:n,chainId:a,value:"0",data:P({abi:h,functionName:"setMetadata",args:[t,R,S]}),description:`Set mutable oak.registrar metadata to oak for agent ${t}.`})}async function le(e,t,a,n){let{registry:d}=I(e),s=v(n.agentId),i=await F(e,t,a,H(e,s).data),g=ne("MetadataSet(uint256,string,string,bytes)"),o=i.logs.filter(u=>w(u.address,d)&&u.topics[0]===g&&!u.removed);if(o.length!==1)throw new c("The receipt must contain one matching MetadataSet event.");let r=o[0],{args:f}=ae({abi:h,eventName:"MetadataSet",topics:r.topics,data:r.data,strict:!0});if(f.agentId!==s||f.metadataKey!==R||f.metadataValue!==S)throw new c("The metadata event does not match this agent and registrar marker.");let p=await x(e,n.agentId);if(p.registrarMetadata!==S||p.uri!==n.uri||!w(p.owner,n.owner))throw new c("The current agent metadata, owner or URI does not match the confirmed operation.");return p}async function pe(e,t){let{chainId:a,registry:n}=I(e),d=e.clientFor(a),s=await d.readContract({address:n,abi:h,functionName:"balanceOf",args:[t]});if(s===0n)return;if(typeof s!="bigint"||s<0n)throw new c("Registry balance is unavailable; registration was not built.");let i=await d.getBlockNumber({cacheTime:0}),g=new Set;for(;;){let o=i>9999999n?i-9999999n:0n,r=await d.getLogs({address:n,event:de("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:t},fromBlock:o,toBlock:i,strict:!0});for(let f of r){let p=f.args.tokenId.toString();if(f.removed||g.has(p))continue;g.add(p);let u=await x(e,p);if(w(u.owner,t))return u}if(o===0n)throw new c("Owned identity could not be located; registration was not built. Run oak setup link <agentId>.");i=o-1n}}function me(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>16)throw new c("Provide at most 16 metadata entries as { key, value } with value as 0x hex or text.");let t=new Set;return e.map(a=>{if(!k(a))throw new c("Provide each metadata entry as { key, value } or { key, text }.");let n=J(a.key);if(t.has(n))throw new c(`Metadata key ${A(n)} is repeated.`);return t.add(n),{metadataKey:n,metadataValue:G(a)}})}function ie(e,t,a){let n=W(t);if(!n)return;let{registryId:d}=I(e);return Array.isArray(n.registrations)&&n.registrations.some(s=>k(s)&&typeof s.agentRegistry=="string"&&w(s.agentRegistry,d)&&String(s.agentId)===a.toString())}function he(e,t,a){let n=ie(e,t.uri,BigInt(t.agentId));return n===!0?{...t,profileComplete:!0}:{...t,profileComplete:n===void 0?null:!1,nextStep:{tool:"erc8004_update",arguments:{agentId:t.agentId,profile:a??"a registration-v1 profile object"},why:"The minted profile does not list its own registry and agent ID yet (registrations is empty). erc8004_update appends it automatically. It is a normal action: it needs a verified identity link and an active subscription, so link with oak_setup first."}}}async function te(e,t,a,n){let{chainId:d,registry:s}=I(e);N(n),q(e,a.chainId);let i=t?v(a.agentId):void 0,g=!t&&a.profile===void 0,o=g?"":fe(e,a.profile,a.tag,i),r=t?[]:me(a.metadata);if(g&&r.length)throw new c("Metadata entries are registered together with a profile; provide a profile, or set metadata afterwards with erc8004_set_metadata.");let f=a.tag!==!1;if(a.metadataTransactionHash!==void 0&&(!f||a.transactionHash===void 0))throw new c("A metadata transaction hash requires tagging and the profile transaction hash.");let p=i!==void 0?P({abi:h,functionName:"setAgentURI",args:[i,o]}):r.length?P({abi:h,functionName:"register",args:[o,r]}):g?P({abi:h,functionName:"register"}):P({abi:h,functionName:"register",args:[o]}),u=l=>i===void 0?he(e,l,a.profile):l;if(a.transactionHash!==void 0){let l=await ue(e,a.transactionHash,n,o,p,i);if(!f)return u(l);if(a.metadataTransactionHash!==void 0)return u(await le(e,a.metadataTransactionHash,n,l));let y=v(l.agentId);await O(e,y,n);let m=await U(e,[H(e,y)],n,`Profile transaction confirmed for agent ${y}; onchain registrar metadata is pending. Submit this metadata transaction locally if not already submitted, then repeat the original arguments with transactionHash and metadataTransactionHash to verify both calls.`);return{...l,...m}}if(!t){let l=await pe(e,n);if(l){let y={...l,registrationResumed:!0};if(!f||l.registrarMetadata===S)return u(y);let m=await U(e,[H(e,v(l.agentId))],n,`Resume registrar metadata for owned agent ${l.agentId}; no new identity will be minted.`);return{...y,...m}}}i!==void 0&&await O(e,i,n);let b=[e.unsignedTx({to:s,data:p,value:"0",chainId:d,description:i===void 0?"Register an ERC-8004 agent profile.":`Update ERC-8004 agent ${i} profile.`})];return i!==void 0&&f&&b.push(H(e,i)),U(e,b,n,`Submit locally, then repeat the original arguments with transactionHash to verify the profile receipt and URI.${f?i===void 0?" The mined Registered event supplies the actual agent ID; confirmation then builds a separate setMetadata transaction for oak.registrar. Both transactions require network gas.":" Submit the profile and metadata transactions in order, then supply metadataTransactionHash as well to verify the onchain oak.registrar marker. Both transactions require network gas.":" No registrar metadata transaction is built; --no-tag does not clear existing onchain metadata."}${i===void 0?" Update the profile registrations with the mined ID afterward.":""}`)}async function ye(e,t){let a=await x(e,t.agentId),{chainId:n,registry:d}=I(e),s=e.clientFor(n),i=BigInt(a.agentId),g=t.metadataKeys===void 0?[]:(()=>{if(!Array.isArray(t.metadataKeys)||t.metadataKeys.length>16)throw new c("Provide at most 16 metadata keys.");return t.metadataKeys.map(m=>V(m,"metadata key",128,!1))})(),o=t.operator===void 0?void 0:oe(String(t.operator)),[r,f,...p]=await Promise.allSettled([s.readContract({address:d,abi:h,functionName:"getApproved",args:[i]}),o?s.readContract({address:d,abi:h,functionName:"isApprovedForAll",args:[a.owner,o]}):Promise.resolve(void 0),...g.map(m=>s.readContract({address:d,abi:h,functionName:"getMetadata",args:[i,m]}))]),u=m=>m.status==="fulfilled"?m.value:void 0,b=u(r),l=E(a.agentWallet)?"unset":w(a.agentWallet,a.owner)?"owner":"verified-other",y=ie(e,a.uri,i);return{...a,approved:typeof b=="string"&&E(b)?null:b??"unavailable",...o?{operator:o,operatorApproved:u(f)??"unavailable"}:{},walletState:l,walletNote:l==="unset"?"No verified payment wallet: it starts as the minting owner, and any NFT transfer or erc8004_unset_wallet clears it. Re-verify with erc8004_wallet_proof then erc8004_set_wallet.":l==="owner"?"The payment wallet is the current owner.":"The payment wallet was proven by a signature from that wallet and is not the owner.",profile:{selfRegistered:y??null,fetched:!1,note:y===void 0?"The URI is external or not decodable; Oak does not fetch it.":void 0},...g.length?{metadata:Object.fromEntries(g.map((m,T)=>{let _=u(p[T]),M=typeof _=="string"&&/^0x([0-9a-fA-F]{2})*$/.test(_)?_:void 0,C;if(M&&M!=="0x")try{C=A(se(M))}catch{C=void 0}return[A(m),{hex:M??"unavailable",...C?{text:C}:{}}]}))}:{}}}var we={type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:128},value:K,text:{type:"string"}}},Ie=e=>{let t=(n,d,s)=>({name:n,inputSchema:d,execute:async(i,g)=>{try{let o=await s(i,g);return k(o)&&typeof o.uri=="string"?{...o,uri:A(o.uri)}:o}catch(o){throw new c(e.plainError(o))}}}),a=n=>({type:"object",additionalProperties:!1,required:n?["agentId","profile"]:[],properties:{profile:{...ce,description:n?void 0:"Omit for the standard blank register(): the profile is attached later with erc8004_update."},tag:{type:"boolean",default:!0,description:"Set false for --no-tag; removes the profile tag and skips setMetadata, leaving existing onchain metadata unchanged."},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"After local submission, verify exact calldata, event and URI; if tagged, build the metadata follow-up unless metadataTransactionHash is supplied."},metadataTransactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hash of the separate setMetadata transaction; supplied with transactionHash to complete tagged confirmation."},...n?{agentId:$}:{metadata:{type:"array",maxItems:16,items:we,description:"Optional extra onchain metadata written by register(agentURI, metadata[]). The key agentWallet is reserved."}}}});return{tools:[t("erc8004_register",a(!1),(n,d)=>te(e,!1,n,d)),t("erc8004_update",a(!0),(n,d)=>te(e,!0,n,d)),t("erc8004_identity",{type:"object",additionalProperties:!1,required:["agentId"],properties:{agentId:$,metadataKeys:{type:"array",maxItems:16,items:{type:"string",minLength:1,maxLength:128},description:"Also read these onchain metadata keys."},operator:{...L,description:"Also report whether this address is approved for all of the owner's agents."}}},n=>ye(e,n))]}},Ee=e=>j("erc8004",[Ie(e),Q(e),X(e),Y(e),z(e)]);export{_e as a,$e as b,ie as c,Ie as d,Ee as e};
1
+ import{b as z}from"./QYYFRAWY.js";import{c as Q}from"./TQL7UDFL.js";import{b as X}from"./PTAWEHKB.js";import{b as Z}from"./ALK6NKFP.js";import{a as Y}from"./PARWLWXW.js";import{a as B,b as R,c as S,d as $,g as K,h as I,k as E,l as v,n as q,p as V,r as W,s as U,t as O,v as F,x as J,y as G}from"./TWSTOFN3.js";import{a as h}from"./X5V2Z2NM.js";import{b as j}from"./AXYOJBX6.js";import{a as N}from"./6IM6A5VA.js";import{c as L,e as k,g as w}from"./73N3TOJL.js";import{a as c}from"./5YS5V2LK.js";import{a as A}from"./JXOEJPJ4.js";import{Buffer as ee}from"node:buffer";import{decodeEventLog as ae,encodeFunctionData as P,getAddress as oe,hexToString as se,parseAbiItem as de,toEventSelector as ne}from"viem";var _e={register:"erc8004_register"},re="https://eips.ethereum.org/EIPS/eip-8004#registration-v1",ce={type:"object",required:["type","name","description","image","services","x402Support","active","registrations"],properties:{type:{const:re},name:{type:"string",minLength:1},description:{type:"string"},image:{type:"string"},services:{type:"array",items:{type:"object",required:["name","endpoint"]}},x402Support:{type:"boolean"},active:{type:"boolean"},registrations:{type:"array"},tags:{type:"array",items:{type:"string"}},supportedTrust:{type:"array",items:{type:"string"}}}};function D(e,t,a=!1){if(typeof e!="string"||!a&&!e.trim())throw new c(`Provide a valid profile ${t}.`)}function ge(e,t){D(e,t);try{let a=new URL(e);if(!["https:","ipfs:"].includes(a.protocol)||!a.hostname||a.username||a.password)throw new Error}catch{throw new c(`Profile ${t} must be an HTTPS or IPFS URI without credentials.`)}}function fe(e,t,a,n){let{registryId:d}=I(e);if(!k(t))throw new c("Provide a registration-v1 profile object.");if(a!==void 0&&typeof a!="boolean")throw new c("The tag option must be a boolean.");if(t.type!==re)throw new c("Use the ERC-8004 registration-v1 profile type.");if(D(t.name,"name"),D(t.description,"description",!0),ge(t.image,"image"),typeof t.active!="boolean"||typeof t.x402Support!="boolean")throw new c("Profile active and x402Support must be booleans.");if(!Array.isArray(t.services)||!Array.isArray(t.registrations))throw new c("Profile services and registrations must be arrays.");for(let r of t.services)Z(r);for(let r of["tags","supportedTrust"])if(t[r]!==void 0&&(!Array.isArray(t[r])||!t[r].every(f=>typeof f=="string"&&f.trim())))throw new c(`Profile ${r} must be an array of nonempty strings.`);let s=t.registrations.map(r=>{if(!k(r)||typeof r.agentRegistry!="string"||!/^eip155:[1-9][0-9]*:0x[0-9a-fA-F]{40}$/.test(r.agentRegistry))throw new c("Provide a valid agentRegistry for every registration.");let f=typeof r.agentId=="number"&&Number.isSafeInteger(r.agentId)?String(r.agentId):r.agentId,p=v(f);if(w(r.agentRegistry,d)){if(n===void 0)throw new c("Do not predict a registration ID; obtain it from the mined Registered receipt.");if(p!==n)throw new c("Profile registration ID does not match the agent being updated.")}return{...r}});n!==void 0&&!s.some(r=>w(r.agentRegistry,d))&&s.push({agentId:n.toString(),agentRegistry:d});let i=[...new Set((t.tags??[]).filter(r=>r!==R))];a!==!1&&i.push(R);let g={...t,registrations:s,...i.length?{tags:i}:{}};i.length||delete g.tags;let o;try{if(o=JSON.stringify(g),ee.byteLength(o)>65536)throw new Error;JSON.parse(o)}catch{throw new c("Profile must be JSON data no larger than 64 KiB.")}return`data:application/json;base64,${ee.from(o,"utf8").toString("base64")}`}async function x(e,t){try{let{chainId:a,registry:n}=I(e),d=v(t),s=e.clientFor(a),i=await s.readContract({address:n,abi:h,functionName:"ownerOf",args:[d]});N(i);let[g,o,r]=await Promise.all([s.readContract({address:n,abi:h,functionName:"tokenURI",args:[d]}),s.readContract({address:n,abi:h,functionName:"getAgentWallet",args:[d]}),s.readContract({address:n,abi:h,functionName:"getMetadata",args:[d,R]})]);if(N(o),typeof g!="string"||typeof r!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(r))throw new c("The registry returned invalid identity data.");return{agentId:d.toString(),chainId:a,registry:n,owner:i,uri:g,agentWallet:o,registrarMetadata:r,registryValidated:!1,summary:B}}catch(a){throw new c(e.plainError(a))}}async function $e(e,t){let a=await x(e,t);return{...a,uri:A(a.uri)}}async function ue(e,t,a,n,d,s){let{registry:i}=I(e),g=await F(e,t,a,d),o=s===void 0?"Registered":"URIUpdated",r=ne(s===void 0?"Registered(uint256,string,address)":"URIUpdated(uint256,string,address)"),f=g.logs.filter(T=>w(T.address,i)&&T.topics[0]===r&&!T.removed);if(f.length!==1)throw new c(`The receipt must contain one matching ${o} event.`);let p=f[0],u=ae({abi:h,eventName:o,topics:p.topics,data:p.data,strict:!0}),b=u.args.agentId,l=u.eventName==="Registered"?u.args.agentURI:u.args.newURI,y=u.eventName==="Registered"?u.args.owner:u.args.updatedBy;if(s!==void 0&&b!==s||l!==n||!w(y,a))throw new c("The registry event does not match the expected agent, URI and wallet.");let m=await x(e,b.toString());if(m.uri!==n||s===void 0&&!w(m.owner,a))throw new c("The current agent owner or URI does not match the confirmed operation.");return m}function H(e,t){let{chainId:a,registry:n}=I(e);return e.unsignedTx({to:n,chainId:a,value:"0",data:P({abi:h,functionName:"setMetadata",args:[t,R,S]}),description:`Set mutable oak.registrar metadata to oak for agent ${t}.`})}async function le(e,t,a,n){let{registry:d}=I(e),s=v(n.agentId),i=await F(e,t,a,H(e,s).data),g=ne("MetadataSet(uint256,string,string,bytes)"),o=i.logs.filter(u=>w(u.address,d)&&u.topics[0]===g&&!u.removed);if(o.length!==1)throw new c("The receipt must contain one matching MetadataSet event.");let r=o[0],{args:f}=ae({abi:h,eventName:"MetadataSet",topics:r.topics,data:r.data,strict:!0});if(f.agentId!==s||f.metadataKey!==R||f.metadataValue!==S)throw new c("The metadata event does not match this agent and registrar marker.");let p=await x(e,n.agentId);if(p.registrarMetadata!==S||p.uri!==n.uri||!w(p.owner,n.owner))throw new c("The current agent metadata, owner or URI does not match the confirmed operation.");return p}async function pe(e,t){let{chainId:a,registry:n}=I(e),d=e.clientFor(a),s=await d.readContract({address:n,abi:h,functionName:"balanceOf",args:[t]});if(s===0n)return;if(typeof s!="bigint"||s<0n)throw new c("Registry balance is unavailable; registration was not built.");let i=await d.getBlockNumber({cacheTime:0}),g=new Set;for(;;){let o=i>9999999n?i-9999999n:0n,r=await d.getLogs({address:n,event:de("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:t},fromBlock:o,toBlock:i,strict:!0});for(let f of r){let p=f.args.tokenId.toString();if(f.removed||g.has(p))continue;g.add(p);let u=await x(e,p);if(w(u.owner,t))return u}if(o===0n)throw new c("Owned identity could not be located; registration was not built. Run oak setup link <agentId>.");i=o-1n}}function me(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>16)throw new c("Provide at most 16 metadata entries as { key, value } with value as 0x hex or text.");let t=new Set;return e.map(a=>{if(!k(a))throw new c("Provide each metadata entry as { key, value } or { key, text }.");let n=J(a.key);if(t.has(n))throw new c(`Metadata key ${A(n)} is repeated.`);return t.add(n),{metadataKey:n,metadataValue:G(a)}})}function ie(e,t,a){let n=W(t);if(!n)return;let{registryId:d}=I(e);return Array.isArray(n.registrations)&&n.registrations.some(s=>k(s)&&typeof s.agentRegistry=="string"&&w(s.agentRegistry,d)&&String(s.agentId)===a.toString())}function he(e,t,a){let n=ie(e,t.uri,BigInt(t.agentId));return n===!0?{...t,profileComplete:!0}:{...t,profileComplete:n===void 0?null:!1,nextStep:{tool:"erc8004_update",arguments:{agentId:t.agentId,profile:a??"a registration-v1 profile object"},why:"The minted profile does not list its own registry and agent ID yet (registrations is empty). erc8004_update appends it automatically. It is a normal action: it needs a verified identity link and an active subscription, so link with oak_setup first."}}}async function te(e,t,a,n){let{chainId:d,registry:s}=I(e);N(n),q(e,a.chainId);let i=t?v(a.agentId):void 0,g=!t&&a.profile===void 0,o=g?"":fe(e,a.profile,a.tag,i),r=t?[]:me(a.metadata);if(g&&r.length)throw new c("Metadata entries are registered together with a profile; provide a profile, or set metadata afterwards with erc8004_set_metadata.");let f=a.tag!==!1;if(a.metadataTransactionHash!==void 0&&(!f||a.transactionHash===void 0))throw new c("A metadata transaction hash requires tagging and the profile transaction hash.");let p=i!==void 0?P({abi:h,functionName:"setAgentURI",args:[i,o]}):r.length?P({abi:h,functionName:"register",args:[o,r]}):g?P({abi:h,functionName:"register"}):P({abi:h,functionName:"register",args:[o]}),u=l=>i===void 0?he(e,l,a.profile):l;if(a.transactionHash!==void 0){let l=await ue(e,a.transactionHash,n,o,p,i);if(!f)return u(l);if(a.metadataTransactionHash!==void 0)return u(await le(e,a.metadataTransactionHash,n,l));let y=v(l.agentId);await O(e,y,n);let m=await U(e,[H(e,y)],n,`Profile transaction confirmed for agent ${y}; onchain registrar metadata is pending. Submit this metadata transaction locally if not already submitted, then repeat the original arguments with transactionHash and metadataTransactionHash to verify both calls.`);return{...l,...m}}if(!t){let l=await pe(e,n);if(l){let y={...l,registrationResumed:!0};if(!f||l.registrarMetadata===S)return u(y);let m=await U(e,[H(e,v(l.agentId))],n,`Resume registrar metadata for owned agent ${l.agentId}; no new identity will be minted.`);return{...y,...m}}}i!==void 0&&await O(e,i,n);let b=[e.unsignedTx({to:s,data:p,value:"0",chainId:d,description:i===void 0?"Register an ERC-8004 agent profile.":`Update ERC-8004 agent ${i} profile.`})];return i!==void 0&&f&&b.push(H(e,i)),U(e,b,n,`Submit locally, then repeat the original arguments with transactionHash to verify the profile receipt and URI.${f?i===void 0?" The mined Registered event supplies the actual agent ID; confirmation then builds a separate setMetadata transaction for oak.registrar. Both transactions require network gas.":" Submit the profile and metadata transactions in order, then supply metadataTransactionHash as well to verify the onchain oak.registrar marker. Both transactions require network gas.":" No registrar metadata transaction is built; --no-tag does not clear existing onchain metadata."}${i===void 0?" Update the profile registrations with the mined ID afterward.":""}`)}async function ye(e,t){let a=await x(e,t.agentId),{chainId:n,registry:d}=I(e),s=e.clientFor(n),i=BigInt(a.agentId),g=t.metadataKeys===void 0?[]:(()=>{if(!Array.isArray(t.metadataKeys)||t.metadataKeys.length>16)throw new c("Provide at most 16 metadata keys.");return t.metadataKeys.map(m=>V(m,"metadata key",128,!1))})(),o=t.operator===void 0?void 0:oe(String(t.operator)),[r,f,...p]=await Promise.allSettled([s.readContract({address:d,abi:h,functionName:"getApproved",args:[i]}),o?s.readContract({address:d,abi:h,functionName:"isApprovedForAll",args:[a.owner,o]}):Promise.resolve(void 0),...g.map(m=>s.readContract({address:d,abi:h,functionName:"getMetadata",args:[i,m]}))]),u=m=>m.status==="fulfilled"?m.value:void 0,b=u(r),l=E(a.agentWallet)?"unset":w(a.agentWallet,a.owner)?"owner":"verified-other",y=ie(e,a.uri,i);return{...a,approved:typeof b=="string"&&E(b)?null:b??"unavailable",...o?{operator:o,operatorApproved:u(f)??"unavailable"}:{},walletState:l,walletNote:l==="unset"?"No verified payment wallet: it starts as the minting owner, and any NFT transfer or erc8004_unset_wallet clears it. Re-verify with erc8004_wallet_proof then erc8004_set_wallet.":l==="owner"?"The payment wallet is the current owner.":"The payment wallet was proven by a signature from that wallet and is not the owner.",profile:{selfRegistered:y??null,fetched:!1,note:y===void 0?"The URI is external or not decodable; Oak does not fetch it.":void 0},...g.length?{metadata:Object.fromEntries(g.map((m,T)=>{let _=u(p[T]),M=typeof _=="string"&&/^0x([0-9a-fA-F]{2})*$/.test(_)?_:void 0,C;if(M&&M!=="0x")try{C=A(se(M))}catch{C=void 0}return[A(m),{hex:M??"unavailable",...C?{text:C}:{}}]}))}:{}}}var we={type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:128},value:K,text:{type:"string"}}},Ie=e=>{let t=(n,d,s)=>({name:n,inputSchema:d,execute:async(i,g)=>{try{let o=await s(i,g);return k(o)&&typeof o.uri=="string"?{...o,uri:A(o.uri)}:o}catch(o){throw new c(e.plainError(o))}}}),a=n=>({type:"object",additionalProperties:!1,required:n?["agentId","profile"]:[],properties:{profile:{...ce,description:n?void 0:"Omit for the standard blank register(): the profile is attached later with erc8004_update."},tag:{type:"boolean",default:!0,description:"Set false for --no-tag; removes the profile tag and skips setMetadata, leaving existing onchain metadata unchanged."},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"After local submission, verify exact calldata, event and URI; if tagged, build the metadata follow-up unless metadataTransactionHash is supplied."},metadataTransactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hash of the separate setMetadata transaction; supplied with transactionHash to complete tagged confirmation."},...n?{agentId:$}:{metadata:{type:"array",maxItems:16,items:we,description:"Optional extra onchain metadata written by register(agentURI, metadata[]). The key agentWallet is reserved."}}}});return{tools:[t("erc8004_register",a(!1),(n,d)=>te(e,!1,n,d)),t("erc8004_update",a(!0),(n,d)=>te(e,!0,n,d)),t("erc8004_identity",{type:"object",additionalProperties:!1,required:["agentId"],properties:{agentId:$,metadataKeys:{type:"array",maxItems:16,items:{type:"string",minLength:1,maxLength:128},description:"Also read these onchain metadata keys."},operator:{...L,description:"Also report whether this address is approved for all of the owner's agents."}}},n=>ye(e,n))]}},Ee=e=>j("erc8004",[Ie(e),Q(e),X(e),Y(e),z(e)]);export{_e as a,$e as b,ie as c,Ie as d,Ee as e};
@@ -1 +1 @@
1
- import{a as y,b as T,c as S,f as d,g as b,h as O,i as E,j as R,k,l as V}from"./5EHQM6DM.js";import{c as M}from"./MYBDO5SA.js";import{c as f,e as C,g as A}from"./73N3TOJL.js";import{a as D}from"./XPFVT2EA.js";import{a as r}from"./5YS5V2LK.js";import{concat as z,encodeAbiParameters as _,encodeFunctionData as P,keccak256 as B,parseAbi as U,parseAbiParameters as j}from"viem";var I=U(["function allocation(address) view returns (address token,uint256 amountTotal,uint256 amountClaimed,uint256 lockupEndTime,uint256 vestingEndTime,address admin)","function amountAvailableToClaim(address) view returns (uint256)","function claim(address)","function editAllocationAdmin(address,address)"]),$=U(["function airdrops(address) view returns (address admin,bytes32 merkleRoot,uint256 totalSupply,uint256 totalClaimed,uint256 lockupEndTime,uint256 vestingEndTime,uint256 adminClaimTime,bool adminClaimed)","function amountAvailableToClaim(address,address,uint256) view returns (uint256)","function claim(address,address,uint256,bytes32[])","function updateAdmin(address,address)","function updateMerkleRoot(address,bytes32)","function adminClaim(address,address)"]),F={bps:{type:"integer",minimum:1,maximum:9e3},admin:f,lockupDuration:T,vestingDuration:T},X={vault:{type:"object",properties:F,required:["bps","lockupDuration","vestingDuration"],additionalProperties:!1},airdrop:{type:"object",properties:{...F,merkleRoot:S},required:["bps","lockupDuration","vestingDuration","merkleRoot"],additionalProperties:!1}};function Y(u,h){let g=[];for(let p of["vault","airdrop"]){let l=u[p];if(l===void 0)continue;if(!C(l))throw new r(`Provide ${p} configuration as an object.`);E(l,["bps","admin","lockupDuration","vestingDuration",...p==="airdrop"?["merkleRoot"]:[]]);let w=d(l.admin??h),v=b(l.lockupDuration),e=b(l.vestingDuration);if(v<BigInt(p==="vault"?604800:86400))throw new r(`${p} lockup is below the contract minimum.`);if(v+e+1209600n>=1n<<256n)throw new r("Extension duration exceeds uint256.");g.push({extension:y[p].address,msgValue:0n,extensionBps:O(l.bps,1,9e3),extensionData:p==="vault"?_(j("(address,uint256,uint256)"),[[w,v,e]]):_(j("(address,bytes32,uint256,uint256)"),[[w,R(l.merkleRoot),v,e]])})}if(g.reduce((p,l)=>p+l.extensionBps,0)>9e3)throw new r("Extensions must leave at least 10% of supply for liquidity.");return g}function H(u,h){return B(B(_(j("address,uint256"),[u,h])))}function N(u,h){return B(z(BigInt(u)<BigInt(h)?[u,h]:[h,u]))}var Z=u=>{let h=()=>u.clientFor(D),g=async(e,t)=>{if(!(await V(u,e)).extensions.some(a=>A(a,y[t].address)))throw new r(`This token has no verified Clanker ${t} extension.`)},p=async e=>{await g(e,"vault");let t=await h().readContract({address:y.vault.address,abi:I,functionName:"allocation",args:[e]});if(!Array.isArray(t)||t.length!==6||!A(d(t[0]),e))throw new r("Clanker returned an invalid vault allocation.");return{token:e,amountTotal:k(t[1]),amountClaimed:k(t[2]),lockupEndTime:k(t[3]),vestingEndTime:k(t[4]),admin:d(t[5]),claimable:k(await h().readContract({address:y.vault.address,abi:I,functionName:"amountAvailableToClaim",args:[e]}))}},l=async e=>{await g(e,"airdrop");let t=await h().readContract({address:y.airdrop.address,abi:$,functionName:"airdrops",args:[e]});if(!Array.isArray(t)||t.length!==8||typeof t[7]!="boolean")throw new r("Clanker returned invalid airdrop state.");return{token:e,admin:d(t[0]),merkleRoot:R(t[1]),totalSupply:k(t[2]),totalClaimed:k(t[3]),lockupEndTime:k(t[4]),vestingEndTime:k(t[5]),adminClaimTime:k(t[6]),adminClaimed:t[7]}},w=(e,t,n,a)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:n,additionalProperties:!1},execute:async(s,o)=>{try{return E(s,Object.keys(t)),await a(s,d(o))}catch(i){throw new r(u.plainError(i))}}}),v=async(e,t,n,a)=>{let s=[u.unsignedTx({to:e,data:t,chainId:D,value:"0",description:n})],o=await u.preview(s,a);return{txs:s,preview:o,summary:`${n} ${o.summary}`}};return{tools:[w("airdrop_proofs",{token:f},["token"],async(e,t)=>{let n=d(e.token),a=await l(n),s=new URL("https://www.clanker.world/api/airdrops/claim");s.searchParams.set("tokenAddress",n),s.searchParams.set("claimerAddress",t);let i=(await M(u.http,s.toString(),{method:"GET"},m=>C(m)&&Array.isArray(m.proofs))).proofs;if(i.length>200)throw new r("Clanker returned too many airdrop proofs.");let c=i.map(m=>{if(!C(m)||!C(m.entry)||!Array.isArray(m.proof)||m.proof.length>64||!A(d(m.entry.account),t))throw new r("Clanker returned invalid airdrop proofs.");let x=b(m.entry.amount),q=m.proof.map(R);if(!x||!A(q.reduce(N,H(t,x)),a.merkleRoot))throw new r("The indexed airdrop proof does not match the active onchain root.");return{allocatedAmount:x.toString(),proof:q}});return{token:n,chainId:D,recipient:t,proofs:c,summary:"Verified against the onchain airdrop root. An empty indexer response does not prove ineligibility; use saved allocation proofs if the tree was not published."}}),w("vault_status",{token:f},["token"],e=>p(d(e.token))),w("vault_claim",{token:f},["token"],async(e,t)=>{let n=d(e.token),a=await p(n);if(a.claimable==="0")throw new r("No vested Clanker tokens are available to claim.");return v(y.vault.address,P({abi:I,functionName:"claim",args:[n]}),`Claim ${a.claimable} base units of ${n} (18 decimals) to vault admin ${a.admin}.`,t)}),w("vault_update_admin",{token:f,admin:f},["token","admin"],async(e,t)=>{let n=d(e.token),a=await p(n);if(!A(a.admin,t))throw new r("Only the vault administrator can transfer its allocation.");return v(y.vault.address,P({abi:I,functionName:"editAllocationAdmin",args:[n,d(e.admin)]}),`Transfer all future Clanker vault claims for ${n} to ${d(e.admin)}.`,t)}),w("airdrop_tree",{allocations:{type:"array",minItems:1,maxItems:200,items:{type:"object",properties:{recipient:f,amount:T},required:["recipient","amount"],additionalProperties:!1}}},["allocations"],async e=>{if(!Array.isArray(e.allocations)||!e.allocations.length||e.allocations.length>200)throw new r("Provide 1 to 200 airdrop allocations.");let t=new Set,n=e.allocations.map(o=>{if(!C(o))throw new r("Provide allocation objects.");E(o,["recipient","amount"]);let i=d(o.recipient),c=b(o.amount);if(!c||t.has(i))throw new r("Airdrop allocations require positive amounts and unique recipients.");return t.add(i),{recipient:i,amount:c.toString(),hash:H(i,c)}}).sort((o,i)=>o.hash.localeCompare(i.hash)),a=[n.map(o=>o.hash)];for(;a.at(-1).length>1;){let o=a.at(-1),i=[];for(let c=0;c<o.length;c+=2)i.push(c+1<o.length?N(o[c],o[c+1]):o[c]);a.push(i)}let s=n.reduce((o,i)=>o+BigInt(i.amount),0n);if(s>=1n<<256n)throw new r("Airdrop total exceeds uint256.");return{merkleRoot:a.at(-1)[0],total:s.toString(),allocations:n.map((o,i)=>{let c=[],m=i;for(let x of a.slice(0,-1))x[m^1]&&c.push(x[m^1]),m=Math.floor(m/2);return{recipient:o.recipient,amount:o.amount,proof:c}}),summary:"Double-hashed ABI(address,uint256) leaves; sorted hash pairs. Save these public proofs. Allocations are token base units, 18 decimals; match their total to the launch extension supply."}}),w("airdrop_status",{token:f,allocatedAmount:T},["token"],async(e,t)=>{let n=d(e.token);return{...await l(n),...e.allocatedAmount===void 0?{}:{claimable:k(await h().readContract({address:y.airdrop.address,abi:$,functionName:"amountAvailableToClaim",args:[n,t,b(e.allocatedAmount)]}))}}}),w("airdrop_claim",{token:f,allocatedAmount:T,proof:{type:"array",maxItems:64,items:S}},["token","allocatedAmount","proof"],async(e,t)=>{let n=d(e.token),a=await l(n),s=b(e.allocatedAmount);if(!s||!Array.isArray(e.proof)||e.proof.length>64)throw new r("Provide a positive allocation and Merkle proof.");let o=e.proof.map(R),i=o.reduce(N,H(t,s));if(!A(i,a.merkleRoot))throw new r("The airdrop proof does not match the active root for this wallet and allocation.");return v(y.airdrop.address,P({abi:$,functionName:"claim",args:[n,t,s,o]}),`Claim vested allocation of ${s} base units of ${n} (18 decimals) to ${t}. Preview determines currently unlocked receipts.`,t)}),w("airdrop_manage",{token:f,operation:{enum:["admin","root","reclaim"]},admin:f,merkleRoot:S,recipient:f},["token","operation"],async(e,t)=>{let n=d(e.token),a=await l(n);if(!A(a.admin,t))throw new r("Only the airdrop administrator may manage it.");let s=e.operation==="admin"?"admin":e.operation==="root"?"merkleRoot":"recipient";for(let i of["admin","merkleRoot","recipient"])if(e[i]!==void 0&&i!==s)throw new r(`Input ${i} does not match this airdrop operation.`);let o;if(e.operation==="admin")o=P({abi:$,functionName:"updateAdmin",args:[n,d(e.admin)]});else if(e.operation==="root")o=P({abi:$,functionName:"updateMerkleRoot",args:[n,R(e.merkleRoot)]});else if(e.operation==="reclaim")o=P({abi:$,functionName:"adminClaim",args:[n,d(e.recipient)]});else throw new r("Choose admin, root or reclaim.");return v(y.airdrop.address,o,`Clanker airdrop ${String(e.operation)} for ${n}; ${String(e.admin??e.merkleRoot??e.recipient)}. Reclaim permanently closes recipient claims; contract timing and zero-claim guards apply.`,t)})]}};export{X as a,Y as b,Z as c};
1
+ import{a as y,b as T,c as S,f as d,g as b,h as O,i as E,j as R,k,l as V}from"./WQ6H62DM.js";import{c as M}from"./MYBDO5SA.js";import{c as f,e as C,g as A}from"./73N3TOJL.js";import{a as D}from"./G6HCV67X.js";import{a as r}from"./5YS5V2LK.js";import{concat as z,encodeAbiParameters as _,encodeFunctionData as P,keccak256 as B,parseAbi as U,parseAbiParameters as j}from"viem";var I=U(["function allocation(address) view returns (address token,uint256 amountTotal,uint256 amountClaimed,uint256 lockupEndTime,uint256 vestingEndTime,address admin)","function amountAvailableToClaim(address) view returns (uint256)","function claim(address)","function editAllocationAdmin(address,address)"]),$=U(["function airdrops(address) view returns (address admin,bytes32 merkleRoot,uint256 totalSupply,uint256 totalClaimed,uint256 lockupEndTime,uint256 vestingEndTime,uint256 adminClaimTime,bool adminClaimed)","function amountAvailableToClaim(address,address,uint256) view returns (uint256)","function claim(address,address,uint256,bytes32[])","function updateAdmin(address,address)","function updateMerkleRoot(address,bytes32)","function adminClaim(address,address)"]),F={bps:{type:"integer",minimum:1,maximum:9e3},admin:f,lockupDuration:T,vestingDuration:T},X={vault:{type:"object",properties:F,required:["bps","lockupDuration","vestingDuration"],additionalProperties:!1},airdrop:{type:"object",properties:{...F,merkleRoot:S},required:["bps","lockupDuration","vestingDuration","merkleRoot"],additionalProperties:!1}};function Y(u,h){let g=[];for(let p of["vault","airdrop"]){let l=u[p];if(l===void 0)continue;if(!C(l))throw new r(`Provide ${p} configuration as an object.`);E(l,["bps","admin","lockupDuration","vestingDuration",...p==="airdrop"?["merkleRoot"]:[]]);let w=d(l.admin??h),v=b(l.lockupDuration),e=b(l.vestingDuration);if(v<BigInt(p==="vault"?604800:86400))throw new r(`${p} lockup is below the contract minimum.`);if(v+e+1209600n>=1n<<256n)throw new r("Extension duration exceeds uint256.");g.push({extension:y[p].address,msgValue:0n,extensionBps:O(l.bps,1,9e3),extensionData:p==="vault"?_(j("(address,uint256,uint256)"),[[w,v,e]]):_(j("(address,bytes32,uint256,uint256)"),[[w,R(l.merkleRoot),v,e]])})}if(g.reduce((p,l)=>p+l.extensionBps,0)>9e3)throw new r("Extensions must leave at least 10% of supply for liquidity.");return g}function H(u,h){return B(B(_(j("address,uint256"),[u,h])))}function N(u,h){return B(z(BigInt(u)<BigInt(h)?[u,h]:[h,u]))}var Z=u=>{let h=()=>u.clientFor(D),g=async(e,t)=>{if(!(await V(u,e)).extensions.some(a=>A(a,y[t].address)))throw new r(`This token has no verified Clanker ${t} extension.`)},p=async e=>{await g(e,"vault");let t=await h().readContract({address:y.vault.address,abi:I,functionName:"allocation",args:[e]});if(!Array.isArray(t)||t.length!==6||!A(d(t[0]),e))throw new r("Clanker returned an invalid vault allocation.");return{token:e,amountTotal:k(t[1]),amountClaimed:k(t[2]),lockupEndTime:k(t[3]),vestingEndTime:k(t[4]),admin:d(t[5]),claimable:k(await h().readContract({address:y.vault.address,abi:I,functionName:"amountAvailableToClaim",args:[e]}))}},l=async e=>{await g(e,"airdrop");let t=await h().readContract({address:y.airdrop.address,abi:$,functionName:"airdrops",args:[e]});if(!Array.isArray(t)||t.length!==8||typeof t[7]!="boolean")throw new r("Clanker returned invalid airdrop state.");return{token:e,admin:d(t[0]),merkleRoot:R(t[1]),totalSupply:k(t[2]),totalClaimed:k(t[3]),lockupEndTime:k(t[4]),vestingEndTime:k(t[5]),adminClaimTime:k(t[6]),adminClaimed:t[7]}},w=(e,t,n,a)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:n,additionalProperties:!1},execute:async(s,o)=>{try{return E(s,Object.keys(t)),await a(s,d(o))}catch(i){throw new r(u.plainError(i))}}}),v=async(e,t,n,a)=>{let s=[u.unsignedTx({to:e,data:t,chainId:D,value:"0",description:n})],o=await u.preview(s,a);return{txs:s,preview:o,summary:`${n} ${o.summary}`}};return{tools:[w("airdrop_proofs",{token:f},["token"],async(e,t)=>{let n=d(e.token),a=await l(n),s=new URL("https://www.clanker.world/api/airdrops/claim");s.searchParams.set("tokenAddress",n),s.searchParams.set("claimerAddress",t);let i=(await M(u.http,s.toString(),{method:"GET"},m=>C(m)&&Array.isArray(m.proofs))).proofs;if(i.length>200)throw new r("Clanker returned too many airdrop proofs.");let c=i.map(m=>{if(!C(m)||!C(m.entry)||!Array.isArray(m.proof)||m.proof.length>64||!A(d(m.entry.account),t))throw new r("Clanker returned invalid airdrop proofs.");let x=b(m.entry.amount),q=m.proof.map(R);if(!x||!A(q.reduce(N,H(t,x)),a.merkleRoot))throw new r("The indexed airdrop proof does not match the active onchain root.");return{allocatedAmount:x.toString(),proof:q}});return{token:n,chainId:D,recipient:t,proofs:c,summary:"Verified against the onchain airdrop root. An empty indexer response does not prove ineligibility; use saved allocation proofs if the tree was not published."}}),w("vault_status",{token:f},["token"],e=>p(d(e.token))),w("vault_claim",{token:f},["token"],async(e,t)=>{let n=d(e.token),a=await p(n);if(a.claimable==="0")throw new r("No vested Clanker tokens are available to claim.");return v(y.vault.address,P({abi:I,functionName:"claim",args:[n]}),`Claim ${a.claimable} base units of ${n} (18 decimals) to vault admin ${a.admin}.`,t)}),w("vault_update_admin",{token:f,admin:f},["token","admin"],async(e,t)=>{let n=d(e.token),a=await p(n);if(!A(a.admin,t))throw new r("Only the vault administrator can transfer its allocation.");return v(y.vault.address,P({abi:I,functionName:"editAllocationAdmin",args:[n,d(e.admin)]}),`Transfer all future Clanker vault claims for ${n} to ${d(e.admin)}.`,t)}),w("airdrop_tree",{allocations:{type:"array",minItems:1,maxItems:200,items:{type:"object",properties:{recipient:f,amount:T},required:["recipient","amount"],additionalProperties:!1}}},["allocations"],async e=>{if(!Array.isArray(e.allocations)||!e.allocations.length||e.allocations.length>200)throw new r("Provide 1 to 200 airdrop allocations.");let t=new Set,n=e.allocations.map(o=>{if(!C(o))throw new r("Provide allocation objects.");E(o,["recipient","amount"]);let i=d(o.recipient),c=b(o.amount);if(!c||t.has(i))throw new r("Airdrop allocations require positive amounts and unique recipients.");return t.add(i),{recipient:i,amount:c.toString(),hash:H(i,c)}}).sort((o,i)=>o.hash.localeCompare(i.hash)),a=[n.map(o=>o.hash)];for(;a.at(-1).length>1;){let o=a.at(-1),i=[];for(let c=0;c<o.length;c+=2)i.push(c+1<o.length?N(o[c],o[c+1]):o[c]);a.push(i)}let s=n.reduce((o,i)=>o+BigInt(i.amount),0n);if(s>=1n<<256n)throw new r("Airdrop total exceeds uint256.");return{merkleRoot:a.at(-1)[0],total:s.toString(),allocations:n.map((o,i)=>{let c=[],m=i;for(let x of a.slice(0,-1))x[m^1]&&c.push(x[m^1]),m=Math.floor(m/2);return{recipient:o.recipient,amount:o.amount,proof:c}}),summary:"Double-hashed ABI(address,uint256) leaves; sorted hash pairs. Save these public proofs. Allocations are token base units, 18 decimals; match their total to the launch extension supply."}}),w("airdrop_status",{token:f,allocatedAmount:T},["token"],async(e,t)=>{let n=d(e.token);return{...await l(n),...e.allocatedAmount===void 0?{}:{claimable:k(await h().readContract({address:y.airdrop.address,abi:$,functionName:"amountAvailableToClaim",args:[n,t,b(e.allocatedAmount)]}))}}}),w("airdrop_claim",{token:f,allocatedAmount:T,proof:{type:"array",maxItems:64,items:S}},["token","allocatedAmount","proof"],async(e,t)=>{let n=d(e.token),a=await l(n),s=b(e.allocatedAmount);if(!s||!Array.isArray(e.proof)||e.proof.length>64)throw new r("Provide a positive allocation and Merkle proof.");let o=e.proof.map(R),i=o.reduce(N,H(t,s));if(!A(i,a.merkleRoot))throw new r("The airdrop proof does not match the active root for this wallet and allocation.");return v(y.airdrop.address,P({abi:$,functionName:"claim",args:[n,t,s,o]}),`Claim vested allocation of ${s} base units of ${n} (18 decimals) to ${t}. Preview determines currently unlocked receipts.`,t)}),w("airdrop_manage",{token:f,operation:{enum:["admin","root","reclaim"]},admin:f,merkleRoot:S,recipient:f},["token","operation"],async(e,t)=>{let n=d(e.token),a=await l(n);if(!A(a.admin,t))throw new r("Only the airdrop administrator may manage it.");let s=e.operation==="admin"?"admin":e.operation==="root"?"merkleRoot":"recipient";for(let i of["admin","merkleRoot","recipient"])if(e[i]!==void 0&&i!==s)throw new r(`Input ${i} does not match this airdrop operation.`);let o;if(e.operation==="admin")o=P({abi:$,functionName:"updateAdmin",args:[n,d(e.admin)]});else if(e.operation==="root")o=P({abi:$,functionName:"updateMerkleRoot",args:[n,R(e.merkleRoot)]});else if(e.operation==="reclaim")o=P({abi:$,functionName:"adminClaim",args:[n,d(e.recipient)]});else throw new r("Choose admin, root or reclaim.");return v(y.airdrop.address,o,`Clanker airdrop ${String(e.operation)} for ${n}; ${String(e.admin??e.merkleRoot??e.recipient)}. Reclaim permanently closes recipient claims; contract timing and zero-claim guards apply.`,t)})]}};export{X as a,Y as b,Z as c};
@@ -1 +1 @@
1
- import{g as v}from"./73N3TOJL.js";import{a as w}from"./XPFVT2EA.js";import{a as t}from"./5YS5V2LK.js";import{a as k}from"./JXOEJPJ4.js";import{getAddress as b,parseAbi as A}from"viem";var y={one_hour:3600n,six_hours:21600n,one_day:86400n,seven_days:604800n,thirty_days:2592000n,ninety_days:7776000n,one_year:31536000n},f=A(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewRedeem(uint256) view returns (uint256)"]);async function Y(u,d,s){let i=0n,o=s.number,e=await u.getBlock({blockNumber:i});if(e.timestamp>d)throw new t("Longbow has insufficient chain history for this window.");for(let n=0;i+1n<o&&n<64;n++){let a=(i+o)/2n,c=await u.getBlock({blockNumber:a});if(c.number!==a||c.timestamp<e.timestamp||c.timestamp>s.timestamp)throw new t("Longbow historical block response is inconsistent.");c.timestamp<=d?(i=a,e=c):o=a}if(i+1n<o||e.number!==i)throw new t("Longbow historical block search exceeded its bound.");return e}async function S(u,d,s,i="six_hours"){let o=y[i];if(!Object.hasOwn(y,i)||!o)throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let e=u.clientFor(w);if(await e.getChainId()!==w)throw new t("Longbow APY assessment requires chain 4663.");let n=await e.getBlock({blockTag:"latest"});if(n.number===null||n.timestamp<o)throw new t("Longbow has insufficient chain history for this window.");let a=await Y(e,n.timestamp-o,{number:n.number,timestamp:n.timestamp}),c=10n**27n,r=await Promise.all([a,n].map(async m=>{let[P,L,N,g]=await Promise.all([e.readContract({address:d,abi:f,functionName:"asset",blockNumber:m.number}),e.readContract({address:d,abi:f,functionName:"decimals",blockNumber:m.number}),e.readContract({address:s.address,abi:f,functionName:"decimals",blockNumber:m.number}),e.readContract({address:d,abi:f,functionName:"previewRedeem",args:[c],blockNumber:m.number})]);if(b(P)!==b(s.address)||L!==18||N!==s.decimals||typeof g!="bigint"||g<0n||g>=1n<<256n)throw new t("Longbow historical share price or token metadata is unavailable or invalid. No zero rate was inferred.");return g})),h=n.timestamp-a.timestamp;if(h<=0n||h>o+300n)throw new t("Longbow historical blocks do not cover the requested APY window within 300 seconds.");if(r[0]===0n)throw new t("Longbow starting share price is zero; a realized APY cannot be calculated.");let l=Number(r[1]-r[0])/Number(r[0]),p=Math.expm1(Math.log1p(l)*31536e3/Number(h));if(!Number.isFinite(p))throw new t("Longbow annualized share-price change is outside the supported numeric range.");return{chainId:w,vault:d,asset:{...s,address:b(s.address)},shareToken:{address:d,symbol:"Longbow shares",decimals:18,chainId:w},source:"Oak-computed on-chain",view:"apy",stale:!1,window:{lookback:i,requestedSeconds:o.toString(),elapsedSeconds:h.toString(),fromTimestamp:a.timestamp.toString(),toTimestamp:n.timestamp.toString(),fromBlock:a.number.toString(),toBlock:n.number.toString()},sharePrice:{shareUnits:c.toString(),startAssets:r[0].toString(),endAssets:r[1].toString(),assetDecimals:s.decimals},data:{annualYieldFraction:String(p),annualYieldPercent:String(p*100),lookback:i,basis:"Oak-computed realized APY: (end share price / start share price)^(31536000 / elapsed seconds) - 1, using ERC-4626 previewRedeem at two pinned blocks."},caveat:"Historical share-price change includes what the vault accounts for in previewRedeem, excludes external rewards and gas, and is not a promised return. Archive RPC history is required; missing history is not zero APY."}}async function z(u,d,s,i){if(Object.keys(i).some(r=>!["view","lookback"].includes(r)))throw new t("Longbow APY takes a lookback, not pagination.");let o=i.lookback??"six_hours";if(typeof o!="string"||!Object.hasOwn(y,o))throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let[e,n]=await Promise.allSettled([C(u,d,s,{view:"published_apy"}),S(u,d,s,o)]),a=e.status==="fulfilled"&&!e.value.stale?e.value:void 0;if(!a&&n.status==="rejected")throw new t(`Longbow APY is unavailable: the vendor figure is unavailable or stale, and the on-chain window could not be measured. ${u.plainError(n.reason)}`);return{...a??(n.status==="fulfilled"?n.value:void 0),view:"apy",shown:a?"Longbow vendor":"Oak-computed on-chain",realized:n.status==="fulfilled"?n.value:null,published:e.status==="fulfilled"?e.value:null,warnings:[...a?[]:["Longbow vendor APY is unavailable or stale; showing Oak-computed realized APY."],...n.status==="rejected"?["Oak-computed APY is unavailable: the archive RPC window could not be measured."]:[]]}}async function C(u,d,s,i){if(Object.keys(i).some(m=>m!=="view")||i.view!=="published_apy")throw new t("published_apy takes no historical lookback, cursor or limit.");let o=u.clientFor(w);if(await o.getChainId()!==w)throw new t("Longbow APY assessment requires chain 4663.");let[e,n]=await Promise.all([o.getBlock(),o.readContract({address:d,abi:A(["function asset() view returns (address)"]),functionName:"asset"})]);if(b(n)!==b(s.address))throw new t("Longbow vault does not use the pinned asset.");let a="https://longbow.credit/api/v2/vaults",c=await u.http(a,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(15e3)});if(!c.ok)throw new t(`Longbow published APY HTTP ${c.status}; the rate is unavailable.`);let r=await c.json();if(!r||typeof r!="object"||!Number.isSafeInteger(r.asOf)||Number(r.asOf)<0||!Array.isArray(r.vaults)||r.vaults.length>100)throw new t("Longbow published APY response has an invalid timestamp or vault inventory.");let h=r.vaults.filter(m=>m&&typeof m=="object"&&typeof m.address=="string"&&v(String(m.address),d));if(h.length!==1)throw new t("Longbow published APY omitted or duplicated this vault; no zero rate is inferred.");let l=h[0];if(l.error||typeof l.asset!="string"||b(l.asset)!==b(s.address)||l.decimals!==s.decimals||typeof l.apy!="number"||!Number.isFinite(l.apy)||l.apy<-100||typeof l.apyBasis!="string"||l.apyBasis.length>64)throw new t("Longbow published APY asset, units, basis or rate is invalid.");let p=BigInt(Number(r.asOf));return{chainId:w,vault:d,asset:{...s,address:b(s.address)},shareToken:{address:d,symbol:"Longbow shares",decimals:18,chainId:w},sourceUrl:a,view:"published_apy",asOf:p.toString(),stale:e.timestamp>p+900n||p>e.timestamp+60n,data:{annualYieldPercent:String(l.apy),annualYieldFraction:String(l.apy/100),basis:k(l.apyBasis)},caveat:"Longbow publisher quote, not a realized Morpho lookback series or a promised return. The app formats this field directly as percent (0.03 means 0.03%, not 3%). No bonus, future payout or fee inclusion is inferred. Onchain book and fees remain available through longbow_details."}}export{S as a,z as b,C as c};
1
+ import{g as v}from"./73N3TOJL.js";import{a as w}from"./G6HCV67X.js";import{a as t}from"./5YS5V2LK.js";import{a as k}from"./JXOEJPJ4.js";import{getAddress as b,parseAbi as A}from"viem";var y={one_hour:3600n,six_hours:21600n,one_day:86400n,seven_days:604800n,thirty_days:2592000n,ninety_days:7776000n,one_year:31536000n},f=A(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewRedeem(uint256) view returns (uint256)"]);async function Y(u,d,s){let i=0n,o=s.number,e=await u.getBlock({blockNumber:i});if(e.timestamp>d)throw new t("Longbow has insufficient chain history for this window.");for(let n=0;i+1n<o&&n<64;n++){let a=(i+o)/2n,c=await u.getBlock({blockNumber:a});if(c.number!==a||c.timestamp<e.timestamp||c.timestamp>s.timestamp)throw new t("Longbow historical block response is inconsistent.");c.timestamp<=d?(i=a,e=c):o=a}if(i+1n<o||e.number!==i)throw new t("Longbow historical block search exceeded its bound.");return e}async function S(u,d,s,i="six_hours"){let o=y[i];if(!Object.hasOwn(y,i)||!o)throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let e=u.clientFor(w);if(await e.getChainId()!==w)throw new t("Longbow APY assessment requires chain 4663.");let n=await e.getBlock({blockTag:"latest"});if(n.number===null||n.timestamp<o)throw new t("Longbow has insufficient chain history for this window.");let a=await Y(e,n.timestamp-o,{number:n.number,timestamp:n.timestamp}),c=10n**27n,r=await Promise.all([a,n].map(async m=>{let[P,L,N,g]=await Promise.all([e.readContract({address:d,abi:f,functionName:"asset",blockNumber:m.number}),e.readContract({address:d,abi:f,functionName:"decimals",blockNumber:m.number}),e.readContract({address:s.address,abi:f,functionName:"decimals",blockNumber:m.number}),e.readContract({address:d,abi:f,functionName:"previewRedeem",args:[c],blockNumber:m.number})]);if(b(P)!==b(s.address)||L!==18||N!==s.decimals||typeof g!="bigint"||g<0n||g>=1n<<256n)throw new t("Longbow historical share price or token metadata is unavailable or invalid. No zero rate was inferred.");return g})),h=n.timestamp-a.timestamp;if(h<=0n||h>o+300n)throw new t("Longbow historical blocks do not cover the requested APY window within 300 seconds.");if(r[0]===0n)throw new t("Longbow starting share price is zero; a realized APY cannot be calculated.");let l=Number(r[1]-r[0])/Number(r[0]),p=Math.expm1(Math.log1p(l)*31536e3/Number(h));if(!Number.isFinite(p))throw new t("Longbow annualized share-price change is outside the supported numeric range.");return{chainId:w,vault:d,asset:{...s,address:b(s.address)},shareToken:{address:d,symbol:"Longbow shares",decimals:18,chainId:w},source:"Oak-computed on-chain",view:"apy",stale:!1,window:{lookback:i,requestedSeconds:o.toString(),elapsedSeconds:h.toString(),fromTimestamp:a.timestamp.toString(),toTimestamp:n.timestamp.toString(),fromBlock:a.number.toString(),toBlock:n.number.toString()},sharePrice:{shareUnits:c.toString(),startAssets:r[0].toString(),endAssets:r[1].toString(),assetDecimals:s.decimals},data:{annualYieldFraction:String(p),annualYieldPercent:String(p*100),lookback:i,basis:"Oak-computed realized APY: (end share price / start share price)^(31536000 / elapsed seconds) - 1, using ERC-4626 previewRedeem at two pinned blocks."},caveat:"Historical share-price change includes what the vault accounts for in previewRedeem, excludes external rewards and gas, and is not a promised return. Archive RPC history is required; missing history is not zero APY."}}async function z(u,d,s,i){if(Object.keys(i).some(r=>!["view","lookback"].includes(r)))throw new t("Longbow APY takes a lookback, not pagination.");let o=i.lookback??"six_hours";if(typeof o!="string"||!Object.hasOwn(y,o))throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let[e,n]=await Promise.allSettled([C(u,d,s,{view:"published_apy"}),S(u,d,s,o)]),a=e.status==="fulfilled"&&!e.value.stale?e.value:void 0;if(!a&&n.status==="rejected")throw new t(`Longbow APY is unavailable: the vendor figure is unavailable or stale, and the on-chain window could not be measured. ${u.plainError(n.reason)}`);return{...a??(n.status==="fulfilled"?n.value:void 0),view:"apy",shown:a?"Longbow vendor":"Oak-computed on-chain",realized:n.status==="fulfilled"?n.value:null,published:e.status==="fulfilled"?e.value:null,warnings:[...a?[]:["Longbow vendor APY is unavailable or stale; showing Oak-computed realized APY."],...n.status==="rejected"?["Oak-computed APY is unavailable: the archive RPC window could not be measured."]:[]]}}async function C(u,d,s,i){if(Object.keys(i).some(m=>m!=="view")||i.view!=="published_apy")throw new t("published_apy takes no historical lookback, cursor or limit.");let o=u.clientFor(w);if(await o.getChainId()!==w)throw new t("Longbow APY assessment requires chain 4663.");let[e,n]=await Promise.all([o.getBlock(),o.readContract({address:d,abi:A(["function asset() view returns (address)"]),functionName:"asset"})]);if(b(n)!==b(s.address))throw new t("Longbow vault does not use the pinned asset.");let a="https://longbow.credit/api/v2/vaults",c=await u.http(a,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(15e3)});if(!c.ok)throw new t(`Longbow published APY HTTP ${c.status}; the rate is unavailable.`);let r=await c.json();if(!r||typeof r!="object"||!Number.isSafeInteger(r.asOf)||Number(r.asOf)<0||!Array.isArray(r.vaults)||r.vaults.length>100)throw new t("Longbow published APY response has an invalid timestamp or vault inventory.");let h=r.vaults.filter(m=>m&&typeof m=="object"&&typeof m.address=="string"&&v(String(m.address),d));if(h.length!==1)throw new t("Longbow published APY omitted or duplicated this vault; no zero rate is inferred.");let l=h[0];if(l.error||typeof l.asset!="string"||b(l.asset)!==b(s.address)||l.decimals!==s.decimals||typeof l.apy!="number"||!Number.isFinite(l.apy)||l.apy<-100||typeof l.apyBasis!="string"||l.apyBasis.length>64)throw new t("Longbow published APY asset, units, basis or rate is invalid.");let p=BigInt(Number(r.asOf));return{chainId:w,vault:d,asset:{...s,address:b(s.address)},shareToken:{address:d,symbol:"Longbow shares",decimals:18,chainId:w},sourceUrl:a,view:"published_apy",asOf:p.toString(),stale:e.timestamp>p+900n||p>e.timestamp+60n,data:{annualYieldPercent:String(l.apy),annualYieldFraction:String(l.apy/100),basis:k(l.apyBasis)},caveat:"Longbow publisher quote, not a realized Morpho lookback series or a promised return. The app formats this field directly as percent (0.03 means 0.03%, not 3%). No bonus, future payout or fee inclusion is inferred. Onchain book and fees remain available through longbow_details."}}export{S as a,z as b,C as c};
@@ -1 +1 @@
1
- import{a as p,b as g,i as _}from"./XPFVT2EA.js";import{a as c}from"./5YS5V2LK.js";import{AsyncLocalStorage as j}from"node:async_hooks";import{custom as I}from"viem";import{createPublicClient as A,custom as k,defineChain as N}from"viem";var T="https://rpc.mainnet.chain.robinhood.com",F="oak-core/0.1.0",K=_[4663].ponsClaims.multicall3.address,v=new Set(["eth_sendTransaction","eth_sendRawTransaction","eth_sign","personal_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","wallet_sendTransaction","wallet_sign"]);function U(e=p,t=T){if(!Number.isSafeInteger(e)||e<=0)throw new c("Provide a positive integer chain ID.");let n=e===p?"Robinhood Chain":e===g?"Robinhood Chain Testnet":`Chain ${e}`;return N({id:e,name:n,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[t]}},...e===p?{contracts:{multicall3:{address:K}}}:{}})}function Z(e=p,t){if(t?.chain&&t.chain.id===e)return t.chain.contracts?.multicall3?.address;if(!(!Number.isSafeInteger(e)||e<=0))return U(e).contracts?.multicall3?.address}function q(e,t,n){let s=e?.trim()||n?.rpcUrl?.trim()||n?.rpcUrls?.[t]?.trim(),r=t===p?process.env.OAK_RPC_URL?.trim():t===g?(process.env.OAK_TESTNET_RPC_URL??process.env.OAK_RPC_URL)?.trim():process.env[`OAK_RPC_URL_${t}`]?.trim(),a=s||r||(t===p?T:void 0);if(!a)throw new c(`No RPC URL configured for chain ${t}.`);if((n?.requireKeyedRpc??process.env.NODE_ENV==="production")&&t===p&&a===T)throw new c("Production requires a keyed OAK_RPC_URL.");return a}var $=1e4;async function P(e,t=$){if(!Number.isFinite(t)||t<=0||t>3e4)throw new c("RPC timeout must be greater than zero and at most 30000 ms.");let n=new AbortController,s;try{return await Promise.race([new Promise((r,a)=>{s=setTimeout(()=>{a(new c("The RPC request timed out. Please try again.")),n.abort()},t)}),e(n.signal)])}finally{clearTimeout(s)}}function H(e,t=p,n){let s=typeof e=="object"&&e!==null,r=s?e:n??{},a=typeof e=="string"?e:r.rpcUrl,i=s?r.chainId??t:t;if(!Number.isSafeInteger(i)||i<=0)throw new c("Provide a positive integer chain ID.");if(r.timeoutMs!==void 0&&(!Number.isFinite(r.timeoutMs)||r.timeoutMs<=0||r.timeoutMs>3e4))throw new c("RPC timeout must be greater than zero and at most 30000 ms.");let d=q(a,i,r),u=U(i,d);if(r.transport){let o=r.transport({chain:u,retryCount:0});return A({chain:u,transport:k({request:m=>{if(v.has(m.method)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(m.method))throw new c("Read-only RPC client does not allow this method.");return P(()=>o.request(m),r.timeoutMs)}},{retryCount:0})})}let l=M({url:d,chainId:i,fetch:r.fetch,userAgent:r.userAgent?.trim()||F,retries:r.retries,retryDelayMs:r.retryDelayMs,maxRetryDelayMs:r.maxRetryDelayMs,timeoutMs:r.timeoutMs,fallbackUrls:r.rpcFallbackUrls?.[i]??r.fallbackRpcUrls??C(process.env[`OAK_RPC_FALLBACK_URLS_${i}`]??(i===p?process.env.OAK_RPC_FALLBACK_URLS:void 0))})({chain:u,retryCount:0}),h=k({request:o=>{if(v.has(o.method)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(o.method))throw new c("Read-only RPC client does not allow this method.");return l.request(o)}},{retryCount:0});return A({chain:u,transport:h})}function ee(e={}){let t=new Map;return n=>{let s=t.get(n);if(s)return s;let r=H(e.rpcUrls?.[n],n,e);return t.set(n,r),r}}var y=class extends c{};function D(e){let t=[];for(;e&&typeof e=="object"&&!t.includes(e);)t.push(e),e=e.cause;return t}function B(e){return D(e).find(t=>t instanceof y)}function z(e){if(!B(e))for(let t of D(e)){let n=Number(t.status??t.code);if(n===429||n>=500&&n<=599)return{status:n,delay:typeof t.retryAfterMs=="number"?t.retryAfterMs:void 0};if(/rate.?limit|too many requests/i.test(String(t.message??"")))return{status:429}}}async function x(e,t,n={},s){let r=n.retries??3,a=n.retryDelayMs??250,i=n.maxRetryDelayMs??2e3;if(!Number.isInteger(r)||r<0||r>5||!Number.isFinite(a)||a<0||!Number.isFinite(i)||i<0||i>3e4)throw new c("RPC retries must be 0 to 5; backoff must be non-negative and at most 30000 ms.");for(let d=0;;d++){s?.throwIfAborted();try{return await e()}catch(u){let f=z(u);if(!f)throw u;let l=Math.min(i,a*2**d),h=Math.max(Math.min(i,l+Math.floor(Math.random()*l/4)),f.delay??0);if(d>=r||h>i){let o=f.status===429?"public RPC rate-limited":`RPC returned HTTP ${f.status}`,m=f.delay?` Retry after ${Math.max(1,Math.ceil(f.delay/1e3))} seconds.`:"";throw new y(`${o}, retried ${d} times (${t}).${m} ${f.status===429?"The RPC rate limit remains active. ":""}Configure a keyed OAK_RPC_URL or comma-separated OAK_RPC_FALLBACK_URLS for this chain.`)}await new Promise((o,m)=>{let w=()=>{clearTimeout(b),m(s?.reason)},b=setTimeout(()=>{s?.removeEventListener("abort",w),o()},h);s?.addEventListener("abort",w,{once:!0}),s?.aborted&&w()})}}}function C(e){if(e===void 0||e.trim()==="")return[];let t=e.split(",").map(n=>n.trim());if(t.length>4)throw new c("Configure at most four ordered fallback RPC URLs.");for(let n of t){let s;try{s=new URL(n)}catch{throw new c("Fallback RPC URLs must use HTTP or HTTPS.")}if(!["http:","https:"].includes(s.protocol))throw new c("Fallback RPC URLs must use HTTP or HTTPS.")}return t}var R=new Map;async function J(e,t,n){let s=R.get(e)??Promise.resolve(),r,a=new Promise(d=>{r=d}),i=s.then(()=>a);R.set(e,i);try{return await s,n.throwIfAborted(),await t()}finally{r(),R.get(e)===i&&R.delete(e)}}var L=new j,S=new Map,E=e=>{let t=new URL(e).origin,n=S.get(t);return n||(n={interactive:0},S.set(t,n)),n};async function V(e,t){let n=L.getStore(),s=[...new Set(e.map(E))].filter(r=>!n?.has(r));s.forEach(r=>{r.interactive++});try{let r=s.flatMap(a=>a.background?[a.background.catch(()=>{})]:[]);return r.length&&await Promise.all(r),await t()}finally{s.forEach(r=>{r.interactive--})}}async function oe(e,t,n=s=>new Promise(r=>{setTimeout(r,s).unref()})){let s=E(e);for(;s.interactive||s.background;)await n(100);let r=Promise.resolve().then(()=>L.run(new Set([s]),t));s.background=r;try{return await r}finally{s.background===r&&(s.background=void 0)}}function M(e){let t=[...new Set([e.url,...e.fallbackUrls??[]])];C(t.slice(1).join(","));let n=new Set,s=0;return I({request:({method:r,params:a})=>V(t,()=>P(async i=>{let d;for(let u of t){let f=async(l,h=[])=>{let o=await(e.fetch??globalThis.fetch)(u,{method:"POST",redirect:"error",signal:i,headers:{"content-type":"application/json","user-agent":e.userAgent??"oak-core/0.1.0"},body:JSON.stringify({jsonrpc:"2.0",id:++s,method:l,params:h})});if(!o.ok){let w=o.headers.get("retry-after"),b=w===null?void 0:/^\d+(\.\d+)?$/.test(w.trim())?Number(w)*1e3:Math.max(0,Date.parse(w)-Date.now()),O=typeof b=="number"&&Number.isFinite(b)?b:void 0;throw await o.body?.cancel(),o.status===429||o.status>=500?Object.assign(new Error("Transient RPC HTTP failure"),{status:o.status,retryAfterMs:O}):new y(`RPC returned HTTP ${o.status} (${l}).`)}let m;try{m=await o.json()}catch{throw new y("The RPC endpoint returned malformed JSON.")}if(m.error)throw Object.assign(new Error(m.error.message??"RPC error"),{code:m.error.code,data:m.error.data});return m.result};try{if(u!==t[0]&&r!=="eth_chainId"&&(!n.has(u)||r==="eth_sendRawTransaction")){let o=await x(()=>f("eth_chainId"),"eth_chainId",e,i);if(Number(o)!==e.chainId)throw new y("RPC chain does not match the requested chain.");n.add(u)}let l=()=>x(()=>f(r,a),r,e,i),h=await(r==="eth_simulateV1"?J(u,l,i):l());if(r==="eth_chainId")if(Number(h)!==e.chainId){if(u!==t[0])throw new y("RPC chain does not match the requested chain.")}else n.add(u);return h}catch(l){if(d=l,!(l instanceof y)||!/rate-limited|HTTP 5\d\d|chain does not match/.test(l.message))throw l}}throw d},e.timeoutMs))},{retryCount:0})}export{y as a,B as b,x as c,C as d,V as e,oe as f,M as g,T as h,F as i,K as j,U as k,Z as l,$ as m,P as n,H as o,ee as p};
1
+ import{a as p,b as g,i as _}from"./G6HCV67X.js";import{a as c}from"./5YS5V2LK.js";import{AsyncLocalStorage as j}from"node:async_hooks";import{custom as I}from"viem";import{createPublicClient as A,custom as k,defineChain as N}from"viem";var T="https://rpc.mainnet.chain.robinhood.com",F="oak-core/0.1.0",K=_[4663].ponsClaims.multicall3.address,v=new Set(["eth_sendTransaction","eth_sendRawTransaction","eth_sign","personal_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","wallet_sendTransaction","wallet_sign"]);function U(e=p,t=T){if(!Number.isSafeInteger(e)||e<=0)throw new c("Provide a positive integer chain ID.");let n=e===p?"Robinhood Chain":e===g?"Robinhood Chain Testnet":`Chain ${e}`;return N({id:e,name:n,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[t]}},...e===p?{contracts:{multicall3:{address:K}}}:{}})}function Z(e=p,t){if(t?.chain&&t.chain.id===e)return t.chain.contracts?.multicall3?.address;if(!(!Number.isSafeInteger(e)||e<=0))return U(e).contracts?.multicall3?.address}function q(e,t,n){let s=e?.trim()||n?.rpcUrl?.trim()||n?.rpcUrls?.[t]?.trim(),r=t===p?process.env.OAK_RPC_URL?.trim():t===g?(process.env.OAK_TESTNET_RPC_URL??process.env.OAK_RPC_URL)?.trim():process.env[`OAK_RPC_URL_${t}`]?.trim(),a=s||r||(t===p?T:void 0);if(!a)throw new c(`No RPC URL configured for chain ${t}.`);if((n?.requireKeyedRpc??process.env.NODE_ENV==="production")&&t===p&&a===T)throw new c("Production requires a keyed OAK_RPC_URL.");return a}var $=1e4;async function P(e,t=$){if(!Number.isFinite(t)||t<=0||t>3e4)throw new c("RPC timeout must be greater than zero and at most 30000 ms.");let n=new AbortController,s;try{return await Promise.race([new Promise((r,a)=>{s=setTimeout(()=>{a(new c("The RPC request timed out. Please try again.")),n.abort()},t)}),e(n.signal)])}finally{clearTimeout(s)}}function H(e,t=p,n){let s=typeof e=="object"&&e!==null,r=s?e:n??{},a=typeof e=="string"?e:r.rpcUrl,i=s?r.chainId??t:t;if(!Number.isSafeInteger(i)||i<=0)throw new c("Provide a positive integer chain ID.");if(r.timeoutMs!==void 0&&(!Number.isFinite(r.timeoutMs)||r.timeoutMs<=0||r.timeoutMs>3e4))throw new c("RPC timeout must be greater than zero and at most 30000 ms.");let d=q(a,i,r),u=U(i,d);if(r.transport){let o=r.transport({chain:u,retryCount:0});return A({chain:u,transport:k({request:m=>{if(v.has(m.method)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(m.method))throw new c("Read-only RPC client does not allow this method.");return P(()=>o.request(m),r.timeoutMs)}},{retryCount:0})})}let l=M({url:d,chainId:i,fetch:r.fetch,userAgent:r.userAgent?.trim()||F,retries:r.retries,retryDelayMs:r.retryDelayMs,maxRetryDelayMs:r.maxRetryDelayMs,timeoutMs:r.timeoutMs,fallbackUrls:r.rpcFallbackUrls?.[i]??r.fallbackRpcUrls??C(process.env[`OAK_RPC_FALLBACK_URLS_${i}`]??(i===p?process.env.OAK_RPC_FALLBACK_URLS:void 0))})({chain:u,retryCount:0}),h=k({request:o=>{if(v.has(o.method)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(o.method))throw new c("Read-only RPC client does not allow this method.");return l.request(o)}},{retryCount:0});return A({chain:u,transport:h})}function ee(e={}){let t=new Map;return n=>{let s=t.get(n);if(s)return s;let r=H(e.rpcUrls?.[n],n,e);return t.set(n,r),r}}var y=class extends c{};function D(e){let t=[];for(;e&&typeof e=="object"&&!t.includes(e);)t.push(e),e=e.cause;return t}function B(e){return D(e).find(t=>t instanceof y)}function z(e){if(!B(e))for(let t of D(e)){let n=Number(t.status??t.code);if(n===429||n>=500&&n<=599)return{status:n,delay:typeof t.retryAfterMs=="number"?t.retryAfterMs:void 0};if(/rate.?limit|too many requests/i.test(String(t.message??"")))return{status:429}}}async function x(e,t,n={},s){let r=n.retries??3,a=n.retryDelayMs??250,i=n.maxRetryDelayMs??2e3;if(!Number.isInteger(r)||r<0||r>5||!Number.isFinite(a)||a<0||!Number.isFinite(i)||i<0||i>3e4)throw new c("RPC retries must be 0 to 5; backoff must be non-negative and at most 30000 ms.");for(let d=0;;d++){s?.throwIfAborted();try{return await e()}catch(u){let f=z(u);if(!f)throw u;let l=Math.min(i,a*2**d),h=Math.max(Math.min(i,l+Math.floor(Math.random()*l/4)),f.delay??0);if(d>=r||h>i){let o=f.status===429?"public RPC rate-limited":`RPC returned HTTP ${f.status}`,m=f.delay?` Retry after ${Math.max(1,Math.ceil(f.delay/1e3))} seconds.`:"";throw new y(`${o}, retried ${d} times (${t}).${m} ${f.status===429?"The RPC rate limit remains active. ":""}Configure a keyed OAK_RPC_URL or comma-separated OAK_RPC_FALLBACK_URLS for this chain.`)}await new Promise((o,m)=>{let w=()=>{clearTimeout(b),m(s?.reason)},b=setTimeout(()=>{s?.removeEventListener("abort",w),o()},h);s?.addEventListener("abort",w,{once:!0}),s?.aborted&&w()})}}}function C(e){if(e===void 0||e.trim()==="")return[];let t=e.split(",").map(n=>n.trim());if(t.length>4)throw new c("Configure at most four ordered fallback RPC URLs.");for(let n of t){let s;try{s=new URL(n)}catch{throw new c("Fallback RPC URLs must use HTTP or HTTPS.")}if(!["http:","https:"].includes(s.protocol))throw new c("Fallback RPC URLs must use HTTP or HTTPS.")}return t}var R=new Map;async function J(e,t,n){let s=R.get(e)??Promise.resolve(),r,a=new Promise(d=>{r=d}),i=s.then(()=>a);R.set(e,i);try{return await s,n.throwIfAborted(),await t()}finally{r(),R.get(e)===i&&R.delete(e)}}var L=new j,S=new Map,E=e=>{let t=new URL(e).origin,n=S.get(t);return n||(n={interactive:0},S.set(t,n)),n};async function V(e,t){let n=L.getStore(),s=[...new Set(e.map(E))].filter(r=>!n?.has(r));s.forEach(r=>{r.interactive++});try{let r=s.flatMap(a=>a.background?[a.background.catch(()=>{})]:[]);return r.length&&await Promise.all(r),await t()}finally{s.forEach(r=>{r.interactive--})}}async function oe(e,t,n=s=>new Promise(r=>{setTimeout(r,s).unref()})){let s=E(e);for(;s.interactive||s.background;)await n(100);let r=Promise.resolve().then(()=>L.run(new Set([s]),t));s.background=r;try{return await r}finally{s.background===r&&(s.background=void 0)}}function M(e){let t=[...new Set([e.url,...e.fallbackUrls??[]])];C(t.slice(1).join(","));let n=new Set,s=0;return I({request:({method:r,params:a})=>V(t,()=>P(async i=>{let d;for(let u of t){let f=async(l,h=[])=>{let o=await(e.fetch??globalThis.fetch)(u,{method:"POST",redirect:"error",signal:i,headers:{"content-type":"application/json","user-agent":e.userAgent??"oak-core/0.1.0"},body:JSON.stringify({jsonrpc:"2.0",id:++s,method:l,params:h})});if(!o.ok){let w=o.headers.get("retry-after"),b=w===null?void 0:/^\d+(\.\d+)?$/.test(w.trim())?Number(w)*1e3:Math.max(0,Date.parse(w)-Date.now()),O=typeof b=="number"&&Number.isFinite(b)?b:void 0;throw await o.body?.cancel(),o.status===429||o.status>=500?Object.assign(new Error("Transient RPC HTTP failure"),{status:o.status,retryAfterMs:O}):new y(`RPC returned HTTP ${o.status} (${l}).`)}let m;try{m=await o.json()}catch{throw new y("The RPC endpoint returned malformed JSON.")}if(m.error)throw Object.assign(new Error(m.error.message??"RPC error"),{code:m.error.code,data:m.error.data});return m.result};try{if(u!==t[0]&&r!=="eth_chainId"&&(!n.has(u)||r==="eth_sendRawTransaction")){let o=await x(()=>f("eth_chainId"),"eth_chainId",e,i);if(Number(o)!==e.chainId)throw new y("RPC chain does not match the requested chain.");n.add(u)}let l=()=>x(()=>f(r,a),r,e,i),h=await(r==="eth_simulateV1"?J(u,l,i):l());if(r==="eth_chainId")if(Number(h)!==e.chainId){if(u!==t[0])throw new y("RPC chain does not match the requested chain.")}else n.add(u);return h}catch(l){if(d=l,!(l instanceof y)||!/rate-limited|HTTP 5\d\d|chain does not match/.test(l.message))throw l}}throw d},e.timeoutMs))},{retryCount:0})}export{y as a,B as b,x as c,C as d,V as e,oe as f,M as g,T as h,F as i,K as j,U as k,Z as l,$ as m,P as n,H as o,ee as p};
@@ -1 +1 @@
1
- import{a as H,b as z}from"./LIUXNOLP.js";import{a as _}from"./OG5HRQU4.js";import{a as O,b as B}from"./6IM6A5VA.js";import{b as D,c as E,d as U}from"./EG6M6SSO.js";import{a as $,b as M,i as R,s as S}from"./XPFVT2EA.js";import{a as u,b as N,c as I,d as F}from"./5YS5V2LK.js";import{decodeFunctionResult as J,encodeFunctionData as Q,erc20Abi as q,getAddress as G,isAddress as X,toEventSelector as Y,toHex as v,zeroAddress as Z}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ee(e){let r=e.toLowerCase();return r===Z||r===C?C:e}var te=Y("Transfer(address,address,uint256)"),K="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function A(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function P(){throw new u("The endpoint returned an unexpected simulation response.")}async function L(e,r,d,a){let s=await e.getChainId();if(s!==r)throw new u(`Preview is on chain ${r}, but the endpoint reports chain ${s}.`);let i=await H(e),t=await z(e,i);if(i.number===null||typeof i.baseFeePerGas!="bigint"||i.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new u("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let n=t<i.baseFeePerGas?i.baseFeePerGas:t,y=D(i.gasLimit),b=d.map(f=>({from:a,to:f.to,data:f.data,value:v(BigInt(f.value)),gasPrice:v(n),gas:v(y)})),w=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:v(i.baseFeePerGas)},calls:b}],validation:!1,traceTransfers:!0},v(i.number)]},{retryCount:0});try{return await w()}catch(f){if(!I(f))throw f;let o=await e.getBalance({address:a,blockNumber:i.number}),c=await Promise.all(d.map(m=>e.estimateGas({account:a,to:m.to,data:m.data,value:BigInt(m.value),gas:y,blockNumber:i.number}).catch(()=>{}))),p=o;for(let[m,l]of b.entries()){let g=BigInt(l.value),x=U(D(i.gasLimit,c[m]),p,g,n,a,r),T=c[m];if(T!==void 0&&T>x)throw new u(E(a,r,o-p+g+T*n,o));l.gas=v(x),p-=g}let h=await w();if(Array.isArray(h)&&A(h[0])&&Array.isArray(h[0].calls))for(let[m,l]of h[0].calls.entries()){let g=b[m];if(g&&A(l)&&l.status==="0x0"&&typeof l.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(l.gasUsed)&&BigInt(l.gasUsed)>=BigInt(g.gas))throw new u(E(a,r,BigInt(g.value)+(BigInt(g.gas)+1n)*n,o))}return h}}function V(e,r,d,a){(!Array.isArray(e)||e.length!==1||!A(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==r)&&P();let s=new Map;for(let[i,t]of e[0].calls.entries()){if(A(t)||P(),t.status==="0x0")throw new u(`Preview call ${i+1} on chain ${a} reverted. ${F(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&P();for(let n of t.logs){if((!A(n)||!Array.isArray(n.topics))&&P(),typeof n.topics[0]!="string"||n.topics[0].toLowerCase()!==te||n.topics.length===4)continue;(n.topics.length!==3||typeof n.address!="string"||!X(n.address,{strict:!1})||typeof n.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.data)||!n.topics.slice(1).every(c=>typeof c=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(c)))&&P();let y=n.topics[1].slice(-40).toLowerCase(),b=n.topics[2].slice(-40).toLowerCase(),w=d.slice(2).toLowerCase(),f=BigInt(n.data),o=(b===w?f:0n)-(y===w?f:0n);if(o!==0n){let c=ee(n.address.toLowerCase());s.set(c,(s.get(c)??0n)+o)}}}return s}async function W(e,r,d,a){let s=r===$?S.mainnet:r===M?S.testnet:void 0,i=s&&[{address:s.usdg,symbol:"USDG",decimals:6},{address:s.weth,symbol:"WETH",decimals:18},...r===$?[{address:R[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(n=>n.address.toLowerCase()===e);if(i)return{...i,address:G(e),chainId:r};let t;if(e===C){let n=d.chain?.nativeCurrency??(r===4663?{symbol:"ETH",decimals:18}:void 0);if(!n)throw new u(`Native token metadata is unavailable for chain ${r}.`);t={address:e,chainId:r,symbol:n.symbol,decimals:n.decimals}}else if(a)t=await a(e,r,d);else{let n=await _(d,r,e,"decimals");t={address:e,chainId:r,symbol:e,decimals:n}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==r||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new u(`Invalid token metadata for ${e} on chain ${r}.`);return{address:e===C?e:G(e),chainId:r,symbol:e===C?t.symbol:G(e),decimals:t.decimals}}function le(e){return async(r,d)=>{O(d);let a=r.map(B),s=a[0]?.chainId;if(s===void 0)return{txs:a,changes:[],summary:K};let i=a.find(t=>t.chainId!==s);if(i)throw new u(`Preview cannot combine chain ${s} with chain ${i.chainId}. Preview each chain separately.`);try{let t=e.clientFor(s),n;try{n=await L(t,s,a,d)}catch(o){if(!N(o,-32601,-32004)||!e.anvilFor)throw o;t=await e.anvilFor(s),n=await L(t,s,a,d)}let y=V(n,a.length,d,s),b=new Map,w=[];for(let[o,c]of y)if(c!==0n)try{b.set(o,await W(o,s,t,e.tokenFor))}catch(p){if(o===C||e.tokenFor||(await t.getCode({address:o})??"0x")!=="0x")throw p;w.push(o)}if(w.length){let o=w.flatMap(m=>["symbol","decimals"].map(l=>B({to:m,data:Q({abi:q,functionName:l}),value:"0",chainId:s,description:`Read simulated token ${l}.`}))),c=await L(t,s,[...a,...o],d);(!Array.isArray(c)||c.length!==1||!A(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==a.length+o.length)&&P();let p=c[0].calls,h=V([{calls:p.slice(0,a.length)}],a.length,d,s);if(y.size!==h.size||[...y].some(([m,l])=>h.get(m)!==l))throw new u("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[m,l]of w.entries()){let g=(T,j)=>{let k=p[a.length+m*2+j];if(!A(k)||k.status!=="0x1"||k.error||typeof k.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(k.returnData))throw new u(`Invalid simulated token metadata for ${l} on chain ${s}.`);return J({abi:q,functionName:T,data:k.returnData})},x={address:l,chainId:s,symbol:g("symbol",0),decimals:g("decimals",1)};b.set(l,await W(l,s,t,async()=>x))}}let f=[...y].filter(([,o])=>o!==0n).map(([o,c])=>({token:b.get(o),amount:c.toString()}));return{txs:a,changes:f,summary:K}}catch(t){throw new u(`Preview on chain ${s} failed: ${F(t)}`)}}}export{C as a,ee as b,le as c};
1
+ import{a as H,b as z}from"./LIUXNOLP.js";import{a as _}from"./QRDDKA4I.js";import{a as O,b as B}from"./6IM6A5VA.js";import{b as D,c as E,d as U}from"./EG6M6SSO.js";import{a as $,b as M,i as R,s as S}from"./G6HCV67X.js";import{a as u,b as N,c as I,d as F}from"./5YS5V2LK.js";import{decodeFunctionResult as J,encodeFunctionData as Q,erc20Abi as q,getAddress as G,isAddress as X,toEventSelector as Y,toHex as v,zeroAddress as Z}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ee(e){let r=e.toLowerCase();return r===Z||r===C?C:e}var te=Y("Transfer(address,address,uint256)"),K="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function A(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function P(){throw new u("The endpoint returned an unexpected simulation response.")}async function L(e,r,d,a){let s=await e.getChainId();if(s!==r)throw new u(`Preview is on chain ${r}, but the endpoint reports chain ${s}.`);let i=await H(e),t=await z(e,i);if(i.number===null||typeof i.baseFeePerGas!="bigint"||i.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new u("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let n=t<i.baseFeePerGas?i.baseFeePerGas:t,y=D(i.gasLimit),b=d.map(f=>({from:a,to:f.to,data:f.data,value:v(BigInt(f.value)),gasPrice:v(n),gas:v(y)})),w=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:v(i.baseFeePerGas)},calls:b}],validation:!1,traceTransfers:!0},v(i.number)]},{retryCount:0});try{return await w()}catch(f){if(!I(f))throw f;let o=await e.getBalance({address:a,blockNumber:i.number}),c=await Promise.all(d.map(m=>e.estimateGas({account:a,to:m.to,data:m.data,value:BigInt(m.value),gas:y,blockNumber:i.number}).catch(()=>{}))),p=o;for(let[m,l]of b.entries()){let g=BigInt(l.value),x=U(D(i.gasLimit,c[m]),p,g,n,a,r),T=c[m];if(T!==void 0&&T>x)throw new u(E(a,r,o-p+g+T*n,o));l.gas=v(x),p-=g}let h=await w();if(Array.isArray(h)&&A(h[0])&&Array.isArray(h[0].calls))for(let[m,l]of h[0].calls.entries()){let g=b[m];if(g&&A(l)&&l.status==="0x0"&&typeof l.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(l.gasUsed)&&BigInt(l.gasUsed)>=BigInt(g.gas))throw new u(E(a,r,BigInt(g.value)+(BigInt(g.gas)+1n)*n,o))}return h}}function V(e,r,d,a){(!Array.isArray(e)||e.length!==1||!A(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==r)&&P();let s=new Map;for(let[i,t]of e[0].calls.entries()){if(A(t)||P(),t.status==="0x0")throw new u(`Preview call ${i+1} on chain ${a} reverted. ${F(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&P();for(let n of t.logs){if((!A(n)||!Array.isArray(n.topics))&&P(),typeof n.topics[0]!="string"||n.topics[0].toLowerCase()!==te||n.topics.length===4)continue;(n.topics.length!==3||typeof n.address!="string"||!X(n.address,{strict:!1})||typeof n.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.data)||!n.topics.slice(1).every(c=>typeof c=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(c)))&&P();let y=n.topics[1].slice(-40).toLowerCase(),b=n.topics[2].slice(-40).toLowerCase(),w=d.slice(2).toLowerCase(),f=BigInt(n.data),o=(b===w?f:0n)-(y===w?f:0n);if(o!==0n){let c=ee(n.address.toLowerCase());s.set(c,(s.get(c)??0n)+o)}}}return s}async function W(e,r,d,a){let s=r===$?S.mainnet:r===M?S.testnet:void 0,i=s&&[{address:s.usdg,symbol:"USDG",decimals:6},{address:s.weth,symbol:"WETH",decimals:18},...r===$?[{address:R[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(n=>n.address.toLowerCase()===e);if(i)return{...i,address:G(e),chainId:r};let t;if(e===C){let n=d.chain?.nativeCurrency??(r===4663?{symbol:"ETH",decimals:18}:void 0);if(!n)throw new u(`Native token metadata is unavailable for chain ${r}.`);t={address:e,chainId:r,symbol:n.symbol,decimals:n.decimals}}else if(a)t=await a(e,r,d);else{let n=await _(d,r,e,"decimals");t={address:e,chainId:r,symbol:e,decimals:n}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==r||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new u(`Invalid token metadata for ${e} on chain ${r}.`);return{address:e===C?e:G(e),chainId:r,symbol:e===C?t.symbol:G(e),decimals:t.decimals}}function le(e){return async(r,d)=>{O(d);let a=r.map(B),s=a[0]?.chainId;if(s===void 0)return{txs:a,changes:[],summary:K};let i=a.find(t=>t.chainId!==s);if(i)throw new u(`Preview cannot combine chain ${s} with chain ${i.chainId}. Preview each chain separately.`);try{let t=e.clientFor(s),n;try{n=await L(t,s,a,d)}catch(o){if(!N(o,-32601,-32004)||!e.anvilFor)throw o;t=await e.anvilFor(s),n=await L(t,s,a,d)}let y=V(n,a.length,d,s),b=new Map,w=[];for(let[o,c]of y)if(c!==0n)try{b.set(o,await W(o,s,t,e.tokenFor))}catch(p){if(o===C||e.tokenFor||(await t.getCode({address:o})??"0x")!=="0x")throw p;w.push(o)}if(w.length){let o=w.flatMap(m=>["symbol","decimals"].map(l=>B({to:m,data:Q({abi:q,functionName:l}),value:"0",chainId:s,description:`Read simulated token ${l}.`}))),c=await L(t,s,[...a,...o],d);(!Array.isArray(c)||c.length!==1||!A(c[0])||!Array.isArray(c[0].calls)||c[0].calls.length!==a.length+o.length)&&P();let p=c[0].calls,h=V([{calls:p.slice(0,a.length)}],a.length,d,s);if(y.size!==h.size||[...y].some(([m,l])=>h.get(m)!==l))throw new u("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[m,l]of w.entries()){let g=(T,j)=>{let k=p[a.length+m*2+j];if(!A(k)||k.status!=="0x1"||k.error||typeof k.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(k.returnData))throw new u(`Invalid simulated token metadata for ${l} on chain ${s}.`);return J({abi:q,functionName:T,data:k.returnData})},x={address:l,chainId:s,symbol:g("symbol",0),decimals:g("decimals",1)};b.set(l,await W(l,s,t,async()=>x))}}let f=[...y].filter(([,o])=>o!==0n).map(([o,c])=>({token:b.get(o),amount:c.toString()}));return{txs:a,changes:f,summary:K}}catch(t){throw new u(`Preview on chain ${s} failed: ${F(t)}`)}}}export{C as a,ee as b,le as c};
@@ -1 +1 @@
1
- import{a as l}from"./6IM6A5VA.js";import{a as F}from"./UWOFA6GV.js";import{g as D}from"./73N3TOJL.js";import{a as U}from"./RETS2ZEK.js";import{a as c}from"./XPFVT2EA.js";import{a as w}from"./5YS5V2LK.js";import{encodeFunctionData as A,getAddress as S,parseAbi as _}from"viem";var N={address:S("0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"),symbol:"NET",decimals:9,chainId:c},r={address:S("0xb773ec2C326B7f98a5a83fc098825492F020a4c7"),symbol:"sNET",decimals:9,chainId:c},u={address:S("0x63C12667638f2Ae6fC6ae09B43D98Ec84a8586eA"),symbol:"wsNET",decimals:18,chainId:c},i=S("0xB078cc304A0B264C5F3680DC0488954ACcd02E87"),E=S("0xA1ee052EC32532304a7522bd9A4b594eC28fF1b1"),tt=[i,u.address,E],p=_(["function net() view returns (address)","function sNet() view returns (address)","function warmupEpochs() view returns (uint256)","function epoch() view returns (uint64 length,uint64 number,uint64 end,uint256 distribute)","function warmup(address) view returns (uint256 gons,uint64 releaseEpoch)","function totalStaked() view returns (uint256)","function enabled() view returns (bool)","function claim(address to) returns (uint256)","function rebase()","function stake(address to, uint256 amount) returns (uint256)","function unstake(address to, uint256 amount) returns (uint256)"]),k=_(["function sNet() view returns (address)","function wrap(uint256 sNetAmount) returns (uint256)","function unwrap(uint256 wsAmount) returns (uint256)","function sNetToWs(uint256 sNetAmount) view returns (uint256)","function wsToSNet(uint256 wsAmount) view returns (uint256)"]),C=_(["function net() view returns (address)","function sNet() view returns (address)","function staking() view returns (address)","function wsNet() view returns (address)","function zap(uint256 netAmount) returns (uint256)"]),W=_(["function balanceOf(address owner) view returns (uint256)","function balanceForGons(uint256) view returns (uint256)"]),z="The expected output is a chain-read estimate; these calls encode no minimum output. No transaction was sent.",O=o=>({anyOf:[F(`Positive ${o.symbol} amount in integer base units (${o.decimals} decimals).`),{const:"max",description:`The fresh full ${o.symbol} wallet balance.`}]}),et=o=>{async function v(e){try{return await e()}catch(t){throw new w(o.plainError(t))}}function y(e,t){if(Object.keys(e).some(n=>!t.includes(n)))throw new w("Unsupported NetNet staking argument. Use the fields in the tool schema.")}async function f(e=!1){let t=o.clientFor(c);if(await t.getChainId()!==c)throw new w("NetNet staking requires chain 4663.");let n=[t.readContract({address:i,abi:p,functionName:"net"}),t.readContract({address:i,abi:p,functionName:"sNet"}),t.readContract({address:u.address,abi:k,functionName:"sNet"}),...e?[t.readContract({address:E,abi:C,functionName:"net"}),t.readContract({address:E,abi:C,functionName:"sNet"}),t.readContract({address:E,abi:C,functionName:"staking"}),t.readContract({address:E,abi:C,functionName:"wsNet"})]:[]],[s,a,d,...m]=await Promise.all(n),b=[N.address,r.address,r.address,...e?[N.address,r.address,i,u.address]:[]];if(![s,a,d,...m].every((T,q)=>typeof T=="string"&&D(T,b[q])))throw new w("NetNet staking contracts do not report the pinned NET, sNET and wsNET links.");return t}async function x(e,t){return o.clientFor(c).readContract({address:e.address,abi:W,functionName:"balanceOf",args:[t]})}async function $(e,t,n){let s=await x(t,n),a;if(e==="max")a=s;else{if(typeof e!="string")throw new w(`Provide an integer ${t.symbol} amount in base units, or "max".`);a=U(e)}if(a<=0n||a>=1n<<256n)throw new w(`This wallet has no ${t.symbol} to use; the amount must be positive.`);if(a>s)throw new w(`Insufficient ${t.symbol}: wallet holds ${s.toString()} base units, requested ${a.toString()}.`);return a}async function g(e,t,n,s){let a=await o.preview(e,t),d=a.changes.map(({token:m,amount:b})=>{let T=b.startsWith("-");return`${T?"-":"+"}${o.formatAmount(T?b.slice(1):b,m.decimals)} ${m.symbol}`}).join(", ");return{txs:e,preview:a,expectedOutput:n,summary:`${s} ${a.summary} ${d?`Estimated changes: ${d}. `:""}${z}`}}let h=(e,t,n)=>o.unsignedTx({to:e,data:t,value:"0",chainId:c,description:n});async function j(e,t){if(y(e,["amount","wrap"]),l(t),e.wrap!==void 0&&typeof e.wrap!="boolean")throw new w("wrap must be a boolean.");let n=await f(e.wrap===!0);if(e.amount==="max")throw new w("Provide an exact NET amount in base units to stake.");let s=await n.readContract({address:i,abi:p,functionName:"warmupEpochs"});if(s!==0n&&e.wrap===!0)throw new w("NetNet warmup prevents immediate Zap wrapping; stake directly, then claim matured sNET before wrapping.");let a=await $(e.amount,N,t),d=o.formatAmount(a.toString(),N.decimals);if(e.wrap===!0){let m=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[a]});return g([o.approval(N.address,E,a.toString(),c),h(E,A({abi:C,functionName:"zap",args:[a]}),`Stake ${d} NET and wrap it into wsNET with NetNet's Zap.`)],t,{token:u,amount:m.toString()},`Approve exactly ${d} NET, then stake and wrap it into wsNET in one call.`)}return g([o.approval(N.address,i,a.toString(),c),h(i,A({abi:p,functionName:"stake",args:[S(t),a]}),`Stake ${d} NET into sNET.`)],t,{token:r,amount:s===0n?a.toString():"0"},s===0n?`Approve exactly ${d} NET, then stake it 1:1 into rebasing sNET.`:`Approve exactly ${d} NET and stake it into a ${s}-epoch warmup. No immediate sNET receipt; netnet_claim_stake releases matured sNET. Another stake resets your release epoch.`)}async function B(e,t){y(e,["amount"]),l(t),await f();let n=await $(e.amount,r,t),s=o.formatAmount(n.toString(),r.decimals);return g([o.approval(r.address,i,n.toString(),c),h(i,A({abi:p,functionName:"unstake",args:[S(t),n]}),`Unstake ${s} sNET into NET.`)],t,{token:N,amount:n.toString()},`Approve exactly ${s} sNET, then unstake it 1:1 into NET.`)}async function L(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,r,t),a=o.formatAmount(s.toString(),r.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[s]});return g([o.approval(r.address,u.address,s.toString(),c),h(u.address,A({abi:k,functionName:"wrap",args:[s]}),`Wrap ${a} sNET into wsNET.`)],t,{token:u,amount:d.toString()},`Approve exactly ${a} sNET, then wrap it into non-rebasing wsNET, the Loopback collateral.`)}async function G(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,u,t),a=o.formatAmount(s.toString(),u.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});return g([h(u.address,A({abi:k,functionName:"unwrap",args:[s]}),`Unwrap ${a} wsNET into sNET.`)],t,{token:r,amount:d.toString()},`Unwrap ${a} wsNET into sNET; no approval is needed.`)}async function M(e){return v(async()=>{l(e);let t=await f(),[n,s]=await Promise.all([x(r,e),x(u,e)]),a=[];if(n>0n&&a.push({module:"netnet",id:`${c}:${r.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:n.toString()}],description:`${o.formatAmount(n.toString(),r.decimals)} sNET staked NET (rebasing; unstakes 1:1 into NET with netnet_unstake).`}),s>0n){let m=await t.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});a.push({module:"netnet",id:`${c}:${u.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:m.toString()}],description:`${o.formatAmount(s.toString(),u.decimals)} wsNET in the wallet, worth ${o.formatAmount(m.toString(),r.decimals)} sNET (NET 1:1) at the current index. wsNET posted as Morpho collateral appears under Morpho instead.`})}if(await t.readContract({address:i,abi:p,functionName:"warmupEpochs"})>0n){let m=await I({},e);BigInt(m.warmup.pendingSNet)>0n&&a.push({module:"netnet",id:`${c}:${i.toLowerCase()}:warmup`,chainId:c,assets:[{token:N,amount:m.warmup.pendingSNet}],description:`Pending NetNet warmup stake; releases sNET at epoch ${m.warmup.releaseEpoch}. Claim with netnet_claim_stake, then wrap or unstake.`})}return a})}async function I(e,t){y(e,[]),l(t);let n=await f(),[s,a,d,m,b]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.readContract({address:i,abi:p,functionName:"warmup",args:[t]}),n.readContract({address:i,abi:p,functionName:"warmupEpochs"}),n.readContract({address:i,abi:p,functionName:"totalStaked"}),n.readContract({address:i,abi:p,functionName:"enabled"})]),T=await n.readContract({address:r.address,abi:W,functionName:"balanceForGons",args:[a[0]]});return{chainId:c,staking:i,tokens:{net:N,sNet:r,wsNet:u},enabled:b,epoch:{length:s[0].toString(),number:s[1].toString(),end:s[2].toString(),distribute:s[3].toString()},warmupEpochs:d.toString(),totalStaked:m.toString(),warmup:{gons:a[0].toString(),releaseEpoch:a[1].toString(),pendingSNet:T.toString(),matured:a[0]>0n&&s[1]>=a[1]},caveat:"Warmup uses epoch numbers, not wall-clock time. Each rebase advances at most one due epoch; a claim also rebases once if due. A new stake resets the warmup release epoch."}}async function R(e,t){let n=await I(e,t);if(!n.enabled||!n.warmup.matured)throw new w("No matured NetNet warmup stake. Read netnet_staking_status and advance a due epoch before claiming.");return g([h(i,A({abi:p,functionName:"claim",args:[t]}),`Claim matured sNET to this wallet ${t}.`)],t,{token:r,amount:n.warmup.pendingSNet},"Claim matured NetNet staking warmup; rebase may change the sNET receipt.")}async function Z(e,t){y(e,[]),l(t);let n=await f(),[s,a,d]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.getBlock(),n.readContract({address:i,abi:p,functionName:"enabled"})]);if(!d||a.timestamp<s[2])throw new w("No enabled NetNet epoch is due to rebase.");return g([h(i,A({abi:p,functionName:"rebase"}),"Advance one due NetNet staking epoch and checkpoint its oracle.")],t,{token:r,amount:"0"},"Advance one due epoch. Distribution depends on live protocol state; this does not guarantee a reward.")}let P=(e,t,n)=>({name:e,inputSchema:{type:"object",properties:t,required:["amount"],additionalProperties:!1},execute:(s,a)=>v(()=>n(s,a))});return{positions:M,tools:[{name:"netnet_staking_status",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>I(e,t))},{name:"netnet_claim_stake",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>R(e,t))},{name:"netnet_rebase",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>Z(e,t))},P("netnet_stake",{amount:F("Positive NET amount in integer base units (9 decimals)."),wrap:{type:"boolean",default:!1,description:"Stake and wrap into wsNET in one call through NetNet's Zap."}},j),P("netnet_wrap",{amount:O(r)},L),P("netnet_unwrap",{amount:O(u)},G),P("netnet_unstake",{amount:O(r)},B)]}};export{N as a,r as b,u as c,i as d,E as e,tt as f,et as g};
1
+ import{a as l}from"./6IM6A5VA.js";import{a as F}from"./UWOFA6GV.js";import{g as D}from"./73N3TOJL.js";import{a as U}from"./RETS2ZEK.js";import{a as c}from"./G6HCV67X.js";import{a as w}from"./5YS5V2LK.js";import{encodeFunctionData as A,getAddress as S,parseAbi as _}from"viem";var N={address:S("0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"),symbol:"NET",decimals:9,chainId:c},r={address:S("0xb773ec2C326B7f98a5a83fc098825492F020a4c7"),symbol:"sNET",decimals:9,chainId:c},u={address:S("0x63C12667638f2Ae6fC6ae09B43D98Ec84a8586eA"),symbol:"wsNET",decimals:18,chainId:c},i=S("0xB078cc304A0B264C5F3680DC0488954ACcd02E87"),E=S("0xA1ee052EC32532304a7522bd9A4b594eC28fF1b1"),tt=[i,u.address,E],p=_(["function net() view returns (address)","function sNet() view returns (address)","function warmupEpochs() view returns (uint256)","function epoch() view returns (uint64 length,uint64 number,uint64 end,uint256 distribute)","function warmup(address) view returns (uint256 gons,uint64 releaseEpoch)","function totalStaked() view returns (uint256)","function enabled() view returns (bool)","function claim(address to) returns (uint256)","function rebase()","function stake(address to, uint256 amount) returns (uint256)","function unstake(address to, uint256 amount) returns (uint256)"]),k=_(["function sNet() view returns (address)","function wrap(uint256 sNetAmount) returns (uint256)","function unwrap(uint256 wsAmount) returns (uint256)","function sNetToWs(uint256 sNetAmount) view returns (uint256)","function wsToSNet(uint256 wsAmount) view returns (uint256)"]),C=_(["function net() view returns (address)","function sNet() view returns (address)","function staking() view returns (address)","function wsNet() view returns (address)","function zap(uint256 netAmount) returns (uint256)"]),W=_(["function balanceOf(address owner) view returns (uint256)","function balanceForGons(uint256) view returns (uint256)"]),z="The expected output is a chain-read estimate; these calls encode no minimum output. No transaction was sent.",O=o=>({anyOf:[F(`Positive ${o.symbol} amount in integer base units (${o.decimals} decimals).`),{const:"max",description:`The fresh full ${o.symbol} wallet balance.`}]}),et=o=>{async function v(e){try{return await e()}catch(t){throw new w(o.plainError(t))}}function y(e,t){if(Object.keys(e).some(n=>!t.includes(n)))throw new w("Unsupported NetNet staking argument. Use the fields in the tool schema.")}async function f(e=!1){let t=o.clientFor(c);if(await t.getChainId()!==c)throw new w("NetNet staking requires chain 4663.");let n=[t.readContract({address:i,abi:p,functionName:"net"}),t.readContract({address:i,abi:p,functionName:"sNet"}),t.readContract({address:u.address,abi:k,functionName:"sNet"}),...e?[t.readContract({address:E,abi:C,functionName:"net"}),t.readContract({address:E,abi:C,functionName:"sNet"}),t.readContract({address:E,abi:C,functionName:"staking"}),t.readContract({address:E,abi:C,functionName:"wsNet"})]:[]],[s,a,d,...m]=await Promise.all(n),b=[N.address,r.address,r.address,...e?[N.address,r.address,i,u.address]:[]];if(![s,a,d,...m].every((T,q)=>typeof T=="string"&&D(T,b[q])))throw new w("NetNet staking contracts do not report the pinned NET, sNET and wsNET links.");return t}async function x(e,t){return o.clientFor(c).readContract({address:e.address,abi:W,functionName:"balanceOf",args:[t]})}async function $(e,t,n){let s=await x(t,n),a;if(e==="max")a=s;else{if(typeof e!="string")throw new w(`Provide an integer ${t.symbol} amount in base units, or "max".`);a=U(e)}if(a<=0n||a>=1n<<256n)throw new w(`This wallet has no ${t.symbol} to use; the amount must be positive.`);if(a>s)throw new w(`Insufficient ${t.symbol}: wallet holds ${s.toString()} base units, requested ${a.toString()}.`);return a}async function g(e,t,n,s){let a=await o.preview(e,t),d=a.changes.map(({token:m,amount:b})=>{let T=b.startsWith("-");return`${T?"-":"+"}${o.formatAmount(T?b.slice(1):b,m.decimals)} ${m.symbol}`}).join(", ");return{txs:e,preview:a,expectedOutput:n,summary:`${s} ${a.summary} ${d?`Estimated changes: ${d}. `:""}${z}`}}let h=(e,t,n)=>o.unsignedTx({to:e,data:t,value:"0",chainId:c,description:n});async function j(e,t){if(y(e,["amount","wrap"]),l(t),e.wrap!==void 0&&typeof e.wrap!="boolean")throw new w("wrap must be a boolean.");let n=await f(e.wrap===!0);if(e.amount==="max")throw new w("Provide an exact NET amount in base units to stake.");let s=await n.readContract({address:i,abi:p,functionName:"warmupEpochs"});if(s!==0n&&e.wrap===!0)throw new w("NetNet warmup prevents immediate Zap wrapping; stake directly, then claim matured sNET before wrapping.");let a=await $(e.amount,N,t),d=o.formatAmount(a.toString(),N.decimals);if(e.wrap===!0){let m=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[a]});return g([o.approval(N.address,E,a.toString(),c),h(E,A({abi:C,functionName:"zap",args:[a]}),`Stake ${d} NET and wrap it into wsNET with NetNet's Zap.`)],t,{token:u,amount:m.toString()},`Approve exactly ${d} NET, then stake and wrap it into wsNET in one call.`)}return g([o.approval(N.address,i,a.toString(),c),h(i,A({abi:p,functionName:"stake",args:[S(t),a]}),`Stake ${d} NET into sNET.`)],t,{token:r,amount:s===0n?a.toString():"0"},s===0n?`Approve exactly ${d} NET, then stake it 1:1 into rebasing sNET.`:`Approve exactly ${d} NET and stake it into a ${s}-epoch warmup. No immediate sNET receipt; netnet_claim_stake releases matured sNET. Another stake resets your release epoch.`)}async function B(e,t){y(e,["amount"]),l(t),await f();let n=await $(e.amount,r,t),s=o.formatAmount(n.toString(),r.decimals);return g([o.approval(r.address,i,n.toString(),c),h(i,A({abi:p,functionName:"unstake",args:[S(t),n]}),`Unstake ${s} sNET into NET.`)],t,{token:N,amount:n.toString()},`Approve exactly ${s} sNET, then unstake it 1:1 into NET.`)}async function L(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,r,t),a=o.formatAmount(s.toString(),r.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"sNetToWs",args:[s]});return g([o.approval(r.address,u.address,s.toString(),c),h(u.address,A({abi:k,functionName:"wrap",args:[s]}),`Wrap ${a} sNET into wsNET.`)],t,{token:u,amount:d.toString()},`Approve exactly ${a} sNET, then wrap it into non-rebasing wsNET, the Loopback collateral.`)}async function G(e,t){y(e,["amount"]),l(t);let n=await f(),s=await $(e.amount,u,t),a=o.formatAmount(s.toString(),u.decimals),d=await n.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});return g([h(u.address,A({abi:k,functionName:"unwrap",args:[s]}),`Unwrap ${a} wsNET into sNET.`)],t,{token:r,amount:d.toString()},`Unwrap ${a} wsNET into sNET; no approval is needed.`)}async function M(e){return v(async()=>{l(e);let t=await f(),[n,s]=await Promise.all([x(r,e),x(u,e)]),a=[];if(n>0n&&a.push({module:"netnet",id:`${c}:${r.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:n.toString()}],description:`${o.formatAmount(n.toString(),r.decimals)} sNET staked NET (rebasing; unstakes 1:1 into NET with netnet_unstake).`}),s>0n){let m=await t.readContract({address:u.address,abi:k,functionName:"wsToSNet",args:[s]});a.push({module:"netnet",id:`${c}:${u.address.toLowerCase()}`,chainId:c,assets:[{token:{...N},amount:m.toString()}],description:`${o.formatAmount(s.toString(),u.decimals)} wsNET in the wallet, worth ${o.formatAmount(m.toString(),r.decimals)} sNET (NET 1:1) at the current index. wsNET posted as Morpho collateral appears under Morpho instead.`})}if(await t.readContract({address:i,abi:p,functionName:"warmupEpochs"})>0n){let m=await I({},e);BigInt(m.warmup.pendingSNet)>0n&&a.push({module:"netnet",id:`${c}:${i.toLowerCase()}:warmup`,chainId:c,assets:[{token:N,amount:m.warmup.pendingSNet}],description:`Pending NetNet warmup stake; releases sNET at epoch ${m.warmup.releaseEpoch}. Claim with netnet_claim_stake, then wrap or unstake.`})}return a})}async function I(e,t){y(e,[]),l(t);let n=await f(),[s,a,d,m,b]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.readContract({address:i,abi:p,functionName:"warmup",args:[t]}),n.readContract({address:i,abi:p,functionName:"warmupEpochs"}),n.readContract({address:i,abi:p,functionName:"totalStaked"}),n.readContract({address:i,abi:p,functionName:"enabled"})]),T=await n.readContract({address:r.address,abi:W,functionName:"balanceForGons",args:[a[0]]});return{chainId:c,staking:i,tokens:{net:N,sNet:r,wsNet:u},enabled:b,epoch:{length:s[0].toString(),number:s[1].toString(),end:s[2].toString(),distribute:s[3].toString()},warmupEpochs:d.toString(),totalStaked:m.toString(),warmup:{gons:a[0].toString(),releaseEpoch:a[1].toString(),pendingSNet:T.toString(),matured:a[0]>0n&&s[1]>=a[1]},caveat:"Warmup uses epoch numbers, not wall-clock time. Each rebase advances at most one due epoch; a claim also rebases once if due. A new stake resets the warmup release epoch."}}async function R(e,t){let n=await I(e,t);if(!n.enabled||!n.warmup.matured)throw new w("No matured NetNet warmup stake. Read netnet_staking_status and advance a due epoch before claiming.");return g([h(i,A({abi:p,functionName:"claim",args:[t]}),`Claim matured sNET to this wallet ${t}.`)],t,{token:r,amount:n.warmup.pendingSNet},"Claim matured NetNet staking warmup; rebase may change the sNET receipt.")}async function Z(e,t){y(e,[]),l(t);let n=await f(),[s,a,d]=await Promise.all([n.readContract({address:i,abi:p,functionName:"epoch"}),n.getBlock(),n.readContract({address:i,abi:p,functionName:"enabled"})]);if(!d||a.timestamp<s[2])throw new w("No enabled NetNet epoch is due to rebase.");return g([h(i,A({abi:p,functionName:"rebase"}),"Advance one due NetNet staking epoch and checkpoint its oracle.")],t,{token:r,amount:"0"},"Advance one due epoch. Distribution depends on live protocol state; this does not guarantee a reward.")}let P=(e,t,n)=>({name:e,inputSchema:{type:"object",properties:t,required:["amount"],additionalProperties:!1},execute:(s,a)=>v(()=>n(s,a))});return{positions:M,tools:[{name:"netnet_staking_status",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>I(e,t))},{name:"netnet_claim_stake",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>R(e,t))},{name:"netnet_rebase",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:(e,t)=>v(()=>Z(e,t))},P("netnet_stake",{amount:F("Positive NET amount in integer base units (9 decimals)."),wrap:{type:"boolean",default:!1,description:"Stake and wrap into wsNET in one call through NetNet's Zap."}},j),P("netnet_wrap",{amount:O(r)},L),P("netnet_unwrap",{amount:O(u)},G),P("netnet_unstake",{amount:O(r)},B)]}};export{N as a,r as b,u as c,i as d,E as e,tt as f,et as g};
@@ -1 +1 @@
1
- import{c as v,d as N,e as h}from"./ULJ6E4HP.js";import{a as m}from"./UWOFA6GV.js";import{c as d,f as B,g as p,i as E}from"./73N3TOJL.js";import{a as H}from"./XPFVT2EA.js";import{a as o}from"./5YS5V2LK.js";import{decodeEventLog as W,encodeFunctionData as G,getAddress as V,hashStruct as Y,isHex as J,parseAbi as Q,zeroAddress as k}from"viem";var Z="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",I=Q(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",Z,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),ee={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},ne=V("0x000000000022D473030F116dDEE9F6B43aC78BA3"),F={key:{type:"object",properties:{currency0:d,currency1:d,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:d},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean"},amountSpecified:{type:"string",pattern:"^-?[0-9]+$"},amountBound:m(),sqrtPriceLimitX96:m(),recipient:d,relayer:d,relayerFee:m(),engagement:d,campaigns:{type:"array",items:m(),maxItems:8},nonce:m(),deadline:m()},x={owner:d,signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$"},intent:{type:"object",properties:F,required:Object.keys(F),additionalProperties:!1}};function D(t){return B(t,"Provide a complete trader-signed Hookr intent.")}function y(t,i=256,e=!1){if(typeof t!="string"||!/^-?\d+$/.test(t)||t.length>79)throw new o("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let n=BigInt(t);if(e?n<=-(1n<<BigInt(i-1))||n>=1n<<BigInt(i-1):n<0n||n>=1n<<BigInt(i))throw new o("Hookr intent integer is outside its ABI range.");return n}function l(t){return E(t,"Provide valid Hookr intent addresses.")}function j(t,i){if(Object.keys(t).some(s=>!Object.hasOwn(x,s)))throw new o("Provide only owner, intent and the trader signature for Hookr relay.");let e=D(t.intent);if(Object.keys(e).some(s=>!Object.hasOwn(F,s)))throw new o("Hookr intent contains an undocumented field.");let n=D(e.key);if(Object.keys(n).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof n.fee!="number"||!Number.isInteger(n.fee)||n.fee<0||n.fee>16777215||typeof n.tickSpacing!="number"||!Number.isInteger(n.tickSpacing)||n.tickSpacing<=0||n.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new o("Provide a valid canonical v4 pool key and direction.");let a={currency0:l(n.currency0),currency1:l(n.currency1),fee:n.fee,tickSpacing:n.tickSpacing,hooks:l(n.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new o("Hookr pool currencies must sort strictly by address.");let r=l(t.owner);if(r===k||p(r,i))throw new o("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new o("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:y(e.amountSpecified,128,!0),amountBound:y(e.amountBound,128),sqrtPriceLimitX96:y(e.sqrtPriceLimitX96,160),recipient:l(e.recipient),relayer:l(e.relayer),relayerFee:y(e.relayerFee),engagement:l(e.engagement),campaigns:e.campaigns.map(s=>y(s)),nonce:y(e.nonce),deadline:y(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new o("Hookr intent input/output amounts and bound must be nonzero.");if([k,h,v].some(s=>p(s,c.recipient)))throw new o("Hookr intent recipient is reserved.");if(c.relayer!==k&&!p(c.relayer,i)||c.relayer===k&&c.relayerFee!==0n)throw new o("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===k!=(c.campaigns.length===0))throw new o("Hookr engagement and campaigns must be supplied together.");let f=c.zeroForOne?a.currency0:a.currency1;if(f===k)throw new o("Hookr Permit2 relay cannot pull native ETH input.");if(typeof t.signature!="string"||!J(t.signature,{strict:!0})||t.signature.length<4||t.signature.length%2!==0||t.signature.length>16386)throw new o("Provide the trader-signed Permit2 witness signature, never a private key.");let S=t.signature,w=Y({data:c,primaryType:"HookrSwapIntent",types:ee});return{owner:r,intent:c,signature:S,input:f,intentHash:w}}function q(t,i){let{owner:e,intent:n,signature:a}=j(t,i);return{chainId:H,to:h,value:"0",data:G({abi:I,functionName:"execute",args:[n,e,a]}),description:`Relay Hookr trader ${e} to recipient ${n.recipient}; relayer fee ${n.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function ce(t,i,e){let n=q(i,e);if(t.length!==1||t[0].chainId!==n.chainId||!p(t[0].to,n.to)||t[0].value!=="0"||!p(t[0].data,n.data))throw new o("Hookr relay calldata differs from the locally requested signed intent.")}function ue(t){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:x,required:Object.keys(x),additionalProperties:!1},execute:async(i,e)=>{let n=j(i,e),{owner:a,intent:r,signature:c,input:f,intentHash:S}=n,w=t.clientFor(H),s=await w.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>r.deadline)throw new o("Hookr signed intent expired or the chain timestamp is unavailable.");let g=(X,M=[])=>w.readContract({address:h,abi:I,functionName:X,args:M,blockNumber:s.number}),[_,u,z,K,$,U]=await Promise.all([g("hashIntent",[r]),g("pullOf",[r]),g("isNonceUsed",[a,r.nonce]),g("router"),g("registry"),g("permit2")]);if(_!==S||z!==!1||K!==v||$!==N||U!==ne)throw new o("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(u)||u.length!==3||typeof u[0]!="string"||!p(u[0],f)||typeof u[1]!="bigint"||typeof u[2]!="boolean")throw new o("Hookr Permit2 pull could not be verified.");let b=u[2],P=r.amountSpecified<0n?-r.amountSpecified:r.amountBound;if(u[1]!==P+(b?r.relayerFee:0n)||r.amountSpecified>0n&&!b&&r.relayerFee>r.amountSpecified)throw new o("Hookr Permit2 pull or output-side fee differs from the signed terms.");let C=await w.simulateContract({address:h,abi:I,functionName:"execute",args:[r,a,c],account:e,blockNumber:s.number}),[A,R]=C.result,T=r.amountSpecified<0n?r.amountBound:r.amountSpecified-(b?0n:r.relayerFee);if(A>P||R<T)throw new o("Hookr relay simulation did not satisfy the signed input/output bounds.");let O=[t.unsignedTx(q(i,e))],L=await t.preview(O,e);return{txs:O,preview:L,summary:O[0].description,intentHash:S,owner:a,recipient:r.recipient,relayer:e,inputToken:f,maximumPull:u[1].toString(),feeToken:b?f:r.zeroForOne?r.key.currency1:r.key.currency0,relayerFee:r.relayerFee.toString(),feeFromInput:b,minimumOutput:T.toString(),simulatedAmountIn:A.toString(),simulatedAmountOut:R.toString(),note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}},required:["transactionHash"],additionalProperties:!1},execute:async i=>{if(Object.keys(i).some(a=>a!=="transactionHash")||typeof i.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(i.transactionHash))throw new o("Provide a Hookr relay transactionHash.");let e=await t.clientFor(H).getTransactionReceipt({hash:i.transactionHash});if(e.status!=="success")throw new o("Hookr relay reverted. No fee is proven paid.");let n=e.logs.filter(a=>p(a.address,h)).flatMap(a=>{try{let r=W({abi:I,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...r.args,amountIn:r.args.amountIn.toString(),amountOut:r.args.amountOut.toString(),relayerFee:r.args.relayerFee.toString()}]}catch{return[]}});if(!n.length)throw new o("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:H,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:n,note:"Event evidence at this mined block; check balances and finality."}}}]}export{I as a,j as b,q as c,ce as d,ue as e};
1
+ import{c as v,d as N,e as h}from"./TMGWXDCZ.js";import{a as m}from"./UWOFA6GV.js";import{c as d,f as B,g as p,i as E}from"./73N3TOJL.js";import{a as H}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.js";import{decodeEventLog as W,encodeFunctionData as G,getAddress as V,hashStruct as Y,isHex as J,parseAbi as Q,zeroAddress as k}from"viem";var Z="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",I=Q(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",Z,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),ee={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},ne=V("0x000000000022D473030F116dDEE9F6B43aC78BA3"),F={key:{type:"object",properties:{currency0:d,currency1:d,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:d},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean"},amountSpecified:{type:"string",pattern:"^-?[0-9]+$"},amountBound:m(),sqrtPriceLimitX96:m(),recipient:d,relayer:d,relayerFee:m(),engagement:d,campaigns:{type:"array",items:m(),maxItems:8},nonce:m(),deadline:m()},x={owner:d,signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$"},intent:{type:"object",properties:F,required:Object.keys(F),additionalProperties:!1}};function D(t){return B(t,"Provide a complete trader-signed Hookr intent.")}function y(t,i=256,e=!1){if(typeof t!="string"||!/^-?\d+$/.test(t)||t.length>79)throw new o("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let n=BigInt(t);if(e?n<=-(1n<<BigInt(i-1))||n>=1n<<BigInt(i-1):n<0n||n>=1n<<BigInt(i))throw new o("Hookr intent integer is outside its ABI range.");return n}function l(t){return E(t,"Provide valid Hookr intent addresses.")}function j(t,i){if(Object.keys(t).some(s=>!Object.hasOwn(x,s)))throw new o("Provide only owner, intent and the trader signature for Hookr relay.");let e=D(t.intent);if(Object.keys(e).some(s=>!Object.hasOwn(F,s)))throw new o("Hookr intent contains an undocumented field.");let n=D(e.key);if(Object.keys(n).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof n.fee!="number"||!Number.isInteger(n.fee)||n.fee<0||n.fee>16777215||typeof n.tickSpacing!="number"||!Number.isInteger(n.tickSpacing)||n.tickSpacing<=0||n.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new o("Provide a valid canonical v4 pool key and direction.");let a={currency0:l(n.currency0),currency1:l(n.currency1),fee:n.fee,tickSpacing:n.tickSpacing,hooks:l(n.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new o("Hookr pool currencies must sort strictly by address.");let r=l(t.owner);if(r===k||p(r,i))throw new o("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new o("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:y(e.amountSpecified,128,!0),amountBound:y(e.amountBound,128),sqrtPriceLimitX96:y(e.sqrtPriceLimitX96,160),recipient:l(e.recipient),relayer:l(e.relayer),relayerFee:y(e.relayerFee),engagement:l(e.engagement),campaigns:e.campaigns.map(s=>y(s)),nonce:y(e.nonce),deadline:y(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new o("Hookr intent input/output amounts and bound must be nonzero.");if([k,h,v].some(s=>p(s,c.recipient)))throw new o("Hookr intent recipient is reserved.");if(c.relayer!==k&&!p(c.relayer,i)||c.relayer===k&&c.relayerFee!==0n)throw new o("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===k!=(c.campaigns.length===0))throw new o("Hookr engagement and campaigns must be supplied together.");let f=c.zeroForOne?a.currency0:a.currency1;if(f===k)throw new o("Hookr Permit2 relay cannot pull native ETH input.");if(typeof t.signature!="string"||!J(t.signature,{strict:!0})||t.signature.length<4||t.signature.length%2!==0||t.signature.length>16386)throw new o("Provide the trader-signed Permit2 witness signature, never a private key.");let S=t.signature,w=Y({data:c,primaryType:"HookrSwapIntent",types:ee});return{owner:r,intent:c,signature:S,input:f,intentHash:w}}function q(t,i){let{owner:e,intent:n,signature:a}=j(t,i);return{chainId:H,to:h,value:"0",data:G({abi:I,functionName:"execute",args:[n,e,a]}),description:`Relay Hookr trader ${e} to recipient ${n.recipient}; relayer fee ${n.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function ce(t,i,e){let n=q(i,e);if(t.length!==1||t[0].chainId!==n.chainId||!p(t[0].to,n.to)||t[0].value!=="0"||!p(t[0].data,n.data))throw new o("Hookr relay calldata differs from the locally requested signed intent.")}function ue(t){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:x,required:Object.keys(x),additionalProperties:!1},execute:async(i,e)=>{let n=j(i,e),{owner:a,intent:r,signature:c,input:f,intentHash:S}=n,w=t.clientFor(H),s=await w.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>r.deadline)throw new o("Hookr signed intent expired or the chain timestamp is unavailable.");let g=(X,M=[])=>w.readContract({address:h,abi:I,functionName:X,args:M,blockNumber:s.number}),[_,u,z,K,$,U]=await Promise.all([g("hashIntent",[r]),g("pullOf",[r]),g("isNonceUsed",[a,r.nonce]),g("router"),g("registry"),g("permit2")]);if(_!==S||z!==!1||K!==v||$!==N||U!==ne)throw new o("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(u)||u.length!==3||typeof u[0]!="string"||!p(u[0],f)||typeof u[1]!="bigint"||typeof u[2]!="boolean")throw new o("Hookr Permit2 pull could not be verified.");let b=u[2],P=r.amountSpecified<0n?-r.amountSpecified:r.amountBound;if(u[1]!==P+(b?r.relayerFee:0n)||r.amountSpecified>0n&&!b&&r.relayerFee>r.amountSpecified)throw new o("Hookr Permit2 pull or output-side fee differs from the signed terms.");let C=await w.simulateContract({address:h,abi:I,functionName:"execute",args:[r,a,c],account:e,blockNumber:s.number}),[A,R]=C.result,T=r.amountSpecified<0n?r.amountBound:r.amountSpecified-(b?0n:r.relayerFee);if(A>P||R<T)throw new o("Hookr relay simulation did not satisfy the signed input/output bounds.");let O=[t.unsignedTx(q(i,e))],L=await t.preview(O,e);return{txs:O,preview:L,summary:O[0].description,intentHash:S,owner:a,recipient:r.recipient,relayer:e,inputToken:f,maximumPull:u[1].toString(),feeToken:b?f:r.zeroForOne?r.key.currency1:r.key.currency0,relayerFee:r.relayerFee.toString(),feeFromInput:b,minimumOutput:T.toString(),simulatedAmountIn:A.toString(),simulatedAmountOut:R.toString(),note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}},required:["transactionHash"],additionalProperties:!1},execute:async i=>{if(Object.keys(i).some(a=>a!=="transactionHash")||typeof i.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(i.transactionHash))throw new o("Provide a Hookr relay transactionHash.");let e=await t.clientFor(H).getTransactionReceipt({hash:i.transactionHash});if(e.status!=="success")throw new o("Hookr relay reverted. No fee is proven paid.");let n=e.logs.filter(a=>p(a.address,h)).flatMap(a=>{try{let r=W({abi:I,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...r.args,amountIn:r.args.amountIn.toString(),amountOut:r.args.amountOut.toString(),relayerFee:r.args.relayerFee.toString()}]}catch{return[]}});if(!n.length)throw new o("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:H,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:n,note:"Event evidence at this mined block; check balances and finality."}}}]}export{I as a,j as b,q as c,ce as d,ue as e};
@@ -1 +1 @@
1
- import{g as h}from"./O47JXRXN.js";import{a as O}from"./6IM6A5VA.js";import{a as l}from"./UWOFA6GV.js";import{h as g}from"./73N3TOJL.js";import{a as w,i as B}from"./XPFVT2EA.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as k,getAddress as T,parseAbi as D,parseAbiItem as _,zeroAddress as E}from"viem";var b=T("0x23e99d72e24dc538c955b9bade710d2ce3a7fca4"),v={address:T(B[w].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:w},f=D(["function rewardToken() view returns (address)","function owner() view returns (address)","function publisher() view returns (address)","function epochs(uint256) view returns (bytes32 root,uint128 total,uint128 claimed,uint64 expiry,bool swept)","function hasClaimed(uint256,address) view returns (bool)","function claimable(uint256 epochId,address account,uint256 amount,bytes32[] proof) view returns (bool)","function claim(uint256 epochId,uint256 amount,bytes32[] proof)","function setPublisher(address publisher)","function sweep(uint256 epochId,address to)","function fundEpoch(uint256 epochId,bytes32 root,uint256 total,uint64 expiry)","function transferOwnership(address newOwner)","function renounceOwnership()"]),N=_("event EpochFunded(uint256 indexed epochId,bytes32 root,uint256 total,uint64 expiry)"),P=p=>{if(typeof p!="string"||!/^0x[0-9a-f]{64}$/i.test(p))throw new n("Provide a bytes32 Merkle root or proof element.");return p};function R(p){if(!Array.isArray(p)||p.length>64)throw new n("Provide the publisher\u2019s Merkle proof array (at most 64 elements).");return p.map(P)}var M=p=>{async function x(){let e=p.clientFor(w);if(await e.getChainId()!==w)throw new n("Longbow rebates require chain 4663.");let a=await e.getBlock(),s=(o,c=[])=>e.readContract({address:b,abi:f,functionName:o,args:c,blockNumber:a.number}),i=await s("rewardToken");if(!g(i,v.address))throw new n("The Longbow rebate distributor does not report canonical USDG.");return{client:e,block:a,read:s}}async function A(e,a,s,i){let[o,c]=await Promise.all([s("epochs",[e]),s("hasClaimed",[e,a])]);if(!Array.isArray(o)||o.length!==5||typeof c!="boolean")throw new n("Invalid rebate epoch state.");let[r,d,u,m,t]=o;if(typeof d!="bigint"||typeof u!="bigint"||u>d||typeof m!="bigint"||typeof t!="boolean")throw new n("Invalid rebate epoch amounts.");return{epochId:e.toString(),root:P(r),total:d.toString(),claimedAmount:u.toString(),outstanding:(t?0n:d-u).toString(),expiry:m.toString(),swept:t,hasClaimed:c,open:r!==`0x${"0".repeat(64)}`&&!t&&i<m}}let S=(e,a,s,i)=>({name:e,inputSchema:{type:"object",properties:a,required:s,additionalProperties:!1},execute:async(o,c)=>{try{if(O(c),Object.keys(o).some(r=>!Object.hasOwn(a,r)))throw new n("Unsupported Longbow rebate argument.");return await i(o,c)}catch(r){throw new n(p.plainError(r))}}});return{tools:[S("longbow_rebates",{epochIds:{type:"array",maxItems:100,items:l()},fromBlock:l()},[],async(e,a)=>{let{client:s,read:i,block:o}=await x();if(e.epochIds!==void 0&&e.fromBlock!==void 0)throw new n("Use epochIds or fromBlock, not both.");let c,r;if(e.epochIds!==void 0){if(!Array.isArray(e.epochIds)||e.epochIds.length>100)throw new n("Provide at most 100 rebate epochIds.");c=e.epochIds.map(t=>h(t))}else{if(r=e.fromBlock===void 0?o.number>100000n?o.number-100000n:0n:h(e.fromBlock),r>o.number||o.number-r>1000000n)throw new n("Read at most 1000000 blocks per rebate discovery window.");let t=await s.getLogs({address:b,event:N,fromBlock:r,toBlock:o.number,strict:!0});if(c=[...new Set(t.map(y=>y.args.epochId))],c.length>100)throw new n("Too many rebate epochs; narrow the block window.")}let[d,u,m]=await Promise.all([i("owner"),i("publisher"),Promise.all(c.map(t=>A(t,a,i,o.timestamp)))]);return{chainId:w,distributor:b,token:v,blockNumber:o.number.toString(),owner:d,publisher:u,epochs:m,scannedFromBlock:r?.toString()??null,caveat:"Discovery covers only these IDs or this event window. Amounts/proofs require the publisher\u2019s tree; the app does not expose a verified proof endpoint. Claims expire at each on-chain expiry, even if app prose says otherwise."}}),S("longbow_claim_rebate",{epochId:l(),amount:l(),proof:{type:"array",maxItems:64,items:{type:"string"}}},["epochId","amount","proof"],async(e,a)=>{let s=h(e.epochId),i=h(e.amount),o=R(e.proof),{read:c,block:r}=await x(),d=await A(s,a,c,r.timestamp);if(!d.open||d.hasClaimed||i===0n||await c("claimable",[s,a,i,o])!==!0)throw new n("Rebate is closed, already claimed or not proven for this wallet and amount.");let u=`Claim ${i} USDG base units from Longbow rebate epoch ${s} to this wallet ${a}. No approvals.`,m=[p.unsignedTx({to:b,data:k({abi:f,functionName:"claim",args:[s,i,o]}),value:"0",chainId:w,description:u})],t=await p.preview(m,a);if(t.changes.filter(I=>I.token.chainId===w&&g(I.token.address,v.address)&&I.token.decimals===6).reduce((I,C)=>I+BigInt(C.amount),0n)!==i)throw new n("Rebate preview does not return the exact proven USDG amount.");return{txs:m,preview:t,summary:`${u} ${t.summary}`}}),S("longbow_manage_rebates",{operation:{enum:["setPublisher","fundEpoch","sweep","transferOwnership","renounceOwnership"]},epochId:l(),root:{type:"string"},amount:l(),expiry:l(),account:{type:"string"}},["operation"],async(e,a)=>{let{read:s,block:i}=await x(),o=e.operation==="fundEpoch";if(!g(await s(o?"publisher":"owner"),a))throw new n("This wallet lacks the rebate publisher/owner role.");let c=o?["operation","epochId","root","amount","expiry"]:e.operation==="sweep"?["operation","epochId","account"]:e.operation==="renounceOwnership"?["operation"]:["operation","account"];if(Object.keys(e).some(t=>!c.includes(t)))throw new n("Unexpected fields for this rebate management operation.");let r,d=0n;if(o){let t=h(e.expiry,64);if(d=h(e.amount,128),d===0n||t<i.timestamp+30n*86400n)throw new n("Fund a positive rebate amount with at least 30 days to claim.");r=k({abi:f,functionName:"fundEpoch",args:[h(e.epochId),P(e.root),d,t]})}else if(e.operation==="renounceOwnership")r=k({abi:f,functionName:"renounceOwnership"});else{if(typeof e.account!="string")throw new n("Provide the explicit publisher, owner or sweep recipient.");O(e.account);let t=T(e.account);if(t===E)throw new n("The rebate recipient/role cannot be zero.");if(e.operation==="sweep"){let y=await A(h(e.epochId),a,s,i.timestamp);if(y.swept||i.timestamp<BigInt(y.expiry))throw new n("Only expired, unswept rebate epochs can be swept.");r=k({abi:f,functionName:"sweep",args:[h(e.epochId),t]})}else if(e.operation==="setPublisher"||e.operation==="transferOwnership")r=k({abi:f,functionName:e.operation,args:[t]});else throw new n("Choose a supported rebate management operation.")}let u=`Longbow rebate ${String(e.operation)}: ${JSON.stringify(e)}. ${e.operation==="renounceOwnership"?"Owner administration is permanently relinquished.":""}`,m=[...o?[p.approval(v.address,b,d.toString(),w)]:[],p.unsignedTx({to:b,data:r,value:"0",chainId:w,description:u})];return{txs:m,preview:await p.preview(m,a),summary:u}})]}};export{b as a,f as b,M as c};
1
+ import{g as h}from"./NAYRD43N.js";import{a as O}from"./6IM6A5VA.js";import{a as l}from"./UWOFA6GV.js";import{h as g}from"./73N3TOJL.js";import{a as w,i as B}from"./G6HCV67X.js";import{a as n}from"./5YS5V2LK.js";import{encodeFunctionData as k,getAddress as T,parseAbi as D,parseAbiItem as _,zeroAddress as E}from"viem";var b=T("0x23e99d72e24dc538c955b9bade710d2ce3a7fca4"),v={address:T(B[w].tokens.USDG.address),symbol:"USDG",decimals:6,chainId:w},f=D(["function rewardToken() view returns (address)","function owner() view returns (address)","function publisher() view returns (address)","function epochs(uint256) view returns (bytes32 root,uint128 total,uint128 claimed,uint64 expiry,bool swept)","function hasClaimed(uint256,address) view returns (bool)","function claimable(uint256 epochId,address account,uint256 amount,bytes32[] proof) view returns (bool)","function claim(uint256 epochId,uint256 amount,bytes32[] proof)","function setPublisher(address publisher)","function sweep(uint256 epochId,address to)","function fundEpoch(uint256 epochId,bytes32 root,uint256 total,uint64 expiry)","function transferOwnership(address newOwner)","function renounceOwnership()"]),N=_("event EpochFunded(uint256 indexed epochId,bytes32 root,uint256 total,uint64 expiry)"),P=p=>{if(typeof p!="string"||!/^0x[0-9a-f]{64}$/i.test(p))throw new n("Provide a bytes32 Merkle root or proof element.");return p};function R(p){if(!Array.isArray(p)||p.length>64)throw new n("Provide the publisher\u2019s Merkle proof array (at most 64 elements).");return p.map(P)}var M=p=>{async function x(){let e=p.clientFor(w);if(await e.getChainId()!==w)throw new n("Longbow rebates require chain 4663.");let a=await e.getBlock(),s=(o,c=[])=>e.readContract({address:b,abi:f,functionName:o,args:c,blockNumber:a.number}),i=await s("rewardToken");if(!g(i,v.address))throw new n("The Longbow rebate distributor does not report canonical USDG.");return{client:e,block:a,read:s}}async function A(e,a,s,i){let[o,c]=await Promise.all([s("epochs",[e]),s("hasClaimed",[e,a])]);if(!Array.isArray(o)||o.length!==5||typeof c!="boolean")throw new n("Invalid rebate epoch state.");let[r,d,u,m,t]=o;if(typeof d!="bigint"||typeof u!="bigint"||u>d||typeof m!="bigint"||typeof t!="boolean")throw new n("Invalid rebate epoch amounts.");return{epochId:e.toString(),root:P(r),total:d.toString(),claimedAmount:u.toString(),outstanding:(t?0n:d-u).toString(),expiry:m.toString(),swept:t,hasClaimed:c,open:r!==`0x${"0".repeat(64)}`&&!t&&i<m}}let S=(e,a,s,i)=>({name:e,inputSchema:{type:"object",properties:a,required:s,additionalProperties:!1},execute:async(o,c)=>{try{if(O(c),Object.keys(o).some(r=>!Object.hasOwn(a,r)))throw new n("Unsupported Longbow rebate argument.");return await i(o,c)}catch(r){throw new n(p.plainError(r))}}});return{tools:[S("longbow_rebates",{epochIds:{type:"array",maxItems:100,items:l()},fromBlock:l()},[],async(e,a)=>{let{client:s,read:i,block:o}=await x();if(e.epochIds!==void 0&&e.fromBlock!==void 0)throw new n("Use epochIds or fromBlock, not both.");let c,r;if(e.epochIds!==void 0){if(!Array.isArray(e.epochIds)||e.epochIds.length>100)throw new n("Provide at most 100 rebate epochIds.");c=e.epochIds.map(t=>h(t))}else{if(r=e.fromBlock===void 0?o.number>100000n?o.number-100000n:0n:h(e.fromBlock),r>o.number||o.number-r>1000000n)throw new n("Read at most 1000000 blocks per rebate discovery window.");let t=await s.getLogs({address:b,event:N,fromBlock:r,toBlock:o.number,strict:!0});if(c=[...new Set(t.map(y=>y.args.epochId))],c.length>100)throw new n("Too many rebate epochs; narrow the block window.")}let[d,u,m]=await Promise.all([i("owner"),i("publisher"),Promise.all(c.map(t=>A(t,a,i,o.timestamp)))]);return{chainId:w,distributor:b,token:v,blockNumber:o.number.toString(),owner:d,publisher:u,epochs:m,scannedFromBlock:r?.toString()??null,caveat:"Discovery covers only these IDs or this event window. Amounts/proofs require the publisher\u2019s tree; the app does not expose a verified proof endpoint. Claims expire at each on-chain expiry, even if app prose says otherwise."}}),S("longbow_claim_rebate",{epochId:l(),amount:l(),proof:{type:"array",maxItems:64,items:{type:"string"}}},["epochId","amount","proof"],async(e,a)=>{let s=h(e.epochId),i=h(e.amount),o=R(e.proof),{read:c,block:r}=await x(),d=await A(s,a,c,r.timestamp);if(!d.open||d.hasClaimed||i===0n||await c("claimable",[s,a,i,o])!==!0)throw new n("Rebate is closed, already claimed or not proven for this wallet and amount.");let u=`Claim ${i} USDG base units from Longbow rebate epoch ${s} to this wallet ${a}. No approvals.`,m=[p.unsignedTx({to:b,data:k({abi:f,functionName:"claim",args:[s,i,o]}),value:"0",chainId:w,description:u})],t=await p.preview(m,a);if(t.changes.filter(I=>I.token.chainId===w&&g(I.token.address,v.address)&&I.token.decimals===6).reduce((I,C)=>I+BigInt(C.amount),0n)!==i)throw new n("Rebate preview does not return the exact proven USDG amount.");return{txs:m,preview:t,summary:`${u} ${t.summary}`}}),S("longbow_manage_rebates",{operation:{enum:["setPublisher","fundEpoch","sweep","transferOwnership","renounceOwnership"]},epochId:l(),root:{type:"string"},amount:l(),expiry:l(),account:{type:"string"}},["operation"],async(e,a)=>{let{read:s,block:i}=await x(),o=e.operation==="fundEpoch";if(!g(await s(o?"publisher":"owner"),a))throw new n("This wallet lacks the rebate publisher/owner role.");let c=o?["operation","epochId","root","amount","expiry"]:e.operation==="sweep"?["operation","epochId","account"]:e.operation==="renounceOwnership"?["operation"]:["operation","account"];if(Object.keys(e).some(t=>!c.includes(t)))throw new n("Unexpected fields for this rebate management operation.");let r,d=0n;if(o){let t=h(e.expiry,64);if(d=h(e.amount,128),d===0n||t<i.timestamp+30n*86400n)throw new n("Fund a positive rebate amount with at least 30 days to claim.");r=k({abi:f,functionName:"fundEpoch",args:[h(e.epochId),P(e.root),d,t]})}else if(e.operation==="renounceOwnership")r=k({abi:f,functionName:"renounceOwnership"});else{if(typeof e.account!="string")throw new n("Provide the explicit publisher, owner or sweep recipient.");O(e.account);let t=T(e.account);if(t===E)throw new n("The rebate recipient/role cannot be zero.");if(e.operation==="sweep"){let y=await A(h(e.epochId),a,s,i.timestamp);if(y.swept||i.timestamp<BigInt(y.expiry))throw new n("Only expired, unswept rebate epochs can be swept.");r=k({abi:f,functionName:"sweep",args:[h(e.epochId),t]})}else if(e.operation==="setPublisher"||e.operation==="transferOwnership")r=k({abi:f,functionName:e.operation,args:[t]});else throw new n("Choose a supported rebate management operation.")}let u=`Longbow rebate ${String(e.operation)}: ${JSON.stringify(e)}. ${e.operation==="renounceOwnership"?"Owner administration is permanently relinquished.":""}`,m=[...o?[p.approval(v.address,b,d.toString(),w)]:[],p.unsignedTx({to:b,data:r,value:"0",chainId:w,description:u})];return{txs:m,preview:await p.preview(m,a),summary:u}})]}};export{b as a,f as b,M as c};
@@ -1 +1 @@
1
- import{g as u}from"./73N3TOJL.js";import{a as o,i as d}from"./XPFVT2EA.js";import{a as s}from"./5YS5V2LK.js";import{encodeAbiParameters as g,keccak256 as b,parseAbi as f,zeroAddress as h}from"viem";var p=d[o].pons,w=f(["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 memeHook() view returns (address)"]),l=f(["function factory() view returns (address)","function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)"]),v=f(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]);async function A(t,r,n){if(t.chainId!==o||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new s("No supported Pons reference price on this chain or for these token decimals.");let e=await r.readContract({address:p.factory.address,abi:w,functionName:"getLaunchedToken",args:[t.address],blockNumber:n});if(!e.exists||!u(e.token,t.address)||e.pairToken.toLowerCase()!==h)throw new s("No supported native-ETH Pons launch reference price.");let m=10n**BigInt(t.decimals);if(e.phase===0){let[c,[a,i]]=await Promise.all([r.readContract({address:e.curve,abi:l,functionName:"factory",blockNumber:n}),r.readContract({address:e.curve,abi:l,functionName:"getReserves",blockNumber:n})]);if(!u(c,p.factory.address)||a<=0n||i<=0n)throw new s("The Pons curve reference price is unavailable.");return{numerator:a*m,denominator:i*10n**18n}}if(e.phase===2){let c=await r.readContract({address:p.factory.address,abi:w,functionName:"memeHook",blockNumber:n}),a=b(g([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[h,t.address,e.poolFee,e.tickSpacing,c])),[i,y]=await Promise.all([r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getSlot0",args:[a],blockNumber:n}),r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getLiquidity",args:[a],blockNumber:n})]);if(i[0]<=0n||y<=0n)throw new s("The graduated Pons pool reference price is unavailable.");return{numerator:(1n<<192n)*m,denominator:i[0]**2n*10n**18n}}throw new s("The Pons launch has no active reference price in this phase.")}export{A as a};
1
+ import{g as u}from"./73N3TOJL.js";import{a as o,i as d}from"./G6HCV67X.js";import{a as s}from"./5YS5V2LK.js";import{encodeAbiParameters as g,keccak256 as b,parseAbi as f,zeroAddress as h}from"viem";var p=d[o].pons,w=f(["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 memeHook() view returns (address)"]),l=f(["function factory() view returns (address)","function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)"]),v=f(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]);async function A(t,r,n){if(t.chainId!==o||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new s("No supported Pons reference price on this chain or for these token decimals.");let e=await r.readContract({address:p.factory.address,abi:w,functionName:"getLaunchedToken",args:[t.address],blockNumber:n});if(!e.exists||!u(e.token,t.address)||e.pairToken.toLowerCase()!==h)throw new s("No supported native-ETH Pons launch reference price.");let m=10n**BigInt(t.decimals);if(e.phase===0){let[c,[a,i]]=await Promise.all([r.readContract({address:e.curve,abi:l,functionName:"factory",blockNumber:n}),r.readContract({address:e.curve,abi:l,functionName:"getReserves",blockNumber:n})]);if(!u(c,p.factory.address)||a<=0n||i<=0n)throw new s("The Pons curve reference price is unavailable.");return{numerator:a*m,denominator:i*10n**18n}}if(e.phase===2){let c=await r.readContract({address:p.factory.address,abi:w,functionName:"memeHook",blockNumber:n}),a=b(g([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[h,t.address,e.poolFee,e.tickSpacing,c])),[i,y]=await Promise.all([r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getSlot0",args:[a],blockNumber:n}),r.readContract({address:d[o].ponsTrade.state_view.address,abi:v,functionName:"getLiquidity",args:[a],blockNumber:n})]);if(i[0]<=0n||y<=0n)throw new s("The graduated Pons pool reference price is unavailable.");return{numerator:(1n<<192n)*m,denominator:i[0]**2n*10n**18n}}throw new s("The Pons launch has no active reference price in this phase.")}export{A as a};
@@ -1 +1 @@
1
- import{a as Ie,b as fe,g as Y,h as he,i as $e,m as Z,n as _,y as be,z as qe}from"./CAU44UWP.js";import{b as y,c as Se}from"./HQVC6X3T.js";import{a as le,b as z}from"./VJ3W2V3B.js";import{a as R}from"./6IM6A5VA.js";import{a as Pe}from"./EG6M6SSO.js";import{a as Ae}from"./UWOFA6GV.js";import{c as me,g as P}from"./73N3TOJL.js";import{a as xe}from"./RETS2ZEK.js";import{a as h,i as pe}from"./XPFVT2EA.js";import{a as d}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{randomUUID as Fe}from"node:crypto";import{encodeAbiParameters as ee,encodeFunctionData as ke,erc20Abi as Be,getAddress as D,parseAbi as K,parseAbiParameters as te,zeroAddress as L}from"viem";var Ne=pe[h].pons,Q=pe[h].ponsTrade,Ce=K(["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))"]),ne=K(["function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)","function feeBps() view returns (uint256)","function creatorTaxBps() view returns (uint256)","function currentSnipeTaxBps(address) view returns (uint256)","function sellableTokens() view returns (uint256)","function buy(uint256 quoteIn,uint256 minTokensOut,address recipient) payable returns (uint256)","function sell(uint256 tokensIn,uint256 minQuoteOut,address recipient) returns (uint256)"]),Ue=K(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)"]),He=K(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),ze=K(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),Le=te("((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint256 minHopPriceX36,bytes hookData)"),Ke={address:le,chainId:h,decimals:18,symbol:"ETH"},Me="There is no on-chain expiry. The signed transaction is protected by its minimum output.",Xe=`Quote expiry is enforced by Oak before signing only. ${Me}`,I=10000n,we=(1n<<256n)-1n,Oe=(1n<<128n)-1n,$=(n,o)=>({token:n,amount:o.toString()}),Ee=(n,o)=>(n+o-1n)/o,je={type:"object",additionalProperties:!1,required:["token","amountIn"],properties:{token:{...me,description:"Pons launch token address on chain 4663."},amountIn:Ae("Positive base units: the launch pair token for buy (native ETH wei for ETH pairs; pons_status shows pairToken), the launch token for sell."),pairToken:{...me,description:"The launch pair from pons_status. Required to buy a custom-pair launch, so amountIn is never read in the wrong units; omit or use the zero address for native ETH."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:fe}}};function Re(n,o,i,s){if(n===void 0){if(i&&y(o)!==L)throw new d(`This Pons launch is paired with ${s}; amountIn is in that token's base units. Repeat with pairToken "${o}" to confirm the input asset.`);return}if(typeof n!="string")throw new d("pairToken must be a token address.");if(R(n),!P(y(n),y(o)))throw new Y(`This Pons launch trades only against ${s}.`)}async function _e(n,o,i,s,{quoteOnly:f=!1,curveOnly:e=!1,blockNumber:c}={}){if(R(i),Object.keys(o).some(m=>!["token","amountIn","slippageBps","pairToken"].includes(m)))throw new d("Provide only token, amountIn, optional pairToken and optional slippageBps.");if(typeof o.token!="string")throw new d("Provide a launch token address.");R(o.token);let t=D(o.token),r=xe(o.amountIn);if(r===0n||r>we)throw new d("Trade amount must be positive and within the uint256 range.");let p=o.slippageBps??fe;if(typeof p!="number"||!Number.isInteger(p)||p<0||p>=1e4)throw new d("Slippage must be an integer from 0 to 9999 basis points.");let x=m=>m*(I-BigInt(p))/I,a=n.clientFor(h),l=c===void 0?await a.getBlock():await a.getBlock({blockNumber:c});if(c!==void 0&&l.number!==c)throw new d("Pons quote snapshot is unavailable.");let u=await a.readContract({address:Ne.factory.address,abi:Ce,functionName:"getLaunchedToken",args:[t],blockNumber:l.number});if(!u.exists||!P(u.token,t))throw new d("This address is not a Pons launch token.");if(e&&u.phase!==0)throw new Y("Pons curve quotes are only available before graduation.");if(u.phase===1)throw new d("Pons graduation is pending; the curve is closed and the pool is not ready.");if(u.phase===3)throw new d("This Pons launch was rescued and has no active trade route.");if(u.phase!==0&&u.phase!==2)throw new d("This Pons launch has an unknown trade phase.");let v=y(u.pairToken)===L,E=D(u.pairToken);if(P(E,t))throw new d("This Pons launch has an invalid pair.");let X=m=>Promise.all([a.readContract({address:m,abi:Be,functionName:"symbol",blockNumber:l.number}),a.readContract({address:m,abi:Be,functionName:"decimals",blockNumber:l.number})]),[[B,F],U]=await Promise.all([X(t),v?void 0:X(E)]),w=U?{address:E,chainId:h,symbol:ce(U[0]),decimals:U[1]}:Ke,j=v?"native ETH":`${w.symbol} (${w.address})`;Re(o.pairToken,E,s,`${j}, ${w.decimals} decimals`);let G={address:t,chainId:h,symbol:ce(B),decimals:F},oe=s?w:G,se=s?G:w,q=[],re=(m,k,S,A)=>n.unsignedTx({to:m,data:k,value:S.toString(),chainId:h,description:A}),T,b,V,O=r,Te=null,ie;if(u.phase===0){let m=g=>a.readContract({address:u.curve,abi:ne,functionName:g,blockNumber:l.number}),[[k,S],A,N,C,M]=await Promise.all([a.readContract({address:u.curve,abi:ne,functionName:"getReserves",blockNumber:l.number}),m("feeBps"),m("creatorTaxBps"),s?a.readContract({address:u.curve,abi:ne,functionName:"currentSnipeTaxBps",args:[i],blockNumber:l.number}):Promise.resolve(0n),s?m("sellableTokens"):Promise.resolve(0n)]);if(k<=0n||S<=0n||A+N>I-100n)throw new d("Pons curve reserves or fee settings are unavailable.");let J=I-A-N-100n,ue=C<J?C:J,ge=g=>({base:g*A/I,creator:g*N/I,snipe:g*ue/I}),ye=g=>{let H=ge(g);return g-H.base-H.creator-H.snipe},W;if(s){if(M<=0n||M>=S)throw new d("The curve has no available sellable tokens.");let g=ye(r);if(T=g*S/(k+g),T>=M){T=M;let H=T*k/(S-T)+1n;O=Ee(H*I,I-A-N-ue),O>r&&(O=r)}W=O,b=x(T),V=Ee(b*r,O),v||q.push(n.approval(w.address,u.curve,r.toString(),h))}else W=r*k/(S+r),T=ye(W),b=x(T),q.push(n.approval(t,u.curve,r.toString(),h));let de=ge(W);Te={base:$(w,de.base),creator:$(w,de.creator),snipe:$(w,de.snipe)},ie=`Curve fees included: ${A} base, ${N} creator and ${ue} opening-tax basis points, each rounded separately.`,q.push(re(u.curve,ke({abi:ne,functionName:s?"buy":"sell",args:[r,V??b,i]}),s&&v?r:0n,s?`Buy Pons curve tokens with ${j}.`:`Sell Pons curve tokens for ${j}.`))}else{if(r>Oe)throw new d("Trade amount exceeds the router uint128 range.");let m=Se(u.pairToken,t,u.poolFee,u.tickSpacing),k=s?y(u.pairToken):t,S=s?t:y(u.pairToken),A=P(k,m.currency0);if(T=(await a.simulateContract({address:Q.quoter.address,abi:Ue,functionName:"quoteExactInputSingle",args:[{poolKey:m,zeroForOne:A,exactAmount:r,hookData:"0x"}],account:i,gas:Pe,blockNumber:l.number})).result[0],b=x(T),b>Oe)throw new d("Minimum output exceeds the router uint128 range.");let C=l.timestamp+300n;if(C>=1n<<48n)throw new d("Permit2 expiry exceeds its timestamp range.");k!==L&&(q.push(n.approval(k,Q.permit2.address,r.toString(),h)),q.push(re(Q.permit2.address,ke({abi:ze,functionName:"approve",args:[k,Q.universal_router.address,r,Number(C)]}),0n,"Approve the exact token amount to the Pons router through Permit2 for five minutes.")));let M=[ee(Le,[{poolKey:m,zeroForOne:A,amountIn:r,amountOutMinimum:b,minHopPriceX36:0n,hookData:"0x"}]),ee(te("address,uint256"),[k,r]),ee(te("address,uint256"),[S,b])],J=ee(te("bytes,bytes[]"),["0x060c0f",M]);q.push(re(Q.universal_router.address,ke({abi:He,functionName:"execute",args:["0x10",[J],C]}),k===L?r:0n,"Trade through Pons Universal Router v2.1.2.")),ie="Quoter output is net of Pons hook fees; no additional fee is subtracted."}if(T<=0n||b<=0n||b>we||(V??b)>we)throw new d("Trade output or minimum is outside the supported positive range.");let ve=f?{changes:[],summary:"Quote only; preview is required before sending."}:await n.preview(q,i),ae=r-O;return{txs:q,changes:ve.changes,summary:`${s?"Buy":"Sell"} ${G.symbol} (${G.address}) on chain ${h}${v?"":` ${s?"with":"for"} ${j}`}. ${ie} ${u.phase===0?`${Me} `:""}${ae>0n?`Expected ${v?"native refund":"refund"}: ${n.formatAmount(ae.toString(),w.decimals)} ${w.symbol}; minimum output uses the expected spend after refund. `:""}${ve.summary}`,pairToken:w,quote:{phase:u.phase,amountIn:$(oe,r),amountOut:$(se,T),minAmountOut:$(se,b),minimumKind:"absolute",calldataMinAmountOut:$(se,V??b),expectedSpend:$(oe,O),expectedRefund:$(oe,ae),fees:Te,blockNumber:l.number.toString(),blockTimestamp:l.timestamp.toString()}}}function cn(n){return Qe(n,!0)}function Qe(n,o=!1,i){let s=new Map,f=e=>{if(BigInt(Z())>=BigInt(e.expiresAt))throw new he};return{name:"pons",async quote(e,c){if(e={...e,from:z(e.from),to:z(e.to)},_(e.from)&&_(e.to))throw new Y("Pons quotes require a launch token and its pair token.");let t=_(e.from)||!_(e.to)&&await Ge(n,e.from,e.to,i),r=Z(),p=await _e(n,{token:t?e.to:e.from,amountIn:e.amountIn,slippageBps:e.slippageBps,pairToken:y(t?e.from:e.to)},c,t,{quoteOnly:!0,curveOnly:o,blockNumber:i}),x=p.txs.at(-1),a=p.quote,l=String(BigInt(i===void 0?r:a.blockTimestamp)+BigInt(Ie)),u=a.minAmountOut.amount,v=a.fees,E=_(p.pairToken.address)?"native ETH base units (18 decimals)":`${p.pairToken.symbol} (${p.pairToken.address}) base units (${p.pairToken.decimals} decimals)`,X=v?`Pons curve fees included in net output: ${v.base.amount} base, ${v.creator.amount} creator and ${v.snipe.amount} opening tax, in ${E}. Oak swap fee: 0 (venue fee is never Oak income). ${Xe}`:"Quoter output is net of Pons hook fees; no additional fee is subtracted. Oak swap fee: 0.",B=qe({...e,quoteId:`pons:${Fe()}`,provider:"pons",wallet:c,chainId:h,router:x.to,spender:a.phase===0?x.to:Q.permit2.address,expiresAt:l,data:x.data,value:x.value,amountOut:a.amountOut.amount,minAmountOut:u,blockNumber:a.blockNumber,...a.phase===0?{ponsCurveToken:t?e.to:e.from,calldataMinAmountOut:a.calldataMinAmountOut.amount}:{ponsPoolToken:t?e.to:e.from},expectedSpend:a.expectedSpend.amount,expectedRefund:a.expectedRefund.amount,feeDisclosure:X,oakFee:"0"});be(x,B),f(B);for(let[F,U]of s)BigInt(Z())>=BigInt(U.quote.expiresAt)&&s.delete(F);for(;s.size>=$e;)s.delete(s.keys().next().value);return s.set(B.quoteId,{quote:{...B},txs:p.txs.map(F=>({...F})),summary:p.summary}),B},async build(e,c){let t=s.get(e);if(!t)throw new he;if(f(t.quote),R(c),!P(c,t.quote.wallet))throw new d("Quote was issued for a different wallet.");let r=t.txs.map(a=>({...a}));be(r.at(-1),t.quote);let p=await n.preview(r,c);if(f(t.quote),p.changes.filter(a=>P(z(a.token.address),z(t.quote.to))).reduce((a,l)=>a+BigInt(l.amount),0n)<BigInt(t.quote.minAmountOut))throw new d("Preview retained output is below the accepted minimum.");return{txs:r,summary:`${t.summary} ${p.summary} ${t.quote.feeDisclosure}`}}}}async function De(n,o,i){return n.clientFor(h).readContract({address:Ne.factory.address,abi:Ce,functionName:"getLaunchedToken",args:[D(o)],...i===void 0?{}:{blockNumber:i}})}async function Ge(n,o,i,s){let f=await De(n,i,s);return f.exists&&P(f.token,i)&&P(y(f.pairToken),y(o))}async function pn(n,o,i,s,f){if(typeof i.token!="string")throw new d("Provide a launch token address.");R(i.token);let e=D(i.token),c=await De(n,e,f);if(!c.exists||!P(c.token,e))throw new d("This address is not a Pons launch token.");let t=y(c.pairToken)===L?le:D(c.pairToken);return Re(i.pairToken,D(c.pairToken),o,t),{quote:await Qe(n,!1,f).quote({from:o?t:e,to:o?e:t,amountIn:String(i.amountIn),...i.slippageBps===void 0?{}:{slippageBps:i.slippageBps}},s),input:o?t:e}}var Ve=n=>({tools:[!0,!1].map(o=>({name:o?"pons_buy":"pons_sell",inputSchema:je,async execute(i,s){try{return await _e(n,i,s,o)}catch(f){throw new d(n.plainError(f))}}}))}),mn=Ve;export{cn as a,Qe as b,pn as c,Ve as d,mn as e};
1
+ import{a as Ie,b as fe,g as Y,h as he,i as $e,m as Z,n as _,y as be,z as qe}from"./5O5ZE3ZV.js";import{b as y,c as Se}from"./KSZMMNXK.js";import{a as le,b as z}from"./CY75R4FK.js";import{a as R}from"./6IM6A5VA.js";import{a as Pe}from"./EG6M6SSO.js";import{a as Ae}from"./UWOFA6GV.js";import{c as me,g as P}from"./73N3TOJL.js";import{a as xe}from"./RETS2ZEK.js";import{a as h,i as pe}from"./G6HCV67X.js";import{a as d}from"./5YS5V2LK.js";import{a as ce}from"./JXOEJPJ4.js";import{randomUUID as Fe}from"node:crypto";import{encodeAbiParameters as ee,encodeFunctionData as ke,erc20Abi as Be,getAddress as D,parseAbi as K,parseAbiParameters as te,zeroAddress as L}from"viem";var Ne=pe[h].pons,Q=pe[h].ponsTrade,Ce=K(["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))"]),ne=K(["function getReserves() view returns (uint256 quoteReserve,uint256 tokenReserve)","function feeBps() view returns (uint256)","function creatorTaxBps() view returns (uint256)","function currentSnipeTaxBps(address) view returns (uint256)","function sellableTokens() view returns (uint256)","function buy(uint256 quoteIn,uint256 minTokensOut,address recipient) payable returns (uint256)","function sell(uint256 tokensIn,uint256 minQuoteOut,address recipient) returns (uint256)"]),Ue=K(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut,uint256 gasEstimate)"]),He=K(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),ze=K(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),Le=te("((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 amountIn,uint128 amountOutMinimum,uint256 minHopPriceX36,bytes hookData)"),Ke={address:le,chainId:h,decimals:18,symbol:"ETH"},Me="There is no on-chain expiry. The signed transaction is protected by its minimum output.",Xe=`Quote expiry is enforced by Oak before signing only. ${Me}`,I=10000n,we=(1n<<256n)-1n,Oe=(1n<<128n)-1n,$=(n,o)=>({token:n,amount:o.toString()}),Ee=(n,o)=>(n+o-1n)/o,je={type:"object",additionalProperties:!1,required:["token","amountIn"],properties:{token:{...me,description:"Pons launch token address on chain 4663."},amountIn:Ae("Positive base units: the launch pair token for buy (native ETH wei for ETH pairs; pons_status shows pairToken), the launch token for sell."),pairToken:{...me,description:"The launch pair from pons_status. Required to buy a custom-pair launch, so amountIn is never read in the wrong units; omit or use the zero address for native ETH."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:fe}}};function Re(n,o,i,s){if(n===void 0){if(i&&y(o)!==L)throw new d(`This Pons launch is paired with ${s}; amountIn is in that token's base units. Repeat with pairToken "${o}" to confirm the input asset.`);return}if(typeof n!="string")throw new d("pairToken must be a token address.");if(R(n),!P(y(n),y(o)))throw new Y(`This Pons launch trades only against ${s}.`)}async function _e(n,o,i,s,{quoteOnly:f=!1,curveOnly:e=!1,blockNumber:c}={}){if(R(i),Object.keys(o).some(m=>!["token","amountIn","slippageBps","pairToken"].includes(m)))throw new d("Provide only token, amountIn, optional pairToken and optional slippageBps.");if(typeof o.token!="string")throw new d("Provide a launch token address.");R(o.token);let t=D(o.token),r=xe(o.amountIn);if(r===0n||r>we)throw new d("Trade amount must be positive and within the uint256 range.");let p=o.slippageBps??fe;if(typeof p!="number"||!Number.isInteger(p)||p<0||p>=1e4)throw new d("Slippage must be an integer from 0 to 9999 basis points.");let x=m=>m*(I-BigInt(p))/I,a=n.clientFor(h),l=c===void 0?await a.getBlock():await a.getBlock({blockNumber:c});if(c!==void 0&&l.number!==c)throw new d("Pons quote snapshot is unavailable.");let u=await a.readContract({address:Ne.factory.address,abi:Ce,functionName:"getLaunchedToken",args:[t],blockNumber:l.number});if(!u.exists||!P(u.token,t))throw new d("This address is not a Pons launch token.");if(e&&u.phase!==0)throw new Y("Pons curve quotes are only available before graduation.");if(u.phase===1)throw new d("Pons graduation is pending; the curve is closed and the pool is not ready.");if(u.phase===3)throw new d("This Pons launch was rescued and has no active trade route.");if(u.phase!==0&&u.phase!==2)throw new d("This Pons launch has an unknown trade phase.");let v=y(u.pairToken)===L,E=D(u.pairToken);if(P(E,t))throw new d("This Pons launch has an invalid pair.");let X=m=>Promise.all([a.readContract({address:m,abi:Be,functionName:"symbol",blockNumber:l.number}),a.readContract({address:m,abi:Be,functionName:"decimals",blockNumber:l.number})]),[[B,F],U]=await Promise.all([X(t),v?void 0:X(E)]),w=U?{address:E,chainId:h,symbol:ce(U[0]),decimals:U[1]}:Ke,j=v?"native ETH":`${w.symbol} (${w.address})`;Re(o.pairToken,E,s,`${j}, ${w.decimals} decimals`);let G={address:t,chainId:h,symbol:ce(B),decimals:F},oe=s?w:G,se=s?G:w,q=[],re=(m,k,S,A)=>n.unsignedTx({to:m,data:k,value:S.toString(),chainId:h,description:A}),T,b,V,O=r,Te=null,ie;if(u.phase===0){let m=g=>a.readContract({address:u.curve,abi:ne,functionName:g,blockNumber:l.number}),[[k,S],A,N,C,M]=await Promise.all([a.readContract({address:u.curve,abi:ne,functionName:"getReserves",blockNumber:l.number}),m("feeBps"),m("creatorTaxBps"),s?a.readContract({address:u.curve,abi:ne,functionName:"currentSnipeTaxBps",args:[i],blockNumber:l.number}):Promise.resolve(0n),s?m("sellableTokens"):Promise.resolve(0n)]);if(k<=0n||S<=0n||A+N>I-100n)throw new d("Pons curve reserves or fee settings are unavailable.");let J=I-A-N-100n,ue=C<J?C:J,ge=g=>({base:g*A/I,creator:g*N/I,snipe:g*ue/I}),ye=g=>{let H=ge(g);return g-H.base-H.creator-H.snipe},W;if(s){if(M<=0n||M>=S)throw new d("The curve has no available sellable tokens.");let g=ye(r);if(T=g*S/(k+g),T>=M){T=M;let H=T*k/(S-T)+1n;O=Ee(H*I,I-A-N-ue),O>r&&(O=r)}W=O,b=x(T),V=Ee(b*r,O),v||q.push(n.approval(w.address,u.curve,r.toString(),h))}else W=r*k/(S+r),T=ye(W),b=x(T),q.push(n.approval(t,u.curve,r.toString(),h));let de=ge(W);Te={base:$(w,de.base),creator:$(w,de.creator),snipe:$(w,de.snipe)},ie=`Curve fees included: ${A} base, ${N} creator and ${ue} opening-tax basis points, each rounded separately.`,q.push(re(u.curve,ke({abi:ne,functionName:s?"buy":"sell",args:[r,V??b,i]}),s&&v?r:0n,s?`Buy Pons curve tokens with ${j}.`:`Sell Pons curve tokens for ${j}.`))}else{if(r>Oe)throw new d("Trade amount exceeds the router uint128 range.");let m=Se(u.pairToken,t,u.poolFee,u.tickSpacing),k=s?y(u.pairToken):t,S=s?t:y(u.pairToken),A=P(k,m.currency0);if(T=(await a.simulateContract({address:Q.quoter.address,abi:Ue,functionName:"quoteExactInputSingle",args:[{poolKey:m,zeroForOne:A,exactAmount:r,hookData:"0x"}],account:i,gas:Pe,blockNumber:l.number})).result[0],b=x(T),b>Oe)throw new d("Minimum output exceeds the router uint128 range.");let C=l.timestamp+300n;if(C>=1n<<48n)throw new d("Permit2 expiry exceeds its timestamp range.");k!==L&&(q.push(n.approval(k,Q.permit2.address,r.toString(),h)),q.push(re(Q.permit2.address,ke({abi:ze,functionName:"approve",args:[k,Q.universal_router.address,r,Number(C)]}),0n,"Approve the exact token amount to the Pons router through Permit2 for five minutes.")));let M=[ee(Le,[{poolKey:m,zeroForOne:A,amountIn:r,amountOutMinimum:b,minHopPriceX36:0n,hookData:"0x"}]),ee(te("address,uint256"),[k,r]),ee(te("address,uint256"),[S,b])],J=ee(te("bytes,bytes[]"),["0x060c0f",M]);q.push(re(Q.universal_router.address,ke({abi:He,functionName:"execute",args:["0x10",[J],C]}),k===L?r:0n,"Trade through Pons Universal Router v2.1.2.")),ie="Quoter output is net of Pons hook fees; no additional fee is subtracted."}if(T<=0n||b<=0n||b>we||(V??b)>we)throw new d("Trade output or minimum is outside the supported positive range.");let ve=f?{changes:[],summary:"Quote only; preview is required before sending."}:await n.preview(q,i),ae=r-O;return{txs:q,changes:ve.changes,summary:`${s?"Buy":"Sell"} ${G.symbol} (${G.address}) on chain ${h}${v?"":` ${s?"with":"for"} ${j}`}. ${ie} ${u.phase===0?`${Me} `:""}${ae>0n?`Expected ${v?"native refund":"refund"}: ${n.formatAmount(ae.toString(),w.decimals)} ${w.symbol}; minimum output uses the expected spend after refund. `:""}${ve.summary}`,pairToken:w,quote:{phase:u.phase,amountIn:$(oe,r),amountOut:$(se,T),minAmountOut:$(se,b),minimumKind:"absolute",calldataMinAmountOut:$(se,V??b),expectedSpend:$(oe,O),expectedRefund:$(oe,ae),fees:Te,blockNumber:l.number.toString(),blockTimestamp:l.timestamp.toString()}}}function cn(n){return Qe(n,!0)}function Qe(n,o=!1,i){let s=new Map,f=e=>{if(BigInt(Z())>=BigInt(e.expiresAt))throw new he};return{name:"pons",async quote(e,c){if(e={...e,from:z(e.from),to:z(e.to)},_(e.from)&&_(e.to))throw new Y("Pons quotes require a launch token and its pair token.");let t=_(e.from)||!_(e.to)&&await Ge(n,e.from,e.to,i),r=Z(),p=await _e(n,{token:t?e.to:e.from,amountIn:e.amountIn,slippageBps:e.slippageBps,pairToken:y(t?e.from:e.to)},c,t,{quoteOnly:!0,curveOnly:o,blockNumber:i}),x=p.txs.at(-1),a=p.quote,l=String(BigInt(i===void 0?r:a.blockTimestamp)+BigInt(Ie)),u=a.minAmountOut.amount,v=a.fees,E=_(p.pairToken.address)?"native ETH base units (18 decimals)":`${p.pairToken.symbol} (${p.pairToken.address}) base units (${p.pairToken.decimals} decimals)`,X=v?`Pons curve fees included in net output: ${v.base.amount} base, ${v.creator.amount} creator and ${v.snipe.amount} opening tax, in ${E}. Oak swap fee: 0 (venue fee is never Oak income). ${Xe}`:"Quoter output is net of Pons hook fees; no additional fee is subtracted. Oak swap fee: 0.",B=qe({...e,quoteId:`pons:${Fe()}`,provider:"pons",wallet:c,chainId:h,router:x.to,spender:a.phase===0?x.to:Q.permit2.address,expiresAt:l,data:x.data,value:x.value,amountOut:a.amountOut.amount,minAmountOut:u,blockNumber:a.blockNumber,...a.phase===0?{ponsCurveToken:t?e.to:e.from,calldataMinAmountOut:a.calldataMinAmountOut.amount}:{ponsPoolToken:t?e.to:e.from},expectedSpend:a.expectedSpend.amount,expectedRefund:a.expectedRefund.amount,feeDisclosure:X,oakFee:"0"});be(x,B),f(B);for(let[F,U]of s)BigInt(Z())>=BigInt(U.quote.expiresAt)&&s.delete(F);for(;s.size>=$e;)s.delete(s.keys().next().value);return s.set(B.quoteId,{quote:{...B},txs:p.txs.map(F=>({...F})),summary:p.summary}),B},async build(e,c){let t=s.get(e);if(!t)throw new he;if(f(t.quote),R(c),!P(c,t.quote.wallet))throw new d("Quote was issued for a different wallet.");let r=t.txs.map(a=>({...a}));be(r.at(-1),t.quote);let p=await n.preview(r,c);if(f(t.quote),p.changes.filter(a=>P(z(a.token.address),z(t.quote.to))).reduce((a,l)=>a+BigInt(l.amount),0n)<BigInt(t.quote.minAmountOut))throw new d("Preview retained output is below the accepted minimum.");return{txs:r,summary:`${t.summary} ${p.summary} ${t.quote.feeDisclosure}`}}}}async function De(n,o,i){return n.clientFor(h).readContract({address:Ne.factory.address,abi:Ce,functionName:"getLaunchedToken",args:[D(o)],...i===void 0?{}:{blockNumber:i}})}async function Ge(n,o,i,s){let f=await De(n,i,s);return f.exists&&P(f.token,i)&&P(y(f.pairToken),y(o))}async function pn(n,o,i,s,f){if(typeof i.token!="string")throw new d("Provide a launch token address.");R(i.token);let e=D(i.token),c=await De(n,e,f);if(!c.exists||!P(c.token,e))throw new d("This address is not a Pons launch token.");let t=y(c.pairToken)===L?le:D(c.pairToken);return Re(i.pairToken,D(c.pairToken),o,t),{quote:await Qe(n,!1,f).quote({from:o?t:e,to:o?e:t,amountIn:String(i.amountIn),...i.slippageBps===void 0?{}:{slippageBps:i.slippageBps}},s),input:o?t:e}}var Ve=n=>({tools:[!0,!1].map(o=>({name:o?"pons_buy":"pons_sell",inputSchema:je,async execute(i,s){try{return await _e(n,i,s,o)}catch(f){throw new d(n.plainError(f))}}}))}),mn=Ve;export{cn as a,Qe as b,pn as c,Ve as d,mn as e};
@@ -0,0 +1 @@
1
+ import{a as $}from"./LT5P6PZW.js";import{a as L}from"./CY75R4FK.js";import{c as D,f as z,g as F,i as U}from"./73N3TOJL.js";import{a as k}from"./G6HCV67X.js";import{a as c}from"./5YS5V2LK.js";import{encodeFunctionData as W,erc20Abi as ne,erc721Abi as K,getAddress as te,parseAbi as oe,zeroAddress as q}from"viem";var A=$,J=oe(["function launchFee() view returns (uint256 fee,address treasury,uint256 pendingFee,address pendingTreasury,uint256 readyAt)"]),w=(e,n)=>e.name==="seed"?"marketSeed":e.name||`arg${n}`,G=e=>"components"in e?e.components:[],re=e=>{if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new c("Provide Hookr amounts as decimal base-unit strings within uint256.");return BigInt(e)},p=e=>z(e,"Provide the documented Hookr parameter object."),g=e=>U(e,"Provide a valid Hookr address."),Q=e=>e.stateMutability==="view"||e.stateMutability==="pure";function B(e){return e.abi}function X(e){let n=/^(.*)\[([0-9]*)\]$/.exec(e.type);return n?{type:"array",items:X({...e,type:n[1]}),minItems:n[2]?Number(n[2]):0,maxItems:n[2]?Number(n[2]):128}:e.type==="tuple"?E(G(e)):e.type==="bool"?{type:"boolean"}:e.type==="address"?D:/^u?int/.test(e.type)?{type:"string",pattern:e.type.startsWith("uint")?"^(0|[1-9][0-9]*)$":"^(0|-?[1-9][0-9]*)$",description:"Decimal integer; token amounts are base units, timestamps are Unix seconds."}:e.type.startsWith("bytes")?{type:"string",pattern:"^0x([0-9a-fA-F]{2})*$",maxLength:32770}:{type:"string",maxLength:4096}}function E(e){return{type:"object",properties:Object.fromEntries(e.map((n,r)=>[w(n,r),X(n)])),required:e.map(w),additionalProperties:!1}}function j(e,n){let r=/^(.*)\[([0-9]*)\]$/.exec(e.type);if(r){if(!Array.isArray(n)||n.length>128||r[2]&&n.length!==Number(r[2]))throw new c("Hookr parameter array has an invalid length.");return n.map(s=>j({...e,type:r[1]},s))}if(e.type==="tuple"){let s=p(n),u=G(e);return C(s,u.map(w)),Object.fromEntries(u.map((i,d)=>[i.name||`arg${d}`,j(i,s[w(i,d)])]))}if(e.type==="address")return g(n);if(e.type==="bool"){if(typeof n!="boolean")throw new c("Provide a Hookr boolean.");return n}let a=/^(u?)int([0-9]*)$/.exec(e.type);if(a){if(typeof n!="string"||!/^(0|-?[1-9][0-9]*)$/.test(n)||n.length>79)throw new c("Provide Hookr integers as decimal base-unit strings.");let s=BigInt(n),u=BigInt(a[2]||256),i=!a[1];if(s<(i?-(1n<<u-1n):0n)||s>=1n<<(i?u-1n:u))throw new c("Hookr integer exceeds its ABI range.");return u<=32n?Number(s):s}if(e.type.startsWith("bytes")){let s=Number(e.type.slice(5));if(typeof n!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(n)||n.length>32770||s&&n.length!==2+s*2)throw new c("Provide a valid Hookr hex byte string of the ABI length.");return n}if(e.type!=="string"||typeof n!="string"||new TextEncoder().encode(n).length>4096)throw new c("Provide a valid Hookr string.");return n}function C(e,n){if(Object.keys(e).some(r=>!n.includes(r))||n.some(r=>!Object.hasOwn(e,r)))throw new c("Provide exactly the documented Hookr parameters.")}function fe(e,n){C(n,e.inputs.map(w));let r=e.inputs.map((a,s)=>j(a,n[w(a,s)]));return{values:r,params:Object.fromEntries(e.inputs.map((a,s)=>[w(a,s),r[s]]))}}function Y(e,n){if(C(e,["contract","function","params"]),typeof e.contract!="string"||!Object.hasOwn(A,e.contract))throw new c("Choose a contract from hookr_contracts.");let r=A[e.contract];if(!n&&r.address.toLowerCase()===$.launcherV1.address.toLowerCase())throw new c("Use hookr_launch for the reviewed new Launcher; generic actions cannot call it.");let a=B(r).find(d=>d.name===e.function&&(n?Q(d):r.actions.includes(d.name)));if(!a)throw new c("This Hookr function is not exposed in this read/action lane. Read hookr_contracts for coverage.");let s=p(e.params);C(s,a.inputs.map(w));let u=a.inputs.map((d,f)=>j(d,s[w(d,f)])),i=Object.fromEntries(a.inputs.map((d,f)=>[w(d,f),u[f]]));return{pin:r,fn:a,values:u,params:i,target:g(r.address)}}var V={type:"object",properties:{contract:{type:"string",enum:Object.keys(A)},function:{type:"string"},params:{type:"object",description:"Exact typed parameters from hookr_contracts for this contract and function; validated recursively before any chain read."}},required:["contract","function","params"],additionalProperties:!1};function Z(e){return JSON.parse(JSON.stringify(e,(n,r)=>typeof r=="bigint"?r.toString():r))}async function ie(e,n,r){if(e.network==="testnet")throw new c("Hookr actions are configured only on mainnet, chain 4663.");let{pin:a,fn:s,values:u,params:i,target:d}=Y(n,!1),f=n.contract,h=s.name,H=e.clientFor(k),P=[],I=[],b=0n,O=new Map,l=(t,o)=>{let m=g(t),x=typeof o=="bigint"?o:re(o);if(x<0n||x>=(1n<<256n)-1n)throw new c("Hookr funding must be an exact bounded amount.");x&&(m===q?b+=x:O.set(m,(O.get(m)??0n)+x))},v=(t,o,m=[])=>H.readContract({address:g(A[t].address),abi:A[t].abi,functionName:o,args:m});if(f==="router"&&["swap","swapGated"].includes(h)){let t=p(i.params),o=p(t.key),m=t.amountSpecified;if(m===0n||t.amountBound===0n)throw new c("Hookr swaps require a nonzero amount and bound.");l(t.zeroForOne?o.currency0:o.currency1,m<0n?-m:t.amountBound)}else if(f==="vault"&&h==="deposit"){let t=p(i.params),o=p(t.key);if(l(o.currency0,t.amount0Desired),l(o.currency1,t.amount1Desired),t.amount0Min>t.amount0Desired||t.amount1Min>t.amount1Desired)throw new c("Hookr deposit minimum exceeds its desired amount.")}else if(f==="vault"&&h==="transfer")I.push({token:d,id:i.id,amount:i.amount,to:g(i.receiver)});else if(f==="launcher"&&h.startsWith("launch")){let t=h==="launchFamily"?p(i.p):i,o=p(t.token),m=t.members;if(m.length<1||m.length>8)throw new c("Hookr launch needs one to eight members.");if(F(String(o.salt),String(await v("launcher","SKIP_TAKEN"))))throw new c("Hookr skip-taken launches need per-pool funding checks and are not exposed yet.");let x=o.existing===q?g(await v("launcher","predictToken",[r,o])):g(o.existing),_=0n;for(let y of m){let T=BigInt(x)<BigInt(String(y.quote)),M=T?y.amount0Max:y.amount1Max;o.existing===q?_+=M:l(x,M),l(y.quote,T?y.amount1Max:y.amount0Max)}if(_>o.supply)throw new c("Hookr launch seeds more new tokens than its supply.");let ee=h==="launchFamily"?t.buys:h==="launchWithBuy"?[p(i.buy)]:[];for(let y of ee){let T=m[Number(y.member)];if(!T)throw new c("Hookr dev buy references an unavailable member.");l(T.quote,y.quoteIn)}let N=await H.readContract({address:d,abi:J,functionName:"launchFee"});if(!Array.isArray(N)||typeof N[0]!="bigint"||N[0]<0n)throw new c("Hookr launch fee is unavailable.");b+=N[0]}else if(f==="launcher"&&h==="addLiquidity"){let t=p(await v("launcher","position",[i.familyId,i.member])),o=p(t.key);l(o.currency0,i.max0),l(o.currency1,i.max1)}else if(f==="ownedFactory"&&h==="deploy"){let t=await v("ownedFactory","deployFee");if(typeof t!="bigint"||t<0n)throw new c("Hookr own-hook deployment fee is unavailable.");b=t}else if(f==="programs"&&h==="createProgram"){let t=p(i.t);if(l(t.rewardToken,t.cashBudget),b)throw new c("Hookr program cash rewards require an ERC-20 token.")}else if(f==="commissions"&&h==="createCampaign"){let t=p(i.t),o=t.end-t.start;if(o<=0n||o%86400n!==0n||o/86400n>366n)throw new c("Hookr referral campaigns must cover one to 366 whole days.");l(t.currency,t.dailyBudget*(o/86400n))}else if(f==="reserve"&&h==="fundReserve")l(i.token,i.amount);else if(f==="tokenizer"){let t=p(i.arg1);if(t.launchParams!=="0x"||["feebs","positionIds","positionPermits","v3PositionIds","v3Permits"].some(o=>t[o].length>0))throw new c("Composite revenue launches and NFT streams need their exact child-spender and funding routes; this route accepts families, Rules, revenue-token shares and bound outside sources.");for(let o of t.revenueTokens)l(o.token,o.amount);if(h==="tokenize"&&p(i.arg2).open){let o=await H.readContract({address:g(A.launcher.address),abi:J,functionName:"launchFee"});if(!Array.isArray(o)||typeof o[0]!="bigint"||o[0]<0n)throw new c("Hookr revenue market launch fee is unavailable.");b+=o[0]}}else if(f==="boost"&&["fund","notify"].includes(h)){let t=p(await v("boost","gauge",[i.id]));if(l(p(t.terms).rewardToken,i.amount),b)throw new c("Hookr boost rewards require an ERC-20 token.")}else if(f==="boost"&&h==="stake"){let t=g(await v("boost","positionManager"));if(t!==te("0x58daec3116aae6D93017bAAea7749052E8a04fA7"))throw new c("Hookr boost position manager disagrees with the published deployment.");let o=await H.readContract({address:t,abi:K,functionName:"ownerOf",args:[i.tokenId]});if(!F(o,r))throw new c("The signing wallet must own the position NFT it stakes.");P.push(e.unsignedTx({to:t,data:W({abi:K,functionName:"approve",args:[d,i.tokenId]}),value:"0",chainId:k,description:`Approve only Hookr position NFT #${i.tokenId} to ${d}.`})),I.push({token:t,id:i.tokenId,amount:1n,to:d})}let R=await H.getBlock();if(typeof R.timestamp!="bigint"||R.timestamp<=0n)throw new c("Hookr chain time is unavailable.");let S=t=>{if(Array.isArray(t)){t.forEach(S);return}if(!(!t||typeof t!="object"))for(let[o,m]of Object.entries(t)){if(o==="deadline"&&typeof m=="bigint"&&m<R.timestamp)throw new c("Hookr deadline expired. Refresh the action terms.");S(m)}};S(i);for(let[t,o]of O){if(o>=(1n<<256n)-1n)throw new c("Hookr aggregate funding exceeds its exact approval bound.");let m=await H.readContract({address:t,abi:ne,functionName:"allowance",args:[r,d]});m>0n&&m!==o&&P.push(e.approval(t,d,"0",k)),P.push(e.approval(t,d,o.toString(),k)),I.push({token:t,amount:o})}return b&&I.push({token:L,amount:b,to:d}),P.push(e.unsignedTx({to:d,data:W({abi:[s],functionName:s.name,args:u}),value:b.toString(),chainId:k,description:`Hookr ${f}.${h}: ${JSON.stringify(Z(i))}. Review recipients, bounds, ownership and any delayed effects.`})),{txs:P,inputs:I}}function pe(e,n){if(e.length!==n.length||e.some((r,a)=>r.chainId!==n[a].chainId||!F(r.to,n[a].to)||r.value!==n[a].value||!F(r.data,n[a].data)))throw new c("Hookr transactions differ from the locally reconstructed parameters and exact funding.")}function he(e){return[{name:"hookr_contracts",inputSchema:{type:"object",description:"Read Hookr contract coverage and typed function schemas: swaps, launches and dev buys, liquidity, saved hooks, own hooks, LP boost, programs, referrals, claims, registry and treasury administration. Filter contract/function to fetch only the needed schema. No network request.",properties:{contract:{type:"string",enum:Object.keys(A)},function:{type:"string"}},additionalProperties:!1},execute:async n=>{if(Object.keys(n).some(a=>!["contract","function"].includes(a))||n.contract!==void 0&&(typeof n.contract!="string"||!Object.hasOwn(A,n.contract))||n.function!==void 0&&typeof n.function!="string")throw new c("Choose a documented Hookr contract and function filter.");let r=a=>n.function===void 0||a.name===n.function;return{chainId:k,contracts:Object.entries(A).filter(([a])=>n.contract===void 0||a===n.contract).map(([a,s])=>({role:a,address:g(s.address),source:s.source,match:s.match,reads:B(s).filter(u=>Q(u)&&r(u)).map(u=>({function:u.name,params:E(u.inputs)})),actions:s.actions.filter(u=>n.function===void 0||u===n.function).map(u=>({function:u,params:E(B(s).find(i=>i.name===u).inputs)}))})),note:"Contract parameters use decimal base-unit strings for every integer. Actions always require preview and local human confirmation. Unlisted/internal functions are unavailable."}}},{name:"hookr_read",inputSchema:{...V,description:"Read a pinned Hookr contract function. Fetch its exact parameter schema with hookr_contracts {contract,function}; no signing, subscription or identity required."},execute:async n=>{let{pin:r,fn:a,values:s,target:u}=Y(n,!0),i=await e.clientFor(k).readContract({address:u,abi:[a],functionName:a.name,args:s});return{chainId:k,contract:u,function:a.name,result:Z(i),source:r.source}}},{name:"hookr_action",inputSchema:{...V,description:"Build a pinned Hookr action with exact funding: swap, launch/dev buy, liquidity deposit/exit, boost stake/exit, profile/own-hook management, programs/referrals and owner/keeper administration. Fetch its exact parameter schema with hookr_contracts {contract,function}. Preview and human confirmation required."},execute:async(n,r)=>{let a=await ie(e,n,r),s=await e.preview(a.txs,r);return{txs:a.txs,preview:s,summary:`Hookr ${n.contract}.${n.function}; review the preview and human confirmation.`}}}]}export{E as a,fe as b,ie as c,pe as d,he as e};