@oakagentkit/core 0.2.6 → 0.2.7

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 (651) hide show
  1. package/build/dist/api/abort-scope.d.ts +2 -0
  2. package/build/dist/api/abort-scope.js +1 -0
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.js +1 -1
  5. package/build/dist/api/http.js +1 -1
  6. package/build/dist/api/metadata.js +1 -1
  7. package/build/dist/api/modules/beefy/boosts.js +1 -1
  8. package/build/dist/api/modules/beefy/clm.js +1 -1
  9. package/build/dist/api/modules/beefy/guard.js +1 -1
  10. package/build/dist/api/modules/beefy/index.js +1 -1
  11. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  12. package/build/dist/api/modules/beefy/management.js +1 -1
  13. package/build/dist/api/modules/beefy/vaults.js +1 -1
  14. package/build/dist/api/modules/borro/actions.js +1 -1
  15. package/build/dist/api/modules/borro/checks.js +1 -1
  16. package/build/dist/api/modules/borro/copy.d.ts +15 -10
  17. package/build/dist/api/modules/borro/copy.js +1 -1
  18. package/build/dist/api/modules/borro/index.js +1 -1
  19. package/build/dist/api/modules/borro/liquidity.js +1 -1
  20. package/build/dist/api/modules/borro/positions.js +1 -1
  21. package/build/dist/api/modules/borro/reader.js +1 -1
  22. package/build/dist/api/modules/chop/abi.d.ts +31 -0
  23. package/build/dist/api/modules/chop/abi.js +1 -1
  24. package/build/dist/api/modules/chop/actions.js +1 -1
  25. package/build/dist/api/modules/chop/checks.d.ts +13 -5
  26. package/build/dist/api/modules/chop/checks.js +1 -1
  27. package/build/dist/api/modules/chop/copy.d.ts +11 -1
  28. package/build/dist/api/modules/chop/copy.js +1 -1
  29. package/build/dist/api/modules/chop/guard.js +1 -1
  30. package/build/dist/api/modules/chop/index.js +1 -1
  31. package/build/dist/api/modules/chop/positions.js +1 -1
  32. package/build/dist/api/modules/chop/reader.d.ts +132 -7
  33. package/build/dist/api/modules/chop/reader.js +1 -1
  34. package/build/dist/api/modules/chop/types.d.ts +12 -0
  35. package/build/dist/api/modules/clanker/extensions.d.ts +9 -0
  36. package/build/dist/api/modules/clanker/extensions.js +1 -1
  37. package/build/dist/api/modules/clanker/index.js +1 -1
  38. package/build/dist/api/modules/clanker/manage.js +1 -1
  39. package/build/dist/api/modules/clanker/pool-config.d.ts +15 -0
  40. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  41. package/build/dist/api/modules/clanker/protocol.js +1 -1
  42. package/build/dist/api/modules/earn/copy.d.ts +32 -10
  43. package/build/dist/api/modules/earn/copy.js +1 -1
  44. package/build/dist/api/modules/earn/cost.d.ts +11 -1
  45. package/build/dist/api/modules/earn/cost.js +1 -1
  46. package/build/dist/api/modules/earn/index.js +1 -1
  47. package/build/dist/api/modules/earn/lp.d.ts +14 -1
  48. package/build/dist/api/modules/earn/lp.js +1 -1
  49. package/build/dist/api/modules/earn/options.d.ts +6 -4
  50. package/build/dist/api/modules/earn/options.js +1 -1
  51. package/build/dist/api/modules/erc8004/common.d.ts +1 -1
  52. package/build/dist/api/modules/erc8004/common.js +1 -1
  53. package/build/dist/api/modules/erc8004/domain.js +1 -1
  54. package/build/dist/api/modules/erc8004/index.js +1 -1
  55. package/build/dist/api/modules/erc8004/management.js +1 -1
  56. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  57. package/build/dist/api/modules/erc8004/services.js +1 -1
  58. package/build/dist/api/modules/erc8004/validation.js +1 -1
  59. package/build/dist/api/modules/factor/abi.d.ts +642 -0
  60. package/build/dist/api/modules/factor/abi.js +1 -0
  61. package/build/dist/api/modules/factor/actions.d.ts +15 -0
  62. package/build/dist/api/modules/factor/actions.js +1 -0
  63. package/build/dist/api/modules/factor/api.d.ts +7 -0
  64. package/build/dist/api/modules/factor/api.js +1 -0
  65. package/build/dist/api/modules/factor/checks.d.ts +11 -0
  66. package/build/dist/api/modules/factor/checks.js +1 -0
  67. package/build/dist/api/modules/factor/copy.d.ts +33 -0
  68. package/build/dist/api/modules/factor/copy.js +1 -0
  69. package/build/dist/api/modules/factor/guard.d.ts +12 -0
  70. package/build/dist/api/modules/factor/guard.js +1 -0
  71. package/build/dist/api/modules/factor/index.d.ts +16 -0
  72. package/build/dist/api/modules/factor/index.js +8 -0
  73. package/build/dist/api/modules/factor/messages.d.ts +46 -0
  74. package/build/dist/api/modules/factor/messages.js +1 -0
  75. package/build/dist/api/modules/factor/pins.d.ts +64 -0
  76. package/build/dist/api/modules/factor/pins.js +1 -0
  77. package/build/dist/api/modules/factor/reader.d.ts +17 -0
  78. package/build/dist/api/modules/factor/reader.js +1 -0
  79. package/build/dist/api/modules/factor/types.d.ts +18 -0
  80. package/build/dist/api/modules/factor/types.js +0 -0
  81. package/build/dist/api/modules/gloam/copy.d.ts +4 -3
  82. package/build/dist/api/modules/gloam/copy.js +2 -2
  83. package/build/dist/api/modules/gloam/index.js +1 -1
  84. package/build/dist/api/modules/grove/index.js +1 -1
  85. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  86. package/build/dist/api/modules/heyresearch/index.js +1 -1
  87. package/build/dist/api/modules/heyresearch/public-reads.d.ts +29 -1
  88. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  89. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  90. package/build/dist/api/modules/heyresearch/status-labels.d.ts +2 -0
  91. package/build/dist/api/modules/heyresearch/status-labels.js +1 -1
  92. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  93. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  94. package/build/dist/api/modules/hoodag/index.js +1 -1
  95. package/build/dist/api/modules/hoodag/management.js +1 -1
  96. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  97. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  98. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  99. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  100. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  101. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  102. package/build/dist/api/modules/hoodlock/index.js +1 -1
  103. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  104. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  105. package/build/dist/api/modules/hoodlock/public.js +1 -1
  106. package/build/dist/api/modules/hookr/actions.js +1 -1
  107. package/build/dist/api/modules/hookr/addons.js +1 -1
  108. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  109. package/build/dist/api/modules/hookr/contracts.d.ts +2 -1
  110. package/build/dist/api/modules/hookr/contracts.js +1 -1
  111. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  112. package/build/dist/api/modules/hookr/discovery.js +1 -1
  113. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  114. package/build/dist/api/modules/hookr/index.js +1 -1
  115. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  116. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  117. package/build/dist/api/modules/hookr/launch.js +1 -1
  118. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  119. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  120. package/build/dist/api/modules/hookr/lp-reads.d.ts +2 -0
  121. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  122. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  123. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  124. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  125. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  126. package/build/dist/api/modules/hookr/relay.js +1 -1
  127. package/build/dist/api/modules/hookr/revenue.js +1 -1
  128. package/build/dist/api/modules/kyberswap/index.js +1 -1
  129. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  130. package/build/dist/api/modules/layerbank/actions.js +1 -1
  131. package/build/dist/api/modules/layerbank/index.js +1 -1
  132. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  133. package/build/dist/api/modules/layerbank/reader.js +1 -1
  134. package/build/dist/api/modules/lighter/index.js +1 -1
  135. package/build/dist/api/modules/longbow/administration.js +1 -1
  136. package/build/dist/api/modules/longbow/fixed.js +1 -1
  137. package/build/dist/api/modules/longbow/index.js +1 -1
  138. package/build/dist/api/modules/longbow/nft.js +1 -1
  139. package/build/dist/api/modules/longbow/rebates.js +1 -1
  140. package/build/dist/api/modules/longbow/staking.js +1 -1
  141. package/build/dist/api/modules/meridian/index.js +1 -1
  142. package/build/dist/api/modules/meridian/markets.js +1 -1
  143. package/build/dist/api/modules/meridian/perps-batch.js +1 -1
  144. package/build/dist/api/modules/meridian/perps-stream.js +1 -1
  145. package/build/dist/api/modules/meridian/perps.js +1 -1
  146. package/build/dist/api/modules/meridian/predict-read.js +1 -1
  147. package/build/dist/api/modules/meridian/rfq.js +1 -1
  148. package/build/dist/api/modules/merkl/discovery.js +1 -1
  149. package/build/dist/api/modules/merkl/index.js +1 -1
  150. package/build/dist/api/modules/merkl/manage.js +1 -1
  151. package/build/dist/api/modules/merkl/protocol.js +1 -1
  152. package/build/dist/api/modules/morpho/allocator.js +1 -1
  153. package/build/dist/api/modules/morpho/bundles.js +1 -1
  154. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  155. package/build/dist/api/modules/morpho/index.js +1 -1
  156. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  157. package/build/dist/api/modules/morpho/midnight.js +1 -1
  158. package/build/dist/api/modules/morpho/protocol.js +1 -1
  159. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  160. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  161. package/build/dist/api/modules/morpho/vault-v2.d.ts +2 -0
  162. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  163. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  164. package/build/dist/api/modules/netnet/card-read.js +1 -1
  165. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  166. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  167. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  168. package/build/dist/api/modules/netnet/financial.js +1 -1
  169. package/build/dist/api/modules/netnet/index.js +1 -1
  170. package/build/dist/api/modules/netnet/staking.js +1 -1
  171. package/build/dist/api/modules/orbio/gateway.js +1 -1
  172. package/build/dist/api/modules/orbio/index.js +1 -1
  173. package/build/dist/api/modules/pendle/convert.js +1 -1
  174. package/build/dist/api/modules/pendle/costs.js +1 -1
  175. package/build/dist/api/modules/pendle/index.js +1 -1
  176. package/build/dist/api/modules/pendle/markets.js +1 -1
  177. package/build/dist/api/modules/pendle/positions.js +1 -1
  178. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  179. package/build/dist/api/modules/pendle/reader.js +1 -1
  180. package/build/dist/api/modules/pendle/redeem.js +1 -1
  181. package/build/dist/api/modules/pendle/trade.js +1 -1
  182. package/build/dist/api/modules/pendle/validate.js +1 -1
  183. package/build/dist/api/modules/pons/claim.js +1 -1
  184. package/build/dist/api/modules/pons/holder-directory.js +1 -1
  185. package/build/dist/api/modules/pons/index.js +1 -1
  186. package/build/dist/api/modules/pons/launch-status.js +1 -1
  187. package/build/dist/api/modules/pons/reads.js +1 -1
  188. package/build/dist/api/modules/pons/trade.d.ts +3 -2
  189. package/build/dist/api/modules/pons/trade.js +1 -1
  190. package/build/dist/api/modules/poolstrade/index.js +1 -1
  191. package/build/dist/api/modules/priors/coverage.js +1 -1
  192. package/build/dist/api/modules/priors/discovery.js +1 -1
  193. package/build/dist/api/modules/priors/features.js +1 -1
  194. package/build/dist/api/modules/priors/holdings.js +1 -1
  195. package/build/dist/api/modules/priors/index.js +1 -1
  196. package/build/dist/api/modules/priors/integration.d.ts +1 -0
  197. package/build/dist/api/modules/priors/integration.js +1 -1
  198. package/build/dist/api/modules/priors/market.js +1 -1
  199. package/build/dist/api/modules/priors/pt.js +1 -1
  200. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  201. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  202. package/build/dist/api/modules/raeto/authorization.d.ts +30 -0
  203. package/build/dist/api/modules/raeto/authorization.js +1 -0
  204. package/build/dist/api/modules/raeto/copy.d.ts +46 -0
  205. package/build/dist/api/modules/raeto/copy.js +1 -0
  206. package/build/dist/api/modules/raeto/errors.d.ts +4 -0
  207. package/build/dist/api/modules/raeto/errors.js +1 -0
  208. package/build/dist/api/modules/raeto/estimate.d.ts +2 -0
  209. package/build/dist/api/modules/raeto/estimate.js +1 -0
  210. package/build/dist/api/modules/raeto/index.d.ts +16 -0
  211. package/build/dist/api/modules/raeto/index.js +1 -0
  212. package/build/dist/api/modules/raeto/pairing.d.ts +40 -0
  213. package/build/dist/api/modules/raeto/pairing.js +1 -0
  214. package/build/dist/api/modules/raeto/pins.d.ts +24 -0
  215. package/build/dist/api/modules/raeto/pins.js +1 -0
  216. package/build/dist/api/modules/raeto/templates.d.ts +22 -0
  217. package/build/dist/api/modules/raeto/templates.js +1 -0
  218. package/build/dist/api/modules/raeto/terms.d.ts +8 -0
  219. package/build/dist/api/modules/raeto/terms.js +1 -0
  220. package/build/dist/api/modules/raeto/types.d.ts +64 -0
  221. package/build/dist/api/modules/raeto/types.js +0 -0
  222. package/build/dist/api/modules/relay/api.d.ts +16 -0
  223. package/build/dist/api/modules/relay/api.js +1 -1
  224. package/build/dist/api/modules/relay/discovery.js +1 -1
  225. package/build/dist/api/modules/relay/inbound.js +1 -1
  226. package/build/dist/api/modules/relay/index.d.ts +1 -0
  227. package/build/dist/api/modules/relay/index.js +1 -1
  228. package/build/dist/api/modules/relay/order.js +1 -1
  229. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  230. package/build/dist/api/modules/relay/readiness.d.ts +1 -0
  231. package/build/dist/api/modules/relay/readiness.js +1 -1
  232. package/build/dist/api/modules/relay/reads.js +1 -1
  233. package/build/dist/api/modules/relay/vaults.js +1 -1
  234. package/build/dist/api/modules/spark/actions.js +1 -1
  235. package/build/dist/api/modules/spark/index.js +1 -1
  236. package/build/dist/api/modules/spark/management.js +1 -1
  237. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  238. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  239. package/build/dist/api/modules/steakhouse/index.js +1 -1
  240. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  241. package/build/dist/api/modules/steakhouse/management.js +1 -1
  242. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  243. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  244. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  245. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  246. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  247. package/build/dist/api/modules/tickerspring/index.js +1 -1
  248. package/build/dist/api/modules/tickerspring/journeys.d.ts +1 -0
  249. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  250. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  251. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  252. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  253. package/build/dist/api/modules/tickerspring/research.js +1 -1
  254. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  255. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  256. package/build/dist/api/modules/uniswap/auction.js +1 -1
  257. package/build/dist/api/modules/uniswap/batch.js +1 -1
  258. package/build/dist/api/modules/uniswap/common.js +1 -1
  259. package/build/dist/api/modules/uniswap/fee-percent.d.ts +4 -0
  260. package/build/dist/api/modules/uniswap/fee-percent.js +1 -0
  261. package/build/dist/api/modules/uniswap/fees.js +1 -1
  262. package/build/dist/api/modules/uniswap/index.js +1 -1
  263. package/build/dist/api/modules/uniswap/local-guard.d.ts +2 -0
  264. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  265. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  266. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  267. package/build/dist/api/modules/uniswap/pools.d.ts +2 -0
  268. package/build/dist/api/modules/uniswap/pools.js +1 -1
  269. package/build/dist/api/modules/uniswap/position.js +1 -1
  270. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  271. package/build/dist/api/modules/uniswap/quote-guard.d.ts +38 -0
  272. package/build/dist/api/modules/uniswap/quote-guard.js +1 -0
  273. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  274. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  275. package/build/dist/api/modules/uniswap/trade.d.ts +10 -3
  276. package/build/dist/api/modules/uniswap/trade.js +1 -1
  277. package/build/dist/api/modules/uniswap/v2.js +1 -1
  278. package/build/dist/api/modules/uniswap/v3.js +1 -1
  279. package/build/dist/api/modules/uniswap/v4.d.ts +6 -0
  280. package/build/dist/api/modules/uniswap/v4.js +1 -1
  281. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  282. package/build/dist/api/modules/velora/claims.js +1 -1
  283. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  284. package/build/dist/api/modules/velora/index.js +1 -1
  285. package/build/dist/api/modules/wormhole/index.js +1 -1
  286. package/build/dist/api/modules/wormhole/scan-text.js +1 -1
  287. package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -1
  288. package/build/dist/api/modules/wormhole/third-party-text.d.ts +14 -3
  289. package/build/dist/api/modules/wormhole/third-party-text.js +1 -1
  290. package/build/dist/api/modules/wormhole/token-check.js +1 -1
  291. package/build/dist/api/modules/wormhole/x402-client.js +1 -1
  292. package/build/dist/api/oak-fee.d.ts +12 -0
  293. package/build/dist/api/oak-fee.js +1 -0
  294. package/build/dist/api/param-text.d.ts +22 -0
  295. package/build/dist/api/param-text.js +1 -0
  296. package/build/dist/api/position-economics.d.ts +70 -0
  297. package/build/dist/api/position-economics.js +1 -0
  298. package/build/dist/api/positions.d.ts +8 -5
  299. package/build/dist/api/positions.js +1 -1
  300. package/build/dist/api/prices.d.ts +3 -0
  301. package/build/dist/api/prices.js +1 -1
  302. package/build/dist/api/progress.d.ts +7 -0
  303. package/build/dist/api/progress.js +1 -0
  304. package/build/dist/api/read-budgets.d.ts +4 -0
  305. package/build/dist/api/read-budgets.js +1 -0
  306. package/build/dist/api/read-shape.d.ts +45 -0
  307. package/build/dist/api/read-shape.js +1 -0
  308. package/build/dist/api/revert.d.ts +23 -0
  309. package/build/dist/api/revert.js +1 -0
  310. package/build/dist/api/routes.js +1 -1
  311. package/build/dist/api/rpc.d.ts +1 -0
  312. package/build/dist/api/rpc.js +1 -1
  313. package/build/dist/api/secret-fields.js +1 -1
  314. package/build/dist/api/send.js +1 -1
  315. package/build/dist/api/signing-registry.d.ts +8 -0
  316. package/build/dist/api/signing-registry.js +1 -1
  317. package/build/dist/api/simulate.js +1 -1
  318. package/build/dist/api/swap.d.ts +4 -0
  319. package/build/dist/api/swap.js +1 -1
  320. package/build/dist/api/tokens.d.ts +1 -0
  321. package/build/dist/api/tokens.js +1 -1
  322. package/build/dist/api/tool-policy.js +1 -1
  323. package/build/dist/api/types.d.ts +3 -0
  324. package/build/dist/api/untrusted-unwrap.d.ts +1 -0
  325. package/build/dist/api/untrusted-unwrap.js +1 -0
  326. package/build/dist/api/usd-estimate.d.ts +23 -0
  327. package/build/dist/api/usd-estimate.js +1 -0
  328. package/build/dist/api/vendor-limits.js +1 -1
  329. package/build/dist/chunks/{T7TFUH5K.js → 2E4I7CJ7.js} +1 -1
  330. package/build/dist/chunks/2FHELZ7Y.js +1 -0
  331. package/build/dist/chunks/2GXHYI23.js +1 -0
  332. package/build/dist/chunks/2LWBN35N.js +1 -0
  333. package/build/dist/chunks/{4HG6FRVH.js → 2OKYXT25.js} +1 -1
  334. package/build/dist/chunks/2SUHQWND.js +1 -0
  335. package/build/dist/chunks/2ZWKIBJT.js +1 -0
  336. package/build/dist/chunks/32RXFUOH.js +1 -0
  337. package/build/dist/chunks/3CH2IPQL.js +1 -0
  338. package/build/dist/chunks/3DNJTJ2X.js +1 -0
  339. package/build/dist/chunks/3K2N5VFH.js +1 -0
  340. package/build/dist/chunks/3VBIRLU3.js +1 -0
  341. package/build/dist/chunks/3ZABD6ZF.js +2 -0
  342. package/build/dist/chunks/44MB6SA6.js +1 -0
  343. package/build/dist/chunks/4D4ZRZUW.js +1 -0
  344. package/build/dist/chunks/{IPN6Z4JM.js → 4FPV4CRC.js} +1 -1
  345. package/build/dist/chunks/4GNUXN4K.js +1 -0
  346. package/build/dist/chunks/{K4DHHQBI.js → 4JRXEN7C.js} +2 -2
  347. package/build/dist/chunks/4JTTA3BX.js +1 -0
  348. package/build/dist/chunks/4OVIMYNH.js +2 -0
  349. package/build/dist/chunks/{7QIO77VE.js → 4Q2ZBZXM.js} +1 -1
  350. package/build/dist/chunks/4RQAOOO2.js +1 -0
  351. package/build/dist/chunks/4TTDAF4B.js +1 -0
  352. package/build/dist/chunks/523ZIR3J.js +1 -0
  353. package/build/dist/chunks/5DPJQCKJ.js +68 -0
  354. package/build/dist/chunks/5HIHUYA4.js +1 -0
  355. package/build/dist/chunks/5PI57UC2.js +1 -0
  356. package/build/dist/chunks/5RXALTDT.js +1 -0
  357. package/build/dist/chunks/5TUXSOMI.js +1 -0
  358. package/build/dist/chunks/5UAXLWJ2.js +1 -0
  359. package/build/dist/chunks/5XAXJEWM.js +5 -0
  360. package/build/dist/chunks/67BWOVET.js +1 -0
  361. package/build/dist/chunks/6NUNCD5J.js +1 -0
  362. package/build/dist/chunks/{FJ4S4GHY.js → 6PZGDVHV.js} +1 -1
  363. package/build/dist/chunks/{RTAHNWHN.js → 6UVGQYZ3.js} +1 -1
  364. package/build/dist/chunks/753HZZTY.js +1 -0
  365. package/build/dist/chunks/7D73A6KS.js +1 -0
  366. package/build/dist/chunks/7MBVTNLU.js +1 -0
  367. package/build/dist/chunks/7QKYDNF6.js +18 -0
  368. package/build/dist/chunks/7VC53B5X.js +70 -0
  369. package/build/dist/chunks/7VNO46LV.js +1 -0
  370. package/build/dist/chunks/ACH4BSME.js +3 -0
  371. package/build/dist/chunks/AHUCYDBC.js +1 -0
  372. package/build/dist/chunks/AI3VAPA3.js +1 -0
  373. package/build/dist/chunks/AMTRDPVO.js +1 -0
  374. package/build/dist/chunks/APHNOGNS.js +1 -0
  375. package/build/dist/chunks/{BND2UFVW.js → ARI72OYT.js} +1 -1
  376. package/build/dist/chunks/ARLGF5MU.js +1 -0
  377. package/build/dist/chunks/BAIY32AV.js +1 -0
  378. package/build/dist/chunks/BB765L75.js +3 -0
  379. package/build/dist/chunks/BE3A7677.js +1 -0
  380. package/build/dist/chunks/{PAY5PD4H.js → BX46C5ZP.js} +1 -1
  381. package/build/dist/chunks/{XL3LLGIR.js → BZ34ZR65.js} +1 -1
  382. package/build/dist/chunks/C3WBHFLX.js +1 -0
  383. package/build/dist/chunks/C75MT5SD.js +1 -0
  384. package/build/dist/chunks/CAWTAR5V.js +1 -0
  385. package/build/dist/chunks/CNLL4NCR.js +1 -0
  386. package/build/dist/chunks/CO4GCF4L.js +1 -0
  387. package/build/dist/chunks/{P5PYFK7L.js → CQ5WRWV4.js} +1 -1
  388. package/build/dist/chunks/{SJJR4ZBZ.js → CSDN4MYP.js} +1 -1
  389. package/build/dist/chunks/CSOO4SW7.js +1 -0
  390. package/build/dist/chunks/CZL6T2ZQ.js +1 -0
  391. package/build/dist/chunks/D742AYEV.js +1 -0
  392. package/build/dist/chunks/DGCJZ3HO.js +1 -0
  393. package/build/dist/chunks/DNNFKDZR.js +1 -0
  394. package/build/dist/chunks/DPE7SPW7.js +1 -0
  395. package/build/dist/chunks/DSTMEY5F.js +1 -0
  396. package/build/dist/chunks/{FUDAXV5X.js → DYYEA5HB.js} +1 -1
  397. package/build/dist/chunks/EFESPGA2.js +1 -0
  398. package/build/dist/chunks/EGZREEG2.js +1 -0
  399. package/build/dist/chunks/EH5G4O3U.js +1 -0
  400. package/build/dist/chunks/EI6GGPDS.js +20 -0
  401. package/build/dist/chunks/EVBHQQQG.js +1 -0
  402. package/build/dist/chunks/EZZM2GQT.js +2 -0
  403. package/build/dist/chunks/F3VDVTMS.js +1 -0
  404. package/build/dist/chunks/F4UQEPJT.js +1 -0
  405. package/build/dist/chunks/FHTNMGFR.js +1 -0
  406. package/build/dist/chunks/FJLJ7ZQ5.js +1 -0
  407. package/build/dist/chunks/{WP6RHXGN.js → FL5SSHUL.js} +1 -1
  408. package/build/dist/chunks/FNGIJKMZ.js +1 -0
  409. package/build/dist/chunks/{KIFZ5ZSK.js → FOD34G2H.js} +1 -1
  410. package/build/dist/chunks/{WV3A3OUU.js → FOKEFXGP.js} +1 -1
  411. package/build/dist/chunks/FV4WZOTD.js +1 -0
  412. package/build/dist/chunks/FWIFTPSE.js +2 -0
  413. package/build/dist/chunks/FZ6IJZZM.js +1 -0
  414. package/build/dist/chunks/G2LAO23N.js +1 -0
  415. package/build/dist/chunks/GDRQ2ANN.js +1 -0
  416. package/build/dist/chunks/GG24LO2R.js +1 -0
  417. package/build/dist/chunks/GLF7WEY2.js +1 -0
  418. package/build/dist/chunks/GQ3XZFRL.js +1 -0
  419. package/build/dist/chunks/{QU5XKRGK.js → GQYV4TFO.js} +1 -1
  420. package/build/dist/chunks/GRSXWQWD.js +1 -0
  421. package/build/dist/chunks/{DL6AEWEM.js → GSFHM5L3.js} +1 -1
  422. package/build/dist/chunks/{QHBS3PVU.js → H5DY7CNB.js} +1 -1
  423. package/build/dist/chunks/HCBX4NFM.js +1 -0
  424. package/build/dist/chunks/HHO5ISMM.js +1 -0
  425. package/build/dist/chunks/HIX5N25Z.js +1 -0
  426. package/build/dist/chunks/HKVQ646Q.js +1 -0
  427. package/build/dist/chunks/IEG6GLFR.js +1 -0
  428. package/build/dist/chunks/INOYMBWE.js +1 -0
  429. package/build/dist/chunks/IV4K7FMD.js +1 -0
  430. package/build/dist/chunks/{PIIHOXWF.js → J73ATSEQ.js} +1 -1
  431. package/build/dist/chunks/JBTOZ6IH.js +1 -0
  432. package/build/dist/chunks/JESMX2UC.js +1 -0
  433. package/build/dist/chunks/JJGZ7W3V.js +1 -0
  434. package/build/dist/chunks/JKRBGAX2.js +1 -0
  435. package/build/dist/chunks/JLRHM2DQ.js +1 -0
  436. package/build/dist/chunks/JOKL5L6X.js +1 -0
  437. package/build/dist/chunks/JS53DQVT.js +1 -0
  438. package/build/dist/chunks/{WIRBCS4W.js → JWR5XVP2.js} +1 -1
  439. package/build/dist/chunks/{JFYBH3DX.js → K6D6SDIG.js} +1 -1
  440. package/build/dist/chunks/K7HTDKAT.js +1 -0
  441. package/build/dist/chunks/{2VXLVXIB.js → KDGSYNOP.js} +1 -1
  442. package/build/dist/chunks/KKPMOAVI.js +1 -0
  443. package/build/dist/chunks/KREBNL2D.js +1 -0
  444. package/build/dist/chunks/L646YWDP.js +1 -0
  445. package/build/dist/chunks/{GSBIERZD.js → LR4XTZ37.js} +1 -1
  446. package/build/dist/chunks/LVFI74ST.js +1 -0
  447. package/build/dist/chunks/{QBIY6FQN.js → M7ZXDLKM.js} +1 -1
  448. package/build/dist/chunks/MVD3KWPP.js +1 -0
  449. package/build/dist/chunks/N245WC5R.js +1 -0
  450. package/build/dist/chunks/{WTXC3XKW.js → N4XNNXOJ.js} +1 -1
  451. package/build/dist/chunks/N6GIC7HJ.js +1 -0
  452. package/build/dist/chunks/{RUC7KH7A.js → NA424YAL.js} +1 -1
  453. package/build/dist/chunks/NUFZUKYS.js +1 -0
  454. package/build/dist/chunks/{XD6X3KTC.js → O3JWCJIF.js} +1 -1
  455. package/build/dist/chunks/OARVU3RC.js +1 -0
  456. package/build/dist/chunks/OEZ7FCLF.js +1 -0
  457. package/build/dist/chunks/{H43RNCX2.js → OUROA7XR.js} +1 -1
  458. package/build/dist/chunks/{2MT3G7YZ.js → OYJFXEDU.js} +1 -1
  459. package/build/dist/chunks/OYPAVXGQ.js +1 -0
  460. package/build/dist/chunks/{SMYWWIE6.js → OZ5MDUD2.js} +1 -1
  461. package/build/dist/chunks/P6OMKZMR.js +3 -0
  462. package/build/dist/chunks/PV4AK32X.js +1 -0
  463. package/build/dist/chunks/{HKEMQBFA.js → PXVREXCS.js} +1 -1
  464. package/build/dist/chunks/PZEF5LBL.js +2 -0
  465. package/build/dist/chunks/Q2ACLVWR.js +1 -0
  466. package/build/dist/chunks/QFSBDPLN.js +1 -0
  467. package/build/dist/chunks/QJNLLI6N.js +1 -0
  468. package/build/dist/chunks/QMZEGT5B.js +1 -0
  469. package/build/dist/chunks/{PNA6UIE5.js → REWXG6X6.js} +1 -1
  470. package/build/dist/chunks/{ALLLYOUG.js → RLI4JDOL.js} +1 -1
  471. package/build/dist/chunks/{UD2XMNIT.js → RLMVA575.js} +1 -1
  472. package/build/dist/chunks/RPB46QAC.js +1 -0
  473. package/build/dist/chunks/{Q42YI3EP.js → RT7IU6TI.js} +1 -1
  474. package/build/dist/chunks/{ER47KGRM.js → SBY4RJ7I.js} +1 -1
  475. package/build/dist/chunks/SCG5HWMN.js +1 -0
  476. package/build/dist/chunks/{XQA5LCL6.js → SENOU5JR.js} +1 -1
  477. package/build/dist/chunks/SKEKXEUU.js +1 -0
  478. package/build/dist/chunks/SOTYQGPT.js +1 -0
  479. package/build/dist/chunks/SZ466I5X.js +1 -0
  480. package/build/dist/chunks/{GNC6RXLT.js → TDZTC5WR.js} +1 -1
  481. package/build/dist/chunks/TE6D3OIX.js +1 -0
  482. package/build/dist/chunks/TID4C2KC.js +1 -0
  483. package/build/dist/chunks/TK55VASJ.js +2 -0
  484. package/build/dist/chunks/TM7Z5SA4.js +1 -0
  485. package/build/dist/chunks/TNJTET4G.js +1 -0
  486. package/build/dist/chunks/TPEKCXVE.js +1 -0
  487. package/build/dist/chunks/TVIMP5CK.js +1 -0
  488. package/build/dist/chunks/U2YCQWZK.js +1 -0
  489. package/build/dist/chunks/U363GQTF.js +1 -0
  490. package/build/dist/chunks/{U4JGEMKT.js → UEDGYZOC.js} +1 -1
  491. package/build/dist/chunks/UOCRYXAB.js +1 -0
  492. package/build/dist/chunks/UQEEF5W5.js +1 -0
  493. package/build/dist/chunks/{QQECG3WP.js → UUID2E22.js} +1 -1
  494. package/build/dist/chunks/UWBKAWX3.js +7 -0
  495. package/build/dist/chunks/V37L4DU4.js +1 -0
  496. package/build/dist/chunks/VR344DAZ.js +1 -0
  497. package/build/dist/chunks/{TX2EOIRS.js → VST6LFUB.js} +1 -1
  498. package/build/dist/chunks/VTPT5544.js +1 -0
  499. package/build/dist/chunks/VVWFB53Q.js +1 -0
  500. package/build/dist/chunks/WHTRPRRD.js +1 -0
  501. package/build/dist/chunks/WHVZ372B.js +1 -0
  502. package/build/dist/chunks/{AFBEZXNV.js → WNWRF4HE.js} +1 -1
  503. package/build/dist/chunks/{4DP2VPXR.js → WOGWLFAL.js} +1 -1
  504. package/build/dist/chunks/WUT7TZYM.js +1 -0
  505. package/build/dist/chunks/XCKTE4ON.js +1 -0
  506. package/build/dist/chunks/XEPCDGN2.js +1 -0
  507. package/build/dist/chunks/XHYFISVV.js +1 -0
  508. package/build/dist/chunks/XPEDQBLI.js +1 -0
  509. package/build/dist/chunks/{QFNT73OF.js → XQ24RSEI.js} +1 -1
  510. package/build/dist/chunks/XRDXFHIK.js +1 -0
  511. package/build/dist/chunks/XTFRPI4G.js +1 -0
  512. package/build/dist/chunks/XVJ7ILKK.js +1 -0
  513. package/build/dist/chunks/XWKK75TO.js +1 -0
  514. package/build/dist/chunks/{CBLMQ5UU.js → XYPGLG6A.js} +1 -1
  515. package/build/dist/chunks/Y77EVVT4.js +1 -0
  516. package/build/dist/chunks/YEIM6BZQ.js +1 -0
  517. package/build/dist/chunks/{XSKFKBDR.js → YMV5TL5C.js} +1 -1
  518. package/build/dist/chunks/YSMWCKIX.js +1 -0
  519. package/build/dist/chunks/YTLH4M4Y.js +1 -0
  520. package/build/dist/chunks/YUHNPUNK.js +1 -0
  521. package/build/dist/chunks/YWZQJJYY.js +1 -0
  522. package/build/dist/chunks/{EGYVRQUR.js → ZF2VPDRQ.js} +1 -1
  523. package/build/dist/chunks/ZFU65MB4.js +1 -0
  524. package/build/dist/chunks/ZKZUS3QU.js +1 -0
  525. package/build/dist/chunks/ZOMFHTB2.js +1 -0
  526. package/build/dist/chunks/{OLSP46ZD.js → ZP36DSOD.js} +1 -1
  527. package/build/dist/chunks/ZQ6AF3VX.js +1 -0
  528. package/package.json +1 -1
  529. package/build/dist/chunks/2THSW4QN.js +0 -1
  530. package/build/dist/chunks/2TK3ETUO.js +0 -1
  531. package/build/dist/chunks/35KR3VSS.js +0 -1
  532. package/build/dist/chunks/3GQ7A3VB.js +0 -1
  533. package/build/dist/chunks/3XNZUIRU.js +0 -1
  534. package/build/dist/chunks/46547QT3.js +0 -1
  535. package/build/dist/chunks/4EN6MQEI.js +0 -1
  536. package/build/dist/chunks/4I3OU56B.js +0 -1
  537. package/build/dist/chunks/52ELWNXJ.js +0 -2
  538. package/build/dist/chunks/5AXWBSPG.js +0 -1
  539. package/build/dist/chunks/5N3O42X6.js +0 -1
  540. package/build/dist/chunks/5SMVQCAP.js +0 -1
  541. package/build/dist/chunks/5SZPNZG4.js +0 -1
  542. package/build/dist/chunks/64GOINYS.js +0 -1
  543. package/build/dist/chunks/6I4NTKB2.js +0 -1
  544. package/build/dist/chunks/6JAXZNZ3.js +0 -1
  545. package/build/dist/chunks/6O3Q5B6M.js +0 -1
  546. package/build/dist/chunks/6OGDTEGH.js +0 -1
  547. package/build/dist/chunks/6WZX7C4T.js +0 -2
  548. package/build/dist/chunks/6YB3VOUL.js +0 -1
  549. package/build/dist/chunks/7GJ6SLEV.js +0 -1
  550. package/build/dist/chunks/7KWZ5QJU.js +0 -1
  551. package/build/dist/chunks/7QZOTRSA.js +0 -2
  552. package/build/dist/chunks/7WSHW7KW.js +0 -1
  553. package/build/dist/chunks/A7I4IWUB.js +0 -1
  554. package/build/dist/chunks/ABPL3ZZI.js +0 -1
  555. package/build/dist/chunks/ACW63WIL.js +0 -20
  556. package/build/dist/chunks/AEL62KCG.js +0 -1
  557. package/build/dist/chunks/AKYF5264.js +0 -7
  558. package/build/dist/chunks/AW7AXQCZ.js +0 -1
  559. package/build/dist/chunks/AXRL3REN.js +0 -1
  560. package/build/dist/chunks/BBTPRZ6T.js +0 -1
  561. package/build/dist/chunks/BOVMED7R.js +0 -1
  562. package/build/dist/chunks/BTPXJAUX.js +0 -1
  563. package/build/dist/chunks/C7AXJHBT.js +0 -1
  564. package/build/dist/chunks/CBG5HARQ.js +0 -2
  565. package/build/dist/chunks/CDPSMI3Z.js +0 -1
  566. package/build/dist/chunks/CHXBOXOD.js +0 -1
  567. package/build/dist/chunks/CQEJSCFQ.js +0 -1
  568. package/build/dist/chunks/DBNTZEAJ.js +0 -1
  569. package/build/dist/chunks/DHUDSOGR.js +0 -18
  570. package/build/dist/chunks/DJN3JAWB.js +0 -1
  571. package/build/dist/chunks/FEYAY6OZ.js +0 -1
  572. package/build/dist/chunks/GG6Y4OCJ.js +0 -1
  573. package/build/dist/chunks/GGHBFLRC.js +0 -1
  574. package/build/dist/chunks/GGSAKCND.js +0 -1
  575. package/build/dist/chunks/GRQYTVNT.js +0 -1
  576. package/build/dist/chunks/H6T5FXEX.js +0 -1
  577. package/build/dist/chunks/HHXBUYHO.js +0 -1
  578. package/build/dist/chunks/HQUVB7Z5.js +0 -3
  579. package/build/dist/chunks/HU7IMNBI.js +0 -1
  580. package/build/dist/chunks/HWX36XJI.js +0 -1
  581. package/build/dist/chunks/I26DMNJG.js +0 -1
  582. package/build/dist/chunks/I55MURSJ.js +0 -1
  583. package/build/dist/chunks/IMO3GDA5.js +0 -1
  584. package/build/dist/chunks/IPRVIKYC.js +0 -1
  585. package/build/dist/chunks/IVX4R5OL.js +0 -1
  586. package/build/dist/chunks/JQOQMFWD.js +0 -3
  587. package/build/dist/chunks/JUZ5JU6D.js +0 -70
  588. package/build/dist/chunks/JZS3E66E.js +0 -1
  589. package/build/dist/chunks/K3RDPI5J.js +0 -1
  590. package/build/dist/chunks/KBKK7UNY.js +0 -1
  591. package/build/dist/chunks/KVFZKPJT.js +0 -1
  592. package/build/dist/chunks/L5BLHY34.js +0 -1
  593. package/build/dist/chunks/LKXO2BQS.js +0 -1
  594. package/build/dist/chunks/LKZX4CAA.js +0 -1
  595. package/build/dist/chunks/LYMNHO5T.js +0 -1
  596. package/build/dist/chunks/M2UXYCKH.js +0 -1
  597. package/build/dist/chunks/M37654RL.js +0 -1
  598. package/build/dist/chunks/M6LC6DRE.js +0 -1
  599. package/build/dist/chunks/MOE3EVAL.js +0 -1
  600. package/build/dist/chunks/N4Q6GN65.js +0 -1
  601. package/build/dist/chunks/NAZPDRIF.js +0 -1
  602. package/build/dist/chunks/NKX3FE34.js +0 -1
  603. package/build/dist/chunks/NKZKKCK2.js +0 -1
  604. package/build/dist/chunks/NOFUKKP5.js +0 -1
  605. package/build/dist/chunks/O6ROOKY2.js +0 -1
  606. package/build/dist/chunks/OJ4WJUPP.js +0 -1
  607. package/build/dist/chunks/OOZSE2R7.js +0 -1
  608. package/build/dist/chunks/OTXSKFUD.js +0 -1
  609. package/build/dist/chunks/P5AJSLZ7.js +0 -1
  610. package/build/dist/chunks/PACN53TR.js +0 -1
  611. package/build/dist/chunks/PAHXBLCS.js +0 -1
  612. package/build/dist/chunks/PK66GCDT.js +0 -1
  613. package/build/dist/chunks/PSBQWDYI.js +0 -1
  614. package/build/dist/chunks/PXT5YTWU.js +0 -1
  615. package/build/dist/chunks/PZGGE5D3.js +0 -1
  616. package/build/dist/chunks/QA2RRIES.js +0 -1
  617. package/build/dist/chunks/QA3UHEO3.js +0 -1
  618. package/build/dist/chunks/QW2OPEYJ.js +0 -1
  619. package/build/dist/chunks/QYVREJYC.js +0 -1
  620. package/build/dist/chunks/ROFPXEQ5.js +0 -2
  621. package/build/dist/chunks/RTGS7RIO.js +0 -1
  622. package/build/dist/chunks/RUX3RY7Y.js +0 -1
  623. package/build/dist/chunks/RVDUSNWW.js +0 -1
  624. package/build/dist/chunks/S5CBVFHY.js +0 -1
  625. package/build/dist/chunks/SIYUNOLI.js +0 -1
  626. package/build/dist/chunks/TEJ7W534.js +0 -1
  627. package/build/dist/chunks/TPBAFS7K.js +0 -1
  628. package/build/dist/chunks/TVWMTMEF.js +0 -1
  629. package/build/dist/chunks/U2RMUVVY.js +0 -1
  630. package/build/dist/chunks/U5PMVP56.js +0 -1
  631. package/build/dist/chunks/V5JWGWXC.js +0 -1
  632. package/build/dist/chunks/VCOTCVKN.js +0 -1
  633. package/build/dist/chunks/VEQBHI6O.js +0 -1
  634. package/build/dist/chunks/VNV6ZISN.js +0 -1
  635. package/build/dist/chunks/VYAJXLND.js +0 -1
  636. package/build/dist/chunks/WCNHZYQQ.js +0 -1
  637. package/build/dist/chunks/X2P55AC3.js +0 -1
  638. package/build/dist/chunks/XBE3B6Y2.js +0 -1
  639. package/build/dist/chunks/XKSVTN5X.js +0 -1
  640. package/build/dist/chunks/XSRIJUFU.js +0 -1
  641. package/build/dist/chunks/YCZPSMZ5.js +0 -1
  642. package/build/dist/chunks/YN56C7PN.js +0 -1
  643. package/build/dist/chunks/YRNXGQJC.js +0 -1
  644. package/build/dist/chunks/YWRLY5EA.js +0 -1
  645. package/build/dist/chunks/YWSX6IE6.js +0 -1
  646. package/build/dist/chunks/YXTSWRV5.js +0 -1
  647. package/build/dist/chunks/Z6LZGCVW.js +0 -1
  648. package/build/dist/chunks/ZQWZGH7V.js +0 -1
  649. package/build/dist/chunks/ZSN4IRI5.js +0 -1
  650. package/build/dist/chunks/ZV5HIQXC.js +0 -1
  651. package/build/dist/chunks/ZXJ24B4L.js +0 -1
