@oakagentkit/core 0.2.4 → 0.2.6

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 (510) hide show
  1. package/build/dist/api/amounts.d.ts +2 -0
  2. package/build/dist/api/amounts.js +1 -1
  3. package/build/dist/api/args.js +1 -1
  4. package/build/dist/api/gas.js +1 -1
  5. package/build/dist/api/grandfather.js +1 -1
  6. package/build/dist/api/guards.js +1 -1
  7. package/build/dist/api/history.js +1 -1
  8. package/build/dist/api/http.js +1 -1
  9. package/build/dist/api/merkle.js +1 -1
  10. package/build/dist/api/module.js +1 -1
  11. package/build/dist/api/modules/beefy/boosts.js +1 -1
  12. package/build/dist/api/modules/beefy/clm.js +1 -1
  13. package/build/dist/api/modules/beefy/guard.js +1 -1
  14. package/build/dist/api/modules/beefy/index.js +1 -1
  15. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  16. package/build/dist/api/modules/beefy/management.js +1 -1
  17. package/build/dist/api/modules/beefy/vaults.js +1 -1
  18. package/build/dist/api/modules/borro/abi.d.ts +149 -0
  19. package/build/dist/api/modules/borro/abi.js +1 -0
  20. package/build/dist/api/modules/borro/actions.d.ts +2 -0
  21. package/build/dist/api/modules/borro/actions.js +1 -0
  22. package/build/dist/api/modules/borro/checks.d.ts +151 -0
  23. package/build/dist/api/modules/borro/checks.js +1 -0
  24. package/build/dist/api/modules/borro/copy.d.ts +174 -0
  25. package/build/dist/api/modules/borro/copy.js +1 -0
  26. package/build/dist/api/modules/borro/index.d.ts +13 -0
  27. package/build/dist/api/modules/borro/index.js +1 -0
  28. package/build/dist/api/modules/borro/liquidity.d.ts +4 -0
  29. package/build/dist/api/modules/borro/liquidity.js +1 -0
  30. package/build/dist/api/modules/borro/pins.d.ts +264 -0
  31. package/build/dist/api/modules/borro/pins.js +1 -0
  32. package/build/dist/api/modules/borro/positions.d.ts +8 -0
  33. package/build/dist/api/modules/borro/positions.js +1 -0
  34. package/build/dist/api/modules/borro/rates.d.ts +20 -0
  35. package/build/dist/api/modules/borro/rates.js +1 -0
  36. package/build/dist/api/modules/borro/reader.d.ts +36 -0
  37. package/build/dist/api/modules/borro/reader.js +1 -0
  38. package/build/dist/api/modules/borro/types.d.ts +126 -0
  39. package/build/dist/api/modules/borro/types.js +0 -0
  40. package/build/dist/api/modules/chop/abi.d.ts +527 -0
  41. package/build/dist/api/modules/chop/abi.js +1 -0
  42. package/build/dist/api/modules/chop/actions.d.ts +24 -0
  43. package/build/dist/api/modules/chop/actions.js +1 -0
  44. package/build/dist/api/modules/chop/checks.d.ts +26 -0
  45. package/build/dist/api/modules/chop/checks.js +1 -0
  46. package/build/dist/api/modules/chop/copy.d.ts +5 -0
  47. package/build/dist/api/modules/chop/copy.js +1 -0
  48. package/build/dist/api/modules/chop/guard.d.ts +13 -0
  49. package/build/dist/api/modules/chop/guard.js +1 -0
  50. package/build/dist/api/modules/chop/index.d.ts +3 -0
  51. package/build/dist/api/modules/chop/index.js +1 -0
  52. package/build/dist/api/modules/chop/pins.d.ts +53 -0
  53. package/build/dist/api/modules/chop/pins.js +1 -0
  54. package/build/dist/api/modules/chop/positions.d.ts +3 -0
  55. package/build/dist/api/modules/chop/positions.js +1 -0
  56. package/build/dist/api/modules/chop/reader.d.ts +70 -0
  57. package/build/dist/api/modules/chop/reader.js +1 -0
  58. package/build/dist/api/modules/chop/types.d.ts +32 -0
  59. package/build/dist/api/modules/chop/types.js +0 -0
  60. package/build/dist/api/modules/clanker/extensions.js +1 -1
  61. package/build/dist/api/modules/clanker/index.js +1 -1
  62. package/build/dist/api/modules/clanker/manage.js +1 -1
  63. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  64. package/build/dist/api/modules/clanker/protocol.js +1 -1
  65. package/build/dist/api/modules/clanker/state.js +1 -1
  66. package/build/dist/api/modules/earn/copy.d.ts +2 -2
  67. package/build/dist/api/modules/earn/copy.js +1 -1
  68. package/build/dist/api/modules/earn/index.js +1 -1
  69. package/build/dist/api/modules/earn/lp.js +1 -1
  70. package/build/dist/api/modules/earn/options.js +1 -1
  71. package/build/dist/api/modules/erc8004/common.js +1 -1
  72. package/build/dist/api/modules/erc8004/domain.js +1 -1
  73. package/build/dist/api/modules/erc8004/index.js +1 -1
  74. package/build/dist/api/modules/erc8004/management.js +1 -1
  75. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  76. package/build/dist/api/modules/erc8004/services.js +1 -1
  77. package/build/dist/api/modules/erc8004/validation.js +1 -1
  78. package/build/dist/api/modules/gloam/abi.d.ts +89 -0
  79. package/build/dist/api/modules/gloam/abi.js +1 -0
  80. package/build/dist/api/modules/gloam/actions.d.ts +5 -0
  81. package/build/dist/api/modules/gloam/actions.js +1 -0
  82. package/build/dist/api/modules/gloam/checks.d.ts +17 -0
  83. package/build/dist/api/modules/gloam/checks.js +1 -0
  84. package/build/dist/api/modules/gloam/copy.d.ts +22 -0
  85. package/build/dist/api/modules/gloam/copy.js +2 -0
  86. package/build/dist/api/modules/gloam/index.d.ts +6 -0
  87. package/build/dist/api/modules/gloam/index.js +1 -0
  88. package/build/dist/api/modules/gloam/pins.d.ts +41 -0
  89. package/build/dist/api/modules/gloam/pins.js +1 -0
  90. package/build/dist/api/modules/gloam/types.d.ts +308 -0
  91. package/build/dist/api/modules/gloam/types.js +1 -0
  92. package/build/dist/api/modules/grove/index.js +1 -1
  93. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  94. package/build/dist/api/modules/heyresearch/index.js +1 -1
  95. package/build/dist/api/modules/heyresearch/proof-reads.js +1 -1
  96. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  97. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  98. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  99. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  100. package/build/dist/api/modules/hoodag/index.js +1 -1
  101. package/build/dist/api/modules/hoodag/management.js +1 -1
  102. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  103. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  104. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  105. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  106. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  107. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  108. package/build/dist/api/modules/hoodlock/index.js +1 -1
  109. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  110. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  111. package/build/dist/api/modules/hoodlock/public.js +1 -1
  112. package/build/dist/api/modules/hookr/actions.js +1 -1
  113. package/build/dist/api/modules/hookr/addons.js +1 -1
  114. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  115. package/build/dist/api/modules/hookr/contracts.js +1 -1
  116. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  117. package/build/dist/api/modules/hookr/discovery.js +1 -1
  118. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  119. package/build/dist/api/modules/hookr/index.js +1 -1
  120. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  121. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  122. package/build/dist/api/modules/hookr/launch.js +1 -1
  123. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  124. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  125. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  126. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  127. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  128. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  129. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  130. package/build/dist/api/modules/hookr/relay.js +1 -1
  131. package/build/dist/api/modules/hookr/revenue.js +1 -1
  132. package/build/dist/api/modules/kyberswap/index.js +1 -1
  133. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  134. package/build/dist/api/modules/layerbank/actions.js +1 -1
  135. package/build/dist/api/modules/layerbank/checks.js +1 -1
  136. package/build/dist/api/modules/layerbank/index.js +1 -1
  137. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  138. package/build/dist/api/modules/layerbank/reader.js +1 -1
  139. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  140. package/build/dist/api/modules/lighter/index.js +1 -1
  141. package/build/dist/api/modules/longbow/administration.js +1 -1
  142. package/build/dist/api/modules/longbow/analytics.js +1 -1
  143. package/build/dist/api/modules/longbow/fixed.js +1 -1
  144. package/build/dist/api/modules/longbow/index.js +1 -1
  145. package/build/dist/api/modules/longbow/nft.js +1 -1
  146. package/build/dist/api/modules/longbow/rebates.js +1 -1
  147. package/build/dist/api/modules/longbow/staking.js +1 -1
  148. package/build/dist/api/modules/meridian/index.js +1 -1
  149. package/build/dist/api/modules/meridian/markets.js +1 -1
  150. package/build/dist/api/modules/meridian/perps-batch.js +1 -1
  151. package/build/dist/api/modules/meridian/perps-common.js +1 -1
  152. package/build/dist/api/modules/meridian/perps-guards.js +1 -1
  153. package/build/dist/api/modules/meridian/perps-intents.js +1 -1
  154. package/build/dist/api/modules/meridian/perps-stream.js +1 -1
  155. package/build/dist/api/modules/meridian/perps.d.ts +1 -0
  156. package/build/dist/api/modules/meridian/perps.js +1 -1
  157. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  158. package/build/dist/api/modules/meridian/rfq.js +1 -1
  159. package/build/dist/api/modules/merkl/discovery.js +1 -1
  160. package/build/dist/api/modules/merkl/index.js +1 -1
  161. package/build/dist/api/modules/merkl/manage.js +1 -1
  162. package/build/dist/api/modules/merkl/protocol.js +1 -1
  163. package/build/dist/api/modules/morpho/allocator.js +1 -1
  164. package/build/dist/api/modules/morpho/bundles.js +1 -1
  165. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  166. package/build/dist/api/modules/morpho/index.js +1 -1
  167. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  168. package/build/dist/api/modules/morpho/midnight.js +1 -1
  169. package/build/dist/api/modules/morpho/protocol.js +1 -1
  170. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  171. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  172. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  173. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  174. package/build/dist/api/modules/netnet/card-read.js +1 -1
  175. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  176. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  177. package/build/dist/api/modules/netnet/financial.js +1 -1
  178. package/build/dist/api/modules/netnet/index.js +1 -1
  179. package/build/dist/api/modules/netnet/staking.js +1 -1
  180. package/build/dist/api/modules/orbio/gateway.js +1 -1
  181. package/build/dist/api/modules/orbio/index.js +1 -1
  182. package/build/dist/api/modules/orbio/positions.js +1 -1
  183. package/build/dist/api/modules/pendle/convert.js +1 -1
  184. package/build/dist/api/modules/pendle/costs.js +1 -1
  185. package/build/dist/api/modules/pendle/index.js +1 -1
  186. package/build/dist/api/modules/pendle/markets.js +1 -1
  187. package/build/dist/api/modules/pendle/positions.js +1 -1
  188. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  189. package/build/dist/api/modules/pendle/reader.js +1 -1
  190. package/build/dist/api/modules/pendle/redeem.js +1 -1
  191. package/build/dist/api/modules/pendle/trade.js +1 -1
  192. package/build/dist/api/modules/pendle/types.d.ts +16 -1
  193. package/build/dist/api/modules/pendle/validate.js +1 -1
  194. package/build/dist/api/modules/pendle/verify.js +1 -1
  195. package/build/dist/api/modules/pons/claim.js +1 -1
  196. package/build/dist/api/modules/pons/holder-directory.js +1 -1
  197. package/build/dist/api/modules/pons/index.js +1 -1
  198. package/build/dist/api/modules/pons/launch-status.d.ts +1 -0
  199. package/build/dist/api/modules/pons/launch-status.js +1 -1
  200. package/build/dist/api/modules/pons/prices.js +1 -1
  201. package/build/dist/api/modules/pons/reads.js +1 -1
  202. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  203. package/build/dist/api/modules/pons/trade.js +1 -1
  204. package/build/dist/api/modules/poolstrade/index.js +1 -1
  205. package/build/dist/api/modules/priors/coverage.js +1 -1
  206. package/build/dist/api/modules/priors/discovery.js +1 -1
  207. package/build/dist/api/modules/priors/features.js +1 -1
  208. package/build/dist/api/modules/priors/holdings.js +1 -1
  209. package/build/dist/api/modules/priors/index.js +1 -1
  210. package/build/dist/api/modules/priors/integration.js +1 -1
  211. package/build/dist/api/modules/priors/market.js +1 -1
  212. package/build/dist/api/modules/priors/pt.js +1 -1
  213. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  214. package/build/dist/api/modules/priors/starter-line.js +1 -1
  215. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  216. package/build/dist/api/modules/relay/api.js +1 -1
  217. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  218. package/build/dist/api/modules/relay/discovery.js +1 -1
  219. package/build/dist/api/modules/relay/inbound.d.ts +2 -0
  220. package/build/dist/api/modules/relay/inbound.js +1 -1
  221. package/build/dist/api/modules/relay/index.js +1 -1
  222. package/build/dist/api/modules/relay/order.js +1 -1
  223. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  224. package/build/dist/api/modules/relay/readiness.js +1 -1
  225. package/build/dist/api/modules/relay/reads.js +1 -1
  226. package/build/dist/api/modules/relay/vaults.js +1 -1
  227. package/build/dist/api/modules/spark/actions.js +1 -1
  228. package/build/dist/api/modules/spark/details.js +1 -1
  229. package/build/dist/api/modules/spark/index.js +1 -1
  230. package/build/dist/api/modules/spark/management.js +1 -1
  231. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  232. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  233. package/build/dist/api/modules/steakhouse/index.js +1 -1
  234. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  235. package/build/dist/api/modules/steakhouse/management.js +1 -1
  236. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  237. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  238. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  239. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  240. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  241. package/build/dist/api/modules/tickerspring/index.js +1 -1
  242. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  243. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  244. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  245. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  246. package/build/dist/api/modules/tickerspring/research.js +1 -1
  247. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  248. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  249. package/build/dist/api/modules/uniswap/auction.js +1 -1
  250. package/build/dist/api/modules/uniswap/batch.js +1 -1
  251. package/build/dist/api/modules/uniswap/common.js +1 -1
  252. package/build/dist/api/modules/uniswap/fees.js +1 -1
  253. package/build/dist/api/modules/uniswap/index.js +1 -1
  254. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  255. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  256. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  257. package/build/dist/api/modules/uniswap/pools.js +1 -1
  258. package/build/dist/api/modules/uniswap/position.js +1 -1
  259. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  260. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  261. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  262. package/build/dist/api/modules/uniswap/trade.js +1 -1
  263. package/build/dist/api/modules/uniswap/v2.js +1 -1
  264. package/build/dist/api/modules/uniswap/v3.d.ts +11 -1
  265. package/build/dist/api/modules/uniswap/v3.js +1 -1
  266. package/build/dist/api/modules/uniswap/v4.js +1 -1
  267. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  268. package/build/dist/api/modules/velora/claims.js +1 -1
  269. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  270. package/build/dist/api/modules/velora/index.js +1 -1
  271. package/build/dist/api/modules/wormhole/index.d.ts +3 -0
  272. package/build/dist/api/modules/wormhole/index.js +1 -1
  273. package/build/dist/api/modules/wormhole/scan-text.js +1 -1
  274. package/build/dist/api/modules/wormhole/swap-token-verdict.d.ts +11 -0
  275. package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -0
  276. package/build/dist/api/modules/wormhole/third-party-text.d.ts +13 -0
  277. package/build/dist/api/modules/wormhole/third-party-text.js +1 -0
  278. package/build/dist/api/modules/wormhole/token-check.d.ts +2 -0
  279. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  280. package/build/dist/api/modules/wormhole/x402-client.d.ts +36 -0
  281. package/build/dist/api/modules/wormhole/x402-client.js +1 -0
  282. package/build/dist/api/positions.js +1 -1
  283. package/build/dist/api/pricenote.js +1 -1
  284. package/build/dist/api/prices.js +1 -1
  285. package/build/dist/api/pricing.js +1 -1
  286. package/build/dist/api/routes.js +1 -1
  287. package/build/dist/api/send.js +1 -1
  288. package/build/dist/api/signing-registry.js +1 -1
  289. package/build/dist/api/simulate.js +1 -1
  290. package/build/dist/api/swap.js +1 -1
  291. package/build/dist/api/tokens.d.ts +1 -0
  292. package/build/dist/api/tokens.js +1 -1
  293. package/build/dist/api/tool-policy.js +1 -1
  294. package/build/dist/api/tx.js +1 -1
  295. package/build/dist/api/types.d.ts +6 -1
  296. package/build/dist/api/vendor-limits.js +1 -1
  297. package/build/dist/chunks/{ALRRW7SF.js → 2MT3G7YZ.js} +1 -1
  298. package/build/dist/chunks/{WPAF55SP.js → 2THSW4QN.js} +1 -1
  299. package/build/dist/chunks/{MKAPRRKF.js → 2TK3ETUO.js} +1 -1
  300. package/build/dist/chunks/{VVA72C6O.js → 2VXLVXIB.js} +1 -1
  301. package/build/dist/chunks/{ZE7EU2CS.js → 35KR3VSS.js} +1 -1
  302. package/build/dist/chunks/{ZYH4B2GR.js → 3GQ7A3VB.js} +1 -1
  303. package/build/dist/chunks/3VWVW7PX.js +1 -0
  304. package/build/dist/chunks/{WPFAEBE7.js → 3XNZUIRU.js} +1 -1
  305. package/build/dist/chunks/{PBQSJSZO.js → 43LI5NKJ.js} +1 -1
  306. package/build/dist/chunks/{QVYCJ6WV.js → 46KWRAYK.js} +1 -1
  307. package/build/dist/chunks/4DP2VPXR.js +3 -0
  308. package/build/dist/chunks/{47YN4OUI.js → 4EN6MQEI.js} +1 -1
  309. package/build/dist/chunks/{UHRCM7AG.js → 4HG6FRVH.js} +1 -1
  310. package/build/dist/chunks/{E6UU7DL2.js → 4I3OU56B.js} +1 -1
  311. package/build/dist/chunks/{WIVYKLQM.js → 52ELWNXJ.js} +1 -1
  312. package/build/dist/chunks/{5WUKOQIJ.js → 5AXWBSPG.js} +1 -1
  313. package/build/dist/chunks/{D6ZJPNK7.js → 5N3O42X6.js} +1 -1
  314. package/build/dist/chunks/{UA4O226F.js → 5SMVQCAP.js} +1 -1
  315. package/build/dist/chunks/{6L5KTE6Y.js → 5SZPNZG4.js} +1 -1
  316. package/build/dist/chunks/{6PY3IRDS.js → 64GOINYS.js} +1 -1
  317. package/build/dist/chunks/{5ZLOCQA4.js → 66F5ZH34.js} +1 -1
  318. package/build/dist/chunks/{XDZRO5JQ.js → 6I4NTKB2.js} +1 -1
  319. package/build/dist/chunks/{LVLVP5KQ.js → 6JAXZNZ3.js} +1 -1
  320. package/build/dist/chunks/{BXHNYCH2.js → 6O3Q5B6M.js} +1 -1
  321. package/build/dist/chunks/{MFCPL6LF.js → 6OGDTEGH.js} +1 -1
  322. package/build/dist/chunks/{43CSMYDO.js → 6WD4HHID.js} +1 -1
  323. package/build/dist/chunks/{XJEOEMDS.js → 6WZX7C4T.js} +1 -1
  324. package/build/dist/chunks/6YB3VOUL.js +1 -0
  325. package/build/dist/chunks/77CLMPM7.js +1 -0
  326. package/build/dist/chunks/{EKNSLLJK.js → 7GJ6SLEV.js} +1 -1
  327. package/build/dist/chunks/{S2TAJHHK.js → 7KWZ5QJU.js} +1 -1
  328. package/build/dist/chunks/{CTMA4BTM.js → 7QIO77VE.js} +1 -1
  329. package/build/dist/chunks/7QZOTRSA.js +2 -0
  330. package/build/dist/chunks/{IKEJCBYU.js → 7WSHW7KW.js} +1 -1
  331. package/build/dist/chunks/{PQC5635W.js → A7I4IWUB.js} +1 -1
  332. package/build/dist/chunks/ACW63WIL.js +20 -0
  333. package/build/dist/chunks/AEL62KCG.js +1 -0
  334. package/build/dist/chunks/{UPMGGK34.js → AFBEZXNV.js} +1 -1
  335. package/build/dist/chunks/{AUOXDNUO.js → AKYF5264.js} +1 -1
  336. package/build/dist/chunks/{HVM2EEXB.js → ALLLYOUG.js} +1 -1
  337. package/build/dist/chunks/APQYLJGS.js +1 -0
  338. package/build/dist/chunks/AW7AXQCZ.js +1 -0
  339. package/build/dist/chunks/{WOEKXQAH.js → AXRL3REN.js} +1 -1
  340. package/build/dist/chunks/{ECWGKLBW.js → BBTPRZ6T.js} +1 -1
  341. package/build/dist/chunks/{ALPYEM7B.js → BND2UFVW.js} +1 -1
  342. package/build/dist/chunks/{GHPREYQK.js → BOVMED7R.js} +1 -1
  343. package/build/dist/chunks/{57JFKIMK.js → BTPXJAUX.js} +1 -1
  344. package/build/dist/chunks/{ZGKVXFM5.js → C7AXJHBT.js} +1 -1
  345. package/build/dist/chunks/{5U7TCKX2.js → CBG5HARQ.js} +1 -1
  346. package/build/dist/chunks/{NA7R6J5N.js → CBLMQ5UU.js} +1 -1
  347. package/build/dist/chunks/CDPSMI3Z.js +1 -0
  348. package/build/dist/chunks/{5N4A5XAW.js → CHXBOXOD.js} +1 -1
  349. package/build/dist/chunks/{2ZUP7ZEV.js → CQEJSCFQ.js} +1 -1
  350. package/build/dist/chunks/{6AAARNZ3.js → DBNTZEAJ.js} +1 -1
  351. package/build/dist/chunks/{IQIWASRD.js → DHUDSOGR.js} +1 -1
  352. package/build/dist/chunks/{L7OQUHM5.js → DJN3JAWB.js} +1 -1
  353. package/build/dist/chunks/{YPM2UITD.js → DL6AEWEM.js} +1 -1
  354. package/build/dist/chunks/{CERNEJ2F.js → DW4V5PUY.js} +1 -1
  355. package/build/dist/chunks/E3RACZUY.js +1 -0
  356. package/build/dist/chunks/{MOPETB64.js → EGYVRQUR.js} +1 -1
  357. package/build/dist/chunks/{IQGY5FW7.js → ER47KGRM.js} +1 -1
  358. package/build/dist/chunks/{ZSQOMSOC.js → FEYAY6OZ.js} +1 -1
  359. package/build/dist/chunks/FIO6VC2J.js +1 -0
  360. package/build/dist/chunks/FJ4S4GHY.js +1 -0
  361. package/build/dist/chunks/{RPNAFUM5.js → FUDAXV5X.js} +1 -1
  362. package/build/dist/chunks/{I6KUORFT.js → GG6Y4OCJ.js} +1 -1
  363. package/build/dist/chunks/{3AXVB23N.js → GGHBFLRC.js} +1 -1
  364. package/build/dist/chunks/{4ALMYJJV.js → GGSAKCND.js} +1 -1
  365. package/build/dist/chunks/GNC6RXLT.js +1 -0
  366. package/build/dist/chunks/{3ESNHZT5.js → GRQYTVNT.js} +1 -1
  367. package/build/dist/chunks/{WVONJOWN.js → GSBIERZD.js} +1 -1
  368. package/build/dist/chunks/H43RNCX2.js +1 -0
  369. package/build/dist/chunks/{NYNJITCM.js → H6T5FXEX.js} +1 -1
  370. package/build/dist/chunks/HHXBUYHO.js +1 -0
  371. package/build/dist/chunks/{64WKYWZV.js → HKEMQBFA.js} +1 -1
  372. package/build/dist/chunks/{4YFVAYKR.js → HM72DH4V.js} +1 -1
  373. package/build/dist/chunks/{XFKVU46U.js → HQUVB7Z5.js} +1 -1
  374. package/build/dist/chunks/HS4DZPYT.js +1 -0
  375. package/build/dist/chunks/{OTIXQZ3X.js → HU7IMNBI.js} +1 -1
  376. package/build/dist/chunks/{ENX72ARB.js → HWX36XJI.js} +1 -1
  377. package/build/dist/chunks/{QRC4ZPDA.js → I26DMNJG.js} +1 -1
  378. package/build/dist/chunks/I55MURSJ.js +1 -0
  379. package/build/dist/chunks/I6PQW2JI.js +1 -0
  380. package/build/dist/chunks/{S3FPF537.js → IMO3GDA5.js} +1 -1
  381. package/build/dist/chunks/{BQICZFLR.js → IOYRL6AY.js} +1 -1
  382. package/build/dist/chunks/IPN6Z4JM.js +1 -0
  383. package/build/dist/chunks/{MKBNLGDD.js → IPRVIKYC.js} +1 -1
  384. package/build/dist/chunks/{EOQYLFXA.js → IVX4R5OL.js} +1 -1
  385. package/build/dist/chunks/IX3GZMTM.js +1 -0
  386. package/build/dist/chunks/JFYBH3DX.js +1 -0
  387. package/build/dist/chunks/{Y7RPSDD2.js → JKD2B6OX.js} +1 -1
  388. package/build/dist/chunks/JQOQMFWD.js +3 -0
  389. package/build/dist/chunks/{PSVOVZH7.js → JUZ5JU6D.js} +5 -5
  390. package/build/dist/chunks/{I4TGMF2C.js → JZS3E66E.js} +1 -1
  391. package/build/dist/chunks/{SSIENQVU.js → K3RDPI5J.js} +1 -1
  392. package/build/dist/chunks/{PADWZX7J.js → K4DHHQBI.js} +1 -1
  393. package/build/dist/chunks/{NB3LYS3G.js → KIFZ5ZSK.js} +1 -1
  394. package/build/dist/chunks/KVFZKPJT.js +1 -0
  395. package/build/dist/chunks/{EYFBVQ46.js → L5BLHY34.js} +1 -1
  396. package/build/dist/chunks/{GVPX5XCL.js → LKXO2BQS.js} +1 -1
  397. package/build/dist/chunks/{JPNYUEQP.js → LKZX4CAA.js} +1 -1
  398. package/build/dist/chunks/{LROVANUR.js → LYMNHO5T.js} +1 -1
  399. package/build/dist/chunks/{QSN6Y2K6.js → M2UXYCKH.js} +1 -1
  400. package/build/dist/chunks/{BNG2IWZL.js → M37654RL.js} +1 -1
  401. package/build/dist/chunks/{YAJYDD6C.js → M6LC6DRE.js} +1 -1
  402. package/build/dist/chunks/{AG67Z3SC.js → MOE3EVAL.js} +1 -1
  403. package/build/dist/chunks/{DVVFT42J.js → MRMR4QHA.js} +1 -1
  404. package/build/dist/chunks/{WWHCEMNB.js → N4Q6GN65.js} +1 -1
  405. package/build/dist/chunks/{S5WICHIS.js → NAZPDRIF.js} +1 -1
  406. package/build/dist/chunks/{HSFOWJ3Z.js → NKZKKCK2.js} +1 -1
  407. package/build/dist/chunks/{BAAXGB4K.js → NOFUKKP5.js} +1 -1
  408. package/build/dist/chunks/{5KUWLUPM.js → NWNYJ26T.js} +1 -1
  409. package/build/dist/chunks/{7UOOIDR3.js → O6ROOKY2.js} +1 -1
  410. package/build/dist/chunks/{KBXU7U6Q.js → O7HCEPQY.js} +1 -1
  411. package/build/dist/chunks/{LDT3QTSY.js → OJ4WJUPP.js} +1 -1
  412. package/build/dist/chunks/{WD37MEMZ.js → OLSP46ZD.js} +1 -1
  413. package/build/dist/chunks/{TPL4U3AQ.js → OOZSE2R7.js} +1 -1
  414. package/build/dist/chunks/OTXSKFUD.js +1 -0
  415. package/build/dist/chunks/{4TQQH7N6.js → P5AJSLZ7.js} +1 -1
  416. package/build/dist/chunks/{BK23XJXE.js → P5PYFK7L.js} +1 -1
  417. package/build/dist/chunks/{A6YQ5H24.js → PACN53TR.js} +1 -1
  418. package/build/dist/chunks/{K72EYD6R.js → PAHXBLCS.js} +1 -1
  419. package/build/dist/chunks/PAY5PD4H.js +1 -0
  420. package/build/dist/chunks/{SGEZIYJW.js → PIIHOXWF.js} +1 -1
  421. package/build/dist/chunks/{SQL6HD5E.js → PK66GCDT.js} +1 -1
  422. package/build/dist/chunks/PNA6UIE5.js +1 -0
  423. package/build/dist/chunks/{6FTYNYGF.js → PSBQWDYI.js} +1 -1
  424. package/build/dist/chunks/{W76QC2AW.js → PV5FDT6O.js} +1 -1
  425. package/build/dist/chunks/{42DQTKEO.js → PXT5YTWU.js} +1 -1
  426. package/build/dist/chunks/{4ISR2U72.js → PZGGE5D3.js} +1 -1
  427. package/build/dist/chunks/{IMRXZ7JB.js → Q42YI3EP.js} +1 -1
  428. package/build/dist/chunks/{F3BSEE52.js → QA2RRIES.js} +1 -1
  429. package/build/dist/chunks/{ZBFKKUNP.js → QA3UHEO3.js} +1 -1
  430. package/build/dist/chunks/{PWH464CJ.js → QBIY6FQN.js} +1 -1
  431. package/build/dist/chunks/QFNT73OF.js +1 -0
  432. package/build/dist/chunks/QHBS3PVU.js +1 -0
  433. package/build/dist/chunks/QQECG3WP.js +1 -0
  434. package/build/dist/chunks/{RVO3QK2B.js → QU5XKRGK.js} +1 -1
  435. package/build/dist/chunks/QW2OPEYJ.js +1 -0
  436. package/build/dist/chunks/{G7XSFUDL.js → QYVREJYC.js} +1 -1
  437. package/build/dist/chunks/{KA7BPBCV.js → ROFPXEQ5.js} +1 -1
  438. package/build/dist/chunks/{5MQ5KSSV.js → RTAHNWHN.js} +1 -1
  439. package/build/dist/chunks/{MDDHG34Y.js → RTGS7RIO.js} +1 -1
  440. package/build/dist/chunks/{3WXK2FUA.js → RUC7KH7A.js} +1 -1
  441. package/build/dist/chunks/{MBTARLZQ.js → RUX3RY7Y.js} +1 -1
  442. package/build/dist/chunks/{3VAJW6TQ.js → RVDUSNWW.js} +1 -1
  443. package/build/dist/chunks/{ET23SES4.js → S5CBVFHY.js} +1 -1
  444. package/build/dist/chunks/{WMNRP3YH.js → SIYUNOLI.js} +1 -1
  445. package/build/dist/chunks/{TNKVRVTH.js → SJJR4ZBZ.js} +1 -1
  446. package/build/dist/chunks/{UFVPMWPJ.js → SMYWWIE6.js} +1 -1
  447. package/build/dist/chunks/{Z4SRGAVL.js → SPJCSEKP.js} +1 -1
  448. package/build/dist/chunks/{YEXUSRIZ.js → T7TFUH5K.js} +1 -1
  449. package/build/dist/chunks/{SKMPKAZI.js → TAEZTP4L.js} +1 -1
  450. package/build/dist/chunks/{E3UBHTJO.js → TEJ7W534.js} +1 -1
  451. package/build/dist/chunks/{AWXJV2YH.js → TFDPEAVZ.js} +1 -1
  452. package/build/dist/chunks/{UOGHQLQX.js → TMVO2DAK.js} +1 -1
  453. package/build/dist/chunks/{QJFXLYZG.js → TPBAFS7K.js} +1 -1
  454. package/build/dist/chunks/{MXW2TP5P.js → TVWMTMEF.js} +1 -1
  455. package/build/dist/chunks/{GRIGSPD4.js → TX2EOIRS.js} +1 -1
  456. package/build/dist/chunks/{Y7PRJOIK.js → U2RMUVVY.js} +1 -1
  457. package/build/dist/chunks/{VV2HEIFI.js → U5PMVP56.js} +1 -1
  458. package/build/dist/chunks/{TBCSZDAF.js → UD2XMNIT.js} +1 -1
  459. package/build/dist/chunks/{F26FK47J.js → UNJJRQIU.js} +1 -1
  460. package/build/dist/chunks/V5JWGWXC.js +1 -0
  461. package/build/dist/chunks/V74F6IDY.js +1 -0
  462. package/build/dist/chunks/VCOTCVKN.js +1 -0
  463. package/build/dist/chunks/{MYFAKCQI.js → VEQBHI6O.js} +1 -1
  464. package/build/dist/chunks/VHV6WQ5F.js +1 -0
  465. package/build/dist/chunks/{7WQEPZJY.js → VNV6ZISN.js} +1 -1
  466. package/build/dist/chunks/{W2OJ57ZO.js → VYAJXLND.js} +1 -1
  467. package/build/dist/chunks/{MDV7GECM.js → VYYSL557.js} +1 -1
  468. package/build/dist/chunks/WCNHZYQQ.js +1 -0
  469. package/build/dist/chunks/{K22EXPWN.js → WIRBCS4W.js} +1 -1
  470. package/build/dist/chunks/{YRXT3HTW.js → WLMWWEP7.js} +1 -1
  471. package/build/dist/chunks/{NDW5DAFL.js → WP6RHXGN.js} +1 -1
  472. package/build/dist/chunks/{PLZKXQ76.js → WTXC3XKW.js} +1 -1
  473. package/build/dist/chunks/{WGL46F3S.js → WU7XIAXB.js} +1 -1
  474. package/build/dist/chunks/{5OKJEGBH.js → WV3A3OUU.js} +1 -1
  475. package/build/dist/chunks/{MGPHD4VV.js → X2P55AC3.js} +1 -1
  476. package/build/dist/chunks/{RNC463IM.js → XBE3B6Y2.js} +1 -1
  477. package/build/dist/chunks/XD6X3KTC.js +1 -0
  478. package/build/dist/chunks/{BIRMUW7Z.js → XKSVTN5X.js} +1 -1
  479. package/build/dist/chunks/XL3LLGIR.js +1 -0
  480. package/build/dist/chunks/XQA5LCL6.js +1 -0
  481. package/build/dist/chunks/{SDHPFXRM.js → XSKFKBDR.js} +1 -1
  482. package/build/dist/chunks/{TJWVY4VO.js → YCZPSMZ5.js} +1 -1
  483. package/build/dist/chunks/{JZXYLHI7.js → YDNTY67T.js} +1 -1
  484. package/build/dist/chunks/{2DUCTO5C.js → YN56C7PN.js} +1 -1
  485. package/build/dist/chunks/{E6RRXNV2.js → YRNXGQJC.js} +1 -1
  486. package/build/dist/chunks/YWRLY5EA.js +1 -0
  487. package/build/dist/chunks/YWSX6IE6.js +1 -0
  488. package/build/dist/chunks/{DP2NIYBP.js → YXTSWRV5.js} +1 -1
  489. package/build/dist/chunks/{MQYOG66Q.js → Z6LZGCVW.js} +1 -1
  490. package/build/dist/chunks/{OFI3Y55L.js → ZQAFFWDK.js} +1 -1
  491. package/build/dist/chunks/{NZXQWDGF.js → ZQWZGH7V.js} +1 -1
  492. package/build/dist/chunks/{TBIVTEP5.js → ZSN4IRI5.js} +1 -1
  493. package/build/dist/chunks/{ZET37EIG.js → ZV5HIQXC.js} +1 -1
  494. package/build/dist/chunks/{VHLINDDS.js → ZXJ24B4L.js} +1 -1
  495. package/package.json +1 -1
  496. package/build/dist/chunks/24CQ2SPB.js +0 -1
  497. package/build/dist/chunks/2OJAOVMG.js +0 -1
  498. package/build/dist/chunks/65EQECL3.js +0 -1
  499. package/build/dist/chunks/6YYCGUCU.js +0 -1
  500. package/build/dist/chunks/EU3OAJU2.js +0 -1
  501. package/build/dist/chunks/H4NYYJ3Z.js +0 -1
  502. package/build/dist/chunks/HTXKERNS.js +0 -1
  503. package/build/dist/chunks/JG27HM4P.js +0 -1
  504. package/build/dist/chunks/L6D26AMO.js +0 -1
  505. package/build/dist/chunks/O6L4BJP4.js +0 -1
  506. package/build/dist/chunks/SUFA2GKR.js +0 -1
  507. package/build/dist/chunks/UP7FBDMJ.js +0 -1
  508. package/build/dist/chunks/YHRUAQQK.js +0 -1
  509. package/build/dist/chunks/ZCOFMGPS.js +0 -1
  510. package/build/dist/chunks/ZCUXM52B.js +0 -1