@@ -0,0 +1 @@
1
+ import{a as K}from"./JKD2B6OX.js";import{b as Y,d as Z,e as Q}from"./V74F6IDY.js";import{a as J}from"./REWXG6X6.js";import{a as W,c as x,d as B,h as F,i as E,j as L}from"./XQ24RSEI.js";import{a as P}from"./E3RACZUY.js";import{aa as z,fa as H}from"./EI6GGPDS.js";import{k as j}from"./U2YCQWZK.js";import{j as M}from"./DNNFKDZR.js";import{a as $}from"./IOYRL6AY.js";import{e as O,h as U}from"./NWNYJ26T.js";import{a as v}from"./XSD5NL7J.js";import{erc20Abi as X,formatUnits as G,parseAbiItem as q}from"viem";var ee=q("event CreateVaultV2(address indexed caller,address indexed owner,bytes32 salt,address indexed vault)"),te=r=>H("unverified",{...r?{vaultLabel:r}:{}});function ae(r){if(!O(r)||!O(r.chain)||r.chain.id!==4663||!Array.isArray(r.contracts)||!Array.isArray(r.markets)||r.contracts.length>1e3||r.markets.length>1e3)throw new v("Borro vault discovery returned an unreadable candidate list.");let i=[...r.contracts.filter(O).filter(e=>e.name==="BorroUSDGVault").map(e=>e.address),...r.markets.filter(O).map(e=>O(e.vault)?e.vault.address:void 0)];return[...new Set(i.map(x))]}function se(r){return r.sort((i,e)=>+(e.symbol==="USDG")-+(i.symbol==="USDG")||0)}var re=6e4;function oe(r,i={}){let e=i.resolveAllowedAsset??E(i.officialStockTokens),g=L({resolveAllowedAsset:e}),S=new WeakMap,A=s=>{let t=S.get(s);return t||(t={},S.set(s,t)),t},m=s=>{if(s?.aborted)throw new v("Borro read was cancelled.")};async function h(s,t,u){let c=A(s);if(c.inventory&&Date.now()<c.inventory.expiresAt)return structuredClone(c.inventory);let a={items:[],sources:[],incomplete:!1,warnings:[],expiresAt:0},o=new Map;m(u);try{for(let l of ae(await Y(r.http,"contracts",u)))o.set(l.toLowerCase(),{vault:l});a.sources.push("contracts.json")}catch{a.incomplete=!0,a.warnings.push("Borro candidate discovery is unavailable; this inventory may be incomplete.")}if(i.factoryEvents!==!1)try{let l=new Map;for(let p=BigInt(P.factory.fromBlock);p<=t;p+=10000000n){m(u);let k=p+9999999n<t?p+9999999n:t,y=await s.getLogs({address:P.factory.address,event:ee,fromBlock:p,toBlock:k,strict:!0});if(y.length>1e3)throw new v("Borro factory inventory exceeds the read limit.");for(let d of y){let n=x(d.args.vault);if(d.removed||!U(d.address,P.factory.address)||d.blockNumber===null||d.blockNumber<p||d.blockNumber>k||l.has(n.toLowerCase()))throw new v("Borro factory events are unreadable.");l.set(n.toLowerCase(),{vault:n,block:d.blockNumber})}if(l.size>1e3)throw new v("Borro factory inventory exceeds the read limit.")}for(let[p,k]of l)o.set(p,k);a.sources.push("factory-events")}catch{a.incomplete=!0,a.warnings.push("Borro factory discovery is unavailable; vault creation dates or inventory may be incomplete.")}return m(u),a.items=[...o.values()],a.expiresAt=Date.now()+re,a.incomplete||(c.inventory=structuredClone(a)),a}let w=async(s,t={})=>{m(t.signal);let u=await F(s),c=A(s);if(!t.wallet&&c.verified&&Date.now()<c.verified.expiresAt)return structuredClone(c.verified.result);let a=await h(s,u,t.signal),o={vaults:[],refused:[],sources:a.sources,incomplete:a.incomplete,warnings:a.warnings,measuredAtBlock:u.toString()},l=a.items;if(t.heldOnly){if(!t.wallet)throw new v("Provide a wallet for Borro holdings.");m(t.signal);let y=l.length?await s.multicall({allowFailure:!1,batchSize:0,contracts:l.map(({vault:d})=>({address:d,abi:X,functionName:"balanceOf",args:[t.wallet]})),blockNumber:u}):[];if(!Array.isArray(y)||y.length!==l.length)throw new v("Borro share balances could not be read completely. Please try again.");o.shareBalances=l.map((d,n)=>({vault:d.vault,amount:B(y[n]).toString()})),l=l.filter((d,n)=>BigInt(o.shareBalances[n].amount)>0n)}m(t.signal);let p=e;if(l.length&&!i.resolveAllowedAsset&&!i.officialStockTokens)try{p=E(await M({http:r.http,allowAmbiguousSymbols:!0}))}catch{o.incomplete=!0,o.warnings.push("Official stock identities could not be checked; held-share exits remain available by vault address.")}let k=L({resolveAllowedAsset:p});for(let y=0;y<l.length;y+=4){m(t.signal);let d=await Promise.all(l.slice(y,y+4).map(async n=>{try{let b=await k(s,n.vault,t.wallet?"withdraw":"deposit",{blockNumber:u,...t.wallet?{wallet:t.wallet}:{}});if(n.block!==void 0)try{let V=await s.getBlock({blockNumber:n.block}),f=B(V.timestamp);f<=8640000000000n&&V.number===n.block&&(b.deployedAt=new Date(Number(f)*1e3).toISOString())}catch{}return{facts:b}}catch{return{rejected:{vault:n.vault,reason:te(n.vault)}}}}));for(let n of d)n.facts&&o.vaults.push(n.facts),n.rejected&&o.refused.push(n.rejected)}return m(t.signal),se(o.vaults),!t.wallet&&!o.incomplete&&(c.verified={result:structuredClone(o),expiresAt:a.expiresAt}),o},T=async(s,t={})=>{m(t.signal);let u=A(s),c;if(t.wallet||t.signal)c=await w(s,t);else{let a=u.pending??w(s);u.pending=a;try{c=structuredClone(await a)}finally{u.pending===a&&(u.pending=void 0)}}return m(t.signal),{...c,vaults:c.vaults.filter(a=>!t.asset||a.symbol.toUpperCase()===t.asset.toUpperCase())}};return{discoverVaults:T,verifyVault:g,resolveVault:async(s,t,u,c)=>{if(t.asset!==void 0&&!/^[A-Za-z0-9.$_-]{1,32}$/.test(t.asset))throw new v("Provide an official asset symbol.");if(t.vault){let y=await g(s,t.vault,u,{wallet:c});if(t.asset&&y.symbol.toUpperCase()!==t.asset.toUpperCase())throw new v("The asset symbol does not match the verified vault.");return y}if(!t.asset)throw new v("Provide an asset symbol or the vault address.");let a=await T(s,{asset:t.asset,...u==="withdraw"?{wallet:c}:{}});if(a.incomplete)throw new v("Borro discovery is incomplete. Provide the vault address for on-chain verification.");let o=a.vaults.length===1?a.vaults[0]:void 0;if(!o&&t.asset.toUpperCase()==="USDG"&&a.vaults.length>1){let y=await F(s);try{if(a.vaults.some(f=>!U(f.asset,P.assetRule.usdg.address)||f.assetDecimals!==6))throw new v("Unreadable USDG identity.");let d=a.vaults.filter(f=>f.setup.drift.length===0&&f.assetAllowed),n=await Promise.all(d.map(async f=>({facts:f,total:B(await s.readContract({address:f.vault,abi:W,functionName:"totalAssets",blockNumber:y}))})));n.sort((f,_)=>f.total>_.total?-1:f.total<_.total?1:0);let[b,V]=n;b&&b.total>=100000000n&&(!V||b.total>=V.total*10n)&&(o=b.facts)}catch{}}if(!o)throw new v(a.vaults.length?"More than one Borro vault uses this symbol. Provide the vault address.":"No verified Borro vault matched this asset. Provide the vault address to check it on chain.");let l=e;if(!i.resolveAllowedAsset&&!i.officialStockTokens&&!U(o.asset,P.assetRule.usdg.address))try{l=E(await M({http:r.http,allowAmbiguousSymbols:!0}))}catch{}let k=await L({resolveAllowedAsset:l})(s,o.vault,u,{wallet:c});if(k.symbol.toUpperCase()!==t.asset.toUpperCase())throw new v("The asset symbol does not match the verified vault.");return{...k,...o.deployedAt?{deployedAt:o.deployedAt}:{}}}}}var N=(r,i)=>({token:r,amount:i.toString()});async function ne(r,i,e){try{let[g,S]=await Promise.all([i.getGasPrice(),j("ETH",{client:i,http:r.http,chainId:4663,blockNumber:e})]);if(!/^\d+$/.test(S.usdE18)||BigInt(S.usdE18)<=0n||B(g)===0n)return{};let A=w=>Number(G(w*g*BigInt(S.usdE18)/10n**18n,18)),m=A($*2n),h=A($);return[m,h].every(w=>Number.isFinite(w)&&w>0)?{gasInUsd:m,gasOutUsd:h}:{}}catch{return{}}}async function ie(r,i,e,g,S=new Map,A){let m={vault:e.vault,verified:!0,symbol:e.symbol,vaultSymbol:e.vaultSymbol,setup:e.setup,measuredAtBlock:(A??BigInt(e.measuredAtBlock)).toString(),verifiedAtBlock:e.measuredAtBlock,...e.owner?{owner:e.owner}:{},...e.curator?{curator:e.curator}:{},...e.deployedAt?{deployedAt:e.deployedAt}:{}};try{let h=A??BigInt(e.measuredAtBlock),w={address:e.asset,symbol:e.symbol,decimals:e.assetDecimals,chainId:4663},T={address:e.vault,symbol:e.vaultSymbol,decimals:18,chainId:4663},R=(D,C,I=[])=>i.readContract({address:D,abi:[...W,...X],functionName:C,args:I,blockNumber:h}),[s,t,u,c,a,o,l]=await Promise.all([R(e.vault,"totalAssets"),R(e.vault,"performanceFee"),R(e.asset,"balanceOf",[g]),R(e.vault,"balanceOf",[g]),J(i,e,h),ne(r,i,h),i.getBlock({blockNumber:h})]),p=B(c),k=B(t);if(k>10n**18n)throw new v("Borro performance fee is unreadable.");let y=B(await R(e.vault,"convertToAssets",[p])),d={};if(e.owner)try{let[D,C]=await Promise.all([R(e.owner,"getThreshold"),R(e.owner,"getOwners")]),I=B(D);if(!Array.isArray(C)||C.length>1e3||new Set(C.map(x)).size!==C.length||I<1n||I>BigInt(C.length))throw new v("Unreadable group wallet.");d={safeThreshold:Number(I),safeOwners:C.length}}catch{}let n;if(U(e.asset,P.assetRule.usdg.address))try{let D=(await K(i,h)).rateBasePct;Number.isFinite(D)&&D>=0&&(n=D)}catch{}let b=Q(S,w,e.vault);if(l.number!==h)throw new v("Borro block timestamp could not be verified.");let V=Number(B(l.timestamp)),f=e.deployedAt?Date.parse(e.deployedAt)/1e3:void 0,_=z({symbol:e.symbol,kind:U(e.asset,P.assetRule.usdg.address)?"usdg":"stock",nowSeconds:V,...f===void 0?{}:{deployedAtSeconds:f},threshold:d.safeThreshold,owners:d.safeOwners,borroRatePct:b.apr===void 0?void 0:b.apr*100,feePct:Number(G(k,16)),layerbankRatePct:n,totalAmount:G(B(s),e.assetDecimals),readyAmount:a.readyBase===void 0?void 0:G(a.readyBase,e.assetDecimals),gasInUsd:o.gasInUsd===void 0?void 0:`up to $${o.gasInUsd.toFixed(4)}`,gasOutUsd:o.gasOutUsd===void 0?void 0:`up to $${o.gasOutUsd.toFixed(4)}`});return{...m,asset:w,shares:T,totalAssets:N(w,B(s)),performanceFeeWad:k.toString(),walletAssetBalance:N(w,B(u)),walletShares:N(T,p),walletShareValue:N(w,y),liquidityKind:a.kind,...a.readyBase===void 0?{}:{cashOnHand:N(w,a.readyBase)},...d,...o,...n===void 0?{}:{layerbankRateBasePct:n},...b.apr===void 0?{}:{apr:b.apr,rateSource:b.source},...b.readyToWithdraw?{vendorReadyToWithdraw:b.readyToWithdraw}:{},...f!==void 0&&f<=V?{ageSeconds:String(Math.floor(V-f))}:{},risk:{title:"Lending on Borro",text:_,source:"Oak"}}}catch{return{...m,error:"This Borro vault can't be read right now. Please try again."}}}async function ge(r,i,e={},g={},S){if(e.vault&&!g.resolveAllowedAsset&&!g.officialStockTokens)try{g={...g,officialStockTokens:await M({http:r.http,allowAmbiguousSymbols:!0})}}catch{}let A=r.clientFor(4663),m=S??oe(r,g);x(i);let h;if(e.vault){let s=await m.resolveVault(A,e,"deposit",i);h={vaults:[s],refused:[],sources:[],incomplete:!1,warnings:[],measuredAtBlock:s.measuredAtBlock}}else h=await m.discoverVaults(A,e.asset?{asset:e.asset}:{});let[w,T]=await Promise.all([Z(r.http),F(A)]),R=[];for(let s=0;s<h.vaults.length;s+=4)R.push(...await Promise.all(h.vaults.slice(s,s+4).map(t=>ie(r,A,t,i,w,T))));return{...h,vaults:R}}export{ae as a,se as b,oe as c,N as d,ie as e,ge as f};
@@ -0,0 +1 @@
1
+ import{b as S}from"./WUT7TZYM.js";import{a as w}from"./43LI5NKJ.js";import{g as R}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 O,getAddress as h,keccak256 as C,parseAbi as T,parseAbiItem as x,toHex as A,zeroHash as D}from"viem";var s=h(k[o].vaults.spark.address),g={admin:D,setter:C(A("SETTER_ROLE")),taker:C(A("TAKER_ROLE"))},E=[["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=E.map(([r,a])=>({abi:x(`function ${r}`),authority:a})),p=T(["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,i)=>{try{if(w(i),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 m=await e.readContract({address:s,abi:p,functionName:"getRoleMemberCount",args:[d],blockNumber:u});if(m>256n)throw new t("Spark role membership exceeds this reader\u2019s supported size.");let[b,n]=await Promise.all([e.readContract({address:s,abi:p,functionName:"hasRole",args:[d,i],blockNumber:u}),Promise.all(Array.from({length:Number(m)},(y,l)=>e.readContract({address:s,abi:p,functionName:"getRoleMember",args:[d,BigInt(l)],blockNumber:u})))]);return{name:f,role:d,heldByWallet:b,members:n.map(y=>h(y))}}));return{vault:s,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),description:"Role-gated vault admin call: drip, setVsr, setVsrBounds, setDepositCap, take, grantRole, revokeRole, renounceRole or upgradeToAndCall. Pass its inputs in values; Oak checks your role."},values:{type:"array",maxItems:2,items:{type:"string"},description:"Ordered contract inputs; all integers are decimal base-unit strings."}}},execute:async(a,i)=>{try{if(w(i),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 l=a.values[y];if(n.type==="bytes32"){if(typeof l!="string"||!Object.values(g).includes(l))throw new t("Provide a documented Spark role identifier.");return l}return S(n.type,l)});if(e.abi.name==="renounceRole"&&!R(String(u[1]),i))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:s,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:s,abi:p,functionName:"hasRole",args:[g[e.authority],i]})!==!0)throw new t("This wallet does not hold the required Spark role. No transaction was built.");let d=`${e.abi.name} on Spark ${s}; 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.":""}`,m=[r.unsignedTx({to:s,data:O({abi:[e.abi],functionName:e.abi.name,args:u}),value:"0",chainId:o,description:d})],b=await r.preview(m,i);return{txs:m,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}from"./3VBIRLU3.js";import{K as P}from"./7QKYDNF6.js";import{a as O}from"./43LI5NKJ.js";import{a as A}from"./66F5ZH34.js";import{d as g,i as T}from"./NWNYJ26T.js";import{a as p}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{a as k}from"./JXOEJPJ4.js";import{encodeFunctionData as E,getAddress as f,parseAbi as v,zeroAddress as R}from"viem";var w=v(["function owner() view returns (address)","function paused() view returns (bool)","function maximumLoanDuration() view returns (uint256)","function adminFeeInBasisPoints() view returns (uint16)","function pause()","function unpause()","function updateAdminFee(uint16)","function updateMaximumLoanDuration(uint256)","function setERC20Permit(address,bool)","function setERC20Permits(address[],bool[])","function getERC20Permit(address) view returns (bool)","function requestTransferOwnership(address)","function cancelTransferOwnership()","function acceptTransferOwnership()","function rejectTransferOwnership()"]),C=["pause","unpause","updateAdminFee","updateMaximumLoanDuration","setERC20Permit","setERC20Permits","requestTransferOwnership","cancelTransferOwnership","acceptTransferOwnership","rejectTransferOwnership"];function m(d){return T(d,"Provide an explicit checksummed address.",g)}var S=d=>{let h=(n,i,c,e)=>({name:n,inputSchema:{type:"object",properties:i,required:c,additionalProperties:!1},execute:async(s,t)=>{try{if(O(t),Object.keys(s).some(a=>!Object.hasOwn(i,a)))throw new r("Unsupported Longbow administration argument.");return await e(s,t)}catch(a){throw new r(d.plainError(a))}}});async function b(){let n=d.clientFor(p);if(await n.getChainId()!==p)throw new r("Longbow requires chain 4663.");return n}return{tools:[h("longbow_nft_admin",{token:{type:"string",description:"Optional ERC-20 token address to check whether the NFT loan contract permits it as a loan currency."}},[],async n=>{let i=await b(),c=["owner","paused","maximumLoanDuration","adminFeeInBasisPoints"],e=await Promise.all(c.map(s=>i.readContract({address:u,abi:w,functionName:s})));return{chainId:p,contract:u,...Object.fromEntries(c.map((s,t)=>[s,typeof e[t]=="bigint"?String(e[t]):e[t]])),...n.token===void 0?{}:{token:m(n.token),permitted:await i.readContract({address:u,abi:w,functionName:"getERC20Permit",args:[m(n.token)]})}}}),h("longbow_manage_nft",{operation:{type:"string",enum:C,description:"Owner administration call: pause or unpause the protocol, update the admin fee or maximum loan duration, permit tokens, or manage ownership transfer."},value:A("Integer in base units of the setting, as a decimal string. updateAdminFee: basis points (50 = 0.5%, max 10000). updateMaximumLoanDuration: seconds (86400 = 1 day)."),account:{type:"string",description:"Address of the ERC-20 token for setERC20Permit, or of the proposed new owner for requestTransferOwnership."},enabled:{type:"boolean",description:"For setERC20Permit: true permits the token as a loan currency, false removes the permission."},tokens:{type:"array",maxItems:32,description:"For setERC20Permits: unique token addresses to update; pairs by position with permissions.",items:{type:"string",description:"ERC-20 token address."}},permissions:{type:"array",maxItems:32,description:"For setERC20Permits: true/false per token, same length and order as tokens.",items:{type:"boolean",description:"True permits the token at the same index as a loan currency."}}},["operation"],async(n,i)=>{if(typeof n.operation!="string"||!C.includes(n.operation))throw new r("Choose a documented NFT administration operation.");let c=await b(),e=n.operation,s=e.startsWith("update")?["operation","value"]:e==="setERC20Permit"?["operation","account","enabled"]:e==="setERC20Permits"?["operation","tokens","permissions"]:e==="requestTransferOwnership"?["operation","account"]:["operation"];if(Object.keys(n).some(o=>!s.includes(o)))throw new r("Unexpected fields for this NFT administration operation.");if(!["acceptTransferOwnership","rejectTransferOwnership"].includes(e)){let o=await c.readContract({address:u,abi:w,functionName:"owner"});if(f(o)!==f(i))throw new r("This wallet lacks the NFT loan owner role.")}let t=[];if(e.startsWith("update")){let o=P(n.value,!0);if(o>(e==="updateAdminFee"?10000n:(1n<<32n)-1n))throw new r("NFT fee/duration exceeds the contract limit.");t=[e==="updateAdminFee"?Number(o):o]}else if(e==="setERC20Permit"){if(typeof n.enabled!="boolean")throw new r("Provide enabled as a boolean.");t=[m(n.account),n.enabled]}else if(e==="setERC20Permits"){if(!Array.isArray(n.tokens)||!Array.isArray(n.permissions)||!n.tokens.length||n.tokens.length>32||n.tokens.length!==n.permissions.length||n.permissions.some(l=>typeof l!="boolean"))throw new r("Provide equal bounded token and permission arrays.");let o=n.tokens.map(m);if(new Set(o).size!==o.length)throw new r("Currency tokens must be unique.");t=[o,n.permissions]}else if(e==="requestTransferOwnership"){let o=m(n.account);if(o===R)throw new r("New owner must be nonzero.");t=[o]}let a=`Longbow NFT protocol administration ${e} on ${u}, values ${JSON.stringify(t,(o,l)=>typeof l=="bigint"?String(l):l)}. This changes protocol-wide settings or authority. Ownership acceptance/rejection requires the pending owner; the contract preview verifies that role. Permitting a currency here does not qualify it for Oak\u2019s borrower tools.`,y=[d.unsignedTx({to:u,data:E({abi:w,functionName:e,args:t}),value:"0",chainId:p,description:a})];return{txs:y,preview:await d.preview(y,i),summary:a}}),h("longbow_referral",{},[],async(n,i)=>{let c=await d.http(`https://longbow.credit/api/referral/stats/${f(i)}`,{method:"GET",redirect:"error"});if(!c.ok)throw new r(`Longbow referral service returned HTTP ${c.status}; referral state is unavailable.`);let e=await c.json();if(!e||typeof e!="object"||m(e.address)!==f(i))throw new r("Referral response does not match this wallet.");let s=a=>{if(typeof a!="number"||!Number.isSafeInteger(a)||a<0)throw new r("Invalid referral count.");return a},t=e.bonusEarnedAllTime;if(typeof t!="number"||!Number.isFinite(t)||t<0)throw new r("Invalid referral bonus estimate.");if(e.code!==null&&e.code!==void 0&&(typeof e.code!="string"||!/^[a-zA-Z0-9_-]{1,64}$/.test(e.code)))throw new r("Invalid referral code.");return{address:f(i),chainId:p,code:e.code??null,referrals:s(e.referrals),activeThisEpoch:s(e.activeThisEpoch),bonusEstimateUsd:t,source:"Longbow public referral service; off-chain estimates, not verified payments.",warning:k("Referral links are permanent according to the app. Registration/linking publishes wallet associations and requires a separate authorized publication flow. This tool only reads stats; no payout or claim is promised.")}})]}};export{w as a,S as b};
@@ -1 +1 @@
1
- import{b as W}from"./XSRIJUFU.js";import{d as R,e as _}from"./XV6F3RET.js";import{b as z,c as I}from"./SPRVVJXI.js";import{K as E}from"./DHUDSOGR.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{a as C,s as S}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
1
+ import{b as z,c as I}from"./SPRVVJXI.js";import{b as W}from"./TM7Z5SA4.js";import{d as R,e as _}from"./XV6F3RET.js";import{K as E}from"./7QKYDNF6.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{a as C,s as S}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
@@ -0,0 +1 @@
1
+ import{c as D}from"./3K2N5VFH.js";import{b as O,g as M,i as A,j as B,k as T,l as P,m as I,n as U,r as k,s as F,v as f,x as z}from"./QJNLLI6N.js";import{a as w,e as _}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a as d}from"./XSD5NL7J.js";function $(u){return{...u,token:{...u.token,symbol:f(u.token.symbol)??"unknown"}}}var Q=u=>{let N=z(u);async function G(t,r){let g=T(r),i=I(t.originChainId),e=I(t.destinationChainId);if(i!==y&&e!==y)throw new d(`A Relay quote must start or end on chain ${y}.`);let h=P(t.originCurrency??O),b=P(t.destinationCurrency??O),c=T(t.recipient??g),a=U(t.amount);if(a==="0")throw new d("Provide a positive bridge amount.");let n=t.tradeType??"EXACT_INPUT";if(!["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"].includes(String(n)))throw new d("Choose EXACT_INPUT, EXACT_OUTPUT or EXPECTED_OUTPUT.");let m={};for(let E of["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"]){let p=t[E];if(p!==void 0){if(!Array.isArray(p)||p.length>100||p.some(j=>typeof j!="string"||!/^[A-Za-z0-9._ -]{1,128}$/.test(j)))throw new d("Provide valid Relay swap source names.");m[E]=p}}let S=await N("/quote/v2",{user:g,recipient:c,originChainId:i,destinationChainId:e,originCurrency:h,destinationCurrency:b,amount:a,tradeType:n,...m}),o=A(S.details),l=$(k(o.currencyIn)),s=$(k(o.currencyOut)),C=U(A(o.currencyOut).minimumAmount);F(T(o.sender)===g&&T(o.recipient)===c&&l.token.chainId===i&&l.token.address===h&&(n==="EXACT_INPUT"?l.amount===a:s.amount===a)&&s.token.chainId===e&&s.token.address===b&&BigInt(C)<=BigInt(s.amount));let H=Object.fromEntries(Object.entries(A(S.fees)).map(([E,p])=>[E,$(k(p))])),R=typeof o.timeEstimate=="number"&&Number.isFinite(o.timeEstimate)&&o.timeEstimate>=0?o.timeEstimate:void 0,v=M(S.fees),X=e===y,x=X?"relay_bridge_in":"relay_bridge_out",q=n==="EXACT_INPUT"&&Object.keys(m).length===0&&i!==e&&(!X||D(i)!==void 0);return{executable:!1,nextAction:q?x:void 0,originChainId:i,destinationChainId:e,recipient:c,tradeType:n,amountIn:l,amountOut:s,minAmountOut:{token:s.token,amount:C},fees:H,...v,slippage:{source:"provider",minimumAmount:C},...R===void 0?{}:{timeEstimateSeconds:R},summary:`${v.feeDisclosure} Read-only Relay estimate: ${l.amount} base units of ${l.token.symbol} (${l.token.decimals} decimals) on chain ${i} for about ${s.amount}, minimum ${C}, base units of ${s.token.symbol} (${s.token.decimals} decimals) on chain ${e} for ${c}. Slippage: selected by Relay; Oak sent no slippage setting. The returned minimum above is the quote floor. Relay fees are already deducted from the output; origin gas is separate. Nothing was built or signed, and this estimate cannot be executed. ${q?`To bridge, call ${x}; it fetches a fresh quote and shows its own preview for human confirmation.`:"This estimate shape has no matching Oak execution path. No action will preserve these trade type or routing options."}`}}async function Z(t){let r=t.chainId===void 0?void 0:I(t.chainId),i=B((await N("/chains")).chains).map(A).flatMap(e=>{if(typeof e.id!="number"||!Number.isSafeInteger(e.id)||e.id<=0)return[];if(r!==void 0&&e.id!==r)return[];let h=e.disabled===!1,b=_(e.currency)?e.currency:{},c={chainId:e.id,name:f(e.displayName,"name")??f(e.name,"name")??String(e.id),vmType:f(e.vmType),nativeCurrency:{symbol:f(b.symbol),decimals:typeof b.decimals=="number"?b.decimals:void 0},bridgeIn:e.id!==y&&h&&D(e.id)!==void 0,bridgeOut:e.id!==y&&h&&e.vmType==="evm"};if(r===void 0)return[c];let a=new Map;for(let n of[...Array.isArray(e.featuredTokens)?e.featuredTokens:[],...Array.isArray(e.erc20Currencies)?e.erc20Currencies:[]]){if(!_(n)||typeof n.address!="string"||!new RegExp(w).test(n.address)||typeof n.decimals!="number"||!Number.isInteger(n.decimals)||n.decimals<0||n.decimals>255)continue;let m=T(n.address);a.has(m)||a.set(m,{address:m,symbol:f(n.symbol)??"unknown",decimals:n.decimals,bridgeable:n.supportsBridging===!0})}return[{...c,currencies:[...a.values()]}]});if(r!==void 0&&!i.length)throw new d(`Relay does not list chain ${r}.`);return{chains:i,summary:`${i.length} Relay chain${i.length===1?"":"s"}. bridgeIn marks origins relay_bridge_in can build from; bridgeOut marks destinations relay_bridge_out can reach. Currency lists are Relay-reported display data; bridgeable false means Relay does not bridge that token. Confirm token addresses before bridging.`}}return{tools:[{name:"relay_quote",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","destinationChainId","amount"],properties:{originChainId:{type:"integer",minimum:1,description:"Origin chain ID."},destinationChainId:{type:"integer",minimum:1,description:"Destination chain ID."},originCurrency:{type:"string",pattern:w,description:"Origin token address; defaults to the origin chain\u2019s native token."},destinationCurrency:{type:"string",pattern:w,description:"Destination token address; defaults to the destination chain\u2019s native token."},amount:{type:"string",pattern:"^[1-9][0-9]*$",description:'Input token amount for EXACT_INPUT, otherwise output token amount, in base units using that token\u2019s decimals (USDG has 6: "1000000" = 1 USDG).'},recipient:{type:"string",pattern:w,description:"Destination recipient address; defaults to your wallet."},tradeType:{type:"string",enum:["EXACT_INPUT","EXACT_OUTPUT","EXPECTED_OUTPUT"],description:"EXACT_INPUT fixes input; EXACT_OUTPUT fixes output; EXPECTED_OUTPUT targets output."},...Object.fromEntries(["includedSwapSources","excludedSwapSources","includedOriginSwapSources","includedDestinationSwapSources"].map(t=>[t,{type:"array",description:t==="excludedSwapSources"?"Swap sources to exclude.":t==="includedOriginSwapSources"?"Origin swap sources to include.":t==="includedDestinationSwapSources"?"Destination swap sources to include.":"Swap sources to include.",maxItems:100,items:{type:"string",pattern:"^[A-Za-z0-9._ -]{1,128}$"}}]))}},execute:async(t,r)=>{try{return await G(t,r)}catch(g){throw new d(u.plainError(g))}}},{name:"relay_chains",inputSchema:{type:"object",additionalProperties:!1,properties:{chainId:{type:"integer",minimum:1,description:"Filter by chain ID."}}},execute:async t=>{try{return await Z(t)}catch(r){throw new d(u.plainError(r))}}}]}};export{Q as a};
@@ -0,0 +1 @@
1
+ import{a as $e,b as Ee}from"./YEIM6BZQ.js";import{c as en,d as nn,e as _e,f as he,i as Ue,j as tn}from"./RLI4JDOL.js";import{i as de}from"./U2YCQWZK.js";import{b as Te,o as Me}from"./CAWTAR5V.js";import{a as ce}from"./H5DY7CNB.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{a as y,d as Ze,i as Q,j as Ye,m as Qe}from"./FWD4L3CJ.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as on,getAddress as w,isAddress as Nn,keccak256 as Kn,pad as Hn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Fn,toHex as rn}from"viem";var Vn=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),le=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),At=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Xe=8388608,Fe=-887272,ve=887272,An=(1n<<48n)-1n,J=(1n<<128n)-1n,Bn=(1n<<160n)-1n,pe=1n<<96n,sn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",an=1800n,me=50n,cn=(e,n=me)=>e*(10000n-n)/10000n,dn=(e,n,i=me)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Xn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Oe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Sn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",On={currency0:k,currency1:D,fee:Xe,tickSpacing:1,hooks:Re},Rn=new Set([...Oe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),zn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),jn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Wn=z("address currency0, address currency1"),Gn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Zn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),ue=z("bytes actions, bytes[] params"),X=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Yn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),un=z("address currency"),pn=1e6,fe=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Qn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Jn=Fn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Nn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===ce.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===ce.toLowerCase()}function ye(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Kn(S(zn,[n,i,e.fee,e.tickSpacing,r]))}function In(e){return((typeof e=="number"?e:e.fee)&Xe)!==0}function ln(e,n){return In(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ee(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ee(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=In(e.fee);if(!s&&e.fee>pn)throw new o(`PoolKey static fee ${$e(e.fee)} exceeds the v4 maximum of ${$e(pn)}.`);if(s&&e.fee!==Xe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!Rn.has(c.toLowerCase()))throw c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Re&&d.toLowerCase()!==Sn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function et(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function nt(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function mn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Bn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>An)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Qn,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function fn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function tt(e){let n=(e&0xffn)!==0n,i=fn(e>>8n&0xffffffn),r=fn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function yn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function wn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function Cn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=de(e.tickLower),i=de(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:yn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:yn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:wn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:wn(n,i,e.liquidity,e.roundUp)}}function it(e){let n=de(e.tickLower),i=de(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function bn(e,n=y){if(H(e))return{address:ce,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return bn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return bn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:on,functionName:"symbol"}),e.readContract({address:r,abi:on,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:tn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function hn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function qn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await qn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ye(u),poolKey:u}}let s=(i??Xn).toLowerCase();if(s===Sn)return{poolId:s,poolKey:ke(On,s)};let t=Oe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:X,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:X,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=tt(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function ot(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function gn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[Jn,null,Hn(r)],fromBlock:rn(p),toBlock:rn(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:X,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:X,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:le,abi:fe,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Cn({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var rt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(me)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},st={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ct={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function kn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function Pn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return nn(BigInt(e.sqrtPriceX96))}return en(e.initialPrice,n,i)}async function ut(e,n,i){let r;try{r=await e.readContract({address:M,abi:X,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function vn(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Oe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:le,abi:fe,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:le,abi:fe,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function xn(e,n,i,r,c,s){return e.unsignedTx({to:Vn.toLowerCase(),data:re({abi:Yn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var pt=e=>({tools:[{name:"uniswap_add",inputSchema:rt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(sn);let m=t.slippageBps===void 0?Number(me):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(sn);let f=BigInt(m),P=e.clientFor(y);p&&kn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await ut(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=et(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),nt(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:le,abi:fe,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=Pn(t,h.decimals,g.decimals),V=Ue(q,await vn(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):it({amount0:cn(A,f),amount1:cn(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Cn({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:dn(ee,A,f),Y=l?I:dn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await qn(P),O=await Ke(P,t.deadline,U.toString()),te=O<U+an?O:U+an,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>An)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[xn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ae=u.currency0.toLowerCase();G.push(e.approval(ae,He.toLowerCase(),q.toString(),y)),G.push(mn(ae,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ae=u.currency1.toLowerCase();G.push(e.approval(ae,He.toLowerCase(),V.toString(),y)),G.push(mn(ae,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(jn,[R,v,x,E,q,V,$.toLowerCase(),ie]),$n=S(Wn,[R.currency0,R.currency1]),We=S(Gn,[k,$.toLowerCase()]),En=S(ge,[a??0n,E,q,V,ie]),_n=a===void 0?S(ue,["0x020d14",[Le,$n,We]]):S(ue,["0x00121214",[En,S(un,[R.currency0]),S(un,[R.currency1]),We]]),Un=re({abi:X,functionName:"modifyLiquidities",args:[_n,O]}),Dn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Un,value:Dn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?ce:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Ln=Ne(we.changes,e.formatAmount),qe=ln(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],Tn=Se.length,Mn=a===void 0?`This deposit takes ${Tn} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(me)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:O.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:_e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${Mn}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Ln.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(ue,["0x0111",[g,A]]),F=re({abi:X,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:X,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,O)=>{let te=h?S(Zn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,O]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:X,functionName:"modifyLiquidities",args:[S(ue,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:X,functionName:"modifyLiquidities",args:[S(ue,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),O=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=O(b),j=O(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):hn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):hn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):ot(t.wallet),m=await gn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:st,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');kn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:le,abi:fe,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=Pn(t,m.decimals,f.decimals),u=Ue(b,await vn(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[xn(e,l,p,b,m,f)],h=await e.preview(x,d),g=ln(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:_e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>gn(e,t)}),St=pt;export{Vn as a,M as b,le as c,He as d,At as e,se as f,D as g,k as h,Xe as i,Fe as j,ve as k,Xn as l,Ve as m,Oe as n,Re as o,Sn as p,On as q,Rn as r,H as s,ye as t,In as u,ln as v,ke as w,et as x,nt as y,mn as z,tt as A,Cn as B,it as C,Ne as D,bn as E,B as F,Pe as G,gn as H,rt as I,st as J,at as K,ct as L,dt as M,vn as N,pt as O,St as P};
@@ -0,0 +1,3 @@
1
+ import{a as ke,b as Te}from"./GSFHM5L3.js";import{b as be,o as we}from"./CAWTAR5V.js";import{a as ye}from"./H5DY7CNB.js";import{c as ie}from"./SCG5HWMN.js";import{a as O}from"./66F5ZH34.js";import{b as re,c as R,d as fe,g as p,i as he,n as ge}from"./NWNYJ26T.js";import{a as l,i as oe,l as u}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{a as F}from"./JXOEJPJ4.js";import{decodeEventLog as qe,encodeAbiParameters as Ue,encodeFunctionData as M,erc20Abi as j,getAddress as Ie,keccak256 as Oe,parseAbi as D,parseAbiItem as Me,toHex as He,zeroAddress as S}from"viem";var ce=oe[l].pons.launchAndBuyRouter.address,Pe=oe[l].ponsTrade.state_view.address,J={address:S,chainId:l,symbol:"ETH",decimals:18},f=D(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))","function previewLaunchEconomics(uint256,address) view returns (bytes32)","function launchFee() view returns (uint256)","function canLaunch(address) view returns (bool)","function launchConfigCount() view returns (uint256)","function approvedPairTokens(address) view returns (bool)","function pairTokenEconomics(address) view returns (uint256 phantomQuote,uint256 graduationThreshold,uint8 decimals)","function transferCreatorFeeRecipient(address token,address newRecipient)","function setBuybackEnabled(address token,bool enabled)","function getLaunchConfig(uint256) view returns ((uint256 supply,uint256 curveFeeBps,uint256 phantomQuote,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,bool enabled))","function maxCreatorTaxBps() view returns (uint256)","function getLaunchFeePolicy(address) view returns ((address,uint16,uint16,uint16,uint16))","function memeHook() view returns (address)","function createGraduatedPool(address)"]),z=D(["function factory() view returns (address)","function feeEscrow() view returns (address)","function getReserves() view returns (uint256,uint256)","function realQuoteReserve() view returns (uint256)","function feeBps() view returns (uint256)"]),je=D(["function launchFactory() view returns (address)"]),De=D(["function currentFeePolicy() view returns ((address,uint16,uint16,uint16,uint16))"]),ve=D(["function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]),ae=D(["function launchToken((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address) payable","function launchToken((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address,address[]) payable","function launchAndBuy((string,string,string,string,(string,string,string,string,string),address,uint16,bool,bytes32,bytes32),uint256,address,uint256,uint256,address,address[]) payable"]),Fe=Me("event TokenLaunched(address indexed token,address indexed curve,address indexed deployer,address pairToken,uint256 launchConfigId,uint256 graduationThreshold)"),We=["curve","pending pool creation","graduated","rescued"],Ge=10000n,xe=2000n;function C(n){return he(n,"Provide a token or wallet address.",fe)}function H(n){return ge(n,"Amount exceeds the uint256 range.",{notString:"Amounts must be integer strings in base units."})}function Ce(n,e){if(typeof n!="string"||!n.trim())throw new i(`Provide ${e}.`);return n}function N(n,e){return{token:n,amount:e.toString()}}function Re(n,e,t,r,o){let a=n*BigInt(t)/10000n,s=r?(n-a)*BigInt(o)/10000n:0n;return{baseBps:n.toString(),creatorTaxBps:e.toString(),totalBps:(n+BigInt(e)).toString(),protocolBps:a.toString(),creatorBps:(n-a-s+BigInt(e)).toString(),buybackBps:s.toString(),buybackEnabled:r}}async function Q(n,e,t){if(p(e,S))return J;let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:j,functionName:"symbol",blockNumber:t}),r.readContract({address:e,abi:j,functionName:"decimals",blockNumber:t})]);return{address:Ie(e),chainId:l,symbol:F(o),decimals:a}}async function X(n,e,t){let r=n.clientFor(l),[o,a]=await Promise.all([r.readContract({address:e,abi:je,functionName:"launchFactory",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchedToken",args:[e],blockNumber:t})]);if(!p(o,u)||!a.exists||!p(a.token,e))throw new i("This token is not a launch from the supported Pons factory.");if(a.phase>3)throw new i("Pons returned an unknown launch phase.");return a}async function de(n,e,t){let r=n.clientFor(l),o=await X(n,e,t),[a,s,d,c,h,g,y]=await Promise.all([Q(n,e,t),Q(n,o.pairToken,t),r.readContract({address:e,abi:j,functionName:"totalSupply",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"factory",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeEscrow",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"memeHook",blockNumber:t}),r.readContract({address:u,abi:f,functionName:"getLaunchFeePolicy",args:[e],blockNumber:t})]);if(!p(c,u))throw new i("The Pons curve does not belong to the supported factory.");let m=BigInt(y[3]),A=o.sweptQuote,b=null,T=null,_=null;if(o.phase===0){let[P,I,w]=await Promise.all([r.readContract({address:o.curve,abi:z,functionName:"getReserves",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"realQuoteReserve",blockNumber:t}),r.readContract({address:o.curve,abi:z,functionName:"feeBps",blockNumber:t})]);if(A=I,m=w,o.graduationThreshold<=0n||P[1]<=0n)throw new i("Pons returned unavailable curve reserves or threshold.");b=I*1000000n/o.graduationThreshold,b>1000000n&&(b=1000000n),T=N(s,P[0]*10n**BigInt(a.decimals)/P[1])}else if(o.phase===2){let P=[e,o.pairToken].sort(($,x)=>BigInt($)<BigInt(x)?-1:1),I=Oe(Ue([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[P[0],P[1],o.poolFee,o.tickSpacing,g])),[w,q]=await Promise.all([r.readContract({address:Pe,abi:ve,functionName:"getSlot0",args:[I],blockNumber:t}),r.readContract({address:Pe,abi:ve,functionName:"getLiquidity",args:[I],blockNumber:t})]);if(w[0]===0n)throw new i("The graduated Pons pool price is unavailable.");let E=w[0]**2n,U=10n**BigInt(a.decimals);T=N(s,p(P[0],e)?E*U/(1n<<192n):(1n<<192n)*U/E),_={id:I,sqrtPriceX96:w[0].toString(),tick:w[1],protocolFee:w[2],lpFee:w[3],liquidity:q.toString()},b=1000000n}else o.phase===1&&(b=1000000n);return{token:a,pairToken:s,blockNumber:t.toString(),factory:u,curve:o.curve,hook:g,escrow:h,creator:o.deployer,creatorFeeRecipient:o.creatorFeeRecipient,phase:o.phase,phaseName:We[o.phase],tradable:o.phase===0||o.phase===2,graduationThreshold:N(s,o.graduationThreshold),raised:N(s,A),sweptTokens:N(a,o.sweptTokens),sweptAt:o.sweptAt.toString(),progressPpm:b?.toString()??null,totalSupply:N(a,d),fees:Re(m,o.creatorTaxBps,y[1],o.buybackEnabled,y[2]),pool:_,spot:T,priceKind:"Marginal spot per whole token; not an execution quote or time average."}}async function ze(n,e,t,r){let o=n.clientFor(l),[a,s]=await Promise.all([o.readContract({address:e.token.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r}),p(e.pairToken.address,S)?o.getBalance({address:t,blockNumber:r}):o.readContract({address:e.pairToken.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:r})]),d;try{let c=await ke(n,e.token.address,t,!1,r),h=c.credited.some(g=>BigInt(g.amount)>0n)||BigInt(c.buybackVest.releasable.amount)>0n;d={isRecipient:c.isRecipient,recipient:c.recipient,escrow:c.escrow,credited:c.credited,pendingBeforeSweep:c.pendingBeforeSweep,operatorWait:c.operatorWait??null,buybackVest:c.buybackVest,nextStep:[c.isRecipient&&(h||c.txs.length||c.pendingBeforeSweep.length&&!c.operatorWait)?"pons_claim builds the sweep, vest release and escrow claims for this wallet.":"",!c.isRecipient&&h?"Escrow credits belong to this holder; only the current creator fee recipient can sweep or release this coin.":"",c.operatorWait?`${Te(c.operatorWait)} Oak cannot run it; credited amounts stay claimable.`:""].filter(Boolean).join(" ")||"Nothing to sweep or claim for this holder."}}catch(c){d={unavailable:n.plainError(c)}}return{holder:t,holding:N(e.token,a),pairBalance:N(e.pairToken,s),creatorFees:d,note:"Sell the actual holding shown here, not a quoted output. Balances are read at the status block."}}async function Qe(n,e,t){try{let r=await n.clientFor(l).getBlockNumber({cacheTime:0}),o=await de(n,C(e),r);return t===void 0?o:{...o,account:await ze(n,o,C(t),r)}}catch(r){throw new i(n.plainError(r))}}var Ae="https://ponsfamily.com/api/launches",Ve=n=>{let e=n;return!!e&&Array.isArray(e.items)&&e.items.length<=100&&(e.nextCursor===null||e.nextCursor===void 0||typeof e.nextCursor=="string")&&e.items.every(t=>!!t&&typeof t.address=="string"&&re.test(t.address)&&typeof t.factory=="string"&&re.test(t.factory))};async function Je(n,e){let t=e.limit??20;if(typeof t!="number"||!Number.isInteger(t)||t<1||t>40)throw new i("Choose a search or listing limit from 1 to 40.");let r=new URL(Ae);if(e.query!==void 0){if(typeof e.query!="string"||!e.query.trim()||e.query.length>100)throw new i("Provide a name, symbol or address query of 1 to 100 characters.");r.searchParams.set("q",e.query.trim())}else r.searchParams.set("sort","newest");if(e.cursor!==void 0){if(e.query!==void 0)throw new i("Search returns one page; use cursor only for the newest-first listing.");if(typeof e.cursor!="string"||!/^[0-9]{1,20}(\.0x[0-9a-fA-F]{40})?$/.test(e.cursor))throw new i("Use the nextCursor returned by the previous pons_browse page.");r.searchParams.set("cursor",e.cursor)}r.searchParams.set("limit",String(t));let o=await ie(n.http,r,{method:"GET",redirect:"error"},Ve);if(o.nextCursor&&!/^[0-9]{1,20}(\.0x[0-9a-fA-F]{40})?$/.test(o.nextCursor))throw new i("Pons returned a malformed listing cursor.");let a=o.items.filter(h=>p(h.factory,u)),s=[...new Map(a.map(h=>[h.address.toLowerCase(),Ie(h.address)])).values()].slice(0,t),d=await n.clientFor(l).getBlockNumber({cacheTime:0});return{items:await Promise.all(s.map(h=>de(n,h,d))),statusBlock:d.toString(),source:Ae,nextCursor:e.query===void 0?o.nextCursor??null:null,excludedOtherFactories:o.items.length-a.length,coverage:e.query!==void 0?"Pons index search over every launch (one page, at most 40). Results are discovery only; each one was re-read on chain from the pinned factory.":"Newest-first page of Pons's complete launch index; pass nextCursor to continue until it is null. Each item was re-read on chain; launches from other Pons factories are dropped."}}async function Ke(n,e={}){if(e.query!==void 0||e.cursor!==void 0||e.complete===!0)try{if(e.fromBlock!==void 0||e.toBlock!==void 0)throw new i("Use block bounds for an on-chain window, or query/cursor for the Pons index, not both.");return await Je(n,e)}catch(t){throw new i(n.plainError(t))}return Ne(n,e)}async function Ne(n,e={}){try{let t=n.clientFor(l),r=await t.getBlockNumber({cacheTime:0}),o=e.toBlock===void 0?r:H(e.toBlock),a=e.fromBlock===void 0?o>=xe?o-xe+1n:0n:H(e.fromBlock),s=e.limit??20;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>100)throw new i("Choose a launch limit from 1 to 100.");if(a>o||o>r||o-a+1n>Ge)throw new i("Choose an ordered range of at most 10000 mined blocks.");let d=await t.getLogs({address:u,event:Fe,fromBlock:a,toBlock:o,strict:!0}),c=new Map;for(let y of d.filter(m=>p(m.address,u)&&!m.removed&&m.blockNumber!==null&&m.blockNumber>=a&&m.blockNumber<=o).sort((m,A)=>m.blockNumber===A.blockNumber?(A.logIndex??0)-(m.logIndex??0):m.blockNumber>A.blockNumber?-1:1)){let m=C(y.args.token);c.set(m.toLowerCase(),m)}let h=[...c.values()];return{items:await Promise.all(h.slice(0,s).map(y=>de(n,y,r))),fromBlock:a.toString(),toBlock:o.toString(),statusBlock:r.toString(),truncated:h.length>s,coverage:"Only launches in the requested block range; this is not a complete launch history."}}catch(t){throw new i(n.plainError(t))}}async function K(n,e,t,r){let o=(Array.isArray(e)?e:[e]).map(n.unsignedTx),a=await n.preview(o,t),s=a.changes.map(d=>{let c=d.amount.startsWith("-");return`${c?"-":""}${n.formatAmount(c?d.amount.slice(1):d.amount,d.token.decimals)} ${d.token.symbol} (${d.token.chainId}:${d.token.address})`});return{txs:o,preview:a,summary:`${r} ${a.summary}${s.length?` Changes: ${s.join(", ")}.`:""}`}}var V=["twitter","telegram","discord","website","farcaster"],Be=5242880,$e="https://ponsfamily.com/api/ipfs/image";function se(n,e){if(n==="")return"";if(typeof n!="string"||n.length>2048)throw new i(`Provide a public HTTPS or IPFS ${e}.`);try{let t=new URL(n);if(!["https:","ipfs:"].includes(t.protocol)||!t.hostname||t.username||t.password)throw new Error}catch{throw new i(`Provide a public HTTPS or IPFS ${e}.`)}return n}function Xe(n){if(n===void 0)return;if(!n||typeof n!="object"||Array.isArray(n))throw new i("Provide image mimeType and base64.");let e=n,t={"image/png":"png","image/jpeg":"jpg","image/webp":"webp"};if(Object.keys(e).some(s=>!["mimeType","base64"].includes(s))||typeof e.mimeType!="string"||!t[e.mimeType])throw new i("Use a PNG, JPEG, or WebP image.");if(typeof e.base64!="string"||!e.base64.length||e.base64.length>4*Math.ceil(Be/3)||e.base64.length%4!==0||!/^[A-Za-z0-9+/]*={0,2}$/.test(e.base64))throw new i("Provide a base64 image of 1 to 5242880 bytes.");let r=atob(e.base64);if(!r.length||r.length>Be||btoa(r)!==e.base64)throw new i("Provide a base64 image of 1 to 5242880 bytes.");let o=Uint8Array.from(r,s=>s.charCodeAt(0));if(!(e.mimeType==="image/png"?r.startsWith(`\x89PNG\r
2
+ 
3
+ `):e.mimeType==="image/jpeg"?o[0]===255&&o[1]===216&&o[2]===255:r.startsWith("RIFF")&&r.slice(8,12)==="WEBP"))throw new i("Image bytes do not match the declared PNG, JPEG, or WebP type.");return{bytes:o,mimeType:e.mimeType,extension:t[e.mimeType]}}async function Ye(n,e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Provide a mined Pons launch transaction hash.");let o=await n.clientFor(l).getTransactionReceipt({hash:e});if(o.status!=="success"||!p(o.from,t))throw new i("The Pons launch must be a successful transaction from this wallet.");let a=o.logs.flatMap(c=>{if(!p(c.address,u))return[];try{return[qe({abi:[Fe],data:c.data,topics:c.topics,strict:!0}).args]}catch{return[]}}).filter(c=>p(c.deployer,t));if(a.length!==1)throw new i("The receipt does not contain exactly one Pons launch for this wallet.");let s=a[0].token,d=await X(n,s,o.blockNumber);return{transactionHash:e,token:await Q(n,s,o.blockNumber),curve:d.curve,creator:d.deployer,creatorFeeRecipient:d.creatorFeeRecipient,chainId:l,summary:`Pons launch mined: ${s}. Creator fee recipient ${d.creatorFeeRecipient}. Use pons_status to inspect the launch and pons_claim to collect creator fees.`}}async function Ze(n,e,t){let r=Ce(e.name,"a coin name"),o=Ce(e.symbol,"a coin symbol");if(e.creatorFeeRecipient===void 0)throw new i("Provide an explicit nonzero creatorFeeRecipient; it is never defaulted to the agent wallet.");let a=C(e.creatorFeeRecipient);if(p(a,S))throw new i("Provide a nonzero creator fee recipient.");if(!p(a,t))throw new i("Pons creator fee recipient must be the signing wallet.");let s=C(e.pairToken??S),d=H(e.launchConfigId??"0"),c=H(e.initialBuy??"0"),h=C(e.buyRecipient??t);if(p(h,S))throw new i("Provide a nonzero initial buy recipient.");if(c===0n&&e.buyRecipient!==void 0)throw new i("A buy recipient requires an initial buy.");let g=H(e.minTokensOut??"0");if(c>0n&&e.minTokensOut!==void 0&&g<=1n)throw new i("Initial buy minimum must exceed one token base unit.");if(c>0n&&!p(h,t)&&e.minTokensOut===void 0)throw new i("Provide minTokensOut for an initial buy sent to another wallet.");if(c===0n&&g!==0n)throw new i("A launch without an initial buy must have a zero token minimum.");let y=e.creatorTaxBps??100;if(typeof y!="number"||!Number.isInteger(y)||y<0||y>65535)throw new i("Creator tax must be an integer number of basis points.");let m=e.buybackEnabled??!1;if(typeof m!="boolean")throw new i("Buyback enabled must be true or false.");let A=e.metadata??["",""],b=e.links??["","","","",""];if(!Array.isArray(A)||A.length!==2||!A.every(k=>typeof k=="string")||!Array.isArray(b)||b.length!==5||!b.every(k=>typeof k=="string"))throw new i("Provide two metadata strings and five link strings in ABI order.");if(e.metadata!==void 0&&(e.logo!==void 0||e.description!==void 0||e.image!==void 0))throw new i("Use named logo, description and image inputs or legacy metadata, not both.");if(e.links!==void 0&&e.socials!==void 0)throw new i("Use named socials or legacy links, not both.");let T=se(e.logo??A[0],"coin image URI"),_=e.description??A[1];if(typeof _!="string")throw new i("Provide a coin description string.");let P=e.socials;if(P!==void 0&&(!P||typeof P!="object"||Array.isArray(P)||Object.keys(P).some(k=>!V.includes(k))))throw new i("Provide twitter, telegram, discord, website and farcaster social links.");let I=V.map((k,v)=>se(P===void 0?b[v]:P[k]??"",`${k} link`)),w=Xe(e.image);if(w&&T)throw new i("Provide an image upload or an existing logo URI, not both.");let q=e.snipeTaxExemptions??[];if(!Array.isArray(q)||q.length>31)throw new i("Provide at most 31 snipe tax exemption addresses.");let E=q.map(C),U=e.salt??He(crypto.getRandomValues(new Uint8Array(32)));if(typeof U!="string"||!/^0x[0-9a-fA-F]{64}$/.test(U))throw new i("Salt must be 32 hex-encoded bytes.");let $=n.clientFor(l),x=await $.getBlockNumber({cacheTime:0}),[ue,Ee]=await Promise.all([$.readContract({address:u,abi:f,functionName:"canLaunch",args:[t],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"launchConfigCount",blockNumber:x})]);if(!ue)throw new i("This wallet cannot launch on Pons. Ask Pons for launch access and retry when canLaunch is true.");if(d>=Ee)throw new i("Choose an existing Pons launchConfigId using pons_launch_options.");let[Y,W,Le,_e]=await Promise.all([$.readContract({address:u,abi:f,functionName:"launchFee",blockNumber:x}),$.readContract({address:u,abi:f,functionName:"getLaunchConfig",args:[d],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"maxCreatorTaxBps",blockNumber:x}),$.readContract({address:u,abi:f,functionName:"memeHook",blockNumber:x})]);if(!W.enabled)throw new i("This Pons launch configuration is disabled. Choose an enabled launchConfigId.");let L=J,le=W.phantomQuote,pe=W.graduationThreshold;if(!p(s,S)){let[k,v]=await Promise.all([$.readContract({address:u,abi:f,functionName:"approvedPairTokens",args:[s],blockNumber:x}),$.readContract({address:u,abi:f,functionName:"pairTokenEconomics",args:[s],blockNumber:x})]);if(!k||v[0]<=0n||v[1]<=0n)throw new i("This pair token is not approved with usable Pons economics. Choose a supported pair.");if(L=await Q(n,s,x),v[2]!==L.decimals)throw new i("Pair token decimals disagree with Pons. Ask Pons to refresh pair economics.");[le,pe]=v}if(BigInt(y)>Le)throw new i("Creator tax exceeds the current Pons maximum.");let[Z,ee]=await Promise.all([$.readContract({address:u,abi:f,functionName:"previewLaunchEconomics",args:[d,s],blockNumber:x}),$.readContract({address:_e,abi:De,functionName:"currentFeePolicy",blockNumber:x})]);if(e.expectedEconomics!==void 0&&e.expectedEconomics!==Z)throw new i("Pons launch economics changed. Refresh the launch preview.");let G=Re(W.curveFeeBps,y,ee[1],m,ee[2]),te="";if(w){let k=new FormData;k.append("image",new Blob([w.bytes],{type:w.mimeType}),`coin.${w.extension}`);let v=await ie(n.http,$e,{method:"POST",body:k,redirect:"error"},B=>!!B&&typeof B=="object"&&typeof B.uri=="string");if(T=se(v.uri,"uploaded coin image URI"),!T)throw new i("Pons returned an empty image URI. Retry with a public image URI.");te=`Image (${w.bytes.length} bytes, ${w.mimeType}) uploaded via multipart POST to ${$e}; URI ${F(T)}. This off-chain upload persists even if launch is cancelled or fails; Pons retention/deletion is unknown.`}let ne=k=>{let v=[r,o,T,_,I,a,y,m,Z,U],B={to:c===0n?u:ce,chainId:l,value:(Y+(p(s,S)?c:0n)).toString(),data:c===0n?E.length?M({abi:ae,functionName:"launchToken",args:[v,d,s,E]}):M({abi:ae,functionName:"launchToken",args:[v,d,s]}):M({abi:ae,functionName:"launchAndBuy",args:[v,d,s,c,k,h,E]}),description:`Launch ${F(r)} through the Pons ${c===0n?"factory":"router"} from ${t}; creator fees to ${a}. ${te}`.trim()};return c>0n&&!p(s,S)?[n.approval(s,ce,c.toString(),l),B]:[B]};if(c>0n&&e.minTokensOut===void 0){let v=(await n.preview(ne(0n).map(n.unsignedTx),t)).changes.filter(B=>B.token.chainId===l&&!p(B.token.address,S)&&!p(B.token.address,ye)&&!p(B.token.address,s)&&B.token.decimals===18&&/^\d+$/.test(B.amount)&&BigInt(B.amount)>0n);if(v.length!==1)throw new i("Pons launch preview did not identify a unique initial buy token output.");if(g=BigInt(we(v[0].amount,be)),g<=1n)throw new i("Initial buy minimum must exceed one token base unit.")}let me=await K(n,ne(g),t,`Unsigned Pons launch from ${t}: ${F(r)} (${F(o)}), image ${T?F(T):"none"}, description ${F(_)}, links ${JSON.stringify(Object.fromEntries(V.map((k,v)=>[k,F(I[v])])))}. canLaunch=true at block ${x}; config ${d}, supply ${W.supply}, phantom quote ${le}, graduation threshold ${pe} pair base units. Pair ${L.symbol} (${l}:${L.address}, ${L.decimals} decimals). Initial buy ${n.formatAmount(c.toString(),L.decimals)} ${L.symbol} to ${h}; minimum ${g} token base units (18 decimals). Launch fee ${n.formatAmount(Y.toString(),18)} ETH plus gas; exact transaction value ${ne(g).at(-1).value} wei. Curve fees ${G.totalBps} bps total, ${G.protocolBps} bps protocol, ${G.creatorBps} bps creator, ${G.buybackBps} bps buyback; creator tax ${y} bps, buybacks ${m?"on":"off"}, graduated hook fee ${ee[3]} bps plus creator tax. Creator fee recipient ${a}. Extra opening-tax exemptions ${JSON.stringify(E)}. Name, metadata, pair, tax and launch economics are fixed after launch. ${te}`);return{...me,creatorFeeWarning:void 0,preview:{...me.preview,warnings:[]},canLaunch:ue,blockNumber:x.toString(),launchConfigId:d.toString(),pairToken:L,salt:U,logo:T&&F(T),economics:Z,launchFee:N(J,Y),initialBuy:N(L,c),minimum:{amount:g.toString(),decimals:18,token:{chainId:l,address:null,name:F(r),symbol:F(o)},addressStatus:"Read the mined token address with pons_launch transactionHash; the local bridge does this automatically."},fees:G}}async function et(n,e,t){let r=n.clientFor(l),o=await r.getBlockNumber({cacheTime:0}),a=C(e.pairToken??S),[s,d,c,h]=await Promise.all([r.readContract({address:u,abi:f,functionName:"canLaunch",args:[t],blockNumber:o}),r.readContract({address:u,abi:f,functionName:"launchConfigCount",blockNumber:o}),r.readContract({address:u,abi:f,functionName:"launchFee",blockNumber:o}),r.readContract({address:u,abi:f,functionName:"maxCreatorTaxBps",blockNumber:o})]),g=H(e.offset??"0"),y=await Promise.all(Array.from({length:Number(d>g?d-g>100n?100n:d-g:0n)},async(_,P)=>{let I=g+BigInt(P),w=await r.readContract({address:u,abi:f,functionName:"getLaunchConfig",args:[I],blockNumber:o});return{id:I.toString(),...Object.fromEntries(Object.entries(w).map(([q,E])=>[q,typeof E=="bigint"?E.toString():E]))}})),m=p(a,S),[A,b,T]=await Promise.all([m?!0:r.readContract({address:u,abi:f,functionName:"approvedPairTokens",args:[a],blockNumber:o}),m?void 0:r.readContract({address:u,abi:f,functionName:"pairTokenEconomics",args:[a],blockNumber:o}),Q(n,a,o)]);return{chainId:l,factory:u,router:ce,blockNumber:o.toString(),canLaunch:s,launchFee:N(J,c),maxCreatorTaxBps:h.toString(),configs:y,configCount:d.toString(),nextOffset:g+BigInt(y.length)<d?(g+BigInt(y.length)).toString():null,pairToken:T,pairApproved:A&&(!b||b[0]>0n&&b[1]>0n&&b[2]===T.decimals),pairEconomics:b?{phantomQuote:b[0].toString(),graduationThreshold:b[1].toString(),decimals:b[2]}:null,pairDiscovery:"Native ETH or any approved ERC-20 address with usable pairTokenEconomics; query each candidate address. The factory has no pair enumeration read."}}async function Se(n,e,t,r){let o=C(e.token),a=await X(n,o,await n.clientFor(l).getBlockNumber({cacheTime:0}));if(!p(a.creatorFeeRecipient,t))throw new i(`Only the current creator fee recipient ${a.creatorFeeRecipient} can change this setting. Use that wallet.`);if(r){let s=C(e.creatorFeeRecipient);if(p(s,S))throw new i("Provide a nonzero creator fee recipient.");return K(n,{to:u,chainId:l,value:"0",data:M({abi:f,functionName:"transferCreatorFeeRecipient",args:[o,s]}),description:`Transfer future creator fees and the buyback vest beneficiary for ${o} to ${s}.`},t,`Unsigned Pons fee recipient transfer to ${s}; previously credited fees stay with ${t}. This wallet loses future fee controls. Cost: gas only.`)}if(typeof e.enabled!="boolean")throw new i("Buyback enabled must be true or false.");return K(n,{to:u,chainId:l,value:"0",data:M({abi:f,functionName:"setBuybackEnabled",args:[o,e.enabled]}),description:`Turn Pons buybacks ${e.enabled?"on":"off"} for ${o}.`},t,`Unsigned Pons buyback change: ${e.enabled?"on; funded from the creator fee share, tokens vest over five years":"off; existing vest stays locked on its schedule"}. Cost: gas only.`)}var tt=n=>{function e(t,r,o,a){return{name:t,inputSchema:{type:"object",properties:r,required:o,additionalProperties:!1,...t==="pons_launch"?{anyOf:[{required:["transactionHash"]},{required:["name","symbol","creatorFeeRecipient"]}]}:{},...t==="pons_browse"?{allOf:[{if:{anyOf:[{required:["query"]},{required:["cursor"]},{properties:{complete:{description:"Request a complete paginated listing through the Pons index.",const:!0}},required:["complete"]}]},then:{properties:{limit:{description:"Maximum number of results to return, within the stated bounds.",maximum:40}}}}]}:{}},execute:async(s,d)=>{try{C(d);for(let c of Object.keys(s))if(!(c in r))throw new i(`Unknown ${t} input: ${c}.`);return await a(s,d)}catch(c){throw new i(n.plainError(c))}}}}return{tools:[e("pons_browse",{fromBlock:O("First block number of the scan, as a decimal string; inclusive."),toBlock:O("Last block number of the scan, as a decimal string; inclusive."),limit:{type:"integer",minimum:1,maximum:100,description:"At most 40 for query, cursor or complete listings; at most 100 for an on-chain block window."},query:{type:"string",minLength:1,maxLength:100,description:"Name, symbol or address search over every Pons launch (Pons index; results re-read on chain)."},cursor:{type:"string",maxLength:64,description:"nextCursor from a previous newest-first page."},complete:{type:"boolean",description:"List every launch newest first through the Pons index, paginated with cursor."}},[],t=>Ke(n,t)),e("pons_status",{token:{...R,description:"Address of the token to inspect or use."},holder:{...R,description:"Holder address to inspect; defaults to the signing wallet."}},["token"],(t,r)=>Qe(n,C(t.token),C(t.holder??r))),e("pons_launch_options",{pairToken:{...R,description:"Launch pair token address; the zero address means native ETH."},offset:O("Launch configuration list offset, as a decimal string; defaults to zero.")},[],(t,r)=>et(n,t,r)),e("pons_transfer_creator_fee_recipient",{token:{...R,description:"Address of the token to inspect or use."},creatorFeeRecipient:{...R,description:"New nonzero recipient address for future creator fees; use the intended recipient."}},["token","creatorFeeRecipient"],(t,r)=>Se(n,t,r,!0)),e("pons_set_buyback",{token:{...R,description:"Address of the token to inspect or use."},enabled:{description:"Whether to enable creator buybacks.",type:"boolean"}},["token","enabled"],(t,r)=>Se(n,t,r,!1)),e("pons_launch",{name:{description:"Name for the new launch token.",type:"string",minLength:1},symbol:{description:"Symbol for the new launch token.",type:"string",minLength:1},creatorFeeRecipient:{...R,description:"Creator-fee recipient address; must be the nonzero signing wallet."},pairToken:{...R,description:"Launch pair token address; the zero address means native ETH."},launchConfigId:O('Identifier of the Pons launch configuration, as a decimal string, from pons_launch_options. Example: "1".'),buyRecipient:{...R,description:"Recipient address for the initial buy; defaults to the signing wallet and requires initialBuy."},logo:{description:"Public HTTPS or IPFS logo URI, or empty; cannot combine a nonempty logo with image upload.",type:"string"},description:{description:"Plain-text description of the launch token.",type:"string"},socials:{description:"Social links keyed by twitter, telegram, discord, website or farcaster.",type:"object",properties:Object.fromEntries(V.map(t=>[t,{type:"string",description:`Public HTTPS or IPFS URI for the token's ${t} page, or empty.`}])),additionalProperties:!1},image:{description:"Launch image upload with its MIME type and base64-encoded content.",type:"object",properties:{mimeType:{description:"Image content type: PNG, JPEG or WebP.",type:"string",enum:["image/png","image/jpeg","image/webp"]},base64:{description:"Base64-encoded image bytes without a data URL prefix.",type:"string",minLength:1,maxLength:6990508}},required:["mimeType","base64"],additionalProperties:!1},snipeTaxExemptions:{description:"Up to 31 wallet addresses exempt from the launch snipe tax; use intended addresses.",type:"array",items:R,maxItems:31},transactionHash:{description:"Confirmed launch transaction hash as a 32-byte hex string; use to recover a submitted launch.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},initialBuy:O('Initial buy amount of pair token in base units; use pair token decimals. Example: "1000000" = 1 pair token at 6 decimals.'),minTokensOut:O('Minimum launch-token output in base units (18 decimals). Example: "1000000000000000000" = 1 launch token.'),creatorTaxBps:{description:"Creator tax in basis points (50 = 0.5%); cannot exceed the current maximum from pons_launch_options.",type:"integer",minimum:0,maximum:65535},buybackEnabled:{description:"Whether creator buybacks are enabled for this launch.",type:"boolean"},expectedEconomics:{description:"Economics hash from the prior pons_launch result, as a 32-byte hex string; confirms changed terms on retry.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},salt:{description:"Deployment salt as a 32-byte hex string; choose a fresh value for a new deployment.",type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},metadata:{description:"Legacy metadata tuple: [logo URL, token description].",type:"array",items:{type:"string"},minItems:2,maxItems:2},links:{description:"Legacy social URL tuple: [twitter, telegram, discord, website, farcaster].",type:"array",items:{type:"string"},minItems:5,maxItems:5}},[],(t,r)=>t.transactionHash===void 0?Ze(n,t,r):Ye(n,t.transactionHash,r)),e("pons_graduate",{token:{...R,description:"Address of the token to inspect or use."}},["token"],async(t,r)=>{let o=C(t.token);if((await X(n,o,await n.clientFor(l).getBlockNumber({cacheTime:0}))).phase!==1)throw new i("Graduation requires a launch pending pool creation (phase 1).");return K(n,{to:u,chainId:l,value:"0",data:M({abi:f,functionName:"createGraduatedPool",args:[o]}),description:`Create the graduated Pons pool for ${o}.`},r,"Unsigned permissionless graduation retry; recheck status after the transaction is mined.")})],positions:async t=>{try{C(t);let r=await Ne(n,{limit:100}),o=r.items.filter(a=>p(a.creator,t)||p(a.creatorFeeRecipient,t));return await Promise.all(o.map(async a=>{let s=await n.clientFor(l).readContract({address:a.token.address,abi:j,functionName:"balanceOf",args:[t],blockNumber:BigInt(a.blockNumber)});return{module:"pons",id:`${l}:${a.token.address}`,chainId:l,assets:[N(a.token,s)],description:`Pons ${a.phaseName}; creator fee recipient ${a.creatorFeeRecipient}. Discovery covers recent launches only (${r.fromBlock}-${r.toBlock}${r.truncated?", truncated":""}).`}}))}catch(r){throw new i(n.plainError(r))}}}},pt=tt;export{X as a,de as b,Qe as c,Ke as d,tt as e,pt as f};
@@ -0,0 +1 @@
1
+ import{a as f,c as p}from"./XTFRPI4G.js";var d=256,y=131072;function b(g,r,n={textFields:r.length,truncated:r.length>d,linksOnly:!1}){let i=[],l=r.length>0&&r.length<=d&&!n.truncated,h=0;for(let t of r.slice(0,d)){let e=g;try{if(t.length>32)throw new Error("path_limit");for(let T of t){if(e===null||typeof e!="object")throw new Error("missing_field");let a=Object.getOwnPropertyDescriptor(e,T);if(!a||!("value"in a))throw new Error("unreadable_field");e=a.value}if(typeof e!="string"||!e.trim()||e.length>f)throw new Error("not_scannable");if(h+=Buffer.byteLength(e,"utf8"),h>y)throw new Error("total_limit");let c=p({text:e}),u=c.decision==="refuse"?"flagged":c.decision==="allow"?c.findings.length?"review":"clear":"unknown";i.push({path:[...t],verdict:u,inputHash:c.inputHash}),u==="unknown"&&(l=!1)}catch{l=!1,i.push({path:[...t],verdict:"unknown",inputHash:null})}}let o=i.some(t=>t.verdict==="flagged")?"flagged: instruction-like text found":i.some(t=>t.verdict==="review")?"review: instruction-like text reported (not blocking)":l?"clear":"unknown",s=i.filter(t=>t.verdict!=="unknown").map(t=>t.path),k=o==="clear"?`no instruction-like text in the ${s.length} fields checked`:o.startsWith("review:")?"instruction-like text reported, read it before approving":o.startsWith("flagged:")?"instruction-like text found":"text check incomplete",x=n.truncated?`; checked ${s.length} of ${n.textFields} text fields`:"",w=n.linksOnly?"; links only; this result had no names or descriptions":"";return{verdict:o,scope:"text-only",checked:{fields:s.length,textFields:n.textFields,truncated:n.truncated},label:`Text check only, not a price check: ${k}${x}${w}.`,checkedFields:s,fields:i,complete:l}}export{d as a,b};
@@ -1 +1 @@
1
- import{a as k}from"./VEQBHI6O.js";import{e as h}from"./NWNYJ26T.js";import{a as w}from"./XSD5NL7J.js";import{createHash as S,createPublicKey as T,verify as x}from"node:crypto";import{getAddress as I,isAddress as R}from"viem";var v="https://dashboard.agentwormhole.com",f=4663,$="name,symbol,description,logo",C="wormhole-x402@0.11.0",L=5e3,E=65536,O="MCowBQYDK2VwAyEAgzc6812eT397nvzP/off3M93Z+yM5/BmEefSnRnS7o0=",D=T({key:Buffer.from(O,"base64"),format:"der",type:"spki"}),B=S("sha256").update(Buffer.from(O,"base64")).digest("hex"),A=/^[0-9a-f]{64}$/,P=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,_=["v","metadata_hash","scope","chain_id","token","bundle_hash","verdict","codes","ruleset","issued_at","expires_at"];function z(e,t,a=D){try{if(a.asymmetricKeyType!=="ed25519"||typeof t!="string"||!/^[A-Za-z0-9+/]{86}==$/.test(t))return!1;let s=Buffer.from(t,"base64");return s.length===64&&s.toString("base64")===t&&x(null,Buffer.from(e,"utf8"),a,s)}catch{return!1}}function H(e){return JSON.stringify(Object.fromEntries(_.map(t=>[t,e[t]])))}function K(e){return h(e)&&Object.keys(e).length===_.length&&_.every(t=>Object.hasOwn(e,t))&&e.v===2&&typeof e.metadata_hash=="string"&&A.test(e.metadata_hash)&&typeof e.bundle_hash=="string"&&A.test(e.bundle_hash)&&typeof e.scope=="string"&&Number.isSafeInteger(e.chain_id)&&typeof e.token=="string"&&/^0x[0-9a-f]{40}$/.test(e.token)&&["clean_by_rules","flagged"].includes(String(e.verdict))&&Array.isArray(e.codes)&&e.codes.length<=100&&e.codes.every(t=>typeof t=="string"&&/^[A-Z0-9_-]{1,40}$/.test(t))&&typeof e.ruleset=="string"&&/^wormhole-x402@\d+\.\d+\.\d+$/.test(e.ruleset)&&[e.issued_at,e.expires_at].every(t=>typeof t=="string"&&P.test(t)&&Number.isFinite(Date.parse(t))&&new Date(t).toISOString()===t)}async function j(e,t){let a=e.headers.get("content-length");if(a&&(!/^\d+$/.test(a)||Number(a)>E))throw e.body?.cancel().catch(()=>{}),new Error("oversized_response");let s=e.body?.getReader();if(!s)throw new Error("invalid_response");let d=[],i=0,c=()=>{s.cancel().catch(()=>{})};t.addEventListener("abort",c,{once:!0});try{for(;;){if(t.aborted)throw new Error("timeout");let{value:u,done:l}=await s.read();if(l)break;if(i+=u.byteLength,i>E)throw new Error("oversized_response");d.push(u)}if(t.aborted)throw new Error("timeout");return JSON.parse(Buffer.concat(d).toString("utf8"))}finally{t.removeEventListener("abort",c),s.cancel().catch(()=>{}),s.releaseLock()}}async function F(e,t){if(!h(t)||Object.keys(t).length!==1||typeof t.token!="string"||!R(t.token,{strict:!0})||t.token.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")throw new w("Provide only token: a valid ERC-20 contract address on Robinhood Chain 4663.");let a=I(t.token),s=`${v}/api/v1/token/${f}/${a.toLowerCase()}`,d={token:{address:a,chainId:f},contentBound:!1,mutationCountAuthenticated:!1,attribution:{provider:"Agent Wormhole",source:s,page:`${v}/t/${f}/${a.toLowerCase()}`},keyId:B,unknowns:["Fresh full metadata is not available in the free response; description/logo and current displayed bytes are not bound.","The key was bootstrapped from the same origin, not independently authenticated; key rotation policy is unknown.","No contract code, economics, sellability, linked pages or image bytes were checked. Rules are evadable."]},i=(o,n=!1)=>({...d,status:"unchecked",verdict:null,signatureValid:n,codes:[],reason:o}),c=new AbortController,u,l=new Promise((o,n)=>{u=setTimeout(()=>{c.abort(),n(new Error("timeout"))},L)});try{return await Promise.race([l,(async()=>{let o=await e(s,{method:"GET",redirect:"error",credentials:"omit",headers:{accept:"application/json"},signal:c.signal}).catch(g=>{if(g instanceof k)return g.response;throw g});if(c.signal.aborted)throw new Error("timeout");if(o.redirected)return o.body?.cancel().catch(()=>{}),i("redirect_refused");if(!o.ok)return o.body?.cancel().catch(()=>{}),o.status===404?{...d,status:"unobserved",verdict:null,signatureValid:!1,codes:[],reason:"No attestation. Absence is not a verdict."}:i(o.status===429?"rate_limited":`http_${o.status}`);let n=await j(o,c.signal);if(!h(n)||!K(n.attestation)||typeof n.signature!="string"||!/^[A-Za-z0-9+/]{86}==$/.test(n.signature))return i("invalid_attestation");let r=n.attestation;if(!z(H(r),n.signature))return i("invalid_signature");if(r.chain_id!==f||r.token!==a.toLowerCase()||r.scope!==$)return i("identity_or_scope_mismatch",!0);if(S("sha256").update(JSON.stringify({v:2,chainId:f,address:r.token,metadataHash:r.metadata_hash})).digest("hex")!==r.bundle_hash)return i("bundle_mismatch",!0);if(n.observed!==!0||n.chain_id!==f||typeof n.token!="string"||n.token.toLowerCase()!==r.token||n.bundle_hash!==r.bundle_hash||n.verdict!==r.verdict||JSON.stringify(n.codes)!==JSON.stringify(r.codes))return i("record_mismatch",!0);let m=Date.parse(r.issued_at),p=Date.parse(r.expires_at),b=Date.now();if(m>b||p<=m||p-m>864e5)return i("invalid_time_window",!0);let y=[...b>=p?["expired"]:[],...r.ruleset!==C?["unrecognized_ruleset"]:[],...n.attestation_current!==!0||n.re_attestation!=="current"?["service_reports_not_current"]:[]],N={attestation:r,signature:n.signature,scope:r.scope,metadataHash:r.metadata_hash,bundleHash:r.bundle_hash,ruleset:r.ruleset,issuedAt:r.issued_at,expiresAt:r.expires_at,bundleIdentityValid:!0};return{...d,status:y.length?"stale":"verified",verdict:y.length?null:r.verdict,signatureValid:!0,codes:r.codes,evidence:N,staleReasons:y,mutationCount:Number.isSafeInteger(n.mutations)&&Number(n.mutations)>=0?n.mutations:null,notice:"A verified metadata snapshot is not a safety certificate. Unsigned service history and freshness do not prove no mutation since the scan."}})()])}catch(o){return i(c.signal.aborted||o instanceof Error&&o.message==="timeout"?"timeout":"unavailable_or_malformed_response")}finally{u!==void 0&&clearTimeout(u)}}export{L as a,z as b,F as c};
1
+ import{a as k}from"./SCG5HWMN.js";import{e as h}from"./NWNYJ26T.js";import{a as w}from"./XSD5NL7J.js";import{createHash as S,createPublicKey as T,verify as x}from"node:crypto";import{getAddress as I,isAddress as R}from"viem";var v="https://dashboard.agentwormhole.com",f=4663,$="name,symbol,description,logo",C="wormhole-x402@0.11.0",L=5e3,E=65536,O="MCowBQYDK2VwAyEAgzc6812eT397nvzP/off3M93Z+yM5/BmEefSnRnS7o0=",D=T({key:Buffer.from(O,"base64"),format:"der",type:"spki"}),B=S("sha256").update(Buffer.from(O,"base64")).digest("hex"),A=/^[0-9a-f]{64}$/,P=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,_=["v","metadata_hash","scope","chain_id","token","bundle_hash","verdict","codes","ruleset","issued_at","expires_at"];function z(e,t,a=D){try{if(a.asymmetricKeyType!=="ed25519"||typeof t!="string"||!/^[A-Za-z0-9+/]{86}==$/.test(t))return!1;let s=Buffer.from(t,"base64");return s.length===64&&s.toString("base64")===t&&x(null,Buffer.from(e,"utf8"),a,s)}catch{return!1}}function H(e){return JSON.stringify(Object.fromEntries(_.map(t=>[t,e[t]])))}function K(e){return h(e)&&Object.keys(e).length===_.length&&_.every(t=>Object.hasOwn(e,t))&&e.v===2&&typeof e.metadata_hash=="string"&&A.test(e.metadata_hash)&&typeof e.bundle_hash=="string"&&A.test(e.bundle_hash)&&typeof e.scope=="string"&&Number.isSafeInteger(e.chain_id)&&typeof e.token=="string"&&/^0x[0-9a-f]{40}$/.test(e.token)&&["clean_by_rules","flagged"].includes(String(e.verdict))&&Array.isArray(e.codes)&&e.codes.length<=100&&e.codes.every(t=>typeof t=="string"&&/^[A-Z0-9_-]{1,40}$/.test(t))&&typeof e.ruleset=="string"&&/^wormhole-x402@\d+\.\d+\.\d+$/.test(e.ruleset)&&[e.issued_at,e.expires_at].every(t=>typeof t=="string"&&P.test(t)&&Number.isFinite(Date.parse(t))&&new Date(t).toISOString()===t)}async function j(e,t){let a=e.headers.get("content-length");if(a&&(!/^\d+$/.test(a)||Number(a)>E))throw e.body?.cancel().catch(()=>{}),new Error("oversized_response");let s=e.body?.getReader();if(!s)throw new Error("invalid_response");let d=[],i=0,c=()=>{s.cancel().catch(()=>{})};t.addEventListener("abort",c,{once:!0});try{for(;;){if(t.aborted)throw new Error("timeout");let{value:u,done:l}=await s.read();if(l)break;if(i+=u.byteLength,i>E)throw new Error("oversized_response");d.push(u)}if(t.aborted)throw new Error("timeout");return JSON.parse(Buffer.concat(d).toString("utf8"))}finally{t.removeEventListener("abort",c),s.cancel().catch(()=>{}),s.releaseLock()}}async function F(e,t){if(!h(t)||Object.keys(t).length!==1||typeof t.token!="string"||!R(t.token,{strict:!0})||t.token.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")throw new w("Provide only token: a valid ERC-20 contract address on Robinhood Chain 4663.");let a=I(t.token),s=`${v}/api/v1/token/${f}/${a.toLowerCase()}`,d={token:{address:a,chainId:f},contentBound:!1,mutationCountAuthenticated:!1,attribution:{provider:"Agent Wormhole",source:s,page:`${v}/t/${f}/${a.toLowerCase()}`},keyId:B,unknowns:["Fresh full metadata is not available in the free response; description/logo and current displayed bytes are not bound.","The key was bootstrapped from the same origin, not independently authenticated; key rotation policy is unknown.","No contract code, economics, sellability, linked pages or image bytes were checked. Rules are evadable."]},i=(o,n=!1)=>({...d,status:"unchecked",verdict:null,signatureValid:n,codes:[],reason:o}),c=new AbortController,u,l=new Promise((o,n)=>{u=setTimeout(()=>{c.abort(),n(new Error("timeout"))},L)});try{return await Promise.race([l,(async()=>{let o=await e(s,{method:"GET",redirect:"error",credentials:"omit",headers:{accept:"application/json"},signal:c.signal}).catch(g=>{if(g instanceof k)return g.response;throw g});if(c.signal.aborted)throw new Error("timeout");if(o.redirected)return o.body?.cancel().catch(()=>{}),i("redirect_refused");if(!o.ok)return o.body?.cancel().catch(()=>{}),o.status===404?{...d,status:"unobserved",verdict:null,signatureValid:!1,codes:[],reason:"No attestation. Absence is not a verdict."}:i(o.status===429?"rate_limited":`http_${o.status}`);let n=await j(o,c.signal);if(!h(n)||!K(n.attestation)||typeof n.signature!="string"||!/^[A-Za-z0-9+/]{86}==$/.test(n.signature))return i("invalid_attestation");let r=n.attestation;if(!z(H(r),n.signature))return i("invalid_signature");if(r.chain_id!==f||r.token!==a.toLowerCase()||r.scope!==$)return i("identity_or_scope_mismatch",!0);if(S("sha256").update(JSON.stringify({v:2,chainId:f,address:r.token,metadataHash:r.metadata_hash})).digest("hex")!==r.bundle_hash)return i("bundle_mismatch",!0);if(n.observed!==!0||n.chain_id!==f||typeof n.token!="string"||n.token.toLowerCase()!==r.token||n.bundle_hash!==r.bundle_hash||n.verdict!==r.verdict||JSON.stringify(n.codes)!==JSON.stringify(r.codes))return i("record_mismatch",!0);let m=Date.parse(r.issued_at),p=Date.parse(r.expires_at),b=Date.now();if(m>b||p<=m||p-m>864e5)return i("invalid_time_window",!0);let y=[...b>=p?["expired"]:[],...r.ruleset!==C?["unrecognized_ruleset"]:[],...n.attestation_current!==!0||n.re_attestation!=="current"?["service_reports_not_current"]:[]],N={attestation:r,signature:n.signature,scope:r.scope,metadataHash:r.metadata_hash,bundleHash:r.bundle_hash,ruleset:r.ruleset,issuedAt:r.issued_at,expiresAt:r.expires_at,bundleIdentityValid:!0};return{...d,status:y.length?"stale":"verified",verdict:y.length?null:r.verdict,signatureValid:!0,codes:r.codes,evidence:N,staleReasons:y,mutationCount:Number.isSafeInteger(n.mutations)&&Number(n.mutations)>=0?n.mutations:null,notice:"A verified metadata snapshot is not a safety certificate. Unsigned service history and freshness do not prove no mutation since the scan."}})()])}catch(o){return i(c.signal.aborted||o instanceof Error&&o.message==="timeout"?"timeout":"unavailable_or_malformed_response")}finally{u!==void 0&&clearTimeout(u)}}export{L as a,z as b,F as c};
@@ -1 +1 @@
1
- import{b as W}from"./AEL62KCG.js";import{c as K}from"./VEQBHI6O.js";import{d as N}from"./UNJJRQIU.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{a as q,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
1
+ import{d as N}from"./UNJJRQIU.js";import{b as W}from"./DNNFKDZR.js";import{c as K}from"./SCG5HWMN.js";import{g as S}from"./NWNYJ26T.js";import{a as j,b as M,c as O}from"./IX3GZMTM.js";import{a as q,i as z}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeAbiParameters as ce,encodeFunctionData as J,erc20Abi as V,getAddress as Z,isAddress as me,keccak256 as X,parseAbi as ue,parseAbiParameters as ye,zeroAddress as ee}from"viem";var x=q,C=Z(z[x].hoodlock.airdrop.address),oe="https://hoodlock.tech",P=25e4,ge=256,fe=604800n,pe=30n,Q=250000000000000000n,Y=0xffffffffn,be=(1n<<64n)-1n,ne=(1n<<128n)-1n,re="0x0000000000000000000000000000000000000000000000000000000000000000",xe="0x1111111111111111111111111111111111111111",Ae=ye("uint256, address, uint256"),T=ue(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function he(o,e,r){let n=e.trim();if(n.startsWith("-")){let t=n.slice(1);return`-${o.formatAmount(t,r)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,r)}function te(o,e){if(!e.changes.length)return e.summary;let r=e.changes.map(n=>`${he(o,n.amount,n.token.decimals)} ${$(n.token.symbol)}`).join(", ");return`${e.summary} (${r})`}async function we(o,e){try{let[r,n]=await Promise.all([o.readContract({address:e,abi:V,functionName:"symbol"}),o.readContract({address:e,abi:V,functionName:"decimals"})]),d=typeof r=="string"&&r.trim()?r.trim():"TOKEN",t=Number(n);return{symbol:d,decimals:Number.isInteger(t)&&t>=0&&t<=255?t:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,r){if(typeof e=="string"&&e.includes(".")){if(r?.decimals===void 0)throw new a(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=r.rounding!==void 0?O(e,r.decimals,r.rounding):o?o.parseAmount(e,r.decimals):O(e,r.decimals),t=M(d);if(t<=0n)throw new a("Airdrop entry amount must be positive.");return t}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=M(e.trim());else throw j()}catch(d){throw d instanceof a?d:new a(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new a("Airdrop entry amount must be strictly positive (> 0).");return n}function H(o,e){try{let r=typeof o=="bigint"?o:BigInt(String(o).trim());if(r<0n)throw new a(`${e} must be non-negative.`);return r}catch(r){throw r instanceof a?r:new a(`Invalid ${e}: ${String(o)}`,{cause:r})}}function A(o,e){if(typeof o!="string"||!me(o,{strict:!1}))throw new a(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Z(o)}function L(o,e,r){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>Y)throw new a(`Airdrop leaf index must be in 0..${Y.toString()}.`);let d=A(e,"account"),t=w(void 0,r),s=ce(Ae,[n,d,t]);return X(X(s))}function ie(o,e){let r=o;for(let n of e)r=N(r,n);return r}function Ne(o){try{let e=L(o.index,o.account,o.amount),r=ie(e,o.proof);return S(r,o.root)}catch{return!1}}function U(o,e){if(!Array.isArray(o)||o.length===0)throw new a("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>P)throw new a(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${P}.`);let r=[],n=0n;for(let i=0;i<o.length;i+=1){let l=o[i];if(!l)throw new a(`Missing airdrop entry at position ${i}.`);let c=l.index??i;if(!Number.isInteger(c)||c!==i)throw new a(`Airdrop entry index at position ${i} must be contiguous ${i} (got ${String(c)}).`);let u=A(l.account,`entries[${i}].account`),g=w(e?.context,l.amount,e);n+=g,r.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>ne)throw new a("Airdrop total amount must be > 0 and fit in uint128.");let d=r.map(i=>L(i.index,i.account,i.amount)),t=[d];for(;t[t.length-1].length>1;){let i=t[t.length-1],l=[];for(let c=0;c<i.length;c+=2){let u=i[c],g=i[c+1];g===void 0?l.push(u):l.push(N(u,g))}t.push(l)}let s=t[t.length-1][0];if(s.toLowerCase()===re)throw new a("Computed Merkle root cannot be zero.");let f=t.length>1?t[1]:t[0],m=r.map((i,l)=>{let c=[],u=l;for(let g=0;g<t.length-1;g+=1){let y=t[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:i.index,account:i.account,amount:i.amount,leaf:d[l],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:s,totalAmount:n.toString(),maxClaims:r.length,values:r.map(i=>[i.index,i.account,i.amount]),entries:r};return{root:s,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:r.length,entries:r,proofs:m,list:p}}function ke(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new a("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,t])=>({index:n,account:d,amount:t})),r=U(e);if(o.root&&!S(r.root,o.root))throw new a(`Rebuilt tree root ${r.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&r.maxClaims!==o.maxClaims)throw new a(`Rebuilt maxClaims (${r.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&r.totalAmount!==o.totalAmount)throw new a(`Rebuilt totalAmount (${r.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return r}async function ae(o,e){return K(o.http,e,{method:"GET"},r=>r!==null&&typeof r=="object")}async function $e(o,e,r){let n=A(e.token,"token");if(n===ee)throw new a("Airdrop token cannot be the zero address.");let d=U(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),t=e.maxClaims??d.maxClaims;if(!Number.isInteger(t)||t<1||t>P||t!==d.maxClaims)throw new a(`maxClaims (${String(t)}) must equal entries.length (${d.maxClaims}) and be in 1..${P}.`);let s=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):s;if(f<s)throw new a(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${s.toString()}).`);if(f<=0n||f>ne)throw new a("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>ge)throw new a(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let i=e.endTime!==void 0?H(e.endTime,"endTime"):0n;if(i>be)throw new a("endTime exceeds uint64 maximum.");let l=o.clientFor(x),c=await l.getCode({address:n});if(!c||c==="0x")throw new a(`Token ${n} has no contract code on chain ${x}.`);let u;if(i!==0n){let _=(await l.getBlock()).timestamp,B=e.inclusionMargin!==void 0?H(e.inclusionMargin,"inclusionMargin"):pe;if(B<=0n)throw new a("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let D=_+B,I=e.inclusionTime!==void 0?H(e.inclusionTime,"inclusionTime"):D;if(I<D)throw new a(`inclusionTime (${I.toString()}) must be after the already-mined block (${_.toString()}) with room for signing and inclusion (>= ${D.toString()}).`);u=I;let F=I+fe;if(i<F)throw new a(`endTime (${i.toString()}) is too short (window too short): must be 0 or at least inclusion time (${I.toString()}) + 604800 (7 days >= ${F.toString()}, after already-mined block.timestamp ${_.toString()}).`)}let g=await l.readContract({address:C,abi:T,functionName:"quote",args:[t]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>Q)throw new a(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${Q.toString()}).`);let b=o.formatAmount(y.toString(),W.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"create",args:[n,d.root,f,t,i,m]}),value:y.toString(),description:`Create HoodLock airdrop (${t} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),v=[h,k],E=A(e.account??r??xe,"wallet"),R=await o.preview(v,E),le=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",se=`${te(o,R)}${le}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:t,endTime:i,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:v,preview:R,summary:se}}async function G(o,e,r,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==r)throw new a(`savedProof account (${m}) does not match claim account (${r}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new a(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?ke(n.list):U(n.entries,{context:o})).proofs.find(i=>!(!S(i.account,r)||n.index!==void 0&&i.index!==Number(n.index)));if(!p)throw new a(`Account ${r} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${oe}/api/airdrop/${e.toString()}/proof?address=${r}`,t=await ae(o,d),s=t?.data??t;if(!s||s.index===void 0||s.amount===void 0||!Array.isArray(s.proof))throw new a(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${r}.`);let f=Number(s.index);if(!Number.isInteger(f)||f<0)throw new a(`Invalid index in API proof: ${String(s.index)}`);return{index:f,amount:w(o,s.amount),proof:s.proof}}async function de(o,e){let r=o.clientFor(x),n=await r.readContract({address:C,abi:T,functionName:"getAirdrop",args:[e.id]}),[d,t,s,f,m,p,i,,l]=n,c=BigInt(t),u=Number(s),g=Number(m),y=BigInt(l),b=A(f,"airdrop.token");if(d===ee||i.toLowerCase()===re)throw new a(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new a(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await r.getBlock()).timestamp>=c)throw new a(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new a(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([r.readContract({address:C,abi:T,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),we(r,b)]);if(h)throw new a(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new a(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let v=L(e.index,e.account,e.amount),E=ie(v,e.proof);if(!S(E,i))throw new a(`Computed Merkle root ${E} does not match on-chain airdrop root ${i} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:i,leaf:v}}async function Se(o,e){let{tokenAddress:r,tokenMeta:n,merkleRoot:d,leaf:t}=await de(o,e),s=e.caller??e.account,f=!S(s,e.account),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:J({abi:T,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${s} pays gas only, token delta 0)`:`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),i=[p],l=await o.preview(i,s),c,u,g=e.amount.toString(),y;if(f){let b=l.changes.filter(h=>h.amount.trim().startsWith("-"));c={...l,changes:b,summary:`${l.summary} Recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units); caller ${s} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}); caller ${s} own token change is 0 (gas only). ${l.summary}`,y="0"}else c=l,u=`Claim ${m} ${$(n.symbol)} (${e.amount.toString()} base units of ${r}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${te(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:r,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:t,merkleRoot:d,proof:[...e.proof],tx:p,txs:i,preview:c,summary:u}}async function Ce(o,e,r){let n=A(e.account??r??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):r!==void 0?A(r,"wallet"):void 0;if(e.id!==void 0){let l=H(e.id,"id"),c=await G(o,l,n,e);return Se(o,{id:l,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let t=`${oe}/api/airdrop/eligible?address=${n}`,s=await ae(o,t),f=Array.isArray(s)?s:s?.claimable??s?.eligible??s?.airdrops??s?.claims??[],m=[];for(let l of f){let c=l.id??l.airdropId;if(c!==void 0)try{let u=H(c,"eligible.id"),g,y,b;if(l.index!==void 0&&l.amount!==void 0&&Array.isArray(l.proof))g=Number(l.index),y=w(o,l.amount),b=l.proof;else{let k=await G(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await de(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No verified eligible HoodLock airdrops were returned by the index for ${n}. Discovery can lag after creation; this does not prove there are no claims. If you know the airdrop id, call hoodlock_airdrop_claim with id and account to resolve its list/proof and verify it on-chain.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(l=>`#${l.id}`).join(", ")}. Discovery can lag after creation. Choose an id, or pass a known new id, to hoodlock_airdrop_claim to verify and build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var ve=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,r)=>$e(o,e,r)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,r)=>Ce(o,e,r)}]}),Le=ve;export{V as a,x as b,C as c,oe as d,P as e,ge as f,fe as g,pe as h,Q as i,T as j,he as k,L as l,ie as m,Ne as n,U as o,ke as p,ve as q,Le as r};
@@ -0,0 +1 @@
1
+ import{f as L,k as r,l as $}from"./ACH4BSME.js";import{a as I,e as c,h as v}from"./CSOO4SW7.js";import{j as h,k as p}from"./2GXHYI23.js";async function M(k,b,d={},O){I(b);let o=new AbortController,C=()=>o.abort(),l=()=>c(o.signal);c(d.signal),d.signal?.addEventListener("abort",C,{once:!0});let u=[];try{let f=await L(k,O,o.signal);l();let w=k.clientFor(4663),S=await v(w,o.signal),T=Array.from({length:Math.ceil(f.logs.length/r)},(t,n)=>f.logs.slice(n*r,(n+1)*r));return await Promise.all(T.map(async(t,n)=>{l(),await $(w,t,b,S,o.signal,(e,y)=>{if(l(),BigInt(e.logTokens.amount)===0n&&BigInt(e.stakedLp.amount)===0n&&BigInt(e.pendingChop.amount)===0n&&BigInt(e.claimableChop.amount)===0n)return;let a=t[y],m=BigInt(e.pendingChop.amount),B=BigInt(e.claimableChop.amount),g=B<=m,s=e.rewardsPaused?0n:B,i={principal:[],debt:[],rewards:[],backing:[],coverage:g?{complete:!0}:{complete:!1,reason:"Chop reward reads disagree."}};if(BigInt(e.logTokens.amount)>0n&&i.backing.push(p({...e.net,source:"chop.redemption.net",heldAs:e.logTokens.token.address,measuredAtBlock:e.measuredAtBlock})),BigInt(e.stakedLp.amount)>0n&&i.backing.push(p({token:a.underlying,amount:null,source:"chop.stakedLp",heldAs:e.stakedLp.token.address,measuredAtBlock:e.measuredAtBlock,unknownReason:"Staked log tokens are not redeemed in this read; unstake to see their redemption."})),g){let A={tool:"chop_harvest",args:{log:a.log.address}},P=m-s;P>0n&&i.rewards.push(h("unpaid",{token:e.pendingChop.token,amount:P.toString(),source:"chop.getUnpaid",measuredAtBlock:e.measuredAtBlock,claim:A})),s>0n&&i.rewards.push(h("claimable",{token:e.claimableChop.token,amount:s.toString(),source:"chop.getClaimable",measuredAtBlock:e.measuredAtBlock,claim:A}))}let E=g?`unpaid CHOP ${m-s} base units; claimable CHOP ${s} base units${e.rewardsPaused?"; rewards are paused":""}.`:"Chop reward reads disagree.";u[n*r+y]=[{module:"chop",id:`4663:${a.log.address}`,chainId:4663,assets:[e.logTokens,e.stakedLp,e.pendingChop],economics:i,description:`Chop log held: ${e.logTokens.amount} base units; redeemable net underlying ${e.net.amount} base units (${a.underlying.address}, decimals ${a.underlying.decimals}); staked LP ${e.stakedLp.amount} base units; ${E}`,oakNotice:e.warnings}]})}).map(t=>t.catch(n=>{throw o.abort(),n}))),[...u.flat(),{module:"chop",id:"4663:coverage",chainId:4663,assets:[],incomplete:!0,description:"Chop positions cover currently verified registry logs only. Delisted or unverified log holdings are not included."}]}catch{return o.abort(),c(d.signal),[...u.flat(),{module:"chop",id:"4663:coverage",chainId:4663,assets:[],incomplete:!0,description:"Chop positions are incomplete because a chain read is unavailable. Please try again."}]}finally{d.signal?.removeEventListener("abort",C)}}export{M as a};
@@ -0,0 +1 @@
1
+ import{B as Pe,t as re,y as qe}from"./BAIY32AV.js";import{a as Re}from"./ZF2VPDRQ.js";import{a as y}from"./WWNAGOCD.js";import{a as k,b as ie,d as He,e as R,f as p,h as C,i as q,j as f,k as $,l as H,m as A,n as se,o as w,p as c,q as F,r as j,s as Se,t as Be}from"./2E4I7CJ7.js";import{b as K,f as ve,g as V,h as Te,i as Le}from"./MQK6OP7S.js";import{a as z}from"./G2LAO23N.js";import{i as oe}from"./U2YCQWZK.js";import{a as xe}from"./H5DY7CNB.js";import{s as be}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as Qe,encodeFunctionData as We,erc20Abi as Ge,formatUnits as Ae,getAddress as ce,parseAbi as Q,zeroAddress as b,zeroHash as ae}from"viem";var Je="hookr_launch",g=ce(K.launcherV1),X=ce(K.rulesV1),Ye=[{type:"tuple",components:[{name:"flags",type:"uint16"},{name:"minScore",type:"uint32"},{name:"tierScore",type:"uint32"},{name:"tierPips",type:"uint24"},{name:"reviewers",type:"bytes32"}]}],_=(a,n=Object.keys(a))=>({type:"object",properties:a,required:n,additionalProperties:!1}),Fe={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},ue=_({token:{description:'Token to launch: kind "new" creates a fresh token; kind "existing" is reserved and currently refused.',oneOf:[_({kind:{const:"new",type:"string",description:z.enumValues({new:"create and launch a fresh token"})},name:{type:"string",minLength:1,maxLength:48,description:"Public token name, 1 to 48 UTF-8 bytes, no control characters."},symbol:{type:"string",minLength:1,maxLength:12,description:"Public token ticker symbol, 1 to 12 UTF-8 bytes, no control characters."},supply:{...k,description:'Total supply of the new token in base units (18 decimals: "1000000000000000000" = 1 token); positive, below 2^108.'},salt:{...ie,description:"Bytes32 hex salt (0x plus 64 hex digits) that fixes the new token address."}}),_({kind:{const:"existing",type:"string",description:z.enumValues({existing:"reserved for an already deployed token; launching it is not supported yet"})},address:{...Fe,description:z.address("existing token contract")}})]},quote:{...Fe,description:"Qualified ETH (zero address) or pinned USDG quote. Other quote funding routes await qualification."},sqrtPriceX96:{...k,description:"Integer sqrt(currency1/currency0) times 2^96 for the sorted PoolKey."},tickLower:{type:"integer",minimum:-887272,maximum:887272,description:"Lower tick of the launch range, a signed integer and a multiple of the tick spacing 200; below tickUpper."},tickUpper:{type:"integer",minimum:-887272,maximum:887272,description:"Upper tick of the launch range, a signed integer and a multiple of the tick spacing 200; above tickLower."},liquidity:{...k,description:"Initial liquidity in v4 liquidity base units (not a token amount), positive and below 2^127; its rounded-up token debts must fit amount0Max and amount1Max."},amount0Max:{...k,description:`Maximum of the pool's currency0 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},amount1Max:{...k,description:`Maximum of the pool's currency1 to fund, in base units of that token (18 decimals: "1000000000000000000" = 1 token).`},agentGate:{description:"Who may buy: all zeros means identity-only; nonzero minScore or tier values add a reputation gate checked by the reviewer set.",..._({minScore:{...k,description:"Minimum agent reputation score required to buy; 0 means no minimum."},tierScore:{...k,description:"Agent score at or above which the reduced tier fee applies; 0 only when tierPips is 0."},tierPips:{...k,description:"Reduced pool fee in pips for agents at tierScore (3000 = 0.3%); at most 50000, and 0 only when tierScore is 0."},reviewerSetId:{...ie,description:"Bytes32 id of a registered reviewer set that scores agents; all zeros unless the gate uses a score."}})},lpRewardsBps:{...k,description:"LP Rewards rate in basis points (50 = 0.5%); at most 1000. This launch profile has zero burn."},arbRecapture:{type:"boolean",description:"True turns on Hookr arb recapture, with recaptured value to LPs; refused while the recapture lane is unavailable. False leaves it off."},deadline:{...k,description:"Latest time this launch may execute, as Unix seconds; must be within the next 300 seconds of chain time."}});function Ze(a){let n=R(a,Object.keys(ue.properties),ue.required),r=A(n.token);if(r.kind==="existing")throw R(r,["kind","address"],["kind","address"]),q(r.address),new o("Existing-token Hookr launches await a qualified funding route. Use token.kind new.");if(R(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,O)=>{if(typeof P!="string"||!P.trim()||new TextEncoder().encode(P).length>O||[...P].some(W=>W.codePointAt(0)<32)||/[\u007f-\u009f\u2028-\u202e\u2066-\u2069\ud800-\udfff]/u.test(P))throw new o(`Use nonempty public token text within ${O} UTF-8 bytes without control characters.`);return P},i=p(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,ce(be.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.");qe(l,u,y.tickSpacing);let s=p(n.sqrtPriceX96,160);if(s<=oe(l)||s>=oe(u))throw new o("Hookr opening price must be strictly inside the aligned tick range.");let d=p(n.liquidity,127);if(!d)throw new o("Hookr liquidity must be positive and at most int128 max.");let m=p(n.amount0Max,128),T=p(n.amount1Max,128),x=Pe({liquidity:d,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>T)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=R(n.agentGate,["minScore","tierScore","tierPips","reviewerSetId"],["minScore","tierScore","tierPips","reviewerSetId"]),I=Number(p(h.minScore,32)),S=Number(p(h.tierScore,32)),B=Number(p(h.tierPips,24)),M=C(h.reviewerSetId);if(B>5e4||S===0!=(B===0)||(I!==0||S!==0)!=(M!==ae))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 N=Number(p(n.lpRewardsBps,16));if(N>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:C(r.salt)},quote:t,sqrtPriceX96:s,tickLower:l,tickUpper:u,liquidity:d,amount0Max:m,amount1Max:T,debts:x,gateTerms:{flags:1,minScore:I,tierScore:S,tierPips:B,reviewers:M},lpRewardsBps:N,arbRecapture:n.arbRecapture,deadline:p(n.deadline,64)}}async function et(a,n,r,e){return q(await c(a,g,w("launcherV1"),"predictToken",[n,r],e))}async function tt(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=(d,m)=>c(a,t.identity,Q(["function balanceOf(address) view returns (uint256)","function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),d,m,i),u=f(await l("balanceOf",[n])),s=!1;if(t.link.linked){let d=BigInt(t.link.agentId);s=q(await l("getAgentWallet",[d]))===n,!s&&u>0n&&(s=q(await l("ownerOf",[d]))===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 nt(a,n,r){let e=Ze(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!==ae,u=await Re(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 tt(i,r,u,l,t.number);let s=await et(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 d={currency0:BigInt(s)<BigInt(e.quote)?s:e.quote,currency1:BigInt(s)<BigInt(e.quote)?e.quote:s,fee:8388608,tickSpacing:y.tickSpacing,hooks:F},m=re(d),T=d.currency0===s,x=T?e.amount0Max:e.amount1Max,h=T?e.amount1Max:e.amount0Max,I=T?e.debts.amount0:e.debts.amount1,S=T?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,M,N,P,O,W,Ie,Ue]=await Promise.all([i.getCode({address:s,blockNumber:t.number}),i.getTransactionCount({address:s,blockNumber:t.number}),c(i,g,w("launcherV1"),"memberKey",[s,e.quote,y.tickSpacing,F],t.number),c(i,F,w("rootV1"),"knownPool",[m],t.number),c(i,g,w("launcherV1"),"SKIP_TAKEN",[],t.number),c(i,j,w("registry"),"isQuote",[e.quote],t.number),c(i,j,w("registry"),"quoteIsBraked",[e.quote],t.number),c(i,X,w("rulesV1"),"minProtocolShareBps",[],t.number)]),[Ce,$e]=H(N,2);if(e.token.salt===C(O))throw new o("SKIP_TAKEN is unsupported. Choose an ordinary new-token salt.");if(B&&B!=="0x"||M!==0||$(P)||!$($e)||re(A(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(!$(W)||$(H(Ie,2)[0]))throw new o("The Hookr quote is not currently qualified or is braked. Choose an admitted quote.");let de=A(u.gate.admission),Me=A(de.caps),pe=p(Me.maxLpFeePips,24),Ne=BigInt(u.coreAdmission.caps.maxLpFeePips),G=BigInt(y.baseLpFeePips)+pe;if(BigInt(e.gateTerms.tierPips)>pe||G>Ne||G>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 le=q(await c(i,X,w("rulesV1"),"protocolRecipient",[],t.number));await V(i,t.number,[le]);let[Oe,Ee,De]=H(await c(i,le,Q(["function feeTerms(address,bool,bytes32) view returns (uint16,uint16,uint16)"]),"feeTerms",[b,e.arbRecapture,m],t.number),3),me=f(Oe,16),J=f(De,16);if(f(Ee,16)!==0n||J>10000n)throw new o("Hookr treasury minimum or integrator terms exceed the reviewed profile.");let he=f(Ue,16),E=me>he?me:he;if(E<2000n||E>5000n)throw new o("Hookr protocol share is outside the reviewed 2000\u20135000 bps profile.");let Y=BigInt(e.lpRewardsBps)*100n+(!e.arbRecapture&&e.lpRewardsBps===0?J:0n);if(Y>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 Z={on:e.arbRecapture,traderBps:0,lpBps:e.arbRecapture?1e4:0,period:0,maxPrizeBps:0,potReleaseBps:0,minBuyQuote:0n,releaseBlocks:0},ke=null;if(e.arbRecapture){let[D,ge]=await Promise.all([c(i,X,Q(["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,w("registry"),"activeLaneOf",[F],t.number)]);Z.releaseBlocks=Number(f(A(H(D,2)[0]).releaseBlocks,32));let[Ve,je,Xe,_e]=H(ge,4),ne=q(Ve);if(await V(i,t.number,[ne]),ne===b||C(je)!==ve(ne).codeHash||f(Xe,32)===0n||f(_e,16)>10000n||!Z.releaseBlocks)throw new o("Hookr recapture lane is unavailable. Use arbRecapture false until its executor and gas floor are reviewed.");ke=se(ge)}let fe={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:X,advisory:Be,liquidityOwner:g,baseLpFeePips:y.baseLpFeePips,caps:{maxLpFeePips:Number(G),maxQuoteTakePips:Number(Y),maxSubjectTakeBps:0},rulesGasLimit:Number(u.coreAdmission.gasLimit),advisoryGasLimit:Number(p(de.gasLimit,32)),advisoryPhases:1,advisoryFailOpen:!1,policyId:ae},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:Z},L=BigInt(u.launchFee.amount);if(L>10000000000000000n)throw new o("Hookr launch fee exceeds the reviewed 0.01 ETH maximum.");let v=b;if(L&&(await V(i,t.number,[u.launchFee.treasury]),v=q(await c(i,u.launchFee.treasury,Q(["function target() view returns (address)"]),"target",[],t.number)),v===b||v===g||v===r||v===Se))throw new o("Hookr launch fee recipient is outside the reviewed payment profile.");let ee=L+(e.quote===b?h:0n),te=[],U=[];if(e.quote!==b){let D=f(await c(i,e.quote,Ge,"allowance",[r,g],t.number));D!==0n&&D!==h&&U.push(a.approval(e.quote,g,"0",4663)),U.push(a.approval(e.quote,g,h.toString(),4663)),te.push({token:e.quote,amount:h})}ee&&te.push({token:xe,amount:ee,to:g});let we=`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 ${d.currency0}; currency1 ${d.currency1}. Launch fee ${L} wei to ${v} (${Ae(L,18)} ETH). Unused quote funding (${h-S} base units) and retained token supply (${e.token.supply-I} 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 ${Y} pips (includes Hookr minimum); protocol share ${E} bps. Arb recapture ${e.arbRecapture}; deadline ${e.deadline}. No lock.`;U.push(a.unsignedTx({to:g,data:We({abi:w("launcherV1"),functionName:"launchAdvised",args:[e.token,F,[fe],[Qe(Ye,[e.gateTerms])],e.deadline]}),value:ee.toString(),chainId:4663,description:we}));let[ye,ze,Ke]=await Promise.all([i.getCode({address:s}),i.getTransactionCount({address:s}),i.readContract({address:g,abi:He,functionName:"launchFee"})]);if(ye&&ye!=="0x"||ze!==0||f(H(Ke,5)[0])!==L)throw new o("Hookr collision state or launch fee changed. Request a fresh launch preview.");return await Le(i,t),{txs:U,inputs:te,summary:we,tokenAddress:s,poolId:m,feeTarget:v,feeTreasury:u.launchFee.treasury,terms:se({request:n,blockNumber:t.number,blockHash:t.hash,owner:r,tokenAddress:s,poolId:m,poolKey:d,member:fe,gateTerms:e.gateTerms,launchFee:L,feeTarget:v,feeTreasury:u.launchFee.treasury,hookrMinimumPips:J,exactApprovals:U.slice(0,-1),refunds:{quote:h-S,retainedSupply:e.token.supply-I},gasEstimate:null,gasEstimateReason:"The local sender estimates the ordered exact calls after funding approvals and confirms the gas limit and maximum fee.",lane:ke,pins:K})}}function ot(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)R(n,["to","data","value","chainId","description"],["to","data","value","chainId","description"])}function kt(a,n){if(ot(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 ft(a){return[{name:Je,inputSchema:ue,execute:async(n,r)=>{let e=await nt(a,n,r);return{txs:e.txs,preview:await a.preview(e.txs,r),terms:e.terms,summary:e.summary}}}]}export{Je as a,g as b,X as c,ue as d,Ze as e,nt as f,ot as g,kt as h,ft as i};
@@ -0,0 +1 @@
1
+ import{b as V}from"./CQ5WRWV4.js";import{a as S,b as C,c as W,d as re}from"./IV4K7FMD.js";import{a as ae,d as se,e as ie}from"./ZQAFFWDK.js";import{d as ue}from"./FL5SSHUL.js";import{b as F}from"./H5DY7CNB.js";import{a as f,b as j,c as oe}from"./43LI5NKJ.js";import{c as G}from"./5TUXSOMI.js";import{b as o,e as ne}from"./IX3GZMTM.js";import{a as x,i as z,w as K,x as _,z as te}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{decodeFunctionData as R,encodeFunctionData as M,parseAbi as ce}from"viem";var ve=60,Z=50,Ne=200;var he="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",J="0x0000000000000000000000000000000000000000",T=z[4663].routes.kyberswap.address,y=z[4663].routes.velora.address,q=K[4663].kyberswap.toLowerCase(),le=K[4663].velora.toLowerCase(),Se="0x0000000000000000000000000000000000000000000000000000000000000000",N=ce(["function swap((address callTarget, address approveTarget, bytes targetData, (address srcToken, address dstToken, address[] srcReceivers, uint256[] srcAmounts, address[] feeReceivers, uint256[] feeAmounts, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags, bytes permit) desc, bytes clientData) execution) payable returns (uint256 returnAmount, uint256 gasUsed)"]),$=ce(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]),E=class extends r{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},L=class extends r{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},be=1e3,k=new Map;function me(e){for(let[t,n]of k)BigInt(e)>=o(n.expiresAt)&&k.delete(t)}function Y(e){return{...e,...e.sourcePoolRoute!==void 0?{sourcePoolRoute:structuredClone(e.sourcePoolRoute)}:{},...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function de(e){let t=Y(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var Oe=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","ponsPoolToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund","oakFee","oakFeeBps","oakFeeToken","grossAmountOut","venueFee","venueFeeBps"];function U(e,t,n=!1){for(let u of Oe)if(!(u==="expiresAt"&&n&&o(e.expiresAt)<=o(t.expiresAt))&&e[u]!==void 0&&String(e[u]).toLowerCase()!==String(t[u]).toLowerCase())throw new r(`Quote ${u} does not match the accepted quote.`)}function H(e=Date.now){let t=e();if(!Number.isFinite(t)||t<0)throw new r("Clock must return a non-negative timestamp.");return t>1e11?Math.floor(t/1e3):Math.floor(t)}function P(e){let t=e.toLowerCase();return t===he.toLowerCase()||t===J.toLowerCase()}function ke(e,t=Z){if(!Number.isInteger(t)||t<0||t>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");return ne(e,String(1e4-t),"10000","floor")}var Ie=200;function $e(e){if(typeof e!="number"||!Number.isFinite(e)||!/^\d+(?:\.\d{1,2})?$/.test(String(e)))throw new r("Velora returned an unsupported venue fee. Request a fresh quote.");let[t,n=""]=String(e).split("."),u=Number(t)*100+Number(n.padEnd(2,"0"));return ee(u),u}function ee(e){if(!Number.isInteger(e)||e<0||e>Ie)throw new r("Velora returned an unsupported venue fee. Request a fresh quote.")}function pe(e,t=S.bps){return ee(t),o(e)*10000n/BigInt(1e4-t)+1n}function xe(e,t){if(ee(t),t!==S.bps||e!==W)throw new r("Velora partnerAndFee must match the pinned Oak fee, recipient and flags.")}function fe(e){if(e.oakFeeBps===S.bps)return`${re()} ${e.provider==="velora"?"Oak\u2019s share is paid to the Oak treasury.":"Paid to the Oak treasury."} Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${e.provider??"venue"}. Output and minimum are net.${e.provider==="velora"?" Velora retains 15% of the partner fee; Oak receives 85% (about 21.25 bps).":""}`;if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");let t=e.provider??"venue";return`Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${t}; Oak swap fee: 0 (venue fee is never Oak income).`}function Fe(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??_[x].kyberswap.address,n=e.approveTarget??J;f(t),f(n);let u=o(e.amountIn),a=o(e.minAmountOut);return M({abi:N,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:P(e.from)?[]:[t],srcAmounts:P(e.from)?[]:[u-BigInt(C(e.amountIn))],feeReceivers:[S.recipient],feeAmounts:[BigInt(S.bps)],dstReceiver:e.wallet,amount:u,minReturnAmount:a,flags:640n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Ee(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??_[x].velora.address;return f(t),M({abi:$,functionName:"swapExactAmountIn",args:[t,{srcToken:e.from,destToken:e.to,fromAmount:o(e.amountIn),toAmount:o(e.minAmountOut),quotedAmount:o(e.amountOut),metadata:e.metadata??Se,beneficiary:e.wallet},e.partnerAndFee??W,"0x",e.executorData??"0x"]})}function De(e){if(typeof e!="string"||!/^0x([0-9a-fA-F]{2})+$/.test(e)||e.length<10)throw new r("Swap calldata must contain a 4-byte function selector.");let t=e.slice(0,10).toLowerCase();if(t===q)return R({abi:N,data:e}).args[0].desc.minReturnAmount;if(t===le)return R({abi:$,data:e}).args[1].toAmount;if(t==="0x3593564c")return se(e).swap.amountOutMinimum;let n=R({abi:ae,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new r(`Unsupported swap router selector ${t}.`)}function we(e,t,n=!1){let u=o(t),a=De(e);if(a<=0n||u<=0n||a!==u&&!(n&&(a>u||e.slice(0,10).toLowerCase()===q&&a+1n===u)))throw new r(`Built swap calldata minimum output (${a}) does not match the accepted quote minimum (${u}).`);return a}function Ae(e,t){let{from:n,to:u,wallet:a,amountIn:d}=t;if(!n||!u||!a||d===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");for(let i of[n,u,a,t.router,e.to])f(i);let p=(i,l,w)=>{if(i.toLowerCase()!==l.toLowerCase())throw new r(`Built swap ${w} does not match the accepted quote.`)};if(p(e.to,t.router,"router"),e.chainId!==(t.chainId??x))throw new r("Built swap chain does not match the accepted quote.");let g=P(n)?o(d):0n;if(o(e.value)!==g||t.value!==void 0&&o(t.value)!==g)throw new r("Built swap value does not match the accepted quote input.");let A=e.data.slice(0,10).toLowerCase(),s=t.router.toLowerCase();if(s===T.toLowerCase()||s===y.toLowerCase()){let i=s===T.toLowerCase(),l=i?d:t.grossAmountOut,w=i?n:u;if(t.oakFeeBps!==S.bps||l===void 0||t.oakFee!==C(l)||t.oakFeeToken?.toLowerCase()!==F(w).toLowerCase())throw new r("Oak fee must match the pinned rate, token and amount.")}let c;if(s===T.toLowerCase()&&A===q){p(t.spender??t.router,T,"spender");let i=R({abi:N,data:e.data});if(M({abi:N,...i}).toLowerCase()!==e.data.toLowerCase())throw new r("KyberSwap calldata must be canonically decodable.");let{callTarget:l,approveTarget:w,desc:m}=i.args[0];p(l,_[x].kyberswap.address,"executor"),p(w,J,"executor approval target");let I=P(n);if(m.srcReceivers.length!==m.srcAmounts.length||(I?m.srcReceivers.length!==0:m.srcReceivers.length===0||m.srcAmounts.some(v=>v<=0n)||m.srcAmounts.reduce((v,b)=>v+b,0n)!==o(d)-BigInt(C(d))))throw new r("KyberSwap source transfers must send the exact input less the pinned fee to the pinned executor or verified input pool.");for(let v of m.srcReceivers)if(v.toLowerCase()!==l.toLowerCase()&&!ue(n,v,e.data))throw new r(`KyberSwap source transfers: receiver ${v} is not a verified input pool or the pinned executor.`);if(m.feeReceivers.length!==1||m.feeAmounts.length!==1||m.feeReceivers[0].toLowerCase()!==S.recipient.toLowerCase()||m.feeAmounts[0]!==BigInt(S.bps)||m.flags!==640n||m.permit!=="0x")throw new r("KyberSwap fee recipients, fee amounts, flags and permit must match the pinned Oak input-fee policy.");c={from:m.srcToken,to:m.dstToken,wallet:m.dstReceiver,amount:m.amount}}else if(s===y.toLowerCase()&&A===le){p(t.spender??t.router,y,"spender");let i=R({abi:$,data:e.data});if(M({abi:$,...i}).toLowerCase()!==e.data.toLowerCase())throw new r("Velora calldata must be canonically decodable.");let[l,w,m,I]=i.args;if(!te.some(v=>v.toLowerCase()===l.toLowerCase()))throw new r("Built swap executor does not match the accepted quote.");if(I!=="0x")throw new r("Velora permit must match the pinned empty-permit policy.");if(xe(m,t.oakFeeBps??S.bps),t.calldataMinAmountOut!==void 0&&o(t.calldataMinAmountOut)!==pe(t.minAmountOut,S.bps))throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.");if(t.calldataMinAmountOut!==void 0&&(w.quotedAmount!==o(t.grossAmountOut??"0")||w.quotedAmount<o(t.calldataMinAmountOut)))throw new r("Velora quoted gross output must match the accepted quote and cover its calldata minimum.");if(m!==0n&&t.calldataMinAmountOut===void 0)throw new r("Velora venue fee requires a fee-adjusted calldata minimum.");c={from:w.srcToken,to:w.destToken,wallet:w.beneficiary,amount:w.fromAmount}}else if(t.provider==="pons"&&(t.ponsPoolToken||t.ponsCurveToken))c=ie(e,{...t,from:n,to:u,wallet:a});else throw new r("Built swap selector does not match the accepted router.");if(p(c.from,n,"input token"),p(c.to,u,"output token"),p(c.wallet,a,"recipient"),c.amount!==o(d))throw new r("Built swap input amount does not match the accepted quote.");we(e.data,t.calldataMinAmountOut??t.minAmountOut,s===T.toLowerCase())}function X(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Quote must include a non-empty quoteId.");if(f(e.router),e.oakFeeBps!==void 0){let h=t.provider??e.provider,O=h==="kyberswap"?t.amountIn??e.amountIn:e.grossAmountOut,Q=h==="kyberswap"?t.from??e.from:t.to??e.to;if(!["kyberswap","velora"].includes(h??"")||e.oakFeeBps!==S.bps||O===void 0||e.oakFee!==C(O)||!Q||e.oakFeeToken?.toLowerCase()!==F(Q).toLowerCase())throw new r("Oak fee must match the pinned rate, token and amount.")}else if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");let n=o(e.amountOut),u=e.destAmountAfterFee??e.netAmountOut,a,d,p;if(u!==void 0){if(d=o(u),a=e.grossAmountOut!==void 0?o(e.grossAmountOut):n>=d?n:d,a<d)throw new r("Gross output cannot be less than net output.");p=e.venueFee!==void 0?o(e.venueFee):a-d}else if(e.grossAmountOut!==void 0){if(a=o(e.grossAmountOut),d=n,a<d)throw new r("Gross output cannot be less than net output.");p=e.venueFee!==void 0?o(e.venueFee):a-d}else e.venueFee!==void 0?(p=o(e.venueFee),d=n,a=d+p):(d=n,a=n,p=0n);if(d<=0n)throw new E("Quote output amount must be positive.");let g=t.slippageBps??e.slippageBps??Z,A=e.minAmountOut!==void 0?o(e.minAmountOut):o(ke(d.toString(),g));if(A<=0n||A>a)throw new r("Quote minAmountOut must be positive and not exceed gross output.");if((t.provider??e.provider)==="velora"&&e.calldataMinAmountOut!==void 0){if(o(e.calldataMinAmountOut)!==pe(A.toString(),S.bps)||o(e.calldataMinAmountOut)>a)throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.")}else if(e.calldataMinAmountOut!==void 0||e.ponsCurveToken!==void 0){if((t.provider??e.provider)!=="pons"||!e.ponsCurveToken)throw new r("Curve minimum requires a Pons curve quote.");f(e.ponsCurveToken);let h=o(t.amountIn??e.amountIn??"0"),O=o(e.expectedSpend??"0"),Q=o(e.expectedRefund??"0"),ge=o(e.calldataMinAmountOut??"0");if(h<=0n||O<=0n||O+Q!==h||ge*O/h!==A)throw new r("Pons actual minimum and refund do not match the encoded minimum.")}let s=H(t.now),c=BigInt(s+ve),i=e.expiresAt!==void 0?o(e.expiresAt):c,l=(i>c?c:i).toString(),w=p.toString(),m=e.venueFeeBps??(a>0n&&p>0n?Number((p*10000n+a/2n)/a):0),I=t.provider??e.provider??(e.router.toLowerCase()===y.toLowerCase()?"velora":"kyberswap"),v=I==="pons"&&e.feeDisclosure?e.feeDisclosure:fe({provider:I,venueFee:w,venueFeeBps:m,oakFee:e.oakFee??"0",oakFeeBps:e.oakFeeBps}),b={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:A.toString(),router:e.router,expiresAt:l,provider:I,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:w,venueFeeBps:m,oakFee:e.oakFee??"0",feeDisclosure:v,...t.from??e.from?{from:F(t.from??e.from)}:{},...t.to??e.to?{to:F(t.to??e.to)}:{},...t.amountIn??e.amountIn?{amountIn:t.amountIn??e.amountIn}:{},...t.wallet??e.wallet?{wallet:t.wallet??e.wallet}:{},slippageBps:g,chainId:t.chainId??e.chainId??x,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(s)>=o(l))throw new L;if(t.cache===!1)return b;if(me(s),BigInt(s)>=o(l))throw new L;let B=k.get(b.quoteId);if(B){U(b,B,!0);let h=de({...B,expiresAt:b.expiresAt});return k.set(h.quoteId,h),Y(h)}for(;k.size>=be;)k.delete(k.keys().next().value);let D=de(b);return k.set(D.quoteId,D),Y(D)}async function Ue(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=F(e.from),e.to=F(e.to);let u=o(e.amountIn);if(u<=0n)throw new r("Swap amountIn must be greater than zero.");let a=e.slippageBps??Z;if(!Number.isInteger(a)||a<0||a>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");if(!Array.isArray(t)||t.length===0)throw new E;let d={from:e.from,to:e.to,amountIn:u.toString(),slippageBps:a},p=await Promise.allSettled(t.map(async s=>{let c=await(s.quotePrices??s.quote).call(s,{...d},e.wallet);return{quote:X(c,{provider:s.name,from:e.from,to:e.to,amountIn:u.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??x,allowance:e.allowance,now:e.now,cache:!1}),provider:s}})),g,A=[];for(let s of p)s.status==="rejected"&&(g??=G(s.reason)),s.status==="fulfilled"&&o(s.value.quote.expiresAt)>BigInt(H(e.now))&&A.push(s.value);if(A.length===0){let s=p.some(c=>c.status==="rejected"&&c.reason instanceof Error&&c.reason.message===V)&&p.every(c=>c.status==="rejected"&&(c.reason instanceof E||c.reason instanceof Error&&c.reason.message===V));throw g??new E(s?V:void 0)}A.sort((s,c)=>{let l=o(c.quote.amountOut)-o(s.quote.amountOut)||o(c.quote.minAmountOut)-o(s.quote.minAmountOut);return l>0n?1:l<0n?-1:0});for(let{quote:s,provider:c}of A)try{if(BigInt(H(e.now))>=o(s.expiresAt))continue;if(n.deferBuild||!c.prepareQuote)return X(s,{now:e.now});let i=await c.prepareQuote(s.quoteId,e.wallet);if(i.quoteId!==s.quoteId)throw new r("Prepared quote ID does not match the selected route.");if(U(i,s,!0),!i.data)throw new r("Selected route did not return swap calldata.");let l={...s,expiresAt:i.expiresAt,data:i.data,value:i.value,allowance:i.allowance??s.allowance};return Ae(j({to:l.router,data:i.data,value:i.value??"0",chainId:l.chainId??x,description:"Selected swap route"}),l),X(l,{now:e.now})}catch(i){g??=G(i);continue}throw g??new E}function He(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Provide a valid quote to build a swap.");f(e.router);let n=k.get(e.quoteId),u=H(t.now);if(me(u),!n||BigInt(u)>=o(n.expiresAt))throw k.delete(e.quoteId),new L;if(e.oakFeeBps===void 0&&e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak fee requires the pinned rate and token; venue fees must never be counted as Oak income.");U(e,n),U({...n,...t},n);let a=n.from,d=n.to,p=n.amountIn,g=n.wallet;if(!a||!d||!g||p===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");let A=n.chainId??x,s=n.spender??n.router,c=t.allowance??e.allowance??n?.allowance??"0";f(a),f(d),f(g),f(s);let i=o(p);if(i<=0n)throw new r("Swap amountIn must be greater than zero.");let l=o(n.minAmountOut);if(l<=0n)throw new r("Swap minAmountOut must be greater than zero.");let w=e.router.toLowerCase()===y.toLowerCase(),m=t.data??e.data??n?.data??(w?Ee({from:a,to:d,amountIn:i.toString(),amountOut:n.grossAmountOut??n.amountOut,minAmountOut:n.calldataMinAmountOut??l.toString(),wallet:g}):Fe({from:a,to:d,amountIn:i.toString(),minAmountOut:l.toString(),wallet:g}));we(m,n.calldataMinAmountOut??l.toString(),n.router.toLowerCase()===T.toLowerCase());let I=n.venueFee??"0",v=n.venueFeeBps??0,b=n.provider??(w?"velora":"kyberswap"),B=n.feeDisclosure??fe({provider:b,venueFee:I,venueFeeBps:v,oakFee:n.oakFee??"0",oakFeeBps:n.oakFeeBps}),D=P(a),h=t.value??e.value??n?.value??(D?i.toString():"0"),O=j({to:e.router,data:m,value:h,chainId:A,description:`Swap ${i} base units of ${a} for at least ${l} base units of ${d} via ${b} (${e.router}). ${B}`});return Ae(O,n),D||o(c)>=i?[O]:[oe(a,s,i.toString(),A),O]}export{ve as a,Z as b,Ne as c,he as d,J as e,N as f,E as g,L as h,be as i,Y as j,de as k,U as l,H as m,P as n,ke as o,Ie as p,$e as q,pe as r,xe as s,fe as t,Fe as u,Ee as v,De as w,we as x,Ae as y,X as z,Ue as A,He as B};
@@ -0,0 +1 @@
1
+ import{AsyncLocalStorage as u}from"node:async_hooks";var o=new u;function d(t,n){return o.run({sink:t,lastProgress:-1/0,lastSentAt:void 0},n)}function g(t,n,r){let e=o.getStore();if(!e?.sink||!Number.isFinite(t)||t<=e.lastProgress)return;let s=Date.now();if(!(e.lastSentAt!==void 0&&s-e.lastSentAt<250)){e.lastProgress=t,e.lastSentAt=s;try{let i={progress:t,...n===void 0?{}:{total:n},...r===void 0?{}:{message:r}};Promise.resolve(e.sink(i)).catch(()=>{})}catch{}}}export{d as a,g as b};
@@ -0,0 +1 @@
1
+ import{a as p,f as u,g as c}from"./J73ATSEQ.js";import{f as a}from"./BAIY32AV.js";import{a as r}from"./66F5ZH34.js";import{a as i}from"./FWD4L3CJ.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as d,parseAbi as f}from"viem";var m=f(["function deposit() payable","function withdraw(uint256)"]);function W(n){return{tools:[{name:"uniswap_wrap",inputSchema:{type:"object",additionalProperties:!1,required:["direction","amount"],properties:{direction:{description:'Choose "wrap" to exchange ETH for WETH, or "unwrap" to exchange WETH for ETH.',type:"string",enum:["wrap","unwrap"]},amount:r('Amount of ETH or WETH in base units (18 decimals). Example: "1000000000000000000" = 1 ETH or WETH.')}},async execute(t,s){if(c(t,["direction","amount"]),t.direction!=="wrap"&&t.direction!=="unwrap")throw new e("Choose direction wrap or unwrap.");let o=p(t.amount,"amount"),w=t.direction==="wrap"?d({abi:m,functionName:"deposit"}):d({abi:m,functionName:"withdraw",args:[o]});return u(n,[n.unsignedTx({to:a,data:w,value:t.direction==="wrap"?o.toString():"0",chainId:i,description:`${t.direction} ${o} ETH/WETH base units to the signing wallet.`})],s,"Wrap or unwrap native ETH at the pinned WETH contract. Ratio 1:1; network gas is additional.")}}]}}export{m as a,W as b};