@@ -1 +1 @@
1
- import{a as y}from"./PBQSJSZO.js";import{m as b}from"./5KUWLUPM.js";import{a as i,i as w,j as l}from"./FWD4L3CJ.js";import{a as c}from"./XSD5NL7J.js";import{erc20Abi as v,getAddress as u,parseAbi as G}from"viem";var d=10n**27n,I=1000000021979553151239153027n,a=u(w[i].vaults.spark.address),U="https://docs.spark.finance/dev/savings/spark-vaults-v2",g=G(["function asset() view returns (address)","function vsr() view returns (uint256)","function totalAssets() view returns (uint256)","function depositCap() view returns (uint256)","function minVsr() view returns (uint256)","function maxVsr() view returns (uint256)","function convertToAssets(uint256) view returns (uint256)"]);function n(e){return b(e,"Spark returned an invalid unsigned integer.")}function q(e){if(e<d||e>I)throw new c("Spark savings rate is outside the documented bounds.");let r=31536000n,s=e,t=d;for(;r>0n;)r%2n&&(t=t*s/d),r/=2n,r>0n&&(s=s*s/d);return t-d}function j(e){return{name:"spark_details",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(r,s)=>{try{if(y(s),Object.keys(r).length)throw new c("Spark details takes no arguments.");let t=e.clientFor(i);if(await t.getChainId()!==i)throw new c("Spark details requires chain 4663.");let o=await t.getBlockNumber({cacheTime:0}),h=await t.readContract({address:a,abi:g,functionName:"asset",blockNumber:o});if(typeof h!="string"||u(h)!==u(l))throw new c("Spark does not report canonical USDG.");let[k,A,C,D,x,N,R]=await Promise.all([...["vsr","totalAssets","depositCap","minVsr","maxVsr"].map(V=>t.readContract({address:a,abi:g,functionName:V,blockNumber:o})),t.readContract({address:u(l),abi:v,functionName:"balanceOf",args:[a],blockNumber:o}),t.readContract({address:a,abi:v,functionName:"balanceOf",args:[s],blockNumber:o})]),f=n(k),p=n(A),m=n(N),S=n(R),T=n(await t.readContract({address:a,abi:g,functionName:"convertToAssets",args:[S],blockNumber:o}));return{chainId:i,vault:a,blockNumber:o.toString(),asset:{address:u(l),symbol:"USDG",decimals:6,chainId:i},shareToken:{address:a,symbol:"spUSDG",decimals:6,chainId:i},rate:{vsrRay:f.toString(),scale:d.toString(),annualYieldRay:q(f).toString(),secondsPerYear:"31536000",minVsrRay:n(D).toString(),maxVsrRay:n(x).toString(),caveat:"Projection with the current per-second rate held constant; governance can change it. Not a promised return."},totalAssets:p.toString(),idleAssets:m.toString(),depositCapAssets:n(C).toString(),outstandingAssets:(p>m?p-m:0n).toString(),heldShares:S.toString(),positionAssets:T.toString(),backing:{source:U,mechanism:"The permissioned taker deploys liquidity through the Spark Liquidity Layer. totalAssets is share-implied accounting; idle USDG alone funds immediate redemptions.",composition:null,compositionStatus:"Current strategy-by-strategy backing was not measured on this chain; inspect the official Spark app."},risk:["Liquidity deployed by the taker may be unavailable for immediate withdrawal.","Vault upgrades and role-controlled rate/cap changes affect behavior.","Share value and the USDG peg can change; conversion does not prove exit liquidity."]}}catch(t){throw new c(e.plainError(t))}}}}export{q as a,j as b};
1
+ import{a as y}from"./43LI5NKJ.js";import{m as b}from"./NWNYJ26T.js";import{a as i,i as w,j as l}from"./FWD4L3CJ.js";import{a as c}from"./XSD5NL7J.js";import{erc20Abi as v,getAddress as u,parseAbi as G}from"viem";var d=10n**27n,I=1000000021979553151239153027n,a=u(w[i].vaults.spark.address),U="https://docs.spark.finance/dev/savings/spark-vaults-v2",g=G(["function asset() view returns (address)","function vsr() view returns (uint256)","function totalAssets() view returns (uint256)","function depositCap() view returns (uint256)","function minVsr() view returns (uint256)","function maxVsr() view returns (uint256)","function convertToAssets(uint256) view returns (uint256)"]);function n(e){return b(e,"Spark returned an invalid unsigned integer.")}function q(e){if(e<d||e>I)throw new c("Spark savings rate is outside the documented bounds.");let r=31536000n,s=e,t=d;for(;r>0n;)r%2n&&(t=t*s/d),r/=2n,r>0n&&(s=s*s/d);return t-d}function j(e){return{name:"spark_details",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(r,s)=>{try{if(y(s),Object.keys(r).length)throw new c("Spark details takes no arguments.");let t=e.clientFor(i);if(await t.getChainId()!==i)throw new c("Spark details requires chain 4663.");let o=await t.getBlockNumber({cacheTime:0}),h=await t.readContract({address:a,abi:g,functionName:"asset",blockNumber:o});if(typeof h!="string"||u(h)!==u(l))throw new c("Spark does not report canonical USDG.");let[k,A,C,D,x,N,R]=await Promise.all([...["vsr","totalAssets","depositCap","minVsr","maxVsr"].map(V=>t.readContract({address:a,abi:g,functionName:V,blockNumber:o})),t.readContract({address:u(l),abi:v,functionName:"balanceOf",args:[a],blockNumber:o}),t.readContract({address:a,abi:v,functionName:"balanceOf",args:[s],blockNumber:o})]),f=n(k),p=n(A),m=n(N),S=n(R),T=n(await t.readContract({address:a,abi:g,functionName:"convertToAssets",args:[S],blockNumber:o}));return{chainId:i,vault:a,blockNumber:o.toString(),asset:{address:u(l),symbol:"USDG",decimals:6,chainId:i},shareToken:{address:a,symbol:"spUSDG",decimals:6,chainId:i},rate:{vsrRay:f.toString(),scale:d.toString(),annualYieldRay:q(f).toString(),secondsPerYear:"31536000",minVsrRay:n(D).toString(),maxVsrRay:n(x).toString(),caveat:"Projection with the current per-second rate held constant; governance can change it. Not a promised return."},totalAssets:p.toString(),idleAssets:m.toString(),depositCapAssets:n(C).toString(),outstandingAssets:(p>m?p-m:0n).toString(),heldShares:S.toString(),positionAssets:T.toString(),backing:{source:U,mechanism:"The permissioned taker deploys liquidity through the Spark Liquidity Layer. totalAssets is share-implied accounting; idle USDG alone funds immediate redemptions.",composition:null,compositionStatus:"Current strategy-by-strategy backing was not measured on this chain; inspect the official Spark app."},risk:["Liquidity deployed by the taker may be unavailable for immediate withdrawal.","Vault upgrades and role-controlled rate/cap changes affect behavior.","Share value and the USDG peg can change; conversion does not prove exit liquidity."]}}catch(t){throw new c(e.plainError(t))}}}}export{q as a,j as b};
@@ -0,0 +1 @@
1
+ var c={chainId:4663,owner:"0x8A22d6e75e9427b9D57e42a7984200029e7E173C",curator:"0x8A22d6e75e9427b9D57e42a7984200029e7E173C",factory:{address:"0x0FBad98595b0186dA120E41f77C102beb49f803c",codeHash:"0xba55eb73d42937607d7e3c77f68353c2517c4fad4df02f0c9bbd2e4248475503",membershipFunction:"isVaultV2",creationEvent:"CreateVaultV2(address,address,bytes32,address)",fromBlock:"0",source:"https://github.com/morpho-org/vault-v2/blob/main/src/VaultV2Factory.sol",measuredAtBlock:"106289278"},assetRule:{usdg:{address:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",symbol:"USDG",decimals:6},officialStockRegistry:"https://api.robinhood.com/rhj/assets"},source:"https://borro.markets/contracts.json"},e=[{chainId:4663,symbol:"SPY",entry:"0xc3ed4a5a7db4102f4ed37af26ef0d3f21e2360c1",proxy:"0x117cc2133c37b721f49de2a7a74833232b3b4c0c",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"QQQ",entry:"0xbad8a97da1050092d6a14194d53e72d407d6cc17",proxy:"0xd5f3879160bc7c32ebb4dc785f8a4f505888de68",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"NVDA",entry:"0x508e23274c39c60c345e35b1f0188be180717cb9",proxy:"0xd0601ce157db5bdc3162bbac2a2c8af5320d9eec",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"TSLA",entry:"0x60b3d353e7e5bd12ed4ea2589c11b5603dd4c988",proxy:"0x322f0929c4625ed5bad873c95208d54e1c003b2d",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"MSTR",entry:"0x2b74f8f2b76cd4e97265bc37fb2578a04b8437e9",proxy:"0xec262a75e413fafd0df80480274532c79d42da09",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"COIN",entry:"0x7ba71bccecb12860ae7e141b6b6f1f8b96d31257",proxy:"0x6330d8c3178a418788df01a47479c0ce7ccf450b",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"PLTR",entry:"0xfe9419e70e5481f7a2ddddc18f856b09b3687b27",proxy:"0x894e1ec2d74ffe5aef8dc8a9e84686accb964f2a",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"SPCX",entry:"0x1261210e19052157fce2064d9aa9a2140bd89791",proxy:"0x4a0e65a3eccec6dbe60ae065f2e7bb85fae35eea",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"GME",entry:"0x328461fb01f54c2ab73909ea947c583d0dc24c3d",proxy:"0x1b0e319c6a659f002271b69db8a7df2f911c153e",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"AAPL",entry:"0x24fe7bcaeb75bc2202a42ecd48a177a27782c64a",proxy:"0xaf3d76f1834a1d425780943c99ea8a608f8a93f9",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"GOOGL",entry:"0xf0731b1022abd1e3f543cfd837c7eba42ed60e4f",proxy:"0x2e0847e8910a9732eb3fb1bb4b70a580adad4fe3",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"},{chainId:4663,symbol:"MSFT",entry:"0x8032c80a7817a3c4c401b096515b27b2ceda4e71",proxy:"0xe93237c50d904957cf27e7b1133b510c669c2e74",proxyCodeHash:"0x6c1fdd40002dcb440c7fff6a84171404d279ccb057803b65826f7546acd65630",implementation:"0xb35490d6f9163de4f80d88dc75c3516eb64c5ae2",codeHash:"0xdc07e86ee482f99641bdafb9a0d772846b167401e094d90a666b94dbdcd1eec7",measuredAtBlock:"106350992",source:"https://rpc.mainnet.chain.robinhood.com"}].flatMap(d=>[d,{...d,entry:d.proxy}]);export{c as a,e as b};
@@ -1 +1 @@
1
- import{a as S}from"./WWNAGOCD.js";import{c as U}from"./NA7R6J5N.js";import{b as R,c as I,d as j,e as C,g as D,h as V,j as t,k as w,l as E,m as B,o as n,p as o,q as d,r as p,s as y,v as H}from"./YEXUSRIZ.js";import{b as a,f as F,g as L,h as O,i as q}from"./MQK6OP7S.js";import{a as s}from"./XSD5NL7J.js";import{getAddress as i}from"viem";async function re(r,m,x,u=[]){let e=await O(r,x);await L(r,e.number,[a.launcherV1,d,a.rulesV1,a.agentGateV1]);let l=i(a.launcherV1),[h,_,z,N,Q,K,G,W,$,J,X,A,b]=await Promise.all([U(r,e.number,m,u),o(r,l,j,"launchFee",[],e.number),o(r,p,n("registry"),"rootOpenFor",[d,m],e.number),o(r,p,n("registry"),"newMarketsPaused",[],e.number),o(r,p,n("registry"),"isLauncher",[l],e.number),o(r,d,n("rootV1"),"poolManager",[],e.number),o(r,l,n("launcherV1"),"poolManager",[],e.number),o(r,l,n("launcherV1"),"registry",[],e.number),o(r,i(a.rulesV1),n("rulesV1"),"trustedRoot",[],e.number),o(r,i(a.rulesV1),n("rulesV1"),"poolManager",[],e.number),o(r,p,n("registry"),"admission",[d,i(a.rulesV1)],e.number),o(r,i(a.rulesV1),n("rulesV1"),"configSchemaHash",[],e.number),o(r,p,n("registry"),"quoteAssets",[],e.number)]);if(K!==y||G!==y||W!==p||$!==d||J!==y)throw new s("Hookr launch dependency wiring differs from the reviewed deployment.");V(A);let c=B(X),g=B(c.caps);if(c.implementation!==i(a.rulesV1)||t(c.kind,8)!==0n||c.codeHash!==F(a.rulesV1).codeHash||c.schemaHash!==A||t(c.gasLimit,32)===0n||t(g.maxLpFeePips,24)>600000n||t(g.maxQuoteTakePips,24)>=1000000n||t(g.maxSubjectTakeBps,16)>1000n)throw new s("Hookr core admission, schema or caps differ from the supported launch profile.");if(!Array.isArray(b)||b.length>32)throw new s("Hookr qualified quote list is incomplete or exceeds the bounded read.");let T=[];for(let f=0;f<b.length;f+=2)T.push(...await Promise.all(b.slice(f,f+2).map(ee=>H(r,i(String(ee)),e.number))));let Y=await H(r,i("0x0000000000000000000000000000000000000000"),e.number),k=E(_,5),Z={token:Y,amount:t(k[0]).toString(),currency:"ETH",decimals:18,treasury:i(String(k[1])),pendingAmount:t(k[2]).toString(),pendingTreasury:i(String(k[3])),readyAt:t(k[4]).toString()},M=w(z),P=w(N),v=w(Q);return await q(r,e),{chainId:4663,blockNumber:e.number.toString(),blockHash:e.hash,timestamp:e.timestamp.toString(),version:"hookr-launcher-v1",launcher:l,root:d,core:i(a.rulesV1),poolManager:y,permissionMask:"0x2acc",launchFee:Z,qualifiedQuotes:T,coreAdmission:{schemaHash:A,gasLimit:t(c.gasLimit,32).toString(),caps:{maxLpFeePips:t(g.maxLpFeePips,24).toString(),maxQuoteTakePips:t(g.maxQuoteTakePips,24).toString(),maxSubjectTakeBps:t(g.maxSubjectTakeBps,16).toString()}},gate:h,rootOpenForWallet:M,newMarketsPaused:P,launcherAdmitted:v,launchAvailable:M&&!P&&v&&h.healthyIdentityOnly&&h.walletAgent,scoreLaunchAvailable:M&&!P&&v&&h.healthyForScores&&h.walletAgent,supportedSettings:{route:"launchAdvised",members:"1",tokenKinds:["new"],reservedTokenKinds:["existing"],tickSpacing:String(S.tickSpacing),baseLpFeePips:String(S.baseLpFeePips),deadlineSecondsMax:S.deadlineSeconds.toString(),guardEndBlock:"0",burnBps:"0",royaltyBps:"0",integrator:null,nameMaxUtf8Bytes:"48",symbolMaxUtf8Bytes:"12",supplyMaxBaseUnits:((1n<<108n)-1n).toString(),liquidityMax:((1n<<127n)-1n).toString(),fee:"8388608",tickSpacingMin:"1",tickSpacingMax:"32767",tickMin:"-887272",tickMax:"887272",requiresTickAlignment:!0,gateRequired:!0,gatePhases:"1",gateFailOpen:!1,arbitraryAdvisories:!1,devBuy:!1,locks:!1,ownedRoot:!1,lpRewardsBpsMax:"1000",lpRewardsPlusBurnBpsMax:"1000",totalLpFeePipsMax:"600000",protocolShareBpsMin:"2000",protocolShareBpsMax:"5000",existingTokenFunding:"requires a separately qualified token route"},readStatus:"complete",warnings:["Read-only admission snapshot. hookr_launch supports one new-token agents-only pool with the fixed profile; add/collect/remove require separate tools.","Oak identity linking alone does not establish on-chain Hookr gate eligibility.",h.reviewerSetsNotice]}}function le(r){return[{name:"hookr_launch_options",inputSchema:{type:"object",additionalProperties:!1,properties:{...I,reviewerSetIds:{type:"array",maxItems:8,uniqueItems:!0,items:R,description:"Existing registered reviewer set IDs to inspect; no alias or arbitrary reviewer address."}}},execute:async(m,x)=>{if(C(m,["blockNumber","reviewerSetIds"]),r.network==="testnet")throw new s("Hookr launch reads are configured only on mainnet, chain 4663.");let u=m.reviewerSetIds??[];if(!Array.isArray(u)||u.length>8||new Set(u).size!==u.length)throw new s("Provide at most eight distinct reviewer set IDs.");let e=u.map(V);if(new Set(e).size!==e.length)throw new s("Provide distinct reviewer set IDs.");try{return await re(r.clientFor(4663),x,D(m),e)}catch(l){throw l instanceof s?l:new s("Hookr launch settings are unavailable at the named block. Retry the complete read; no zero fee or healthy gate is implied.")}}}]}export{re as a,le as b};
1
+ import{a as S}from"./WWNAGOCD.js";import{c as U}from"./CBLMQ5UU.js";import{b as R,c as I,d as j,e as C,g as D,h as V,j as t,k as w,l as E,m as B,o as n,p as o,q as d,r as p,s as y,v as H}from"./T7TFUH5K.js";import{b as a,f as F,g as L,h as O,i as q}from"./MQK6OP7S.js";import{a as s}from"./XSD5NL7J.js";import{getAddress as i}from"viem";async function re(r,m,x,u=[]){let e=await O(r,x);await L(r,e.number,[a.launcherV1,d,a.rulesV1,a.agentGateV1]);let l=i(a.launcherV1),[h,_,z,N,Q,K,G,W,$,J,X,A,b]=await Promise.all([U(r,e.number,m,u),o(r,l,j,"launchFee",[],e.number),o(r,p,n("registry"),"rootOpenFor",[d,m],e.number),o(r,p,n("registry"),"newMarketsPaused",[],e.number),o(r,p,n("registry"),"isLauncher",[l],e.number),o(r,d,n("rootV1"),"poolManager",[],e.number),o(r,l,n("launcherV1"),"poolManager",[],e.number),o(r,l,n("launcherV1"),"registry",[],e.number),o(r,i(a.rulesV1),n("rulesV1"),"trustedRoot",[],e.number),o(r,i(a.rulesV1),n("rulesV1"),"poolManager",[],e.number),o(r,p,n("registry"),"admission",[d,i(a.rulesV1)],e.number),o(r,i(a.rulesV1),n("rulesV1"),"configSchemaHash",[],e.number),o(r,p,n("registry"),"quoteAssets",[],e.number)]);if(K!==y||G!==y||W!==p||$!==d||J!==y)throw new s("Hookr launch dependency wiring differs from the reviewed deployment.");V(A);let c=B(X),g=B(c.caps);if(c.implementation!==i(a.rulesV1)||t(c.kind,8)!==0n||c.codeHash!==F(a.rulesV1).codeHash||c.schemaHash!==A||t(c.gasLimit,32)===0n||t(g.maxLpFeePips,24)>600000n||t(g.maxQuoteTakePips,24)>=1000000n||t(g.maxSubjectTakeBps,16)>1000n)throw new s("Hookr core admission, schema or caps differ from the supported launch profile.");if(!Array.isArray(b)||b.length>32)throw new s("Hookr qualified quote list is incomplete or exceeds the bounded read.");let T=[];for(let f=0;f<b.length;f+=2)T.push(...await Promise.all(b.slice(f,f+2).map(ee=>H(r,i(String(ee)),e.number))));let Y=await H(r,i("0x0000000000000000000000000000000000000000"),e.number),k=E(_,5),Z={token:Y,amount:t(k[0]).toString(),currency:"ETH",decimals:18,treasury:i(String(k[1])),pendingAmount:t(k[2]).toString(),pendingTreasury:i(String(k[3])),readyAt:t(k[4]).toString()},M=w(z),P=w(N),v=w(Q);return await q(r,e),{chainId:4663,blockNumber:e.number.toString(),blockHash:e.hash,timestamp:e.timestamp.toString(),version:"hookr-launcher-v1",launcher:l,root:d,core:i(a.rulesV1),poolManager:y,permissionMask:"0x2acc",launchFee:Z,qualifiedQuotes:T,coreAdmission:{schemaHash:A,gasLimit:t(c.gasLimit,32).toString(),caps:{maxLpFeePips:t(g.maxLpFeePips,24).toString(),maxQuoteTakePips:t(g.maxQuoteTakePips,24).toString(),maxSubjectTakeBps:t(g.maxSubjectTakeBps,16).toString()}},gate:h,rootOpenForWallet:M,newMarketsPaused:P,launcherAdmitted:v,launchAvailable:M&&!P&&v&&h.healthyIdentityOnly&&h.walletAgent,scoreLaunchAvailable:M&&!P&&v&&h.healthyForScores&&h.walletAgent,supportedSettings:{route:"launchAdvised",members:"1",tokenKinds:["new"],reservedTokenKinds:["existing"],tickSpacing:String(S.tickSpacing),baseLpFeePips:String(S.baseLpFeePips),deadlineSecondsMax:S.deadlineSeconds.toString(),guardEndBlock:"0",burnBps:"0",royaltyBps:"0",integrator:null,nameMaxUtf8Bytes:"48",symbolMaxUtf8Bytes:"12",supplyMaxBaseUnits:((1n<<108n)-1n).toString(),liquidityMax:((1n<<127n)-1n).toString(),fee:"8388608",tickSpacingMin:"1",tickSpacingMax:"32767",tickMin:"-887272",tickMax:"887272",requiresTickAlignment:!0,gateRequired:!0,gatePhases:"1",gateFailOpen:!1,arbitraryAdvisories:!1,devBuy:!1,locks:!1,ownedRoot:!1,lpRewardsBpsMax:"1000",lpRewardsPlusBurnBpsMax:"1000",totalLpFeePipsMax:"600000",protocolShareBpsMin:"2000",protocolShareBpsMax:"5000",existingTokenFunding:"requires a separately qualified token route"},readStatus:"complete",warnings:["Read-only admission snapshot. hookr_launch supports one new-token agents-only pool with the fixed profile; add/collect/remove require separate tools.","Oak identity linking alone does not establish on-chain Hookr gate eligibility.",h.reviewerSetsNotice]}}function le(r){return[{name:"hookr_launch_options",inputSchema:{type:"object",additionalProperties:!1,properties:{...I,reviewerSetIds:{type:"array",maxItems:8,uniqueItems:!0,items:R,description:"Existing registered reviewer set IDs to inspect; no alias or arbitrary reviewer address."}}},execute:async(m,x)=>{if(C(m,["blockNumber","reviewerSetIds"]),r.network==="testnet")throw new s("Hookr launch reads are configured only on mainnet, chain 4663.");let u=m.reviewerSetIds??[];if(!Array.isArray(u)||u.length>8||new Set(u).size!==u.length)throw new s("Provide at most eight distinct reviewer set IDs.");let e=u.map(V);if(new Set(e).size!==e.length)throw new s("Provide distinct reviewer set IDs.");try{return await re(r.clientFor(4663),x,D(m),e)}catch(l){throw l instanceof s?l:new s("Hookr launch settings are unavailable at the named block. Retry the complete read; no zero fee or healthy gate is implied.")}}}]}export{re as a,le as b};
@@ -1 +1 @@
1
- import{a as H}from"./5ZLOCQA4.js";import{c as B,f as j,g as I,k as F,n as G}from"./5KUWLUPM.js";import{a as k,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=z[k].meridian,S=ne.PredictionMarketEscrow.address,M={address:ne.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(e,p){if(e===void 0)return p;if(!Number.isSafeInteger(e)||e<1||e>E)throw new a("Provide a Meridian page limit from 1 to 25.");return e}function Z(e){if(e===void 0)return;let p=()=>new a("Provide the opaque Meridian nextCursor returned by the previous page.");if(typeof e!="string"||e.length>4096||!/^[A-Za-z0-9+/_-]+={0,2}$/.test(e))throw p();try{let c=Buffer.from(e,"base64url");if(c.toString("base64url")!==e.replace(/=+$/,"").replace(/\+/g,"-").replace(/\//g,"_"))throw p();let m=C(JSON.parse(c.toString("utf8")));if(typeof m.k!="string"||!m.k||typeof m.id!="string"||!m.id)throw p()}catch{throw p()}return e}function X(e,p,c,m=!1){let l=C(e),f=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!m||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>p||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof f.hasNextPage!="boolean"||c===void 0&&!f.hasNextPage&&l.totalCount>l.nodes.length||f.endCursor!==null&&(typeof f.endCursor!="string"||!f.endCursor.trim()||f.endCursor.length>4096)||f.hasNextPage&&(l.nodes.length===0||f.endCursor===null||f.endCursor===c))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:f.hasNextPage?f.endCursor:null,complete:!f.hasNextPage&&c===void 0}}function C(e){return j(e,"Meridian returned an unexpected response.")}function A(e){if(typeof e!="string"||!e.trim())throw new a("Meridian returned an invalid text field.");return e}function b(e){return F(e,"Provide a valid Meridian contract or wallet address.")}function v(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return e}function R(e){return G(e,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(e){return e===0?"0":R(e)}function D(e){if(typeof e!="bigint"||e<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(e.toString())}function ue(e,p){return e.chainId===p.chainId&&I(e.address,p.address)}function ee(e,p){let c=C(e),m=C(c.pickConfig),l=b(c.holder),f=b(m.marketAddress);if(c.chainId!==k||!I(l,p))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(f,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof m.resolved!="boolean"||m.result!==null&&typeof m.result!="string")throw new a("Meridian returned an invalid resolution.");let P=v(c.pickConfigId);if(!I(v(m.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(c.side!=="PREDICTOR"&&c.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(c.id),chainId:k,holder:l,side:c.side,balance:N(c.balance),tokenAddress:b(c.tokenAddress),pickConfigId:P,userCollateral:N(c.userCollateral),totalPayout:N(c.totalPayout),prediction:{predictionId:v(C(c.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:f,resolved:m.resolved,result:m.result}}}var le=e=>{async function p(t){try{return await t()}catch(o){throw new a(e.plainError(o))}}async function c(){let t=e.clientFor(k);if(await t.getChainId()!==k)throw new a("Meridian requires an RPC on chain 4663.");return t}async function m(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let n=await e.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!n.ok)throw new a(`Meridian returned HTTP ${n.status}. Please try again.`);let u;try{u=await n.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(u);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await m("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return X(s.positions,o,r,!0)}async function f(t,o){let r=[],s=new Set,n=new Set,u,d,h=0;for(let g=0;g<ce;g++){let w=await l(t,E,u);if(d!==void 0&&d!==w.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=w.totalCount;for(let x of w.nodes){let i=C(x),y=A(i.id);if(n.has(y))throw new a("Meridian repeated a position during pagination; retry from the first page.");n.add(y),N(i.balance)!=="0"&&h++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(w.nextCursor===null){if(h>d||n.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(w.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(w.nextCursor),u=w.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await c();return(await Promise.all(t.map(async n=>{let[u,d,h]=await Promise.all([r.readContract({address:n.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:n.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:n.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let g={address:n.tokenAddress,chainId:k,decimals:d,symbol:A(h)},w=D(u),x=n.pickConfig.resolved?{token:{...M},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[n.pickConfigId,n.tokenAddress,BigInt(w)]}))}:null;return{module:"meridian",id:n.id,chainId:k,assets:[{token:g,amount:w}],description:`Meridian ${n.side.toLowerCase()} position; ${n.pickConfig.resolved?n.pickConfig.result??"resolved":"unresolved"}.`,holder:n.holder,side:n.side,pickConfigId:n.pickConfigId,prediction:n.prediction,pickConfig:n.pickConfig,userCollateral:{token:{...M},amount:n.userCollateral},totalPayout:{token:{...M},amount:n.totalPayout},claimable:x}}))).filter(n=>BigInt(n.assets[0].amount)>0n)}async function q(t){return P(await f(t),t)}function _(t){return e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function L(t,o,r){let s=o.changes.map(n=>{let u=n.amount.startsWith("-"),d=e.formatAmount(u?n.amount.slice(1):n.amount,n.token.decimals);return`${u?"-":"+"}${d} ${n.token.symbol} (${n.token.address}, chain ${n.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=Z(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let n;if(t.search!==void 0&&(n=A(t.search).trim(),n.length>500))throw new a("Keep the Meridian market search to 500 characters.");let u=t.conditionId===void 0?void 0:v(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),h=await m("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...n===void 0?{}:{search:n},...u===void 0?{}:{conditionIds:[u]},...d===void 0?{}:{resolvers:[d]}}),g=X(h.conditions,o,r),w=g.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let y=v(i.conditionId),T=b(i.resolver);if(u!==void 0&&!I(y,u)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:y,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:k,collateral:{...M},totalCount:g.totalCount,markets:w,limit:o,nextCursor:g.nextCursor,complete:g.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let n=await c(),u=D(await n.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(u))throw new a("The redemption amount exceeds the wallet position balance.");let d=e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),h=[d],g;try{g=await e.preview(h,o)}catch(i){if(!/\breverted\b/i.test(e.plainError(i)))throw i;let y=await f(o,r);if(y.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=y[0];if(T.pickConfig.resolved){let re=D(await n.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}h=[_(T.prediction.predictionId),d],g=await e.preview(h,o)}let w=g.changes.filter(i=>ue(i.token,M)&&i.token.decimals===M.decimals).reduce((i,y)=>i+BigInt(y.amount),0n),x=g.changes.filter(i=>i.token.chainId===k&&I(i.token.address,r)).reduce((i,y)=>i+BigInt(y.amount),0n);if(w<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return L(h,g,h.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,n){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(u,d)=>p(async()=>{if(C(u),b(d),Object.keys(u).some(h=>!Object.hasOwn(o,h))||r.some(h=>u[h]===void 0))throw new a("Provide only the required Meridian tool inputs.");return n(u,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=Z(t.cursor),n=await l(o,r,s);return{positions:await P(n.nodes.map(u=>ee(u,o)),o),totalCount:n.totalCount,limit:r,nextCursor:n.nextCursor,complete:n.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=_(v(t.predictionId));await c();let s=[r];return L(s,await e.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>p(()=>q(t))}},we=le;export{le as a,we as b};
1
+ import{a as H}from"./66F5ZH34.js";import{c as B,f as j,g as I,k as F,n as G}from"./NWNYJ26T.js";import{a as k,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=z[k].meridian,S=ne.PredictionMarketEscrow.address,M={address:ne.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(e,p){if(e===void 0)return p;if(!Number.isSafeInteger(e)||e<1||e>E)throw new a("Provide a Meridian page limit from 1 to 25.");return e}function Z(e){if(e===void 0)return;let p=()=>new a("Provide the opaque Meridian nextCursor returned by the previous page.");if(typeof e!="string"||e.length>4096||!/^[A-Za-z0-9+/_-]+={0,2}$/.test(e))throw p();try{let c=Buffer.from(e,"base64url");if(c.toString("base64url")!==e.replace(/=+$/,"").replace(/\+/g,"-").replace(/\//g,"_"))throw p();let m=C(JSON.parse(c.toString("utf8")));if(typeof m.k!="string"||!m.k||typeof m.id!="string"||!m.id)throw p()}catch{throw p()}return e}function X(e,p,c,m=!1){let l=C(e),f=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!m||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>p||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof f.hasNextPage!="boolean"||c===void 0&&!f.hasNextPage&&l.totalCount>l.nodes.length||f.endCursor!==null&&(typeof f.endCursor!="string"||!f.endCursor.trim()||f.endCursor.length>4096)||f.hasNextPage&&(l.nodes.length===0||f.endCursor===null||f.endCursor===c))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:f.hasNextPage?f.endCursor:null,complete:!f.hasNextPage&&c===void 0}}function C(e){return j(e,"Meridian returned an unexpected response.")}function A(e){if(typeof e!="string"||!e.trim())throw new a("Meridian returned an invalid text field.");return e}function b(e){return F(e,"Provide a valid Meridian contract or wallet address.")}function v(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return e}function R(e){return G(e,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(e){return e===0?"0":R(e)}function D(e){if(typeof e!="bigint"||e<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(e.toString())}function ue(e,p){return e.chainId===p.chainId&&I(e.address,p.address)}function ee(e,p){let c=C(e),m=C(c.pickConfig),l=b(c.holder),f=b(m.marketAddress);if(c.chainId!==k||!I(l,p))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(f,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof m.resolved!="boolean"||m.result!==null&&typeof m.result!="string")throw new a("Meridian returned an invalid resolution.");let P=v(c.pickConfigId);if(!I(v(m.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(c.side!=="PREDICTOR"&&c.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(c.id),chainId:k,holder:l,side:c.side,balance:N(c.balance),tokenAddress:b(c.tokenAddress),pickConfigId:P,userCollateral:N(c.userCollateral),totalPayout:N(c.totalPayout),prediction:{predictionId:v(C(c.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:f,resolved:m.resolved,result:m.result}}}var le=e=>{async function p(t){try{return await t()}catch(o){throw new a(e.plainError(o))}}async function c(){let t=e.clientFor(k);if(await t.getChainId()!==k)throw new a("Meridian requires an RPC on chain 4663.");return t}async function m(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let n=await e.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!n.ok)throw new a(`Meridian returned HTTP ${n.status}. Please try again.`);let u;try{u=await n.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(u);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await m("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return X(s.positions,o,r,!0)}async function f(t,o){let r=[],s=new Set,n=new Set,u,d,h=0;for(let g=0;g<ce;g++){let w=await l(t,E,u);if(d!==void 0&&d!==w.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=w.totalCount;for(let x of w.nodes){let i=C(x),y=A(i.id);if(n.has(y))throw new a("Meridian repeated a position during pagination; retry from the first page.");n.add(y),N(i.balance)!=="0"&&h++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(w.nextCursor===null){if(h>d||n.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(w.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(w.nextCursor),u=w.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await c();return(await Promise.all(t.map(async n=>{let[u,d,h]=await Promise.all([r.readContract({address:n.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:n.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:n.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let g={address:n.tokenAddress,chainId:k,decimals:d,symbol:A(h)},w=D(u),x=n.pickConfig.resolved?{token:{...M},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[n.pickConfigId,n.tokenAddress,BigInt(w)]}))}:null;return{module:"meridian",id:n.id,chainId:k,assets:[{token:g,amount:w}],description:`Meridian ${n.side.toLowerCase()} position; ${n.pickConfig.resolved?n.pickConfig.result??"resolved":"unresolved"}.`,holder:n.holder,side:n.side,pickConfigId:n.pickConfigId,prediction:n.prediction,pickConfig:n.pickConfig,userCollateral:{token:{...M},amount:n.userCollateral},totalPayout:{token:{...M},amount:n.totalPayout},claimable:x}}))).filter(n=>BigInt(n.assets[0].amount)>0n)}async function q(t){return P(await f(t),t)}function _(t){return e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function L(t,o,r){let s=o.changes.map(n=>{let u=n.amount.startsWith("-"),d=e.formatAmount(u?n.amount.slice(1):n.amount,n.token.decimals);return`${u?"-":"+"}${d} ${n.token.symbol} (${n.token.address}, chain ${n.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=Z(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let n;if(t.search!==void 0&&(n=A(t.search).trim(),n.length>500))throw new a("Keep the Meridian market search to 500 characters.");let u=t.conditionId===void 0?void 0:v(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),h=await m("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...n===void 0?{}:{search:n},...u===void 0?{}:{conditionIds:[u]},...d===void 0?{}:{resolvers:[d]}}),g=X(h.conditions,o,r),w=g.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let y=v(i.conditionId),T=b(i.resolver);if(u!==void 0&&!I(y,u)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:y,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:k,collateral:{...M},totalCount:g.totalCount,markets:w,limit:o,nextCursor:g.nextCursor,complete:g.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let n=await c(),u=D(await n.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(u))throw new a("The redemption amount exceeds the wallet position balance.");let d=e.unsignedTx({to:S,chainId:k,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),h=[d],g;try{g=await e.preview(h,o)}catch(i){if(!/\breverted\b/i.test(e.plainError(i)))throw i;let y=await f(o,r);if(y.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=y[0];if(T.pickConfig.resolved){let re=D(await n.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}h=[_(T.prediction.predictionId),d],g=await e.preview(h,o)}let w=g.changes.filter(i=>ue(i.token,M)&&i.token.decimals===M.decimals).reduce((i,y)=>i+BigInt(y.amount),0n),x=g.changes.filter(i=>i.token.chainId===k&&I(i.token.address,r)).reduce((i,y)=>i+BigInt(y.amount),0n);if(w<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return L(h,g,h.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,n){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(u,d)=>p(async()=>{if(C(u),b(d),Object.keys(u).some(h=>!Object.hasOwn(o,h))||r.some(h=>u[h]===void 0))throw new a("Provide only the required Meridian tool inputs.");return n(u,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=Z(t.cursor),n=await l(o,r,s);return{positions:await P(n.nodes.map(u=>ee(u,o)),o),totalCount:n.totalCount,limit:r,nextCursor:n.nextCursor,complete:n.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=_(v(t.predictionId));await c();let s=[r];return L(s,await e.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>p(()=>q(t))}},we=le;export{le as a,we as b};
@@ -1 +1 @@
1
- import{a as k,b as P,d as R,e as x,f as U,g as $}from"./SGEZIYJW.js";import{a as w}from"./5ZLOCQA4.js";import{c as y,g as D}from"./5KUWLUPM.js";import{a as f}from"./FWD4L3CJ.js";import{a as p}from"./XSD5NL7J.js";import{encodeFunctionData as O,erc20Abi as L,getAddress as E,parseAbi as I,zeroAddress as h}from"viem";var _=E("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),g=E("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=I(["function getPair(address,address) view returns (address)"]),S=I(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),C=I(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,c,t,n){if(c===h||t===h||c===t)throw new p("Provide two different ERC-20 tokens; use WETH for native ETH.");let o=s.clientFor(f),i=await o.getBlockNumber(),a=await o.readContract({address:_,abi:F,functionName:"getPair",args:[c,t],blockNumber:i}),[e,v]=await Promise.all([x(s,c,i),x(s,t,i)]);if(a===h)return{pair:a,tokenA:e,tokenB:v,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,A,B]=await Promise.all([o.readContract({address:a,abi:S,functionName:"token0",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"getReserves",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"totalSupply",blockNumber:i}),o.readContract({address:a,abi:L,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,r]=D(M,c)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:v,reserveA:b,reserveB:r,supply:A,balance:B,blockNumber:i}}var H={tokenA:y,tokenB:y,amountADesired:w(),amountBDesired:w(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{type:"integer",minimum:0,maximum:9999},amountAMin:w(),amountBMin:w()};function J(s){let c=async(t,n,o)=>{$(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,o);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==h};let v=s.clientFor(f),M=R(n.slippageBps);if(!D(await v.readContract({address:g,abi:C,functionName:"factory"}),_))throw new p("Uniswap v2 router factory differs from its pinned deployment.");let l=(await v.getBlock()).timestamp+300n,A=[],B=(r,u,m)=>{let d=r===void 0?u*BigInt(1e4-M)/10000n:k(r,m,256,!0);if(d>u||u>0n&&d===0n)throw new p(`${m} must be positive and no more than the reserve-ratio estimate.`);return d},b;if(t==="add"){let r=k(n.amountADesired,"amountADesired"),u=k(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new p("Uniswap v2 pair reserves are inconsistent.");let m=r,d=u;if(e.reserveA>0n&&e.reserveB>0n){let T=r*e.reserveB/e.reserveA;T<=u?d=T:m=u*e.reserveA/e.reserveB}if(m===0n||d===0n)throw new p("Liquidity amounts round to zero at the pool reserve ratio.");let q=B(n.amountAMin,m,"amountAMin"),N=B(n.amountBMin,d,"amountBMin");A.push(s.approval(i,g,r.toString(),f),s.approval(a,g,u.toString(),f)),b=O({abi:C,functionName:"addLiquidity",args:[i,a,r,u,q,N,o,l]})}else{if(e.pair===h||e.supply===0n)throw new p("No Uniswap v2 liquidity exists for this pair.");let r=n.liquidity==="all"?e.balance:k(n.liquidity,"liquidity");if(r===0n||r>e.balance)throw new p("Removal exceeds the wallet LP token balance or is zero.");let[u,m]=await Promise.all([i,a].map(N=>v.readContract({address:N,abi:L,functionName:"balanceOf",args:[e.pair]}))),d=B(n.amountAMin,r*u/e.supply,"amountAMin"),q=B(n.amountBMin,r*m/e.supply,"amountBMin");A.push(s.approval(e.pair,g,r.toString(),f)),b=O({abi:C,functionName:"removeLiquidity",args:[i,a,r,d,q,o,l]})}return A.push(s.unsignedTx({to:g,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${o}; deadline ${l}.`})),U(s,A,o,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:y,tokenB:y}:H},execute:(n,o)=>c(t,n,o)}))}}export{_ as a,g as b,F as c,S as d,C as e,z as f,J as g};
1
+ import{a as k,b as P,d as R,e as x,f as U,g as $}from"./PIIHOXWF.js";import{a as w}from"./66F5ZH34.js";import{c as y,g as D}from"./NWNYJ26T.js";import{a as f}from"./FWD4L3CJ.js";import{a as p}from"./XSD5NL7J.js";import{encodeFunctionData as O,erc20Abi as L,getAddress as E,parseAbi as I,zeroAddress as h}from"viem";var _=E("0x8bceaa40b9acdfaedf85adf4ff01f5ad6517937f"),g=E("0x89e5db8b5aa49aa85ac63f691524311aeb649eba"),F=I(["function getPair(address,address) view returns (address)"]),S=I(["function token0() view returns (address)","function token1() view returns (address)","function getReserves() view returns (uint112,uint112,uint32)","function totalSupply() view returns (uint256)","function balanceOf(address) view returns (uint256)"]),C=I(["function factory() view returns (address)","function addLiquidity(address tokenA,address tokenB,uint256 amountADesired,uint256 amountBDesired,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256,uint256)","function removeLiquidity(address tokenA,address tokenB,uint256 liquidity,uint256 amountAMin,uint256 amountBMin,address to,uint256 deadline) returns (uint256,uint256)","function getAmountsOut(uint256 amountIn,address[] path) view returns (uint256[] amounts)","function getAmountsIn(uint256 amountOut,address[] path) view returns (uint256[] amounts)"]);async function z(s,c,t,n){if(c===h||t===h||c===t)throw new p("Provide two different ERC-20 tokens; use WETH for native ETH.");let o=s.clientFor(f),i=await o.getBlockNumber(),a=await o.readContract({address:_,abi:F,functionName:"getPair",args:[c,t],blockNumber:i}),[e,v]=await Promise.all([x(s,c,i),x(s,t,i)]);if(a===h)return{pair:a,tokenA:e,tokenB:v,reserveA:0n,reserveB:0n,supply:0n,balance:0n,blockNumber:i};let[M,l,A,B]=await Promise.all([o.readContract({address:a,abi:S,functionName:"token0",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"getReserves",blockNumber:i}),o.readContract({address:a,abi:S,functionName:"totalSupply",blockNumber:i}),o.readContract({address:a,abi:L,functionName:"balanceOf",args:[n],blockNumber:i})]),[b,r]=D(M,c)?l:[l[1],l[0]];return{pair:a,tokenA:e,tokenB:v,reserveA:b,reserveB:r,supply:A,balance:B,blockNumber:i}}var H={tokenA:y,tokenB:y,amountADesired:w(),amountBDesired:w(),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$"},slippageBps:{type:"integer",minimum:0,maximum:9999},amountAMin:w(),amountBMin:w()};function J(s){let c=async(t,n,o)=>{$(n,t==="pool"?["tokenA","tokenB"]:["tokenA","tokenB","slippageBps","amountAMin","amountBMin",...t==="add"?["amountADesired","amountBDesired"]:["liquidity"]]);let i=P(n.tokenA),a=P(n.tokenB),e=await z(s,i,a,o);if(t==="pool")return{pair:e.pair,tokenA:e.tokenA,tokenB:e.tokenB,reserveA:e.reserveA.toString(),reserveB:e.reserveB.toString(),totalSupply:e.supply.toString(),balance:e.balance.toString(),blockNumber:e.blockNumber.toString(),initialized:e.pair!==h};let v=s.clientFor(f),M=R(n.slippageBps);if(!D(await v.readContract({address:g,abi:C,functionName:"factory"}),_))throw new p("Uniswap v2 router factory differs from its pinned deployment.");let l=(await v.getBlock()).timestamp+300n,A=[],B=(r,u,m)=>{let d=r===void 0?u*BigInt(1e4-M)/10000n:k(r,m,256,!0);if(d>u||u>0n&&d===0n)throw new p(`${m} must be positive and no more than the reserve-ratio estimate.`);return d},b;if(t==="add"){let r=k(n.amountADesired,"amountADesired"),u=k(n.amountBDesired,"amountBDesired");if(e.reserveA===0n!=(e.reserveB===0n))throw new p("Uniswap v2 pair reserves are inconsistent.");let m=r,d=u;if(e.reserveA>0n&&e.reserveB>0n){let T=r*e.reserveB/e.reserveA;T<=u?d=T:m=u*e.reserveA/e.reserveB}if(m===0n||d===0n)throw new p("Liquidity amounts round to zero at the pool reserve ratio.");let q=B(n.amountAMin,m,"amountAMin"),N=B(n.amountBMin,d,"amountBMin");A.push(s.approval(i,g,r.toString(),f),s.approval(a,g,u.toString(),f)),b=O({abi:C,functionName:"addLiquidity",args:[i,a,r,u,q,N,o,l]})}else{if(e.pair===h||e.supply===0n)throw new p("No Uniswap v2 liquidity exists for this pair.");let r=n.liquidity==="all"?e.balance:k(n.liquidity,"liquidity");if(r===0n||r>e.balance)throw new p("Removal exceeds the wallet LP token balance or is zero.");let[u,m]=await Promise.all([i,a].map(N=>v.readContract({address:N,abi:L,functionName:"balanceOf",args:[e.pair]}))),d=B(n.amountAMin,r*u/e.supply,"amountAMin"),q=B(n.amountBMin,r*m/e.supply,"amountBMin");A.push(s.approval(e.pair,g,r.toString(),f)),b=O({abi:C,functionName:"removeLiquidity",args:[i,a,r,d,q,o,l]})}return A.push(s.unsignedTx({to:g,data:b,value:"0",chainId:f,description:`${t} Uniswap v2 liquidity for ${i}/${a}; recipient ${o}; deadline ${l}.`})),U(s,A,o,`${t==="add"?"Add":"Remove"} v2 liquidity. Review exact approvals, token minimums and wallet recipient. The first deposit sets the price; v2 locks MINIMUM_LIQUIDITY permanently.`)};return{tools:["pool","add","remove"].map(t=>({name:`uniswap_v2_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["tokenA","tokenB",...t==="add"?["amountADesired","amountBDesired"]:t==="remove"?["liquidity"]:[]],properties:t==="pool"?{tokenA:y,tokenB:y}:H},execute:(n,o)=>c(t,n,o)}))}}export{_ as a,g as b,F as c,S as d,C as e,z as f,J as g};
@@ -0,0 +1 @@
1
+ import{a as m,b as c}from"./77CLMPM7.js";import{a as p,b as A,c as _}from"./3VWVW7PX.js";import{decodeFunctionData as G,encodeFunctionData as C,getAddress as v,keccak256 as P,stringToHex as x}from"viem";var l=(o,t)=>typeof o=="string"&&typeof t=="string"&&o.toLowerCase()===t.toLowerCase();function e(o,t,d){if(!l(o,t))throw new Error(`Gloam ${d} changed. Nothing was sent.`)}function h(o,t){if(typeof o!="string"||!/^(0|[1-9][0-9]*)$/.test(o))throw new Error(`Gloam ${t} is invalid. Nothing was sent.`);return BigInt(o)}function E(o){if(Array.isArray(o))return`[${o.map(E).join(",")}]`;if(o&&typeof o=="object")return`{${Object.keys(o).sort().map(t=>`${JSON.stringify(t)}:${E(o[t])}`).join(",")}}`;if(typeof o!="string"&&typeof o!="number"&&typeof o!="boolean"&&o!==null)throw new Error("Gloam relay payload has an invalid field. Nothing was sent.");return JSON.stringify(o)}function j(o){return k(o),P(x(E(o)))}function S(o){if(e(o.poolAddress,m.pool,"pool"),o.fn!=="shieldBound"&&o.fn!=="transfer"&&o.fn!=="unshield")throw new Error("Gloam call selector is not allowed. Nothing was sent.");if(o.valueWei!==0n)throw new Error("Gloam USDG calls must send no native value. Nothing was sent.");let t=C({abi:p,functionName:o.fn,args:o.args});return{to:m.pool,data:t,value:"0",chainId:4663,description:`Gloam ${o.fn}`}}var N=o=>typeof o=="string"&&/^0x[0-9a-fA-F]{64}$/.test(o);function g(o,t){if(typeof o!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(o))throw new Error(`Gloam ${t} is invalid. Nothing was sent.`);return o}function f(o,t){if(!N(o))throw new Error(`Gloam ${t} is invalid. Nothing was sent.`);return o}function T(o){if(e(o.poolAddress,m.pool,"pool"),o.valueWei!==0n)throw new Error("Gloam relay call has native value. Nothing was sent.");if(o.fn==="transfer"){if(o.args.length!==4)throw new Error("Gloam transfer arguments are invalid. Nothing was sent.");let[t,d,r,s]=o.args;if(!Array.isArray(s)||s.length!==2)throw new Error("Gloam commitments are invalid. Nothing was sent.");let n=f(s[0],"first commitment"),a=f(s[1],"second commitment");if(l(n,a))throw new Error("Gloam output commitments must differ. Nothing was sent.");return{action:"transfer",chainId:4663,body:{proof:g(t,"proof"),root:f(d,"root"),nullifier:f(r,"nullifier"),commitments:[n,a]}}}if(o.fn==="unshield"){if(o.args.length!==6)throw new Error("Gloam cash-out arguments are invalid. Nothing was sent.");let[t,d,r,s,n,a]=o.args;if(e(s,m.usdg,"asset"),typeof n!="string")throw new Error("Gloam recipient is invalid. Nothing was sent.");let i=v(n);if(typeof a!="bigint"||a<=0n)throw new Error("Gloam amount is invalid. Nothing was sent.");return{action:"unshield",chainId:4663,body:{proof:g(t,"proof"),root:f(d,"root"),nullifier:f(r,"nullifier"),asset:m.usdg,to:i,amount:a.toString()}}}throw new Error("Gloam relay call selector is not allowed. Nothing was sent.")}function M(o,t){return{action:"memo",chainId:4663,body:{paymentCommitment:f(o,"payment commitment"),memo:g(t,"memo")}}}function k(o){if(!o||typeof o!="object"||Array.isArray(o)||o.chainId!==4663||!["transfer","unshield","memo"].includes(o.action))throw new Error("Gloam relay payload is invalid. Nothing was sent.");if(Object.keys(o).sort().join(",")!=="action,body,chainId"||!o.body||typeof o.body!="object"||Array.isArray(o.body))throw new Error("Gloam relay payload has an unexpected field. Nothing was sent.");let t=o.body,d=Object.keys(t).sort().join(","),r=o.action==="transfer"?"commitments,nullifier,proof,root":o.action==="unshield"?"amount,asset,nullifier,proof,root,to":"memo,paymentCommitment";if(d!==r)throw new Error("Gloam relay payload has an unexpected field. Nothing was sent.");if(o.action==="memo")f(t.paymentCommitment,"payment commitment"),g(t.memo,"memo");else if(g(t.proof,"proof"),f(t.root,"root"),f(t.nullifier,"nullifier"),o.action==="transfer"){if(!Array.isArray(t.commitments)||t.commitments.length!==2)throw new Error("Gloam commitments are invalid. Nothing was sent.");if(f(t.commitments[0],"first commitment"),f(t.commitments[1],"second commitment"),l(t.commitments[0],t.commitments[1]))throw new Error("Gloam output commitments must differ. Nothing was sent.")}else{if(e(t.asset,m.usdg,"asset"),typeof t.to!="string")throw new Error("Gloam recipient is invalid. Nothing was sent.");if(v(t.to),h(t.amount,"amount")<=0n)throw new Error("Gloam amount is invalid. Nothing was sent.")}if(new TextEncoder().encode(E(o)).length>16*1024)throw new Error("Gloam relay payload is too large. Nothing was sent.")}function R(o){if(!o||!o.facts||typeof o.facts!="object"||Array.isArray(o.facts)||typeof o.risk!="string")throw new Error("Gloam public plan is invalid. Nothing was sent.");let t=new Set(["tool","payload","payloadHash","txs","facts","risk"]),d=new Set(["to","data","value","chainId","description","gasLimit"]);if(Object.keys(o).some(n=>!t.has(n))||o.txs!==void 0&&(!Array.isArray(o.txs)||o.txs.some(n=>!n||typeof n!="object"||Object.keys(n).some(a=>!d.has(a)))))throw new Error("Gloam public plan has an unexpected field. Nothing was sent.");let r=/(?:secret|private[_-]?key|receive[_-]?key|note[_-]?package|raw[_-]?note|mnemonic)/i,s=/(?:gloam1\.|oakgloam1\.)/i;if(Object.keys(o.facts).some(n=>r.test(n))||Object.values(o.facts).some(n=>typeof n!="string"||s.test(n))||s.test(o.risk)||(o.txs??[]).some(n=>s.test(n.description)))throw new Error("Gloam plan contains private material. Nothing was sent.");o.payload&&k(o.payload)}function $(o,t,d,r){if(o.chainId!==4663||o.value!=="0"||!/^0x[0-9a-fA-F]+$/.test(o.data))throw new Error("Gloam calldata is invalid. Nothing was sent.");let s=o.data.slice(0,10).toLowerCase();if(s===c.approve.toLowerCase()){if(r.tool!=="gloam_shield")throw new Error("Gloam approval does not match the requested call. Nothing was sent.");e(o.to,m.usdg,"approval token");let a=G({abi:_,data:o.data});if(e(a.args[0],m.pool,"approval spender"),a.args[1]!==h(r.amount,"approval amount"))throw new Error("Gloam approval amount changed. Nothing was sent.");return}if(s===c.postMemo.toLowerCase()){if(r.tool!=="gloam_pay")throw new Error("Gloam memo does not match the requested call. Nothing was sent.");e(o.to,m.memoBoard,"memo board");let a=G({abi:A,data:o.data});e(a.args[0],t.out0,"payment commitment");return}if(e(o.to,m.pool,"pool"),s!==c.shieldBound.toLowerCase()&&s!==c.transfer.toLowerCase()&&s!==c.unshield.toLowerCase())throw new Error("Gloam calldata selector is not allowed. Nothing was sent.");let n=G({abi:p,data:o.data});if(n.functionName==="shieldBound"){if(r.tool!=="gloam_shield")throw new Error("Gloam call does not match the request. Nothing was sent.");if(e(n.args[0],m.usdg,"asset"),n.args[1]!==h(r.amount,"amount"))throw new Error("Gloam amount changed. Nothing was sent.")}else if(n.functionName==="transfer"){if(r.tool!=="gloam_pay"&&r.tool!=="gloam_claim")throw new Error("Gloam call does not match the request. Nothing was sent.");if(e(n.args[1],t.root,"root"),e(n.args[2],r.storedNullifier,"nullifier"),e(n.args[3][0],t.out0,"first commitment"),e(n.args[3][1],t.out1,"second commitment"),l(n.args[3][0],n.args[3][1]))throw new Error("Gloam output commitments must differ. Nothing was sent.")}else{if(r.tool!=="gloam_cash_out")throw new Error("Gloam call does not match the request. Nothing was sent.");if(e(n.args[1],t.root,"root"),e(n.args[2],r.storedNullifier,"nullifier"),e(n.args[3],m.usdg,"asset"),e(n.args[4],d,"cash-out recipient"),n.args[5]!==h(r.amount,"amount"))throw new Error("Gloam amount changed. Nothing was sent.")}}function F(o,t,d){if(R(o),o.tool!==t.tool)throw new Error("Gloam plan does not match the request. Nothing was sent.");let r=t.tool==="gloam_shield"?"shieldBound":t.tool==="gloam_cash_out"?"unshield":t.tool==="gloam_pay"||t.tool==="gloam_claim"?"transfer":void 0,s=r?c[r].toLowerCase():void 0,n=o.txs?.find(i=>i.data.slice(0,10).toLowerCase()===s);if(t.amount!==void 0&&h(t.amount,"amount")<=0n)throw new Error("Gloam amount must be positive. Nothing was sent.");if(t.tool==="gloam_shield"){if(o.payload)throw new Error("Gloam deposit must use the wallet call. Nothing was sent.");let i=(o.txs??[]).map(w=>w.data.slice(0,10).toLowerCase());if(i.filter(w=>w===c.shieldBound.toLowerCase()).length!==1)throw new Error("Gloam shieldBound requires one deposit call. Nothing was sent.");if(i.filter(w=>w===c.approve.toLowerCase()).length>1)throw new Error("Gloam deposit has multiple approvals. Nothing was sent.");if(i.indexOf(c.approve.toLowerCase())>i.indexOf(c.shieldBound.toLowerCase()))throw new Error("Gloam approval must precede the deposit. Nothing was sent.")}let a=o.facts;if(t.tool!=="gloam_status"){if(e(a.pool,m.pool,"pool"),e(a.asset,m.usdg,"asset"),t.asset&&e(a.asset,t.asset,"asset"),t.amount!==void 0&&h(a.amount,"amount")!==h(t.amount,"amount"))throw new Error("Gloam amount changed. Nothing was sent.");if(t.tool!=="gloam_shield"){if(t.rootKnown!==!0||!N(a.root))throw new Error("Gloam root is unknown. Nothing was sent.");e(a.nullifier,t.storedNullifier,"nullifier")}if(t.tool==="gloam_cash_out"&&e(a.recipient,d,"cash-out recipient"),(t.tool==="gloam_pay"||t.tool==="gloam_claim")&&(!N(a.out0)||!N(a.out1)||l(a.out0,a.out1)))throw new Error("Gloam output commitments must differ. Nothing was sent.")}for(let i of o.txs??[])$(i,a,d,t);if(r&&!n&&o.payload?.action!==(r==="shieldBound"?void 0:r))throw new Error(`Gloam ${r} call or relay payload is missing. Nothing was sent.`);if(o.payload){if(!o.payloadHash||!l(o.payloadHash,j(o.payload)))throw new Error("Gloam relay payload hash changed. Nothing was sent.");if(t.tool==="gloam_pay"||t.tool==="gloam_claim"){if(o.payload.action!=="transfer")throw new Error("Gloam relay action changed. Nothing was sent.");e(o.payload.body.root,a.root,"root"),e(o.payload.body.nullifier,t.storedNullifier,"nullifier");let i=o.payload.body.commitments;if(!Array.isArray(i)||i.length!==2||!l(i[0],a.out0)||!l(i[1],a.out1))throw new Error("Gloam relay commitments changed. Nothing was sent.")}else if(t.tool==="gloam_cash_out"){if(o.payload.action!=="unshield")throw new Error("Gloam relay action changed. Nothing was sent.");if(e(o.payload.body.root,a.root,"root"),e(o.payload.body.nullifier,t.storedNullifier,"nullifier"),e(o.payload.body.asset,m.usdg,"asset"),e(o.payload.body.to,d,"cash-out recipient"),h(o.payload.body.amount,"amount")!==h(t.amount,"amount"))throw new Error("Gloam amount changed. Nothing was sent.")}if(n&&(t.tool==="gloam_pay"||t.tool==="gloam_claim"||t.tool==="gloam_cash_out")){let i=G({abi:p,data:n.data});if(i.functionName==="transfer"){let[u,w,b,y]=i.args;if(!l(o.payload.body.proof,u)||!l(o.payload.body.root,w)||!l(o.payload.body.nullifier,b)||!Array.isArray(o.payload.body.commitments)||!l(o.payload.body.commitments[0],y[0])||!l(o.payload.body.commitments[1],y[1]))throw new Error("Gloam relay proof or calldata changed. Nothing was sent.")}else if(i.functionName==="unshield"){let[u,w,b,y,L,O]=i.args;if(!l(o.payload.body.proof,u)||!l(o.payload.body.root,w)||!l(o.payload.body.nullifier,b)||!l(o.payload.body.asset,y)||!l(o.payload.body.to,L)||h(o.payload.body.amount,"amount")!==O)throw new Error("Gloam relay proof or calldata changed. Nothing was sent.")}}}}export{j as a,S as b,T as c,M as d,k as e,R as f,F as g};
@@ -0,0 +1 @@
1
+ import{a}from"./PK66GCDT.js";import{e as d}from"./NWNYJ26T.js";import{isAddress as p}from"viem";var u={version:"oak-wormhole-check/v1",oakRoute:"/v1/wormhole/check",upstreamPaths:{check:"/api/v1/check"}},h=5e3,m=5e3,i=(e="unavailable")=>({verdict:"unknown",reason:e}),l=e=>typeof e=="number"&&Number.isSafeInteger(e)&&e>0;function k(e){return d(e)?e.kind==="text"?Object.keys(e).length===2&&typeof e.text=="string"&&!!e.text.trim()&&e.text.length<=a&&Buffer.byteLength(e.text,"utf8")<=a&&!/(?:\b(?:private[ _-]?key|secret[ _-]?key|mnemonic|seed[ _-]?phrase|recovery[ _-]?phrase)\s*[:=]|\b0x[0-9a-f]{64}\b)/i.test(e.text):e.kind==="token"&&Object.keys(e).length===3&&e.chainId===4663&&typeof e.token=="string"&&p(e.token,{strict:!0})&&e.token.toLowerCase()!=="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee":!1}function y(e){try{let r=new URL(e??"");return r.protocol!=="https:"||r.username||r.password||r.search||r.hash||r.pathname!=="/"?void 0:r.origin}catch{return}}function g(e,r){return d(e)&&e.ok===!0&&(e=e.data),!d(e)||!["clear","flagged","unknown"].includes(String(e.verdict))?i():e.verdict==="unknown"?i(["off","unconfigured","invalid_request","unavailable","rate_limited","price_cap"].includes(String(e.reason))?e.reason:"unavailable"):typeof e.chargedMicrousd!="number"||!Number.isSafeInteger(e.chargedMicrousd)||e.chargedMicrousd<0||e.chargedMicrousd>r||typeof e.evidenceBlockId!="string"||!/^[A-Za-z0-9_-]{1,128}$/.test(e.evidenceBlockId)?i():{verdict:e.verdict,chargedMicrousd:e.chargedMicrousd,evidenceBlockId:e.evidenceBlockId}}async function b(e){let r=new AbortController,t,n=new Promise((c,o)=>{t=setTimeout(()=>{r.abort(),o(new Error("timeout"))},h)});try{return await Promise.race([n,e(r.signal)])}finally{clearTimeout(t),r.abort()}}async function w(e,r){let t=e.body?.getReader();if(!t)throw new Error("empty_response");let n=()=>{t.cancel().catch(()=>{})};r.addEventListener("abort",n,{once:!0});let c=0,o=[];try{for(;;){if(r.aborted)throw new Error("timeout");let{value:s,done:f}=await t.read();if(f)break;if(c+=s.byteLength,c>65536)throw new Error("response_limit");o.push(s)}if(r.aborted)throw new Error("timeout");return JSON.parse(Buffer.concat(o).toString("utf8"))}finally{r.removeEventListener("abort",n),n(),t.releaseLock()}}async function M(e,r={},t=fetch){if(r.payerMode===void 0||r.payerMode==="off")return i("off");let n=y(r.endpointBaseUrl),c=r.priceCapMicrousd??m;if(r.payerMode!=="server-key"||!n||!l(c))return i("unconfigured");if(!k(e))return i("invalid_request");try{return await b(async o=>{let s=await t(`${n}${u.oakRoute}`,{method:"POST",redirect:"error",credentials:"omit",signal:o,headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify({request:e,priceCapMicrousd:c})});return o.aborted||s.redirected||!s.ok?(s.body?.cancel().catch(()=>{}),i()):g(await w(s,o),c)})}catch{return i()}}export{u as a,h as b,m as c,i as d,l as e,k as f,y as g,g as h,b as i,w as j,M as k};
@@ -1 +1 @@
1
- import{b as k,c as P,d as R}from"./65EQECL3.js";import{a as Z}from"./HTXKERNS.js";import{a as H}from"./PBQSJSZO.js";import{g as G,i as Q}from"./5KUWLUPM.js";import{a as W,b as V}from"./UP7FBDMJ.js";import{a as c,d as X,i as O}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{a as T}from"./JXOEJPJ4.js";import{encodeFunctionData as nt,erc20Abi as J,getAddress as a,parseAbi as gt}from"viem";var At="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),wt=a(O[4663].hookr.HookrRoot.address),Ot=a(O[4663].hookr.HookrRouter.address),Bt=a(O[4663].hookr.HookrForwarder.address),ht=a(O[4663].hookr.PoolManager.address),It=a(O[4663].hookr.HOOKR_Token.address),N="0x0000000000000000000000000000000000000000",St="0x000000000000000000000000000000000000dEaD",Y=(1n<<128n)-1n,Tt=new Set([N.toLowerCase(),St.toLowerCase(),y.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),ht.toLowerCase(),wt.toLowerCase()]),B=gt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Ht(t){let n=t.toLowerCase();return n===N.toLowerCase()||n===Z.toLowerCase()}function $t(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Wt(t,n,i){return V(t,n,i)}function et(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${$t(n,i.amount,i.token.decimals)} ${T(i.token.symbol)} (${i.token.address})`).join(", ")}function xt(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function ot(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function Rt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Ct(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Dt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Pt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function tt(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Ht(n))return{...k,chainId:i};H(n);let o=a(n),s=o.toLowerCase();if(s===P.address.toLowerCase())return{address:o,symbol:P.symbol,decimals:X,chainId:i};if(s===R.address.toLowerCase())return{address:o,symbol:R.symbol,decimals:R.decimals,chainId:i};if(s===It.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:J,functionName:"symbol"}),t.readContract({address:o,abi:J,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Et(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function E(t,n=[]){let i=Q(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(Tt.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function rt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function L(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return W(t)}}function Lt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=xt(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Et(d)]),e=Ct(g),l=Number(e.status),h=Rt(l);if(l===0||G(e.owner,N))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Y)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Y)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let C=a(e.key.hooks);E(e.recipient,[C]);let it=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Pt(it),D=L(n.minBounty,"minBounty"),F=D!==void 0&&D>w.minBounty?D:w.minBounty;if(e.bounty<F)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${F} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Dt(m),ut=e.zeroForOne?e.key.currency0:e.key.currency1,st=e.zeroForOne?e.key.currency1:e.key.currency0,[x,p]=await Promise.all([tt(d,ut,s),tt(d,st,s)]),S=L(n.minAmountOut,"minAmountOut"),v=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<v)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${v} base units).`);let at=nt({abi:B,functionName:"fill",args:[r]}),mt=t.formatAmount(e.amountIn.toString(),x.decimals),dt=t.formatAmount(I.amountOut.toString(),p.decimals),ct=t.formatAmount(e.minAmountOut.toString(),p.decimals),lt=t.formatAmount(e.bounty.toString(),18),yt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,q=`Fill Hookr order #${r}: maker's escrow pays ${mt} ${T(x.symbol)} (${e.amountIn} base units of ${x.address}); net output goes to ${a(e.recipient)} (quoted ${dt} ${T(p.symbol)}, order minimum ${ct} ${T(p.symbol)}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${lt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${yt}`,M=t.unsignedTx({to:y,data:at,value:"0",chainId:s,description:q}),z=await t.preview([M],o),bt=et(z,t.formatAmount),K={token:x,amount:e.amountIn.toString()},U={token:p,amount:e.minAmountOut.toString()},ft={token:p,amount:I.amountOut.toString()},j={token:{...k,chainId:s},amount:e.bounty.toString()},pt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:K,minAmountOut:U,bounty:j,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},kt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[M],summary:`${q} Preview deltas: ${bt}.`,preview:z,orderId:r.toString(),fillable:!0,amountIn:K,minAmountOut:U,quotedAmountOut:ft,bounty:j,bountyBounds:kt,order:pt}}catch(o){throw new u(t.plainError(o))}}}}function Nt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=n.to!==void 0&&n.to!==null?E(String(n.to)):E(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=L(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=nt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=et(A,t.formatAmount),$={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new u(t.plainError(o))}}}}async function _t(t,n){H(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:At,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var _=t=>({tools:[Lt(t),Nt(t)],positions:n=>_t(t,n)}),Vt=_,Gt=_,Qt=_;export{At as a,y as b,wt as c,Ot as d,Bt as e,ht as f,It as g,B as h,$t as i,Wt as j,Lt as k,Nt as l,_t as m,_ as n,Vt as o,Gt as p,Qt as q};
1
+ import{b as k,c as P,d as R}from"./AEL62KCG.js";import{a as Z}from"./QHBS3PVU.js";import{a as H}from"./43LI5NKJ.js";import{g as G,i as Q}from"./NWNYJ26T.js";import{b as W,c as V}from"./IX3GZMTM.js";import{a as c,d as X,i as O}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{a as T}from"./JXOEJPJ4.js";import{encodeFunctionData as nt,erc20Abi as J,getAddress as a,parseAbi as gt}from"viem";var At="hookr",y=a(O[4663].hookr.HookrLimitOrders.address),wt=a(O[4663].hookr.HookrRoot.address),Ot=a(O[4663].hookr.HookrRouter.address),Bt=a(O[4663].hookr.HookrForwarder.address),ht=a(O[4663].hookr.PoolManager.address),It=a(O[4663].hookr.HOOKR_Token.address),N="0x0000000000000000000000000000000000000000",St="0x000000000000000000000000000000000000dEaD",Y=(1n<<128n)-1n,Tt=new Set([N.toLowerCase(),St.toLowerCase(),y.toLowerCase(),Ot.toLowerCase(),Bt.toLowerCase(),ht.toLowerCase(),wt.toLowerCase()]),B=gt(["function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function fill(uint256 orderId) returns (uint256 amountOut)","function claimBounty(address to) returns (uint256 amount)","function bountyOf(address keeper) view returns (uint256)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)"]);function Ht(t){let n=t.toLowerCase();return n===N.toLowerCase()||n===Z.toLowerCase()}function $t(t,n,i){let o=n.trim();if(o.startsWith("-")){let s=o.slice(1),r=t(s,i);return r==="0"?"0":`-${r}`}return t(o,i)}function Wt(t,n,i){return V(t,n,i)}function et(t,n){return!t.changes||t.changes.length===0?"no net ERC-20/native transfer delta on caller":t.changes.map(i=>`${$t(n,i.amount,i.token.decimals)} ${T(i.token.symbol)} (${i.token.address})`).join(", ")}function xt(t){if(typeof t=="bigint"){if(t<=0n)throw new u("Hookr orderId must be a positive integer.");return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<=0)throw new u("Hookr orderId must be a positive integer.");return BigInt(t)}if(typeof t=="string"&&/^\d+$/.test(t.trim())){let n=BigInt(t.trim());if(n<=0n)throw new u("Hookr orderId must be a positive integer.");return n}throw new u("Provide a positive integer Hookr orderId.")}function ot(t){if(t==null)return c;if(typeof t!="number"||!Number.isSafeInteger(t)||t!==c)throw new u(`Hookr limit orders are only supported on chain ${c}.`);return c}function Rt(t){switch(t){case 0:return"None";case 1:return"Open";case 2:return"Filled";case 3:return"Cancelled";default:return"Unknown"}}function Ct(t){if(Array.isArray(t)){let[n,i,o,s,r,d,g,m,b,e,l]=t;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:i,createdAt:o,expiry:s,zeroForOne:!!r,status:d,recipient:g,amountIn:BigInt(m),minAmountOut:BigInt(b),bounty:BigInt(e),sqrtPriceLimitX96:BigInt(l)}}if(t&&typeof t=="object"){let n=t;if(n.key&&typeof n.key=="object")return{key:{currency0:n.key.currency0,currency1:n.key.currency1,fee:Number(n.key.fee),tickSpacing:Number(n.key.tickSpacing),hooks:n.key.hooks},owner:n.owner,createdAt:n.createdAt,expiry:n.expiry,zeroForOne:!!n.zeroForOne,status:n.status,recipient:n.recipient,amountIn:BigInt(n.amountIn),minAmountOut:BigInt(n.minAmountOut),bounty:BigInt(n.bounty),sqrtPriceLimitX96:BigInt(n.sqrtPriceLimitX96)}}throw new u("HookrLimitOrders returned a malformed order tuple.")}function Dt(t){if(Array.isArray(t)&&t.length>=2)return{fillable:!!t[0],amountOut:BigInt(t[1])};if(t&&typeof t=="object"&&"fillable"in t&&"amountOut"in t){let n=t;return{fillable:!!n.fillable,amountOut:BigInt(n.amountOut)}}throw new u("HookrLimitOrders returned a malformed quoteFill response.")}function Pt(t){if(Array.isArray(t)&&t.length>=3)return{minBounty:BigInt(t[0]),defaultBounty:BigInt(t[1]),maxBounty:BigInt(t[2])};if(t&&typeof t=="object"&&"minBounty"in t&&"defaultBounty"in t&&"maxBounty"in t){let n=t;return{minBounty:BigInt(n.minBounty),defaultBounty:BigInt(n.defaultBounty),maxBounty:BigInt(n.maxBounty)}}throw new u("HookrLimitOrders returned a malformed bountyBounds response.")}async function tt(t,n,i=c){if(i!==c)throw new u(`Unsupported token chain ${i}; Hookr requires chain ${c}.`);if(Ht(n))return{...k,chainId:i};H(n);let o=a(n),s=o.toLowerCase();if(s===P.address.toLowerCase())return{address:o,symbol:P.symbol,decimals:X,chainId:i};if(s===R.address.toLowerCase())return{address:o,symbol:R.symbol,decimals:R.decimals,chainId:i};if(s===It.toLowerCase())return{address:o,symbol:"HOOKR",decimals:18,chainId:i};let[r,d]=await Promise.all([t.readContract({address:o,abi:J,functionName:"symbol"}),t.readContract({address:o,abi:J,functionName:"decimals"})]),g=typeof r=="string"&&r.trim()?r.trim():o,m=Number(d);if(!Number.isInteger(m)||m<0||m>255)throw new u(`Invalid token decimals for ${o} on chain ${i}.`);return{address:o,symbol:g,decimals:m,chainId:i}}async function Et(t){if(typeof t.getBlock!="function")throw new u("Cannot read the latest block timestamp for Hookr order expiry.");let n=await t.getBlock().catch(()=>{throw new u("Cannot read the latest block timestamp for Hookr order expiry.")});if(!n||typeof n.timestamp!="bigint"||n.timestamp<=0n)throw new u("Hookr requires a usable latest block timestamp to check order expiry.");return n.timestamp}function E(t,n=[]){let i=Q(t,"Provide a valid recipient wallet address."),o=i.toLowerCase();if(Tt.has(o)||n.some(s=>s.toLowerCase()===o))throw new u(`Recipient ${i} is a reserved protocol or zero address (invalid recipient).`);return i}function rt(t){if(t.minBountyEth!==void 0||t.minAmountOutDecimal!==void 0||t.rounding!==void 0)throw new u("Use minBounty and minAmountOut as base-unit integer strings.")}function L(t,n){if(t!==void 0){if(typeof t!="string"||!/^\d+$/.test(t))throw new u(`Provide ${n} as a base-unit integer string.`);return W(t)}}function Lt(t){return{name:"hookr_fill",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"HookrLimitOrders orderId as a positive integer string."},minBounty:{type:"string",description:"Optional minimum keeper bounty in wei (decimal base-unit string)."},minAmountOut:{type:"string",description:"Optional quote pre-check only, in token base-unit integer strings. Not enforced on chain: fill(uint256) enforces only the order minAmountOut."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},required:["orderId"],additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=xt(n.orderId),d=t.clientFor(s),[g,m,b]=await Promise.all([d.readContract({address:y,abi:B,functionName:"getOrder",args:[r]}),d.readContract({address:y,abi:B,functionName:"quoteFill",args:[r]}),Et(d)]),e=Ct(g),l=Number(e.status),h=Rt(l);if(l===0||G(e.owner,N))throw new u(`Hookr order #${r} does not exist.`);if(l!==1)throw new u(`Hookr order #${r} is not open (current status: ${h}).`);let A=BigInt(e.expiry);if(A<b)throw new u(`Hookr order #${r} is expired (expiry ${A} < current timestamp ${b}).`);let f=Number(e.key.tickSpacing),$=Number(e.key.fee);if(!Number.isInteger(f)||f<=0)throw new u(`Hookr order #${r} has an invalid pool tickSpacing (${f}).`);if(e.amountIn<=0n||e.amountIn>Y)throw new u(`Hookr order #${r} has an invalid amountIn (${e.amountIn}).`);if(e.minAmountOut<=0n||e.minAmountOut>Y)throw new u(`Hookr order #${r} has an invalid minAmountOut (${e.minAmountOut}).`);let C=a(e.key.hooks);E(e.recipient,[C]);let it=await d.readContract({address:y,abi:B,functionName:"bountyBounds",args:[{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},e.zeroForOne,e.amountIn,e.minAmountOut]}),w=Pt(it),D=L(n.minBounty,"minBounty"),F=D!==void 0&&D>w.minBounty?D:w.minBounty;if(e.bounty<F)throw new u(`Hookr order #${r} is underbounty: order bounty (${e.bounty} wei) is below the required keeper bounty (${F} wei).`);if(e.bounty>w.maxBounty)throw new u(`Hookr order #${r} bounty (${e.bounty} wei) exceeds maximum bounty bound (${w.maxBounty} wei).`);let I=Dt(m),ut=e.zeroForOne?e.key.currency0:e.key.currency1,st=e.zeroForOne?e.key.currency1:e.key.currency0,[x,p]=await Promise.all([tt(d,ut,s),tt(d,st,s)]),S=L(n.minAmountOut,"minAmountOut"),v=S!==void 0&&S>e.minAmountOut?S:e.minAmountOut;if(!I.fillable||I.amountOut<=0n||I.amountOut<v)throw new u(`Hookr order #${r} is not executable: quoted output (${I.amountOut} base units of ${p.address}) does not meet minimum output (${v} base units).`);let at=nt({abi:B,functionName:"fill",args:[r]}),mt=t.formatAmount(e.amountIn.toString(),x.decimals),dt=t.formatAmount(I.amountOut.toString(),p.decimals),ct=t.formatAmount(e.minAmountOut.toString(),p.decimals),lt=t.formatAmount(e.bounty.toString(),18),yt=S===void 0?"":` Caller minAmountOut ${S} base units is a quote pre-check only, not enforced on chain; fill(uint256) enforces the order minimum of ${e.minAmountOut} base units.`,q=`Fill Hookr order #${r}: maker's escrow pays ${mt} ${T(x.symbol)} (${e.amountIn} base units of ${x.address}); net output goes to ${a(e.recipient)} (quoted ${dt} ${T(p.symbol)}, order minimum ${ct} ${T(p.symbol)}, ${e.minAmountOut} base units of ${p.address}). The filler sends no tokens or ETH (value 0), pays gas, and accrues ${lt} ETH (${e.bounty} wei) bounty to ${o}, payable only via claimBounty. Pool tickSpacing ${f}; expiry ${A} inclusive.${yt}`,M=t.unsignedTx({to:y,data:at,value:"0",chainId:s,description:q}),z=await t.preview([M],o),bt=et(z,t.formatAmount),K={token:x,amount:e.amountIn.toString()},U={token:p,amount:e.minAmountOut.toString()},ft={token:p,amount:I.amountOut.toString()},j={token:{...k,chainId:s},amount:e.bounty.toString()},pt={orderId:r.toString(),key:{currency0:a(e.key.currency0),currency1:a(e.key.currency1),fee:$,tickSpacing:f,hooks:C},owner:a(e.owner),recipient:a(e.recipient),createdAt:BigInt(e.createdAt).toString(),expiry:A.toString(),zeroForOne:e.zeroForOne,status:l,statusLabel:h,amountIn:K,minAmountOut:U,bounty:j,sqrtPriceLimitX96:e.sqrtPriceLimitX96.toString()},kt={minBounty:{token:{...k,chainId:s},amount:w.minBounty.toString()},defaultBounty:{token:{...k,chainId:s},amount:w.defaultBounty.toString()},maxBounty:{token:{...k,chainId:s},amount:w.maxBounty.toString()}};return{txs:[M],summary:`${q} Preview deltas: ${bt}.`,preview:z,orderId:r.toString(),fillable:!0,amountIn:K,minAmountOut:U,quotedAmountOut:ft,bounty:j,bountyBounds:kt,order:pt}}catch(o){throw new u(t.plainError(o))}}}}function Nt(t){return{name:"hookr_claim_bounty",inputSchema:{type:"object",properties:{to:{type:"string",description:"Optional recipient address for the claimed native ETH bounty (must be the signing wallet)."},minBounty:{type:"string",description:"Optional minimum claimable bounty in wei (decimal base-unit string)."},chainId:{type:"number",description:"Target chain ID (must be 4663)."}},additionalProperties:!1},async execute(n,i){try{rt(n),H(i);let o=a(i),s=ot(n.chainId),r=n.to!==void 0&&n.to!==null?E(String(n.to)):E(o);if(r!==o)throw new u("Hookr bounty recipient must be the signing wallet.");let g=await t.clientFor(s).readContract({address:y,abi:B,functionName:"bountyOf",args:[o]}),m=BigInt(g);if(m<=0n)throw new u(`No claimable Hookr keeper bounty for ${o}.`);let b=L(n.minBounty,"minBounty");if(b!==void 0&&m<b)throw new u(`Claimable Hookr bounty (${m} wei) is below the requested minimum (${b} wei).`);let e=nt({abi:B,functionName:"claimBounty",args:[r]}),l=t.formatAmount(m.toString(),18),h=t.unsignedTx({to:y,data:e,value:"0",chainId:s,description:`Claim ${l} ETH (${m} wei) of accrued Hookr keeper bounty from ${y} to ${r}.`}),A=await t.preview([h],o),f=et(A,t.formatAmount),$={token:{...k,chainId:s},amount:m.toString()};return{txs:[h],summary:`Claim ${l} ETH (${m} wei) Hookr keeper bounty to ${r}. Preview deltas: ${f}.`,preview:A,recipient:r,claimableBounty:$}}catch(o){throw new u(t.plainError(o))}}}}async function _t(t,n){H(n);let i=a(n),o=t.clientFor(c);try{let s=await o.readContract({address:y,abi:B,functionName:"bountyOf",args:[i]}),r=BigInt(s);if(r<=0n)return[];let d=t.formatAmount(r.toString(),18);return[{module:At,id:`hookr:bounty:${i.toLowerCase()}`,chainId:c,assets:[{token:{...k,chainId:c},amount:r.toString()}],description:`Hookr claimable keeper bounty (${d} ETH)`}]}catch(s){throw new u(t.plainError(s))}}var _=t=>({tools:[Lt(t),Nt(t)],positions:n=>_t(t,n)}),Vt=_,Gt=_,Qt=_;export{At as a,y as b,wt as c,Ot as d,Bt as e,ht as f,It as g,B as h,$t as i,Wt as j,Lt as k,Nt as l,_t as m,_ as n,Vt as o,Gt as p,Qt as q};
@@ -1 +1 @@
1
- import{d as B,e as te,f as W,h as se,i as T}from"./JG27HM4P.js";import{E as A,a as J,b as Q,c as C,f as _,h as v,m as b,q as U,s as ee,u as oe}from"./WPAF55SP.js";import{f as K,g as Z}from"./HVM2EEXB.js";import{a as F}from"./HTXKERNS.js";import{a as Y}from"./PBQSJSZO.js";import{g as E}from"./5KUWLUPM.js";import{a as y}from"./FWD4L3CJ.js";import{a as w,b as M,e as j}from"./XSD5NL7J.js";import{decodeAbiParameters as fe,getAddress as I,pad as ne,parseAbi as de,parseAbiParameters as me,toEventSelector as he,toHex as ie,zeroAddress as ce}from"viem";var ge=he("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),ke=me("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),we=10000000n,ye=10000n,le=25,z=200,R=16,Pe=3e3,be=500,Ae=500n,q=100,O=de(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ie=de(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function ve(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===ce||e===F.toLowerCase()}function re(o,e){if(o!=null){if(typeof o!="string")throw new w(`${e} must be a token address, or "eth" for native ETH.`);return ve(o)?{eth:!0}:(Y(o),{eth:!1,address:I(o)})}}var ue=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function $(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function pe(o,e,a,r,c){let[t,s,p]=await Promise.all([o.readContract({address:e,abi:T,functionName:"slot0"}),o.readContract({address:e,abi:T,functionName:"liquidity"}),o.readContract({address:e,abi:T,functionName:"tickSpacing"})]),n=BigInt(t[0]);return{version:"v3",id:e,token0:$(a),token1:$(r),fee:c,tickSpacing:Number(p),initialized:n>0n,liquidity:BigInt(s).toString(),sqrtPriceX96:n.toString(),tick:Number(t[1]),price:n>0n?K(n,a.decimals,r.decimals):"0",addSupported:!0}}async function x(o,e,a){let r=a??ee(e),[c,t]=await Promise.all([A(o,e.currency0,y),A(o,e.currency1,y)]),[s,p]=await Promise.all([o.readContract({address:C,abi:O,functionName:"getSlot0",args:[r]}),o.readContract({address:C,abi:O,functionName:"getLiquidity",args:[r]})]),n=BigInt(s[0]),k=oe(e,Number(s[3]));return{version:"v4",id:r,token0:$(c),token1:$(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:I(e.hooks),initialized:n>0n,liquidity:BigInt(p).toString(),sqrtPriceX96:n.toString(),tick:Number(s[1]),price:n>0n?K(n,c.decimals,t.decimals):"0",addSupported:U.has(e.hooks.toLowerCase()),feeNote:k.feeNote,...U.has(e.hooks.toLowerCase())?{}:{note:`Hook ${I(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Se(o,e,a,r){let c=await o.getBlockNumber(),t=[],s=new Set,p=!1,n=we;for(let i=c;;){let l=i+1n>n?i-n+1n:0n,h;try{h=await o.request({method:"eth_getLogs",params:[{address:J.toLowerCase(),topics:[ge,null,e?ne(e):null,a?ne(a):null],fromBlock:ie(l),toBlock:ie(i)}]})}catch(m){if(M(m,-32601)||n<=ye)throw m;n/=2n;continue}if(!Array.isArray(h))throw new w("Invalid v4 Initialize log response.");let P=[];for(let m of h){if(!Array.isArray(m.topics)||m.topics.length!==4||typeof m.data!="string")throw new w("Invalid v4 Initialize log.");let[S,L,N]=fe(ke,m.data),D={currency0:I(`0x${m.topics[2].slice(-40)}`),currency1:I(`0x${m.topics[3].slice(-40)}`),fee:Number(S),tickSpacing:Number(L),hooks:I(N)};P.push({key:D,id:m.topics[1]}),s.add(m.topics[1].toLowerCase())}if(t.push(P),l===0n)break;if(s.size>=r){p=!0;break}i=l-1n}let k=new Map;for(let i of t.reverse())for(let l of i)k.set(l.id.toLowerCase(),l);return{pools:[...k.values()],cut:p}}async function Ce(o,e,a){let r=e.eth?B.weth:e.address,c=a.eth?B.weth:a.address;if(r===c)return[];let[t,s]=ue(r,c)<0?[r,c]:[c,r],[p,n]=await Promise.all([A(o,t,y),A(o,s,y)]),k=[];for(let i of Object.keys(te).map(Number)){let l=I(String(await o.readContract({address:B.factory,abi:se,functionName:"getPool",args:[t,s,i]})));l!==ce&&k.push(await pe(o,l,p,n,i))}return k}function ae(o){return o?o.eth?[v,_]:o.address===_?[_,v]:[o.address]:null}async function _e(o,e){let a=new Map;if(e.length===0)return a;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(c=>({address:C,abi:O,functionName:"getLiquidity",args:[c]}))})).forEach((c,t)=>a.set(e[t].toLowerCase(),c.status==="success"?BigInt(c.result):0n)),a}catch{}for(let r=0;r<e.length;r+=R)(await Promise.allSettled(e.slice(r,r+R).map(async t=>BigInt(await o.readContract({address:C,abi:O,functionName:"getLiquidity",args:[t]}))))).forEach((t,s)=>a.set(e[r+s].toLowerCase(),t.status==="fulfilled"?t.value:0n));return a}async function Le(o,e,a,r){let c=ae(e),t=ae(a),s=new Map,p=(d,f)=>{if(d&&f){if(d===f)return;let[u,g]=ue(d,f)<0?[d,f]:[f,d];s.set(`${u}/${g}`,[u,g])}else if(d||f){let u=d??f;s.set(`${u}/*0`,[u,null]),s.set(`${u}/*1`,[null,u])}};for(let d of c??[null])for(let f of t??[null])p(d,f);let n=new Map;for(let d of b)[...s.values()].some(([u,g])=>(!u||E(d.key.currency0,u))&&(!g||E(d.key.currency1,g)))&&n.set(d.poolId.toLowerCase(),{key:d.key,id:d.poolId});let i=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?Pe:be,l=!1;for(let[d,f]of s.values()){let u=await Se(o,d,f,i+b.length);l||=u.cut;for(let g of u.pools)n.set(g.id.toLowerCase(),g)}let h=new Set(b.map(d=>d.poolId.toLowerCase())),P=[...n.values()],m=P.filter(d=>h.has(d.id.toLowerCase())),S=P.filter(d=>!h.has(d.id.toLowerCase())).reverse();(S.length>i||l)&&r.push(`${l?"At least ":""}${S.length} v4 pools match; only the newest ${i} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let L=S.slice(0,i),N=await _e(o,L.map(d=>d.id)),D=L.sort((d,f)=>{let u=N.get(d.id.toLowerCase())??0n,g=N.get(f.id.toLowerCase())??0n;return u===g?0:u<g?1:-1}),H=[...m,...D];H.length>z&&r.push(`${H.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${z} total). Pass both tokens, or a poolId, to narrow.`);let X=[],V=0,G=H.slice(0,z);for(let d=0;d<G.length;d+=R){let f=await Promise.allSettled(G.slice(d,d+R).map(({key:u,id:g})=>x(o,u,g)));for(let u of f)u.status==="fulfilled"?X.push(u.value):V++}return V>0&&r.push(`${V} pool(s) were skipped because a token or pool state could not be read.`),X}async function Ne(o,e){let a=b.find(n=>E(n.poolId,e));if(a)return x(o,a.key,a.poolId);let[r,c,t,s,p]=await o.readContract({address:Q,abi:Ie,functionName:"poolKeys",args:[e.slice(0,52)]});if(r===v&&c===v&&Number(s)===0)throw new w(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return x(o,{currency0:r,currency1:c,fee:Number(t),tickSpacing:Number(s),hooks:p},e)}function Ee(o){let e=new Set([...b.map(t=>t.poolId.toLowerCase()),...W.map(t=>t.address.toLowerCase())]),a=new Set([v,F.toLowerCase(),_.toLowerCase()]),r=t=>a.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),c=new Map;for(let t of o.filter(s=>s.initialized&&BigInt(s.liquidity)>0n)){let s=`${r(t.token0)}/${r(t.token1)}`;c.set(s,[...c.get(s)??[],t])}for(let t of c.values()){let s=t.filter(i=>e.has(i.id.toLowerCase()));if(s.length===0&&t.length<3)continue;let n=(s.length>0?s:t).map(i=>BigInt(i.sqrtPriceX96)).sort((i,l)=>i<l?-1:i>l?1:0),k=n[Math.floor(n.length/2)];for(let i of t){if(e.has(i.id.toLowerCase()))continue;let l=Z(BigInt(i.sqrtPriceX96),k);l>Ae&&(i.priceOutlierBps=Number(l),i.note=`${i.note?`${i.note} `:""}Price differs ${l} bps from the ${s.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function Be(o,e){let a=e.version;if(a!==void 0&&a!=="v3"&&a!=="v4")throw new w('version must be "v3" or "v4"; omit it to search both.');let r=e.limit===void 0?le:Number(e.limit);if(!Number.isInteger(r)||r<1||r>q)throw new w(`limit must be an integer from 1 to ${q}.`);let c=re(e.tokenA,"tokenA"),t=re(e.tokenB,"tokenB");if(!c&&t)throw new w("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let s=o.clientFor(y),p=[],n=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new w("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");n=[await Ne(s,e.poolId)]}else if(c){if(a!=="v4"&&(t?n.push(...await Ce(s,c,t)):p.push("v3 pools are looked up per pair; pass tokenB to include them.")),a!=="v3")try{n.push(...await Le(s,c,t,p))}catch(i){throw M(i,-32601)?i:new w(`Could not search v4 pools. ${j(i)}`)}}else{p.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let i=await Promise.all(W.map(async h=>{let[P,m]=await Promise.all([A(s,h.token0,y),A(s,h.token1,y)]);return pe(s,h.address,P,m,h.fee)})),l=await Promise.all(b.map(h=>x(s,h.key,h.poolId)));n=[...a==="v4"?[]:i,...a==="v3"?[]:l]}Ee(n),n.sort((i,l)=>BigInt(l.liquidity)>BigInt(i.liquidity)?1:BigInt(l.liquidity)<BigInt(i.liquidity)?-1:0),n.length>r&&p.push(`Showing the ${r} deepest of ${n.length} pools found; raise limit (max ${q}) to see more.`),n=n.slice(0,r);let k=n.filter(i=>i.initialized&&BigInt(i.liquidity)>0n).length;return n.length===0&&p.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:n,notes:p,summary:`Found ${n.length} Uniswap pool(s), ${k} with active liquidity. price is token1 per 1 token0.`}}function Me(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},limit:{type:"integer",minimum:1,maximum:q,default:le}}},execute:async a=>Be(o,a)}]}}export{Be as a,Me as b};
1
+ import{e as B,f as te,g as W,i as se,j as T}from"./IPN6Z4JM.js";import{E as A,a as J,b as Q,c as C,f as _,h as v,m as b,q as U,s as ee,u as oe}from"./2THSW4QN.js";import{f as K,g as Z}from"./ALLLYOUG.js";import{a as F}from"./QHBS3PVU.js";import{a as Y}from"./43LI5NKJ.js";import{g as E}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a as w,b as M,e as j}from"./XSD5NL7J.js";import{decodeAbiParameters as fe,getAddress as I,pad as ne,parseAbi as de,parseAbiParameters as me,toEventSelector as he,toHex as ie,zeroAddress as ce}from"viem";var ge=he("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),ke=me("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),we=10000000n,ye=10000n,le=25,z=200,R=16,Pe=3e3,be=500,Ae=500n,q=100,O=de(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ie=de(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function ve(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===ce||e===F.toLowerCase()}function re(o,e){if(o!=null){if(typeof o!="string")throw new w(`${e} must be a token address, or "eth" for native ETH.`);return ve(o)?{eth:!0}:(Y(o),{eth:!1,address:I(o)})}}var ue=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function $(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function pe(o,e,a,r,c){let[t,s,p]=await Promise.all([o.readContract({address:e,abi:T,functionName:"slot0"}),o.readContract({address:e,abi:T,functionName:"liquidity"}),o.readContract({address:e,abi:T,functionName:"tickSpacing"})]),n=BigInt(t[0]);return{version:"v3",id:e,token0:$(a),token1:$(r),fee:c,tickSpacing:Number(p),initialized:n>0n,liquidity:BigInt(s).toString(),sqrtPriceX96:n.toString(),tick:Number(t[1]),price:n>0n?K(n,a.decimals,r.decimals):"0",addSupported:!0}}async function x(o,e,a){let r=a??ee(e),[c,t]=await Promise.all([A(o,e.currency0,y),A(o,e.currency1,y)]),[s,p]=await Promise.all([o.readContract({address:C,abi:O,functionName:"getSlot0",args:[r]}),o.readContract({address:C,abi:O,functionName:"getLiquidity",args:[r]})]),n=BigInt(s[0]),k=oe(e,Number(s[3]));return{version:"v4",id:r,token0:$(c),token1:$(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:I(e.hooks),initialized:n>0n,liquidity:BigInt(p).toString(),sqrtPriceX96:n.toString(),tick:Number(s[1]),price:n>0n?K(n,c.decimals,t.decimals):"0",addSupported:U.has(e.hooks.toLowerCase()),feeNote:k.feeNote,...U.has(e.hooks.toLowerCase())?{}:{note:`Hook ${I(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Se(o,e,a,r){let c=await o.getBlockNumber(),t=[],s=new Set,p=!1,n=we;for(let i=c;;){let l=i+1n>n?i-n+1n:0n,h;try{h=await o.request({method:"eth_getLogs",params:[{address:J.toLowerCase(),topics:[ge,null,e?ne(e):null,a?ne(a):null],fromBlock:ie(l),toBlock:ie(i)}]})}catch(m){if(M(m,-32601)||n<=ye)throw m;n/=2n;continue}if(!Array.isArray(h))throw new w("Invalid v4 Initialize log response.");let P=[];for(let m of h){if(!Array.isArray(m.topics)||m.topics.length!==4||typeof m.data!="string")throw new w("Invalid v4 Initialize log.");let[S,L,N]=fe(ke,m.data),D={currency0:I(`0x${m.topics[2].slice(-40)}`),currency1:I(`0x${m.topics[3].slice(-40)}`),fee:Number(S),tickSpacing:Number(L),hooks:I(N)};P.push({key:D,id:m.topics[1]}),s.add(m.topics[1].toLowerCase())}if(t.push(P),l===0n)break;if(s.size>=r){p=!0;break}i=l-1n}let k=new Map;for(let i of t.reverse())for(let l of i)k.set(l.id.toLowerCase(),l);return{pools:[...k.values()],cut:p}}async function Ce(o,e,a){let r=e.eth?B.weth:e.address,c=a.eth?B.weth:a.address;if(r===c)return[];let[t,s]=ue(r,c)<0?[r,c]:[c,r],[p,n]=await Promise.all([A(o,t,y),A(o,s,y)]),k=[];for(let i of Object.keys(te).map(Number)){let l=I(String(await o.readContract({address:B.factory,abi:se,functionName:"getPool",args:[t,s,i]})));l!==ce&&k.push(await pe(o,l,p,n,i))}return k}function ae(o){return o?o.eth?[v,_]:o.address===_?[_,v]:[o.address]:null}async function _e(o,e){let a=new Map;if(e.length===0)return a;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(c=>({address:C,abi:O,functionName:"getLiquidity",args:[c]}))})).forEach((c,t)=>a.set(e[t].toLowerCase(),c.status==="success"?BigInt(c.result):0n)),a}catch{}for(let r=0;r<e.length;r+=R)(await Promise.allSettled(e.slice(r,r+R).map(async t=>BigInt(await o.readContract({address:C,abi:O,functionName:"getLiquidity",args:[t]}))))).forEach((t,s)=>a.set(e[r+s].toLowerCase(),t.status==="fulfilled"?t.value:0n));return a}async function Le(o,e,a,r){let c=ae(e),t=ae(a),s=new Map,p=(d,f)=>{if(d&&f){if(d===f)return;let[u,g]=ue(d,f)<0?[d,f]:[f,d];s.set(`${u}/${g}`,[u,g])}else if(d||f){let u=d??f;s.set(`${u}/*0`,[u,null]),s.set(`${u}/*1`,[null,u])}};for(let d of c??[null])for(let f of t??[null])p(d,f);let n=new Map;for(let d of b)[...s.values()].some(([u,g])=>(!u||E(d.key.currency0,u))&&(!g||E(d.key.currency1,g)))&&n.set(d.poolId.toLowerCase(),{key:d.key,id:d.poolId});let i=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?Pe:be,l=!1;for(let[d,f]of s.values()){let u=await Se(o,d,f,i+b.length);l||=u.cut;for(let g of u.pools)n.set(g.id.toLowerCase(),g)}let h=new Set(b.map(d=>d.poolId.toLowerCase())),P=[...n.values()],m=P.filter(d=>h.has(d.id.toLowerCase())),S=P.filter(d=>!h.has(d.id.toLowerCase())).reverse();(S.length>i||l)&&r.push(`${l?"At least ":""}${S.length} v4 pools match; only the newest ${i} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let L=S.slice(0,i),N=await _e(o,L.map(d=>d.id)),D=L.sort((d,f)=>{let u=N.get(d.id.toLowerCase())??0n,g=N.get(f.id.toLowerCase())??0n;return u===g?0:u<g?1:-1}),H=[...m,...D];H.length>z&&r.push(`${H.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${z} total). Pass both tokens, or a poolId, to narrow.`);let X=[],V=0,G=H.slice(0,z);for(let d=0;d<G.length;d+=R){let f=await Promise.allSettled(G.slice(d,d+R).map(({key:u,id:g})=>x(o,u,g)));for(let u of f)u.status==="fulfilled"?X.push(u.value):V++}return V>0&&r.push(`${V} pool(s) were skipped because a token or pool state could not be read.`),X}async function Ne(o,e){let a=b.find(n=>E(n.poolId,e));if(a)return x(o,a.key,a.poolId);let[r,c,t,s,p]=await o.readContract({address:Q,abi:Ie,functionName:"poolKeys",args:[e.slice(0,52)]});if(r===v&&c===v&&Number(s)===0)throw new w(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return x(o,{currency0:r,currency1:c,fee:Number(t),tickSpacing:Number(s),hooks:p},e)}function Ee(o){let e=new Set([...b.map(t=>t.poolId.toLowerCase()),...W.map(t=>t.address.toLowerCase())]),a=new Set([v,F.toLowerCase(),_.toLowerCase()]),r=t=>a.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),c=new Map;for(let t of o.filter(s=>s.initialized&&BigInt(s.liquidity)>0n)){let s=`${r(t.token0)}/${r(t.token1)}`;c.set(s,[...c.get(s)??[],t])}for(let t of c.values()){let s=t.filter(i=>e.has(i.id.toLowerCase()));if(s.length===0&&t.length<3)continue;let n=(s.length>0?s:t).map(i=>BigInt(i.sqrtPriceX96)).sort((i,l)=>i<l?-1:i>l?1:0),k=n[Math.floor(n.length/2)];for(let i of t){if(e.has(i.id.toLowerCase()))continue;let l=Z(BigInt(i.sqrtPriceX96),k);l>Ae&&(i.priceOutlierBps=Number(l),i.note=`${i.note?`${i.note} `:""}Price differs ${l} bps from the ${s.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function Be(o,e){let a=e.version;if(a!==void 0&&a!=="v3"&&a!=="v4")throw new w('version must be "v3" or "v4"; omit it to search both.');let r=e.limit===void 0?le:Number(e.limit);if(!Number.isInteger(r)||r<1||r>q)throw new w(`limit must be an integer from 1 to ${q}.`);let c=re(e.tokenA,"tokenA"),t=re(e.tokenB,"tokenB");if(!c&&t)throw new w("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let s=o.clientFor(y),p=[],n=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new w("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");n=[await Ne(s,e.poolId)]}else if(c){if(a!=="v4"&&(t?n.push(...await Ce(s,c,t)):p.push("v3 pools are looked up per pair; pass tokenB to include them.")),a!=="v3")try{n.push(...await Le(s,c,t,p))}catch(i){throw M(i,-32601)?i:new w(`Could not search v4 pools. ${j(i)}`)}}else{p.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let i=await Promise.all(W.map(async h=>{let[P,m]=await Promise.all([A(s,h.token0,y),A(s,h.token1,y)]);return pe(s,h.address,P,m,h.fee)})),l=await Promise.all(b.map(h=>x(s,h.key,h.poolId)));n=[...a==="v4"?[]:i,...a==="v3"?[]:l]}Ee(n),n.sort((i,l)=>BigInt(l.liquidity)>BigInt(i.liquidity)?1:BigInt(l.liquidity)<BigInt(i.liquidity)?-1:0),n.length>r&&p.push(`Showing the ${r} deepest of ${n.length} pools found; raise limit (max ${q}) to see more.`),n=n.slice(0,r);let k=n.filter(i=>i.initialized&&BigInt(i.liquidity)>0n).length;return n.length===0&&p.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:n,notes:p,summary:`Found ${n.length} Uniswap pool(s), ${k} with active liquidity. price is token1 per 1 token0.`}}function Me(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},limit:{type:"integer",minimum:1,maximum:q,default:le}}},execute:async a=>Be(o,a)}]}}export{Be as a,Me as b};
@@ -1 +1 @@
1
- import{A as qe,s as oe,x as xe}from"./WPAF55SP.js";import{a as Be}from"./MOPETB64.js";import{a as y}from"./WWNAGOCD.js";import{a as w,b as re,d as ve,e as A,f as d,h as $,i as q,j as k,k as N,l as H,m as R,n as ie,o as f,p as c,q as I,r as j,s as He,t as Se}from"./YEXUSRIZ.js";import{b as K,f as Pe,g as V,h as Te,i as Le}from"./MQK6OP7S.js";import{i as ne}from"./S2TAJHHK.js";import{a as be}from"./HTXKERNS.js";import{s as ge}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as _e,encodeFunctionData as Qe,erc20Abi as We,formatUnits as Ae,getAddress as ue,parseAbi as _,zeroAddress as b,zeroHash as se}from"viem";var Ge="hookr_launch",g=ue(K.launcherV1),z=ue(K.rulesV1),Je=[{type:"tuple",components:[{name:"flags",type:"uint16"},{name:"minScore",type:"uint32"},{name:"tierScore",type:"uint32"},{name:"tierPips",type:"uint24"},{name:"reviewers",type:"bytes32"}]}],X=(a,n=Object.keys(a))=>({type:"object",properties:a,required:n,additionalProperties:!1}),Re={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},ae=X({token:{oneOf:[X({kind:{const:"new",type:"string"},name:{type:"string",minLength:1,maxLength:48},symbol:{type:"string",minLength:1,maxLength:12},supply:w,salt:re}),X({kind:{const:"existing",type:"string"},address:Re})]},quote:{...Re,description:"Qualified ETH (zero address) or pinned USDG quote. Other quote funding routes await qualification."},sqrtPriceX96:{...w,description:"Integer sqrt(currency1/currency0) times 2^96 for the sorted PoolKey."},tickLower:{type:"integer",minimum:-887272,maximum:887272},tickUpper:{type:"integer",minimum:-887272,maximum:887272},liquidity:w,amount0Max:w,amount1Max:w,agentGate:X({minScore:w,tierScore:w,tierPips:w,reviewerSetId:re}),lpRewardsBps:w,arbRecapture:{type:"boolean"},deadline:w});function Ye(a){let n=A(a,Object.keys(ae.properties),ae.required),r=R(n.token);if(r.kind==="existing")throw A(r,["kind","address"],["kind","address"]),q(r.address),new o("Existing-token Hookr launches await a qualified funding route. Use token.kind new.");if(A(r,["kind","name","symbol","supply","salt"],["kind","name","symbol","supply","salt"]),r.kind!=="new")throw new o("Choose token.kind new; existing tokens are not supported yet.");let e=(P,M)=>{if(typeof P!="string"||!P.trim()||new TextEncoder().encode(P).length>M||[...P].some(Q=>Q.codePointAt(0)<32)||/[\u007f-\u009f\u2028-\u202e\u2066-\u2069\ud800-\udfff]/u.test(P))throw new o(`Use nonempty public token text within ${M} UTF-8 bytes without control characters.`);return P},i=d(r.supply,108);if(!i)throw new o("Hookr new-token supply must be positive and at most 2^108-1 base units.");let t=q(n.quote);if(![b,ue(ge.mainnet.usdg)].includes(t))throw new o("Use native ETH (zero address) or the pinned USDG quote; other quote funding routes await qualification.");let l=n.tickLower,u=n.tickUpper;if(typeof l!="number"||typeof u!="number")throw new o("Provide integer aligned Hookr ticks.");xe(l,u,y.tickSpacing);let s=d(n.sqrtPriceX96,160);if(s<=ne(l)||s>=ne(u))throw new o("Hookr opening price must be strictly inside the aligned tick range.");let p=d(n.liquidity,127);if(!p)throw new o("Hookr liquidity must be positive and at most int128 max.");let m=d(n.amount0Max,128),L=d(n.amount1Max,128),x=qe({liquidity:p,tickLower:l,tickUpper:u,sqrtPriceX96:s,roundUp:!0});if(x.amount0>=1n<<127n||x.amount1>=1n<<127n||!x.amount0||!x.amount1||x.amount0>m||x.amount1>L)throw new o("Hookr exact rounded-up debts must be positive and fit both approved funding caps. Reduce liquidity or increase the caps.");let h=A(n.agentGate,["minScore","tierScore","tierPips","reviewerSetId"],["minScore","tierScore","tierPips","reviewerSetId"]),F=Number(d(h.minScore,32)),S=Number(d(h.tierScore,32)),B=Number(d(h.tierPips,24)),O=$(h.reviewerSetId);if(B>5e4||S===0!=(B===0)||(F!==0||S!==0)!=(O!==se))throw new o("Use tierPips at most 50000, paired nonzero tier score/pips, and a registered reviewer set only for scored gates. Identity-only uses all zero values.");let U=Number(d(n.lpRewardsBps,16));if(U>1e3)throw new o("Hookr LP Rewards plus burn must not exceed 1000 bps; this profile has zero burn.");if(typeof n.arbRecapture!="boolean")throw new o("Choose arbRecapture true or false explicitly.");return{token:{existing:b,name:e(r.name,48),symbol:e(r.symbol,12),supply:i,salt:$(r.salt)},quote:t,sqrtPriceX96:s,tickLower:l,tickUpper:u,liquidity:p,amount0Max:m,amount1Max:L,debts:x,gateTerms:{flags:1,minScore:F,tierScore:S,tierPips:B,reviewers:O},lpRewardsBps:U,arbRecapture:n.arbRecapture,deadline:d(n.deadline,64)}}async function Ze(a,n,r,e){return q(await c(a,g,f("launcherV1"),"predictToken",[n,r],e))}async function et(a,n,r,e,i){let t=r.gate;if(!t.walletAgent||!(e?t.healthyForScores:t.healthyIdentityOnly))throw new o("Hookr needs a healthy on-chain agent identity. Own an ERC-8004 identity or link its current agent wallet on the Hookr gate; Oak setup linking alone is insufficient.");let l=(p,m)=>c(a,t.identity,_(["function balanceOf(address) view returns (uint256)","function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),p,m,i),u=k(await l("balanceOf",[n])),s=!1;if(t.link.linked){let p=BigInt(t.link.agentId);s=q(await l("getAgentWallet",[p]))===n,!s&&u>0n&&(s=q(await l("ownerOf",[p]))===n)}if(!u&&!s||e&&!s)throw new o("Hookr on-chain identity ownership or gate link is missing or stale. Link a current ERC-8004 agent ID on the Hookr gate before launching; scored gates require that link even for an NFT owner.")}async function tt(a,n,r){let e=Ye(n);if(a.network==="testnet")throw new o("Hookr launch requires Robinhood Chain 4663.");let i=a.clientFor(4663),t=await Te(i);if(e.deadline<=t.timestamp||e.deadline>t.timestamp+y.deadlineSeconds)throw new o("Set a fresh Hookr deadline within the next 300 seconds of chain time.");let l=e.gateTerms.reviewers!==se,u=await Be(i,r,t.number,l?[e.gateTerms.reviewers]:[]);if(!u.rootOpenForWallet||u.newMarketsPaused||!u.launcherAdmitted)throw new o("Hookr new markets or the reviewed Launcher are closed. Retry only after registry admission is restored.");await et(i,r,u,l,t.number);let s=await Ze(i,r,e.token,t.number);if(s===b||s===e.quote)throw new o("Hookr predicted token collides with its quote. Choose a fresh salt.");let p={currency0:BigInt(s)<BigInt(e.quote)?s:e.quote,currency1:BigInt(s)<BigInt(e.quote)?e.quote:s,fee:8388608,tickSpacing:y.tickSpacing,hooks:I},m=oe(p),L=p.currency0===s,x=L?e.amount0Max:e.amount1Max,h=L?e.amount1Max:e.amount0Max,F=L?e.debts.amount0:e.debts.amount1,S=L?e.debts.amount1:e.debts.amount0;if(x>e.token.supply)throw new o("Hookr new-token deposit cap exceeds its fixed supply.");let[B,O,U,P,M,Q,Ie,Fe]=await Promise.all([i.getCode({address:s,blockNumber:t.number}),i.getTransactionCount({address:s,blockNumber:t.number}),c(i,g,f("launcherV1"),"memberKey",[s,e.quote,y.tickSpacing,I],t.number),c(i,I,f("rootV1"),"knownPool",[m],t.number),c(i,g,f("launcherV1"),"SKIP_TAKEN",[],t.number),c(i,j,f("registry"),"isQuote",[e.quote],t.number),c(i,j,f("registry"),"quoteIsBraked",[e.quote],t.number),c(i,z,f("rulesV1"),"minProtocolShareBps",[],t.number)]),[Ce,$e]=H(U,2);if(e.token.salt===$(M))throw new o("SKIP_TAKEN is unsupported. Choose an ordinary new-token salt.");if(B&&B!=="0x"||O!==0||N(P)||!N($e)||oe(R(Ce))!==m)throw new o("Hookr token address or pool is already taken or its predicted key differs. Choose a fresh salt and rebuild.");if(!N(Q)||N(H(Ie,2)[0]))throw new o("The Hookr quote is not currently qualified or is braked. Choose an admitted quote.");let ce=R(u.gate.admission),Ne=R(ce.caps),pe=d(Ne.maxLpFeePips,24),Oe=BigInt(u.coreAdmission.caps.maxLpFeePips),W=BigInt(y.baseLpFeePips)+pe;if(BigInt(e.gateTerms.tierPips)>pe||W>Oe||W>600000n)throw new o("Hookr gate tier or total LP fee exceeds the live admission cap. Lower the tier or wait for compatible admission.");let de=q(await c(i,z,f("rulesV1"),"protocolRecipient",[],t.number));await V(i,t.number,[de]);let[Ue,Me,Ee]=H(await c(i,de,_(["function feeTerms(address,bool,bytes32) view returns (uint16,uint16,uint16)"]),"feeTerms",[b,e.arbRecapture,m],t.number),3),le=k(Ue,16),G=k(Ee,16);if(k(Me,16)!==0n||G>10000n)throw new o("Hookr treasury minimum or integrator terms exceed the reviewed profile.");let me=k(Fe,16),E=le>me?le:me;if(E<2000n||E>5000n)throw new o("Hookr protocol share is outside the reviewed 2000\u20135000 bps profile.");let J=BigInt(e.lpRewardsBps)*100n+(!e.arbRecapture&&e.lpRewardsBps===0?G:0n);if(J>BigInt(u.coreAdmission.caps.maxQuoteTakePips))throw new o("Hookr LP Rewards and minimum quote charge exceed the live quote-take cap. Lower LP Rewards.");let Y={on:e.arbRecapture,traderBps:0,lpBps:e.arbRecapture?1e4:0,period:0,maxPrizeBps:0,potReleaseBps:0,minBuyQuote:0n,releaseBlocks:0},he=null;if(e.arbRecapture){let[D,ye]=await Promise.all([c(i,z,_(["function recaptureDefaults() view returns ((bool on,uint16 traderBps,uint16 lpBps,uint32 period,uint16 maxPrizeBps,uint16 potReleaseBps,uint128 minBuyQuote,uint32 releaseBlocks) rc,uint16 potBps)"]),"recaptureDefaults",[],t.number),c(i,j,f("registry"),"activeLaneOf",[I],t.number)]);Y.releaseBlocks=Number(k(R(H(D,2)[0]).releaseBlocks,32));let[Ve,je,ze,Xe]=H(ye,4),te=q(Ve);if(await V(i,t.number,[te]),te===b||$(je)!==Pe(te).codeHash||k(ze,32)===0n||k(Xe,16)>10000n||!Y.releaseBlocks)throw new o("Hookr recapture lane is unavailable. Use arbRecapture false until its executor and gas floor are reviewed.");he=ie(ye)}let we={quote:e.quote,tickSpacing:y.tickSpacing,sqrtPriceX96:e.sqrtPriceX96,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity,amount0Max:e.amount0Max,amount1Max:e.amount1Max,config:{subject:s,quote:e.quote,rules:z,advisory:Se,liquidityOwner:g,baseLpFeePips:y.baseLpFeePips,caps:{maxLpFeePips:Number(W),maxQuoteTakePips:Number(J),maxSubjectTakeBps:0},rulesGasLimit:Number(u.coreAdmission.gasLimit),advisoryGasLimit:Number(d(ce.gasLimit,32)),advisoryPhases:1,advisoryFailOpen:!1,policyId:se},rules:{guardEndBlock:0,maxFeePips:y.baseLpFeePips,snipeTaxPips:0,snipeFloorPips:0,snipeDecaySeconds:0,dynamicFeeSens:0,burnBps:0,lpBps:e.lpRewardsBps,potBps:0,royaltyBps:0,protocolShareBps:Number(E),potEveryNBuys:0,maxBuyQuoteAmount:0n,potMinBuyQuote:0n,royaltyTo:b,integrator:b},recapture:Y},v=BigInt(u.launchFee.amount);if(v>10000000000000000n)throw new o("Hookr launch fee exceeds the reviewed 0.01 ETH maximum.");let T=b;if(v&&(await V(i,t.number,[u.launchFee.treasury]),T=q(await c(i,u.launchFee.treasury,_(["function target() view returns (address)"]),"target",[],t.number)),T===b||T===g||T===r||T===He))throw new o("Hookr launch fee recipient is outside the reviewed payment profile.");let Z=v+(e.quote===b?h:0n),ee=[],C=[];if(e.quote!==b){let D=k(await c(i,e.quote,We,"allowance",[r,g],t.number));D!==0n&&D!==h&&C.push(a.approval(e.quote,g,"0",4663)),C.push(a.approval(e.quote,g,h.toString(),4663)),ee.push({token:e.quote,amount:h})}Z&&ee.push({token:be,amount:Z,to:g});let ke=`Launch public, permanent token ${JSON.stringify(e.token.name)} (${JSON.stringify(e.token.symbol)}), fixed supply ${Ae(e.token.supply,18)} (18 decimals). Create one agents-only pool (identity check on every buy). Price currency1/currency0 = ${e.sqrtPriceX96*e.sqrtPriceX96}/${1n<<192n}; sqrtPriceX96 ${e.sqrtPriceX96}, ticks ${e.tickLower} to ${e.tickUpper}, spacing ${y.tickSpacing}. Deposit at most ${e.amount0Max} currency0 and ${e.amount1Max} currency1 base units; exact launch debts ${e.debts.amount0} and ${e.debts.amount1}. Currency0 ${p.currency0}; currency1 ${p.currency1}. Launch fee ${v} wei to ${T} (${Ae(v,18)} ETH). Unused quote funding (${h-S} base units) and retained token supply (${e.token.supply-F} base units) return to ${r} in this transaction. Family owner ${r}; token ${s}; pool ${m}. LP base fee 3000 pips; gate flags 1, scores ${e.gateTerms.minScore}/${e.gateTerms.tierScore}, tier ${e.gateTerms.tierPips} pips; LP Rewards ${e.lpRewardsBps} bps; burn 0; quote-take cap ${J} pips (includes Hookr minimum); protocol share ${E} bps. Arb recapture ${e.arbRecapture}; deadline ${e.deadline}. No lock.`;C.push(a.unsignedTx({to:g,data:Qe({abi:f("launcherV1"),functionName:"launchAdvised",args:[e.token,I,[we],[_e(Je,[e.gateTerms])],e.deadline]}),value:Z.toString(),chainId:4663,description:ke}));let[fe,De,Ke]=await Promise.all([i.getCode({address:s}),i.getTransactionCount({address:s}),i.readContract({address:g,abi:ve,functionName:"launchFee"})]);if(fe&&fe!=="0x"||De!==0||k(H(Ke,5)[0])!==v)throw new o("Hookr collision state or launch fee changed. Request a fresh launch preview.");return await Le(i,t),{txs:C,inputs:ee,summary:ke,tokenAddress:s,poolId:m,feeTarget:T,feeTreasury:u.launchFee.treasury,terms:ie({request:n,blockNumber:t.number,blockHash:t.hash,owner:r,tokenAddress:s,poolId:m,poolKey:p,member:we,gateTerms:e.gateTerms,launchFee:v,feeTarget:T,feeTreasury:u.launchFee.treasury,hookrMinimumPips:G,exactApprovals:C.slice(0,-1),refunds:{quote:h-S,retainedSupply:e.token.supply-F},gasEstimate:null,gasEstimateReason:"The local sender estimates the ordered exact calls after funding approvals and confirms the gas limit and maximum fee.",lane:he,pins:K})}}function nt(a){if(!Array.isArray(a)||a.length<1||a.length>3)throw new o("Hookr launch requires only the locally reconstructed finite approvals and one launch transaction.");for(let n of a)A(n,["to","data","value","chainId","description"],["to","data","value","chainId","description"])}function mt(a,n){if(nt(a),a.length!==n.length||a.some((r,e)=>r.to.toLowerCase()!==n[e].to.toLowerCase()||r.data.toLowerCase()!==n[e].data.toLowerCase()||r.value!==n[e].value||r.chainId!==4663))throw new o("Hookr launch differs from the locally reconstructed exact parameters, approvals and funding.")}function ht(a){return[{name:Ge,inputSchema:ae,execute:async(n,r)=>{let e=await tt(a,n,r);return{txs:e.txs,preview:await a.preview(e.txs,r),terms:e.terms,summary:e.summary}}}]}export{Ge as a,g as b,z as c,ae as d,Ye as e,tt as f,nt as g,mt as h,ht as i};
1
+ import{a as Be}from"./EGYVRQUR.js";import{a as y}from"./WWNAGOCD.js";import{A as qe,s as oe,x as xe}from"./2THSW4QN.js";import{a as w,b as re,d as ve,e as A,f as d,h as $,i as q,j as k,k as N,l as H,m as R,n as ie,o as f,p as c,q as I,r as j,s as He,t as Se}from"./T7TFUH5K.js";import{b as K,f as Pe,g as V,h as Te,i as Le}from"./MQK6OP7S.js";import{i as ne}from"./7KWZ5QJU.js";import{a as be}from"./QHBS3PVU.js";import{s as ge}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as _e,encodeFunctionData as Qe,erc20Abi as We,formatUnits as Ae,getAddress as ue,parseAbi as _,zeroAddress as b,zeroHash as se}from"viem";var Ge="hookr_launch",g=ue(K.launcherV1),z=ue(K.rulesV1),Je=[{type:"tuple",components:[{name:"flags",type:"uint16"},{name:"minScore",type:"uint32"},{name:"tierScore",type:"uint32"},{name:"tierPips",type:"uint24"},{name:"reviewers",type:"bytes32"}]}],X=(a,n=Object.keys(a))=>({type:"object",properties:a,required:n,additionalProperties:!1}),Re={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},ae=X({token:{oneOf:[X({kind:{const:"new",type:"string"},name:{type:"string",minLength:1,maxLength:48},symbol:{type:"string",minLength:1,maxLength:12},supply:w,salt:re}),X({kind:{const:"existing",type:"string"},address:Re})]},quote:{...Re,description:"Qualified ETH (zero address) or pinned USDG quote. Other quote funding routes await qualification."},sqrtPriceX96:{...w,description:"Integer sqrt(currency1/currency0) times 2^96 for the sorted PoolKey."},tickLower:{type:"integer",minimum:-887272,maximum:887272},tickUpper:{type:"integer",minimum:-887272,maximum:887272},liquidity:w,amount0Max:w,amount1Max:w,agentGate:X({minScore:w,tierScore:w,tierPips:w,reviewerSetId:re}),lpRewardsBps:w,arbRecapture:{type:"boolean"},deadline:w});function Ye(a){let n=A(a,Object.keys(ae.properties),ae.required),r=R(n.token);if(r.kind==="existing")throw A(r,["kind","address"],["kind","address"]),q(r.address),new o("Existing-token Hookr launches await a qualified funding route. Use token.kind new.");if(A(r,["kind","name","symbol","supply","salt"],["kind","name","symbol","supply","salt"]),r.kind!=="new")throw new o("Choose token.kind new; existing tokens are not supported yet.");let e=(P,M)=>{if(typeof P!="string"||!P.trim()||new TextEncoder().encode(P).length>M||[...P].some(Q=>Q.codePointAt(0)<32)||/[\u007f-\u009f\u2028-\u202e\u2066-\u2069\ud800-\udfff]/u.test(P))throw new o(`Use nonempty public token text within ${M} UTF-8 bytes without control characters.`);return P},i=d(r.supply,108);if(!i)throw new o("Hookr new-token supply must be positive and at most 2^108-1 base units.");let t=q(n.quote);if(![b,ue(ge.mainnet.usdg)].includes(t))throw new o("Use native ETH (zero address) or the pinned USDG quote; other quote funding routes await qualification.");let l=n.tickLower,u=n.tickUpper;if(typeof l!="number"||typeof u!="number")throw new o("Provide integer aligned Hookr ticks.");xe(l,u,y.tickSpacing);let s=d(n.sqrtPriceX96,160);if(s<=ne(l)||s>=ne(u))throw new o("Hookr opening price must be strictly inside the aligned tick range.");let p=d(n.liquidity,127);if(!p)throw new o("Hookr liquidity must be positive and at most int128 max.");let m=d(n.amount0Max,128),L=d(n.amount1Max,128),x=qe({liquidity:p,tickLower:l,tickUpper:u,sqrtPriceX96:s,roundUp:!0});if(x.amount0>=1n<<127n||x.amount1>=1n<<127n||!x.amount0||!x.amount1||x.amount0>m||x.amount1>L)throw new o("Hookr exact rounded-up debts must be positive and fit both approved funding caps. Reduce liquidity or increase the caps.");let h=A(n.agentGate,["minScore","tierScore","tierPips","reviewerSetId"],["minScore","tierScore","tierPips","reviewerSetId"]),F=Number(d(h.minScore,32)),S=Number(d(h.tierScore,32)),B=Number(d(h.tierPips,24)),O=$(h.reviewerSetId);if(B>5e4||S===0!=(B===0)||(F!==0||S!==0)!=(O!==se))throw new o("Use tierPips at most 50000, paired nonzero tier score/pips, and a registered reviewer set only for scored gates. Identity-only uses all zero values.");let U=Number(d(n.lpRewardsBps,16));if(U>1e3)throw new o("Hookr LP Rewards plus burn must not exceed 1000 bps; this profile has zero burn.");if(typeof n.arbRecapture!="boolean")throw new o("Choose arbRecapture true or false explicitly.");return{token:{existing:b,name:e(r.name,48),symbol:e(r.symbol,12),supply:i,salt:$(r.salt)},quote:t,sqrtPriceX96:s,tickLower:l,tickUpper:u,liquidity:p,amount0Max:m,amount1Max:L,debts:x,gateTerms:{flags:1,minScore:F,tierScore:S,tierPips:B,reviewers:O},lpRewardsBps:U,arbRecapture:n.arbRecapture,deadline:d(n.deadline,64)}}async function Ze(a,n,r,e){return q(await c(a,g,f("launcherV1"),"predictToken",[n,r],e))}async function et(a,n,r,e,i){let t=r.gate;if(!t.walletAgent||!(e?t.healthyForScores:t.healthyIdentityOnly))throw new o("Hookr needs a healthy on-chain agent identity. Own an ERC-8004 identity or link its current agent wallet on the Hookr gate; Oak setup linking alone is insufficient.");let l=(p,m)=>c(a,t.identity,_(["function balanceOf(address) view returns (uint256)","function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),p,m,i),u=k(await l("balanceOf",[n])),s=!1;if(t.link.linked){let p=BigInt(t.link.agentId);s=q(await l("getAgentWallet",[p]))===n,!s&&u>0n&&(s=q(await l("ownerOf",[p]))===n)}if(!u&&!s||e&&!s)throw new o("Hookr on-chain identity ownership or gate link is missing or stale. Link a current ERC-8004 agent ID on the Hookr gate before launching; scored gates require that link even for an NFT owner.")}async function tt(a,n,r){let e=Ye(n);if(a.network==="testnet")throw new o("Hookr launch requires Robinhood Chain 4663.");let i=a.clientFor(4663),t=await Te(i);if(e.deadline<=t.timestamp||e.deadline>t.timestamp+y.deadlineSeconds)throw new o("Set a fresh Hookr deadline within the next 300 seconds of chain time.");let l=e.gateTerms.reviewers!==se,u=await Be(i,r,t.number,l?[e.gateTerms.reviewers]:[]);if(!u.rootOpenForWallet||u.newMarketsPaused||!u.launcherAdmitted)throw new o("Hookr new markets or the reviewed Launcher are closed. Retry only after registry admission is restored.");await et(i,r,u,l,t.number);let s=await Ze(i,r,e.token,t.number);if(s===b||s===e.quote)throw new o("Hookr predicted token collides with its quote. Choose a fresh salt.");let p={currency0:BigInt(s)<BigInt(e.quote)?s:e.quote,currency1:BigInt(s)<BigInt(e.quote)?e.quote:s,fee:8388608,tickSpacing:y.tickSpacing,hooks:I},m=oe(p),L=p.currency0===s,x=L?e.amount0Max:e.amount1Max,h=L?e.amount1Max:e.amount0Max,F=L?e.debts.amount0:e.debts.amount1,S=L?e.debts.amount1:e.debts.amount0;if(x>e.token.supply)throw new o("Hookr new-token deposit cap exceeds its fixed supply.");let[B,O,U,P,M,Q,Ie,Fe]=await Promise.all([i.getCode({address:s,blockNumber:t.number}),i.getTransactionCount({address:s,blockNumber:t.number}),c(i,g,f("launcherV1"),"memberKey",[s,e.quote,y.tickSpacing,I],t.number),c(i,I,f("rootV1"),"knownPool",[m],t.number),c(i,g,f("launcherV1"),"SKIP_TAKEN",[],t.number),c(i,j,f("registry"),"isQuote",[e.quote],t.number),c(i,j,f("registry"),"quoteIsBraked",[e.quote],t.number),c(i,z,f("rulesV1"),"minProtocolShareBps",[],t.number)]),[Ce,$e]=H(U,2);if(e.token.salt===$(M))throw new o("SKIP_TAKEN is unsupported. Choose an ordinary new-token salt.");if(B&&B!=="0x"||O!==0||N(P)||!N($e)||oe(R(Ce))!==m)throw new o("Hookr token address or pool is already taken or its predicted key differs. Choose a fresh salt and rebuild.");if(!N(Q)||N(H(Ie,2)[0]))throw new o("The Hookr quote is not currently qualified or is braked. Choose an admitted quote.");let ce=R(u.gate.admission),Ne=R(ce.caps),pe=d(Ne.maxLpFeePips,24),Oe=BigInt(u.coreAdmission.caps.maxLpFeePips),W=BigInt(y.baseLpFeePips)+pe;if(BigInt(e.gateTerms.tierPips)>pe||W>Oe||W>600000n)throw new o("Hookr gate tier or total LP fee exceeds the live admission cap. Lower the tier or wait for compatible admission.");let de=q(await c(i,z,f("rulesV1"),"protocolRecipient",[],t.number));await V(i,t.number,[de]);let[Ue,Me,Ee]=H(await c(i,de,_(["function feeTerms(address,bool,bytes32) view returns (uint16,uint16,uint16)"]),"feeTerms",[b,e.arbRecapture,m],t.number),3),le=k(Ue,16),G=k(Ee,16);if(k(Me,16)!==0n||G>10000n)throw new o("Hookr treasury minimum or integrator terms exceed the reviewed profile.");let me=k(Fe,16),E=le>me?le:me;if(E<2000n||E>5000n)throw new o("Hookr protocol share is outside the reviewed 2000\u20135000 bps profile.");let J=BigInt(e.lpRewardsBps)*100n+(!e.arbRecapture&&e.lpRewardsBps===0?G:0n);if(J>BigInt(u.coreAdmission.caps.maxQuoteTakePips))throw new o("Hookr LP Rewards and minimum quote charge exceed the live quote-take cap. Lower LP Rewards.");let Y={on:e.arbRecapture,traderBps:0,lpBps:e.arbRecapture?1e4:0,period:0,maxPrizeBps:0,potReleaseBps:0,minBuyQuote:0n,releaseBlocks:0},he=null;if(e.arbRecapture){let[D,ye]=await Promise.all([c(i,z,_(["function recaptureDefaults() view returns ((bool on,uint16 traderBps,uint16 lpBps,uint32 period,uint16 maxPrizeBps,uint16 potReleaseBps,uint128 minBuyQuote,uint32 releaseBlocks) rc,uint16 potBps)"]),"recaptureDefaults",[],t.number),c(i,j,f("registry"),"activeLaneOf",[I],t.number)]);Y.releaseBlocks=Number(k(R(H(D,2)[0]).releaseBlocks,32));let[Ve,je,ze,Xe]=H(ye,4),te=q(Ve);if(await V(i,t.number,[te]),te===b||$(je)!==Pe(te).codeHash||k(ze,32)===0n||k(Xe,16)>10000n||!Y.releaseBlocks)throw new o("Hookr recapture lane is unavailable. Use arbRecapture false until its executor and gas floor are reviewed.");he=ie(ye)}let we={quote:e.quote,tickSpacing:y.tickSpacing,sqrtPriceX96:e.sqrtPriceX96,tickLower:e.tickLower,tickUpper:e.tickUpper,liquidity:e.liquidity,amount0Max:e.amount0Max,amount1Max:e.amount1Max,config:{subject:s,quote:e.quote,rules:z,advisory:Se,liquidityOwner:g,baseLpFeePips:y.baseLpFeePips,caps:{maxLpFeePips:Number(W),maxQuoteTakePips:Number(J),maxSubjectTakeBps:0},rulesGasLimit:Number(u.coreAdmission.gasLimit),advisoryGasLimit:Number(d(ce.gasLimit,32)),advisoryPhases:1,advisoryFailOpen:!1,policyId:se},rules:{guardEndBlock:0,maxFeePips:y.baseLpFeePips,snipeTaxPips:0,snipeFloorPips:0,snipeDecaySeconds:0,dynamicFeeSens:0,burnBps:0,lpBps:e.lpRewardsBps,potBps:0,royaltyBps:0,protocolShareBps:Number(E),potEveryNBuys:0,maxBuyQuoteAmount:0n,potMinBuyQuote:0n,royaltyTo:b,integrator:b},recapture:Y},v=BigInt(u.launchFee.amount);if(v>10000000000000000n)throw new o("Hookr launch fee exceeds the reviewed 0.01 ETH maximum.");let T=b;if(v&&(await V(i,t.number,[u.launchFee.treasury]),T=q(await c(i,u.launchFee.treasury,_(["function target() view returns (address)"]),"target",[],t.number)),T===b||T===g||T===r||T===He))throw new o("Hookr launch fee recipient is outside the reviewed payment profile.");let Z=v+(e.quote===b?h:0n),ee=[],C=[];if(e.quote!==b){let D=k(await c(i,e.quote,We,"allowance",[r,g],t.number));D!==0n&&D!==h&&C.push(a.approval(e.quote,g,"0",4663)),C.push(a.approval(e.quote,g,h.toString(),4663)),ee.push({token:e.quote,amount:h})}Z&&ee.push({token:be,amount:Z,to:g});let ke=`Launch public, permanent token ${JSON.stringify(e.token.name)} (${JSON.stringify(e.token.symbol)}), fixed supply ${Ae(e.token.supply,18)} (18 decimals). Create one agents-only pool (identity check on every buy). Price currency1/currency0 = ${e.sqrtPriceX96*e.sqrtPriceX96}/${1n<<192n}; sqrtPriceX96 ${e.sqrtPriceX96}, ticks ${e.tickLower} to ${e.tickUpper}, spacing ${y.tickSpacing}. Deposit at most ${e.amount0Max} currency0 and ${e.amount1Max} currency1 base units; exact launch debts ${e.debts.amount0} and ${e.debts.amount1}. Currency0 ${p.currency0}; currency1 ${p.currency1}. Launch fee ${v} wei to ${T} (${Ae(v,18)} ETH). Unused quote funding (${h-S} base units) and retained token supply (${e.token.supply-F} base units) return to ${r} in this transaction. Family owner ${r}; token ${s}; pool ${m}. LP base fee 3000 pips; gate flags 1, scores ${e.gateTerms.minScore}/${e.gateTerms.tierScore}, tier ${e.gateTerms.tierPips} pips; LP Rewards ${e.lpRewardsBps} bps; burn 0; quote-take cap ${J} pips (includes Hookr minimum); protocol share ${E} bps. Arb recapture ${e.arbRecapture}; deadline ${e.deadline}. No lock.`;C.push(a.unsignedTx({to:g,data:Qe({abi:f("launcherV1"),functionName:"launchAdvised",args:[e.token,I,[we],[_e(Je,[e.gateTerms])],e.deadline]}),value:Z.toString(),chainId:4663,description:ke}));let[fe,De,Ke]=await Promise.all([i.getCode({address:s}),i.getTransactionCount({address:s}),i.readContract({address:g,abi:ve,functionName:"launchFee"})]);if(fe&&fe!=="0x"||De!==0||k(H(Ke,5)[0])!==v)throw new o("Hookr collision state or launch fee changed. Request a fresh launch preview.");return await Le(i,t),{txs:C,inputs:ee,summary:ke,tokenAddress:s,poolId:m,feeTarget:T,feeTreasury:u.launchFee.treasury,terms:ie({request:n,blockNumber:t.number,blockHash:t.hash,owner:r,tokenAddress:s,poolId:m,poolKey:p,member:we,gateTerms:e.gateTerms,launchFee:v,feeTarget:T,feeTreasury:u.launchFee.treasury,hookrMinimumPips:G,exactApprovals:C.slice(0,-1),refunds:{quote:h-S,retainedSupply:e.token.supply-F},gasEstimate:null,gasEstimateReason:"The local sender estimates the ordered exact calls after funding approvals and confirms the gas limit and maximum fee.",lane:he,pins:K})}}function nt(a){if(!Array.isArray(a)||a.length<1||a.length>3)throw new o("Hookr launch requires only the locally reconstructed finite approvals and one launch transaction.");for(let n of a)A(n,["to","data","value","chainId","description"],["to","data","value","chainId","description"])}function mt(a,n){if(nt(a),a.length!==n.length||a.some((r,e)=>r.to.toLowerCase()!==n[e].to.toLowerCase()||r.data.toLowerCase()!==n[e].data.toLowerCase()||r.value!==n[e].value||r.chainId!==4663))throw new o("Hookr launch differs from the locally reconstructed exact parameters, approvals and funding.")}function ht(a){return[{name:Ge,inputSchema:ae,execute:async(n,r)=>{let e=await tt(a,n,r);return{txs:e.txs,preview:await a.preview(e.txs,r),terms:e.terms,summary:e.summary}}}]}export{Ge as a,g as b,z as c,ae as d,Ye as e,tt as f,nt as g,mt as h,ht as i};
@@ -1 +1 @@
1
- import{b as R}from"./W2OJ57ZO.js";import{a as w}from"./PBQSJSZO.js";import{g as S}from"./5KUWLUPM.js";import{a as o,i as k,j as v}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{encodeFunctionData as x,getAddress as h,keccak256 as A,parseAbi as O,parseAbiItem as T,toHex as C,zeroHash as E}from"viem";var i=h(k[o].vaults.spark.address),g={admin:E,setter:A(C("SETTER_ROLE")),taker:A(C("TAKER_ROLE"))},D=[["drip()","any"],["setVsr(uint256 rate)","setter"],["setVsrBounds(uint256 minimum,uint256 maximum)","admin"],["setDepositCap(uint256 cap)","admin"],["take(uint256 assets)","taker"],["grantRole(bytes32 role,address account)","admin"],["revokeRole(bytes32 role,address account)","admin"],["renounceRole(bytes32 role,address account)","any"],["upgradeToAndCall(address implementation,bytes data)","admin"]],N=D.map(([r,a])=>({abi:T(`function ${r}`),authority:a})),p=O(["function asset() view returns (address)","function hasRole(bytes32,address) view returns (bool)","function getRoleMemberCount(bytes32) view returns (uint256)","function getRoleMember(bytes32,uint256) view returns (address)"]);function _(r){return[{name:"spark_roles",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(a,s)=>{try{if(w(s),Object.keys(a).length)throw new t("Spark roles takes no arguments.");let e=r.clientFor(o);if(await e.getChainId()!==o)throw new t("Spark requires chain 4663.");let u=await e.getBlockNumber({cacheTime:0}),c=await Promise.all(Object.entries(g).map(async([f,d])=>{let l=await e.readContract({address:i,abi:p,functionName:"getRoleMemberCount",args:[d],blockNumber:u});if(l>256n)throw new t("Spark role membership exceeds this reader\u2019s supported size.");let[b,n]=await Promise.all([e.readContract({address:i,abi:p,functionName:"hasRole",args:[d,s],blockNumber:u}),Promise.all(Array.from({length:Number(l)},(y,m)=>e.readContract({address:i,abi:p,functionName:"getRoleMember",args:[d,BigInt(m)],blockNumber:u})))]);return{name:f,role:d,heldByWallet:b,members:n.map(y=>h(y))}}));return{vault:i,chainId:o,blockNumber:u.toString(),roles:c}}catch(e){throw new t(r.plainError(e))}}},{name:"spark_manage",inputSchema:{type:"object",additionalProperties:!1,required:["operation","values"],properties:{operation:{type:"string",enum:N.map(a=>a.abi.name)},values:{type:"array",maxItems:2,items:{type:"string"},description:"Ordered contract inputs; all integers are decimal base-unit strings."}}},execute:async(a,s)=>{try{if(w(s),Object.keys(a).some(n=>!["operation","values"].includes(n)))throw new t("Unexpected Spark management argument.");let e=N.find(n=>n.abi.name===a.operation);if(!e||!Array.isArray(a.values)||a.values.length!==e.abi.inputs.length)throw new t("Provide a supported Spark operation and its exact ordered values.");let u=e.abi.inputs.map((n,y)=>{let m=a.values[y];if(n.type==="bytes32"){if(typeof m!="string"||!Object.values(g).includes(m))throw new t("Provide a documented Spark role identifier.");return m}return R(n.type,m)});if(e.abi.name==="renounceRole"&&!S(String(u[1]),s))throw new t("Role renunciation must name this wallet.");let c=r.clientFor(o);if(await c.getChainId()!==o)throw new t("Spark requires chain 4663.");let f=await c.readContract({address:i,abi:p,functionName:"asset"});if(h(f)!==h(v))throw new t("Spark does not use canonical USDG.");if(e.authority!=="any"&&await c.readContract({address:i,abi:p,functionName:"hasRole",args:[g[e.authority],s]})!==!0)throw new t("This wallet does not hold the required Spark role. No transaction was built.");let d=`${e.abi.name} on Spark ${i}; ordered values ${JSON.stringify(a.values)}. ${e.abi.name==="upgradeToAndCall"?"Replaces vault implementation; Oak must review and re-pin upgraded code before subsequent use.":e.abi.name==="take"?"Pulls vault liquidity to this role-authorized wallet; it mints no savings shares.":""}`,l=[r.unsignedTx({to:i,data:x({abi:[e.abi],functionName:e.abi.name,args:u}),value:"0",chainId:o,description:d})],b=await r.preview(l,s);return{txs:l,preview:b,summary:`${d} ${b.summary} Role and rate bounds are enforced again by the contract at execution.`}}catch(e){throw new t(r.plainError(e))}}}]}export{N as a,_ as b};
1
+ import{b as R}from"./VYAJXLND.js";import{a as w}from"./43LI5NKJ.js";import{g as S}from"./NWNYJ26T.js";import{a as o,i as k,j as v}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{encodeFunctionData as x,getAddress as h,keccak256 as A,parseAbi as O,parseAbiItem as T,toHex as C,zeroHash as E}from"viem";var i=h(k[o].vaults.spark.address),g={admin:E,setter:A(C("SETTER_ROLE")),taker:A(C("TAKER_ROLE"))},D=[["drip()","any"],["setVsr(uint256 rate)","setter"],["setVsrBounds(uint256 minimum,uint256 maximum)","admin"],["setDepositCap(uint256 cap)","admin"],["take(uint256 assets)","taker"],["grantRole(bytes32 role,address account)","admin"],["revokeRole(bytes32 role,address account)","admin"],["renounceRole(bytes32 role,address account)","any"],["upgradeToAndCall(address implementation,bytes data)","admin"]],N=D.map(([r,a])=>({abi:T(`function ${r}`),authority:a})),p=O(["function asset() view returns (address)","function hasRole(bytes32,address) view returns (bool)","function getRoleMemberCount(bytes32) view returns (uint256)","function getRoleMember(bytes32,uint256) view returns (address)"]);function _(r){return[{name:"spark_roles",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async(a,s)=>{try{if(w(s),Object.keys(a).length)throw new t("Spark roles takes no arguments.");let e=r.clientFor(o);if(await e.getChainId()!==o)throw new t("Spark requires chain 4663.");let u=await e.getBlockNumber({cacheTime:0}),c=await Promise.all(Object.entries(g).map(async([f,d])=>{let l=await e.readContract({address:i,abi:p,functionName:"getRoleMemberCount",args:[d],blockNumber:u});if(l>256n)throw new t("Spark role membership exceeds this reader\u2019s supported size.");let[b,n]=await Promise.all([e.readContract({address:i,abi:p,functionName:"hasRole",args:[d,s],blockNumber:u}),Promise.all(Array.from({length:Number(l)},(y,m)=>e.readContract({address:i,abi:p,functionName:"getRoleMember",args:[d,BigInt(m)],blockNumber:u})))]);return{name:f,role:d,heldByWallet:b,members:n.map(y=>h(y))}}));return{vault:i,chainId:o,blockNumber:u.toString(),roles:c}}catch(e){throw new t(r.plainError(e))}}},{name:"spark_manage",inputSchema:{type:"object",additionalProperties:!1,required:["operation","values"],properties:{operation:{type:"string",enum:N.map(a=>a.abi.name)},values:{type:"array",maxItems:2,items:{type:"string"},description:"Ordered contract inputs; all integers are decimal base-unit strings."}}},execute:async(a,s)=>{try{if(w(s),Object.keys(a).some(n=>!["operation","values"].includes(n)))throw new t("Unexpected Spark management argument.");let e=N.find(n=>n.abi.name===a.operation);if(!e||!Array.isArray(a.values)||a.values.length!==e.abi.inputs.length)throw new t("Provide a supported Spark operation and its exact ordered values.");let u=e.abi.inputs.map((n,y)=>{let m=a.values[y];if(n.type==="bytes32"){if(typeof m!="string"||!Object.values(g).includes(m))throw new t("Provide a documented Spark role identifier.");return m}return R(n.type,m)});if(e.abi.name==="renounceRole"&&!S(String(u[1]),s))throw new t("Role renunciation must name this wallet.");let c=r.clientFor(o);if(await c.getChainId()!==o)throw new t("Spark requires chain 4663.");let f=await c.readContract({address:i,abi:p,functionName:"asset"});if(h(f)!==h(v))throw new t("Spark does not use canonical USDG.");if(e.authority!=="any"&&await c.readContract({address:i,abi:p,functionName:"hasRole",args:[g[e.authority],s]})!==!0)throw new t("This wallet does not hold the required Spark role. No transaction was built.");let d=`${e.abi.name} on Spark ${i}; ordered values ${JSON.stringify(a.values)}. ${e.abi.name==="upgradeToAndCall"?"Replaces vault implementation; Oak must review and re-pin upgraded code before subsequent use.":e.abi.name==="take"?"Pulls vault liquidity to this role-authorized wallet; it mints no savings shares.":""}`,l=[r.unsignedTx({to:i,data:x({abi:[e.abi],functionName:e.abi.name,args:u}),value:"0",chainId:o,description:d})],b=await r.preview(l,s);return{txs:l,preview:b,summary:`${d} ${b.summary} Role and rate bounds are enforced again by the contract at execution.`}}catch(e){throw new t(r.plainError(e))}}}]}export{N as a,_ as b};
@@ -0,0 +1 @@
1
+ import{a as U,b as N,c as _}from"./HKEMQBFA.js";import{e as S}from"./Q42YI3EP.js";import{b as k,c as R}from"./QU5XKRGK.js";import{a as q,c as f,d as h,f as I,g as D}from"./4HG6FRVH.js";import{g as B}from"./H43RNCX2.js";import{a as b,c as O}from"./43LI5NKJ.js";import{b as v}from"./66F5ZH34.js";import{a as A}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as $}from"viem";var K=a=>{function w(e,n){if(Object.keys(e).some(m=>!n.includes(m)))throw new s("Use only the inputs shown for this Pendle tool. YT and LP actions are not supported.")}function j(e){if(typeof e!="string"||!/^[0-9]+$/.test(e)||e.length>78)throw new s("Provide a positive decimal base-unit amount as a string.");return k(BigInt(e),!0)}function C(e,n){let m=e==="stable"?100:200,r=n===void 0?e==="stable"?50:100:n;if(typeof r!="number"||!Number.isInteger(r)||r<0)throw new s("Slippage must be a whole number of basis points.");if(r>m)throw new s(`Oak won't accept a price move that big. The most it allows is ${m/100}%.`);return r}async function y(e,n,m){w(n,["market","amount","slippageBps"]),f(h(m,a.wallet),"wallet does not match this request"),b(n.market);for(let r=0;r<2;r++){let t=await a.verify(n.market);f(h(t.market,n.market),"verified market does not match the request");let d=await a.client.getBlock();if(t.expired||d.timestamp>=BigInt(t.expiry))throw new s("This Pendle term has ended. Use pendle_redeem to cash out.");let p=C(t.kind,n.slippageBps),o=e==="sell"&&n.amount==="max"?k(await a.client.readContract({address:t.pt,abi:$,functionName:"balanceOf",args:[a.wallet],blockNumber:d.number}),!0):j(n.amount),i=e==="buy"?t.inputToken:t.pt,l=e==="buy"?t.pt:t.inputToken,u=await B(a.http,{inputToken:i,outputToken:l,amount:o,wallet:a.wallet,slippageBps:p}),c=(e==="buy"?I:D)(u.body,{market:t,wallet:a.wallet,amount:o,slippageBps:p});if(Math.abs(c.priceImpact)>.03)throw new s("This is a thin market and your size moves the price too much. Try a smaller amount.");if(Date.now()-u.receivedAt>3e4)continue;await R(a.client,t,e,o,c.amountOut,c.priceImpact);let T=Date.now()-u.receivedAt;if(T<0||T>3e4)continue;let x=e==="sell"?{wallet:a.wallet,market:t.market,pt:t.pt,outputToken:l,amountIn:o.toString(),amountOut:c.amountOut.toString(),minOut:c.minOut.toString(),ptDecimals:t.ptDecimals,outputDecimals:t.inputDecimals,endsAt:t.expiry,feeUsd:c.feeUsd,receivedAt:u.receivedAt,data:c.tx.data}:void 0;return{txs:[O(i,q,o.toString(),A),c.tx],...x?{pendleSellQuote:x}:{},summary:e==="buy"?"Approve the exact input amount, then buy Pendle PT.":"Approve the exact PT amount, then sell early at today\u2019s market price."}}throw new s("Pendle\u2019s quote became too old. Try again for a fresh price.")}async function M(e,n){w(e,["market","minOutBps"]),f(h(n,a.wallet),"wallet does not match this request");let m=U(e.minOutBps),r;if(e.market==="all")try{r=await S(a.client)}catch{throw new s("Oak could not read ended Pendle markets from the chain. Provide one ended market address to cash it out.")}else b(e.market),r=[e.market];let t=[];for(let o of r){let i=await a.verify(o);if(f(h(i.market,o),"verified market does not match the request"),e.market==="all"&&!i.expired)continue;let l=k(await a.client.readContract({address:i.pt,abi:$,functionName:"balanceOf",args:[a.wallet]}));l!==0n&&t.push({verified:i,balance:l})}if(t.length>1)throw new s(`Ended Pendle terms are cashed out one at a time. Run pendle_redeem with one of these market addresses: ${t.map(({verified:o})=>o.market).join(", ")}.`);let d=[],p=[];for(let{verified:o,balance:i}of t){let l=await N(a,o,i,m);d.push(...l.txs);let u=await _(a,o,i,l.expected,m);u&&p.push(u)}return{txs:d,summary:d.length?["Cash out ended Pendle PT balances to each market\u2019s input token.",...p].join(" "):"No PT balance in the selected ended Pendle terms."}}let g={type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Pendle market address returned by pendle_list."},P={type:"integer",minimum:0,maximum:200,description:"USDG: default 50, cap 100 bps. Stock tokens: default 100, cap 200 bps; the verified market determines the cap."};return[{name:"pendle_buy",inputSchema:{type:"object",properties:{market:g,amount:v("Positive decimal base units of the market input token; read its decimals first."),slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("buy",e,n)},{name:"pendle_sell",inputSchema:{type:"object",properties:{market:g,amount:{type:"string",anyOf:[{pattern:"^[0-9]+$"},{const:"max"}],description:"PT decimal base units, or max for the full PT balance."},slippageBps:P},required:["market","amount"],additionalProperties:!1},execute:(e,n)=>y("sell",e,n)},{name:"pendle_redeem",inputSchema:{type:"object",properties:{market:{type:"string",anyOf:[{pattern:"^0x[0-9a-fA-F]{40}$"},{const:"all"}],description:"Ended market address, or all ended markets held by this wallet."},minOutBps:{type:"integer",minimum:0,maximum:50,default:10,description:"Maximum reduction from the on-chain redemption estimate, in basis points."}},required:["market"],additionalProperties:!1},execute:M}]};export{K as a};
@@ -1 +1 @@
1
- import{b as q,o as U}from"./GHPREYQK.js";import{a as le,b as ue,c as me}from"./ZET37EIG.js";import{a as ce}from"./MBTARLZQ.js";import{a as fe,b as pe}from"./RNC463IM.js";import{a as ye}from"./3VAJW6TQ.js";import{e as F,h as O,m as de}from"./W76QC2AW.js";import{b as se}from"./Z4SRGAVL.js";import{a as B}from"./BQICZFLR.js";import{c as ae}from"./MYFAKCQI.js";import{c as D,e as x,g as k,k as te,l as oe,m as re,n as ie}from"./5KUWLUPM.js";import{a as h,i as ne}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeAbiParameters as j,encodeFunctionData as M,erc20Abi as J,isAddress as Pe,parseAbi as Ae,parseAbiParameters as V,toHex as W,zeroAddress as z}from"viem";var A=ne[h].clanker,he=Ae(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=Ae(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),C={address:A.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Se="https://www.clanker.world/api/tokens",ge={type:"string",pattern:"^\\d+$"},be={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function I(e){return oe(te(e,F),F)}function we(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i(`Provide an explicit bytes32 ${t}.`);return e}function P(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new i(`Provide ${t} as text.`);return e}function Z(e,t=256){return ie(e,`Amount exceeds the uint${t} range.`,{bits:t})}function G(e){return re(e,"The contract returned an invalid amount.").toString()}function L(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new i(`Unsupported Clanker input: ${s}.`)}function ke(e,t){return t.changes.map(({token:s,amount:u})=>{let b=u.startsWith("-");return`${b?"-":"+"}${e.formatAmount(b?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function ve(e){return x(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Pe(t[s],{strict:!1})))}function K(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>K(s,t+1)):x(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,K(u,t+1)])):null}function _e(e){return{...K(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!x(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new i("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){L(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new i("Choose an indexer limit from 1 to 20.");let u=new URL(Se);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",P(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",P(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",I(t.deployer));let b=await ae(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},ve);return{tokens:b.data.filter(S=>S.chain_id===h&&k(S.factory_address,A.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var De=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(o){throw new i(e.plainError(o))}},u=(n,o,a,c="0")=>e.unsignedTx({to:n,data:o,value:c,chainId:h,description:a}),b=async(n,o)=>G(await t().readContract({address:A.fee_locker.address,abi:T,functionName:"availableFees",args:[n,o]})),S=async n=>{if(k(n,C.address))return C;let[o,a]=await Promise.all([t().readContract({address:n,abi:J,functionName:"symbol"}),t().readContract({address:n,abi:J,functionName:"decimals"})]);if(typeof o!="string"||!o.trim()||!Number.isInteger(a)||a<0||a>255)throw new i("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:o,decimals:a}},Q=async n=>{n.cursor!==void 0&&$e(n.cursor);let o=await Ne(e,n);return{...o,tokens:o.tokens.map(_e)}},xe=async(n,o)=>{if(L(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new i("Clanker launches use vanity false and an explicit salt.");let a=P(n.name,"token name",!0),c=P(n.symbol,"token symbol",!0),g=we(n.salt,"salt"),y=Z(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new i("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let r=n.minAmountOut===void 0?void 0:Z(n.minAmountOut,128);if(r!==void 0&&r<=1n)throw new i("Initial-buy minimum must exceed one base unit.");if(!y&&r!==void 0)throw new i("A minimum requires a positive initial buy.");let m=ue(n,o);O(n.feeBps??100,0,1e3);let f=pe(n);if(y&&!k(f.poolConfig.pairedToken,C.address))throw new i("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:o,recipient:o,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new i("Provide one to seven reward allocations.");let w=d.map(p=>{if(!x(p))throw new i("Provide reward allocations as objects.");return L(p,["admin","recipient","bps","feePreference"]),{admin:I(p.admin),recipient:I(p.recipient),bps:O(p.bps,1,1e4),feePreference:O(p.feePreference??0,0,2)}});if(w.reduce((p,v)=>p+v.bps,0)!==1e4)throw new i("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:o,name:a,symbol:c,salt:g,image:P(n.image,"image"),metadata:P(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):P(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:f.poolConfig,lockerConfig:{locker:A.locker.address,rewardAdmins:w.map(p=>p.admin),rewardRecipients:w.map(p=>p.recipient),rewardBps:w.map(p=>p.bps),tickLower:f.tickLower,tickUpper:f.tickUpper,positionBps:f.positionBps,lockerData:j(V("(uint8[])"),[[w.map(p=>p.feePreference)]])},mevModuleConfig:{mevModule:A.mev_module.address,mevModuleData:j(V("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Ce=await t().simulateContract({address:A.factory.address,abi:he,functionName:"deployToken",args:[_],account:o,value:0n,gas:B}),E=I(Ce.result),X=p=>{let v=[...m,...y?[{extension:A.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(V("(address,address,uint24,int24,address),uint128,address"),[[z,z,0,0,z],p,o])}]:[]];return u(A.factory.address,M({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:v}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&r===void 0){let v=(await e.preview([X(0n)],o)).changes.filter($=>$.token.chainId===h&&k($.token.address,E)&&$.token.decimals===18).reduce(($,ee)=>$+(/^-?\d+$/.test(ee.amount)?BigInt(ee.amount):(()=>{throw new i("Invalid initial-buy simulation amount.")})()),0n);if(v<=0n)throw new i("Initial-buy simulation returned no token output.");if(r=Z(U(v.toString(),l),128),r<=1n)throw new i("Initial-buy output is too small for a protected minimum.")}let Y=[X(r??0n)],H=await e.preview(Y,o);return{txs:Y,preview:H,predictedToken:E,token:{address:E,chainId:h,symbol:c,decimals:18},...r!==void 0?{minAmountOut:r.toString()}:{},summary:`Launch ${c} at ${E} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${f.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(f)}. Reward allocations: ${JSON.stringify(w)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${ke(e,H)}`}},Te=async(n,o)=>{if(L(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new i("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new i("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new i("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new i("A pool ID requires its Clanker token.");let a=[C],c=[];if(n.token!==void 0){let r=I(n.token);if(k(r,C.address))throw new i("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await de(e,r),{poolId:f,hook:d,locker:w}=m;if(n.poolId!==void 0&&!k(we(n.poolId,"pool ID for fee collection"),f))throw new i("The supplied pool ID does not match the onchain Clanker pool.");k(m.pairedToken,C.address)||a.splice(0,1,await S(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[f]});if(typeof _!="boolean")throw new i("The hook returned an invalid MEV guard state.");_&&c.push(u(d,M({abi:T,functionName:"mevModuleOperational",args:[f]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(w,M({abi:T,functionName:"collectRewards",args:[r]}),"Collect pending LP fees into the fee locker."))}a.push(await S(r))}let g;if(c.length){if(await t().getChainId()!==h)throw new i("Fee simulation endpoint is on the wrong chain.");let r=[...c.map(d=>({from:o,gas:W(B),to:d.to,data:d.data,value:W(BigInt(d.value))})),...a.map(d=>({from:o,gas:W(B),to:A.fee_locker.address,data:M({abi:T,functionName:"availableFees",args:[o,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:r}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!x(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==r.length)throw new i("The endpoint returned an unexpected fee simulation response.");let f=m[0].calls;if(!f.every(d=>x(d)&&d.status==="0x1"&&!d.error))throw new i("Clanker fee collection simulation failed.");g=f.slice(c.length).map(d=>{if(!x(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new i("The endpoint returned an invalid fee balance.");return G(Ie({abi:T,functionName:"availableFees",data:d.returnData}))})}else g=await Promise.all(a.map(r=>b(o,r.address)));let y=a.flatMap((r,m)=>BigInt(g[m])>0n?[{token:r,amount:g[m]}]:[]);if(!y.length)throw new i("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:r}of y)c.push(u(A.fee_locker.address,M({abi:T,functionName:"claim",args:[o,r.address]}),`Claim ${r.symbol} fees to ${o}.`));let l=await e.preview(c,o);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${o}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${ke(e,l)}`}},R=(n,o,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:o,required:a,additionalProperties:!1},execute:(g,y)=>s(async()=>c(g,I(y)))});return{tools:[R("launch",{name:{type:"string"},symbol:{type:"string"},salt:be,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ge,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ge,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:fe,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:D,recipient:D,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...le},["name","symbol","salt"],async(n,o)=>{let a=await xe(n,o);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...D,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...be,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:D},[],Q)],positions:n=>s(async()=>{I(n);let o=new Map,a=new Set,c;do{let l=await Q({deployer:n,limit:20,...c?{cursor:c}:{}});for(let r of l.tokens)k(r.msg_sender,n)&&o.set(r.contract_address.toLowerCase(),r);if(l.cursor&&a.has(l.cursor))throw new i("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let g=[],y=[C];for(let[l,r]of o){let m=await S(r.contract_address),f={...m,symbol:N(m.symbol)},d=G(await t().readContract({address:f.address,abi:J,functionName:"balanceOf",args:[n]}));g.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:f,amount:d}],description:`Indexed launch ${r.name}; wallet token balance, not locked LP principal.`}),y.some(w=>k(w.address,f.address))||y.push(f)}for(let l of y){let r=await b(n,l.address);BigInt(r)>0n&&g.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:r}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},ze=e=>se("clanker",[De(e),ce(e),me(e),ye(e)]);export{Ne as a,De as b,ze as c};
1
+ import{b as q,o as U}from"./BOVMED7R.js";import{a as ce}from"./RUX3RY7Y.js";import{a as fe,b as pe}from"./XBE3B6Y2.js";import{a as ye}from"./RVDUSNWW.js";import{a as le,b as ue,c as me}from"./ZV5HIQXC.js";import{e as F,h as O,m as de}from"./PV5FDT6O.js";import{b as se}from"./SPJCSEKP.js";import{a as B}from"./IOYRL6AY.js";import{c as ae}from"./VEQBHI6O.js";import{c as D,e as x,g as k,k as te,l as oe,m as re,n as ie}from"./NWNYJ26T.js";import{a as h,i as ne}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeAbiParameters as j,encodeFunctionData as M,erc20Abi as J,isAddress as Pe,parseAbi as Ae,parseAbiParameters as V,toHex as W,zeroAddress as z}from"viem";var A=ne[h].clanker,he=Ae(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=Ae(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),C={address:A.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},Se="https://www.clanker.world/api/tokens",ge={type:"string",pattern:"^\\d+$"},be={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function I(e){return oe(te(e,F),F)}function we(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i(`Provide an explicit bytes32 ${t}.`);return e}function P(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new i(`Provide ${t} as text.`);return e}function Z(e,t=256){return ie(e,`Amount exceeds the uint${t} range.`,{bits:t})}function G(e){return re(e,"The contract returned an invalid amount.").toString()}function L(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new i(`Unsupported Clanker input: ${s}.`)}function ke(e,t){return t.changes.map(({token:s,amount:u})=>{let b=u.startsWith("-");return`${b?"-":"+"}${e.formatAmount(b?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function ve(e){return x(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>x(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Pe(t[s],{strict:!1})))}function K(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>K(s,t+1)):x(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,K(u,t+1)])):null}function _e(e){return{...K(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!x(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new i("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){L(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new i("Choose an indexer limit from 1 to 20.");let u=new URL(Se);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",P(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",P(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",I(t.deployer));let b=await ae(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},ve);return{tokens:b.data.filter(S=>S.chain_id===h&&k(S.factory_address,A.factory.address)),total:b.total,cursor:b.cursor||null,tokensDeployed:b.tokensDeployed}}var De=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(o){throw new i(e.plainError(o))}},u=(n,o,a,c="0")=>e.unsignedTx({to:n,data:o,value:c,chainId:h,description:a}),b=async(n,o)=>G(await t().readContract({address:A.fee_locker.address,abi:T,functionName:"availableFees",args:[n,o]})),S=async n=>{if(k(n,C.address))return C;let[o,a]=await Promise.all([t().readContract({address:n,abi:J,functionName:"symbol"}),t().readContract({address:n,abi:J,functionName:"decimals"})]);if(typeof o!="string"||!o.trim()||!Number.isInteger(a)||a<0||a>255)throw new i("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:o,decimals:a}},Q=async n=>{n.cursor!==void 0&&$e(n.cursor);let o=await Ne(e,n);return{...o,tokens:o.tokens.map(_e)}},xe=async(n,o)=>{if(L(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new i("Clanker launches use vanity false and an explicit salt.");let a=P(n.name,"token name",!0),c=P(n.symbol,"token symbol",!0),g=we(n.salt,"salt"),y=Z(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new i("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let r=n.minAmountOut===void 0?void 0:Z(n.minAmountOut,128);if(r!==void 0&&r<=1n)throw new i("Initial-buy minimum must exceed one base unit.");if(!y&&r!==void 0)throw new i("A minimum requires a positive initial buy.");let m=ue(n,o);O(n.feeBps??100,0,1e3);let f=pe(n);if(y&&!k(f.poolConfig.pairedToken,C.address))throw new i("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:o,recipient:o,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new i("Provide one to seven reward allocations.");let w=d.map(p=>{if(!x(p))throw new i("Provide reward allocations as objects.");return L(p,["admin","recipient","bps","feePreference"]),{admin:I(p.admin),recipient:I(p.recipient),bps:O(p.bps,1,1e4),feePreference:O(p.feePreference??0,0,2)}});if(w.reduce((p,v)=>p+v.bps,0)!==1e4)throw new i("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:o,name:a,symbol:c,salt:g,image:P(n.image,"image"),metadata:P(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):P(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:f.poolConfig,lockerConfig:{locker:A.locker.address,rewardAdmins:w.map(p=>p.admin),rewardRecipients:w.map(p=>p.recipient),rewardBps:w.map(p=>p.bps),tickLower:f.tickLower,tickUpper:f.tickUpper,positionBps:f.positionBps,lockerData:j(V("(uint8[])"),[[w.map(p=>p.feePreference)]])},mevModuleConfig:{mevModule:A.mev_module.address,mevModuleData:j(V("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Ce=await t().simulateContract({address:A.factory.address,abi:he,functionName:"deployToken",args:[_],account:o,value:0n,gas:B}),E=I(Ce.result),X=p=>{let v=[...m,...y?[{extension:A.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(V("(address,address,uint24,int24,address),uint128,address"),[[z,z,0,0,z],p,o])}]:[]];return u(A.factory.address,M({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:v}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&r===void 0){let v=(await e.preview([X(0n)],o)).changes.filter($=>$.token.chainId===h&&k($.token.address,E)&&$.token.decimals===18).reduce(($,ee)=>$+(/^-?\d+$/.test(ee.amount)?BigInt(ee.amount):(()=>{throw new i("Invalid initial-buy simulation amount.")})()),0n);if(v<=0n)throw new i("Initial-buy simulation returned no token output.");if(r=Z(U(v.toString(),l),128),r<=1n)throw new i("Initial-buy output is too small for a protected minimum.")}let Y=[X(r??0n)],H=await e.preview(Y,o);return{txs:Y,preview:H,predictedToken:E,token:{address:E,chainId:h,symbol:c,decimals:18},...r!==void 0?{minAmountOut:r.toString()}:{},summary:`Launch ${c} at ${E} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). ${f.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(f)}. Reward allocations: ${JSON.stringify(w)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${ke(e,H)}`}},Te=async(n,o)=>{if(L(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new i("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new i("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new i("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new i("A pool ID requires its Clanker token.");let a=[C],c=[];if(n.token!==void 0){let r=I(n.token);if(k(r,C.address))throw new i("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await de(e,r),{poolId:f,hook:d,locker:w}=m;if(n.poolId!==void 0&&!k(we(n.poolId,"pool ID for fee collection"),f))throw new i("The supplied pool ID does not match the onchain Clanker pool.");k(m.pairedToken,C.address)||a.splice(0,1,await S(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[f]});if(typeof _!="boolean")throw new i("The hook returned an invalid MEV guard state.");_&&c.push(u(d,M({abi:T,functionName:"mevModuleOperational",args:[f]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(w,M({abi:T,functionName:"collectRewards",args:[r]}),"Collect pending LP fees into the fee locker."))}a.push(await S(r))}let g;if(c.length){if(await t().getChainId()!==h)throw new i("Fee simulation endpoint is on the wrong chain.");let r=[...c.map(d=>({from:o,gas:W(B),to:d.to,data:d.data,value:W(BigInt(d.value))})),...a.map(d=>({from:o,gas:W(B),to:A.fee_locker.address,data:M({abi:T,functionName:"availableFees",args:[o,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:r}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!x(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==r.length)throw new i("The endpoint returned an unexpected fee simulation response.");let f=m[0].calls;if(!f.every(d=>x(d)&&d.status==="0x1"&&!d.error))throw new i("Clanker fee collection simulation failed.");g=f.slice(c.length).map(d=>{if(!x(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new i("The endpoint returned an invalid fee balance.");return G(Ie({abi:T,functionName:"availableFees",data:d.returnData}))})}else g=await Promise.all(a.map(r=>b(o,r.address)));let y=a.flatMap((r,m)=>BigInt(g[m])>0n?[{token:r,amount:g[m]}]:[]);if(!y.length)throw new i("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:r}of y)c.push(u(A.fee_locker.address,M({abi:T,functionName:"claim",args:[o,r.address]}),`Claim ${r.symbol} fees to ${o}.`));let l=await e.preview(c,o);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${o}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${ke(e,l)}`}},R=(n,o,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:o,required:a,additionalProperties:!1},execute:(g,y)=>s(async()=>c(g,I(y)))});return{tools:[R("launch",{name:{type:"string"},symbol:{type:"string"},salt:be,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...ge,description:"Native ETH base units, 18 decimals."},minAmountOut:{...ge,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100},pool:fe,rewards:{type:"array",minItems:1,maxItems:7,items:{type:"object",properties:{admin:D,recipient:D,bps:{type:"integer",minimum:1,maximum:1e4},feePreference:{type:"integer",minimum:0,maximum:2}},required:["admin","recipient","bps"],additionalProperties:!1}},...le},["name","symbol","salt"],async(n,o)=>{let a=await xe(n,o);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...D,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...be,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:D},[],Q)],positions:n=>s(async()=>{I(n);let o=new Map,a=new Set,c;do{let l=await Q({deployer:n,limit:20,...c?{cursor:c}:{}});for(let r of l.tokens)k(r.msg_sender,n)&&o.set(r.contract_address.toLowerCase(),r);if(l.cursor&&a.has(l.cursor))throw new i("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let g=[],y=[C];for(let[l,r]of o){let m=await S(r.contract_address),f={...m,symbol:N(m.symbol)},d=G(await t().readContract({address:f.address,abi:J,functionName:"balanceOf",args:[n]}));g.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:f,amount:d}],description:`Indexed launch ${r.name}; wallet token balance, not locked LP principal.`}),y.some(w=>k(w.address,f.address))||y.push(f)}for(let l of y){let r=await b(n,l.address);BigInt(r)>0n&&g.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:r}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},ze=e=>se("clanker",[De(e),ce(e),me(e),ye(e)]);export{Ne as a,De as b,ze as c};