@oakagentkit/core 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/build/dist/api/addresses.d.ts +14 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.d.ts +2 -0
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.js +1 -1
  10. package/build/dist/api/modules/beefy/guard.js +1 -1
  11. package/build/dist/api/modules/beefy/index.js +1 -1
  12. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  13. package/build/dist/api/modules/beefy/management.js +1 -1
  14. package/build/dist/api/modules/beefy/vaults.js +1 -1
  15. package/build/dist/api/modules/borro/actions.js +1 -1
  16. package/build/dist/api/modules/borro/index.js +1 -1
  17. package/build/dist/api/modules/borro/liquidity.js +1 -1
  18. package/build/dist/api/modules/borro/positions.js +1 -1
  19. package/build/dist/api/modules/borro/reader.js +1 -1
  20. package/build/dist/api/modules/chop/display.js +1 -1
  21. package/build/dist/api/modules/chop/guard.js +1 -1
  22. package/build/dist/api/modules/chop/index.js +1 -1
  23. package/build/dist/api/modules/clanker/extensions.js +1 -1
  24. package/build/dist/api/modules/clanker/index.js +1 -1
  25. package/build/dist/api/modules/clanker/manage.js +1 -1
  26. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  27. package/build/dist/api/modules/clanker/protocol.js +1 -1
  28. package/build/dist/api/modules/clanker/state.js +1 -1
  29. package/build/dist/api/modules/earn/index.js +1 -1
  30. package/build/dist/api/modules/erc8004/common.js +1 -1
  31. package/build/dist/api/modules/erc8004/domain.js +1 -1
  32. package/build/dist/api/modules/erc8004/index.js +1 -1
  33. package/build/dist/api/modules/erc8004/management.js +1 -1
  34. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  35. package/build/dist/api/modules/erc8004/services.js +1 -1
  36. package/build/dist/api/modules/erc8004/thesis.js +1 -1
  37. package/build/dist/api/modules/erc8004/validation.js +1 -1
  38. package/build/dist/api/modules/fobo/index.js +1 -1
  39. package/build/dist/api/modules/fobo/intent.js +1 -1
  40. package/build/dist/api/modules/fobo/steps.js +1 -1
  41. package/build/dist/api/modules/fobo/verify.js +1 -1
  42. package/build/dist/api/modules/grove/index.js +1 -1
  43. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  44. package/build/dist/api/modules/heyresearch/index.js +1 -1
  45. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  46. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  47. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/index.js +1 -1
  49. package/build/dist/api/modules/hoodag/management.js +1 -1
  50. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  51. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  52. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  53. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  54. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  55. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  56. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  57. package/build/dist/api/modules/hoodlock/index.js +1 -1
  58. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  59. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  60. package/build/dist/api/modules/hoodlock/public.js +1 -1
  61. package/build/dist/api/modules/hookr/actions.d.ts +39 -2
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/addons.js +1 -1
  64. package/build/dist/api/modules/hookr/agent-gate.d.ts +14 -2
  65. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  66. package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
  67. package/build/dist/api/modules/hookr/agent-link.js +1 -0
  68. package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
  69. package/build/dist/api/modules/hookr/api-client.js +1 -0
  70. package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
  71. package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
  72. package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
  73. package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
  74. package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
  75. package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
  76. package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
  77. package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
  78. package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
  79. package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
  80. package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
  81. package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
  82. package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
  83. package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
  84. package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
  85. package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
  86. package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
  87. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
  88. package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
  89. package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
  90. package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
  91. package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
  92. package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
  93. package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
  94. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
  95. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
  96. package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
  97. package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
  98. package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
  99. package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
  100. package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
  101. package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
  102. package/build/dist/api/modules/hookr/claims.d.ts +53 -0
  103. package/build/dist/api/modules/hookr/claims.js +1 -0
  104. package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
  105. package/build/dist/api/modules/hookr/contracts.js +1 -1
  106. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  107. package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
  108. package/build/dist/api/modules/hookr/discovery.js +1 -1
  109. package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
  110. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  111. package/build/dist/api/modules/hookr/gas.d.ts +48 -0
  112. package/build/dist/api/modules/hookr/gas.js +1 -0
  113. package/build/dist/api/modules/hookr/gates.d.ts +51 -0
  114. package/build/dist/api/modules/hookr/gates.js +1 -0
  115. package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
  116. package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
  117. package/build/dist/api/modules/hookr/index.d.ts +4 -2
  118. package/build/dist/api/modules/hookr/index.js +1 -1
  119. package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
  120. package/build/dist/api/modules/hookr/jobs.js +1 -0
  121. package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
  122. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  123. package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
  124. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  125. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  126. package/build/dist/api/modules/hookr/launch.d.ts +24 -0
  127. package/build/dist/api/modules/hookr/launch.js +1 -1
  128. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  129. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  130. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  131. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  132. package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
  133. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  134. package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
  135. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
  136. package/build/dist/api/modules/hookr/pins.d.ts +5 -0
  137. package/build/dist/api/modules/hookr/pins.js +1 -1
  138. package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
  139. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
  140. package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
  141. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  142. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  143. package/build/dist/api/modules/hookr/relay.js +1 -1
  144. package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
  145. package/build/dist/api/modules/hookr/revenue.js +1 -1
  146. package/build/dist/api/modules/hookr/scan.d.ts +25 -0
  147. package/build/dist/api/modules/hookr/scan.js +1 -0
  148. package/build/dist/api/modules/hookr/swap.d.ts +161 -0
  149. package/build/dist/api/modules/hookr/swap.js +1 -0
  150. package/build/dist/api/modules/kyberswap/index.js +1 -1
  151. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  152. package/build/dist/api/modules/layerbank/abi.js +1 -1
  153. package/build/dist/api/modules/layerbank/actions.js +1 -1
  154. package/build/dist/api/modules/layerbank/checks.js +1 -1
  155. package/build/dist/api/modules/layerbank/index.js +1 -1
  156. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  157. package/build/dist/api/modules/layerbank/reader.js +1 -1
  158. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  159. package/build/dist/api/modules/lighter/index.js +1 -1
  160. package/build/dist/api/modules/longbow/administration.js +1 -1
  161. package/build/dist/api/modules/longbow/analytics.js +1 -1
  162. package/build/dist/api/modules/longbow/fixed.js +1 -1
  163. package/build/dist/api/modules/longbow/index.js +1 -1
  164. package/build/dist/api/modules/longbow/nft.js +1 -1
  165. package/build/dist/api/modules/longbow/rebates.js +1 -1
  166. package/build/dist/api/modules/longbow/staking.js +1 -1
  167. package/build/dist/api/modules/meridian/index.js +1 -1
  168. package/build/dist/api/modules/meridian/markets.js +1 -1
  169. package/build/dist/api/modules/meridian/rfq.js +1 -1
  170. package/build/dist/api/modules/merkl/discovery.js +1 -1
  171. package/build/dist/api/modules/merkl/index.js +1 -1
  172. package/build/dist/api/modules/merkl/manage.js +1 -1
  173. package/build/dist/api/modules/merkl/protocol.js +1 -1
  174. package/build/dist/api/modules/morpho/allocator.js +1 -1
  175. package/build/dist/api/modules/morpho/bundles.js +1 -1
  176. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  177. package/build/dist/api/modules/morpho/index.js +1 -1
  178. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  179. package/build/dist/api/modules/morpho/midnight.js +1 -1
  180. package/build/dist/api/modules/morpho/protocol.js +1 -1
  181. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  182. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  183. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  184. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  185. package/build/dist/api/modules/netnet/card-read.js +1 -1
  186. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  187. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  188. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  189. package/build/dist/api/modules/netnet/financial.js +1 -1
  190. package/build/dist/api/modules/netnet/index.js +1 -1
  191. package/build/dist/api/modules/netnet/staking.js +1 -1
  192. package/build/dist/api/modules/orbio/index.js +1 -1
  193. package/build/dist/api/modules/orbio/positions.js +1 -1
  194. package/build/dist/api/modules/pendle/costs.js +1 -1
  195. package/build/dist/api/modules/pendle/index.js +1 -1
  196. package/build/dist/api/modules/pendle/markets.js +1 -1
  197. package/build/dist/api/modules/pendle/positions.js +1 -1
  198. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  199. package/build/dist/api/modules/pendle/reader.js +1 -1
  200. package/build/dist/api/modules/pendle/redeem.js +1 -1
  201. package/build/dist/api/modules/pendle/trade.js +1 -1
  202. package/build/dist/api/modules/pendle/validate.js +1 -1
  203. package/build/dist/api/modules/pendle/verify.js +1 -1
  204. package/build/dist/api/modules/pons/claim.js +1 -1
  205. package/build/dist/api/modules/pons/index.js +1 -1
  206. package/build/dist/api/modules/pons/launch-status.js +1 -1
  207. package/build/dist/api/modules/pons/prices.js +1 -1
  208. package/build/dist/api/modules/pons/reads.js +1 -1
  209. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  210. package/build/dist/api/modules/pons/trade.js +1 -1
  211. package/build/dist/api/modules/poolstrade/index.js +1 -1
  212. package/build/dist/api/modules/priors/coverage.js +1 -1
  213. package/build/dist/api/modules/priors/discovery.js +1 -1
  214. package/build/dist/api/modules/priors/features.js +1 -1
  215. package/build/dist/api/modules/priors/holdings.js +1 -1
  216. package/build/dist/api/modules/priors/index.js +1 -1
  217. package/build/dist/api/modules/priors/integration.js +1 -1
  218. package/build/dist/api/modules/priors/market.js +1 -1
  219. package/build/dist/api/modules/priors/pt.js +1 -1
  220. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  221. package/build/dist/api/modules/priors/starter-line.js +1 -1
  222. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  223. package/build/dist/api/modules/raeto/index.js +1 -1
  224. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  225. package/build/dist/api/modules/relay/discovery.js +1 -1
  226. package/build/dist/api/modules/relay/inbound.js +1 -1
  227. package/build/dist/api/modules/relay/index.js +1 -1
  228. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  229. package/build/dist/api/modules/relay/reads.js +1 -1
  230. package/build/dist/api/modules/spark/actions.js +1 -1
  231. package/build/dist/api/modules/spark/details.js +1 -1
  232. package/build/dist/api/modules/spark/index.js +1 -1
  233. package/build/dist/api/modules/spark/management.js +1 -1
  234. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  235. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  236. package/build/dist/api/modules/steakhouse/index.js +1 -1
  237. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  238. package/build/dist/api/modules/steakhouse/management.js +1 -1
  239. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  240. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  241. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  242. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  243. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  244. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  245. package/build/dist/api/modules/tickerspring/index.js +1 -1
  246. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  247. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  248. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  249. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  250. package/build/dist/api/modules/tickerspring/research.js +1 -1
  251. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  252. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  253. package/build/dist/api/modules/uniswap/auction.js +1 -1
  254. package/build/dist/api/modules/uniswap/batch.js +1 -1
  255. package/build/dist/api/modules/uniswap/common.js +1 -1
  256. package/build/dist/api/modules/uniswap/fees.js +1 -1
  257. package/build/dist/api/modules/uniswap/index.js +1 -1
  258. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  259. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  260. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  261. package/build/dist/api/modules/uniswap/pools.js +1 -1
  262. package/build/dist/api/modules/uniswap/position.js +1 -1
  263. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  264. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  265. package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
  266. package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
  267. package/build/dist/api/modules/uniswap/stocks.js +1 -1
  268. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  269. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  270. package/build/dist/api/modules/uniswap/trade.js +1 -1
  271. package/build/dist/api/modules/uniswap/v2.js +1 -1
  272. package/build/dist/api/modules/uniswap/v3.js +1 -1
  273. package/build/dist/api/modules/uniswap/v4.js +1 -1
  274. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  275. package/build/dist/api/modules/upoch/index.js +1 -1
  276. package/build/dist/api/modules/upoch/reads.js +1 -1
  277. package/build/dist/api/modules/velora/claims.js +1 -1
  278. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  279. package/build/dist/api/modules/velora/index.js +1 -1
  280. package/build/dist/api/modules/wormhole/index.js +1 -1
  281. package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
  282. package/build/dist/api/positions.js +1 -1
  283. package/build/dist/api/pricenote.js +1 -1
  284. package/build/dist/api/prices.js +1 -1
  285. package/build/dist/api/rpc.js +1 -1
  286. package/build/dist/api/send.js +1 -1
  287. package/build/dist/api/signing-registry.js +1 -1
  288. package/build/dist/api/signing.js +1 -1
  289. package/build/dist/api/simulate.js +1 -1
  290. package/build/dist/api/swap.d.ts +2 -0
  291. package/build/dist/api/swap.js +1 -1
  292. package/build/dist/api/tokens.d.ts +9 -1
  293. package/build/dist/api/tokens.js +1 -1
  294. package/build/dist/api/tool-policy.js +1 -1
  295. package/build/dist/api/universal-router.js +1 -1
  296. package/build/dist/api/usd-estimate.js +1 -1
  297. package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
  298. package/build/dist/chunks/{R66NSNNQ.js → 2BKZLF5A.js} +1 -1
  299. package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
  300. package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
  301. package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
  302. package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
  303. package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
  304. package/build/dist/chunks/{C57DITTF.js → 3HF6WE4L.js} +1 -1
  305. package/build/dist/chunks/3M7RMROZ.js +1 -0
  306. package/build/dist/chunks/3RGED2KO.js +1 -0
  307. package/build/dist/chunks/{4HQEJHCD.js → 3XIJCHT7.js} +1 -1
  308. package/build/dist/chunks/3XY44BP5.js +1 -0
  309. package/build/dist/chunks/3YNXQ3EZ.js +1 -0
  310. package/build/dist/chunks/45QP74CE.js +1 -0
  311. package/build/dist/chunks/{SX5YNFHG.js → 4GAU3JLN.js} +1 -1
  312. package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
  313. package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
  314. package/build/dist/chunks/{QMIH6HXH.js → 4SXRXNHG.js} +1 -1
  315. package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
  316. package/build/dist/chunks/{FRT6AC6M.js → 5677LZOV.js} +1 -1
  317. package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
  318. package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
  319. package/build/dist/chunks/{JDHPMS7X.js → 5DWQUEBA.js} +1 -1
  320. package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
  321. package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
  322. package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
  323. package/build/dist/chunks/5PNFV7HH.js +1 -0
  324. package/build/dist/chunks/5RAZFRO4.js +1 -0
  325. package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
  326. package/build/dist/chunks/5VKVAUFQ.js +1 -0
  327. package/build/dist/chunks/5Y457HYC.js +1 -0
  328. package/build/dist/chunks/64LAWFBE.js +1 -0
  329. package/build/dist/chunks/{3BQ5XHDJ.js → 6EWSLHXL.js} +1 -1
  330. package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
  331. package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
  332. package/build/dist/chunks/{TZ7S5KRB.js → 6QXTL65K.js} +1 -1
  333. package/build/dist/chunks/6RVAV6BB.js +1 -0
  334. package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
  335. package/build/dist/chunks/{RUHNLNVX.js → 6Y2546JA.js} +1 -1
  336. package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
  337. package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
  338. package/build/dist/chunks/7GL547YZ.js +1 -0
  339. package/build/dist/chunks/7JTXYMNP.js +1 -0
  340. package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
  341. package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
  342. package/build/dist/chunks/{WQ2XTDHO.js → 7X5JVF3F.js} +1 -1
  343. package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
  344. package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
  345. package/build/dist/chunks/AODUTN65.js +1 -0
  346. package/build/dist/chunks/{DBOGRUPS.js → AONO47JX.js} +1 -1
  347. package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
  348. package/build/dist/chunks/AZBTNUXF.js +1 -0
  349. package/build/dist/chunks/{TOIKOIY6.js → B5BU645H.js} +1 -1
  350. package/build/dist/chunks/{ZX43P4BK.js → B75SS7H6.js} +1 -1
  351. package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
  352. package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
  353. package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
  354. package/build/dist/chunks/BM4KHOFB.js +1 -0
  355. package/build/dist/chunks/{N65J3L2H.js → BSV65PCA.js} +1 -1
  356. package/build/dist/chunks/{ZVY7GGSP.js → BW755PNH.js} +1 -1
  357. package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
  358. package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
  359. package/build/dist/chunks/{CNDIAF3P.js → C2H3BWN5.js} +1 -1
  360. package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
  361. package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
  362. package/build/dist/chunks/CJMVRV34.js +1 -0
  363. package/build/dist/chunks/CQPIR6ER.js +1 -0
  364. package/build/dist/chunks/{A4K5GXVO.js → CR7DPGI6.js} +1 -1
  365. package/build/dist/chunks/{UUF4Z6K6.js → CVVNAFUE.js} +1 -1
  366. package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
  367. package/build/dist/chunks/{2PS4GCOZ.js → DJRS3TR5.js} +1 -1
  368. package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
  369. package/build/dist/chunks/{MQXSCNUL.js → DPSFR3ZS.js} +1 -1
  370. package/build/dist/chunks/{LKUZAJPZ.js → DV2HVFTM.js} +1 -1
  371. package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
  372. package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
  373. package/build/dist/chunks/EHQRAA3R.js +1 -0
  374. package/build/dist/chunks/{A4FLWHLP.js → EJIP7RBG.js} +1 -1
  375. package/build/dist/chunks/EWZFZUVF.js +1 -0
  376. package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
  377. package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
  378. package/build/dist/chunks/{O2QBSINK.js → F36IA5RI.js} +1 -1
  379. package/build/dist/chunks/{XTXXWRN2.js → F74ARK4H.js} +1 -1
  380. package/build/dist/chunks/{HPS4KOU4.js → FGGDAAHW.js} +1 -1
  381. package/build/dist/chunks/FMEO7RX7.js +1 -0
  382. package/build/dist/chunks/{FHB7QYJO.js → FN6XY6ET.js} +1 -1
  383. package/build/dist/chunks/G4IX4CYN.js +1 -0
  384. package/build/dist/chunks/G53U6Y4L.js +1 -0
  385. package/build/dist/chunks/{HDBZZOHJ.js → GBIL2I2K.js} +1 -1
  386. package/build/dist/chunks/{MJGEGNDU.js → GCFHKJIO.js} +1 -1
  387. package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
  388. package/build/dist/chunks/GTJ6LBGB.js +1 -0
  389. package/build/dist/chunks/GV6Z3MET.js +1 -0
  390. package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
  391. package/build/dist/chunks/GX2RCAHG.js +1 -0
  392. package/build/dist/chunks/{7TRO6MBQ.js → H5KU4DUU.js} +1 -1
  393. package/build/dist/chunks/H7ZJ7LAB.js +1 -0
  394. package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
  395. package/build/dist/chunks/{6CKCZJ3F.js → HEQBTHFS.js} +1 -1
  396. package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
  397. package/build/dist/chunks/HJI7KO6F.js +1 -0
  398. package/build/dist/chunks/{KO7ANIKY.js → HNBYPHTA.js} +1 -1
  399. package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
  400. package/build/dist/chunks/HPO673QQ.js +1 -0
  401. package/build/dist/chunks/{4IOHSX3Z.js → HRGLFGFL.js} +1 -1
  402. package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
  403. package/build/dist/chunks/IJVBCEA2.js +1 -0
  404. package/build/dist/chunks/{N742W5KX.js → IKVRFAUP.js} +1 -1
  405. package/build/dist/chunks/IM7ZF7XZ.js +1 -0
  406. package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
  407. package/build/dist/chunks/IR7KDBFU.js +1 -0
  408. package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
  409. package/build/dist/chunks/IYOWMW5B.js +1 -0
  410. package/build/dist/chunks/J2J73XYU.js +1 -0
  411. package/build/dist/chunks/JCS24YBB.js +1 -0
  412. package/build/dist/chunks/JQVTHPUO.js +1 -0
  413. package/build/dist/chunks/{USGMGKAG.js → JTWJT2O3.js} +1 -1
  414. package/build/dist/chunks/{W7BFM6CK.js → K4CYAWNL.js} +1 -1
  415. package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
  416. package/build/dist/chunks/K5OXLIPK.js +1 -0
  417. package/build/dist/chunks/{ZKBOPZH5.js → K6GECT3F.js} +1 -1
  418. package/build/dist/chunks/{6LVHN33V.js → KB2JWQZ4.js} +1 -1
  419. package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
  420. package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
  421. package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
  422. package/build/dist/chunks/{JJSCDDQO.js → L3IAEXQR.js} +1 -1
  423. package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
  424. package/build/dist/chunks/{YWVPK3DV.js → L76P6WIH.js} +1 -1
  425. package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
  426. package/build/dist/chunks/LD3A2KLN.js +1 -0
  427. package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
  428. package/build/dist/chunks/{ZQPC54J5.js → LKRAUTYI.js} +1 -1
  429. package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
  430. package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
  431. package/build/dist/chunks/MFQTBUSD.js +1 -0
  432. package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
  433. package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
  434. package/build/dist/chunks/{O4P5IQCP.js → MXI7LX2F.js} +1 -1
  435. package/build/dist/chunks/N6YNJGEF.js +1 -0
  436. package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
  437. package/build/dist/chunks/NUTTPUYJ.js +1 -0
  438. package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
  439. package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
  440. package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
  441. package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
  442. package/build/dist/chunks/{E47UYYK4.js → OIGTTRN5.js} +1 -1
  443. package/build/dist/chunks/{2I7XHRTI.js → P6JE2NRA.js} +1 -1
  444. package/build/dist/chunks/PD5NXIRT.js +1 -0
  445. package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
  446. package/build/dist/chunks/{VREGY7E6.js → PMFR47H3.js} +1 -1
  447. package/build/dist/chunks/{PV7FEVBD.js → PXVF2SHU.js} +1 -1
  448. package/build/dist/chunks/{2FOI2625.js → Q43WPRYU.js} +1 -1
  449. package/build/dist/chunks/QAAKUIWE.js +1 -0
  450. package/build/dist/chunks/{ZXFJKW6H.js → QAVP3CWL.js} +1 -1
  451. package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
  452. package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
  453. package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
  454. package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
  455. package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
  456. package/build/dist/chunks/{ZXRIJG6H.js → QP2B7AYX.js} +1 -1
  457. package/build/dist/chunks/{TJU644I7.js → QZ6V6J6W.js} +1 -1
  458. package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
  459. package/build/dist/chunks/RKJFSDGV.js +1 -0
  460. package/build/dist/chunks/RKS3M7L5.js +1 -0
  461. package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
  462. package/build/dist/chunks/{IZP3EKKS.js → RYEQIZ2H.js} +1 -1
  463. package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
  464. package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
  465. package/build/dist/chunks/{KKTOBXIT.js → SRYX65GZ.js} +1 -1
  466. package/build/dist/chunks/{GKUPC4DO.js → TMENUIBC.js} +1 -1
  467. package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
  468. package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
  469. package/build/dist/chunks/TTBB6EFN.js +1 -0
  470. package/build/dist/chunks/{FRVCSDKU.js → TWVDWNTG.js} +1 -1
  471. package/build/dist/chunks/TZG7HTVM.js +1 -0
  472. package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
  473. package/build/dist/chunks/{G5AMH4IP.js → UGFRBJDQ.js} +1 -1
  474. package/build/dist/chunks/{OB3YMTDI.js → UIVOYAO2.js} +1 -1
  475. package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
  476. package/build/dist/chunks/UNBRUWSV.js +1 -0
  477. package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
  478. package/build/dist/chunks/{TGXEKBLV.js → URTQNYWU.js} +1 -1
  479. package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
  480. package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
  481. package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
  482. package/build/dist/chunks/{LZM3DO5Q.js → W5GWK72I.js} +1 -1
  483. package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
  484. package/build/dist/chunks/{3YH5B5NQ.js → WUONMIA2.js} +1 -1
  485. package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
  486. package/build/dist/chunks/{XADHV2DT.js → X53QVHBC.js} +1 -1
  487. package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
  488. package/build/dist/chunks/XUDQYSPU.js +1 -0
  489. package/build/dist/chunks/{S37D7HOK.js → XWZ5SL5Q.js} +1 -1
  490. package/build/dist/chunks/{NIWAVMDR.js → XXLQDQEX.js} +1 -1
  491. package/build/dist/chunks/{QBNASL3T.js → Y5T36EEU.js} +1 -1
  492. package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
  493. package/build/dist/chunks/ZSGW2ZSO.js +1 -0
  494. package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
  495. package/package.json +1 -1
  496. package/build/dist/chunks/5H7NVE6O.js +0 -1
  497. package/build/dist/chunks/7OOCAZBE.js +0 -1
  498. package/build/dist/chunks/DFM4T6ZE.js +0 -1
  499. package/build/dist/chunks/FCVH4FYH.js +0 -1
  500. package/build/dist/chunks/GDUKZYE2.js +0 -1
  501. package/build/dist/chunks/GYPMUYB5.js +0 -1
  502. package/build/dist/chunks/J7OZLXSG.js +0 -1
  503. package/build/dist/chunks/JFC2QCMW.js +0 -1
  504. package/build/dist/chunks/M6JNGU4E.js +0 -1
  505. package/build/dist/chunks/M7OVMIIE.js +0 -1
  506. package/build/dist/chunks/MQK6OP7S.js +0 -1
  507. package/build/dist/chunks/N624NR7Y.js +0 -1
  508. package/build/dist/chunks/OSMOBKRQ.js +0 -1
  509. package/build/dist/chunks/Q3Q3YHEX.js +0 -1
  510. package/build/dist/chunks/QQD4PV64.js +0 -1
  511. package/build/dist/chunks/RN3WUJIO.js +0 -1
  512. package/build/dist/chunks/RP5VCG54.js +0 -1
  513. package/build/dist/chunks/TI727O2H.js +0 -1
  514. package/build/dist/chunks/UHIJMDD2.js +0 -1
  515. package/build/dist/chunks/W32UECOL.js +0 -1
  516. package/build/dist/chunks/WWNAGOCD.js +0 -1
  517. package/build/dist/chunks/XWC6IC5E.js +0 -1
@@ -1 +1 @@
1
- import{b as L}from"./LCH6F5HT.js";import{h as G,j as x}from"./2GXHYI23.js";import{a as b}from"./43LI5NKJ.js";import{a as N}from"./66F5ZH34.js";import{g as $}from"./NWNYJ26T.js";import{b as P}from"./IX3GZMTM.js";import{b as w,e as R,j as W}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as y,getAddress as E,parseAbi as _}from"viem";var h={address:E("0x451b42a15100c340ca12f7c66de06fac5ea2d751"),symbol:"BOW",decimals:18,chainId:w},c=E("0xeba502e1177f5fad9432c2deb273569d8381e01a"),f={address:W[w].tokens.USDG.address,symbol:"USDG",decimals:R,chainId:w},i=_(["function stakingToken() view returns (address)","function rewardsToken() view returns (address)","function balanceOf(address account) view returns (uint256)","function earned(address account) view returns (uint256)","function stake(uint256 amount)","function withdraw(uint256 amount)","function getReward()","function exit()","function cooldown() view returns (uint256)","function stakedAt(address) view returns (uint256)","function stakePaused() view returns (bool)","function totalSupply() view returns (uint256)","function rewardRate() view returns (uint256)","function rewardsDuration() view returns (uint256)","function periodFinish() view returns (uint256)","function owner() view returns (address)","function rewardsDistribution() view returns (address)","function notifyRewardAmount(uint256 reward)","function setRewardsDistribution(address distribution)","function setRewardsDuration(uint256 duration)","function setCooldown(uint256 cooldown)","function setStakePaused(bool paused)","function recoverERC20(address token,uint256 amount)","function transferOwnership(address newOwner)","function renounceOwnership()"]),tn=l=>{async function U(n){try{return await n()}catch(t){throw new o(l.plainError(t))}}function A(n,t){if(Object.keys(n).some(e=>!t.includes(e)))throw new o("Unsupported Longbow staking input. Use the fields in the tool schema.")}async function T(){let n=l.clientFor(w);if(await n.getChainId()!==w)throw new o("Longbow requires a client on chain 4663.");let[t,e]=await Promise.all([n.readContract({address:c,abi:i,functionName:"stakingToken"}),n.readContract({address:c,abi:i,functionName:"rewardsToken"})]);if(typeof t!="string"||typeof e!="string"||!$(t,h.address)||!$(e,f.address))throw new o("Longbow staking does not report the pinned BOW stake and USDG reward tokens.");return n}async function S(n){let t=await T(),[e,a,s]=await Promise.all([t.readContract({address:c,abi:i,functionName:"balanceOf",args:[n]}),t.readContract({address:c,abi:i,functionName:"earned",args:[n]}),t.readContract({address:h.address,abi:i,functionName:"balanceOf",args:[n]})]);return{staked:e,earned:a,held:s,rpc:t}}async function v(n,t,e){let a=await l.preview(n,t),s=a.changes.map(({token:r,amount:d})=>{let u=d.startsWith("-");return`${u?"-":"+"}${l.formatAmount(u?d.slice(1):d,r.decimals)} ${r.symbol}`}).join(", ");return{txs:n,preview:a,summary:`${e} ${a.summary} ${s?`Estimated changes: ${s}. `:""}No transaction was sent.`}}let O=(n,t)=>l.unsignedTx({to:c,data:n,value:"0",chainId:w,description:t}),g=n=>l.formatAmount(n.toString(),h.decimals);async function I(n,t){if(A(n,["amount"]),b(t),typeof n.amount!="string")throw new o("Provide an integer BOW amount in base units (18 decimals).");let e=P(n.amount),{held:a,rpc:s}=await S(t),[r,d]=await Promise.all([s.readContract({address:c,abi:i,functionName:"cooldown"}),s.readContract({address:c,abi:i,functionName:"stakePaused"})]);if(d)throw new o("Longbow new stakes are paused; withdrawals and claims remain available.");if(e<=0n)throw new o("Stake amount must be positive.");if(e>a)throw new o(`Insufficient BOW: wallet holds ${a.toString()} base units, requested ${e.toString()}.`);return v([l.approval(h.address,c,e.toString(),w),O(y({abi:i,functionName:"stake",args:[e]}),`Stake ${g(e)} BOW in Longbow StakingRewards.`)],t,`Approve exactly ${g(e)} BOW, then stake it for USDG rewards. Current withdrawal cooldown: ${r} seconds; staking restarts that clock.`)}async function F(n,t){A(n,["amount"]),b(t);let{staked:e,earned:a,rpc:s}=await S(t),r=await s.readContract({address:c,abi:i,functionName:"cooldown"});if(r>0n){let[u,p]=await Promise.all([s.readContract({address:c,abi:i,functionName:"stakedAt",args:[t]}),s.getBlock()]);if(p.timestamp<u+r)throw new o(`Longbow unstaking cooldown ends at Unix second ${u+r}. Rewards can still be claimed.`)}if(e===0n)throw new o("This wallet has no BOW staked with Longbow.");if(n.amount==="all")return v([O(y({abi:i,functionName:"exit"}),`Unstake all ${g(e)} BOW and claim USDG rewards.`)],t,`Exit Longbow staking: return all ${g(e)} staked BOW and claim ${l.formatAmount(a.toString(),f.decimals)} USDG of earned rewards in one call.`);if(typeof n.amount!="string")throw new o('Provide an integer BOW amount in base units, or "all".');let d=P(n.amount);if(d<=0n||d>e)throw new o(`Unstake amount must be positive and at most the ${e.toString()} base units staked.`);return v([O(y({abi:i,functionName:"withdraw",args:[d]}),`Unstake ${g(d)} BOW.`)],t,`Unstake ${g(d)} BOW. Earned USDG rewards stay claimable with longbow_claim_rewards.`)}async function j(n,t){A(n,[]),b(t);let{earned:e}=await S(t);if(e===0n)throw new o("No Longbow staking rewards to claim for this wallet.");let a=l.formatAmount(e.toString(),f.decimals);return v([O(y({abi:i,functionName:"getReward"}),`Claim ${a} USDG of Longbow staking rewards.`)],t,`Claim ${a} USDG of earned Longbow staking rewards; staked BOW stays staked.`)}async function q(n){return U(async()=>{b(n);let{staked:t,earned:e}=await S(n);return t===0n&&e===0n?[]:[{module:"longbow",id:`${w}:${c.toLowerCase()}`,chainId:w,assets:[...t>0n?[{token:{...h},amount:t.toString()}]:[],...e>0n?[{token:{...f},amount:e.toString()}]:[]],economics:{principal:t>0n?[G("locked",{token:{...h},amount:t.toString(),source:"longbow.staking.staked"})]:[],debt:[],rewards:e>0n?[x("claimable",{token:{...f},amount:e.toString(),source:"longbow.staking.earned",claim:{tool:"longbow_claim_rewards",args:{}}})]:[],backing:[],coverage:{complete:!0}},description:`Longbow BOW staking: ${g(t)} BOW staked, ${l.formatAmount(e.toString(),f.decimals)} USDG rewards earned and claimable.`}]})}let D=(n,t,e,a)=>({name:n,inputSchema:{type:"object",properties:t,required:e,additionalProperties:!1},execute:(s,r)=>U(()=>a(s,r))});async function M(n,t){A(n,[]),b(t);let{staked:e,earned:a,held:s,rpc:r}=await S(t),d=["cooldown","stakePaused","totalSupply","rewardRate","rewardsDuration","periodFinish","owner","rewardsDistribution"],u=await Promise.all(d.map(m=>r.readContract({address:c,abi:i,functionName:m}))),p=await r.readContract({address:c,abi:i,functionName:"stakedAt",args:[t]});return{chainId:w,staking:c,stakeToken:h,rewardToken:f,staked:e.toString(),earned:a.toString(),walletBalance:s.toString(),stakedAt:p.toString(),...Object.fromEntries(d.map((m,k)=>[m,typeof u[k]=="bigint"?u[k].toString():u[k]])),rewardRateScale:"1000000000000000000",caveat:"rewardRate is USDG base units multiplied by 1e18 per second, not APY. Cooldown and pause state are owner-configurable."}}let C=[["notifyRewardAmount",["uint256"]],["setRewardsDistribution",["address"]],["setRewardsDuration",["uint256"]],["setCooldown",["uint256"]],["setStakePaused",["bool"]],["recoverERC20",["address","uint256"]],["transferOwnership",["address"]],["renounceOwnership",[]]];async function H(n,t){A(n,["operation","values","fund"]),b(t);let e=C.find(([m])=>m===n.operation);if(!e||!Array.isArray(n.values)||n.values.length!==e[1].length)throw new o("Choose a staking operation and its exact ordered values.");let a=e[1].map((m,k)=>L(m,n.values[k])),s=await T(),r=e[0]==="notifyRewardAmount",d=await s.readContract({address:c,abi:i,functionName:r?"rewardsDistribution":"owner"});if(!$(d,t))throw new o("This wallet lacks the Longbow staking owner/distribution role.");if(n.fund!==void 0&&(typeof n.fund!="boolean"||!r))throw new o("fund is a boolean available only for notifyRewardAmount.");let u=`Longbow staking ${e[0]}, values ${JSON.stringify(n.values)}.${e[0]==="renounceOwnership"?" Owner administration is permanently relinquished.":""}`,p=[];if(r&&n.fund===!0){let m=a[0];if(m===0n)throw new o("Reward funding must be positive.");let k=_(["function transfer(address,uint256) returns (bool)"]);p.push(l.unsignedTx({to:f.address,data:y({abi:k,functionName:"transfer",args:[c,m]}),value:"0",chainId:w,description:`Fund exactly ${m} USDG base units before notifying rewards.`}))}return p.push(O(y({abi:i,functionName:e[0],args:a}),u)),v(p,t,`${u} ${n.fund===!0?"Funding and notification are separate transactions. A failed notification leaves funded USDG in the staking contract.":""}`)}let B=N('Positive amount of BOW in base units (BOW has 18 decimals). Example: "1000000000000000000" = 1 BOW.');return{positions:q,tools:[D("longbow_staking_status",{},[],M),D("longbow_manage_staking",{operation:{enum:C.map(([n])=>n),description:"Owner or rewards-distributor call on the staking contract. notifyRewardAmount needs the distributor role; the others need the owner. Amounts are USDG base units (6 decimals)."},values:{type:"array",maxItems:2,description:"Ordered arguments for the operation: uint256 as decimal strings, addresses as 0x strings, bool as true/false. Empty list for renounceOwnership. recoverERC20 takes token address then amount.",items:{oneOf:[{type:"string"},{type:"boolean"}]}},fund:{type:"boolean",description:"Only for notifyRewardAmount: true first transfers that much USDG from this wallet to the staking contract, then notifies. Default false."}},["operation","values"],H),D("longbow_stake",{amount:B},["amount"],I),D("longbow_unstake",{amount:{description:'Amount of BOW to unstake in base units (BOW has 18 decimals). Example: "1000000000000000000" = 1 BOW. Use "all" to exit fully and claim rewards.',anyOf:[B,{const:"all",description:"Unstake everything and claim rewards in one exit() call."}]}},["amount"],F),D("longbow_claim_rewards",{},[],j)]}};export{h as a,c as b,tn as c};
1
+ import{b as L}from"./342OZP53.js";import{h as G,j as x}from"./2GXHYI23.js";import{a as b}from"./43LI5NKJ.js";import{a as N}from"./66F5ZH34.js";import{g as $}from"./NWNYJ26T.js";import{b as P}from"./IX3GZMTM.js";import{b as w,e as R,j as W}from"./EWZFZUVF.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as y,getAddress as E,parseAbi as _}from"viem";var h={address:E("0x451b42a15100c340ca12f7c66de06fac5ea2d751"),symbol:"BOW",decimals:18,chainId:w},c=E("0xeba502e1177f5fad9432c2deb273569d8381e01a"),f={address:W[w].tokens.USDG.address,symbol:"USDG",decimals:R,chainId:w},i=_(["function stakingToken() view returns (address)","function rewardsToken() view returns (address)","function balanceOf(address account) view returns (uint256)","function earned(address account) view returns (uint256)","function stake(uint256 amount)","function withdraw(uint256 amount)","function getReward()","function exit()","function cooldown() view returns (uint256)","function stakedAt(address) view returns (uint256)","function stakePaused() view returns (bool)","function totalSupply() view returns (uint256)","function rewardRate() view returns (uint256)","function rewardsDuration() view returns (uint256)","function periodFinish() view returns (uint256)","function owner() view returns (address)","function rewardsDistribution() view returns (address)","function notifyRewardAmount(uint256 reward)","function setRewardsDistribution(address distribution)","function setRewardsDuration(uint256 duration)","function setCooldown(uint256 cooldown)","function setStakePaused(bool paused)","function recoverERC20(address token,uint256 amount)","function transferOwnership(address newOwner)","function renounceOwnership()"]),tn=l=>{async function U(n){try{return await n()}catch(t){throw new o(l.plainError(t))}}function A(n,t){if(Object.keys(n).some(e=>!t.includes(e)))throw new o("Unsupported Longbow staking input. Use the fields in the tool schema.")}async function T(){let n=l.clientFor(w);if(await n.getChainId()!==w)throw new o("Longbow requires a client on chain 4663.");let[t,e]=await Promise.all([n.readContract({address:c,abi:i,functionName:"stakingToken"}),n.readContract({address:c,abi:i,functionName:"rewardsToken"})]);if(typeof t!="string"||typeof e!="string"||!$(t,h.address)||!$(e,f.address))throw new o("Longbow staking does not report the pinned BOW stake and USDG reward tokens.");return n}async function S(n){let t=await T(),[e,a,s]=await Promise.all([t.readContract({address:c,abi:i,functionName:"balanceOf",args:[n]}),t.readContract({address:c,abi:i,functionName:"earned",args:[n]}),t.readContract({address:h.address,abi:i,functionName:"balanceOf",args:[n]})]);return{staked:e,earned:a,held:s,rpc:t}}async function v(n,t,e){let a=await l.preview(n,t),s=a.changes.map(({token:r,amount:d})=>{let u=d.startsWith("-");return`${u?"-":"+"}${l.formatAmount(u?d.slice(1):d,r.decimals)} ${r.symbol}`}).join(", ");return{txs:n,preview:a,summary:`${e} ${a.summary} ${s?`Estimated changes: ${s}. `:""}No transaction was sent.`}}let O=(n,t)=>l.unsignedTx({to:c,data:n,value:"0",chainId:w,description:t}),g=n=>l.formatAmount(n.toString(),h.decimals);async function I(n,t){if(A(n,["amount"]),b(t),typeof n.amount!="string")throw new o("Provide an integer BOW amount in base units (18 decimals).");let e=P(n.amount),{held:a,rpc:s}=await S(t),[r,d]=await Promise.all([s.readContract({address:c,abi:i,functionName:"cooldown"}),s.readContract({address:c,abi:i,functionName:"stakePaused"})]);if(d)throw new o("Longbow new stakes are paused; withdrawals and claims remain available.");if(e<=0n)throw new o("Stake amount must be positive.");if(e>a)throw new o(`Insufficient BOW: wallet holds ${a.toString()} base units, requested ${e.toString()}.`);return v([l.approval(h.address,c,e.toString(),w),O(y({abi:i,functionName:"stake",args:[e]}),`Stake ${g(e)} BOW in Longbow StakingRewards.`)],t,`Approve exactly ${g(e)} BOW, then stake it for USDG rewards. Current withdrawal cooldown: ${r} seconds; staking restarts that clock.`)}async function F(n,t){A(n,["amount"]),b(t);let{staked:e,earned:a,rpc:s}=await S(t),r=await s.readContract({address:c,abi:i,functionName:"cooldown"});if(r>0n){let[u,p]=await Promise.all([s.readContract({address:c,abi:i,functionName:"stakedAt",args:[t]}),s.getBlock()]);if(p.timestamp<u+r)throw new o(`Longbow unstaking cooldown ends at Unix second ${u+r}. Rewards can still be claimed.`)}if(e===0n)throw new o("This wallet has no BOW staked with Longbow.");if(n.amount==="all")return v([O(y({abi:i,functionName:"exit"}),`Unstake all ${g(e)} BOW and claim USDG rewards.`)],t,`Exit Longbow staking: return all ${g(e)} staked BOW and claim ${l.formatAmount(a.toString(),f.decimals)} USDG of earned rewards in one call.`);if(typeof n.amount!="string")throw new o('Provide an integer BOW amount in base units, or "all".');let d=P(n.amount);if(d<=0n||d>e)throw new o(`Unstake amount must be positive and at most the ${e.toString()} base units staked.`);return v([O(y({abi:i,functionName:"withdraw",args:[d]}),`Unstake ${g(d)} BOW.`)],t,`Unstake ${g(d)} BOW. Earned USDG rewards stay claimable with longbow_claim_rewards.`)}async function j(n,t){A(n,[]),b(t);let{earned:e}=await S(t);if(e===0n)throw new o("No Longbow staking rewards to claim for this wallet.");let a=l.formatAmount(e.toString(),f.decimals);return v([O(y({abi:i,functionName:"getReward"}),`Claim ${a} USDG of Longbow staking rewards.`)],t,`Claim ${a} USDG of earned Longbow staking rewards; staked BOW stays staked.`)}async function q(n){return U(async()=>{b(n);let{staked:t,earned:e}=await S(n);return t===0n&&e===0n?[]:[{module:"longbow",id:`${w}:${c.toLowerCase()}`,chainId:w,assets:[...t>0n?[{token:{...h},amount:t.toString()}]:[],...e>0n?[{token:{...f},amount:e.toString()}]:[]],economics:{principal:t>0n?[G("locked",{token:{...h},amount:t.toString(),source:"longbow.staking.staked"})]:[],debt:[],rewards:e>0n?[x("claimable",{token:{...f},amount:e.toString(),source:"longbow.staking.earned",claim:{tool:"longbow_claim_rewards",args:{}}})]:[],backing:[],coverage:{complete:!0}},description:`Longbow BOW staking: ${g(t)} BOW staked, ${l.formatAmount(e.toString(),f.decimals)} USDG rewards earned and claimable.`}]})}let D=(n,t,e,a)=>({name:n,inputSchema:{type:"object",properties:t,required:e,additionalProperties:!1},execute:(s,r)=>U(()=>a(s,r))});async function M(n,t){A(n,[]),b(t);let{staked:e,earned:a,held:s,rpc:r}=await S(t),d=["cooldown","stakePaused","totalSupply","rewardRate","rewardsDuration","periodFinish","owner","rewardsDistribution"],u=await Promise.all(d.map(m=>r.readContract({address:c,abi:i,functionName:m}))),p=await r.readContract({address:c,abi:i,functionName:"stakedAt",args:[t]});return{chainId:w,staking:c,stakeToken:h,rewardToken:f,staked:e.toString(),earned:a.toString(),walletBalance:s.toString(),stakedAt:p.toString(),...Object.fromEntries(d.map((m,k)=>[m,typeof u[k]=="bigint"?u[k].toString():u[k]])),rewardRateScale:"1000000000000000000",caveat:"rewardRate is USDG base units multiplied by 1e18 per second, not APY. Cooldown and pause state are owner-configurable."}}let C=[["notifyRewardAmount",["uint256"]],["setRewardsDistribution",["address"]],["setRewardsDuration",["uint256"]],["setCooldown",["uint256"]],["setStakePaused",["bool"]],["recoverERC20",["address","uint256"]],["transferOwnership",["address"]],["renounceOwnership",[]]];async function H(n,t){A(n,["operation","values","fund"]),b(t);let e=C.find(([m])=>m===n.operation);if(!e||!Array.isArray(n.values)||n.values.length!==e[1].length)throw new o("Choose a staking operation and its exact ordered values.");let a=e[1].map((m,k)=>L(m,n.values[k])),s=await T(),r=e[0]==="notifyRewardAmount",d=await s.readContract({address:c,abi:i,functionName:r?"rewardsDistribution":"owner"});if(!$(d,t))throw new o("This wallet lacks the Longbow staking owner/distribution role.");if(n.fund!==void 0&&(typeof n.fund!="boolean"||!r))throw new o("fund is a boolean available only for notifyRewardAmount.");let u=`Longbow staking ${e[0]}, values ${JSON.stringify(n.values)}.${e[0]==="renounceOwnership"?" Owner administration is permanently relinquished.":""}`,p=[];if(r&&n.fund===!0){let m=a[0];if(m===0n)throw new o("Reward funding must be positive.");let k=_(["function transfer(address,uint256) returns (bool)"]);p.push(l.unsignedTx({to:f.address,data:y({abi:k,functionName:"transfer",args:[c,m]}),value:"0",chainId:w,description:`Fund exactly ${m} USDG base units before notifying rewards.`}))}return p.push(O(y({abi:i,functionName:e[0],args:a}),u)),v(p,t,`${u} ${n.fund===!0?"Funding and notification are separate transactions. A failed notification leaves funded USDG in the staking contract.":""}`)}let B=N('Positive amount of BOW in base units (BOW has 18 decimals). Example: "1000000000000000000" = 1 BOW.');return{positions:q,tools:[D("longbow_staking_status",{},[],M),D("longbow_manage_staking",{operation:{enum:C.map(([n])=>n),description:"Owner or rewards-distributor call on the staking contract. notifyRewardAmount needs the distributor role; the others need the owner. Amounts are USDG base units (6 decimals)."},values:{type:"array",maxItems:2,description:"Ordered arguments for the operation: uint256 as decimal strings, addresses as 0x strings, bool as true/false. Empty list for renounceOwnership. recoverERC20 takes token address then amount.",items:{oneOf:[{type:"string"},{type:"boolean"}]}},fund:{type:"boolean",description:"Only for notifyRewardAmount: true first transfers that much USDG from this wallet to the staking contract, then notifies. Default false."}},["operation","values"],H),D("longbow_stake",{amount:B},["amount"],I),D("longbow_unstake",{amount:{description:'Amount of BOW to unstake in base units (BOW has 18 decimals). Example: "1000000000000000000" = 1 BOW. Use "all" to exit fully and claim rewards.',anyOf:[B,{const:"all",description:"Unstake everything and claim rewards in one exit() call."}]}},["amount"],F),D("longbow_claim_rewards",{},[],j)]}};export{h as a,c as b,tn as c};
@@ -0,0 +1 @@
1
+ import{a as pe}from"./HC3QFA5I.js";import{c as Te}from"./QFUSCK5C.js";import{a as q}from"./B75SS7H6.js";import{a as F,b as M}from"./7WXAS54T.js";import{a as J,b as be}from"./CFPJDLTZ.js";import{a as L}from"./5N6YJFFA.js";import{a as ye}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as ke,c as he}from"./SCG5HWMN.js";import{a as ue,b as Y,c as Q}from"./5HCXZWUH.js";import{q as me,s as P,t as fe}from"./EZUQMTLE.js";import{b as w,c as $,d as K,e as de,j as U,k as le,t as D}from"./EWZFZUVF.js";import{a as b}from"./XSD5NL7J.js";import{a as g,b as Z,c as z}from"./JXOEJPJ4.js";import{decodeFunctionResult as Be,encodeFunctionData as Ue,erc20Abi as ee,getAddress as T,isAddress as X,parseAbi as j}from"viem";var te="https://api.robinhood.com/rhj/assets",Fe={address:F,symbol:"ETH",decimals:18,chainId:w},ne={address:T(le),symbol:"USDG",decimals:de,chainId:w},se={address:T(U[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},Ie={address:T(U[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w},ce=[{address:T(J.chop),symbol:"CHOP",decimals:18,chainId:w},{address:T(J.oakLog.address),symbol:"chOAK",decimals:18,chainId:w},{address:T(be),symbol:"schOAK",decimals:18,chainId:w}],H=(e,n)=>ce.find(s=>s.chainId===n&&s.address.toLowerCase()===e.toLowerCase());function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var $e="ASSET_STATUS_ACTIVE",we="TRADING_STATUS_UNTRADABLE";function Ke(e){if(e.status!==void 0&&e.status!==$e)return`the issuer lists it as ${typeof e.status=="string"&&/^[A-Z_]{1,64}$/.test(e.status)?e.status:"not active"}`;if(!B(e.tradingCapabilities))return;let n=Object.values(e.tradingCapabilities).filter(B);return n.length>0&&n.every(s=>s.whole===we&&s.fractional===we)?"the issuer lists it as untradable in every session":void 0}function He(e,n,s){if(!B(e))return[];let t=e;if(typeof t.tokenSymbol!="string"||!t.tokenSymbol.trim())return[];if(!Array.isArray(t.deployments))return[];if(t.deployments.length>100)throw new b("Official stock deployment list exceeds the lookup limit.");let a=t.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(a))throw new b(`Invalid official stock ticker ${g(a)}.`);if(t.tokenDecimals!==void 0&&(typeof t.tokenDecimals!="number"||!Number.isInteger(t.tokenDecimals)||t.tokenDecimals<0||t.tokenDecimals>255))throw new b("Official stock asset has invalid token decimals.");let r=typeof t.tokenDecimals=="number"?t.tokenDecimals:18,o=Ke(t),c=[];for(let i of t.deployments){if(!B(i))continue;let d=i;if(d.chainId===n){if(typeof d.contractAddress!="string"||!X(d.contractAddress,{strict:!1}))throw new b("Official stock deployment has an invalid contract address.");c.push({address:T(d.contractAddress),symbol:a,decimals:r,chainId:n,...s.includeNames&&typeof t.tokenName=="string"&&t.tokenName.trim()?{name:t.tokenName.trim()}:{},...o?{notTradable:o}:{}})}}return c}function W(e,n=w,s={}){let t=Array.isArray(e)?e:B(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!t)throw new b("Official stock asset list response is malformed.");let a=new Map,r=new Map;if(t.length>1e4)throw new b("Official stock asset list exceeds the lookup limit.");for(let o of t){let c;try{c=He(o,n,s)}catch{continue}for(let i of c){let d=i.address.toLowerCase(),m=i.symbol.toUpperCase(),l=r.get(m);if(!s.allowAmbiguousSymbols&&l&&l!==d)throw new b(`Ambiguous official stock ticker ${g(i.symbol)} across multiple addresses.`);let u=a.get(d);if(u&&(u.symbol!==i.symbol||u.decimals!==i.decimals))throw new b(`Conflicting official stock identity at ${i.address}.`);r.set(m,d),a.set(d,u?.notTradable&&!i.notTradable?{...i,notTradable:u.notTradable}:i)}}return[...a.values()]}function We(e,n){if(typeof e.address!="string"||!X(e.address,{strict:!1}))return!1;let s=e.chainId??w,t=e.address.toLowerCase();return n.some(a=>a.chainId===s&&a.address.toLowerCase()===t&&a.symbol===e.symbol)}function V(e,n){x(e.address);let s=e.chainId??w,t=T(e.address),a=t.toLowerCase(),r=N(e.symbol),o=n.find(i=>i.chainId===s&&i.address.toLowerCase()===a),c=n.find(i=>i.chainId===s&&N(i.symbol)===r);if(o){if(e.symbol!==o.symbol)throw new b(`Token at ${t} does not match official stock ticker ${g(o.symbol)} (received ${g(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==o.decimals)throw new b(`Token ${g(o.symbol)} at ${t} does not match official decimals ${o.decimals}.`);return o}if(c)throw new b(`Token symbol ${g(e.symbol)} at ${t} does not match the official stock contract address ${c.address}.`);return{address:t,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var Ge=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],oe=new WeakMap,ge=new WeakMap,Le=3e4,Ae=Object.freeze([]),E;function bt(){if(!E)return Ae;let e=Date.now()-E.started;return e>=0&&e<Le?E.tokens:Ae}var ae=new WeakMap;function G(e,n){return(ae.get(e)??P)(n)}async function De(e){let n=e?.http??ke(),s=e?.url??te,t=e?.chainId??w,a=Q(n),r=ge.get(a);r||(r=new ue(Le),ge.set(a,r));let{value:o,started:c}=await G(n,()=>r.read(`${t}:${s}`,async()=>{let d=await P(l=>he(a,s,{method:"GET",signal:l},u=>B(u)||Array.isArray(u))),m=W(d,t,{allowAmbiguousSymbols:!0});if(t===w&&m.length===0)throw new b("Official stock asset list has no mainnet deployments; retry when the list is available.");return d})),i=W(o,t,e);if(t===w&&s===te&&(!E||c>=E.started||Date.now()<E.started)&&(E={started:c,tokens:Object.freeze(W(o,t,{allowAmbiguousSymbols:!0}).map(d=>Object.freeze(d)))}),t===w){let d=oe.get(a);d||(d=new Set,oe.set(a,d));for(let m of i)d.add(N(m.symbol))}return i}var Ve=j(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function Se(e){let n=e,s=new Set;for(;n&&typeof n=="object"&&!s.has(n)&&s.size<10;){s.add(n);let t=n;if(t.name==="ContractFunctionZeroDataError"||t.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof t.shortMessage=="string"?t.shortMessage:""} ${typeof t.message=="string"?t.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;n=t.cause}return!1}function Xe(e){return e instanceof b?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function je(e,n,s){if(typeof e.getCode=="function")try{let t=await e.getCode({address:n});return!t||t==="0x"}catch{return Se(s)}return Se(s)}async function re(e,n,s){if(n.length===0)return[];let t=await Promise.allSettled(n.map(a=>e.readContract({address:a.address,abi:ee,functionName:"balanceOf",args:[s]})));if(t.every(a=>a.status==="rejected")&&t[0]?.status==="rejected"&&Xe(t[0].reason))throw t[0].reason;return t.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let r=typeof a.value=="bigint"?a.value:BigInt(a.value);return r>=0n?{ok:!0,amount:r}:{ok:!1}}catch{return{ok:!1}}})}async function Pe(e,n,s,t){if(s.length===0)return[];let a=me(n,e);if(!a)return re(e,s,t);let r=s.map(c=>({target:c.address,allowFailure:!0,callData:Ue({abi:ee,functionName:"balanceOf",args:[t]})})),o;try{o=await e.readContract({address:a,abi:Ve,functionName:"aggregate3",args:[r]})}catch(c){if(await je(e,a,c))return re(e,s,t);throw c}if(!Array.isArray(o)||o.length!==s.length)throw new b("Multicall3 aggregate3 returned an invalid result list.");return o.map(c=>{let i=c,d=Array.isArray(i)?i[0]:i?.success,m=Array.isArray(i)?i[1]:i?.returnData;if(!d||typeof m!="string"||m==="0x")return{ok:!1};try{let l=Be({abi:ee,functionName:"balanceOf",data:m}),u=typeof l=="bigint"?l:BigInt(l);return u>=0n?{ok:!0,amount:u}:{ok:!1}}catch{return{ok:!1}}})}async function yt(e,n={}){x(e);let s=T(e),t=n.chainId??w,a=n.client??fe(n.rpcUrl,t),r=[],o;if(n.stockTokens)r=[...n.stockTokens];else if(n.stockAssetsPayload!==void 0)r=W(n.stockAssetsPayload,t,{allowAmbiguousSymbols:!0});else if(n.includeStockTokens!==!1&&t!==$)try{r=await De({http:n.http,url:n.stockAssetsUrl,chainId:t,allowAmbiguousSymbols:!0})}catch(f){if(n.tokens)throw f;o="Stock token balances are unavailable right now: Oak could not read the official stock list. ETH and the other tokens shown are current. Stock tokens are missing from this list, not zero; ask for balances again shortly."}if(n.tokens)for(let f of n.tokens)V(f,r);let c=t===w?[ne,se,Ie,...n.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:T(n.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:K,chainId:t}]:[]]:t===$?[{...ne,address:T(D.testnet.usdg),chainId:t},{...se,address:T(D.testnet.weth),chainId:t},...n.oakTokenAddress?[{address:T(n.oakTokenAddress),symbol:"OAK",decimals:K,chainId:t}]:[]]:[],i=t===w&&n.includePoolTokens!==!1?[...ce,...ye.vaults.flatMap(f=>[{address:T(f.tokenAddress),symbol:T(f.tokenAddress),decimals:f.tokenDecimals,chainId:t},{address:T(f.earnContractAddress),symbol:T(f.earnContractAddress),decimals:18,chainId:t}])]:[],d=new Set(i.map(f=>f.address.toLowerCase())),m=[],l=new Set;for(let f of[...c,...r,...n.tokens??[],...i]){if(f.chainId!==t||M(f.address)===F)continue;let y=H(f.address,t)??V(f,r),A=y.address.toLowerCase();l.has(A)||(l.add(A),m.push(y))}let[u,p]=await Promise.all([a.getBalance({address:s}),Pe(a,t,m,s)]),S=[],k={address:F,symbol:"ETH",decimals:18,chainId:t};(u>0n||n.includeZero)&&S.push({token:k,amount:u.toString()});for(let f=0;f<m.length;f++){let y=m[f],A=c.some(O=>v(O.address,y.address))||r.some(O=>v(O.address,y.address))||H(y.address,t)?y.symbol:g(y.symbol),C=p[f]??{ok:!1};if(!C.ok){S.push({token:{address:y.address,symbol:A,decimals:y.decimals,chainId:y.chainId},amount:"unavailable"});continue}let I=C.amount;if(I>0n&&d.has(y.address.toLowerCase())&&!H(y.address,t))try{let[O,R]=await Promise.all([L(a,t,y.address,"symbol"),L(a,t,y.address,"decimals")]);A=g(O),y.decimals=R}catch{}(I>0n||n.includeZero)&&S.push({token:{address:y.address,symbol:A,decimals:y.decimals,chainId:y.chainId},amount:I.toString()})}let h="Outside token discovery is disabled; no receipt time window was scanned, so only ETH, pinned tokens and official stock tokens are listed here.";if(n.includeReceivedTokens===!0){let f=await Ze(s,{client:a});h=f.notice;try{let y=f.addresses.filter(C=>!l.has(C.toLowerCase())),A=await Ye(s,y,{client:a,chainId:t});S.push(...A.map(({token:C,amount:I,note:O})=>({token:C,amount:I,verified:!1,note:`Received from outside Oak's lists; not verified.${O?` ${O}`:""}`}))),h+=ze(A)}catch{h+=" Discovery is incomplete: outside balances or token metadata are unavailable; known balances are retained."}}return S.length||S.push({token:k,amount:u.toString()}),S[0]={...S[0],discoveryNotice:h,...o?{stockNotice:o}:{}},S}var _=200;async function Ze(e,n){x(e);let s,t,a="the last 10,000 blocks (approximately 17 minutes at 100 ms per block; UTC boundaries unavailable)",r=()=>`Outside token discovery covers only ERC-20 receipts in ${a}; older holdings may be missing.`;try{if(t=await P(()=>n.client.getBlockNumber({cacheTime:0}),3e3),s=t>9999n?t-9999n:0n,typeof n.client.getBlock=="function")try{let l=await Promise.all([s,t].map(u=>P(()=>n.client.getBlock({blockNumber:u}),3e3)));a=`blocks ${s}\u2013${t}, from ${new Date(Number(l[0].timestamp)*1e3).toISOString()} to ${new Date(Number(l[1].timestamp)*1e3).toISOString()} (UTC)`}catch{}let o=j(["event Transfer(address indexed from,address indexed to,uint256 value)"])[0],i=(await P(()=>n.client.getLogs({event:o,args:{to:T(e)},fromBlock:s,toBlock:t,strict:!0}),3e3)).filter(l=>!l.removed&&typeof l.args.value=="bigint"&&l.args.value>0n);i.every(l=>typeof l.blockNumber=="bigint")&&i.sort((l,u)=>l.blockNumber<u.blockNumber?-1:l.blockNumber>u.blockNumber?1:Number(l.logIndex??0)-Number(u.logIndex??0));let d=new Set;for(let l of i){let u=T(l.address);d.delete(u),d.add(u)}let m=[...d];return m.length>_?{addresses:m.slice(-_),fromBlock:s,toBlock:t,incomplete:!0,notice:`${r()} Discovery is incomplete: more than ${_} token contracts sent to this wallet in that window, so only the ${_} most recent are checked.`}:{addresses:m,fromBlock:s,toBlock:t,incomplete:!1,notice:r()}}catch{return{addresses:[],fromBlock:s,toBlock:t,incomplete:!0,notice:`${r()} Discovery is incomplete: RPC receipt reads are unavailable; known balances are retained. Retry balances when RPC logs are available.`}}}function ze(e){let n=e.filter(s=>s.unreadable).length;return n?n===1?" 1 token's symbol or decimals could not be read; its note says what is missing.":` ${n} tokens' symbols or decimals could not be read; their notes say what is missing.`:""}async function Ye(e,n,s){if(x(e),n.length>1e4)throw new b("Journal token discovery exceeds the balance lookup limit.");let t=[...new Set(n.map(o=>(x(o),T(o))))].filter(o=>M(o)!==F).map(o=>({address:o,symbol:o,decimals:0,chainId:s.chainId})),a=[];for(let o=0;o<t.length;o+=_){let c=t.slice(o,o+_);try{a.push(...await Pe(s.client,s.chainId,c,T(e)))}catch{a.push(...await re(s.client,c,T(e)))}}let r=t.flatMap((o,c)=>{let i=a[c];return i.ok&&i.amount===0n?[]:[{token:o,amount:i.ok?i.amount.toString():"unavailable"}]});return Promise.all(r.map(async({token:o,amount:c})=>{let i=H(o.address,s.chainId);if(i)return{token:{...i},amount:c};let[d,m]=await Promise.all([L(s.client,s.chainId,o.address,"symbol").catch(()=>{}),L(s.client,s.chainId,o.address,"decimals").catch(()=>{})]);if(d!==void 0&&m!==void 0)return{token:{...o,symbol:g(d),decimals:m},amount:c};let l=[...d===void 0?["symbol"]:[],...m===void 0?["decimals"]:[]],u=l.length===2?"This token's symbol and decimals could not be read. It is shown by its contract address, and the amount is in raw base units.":d===void 0?"This token's symbol could not be read. It is shown by its contract address.":"This token's decimals could not be read. The amount is in raw base units.";return{token:{...o,symbol:d===void 0?o.address:g(d),decimals:m??0},amount:c,unreadable:l,note:u}}))}var v=(e,n)=>e.toLowerCase()===n.toLowerCase(),N=e=>z(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,""),Ce=e=>z(e.normalize("NFKC")).toLowerCase().match(/[\p{L}\p{N}]+/gu)?.join(" ")??"";function Ee(e){let n=e.context.network??"mainnet",{chainId:s,usdg:t,weth:a}=D[n],r=(o,c,i)=>({...o,address:M(T(o.address)),name:c,kind:i,verified:!0,source:"Oak fixed addresses",warnings:[]});return[r({...Fe,chainId:s},"Ether","native"),r({...ne,address:t,chainId:s},"Global Dollar","stablecoin"),r({...se,address:a,chainId:s},"Wrapped Ether","wrapped"),...n==="mainnet"?[r(Ie,"USDe","stablecoin")]:[],...n==="mainnet"?ce.map(o=>r(o,o.symbol==="CHOP"?"Chop":o.symbol==="chOAK"?"Chop OAK log":"Chop OAK staked LP",o.symbol==="CHOP"?"erc20":"wrapped")):[],...e.oakTokenAddress?[r({address:e.oakTokenAddress,symbol:"OAK",decimals:K,chainId:s},"Oak","oak")]:[]]}async function Re(e){if(e.context.network==="testnet")return[];let n=e.officialStockTokens??await De({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return n.filter(s=>We(s,n)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:te,warnings:[],identityNote:"Official Robinhood stock token: this address matches Robinhood's published list. The quoted name is text from that list."}))}async function ie(e,n,s=!0){let{chainId:t}=D[n.context.network??"mainnet"],a=n.context.clientFor(t);if(await a.getChainId()!==t)throw new b(`Token lookup requires Robinhood Chain ${t}.`);let[r,o,c]=await Promise.all([G(a,()=>L(a,t,e,"name",n.blockNumber)).catch(i=>{if(s)throw i;return""}),G(a,()=>L(a,t,e,"symbol",n.blockNumber)),G(a,()=>L(a,t,e,"decimals",n.blockNumber))]);if(typeof r!="string"||s&&!r.trim()||typeof o!="string"||!o.trim()||!Number.isInteger(c)||c<0||c>255)throw new b("The contract returned invalid token metadata.");return{address:T(e),name:r||o,symbol:o,decimals:c,chainId:t}}async function Oe(e,n){let s=await n.context.clientFor(w).readContract({address:U[w].clanker.factory.address,abi:j(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&v(s[0],e)}async function Qe(e,n){let s=n.context.clientFor(w),t=U[w].poolsTrade,a=[t.instantLaunchStrategyFeesOn.address,t.instantLaunchStrategyFeesOff.address],r=j(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],o=await s.getBlockNumber(),c=new Set,i=0,d=0;for(let m=63127652n;m<=o;m+=10000000n){if(++i>xe)throw new b("Token origin scan limit reached.");let l=m+9999999n>o?o:m+9999999n,u=await s.getLogs({address:a,event:r,args:{token:e},fromBlock:m,toBlock:l,strict:!0});for(let p of u){if(p.removed||!a.some(k=>v(k,p.address))||!p.args.token||!v(p.args.token,e)||!p.transactionHash||c.has(p.transactionHash))continue;if(c.add(p.transactionHash),++d>20)throw new b("Token origin receipt limit reached.");let S=await s.getTransactionReceipt({hash:p.transactionHash});if(pe(S).some(k=>v(k.token,e)))return T(S.from)}}}var xe=5,Je=100,qe=500,et=3e4;function Me(e){let n=Date.now()+et,s=0,t=new Map,a=o=>{let c=n-Date.now();if(c<=0)throw new b("Token lookup time budget reached; results are partial.");return P(o,Math.min(1e4,c))},r=Y((o,c)=>a(async i=>{let d=await e.context.http(o,{...c,signal:i});return new Proxy(d,{get(m,l){if(l==="json")return()=>a(()=>m.json());let u=Reflect.get(m,l,m);return typeof u=="function"?u.bind(m):u}})}),e.context.http);return ae.set(r,a),{...e,context:{...e.context,http:r,clientFor:o=>{if(!t.has(o)){let c=e.context.clientFor(o),i=d=>{if(++s>qe)throw new b("Token lookup RPC budget reached; results are partial.");return a(d)};t.set(o,Y(new Proxy(c,{get(d,m){let l=Reflect.get(d,m);return typeof l!="function"?l:(...u)=>i(()=>l.apply(d,u))}}),c)),ae.set(t.get(o),i)}return t.get(o)}}}}function Ne(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:g(e.symbol),name:g(e.name)}}async function Tt(e,n){if(n=Me(n),typeof e!="string"||e.length>256||!N(e))throw new b("Provide a token name, symbol or address to find_token.");let s=N(e),t=X(e.trim(),{strict:!1})?M(T(e.trim())):void 0,{chainId:a}=D[n.context.network??"mainnet"],r=[],o=Ee(n),c=!1;try{o.push(...await Re(n))}catch{c=!0,r.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let i=k=>t?v(k.address,t):N(k.symbol).includes(s)||N(k.name).includes(s),d=o.filter(i),m=[],l=(k,h)=>[k.symbol,k.name??""].some(f=>[h.symbol,h.name].some(y=>{let A=N(f),C=N(y),I=Ce(f),O=Ce(y);return!!A&&!!C&&(A===C||(C.length>=3?A.includes(C):` ${I} `.includes(` ${O} `)))})),u=(k,h={})=>{if(m.some(A=>v(A.address,k.address)))return;let f=[`Token ${g(k.symbol)} at ${k.address} is an unverified ${h.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(Z(k.symbol)||Z(k.name)||o.some(A=>!v(A.address,k.address)&&l(k,A)))&&f.push(`Lookalike warning: ${g(k.symbol)} at ${k.address} resembles a verified token's name or symbol.`);let y={...k,...h,kind:h.launchpad?"launchpad":"erc20",verified:!1,source:h.launchpad?`${h.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:f};m.push(y),r.push(...f)};if(t&&!d.length){let k=await ie(t,n),h={};if(a===w){try{await Oe(t,n)&&(h.launchpad="clanker")}catch{r.push("Clanker origin lookup was unavailable for this address.")}if(h.launchpad==="clanker")try{let y=(await q(n.context,{q:t,limit:20})).tokens.find(A=>v(A.contract_address,t));y&&(h.creator=T(y.msg_sender),h.creatorSource="Clanker indexer msg_sender")}catch{r.push("Clanker creator lookup is unavailable.")}else try{let f=await Te(n.context,t);h.launchpad="pons",h.creator=T(f.creator),h.creatorSource="Pons factory deployer"}catch{r.push("Pons launch origin could not be confirmed for this address.")}if(!h.launchpad)try{let f=await Qe(t,n);f&&(h.launchpad="pools.trade",h.creator=f,h.creatorSource="Launch transaction sender; may be a relayer")}catch{c=!0,r.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}u(k,h)}else if(!t&&a===w){let k=new Set,h=new Set,f,y=0,A=0;try{do{if(++y>xe)throw new b("Token search page limit reached.");let C=await q(n.context,{q:e.trim(),limit:20,...f?{cursor:f}:{}});for(let I of C.tokens){if(++A>Je)throw new b("Token candidate limit reached.");let O=T(I.contract_address);if(!(h.has(O)||o.some(R=>v(R.address,O)))){h.add(O);try{let R=await ie(O,n);if(!i(R))continue;let _e=await Oe(O,n)?{launchpad:"clanker",creator:T(I.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};u(R,_e)}catch{c=!0,r.push(`Could not read Clanker candidate ${O}; it was omitted from these partial results.`)}}}if(C.cursor&&k.has(C.cursor))throw new b("The Clanker indexer repeated a pagination cursor.");C.cursor&&k.add(C.cursor),f=C.cursor??void 0}while(f)}catch{c=!0,r.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}r.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===$&&r.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let p=k=>[...new Map(k.map(h=>[h.address.toLowerCase(),h])).values()],S=p([...d,...m]);for(let k of S)if(S.some(h=>!v(h.address,k.address)&&(N(k.symbol)===N(h.symbol)||N(k.name)===N(h.name)))){let h=`Duplicate warning: several tokens share the symbol or name of ${k.address}. Choose the intended address; do not guess from the name.`;k.warnings.push(h),r.push(h)}return d.length>1&&r.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:g(e.trim()),chainId:a,partial:c,matches:p(d).map(Ne),unverified:p(m).map(Ne),warnings:r}}var ve=e=>`${g(e.symbol)} is not tradable right now: ${e.notTradable}. Oak will not quote it; a balance you hold still shows and can still be sent.`;async function pt(e,n){if(typeof e!="string"||!e.trim())throw new b("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new b("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,t=X(s,{strict:!1})?M(T(s)):void 0,a=Ee(n),r=t&&a.find(u=>v(u.address,t));if(r)return r;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),c=!t&&a.find(u=>u.symbol.toUpperCase()===o),i=[],d=!1;try{i=await Re(n)}catch{if(c)return c;if(!t)throw new b("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");d=!0}if(t){let u=i.find(k=>v(k.address,t));if(u){if(u.notTradable)throw new b(ve(u));return n.tokenMetadata&&V(n.tokenMetadata,i),{...u,name:g(u.name)}}let p=n.tokenMetadata??await n.readMetadata?.(t);if(p&&(!v(p.address,t)||p.chainId!==D[n.context.network??"mainnet"].chainId))throw new b("Token metadata does not match the requested address and chain.");if(p&&(typeof p.symbol!="string"||!p.symbol.trim()||!Number.isInteger(p.decimals)||p.decimals<0||p.decimals>255))throw new b("The contract returned invalid token metadata.");let S=p?{...p,name:p.symbol}:await ie(t,Me(n),!1);if(d){let k=N(S.symbol),h=oe.get(Q(n.context.http));if(Ge.some(f=>N(f)===k)||h?.has(k))throw new b("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return V(S,i),{...S,symbol:g(S.symbol),name:g(S.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...d?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let m=[...a,...i].filter(u=>u.symbol.toUpperCase()===o);if(m.length!==1)throw new b(`Token symbol ${g(s)} is ${m.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let l=m[0];if(l.kind==="official_stock"&&s!==l.symbol)throw new b(`Use the exact official stock ticker ${g(l.symbol)}; case variants are refused.`);if(l.notTradable)throw new b(ve(l));return l.source==="Oak fixed addresses"?l:{...l,name:g(l.name)}}export{te as a,Fe as b,ne as c,se as d,Ie as e,ce as f,W as g,We as h,V as i,bt as j,De as k,Ve as l,yt as m,Ze as n,ze as o,Ye as p,Tt as q,pt as r};
@@ -0,0 +1 @@
1
+ import{a as F}from"./G2LAO23N.js";import{c as A,d as _,e as S}from"./HRGLFGFL.js";import{d as j,e as U,g as K}from"./LD3A2KLN.js";import{a as f}from"./66F5ZH34.js";import{c as l,f as q,g as d,i as L}from"./NWNYJ26T.js";import{b as v}from"./EWZFZUVF.js";import{a as i}from"./XSD5NL7J.js";import{decodeEventLog as ce,encodeAbiParameters as de,encodeFunctionData as ue,getAddress as pe,hashStruct as me,isHex as le,keccak256 as ye,parseAbi as fe,parseAbiParameters as ge,zeroAddress as m}from"viem";var he="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",O=fe(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",he,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),ke={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},we=ge("(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)"),be=pe("0x000000000022D473030F116dDEE9F6B43aC78BA3"),R={key:{type:"object",description:"Uniswap v4 PoolKey of the pool to swap in.",properties:{currency0:{...l,description:"Lower-sorted pool token address; the zero address is native ETH, which cannot be the relay input."},currency1:{...l,description:"Higher-sorted pool token address; must be greater than currency0."},fee:{type:"integer",description:F.pips()},tickSpacing:{type:"integer",description:"Pool tick spacing, a positive integer."},hooks:{...l,description:"Address of the pool hook contract."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean",description:"True swaps currency0 for currency1 (input is currency0); false swaps currency1 for currency0."},amountSpecified:{type:"string",pattern:"^-?[0-9]+$",description:'Signed amount in base units: negative = exact input of the input token, positive = exact output of the output token. Example: "-1000000" = 1 USDG in, if USDG (6 decimals) is the input.'},amountBound:{...f(),description:"Slippage bound in base units: minimum output token if amountSpecified is negative, maximum input token if positive. Must be nonzero; read that token's decimals."},sqrtPriceLimitX96:{...f(),description:"Swap price limit as a Q64.96 sqrt price, decimal string."},recipient:{...l,description:F.recipient("account that receives the swap output")},relayer:{...l,description:"Address of the relayer allowed to submit this intent (must be the submitting wallet), or the zero address for an open relay with no fee."},relayerFee:{...f(),description:"Fee paid to the relayer in base units of the fee token (the input token if charged on input, else the output token); read its decimals. Must be 0 for an open relay."},engagement:{...l,description:"Address of the Hookr engagement contract for campaign credit, or the zero address when campaigns is empty."},campaigns:{type:"array",items:f(),maxItems:8,description:"Up to eight campaign IDs (decimal strings) to credit; empty when engagement is the zero address."},nonce:{...f(),description:"Unique Permit2-style intent nonce of the trader, a decimal string; each nonce can execute once."},deadline:{...f(),description:"Intent expiry as a Unix seconds timestamp; the relay fails after this time."}},T={owner:{...l,description:F.recipient("trader who signed the intent and supplies the input funds")},signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$",description:"The trader's Permit2 witness signature over the intent, as 0x-prefixed hex."},intent:{type:"object",description:"The complete trader-signed Hookr swap intent.",properties:R,required:Object.keys(R),additionalProperties:!1}};function C(r){return q(r,"Provide a complete trader-signed Hookr intent.")}function g(r,o=256,e=!1){if(typeof r!="string"||!/^-?\d+$/.test(r)||r.length>79)throw new i("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let n=BigInt(r);if(e?n<=-(1n<<BigInt(o-1))||n>=1n<<BigInt(o-1):n<0n||n>=1n<<BigInt(o))throw new i("Hookr intent integer is outside its ABI range.");return n}function h(r){return L(r,"Provide valid Hookr intent addresses.")}function G(r,o){if(Object.keys(r).some(s=>!Object.hasOwn(T,s)))throw new i("Provide only owner, intent and the trader signature for Hookr relay.");let e=C(r.intent);if(Object.keys(e).some(s=>!Object.hasOwn(R,s)))throw new i("Hookr intent contains an undocumented field.");let n=C(e.key);if(Object.keys(n).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof n.fee!="number"||!Number.isInteger(n.fee)||n.fee<0||n.fee>16777215||typeof n.tickSpacing!="number"||!Number.isInteger(n.tickSpacing)||n.tickSpacing<=0||n.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new i("Provide a valid canonical v4 pool key and direction.");let a={currency0:h(n.currency0),currency1:h(n.currency1),fee:n.fee,tickSpacing:n.tickSpacing,hooks:h(n.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new i("Hookr pool currencies must sort strictly by address.");let t=h(r.owner);if(t===m||d(t,o))throw new i("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new i("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:g(e.amountSpecified,128,!0),amountBound:g(e.amountBound,128),sqrtPriceLimitX96:g(e.sqrtPriceLimitX96,160),recipient:h(e.recipient),relayer:h(e.relayer),relayerFee:g(e.relayerFee),engagement:h(e.engagement),campaigns:e.campaigns.map(s=>g(s)),nonce:g(e.nonce),deadline:g(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new i("Hookr intent input/output amounts and bound must be nonzero.");if([m,S,A].some(s=>d(s,c.recipient)))throw new i("Hookr intent recipient is reserved.");if(c.relayer!==m&&!d(c.relayer,o)||c.relayer===m&&c.relayerFee!==0n)throw new i("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===m!=(c.campaigns.length===0))throw new i("Hookr engagement and campaigns must be supplied together.");let k=c.zeroForOne?a.currency0:a.currency1;if(k===m)throw new i("Hookr Permit2 relay cannot pull native ETH input.");if(typeof r.signature!="string"||!le(r.signature,{strict:!0})||r.signature.length<4||r.signature.length%2!==0||r.signature.length>16386)throw new i("Provide the trader-signed Permit2 witness signature, never a private key.");let x=r.signature,y=me({data:c,primaryType:"HookrSwapIntent",types:ke});return{owner:t,intent:c,signature:x,input:k,intentHash:y}}function M(r,o){let{owner:e,intent:n,signature:a}=G(r,o);return{chainId:v,to:S,value:"0",data:ue({abi:O,functionName:"execute",args:[n,e,a]}),description:`Relay Hookr trader ${e} to recipient ${n.recipient}; relayer fee ${n.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function Ae(r,o,e){let n=M(o,e);if(r.length!==1||r[0].chainId!==n.chainId||!d(r[0].to,n.to)||r[0].value!=="0"||!d(r[0].data,n.data))throw new i("Hookr relay calldata differs from the locally requested signed intent.")}function Re(r){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:T,required:Object.keys(T),additionalProperties:!1},execute:async(o,e)=>{let n=G(o,e),{owner:a,intent:t,signature:c,input:k,intentHash:x}=n,y=r.clientFor(v),s=await y.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>t.deadline)throw new i("Hookr signed intent expired or the chain timestamp is unavailable.");let w=(ae,se=[])=>y.readContract({address:S,abi:O,functionName:ae,args:se,blockNumber:s.number}),[W,u,X,J,Q,V]=await Promise.all([w("hashIntent",[t]),w("pullOf",[t]),w("isNonceUsed",[a,t.nonce]),w("router"),w("registry"),w("permit2")]);if(W!==x||X!==!1||J!==A||Q!==_||V!==be)throw new i("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(u)||u.length!==3||typeof u[0]!="string"||!d(u[0],k)||typeof u[1]!="bigint"||typeof u[2]!="boolean")throw new i("Hookr Permit2 pull could not be verified.");let b=u[2],E=t.amountSpecified<0n?-t.amountSpecified:t.amountBound;if(u[1]!==E+(b?t.relayerFee:0n)||t.amountSpecified>0n&&!b&&t.relayerFee>t.amountSpecified)throw new i("Hookr Permit2 pull or output-side fee differs from the signed terms.");let Y=await y.simulateContract({address:S,abi:O,functionName:"execute",args:[t,a,c],account:e,blockNumber:s.number}),[$,B]=Y.result,D=t.amountSpecified<0n?t.amountBound:t.amountSpecified-(b?0n:t.relayerFee);if($>E||B<D)throw new i("Hookr relay simulation did not satisfy the signed input/output bounds.");let Z=ye(de(we,[t.key])),ee=await U(r,Z,s.number),I=M(o,e),te=await y.estimateGas({account:e,to:I.to,data:I.data,value:0n,blockNumber:s.number}),ne=j(te,ee),H=b?k:t.zeroForOne?t.key.currency1:t.key.currency0,p=await K(y,ne,d(H,m)?t.relayerFee:void 0),N=d(H,m)?"ETH":`token ${H}`,z=`${t.relayerFee} base units ${N}`,re=`Relayer fee ${z}; gas limit ${p.gasLimit}, gas ceiling at current gas price ${p.gasCostEth} ETH; ${p.netWei===null?`net unknown because the reward is denominated in ${N} while gas is ETH`:`net ${p.netWei} wei (${p.netWei} base units ETH)`}. Fee is paid only on success; someone may get there first.`,ie={summary:`${I.description} Relayer fee ${z}; gas limit ${p.gasLimit}. Fee is paid only on success; someone may get there first.`,rewardWei:d(H,m)?t.relayerFee.toString():null,facts:{intentHash:x,feeToken:H,relayerFee:t.relayerFee.toString(),feeFromInput:b,gasLimit:p.gasLimit}},P=[{...r.unsignedTx({...I,description:`${I.description} ${re}`}),gasLimit:p.gasLimit}],oe=await r.preview(P,e);return{txs:P,preview:oe,summary:P[0].description,consent:ie,intentHash:x,owner:a,recipient:t.recipient,relayer:e,inputToken:k,maximumPull:u[1].toString(),feeToken:H,relayerFee:t.relayerFee.toString(),feeFromInput:b,minimumOutput:D.toString(),simulatedAmountIn:$.toString(),simulatedAmountOut:B.toString(),gas:p,note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hash of the mined relay transaction: 32 bytes, 0x followed by 64 hex digits."}},required:["transactionHash"],additionalProperties:!1},execute:async o=>{if(Object.keys(o).some(a=>a!=="transactionHash")||typeof o.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o.transactionHash))throw new i("Provide a Hookr relay transactionHash.");let e=await r.clientFor(v).getTransactionReceipt({hash:o.transactionHash});if(e.status!=="success")throw new i("Hookr relay reverted. No fee is proven paid.");let n=e.logs.filter(a=>d(a.address,S)).flatMap(a=>{try{let t=ce({abi:O,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...t.args,amountIn:t.args.amountIn.toString(),amountOut:t.args.amountOut.toString(),relayerFee:t.args.relayerFee.toString()}]}catch{return[]}});if(!n.length)throw new i("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:v,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:n,note:"Event evidence at this mined block; check balances and finality."}}}]}export{O as a,G as b,M as c,Ae as d,Re as e};
@@ -1 +1 @@
1
- import{a as F,c as y,d as b,f as h,g as N}from"./SK2VBNAU.js";import{g as p}from"./NWNYJ26T.js";import{b as M,j as O,k as _}from"./TI727O2H.js";import{a as A}from"./XSD5NL7J.js";import{getAddress as U,isAddress as W}from"viem";var j=O[M].pendle.marketFactory.address,q=O[M].pendle.router.address,J=600,Q=/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/,X=/^(usd.*|dai|w?eth|oak)$/i,ee=t=>X.test(t.replace(/[._-]/g,"")),te=/^PT-(.+)-\d{1,2}[A-Za-z]{3}\d{4}$/,s=t=>{throw new A(`${t} Oak won't use this market.`)},r=()=>s("Oak couldn't read this Pendle market from the chain.");function S(t){return typeof t!="number"||!Number.isInteger(t)||t<0||t>36?s("A token in this market reports unusual decimals."):t}function $(t){return!Array.isArray(t)||t.some(e=>typeof e!="string"||!W(e,{strict:!1}))?r():[...new Set(t.map(e=>U(e)))]}async function B(t,e,c={}){let g=c.now??Math.floor(Date.now()/1e3),[u,o,a,f,l,E,D,P,x,I,v]=await N(t,[{address:j,abi:F,functionName:"isValidMarket",args:[e.market]},{address:e.market,abi:y,functionName:"readTokens"},{address:e.market,abi:y,functionName:"expiry"},{address:e.market,abi:y,functionName:"isExpired"},{address:e.market,abi:y,functionName:"readState",args:[q]},{address:e.sy,abi:b,functionName:"getTokensIn"},{address:e.sy,abi:b,functionName:"getTokensOut"},{address:e.sy,abi:b,functionName:"decimals"},{address:e.sy,abi:b,functionName:"exchangeRate"},{address:e.pt,abi:h,functionName:"decimals"},{address:e.pt,abi:h,functionName:"symbol"}]);if(!u.ok)return r();if(u.value!==!0)return s("This isn't a market the Pendle factory created.");if(!o.ok||!Array.isArray(o.value)||o.value.length!==3)return r();let[z,Y,Z]=o.value;if(!p(z,e.sy)||!p(Y,e.pt)||!p(Z,e.yt))return s("The market's tokens don't match what Pendle's service listed.");if(!a.ok||typeof a.value!="bigint"||!f.ok||typeof f.value!="boolean")return r();if(a.value!==BigInt(e.expiry))return s("The market's end date doesn't match what Pendle's service listed.");let T=f.value;if(T!==g>=e.expiry&&Math.abs(g-e.expiry)>J)return s("The chain and Oak's clock disagree about whether this market has ended.");if(!l.ok||typeof l.value?.lastLnImpliedRate!="bigint"||!P.ok||!I.ok||!x.ok||typeof x.value!="bigint"||!v.ok||typeof v.value!="string"||!E.ok||!D.ok)return r();let i=$(E.value),V=$(D.value);if(i.length===0||V.length===0)return s("This market lists no token to put in or take out.");let H=S(P.value),G=S(I.value),R=i.find(n=>p(n,_)),L=await N(t,i.flatMap(n=>[{address:n,abi:h,functionName:"symbol"},{address:n,abi:h,functionName:"decimals"}])),w=new Map(i.map((n,k)=>[n,{symbol:L[k*2],decimals:L[k*2+1]}])),m;if(R)m=R;else if(i.length===1)m=i[0];else{let n=te.exec(v.value)?.[1],k=i.filter(K=>{let C=w.get(K).symbol;return C.ok&&C.value===n});k.length===1&&(m=k[0])}if(!m)return s("Oak can't tell which token this market takes as input.");let d=w.get(m);return!d.symbol.ok||typeof d.symbol.value!="string"||!d.decimals.ok?r():!Q.test(d.symbol.value)||!R&&ee(d.symbol.value)?s("The market's token name looks unusual."):{verified:{market:e.market,sy:e.sy,pt:e.pt,yt:e.yt,expiry:e.expiry,expired:T,kind:R?"stable":"stock",inputToken:m,inputSymbol:d.symbol.value,inputDecimals:S(d.decimals.value),ptDecimals:G,syDecimals:H,tokensIn:i,tokensOut:V},ptSymbol:v.value,lnImpliedRate:l.value.lastLnImpliedRate,syExchangeRate:x.value}}async function oe(t,e,c={}){return(await B(t,e,c)).verified}async function de(t,e,c={}){let g=await Promise.allSettled(e.map(a=>B(t,a,c))),u=[],o=[];return g.forEach((a,f)=>{let l=e[f];a.status==="fulfilled"?u.push({row:l,facts:a.value}):o.push(`${l.market}: ${a.reason instanceof A?a.reason.message:"Oak couldn't check this market."}`)}),{ok:u,dropped:o}}export{B as a,oe as b,de as c};
1
+ import{a as F,c as y,d as b,f as h,g as N}from"./SK2VBNAU.js";import{g as p}from"./NWNYJ26T.js";import{b as M,j as O,k as _}from"./EWZFZUVF.js";import{a as A}from"./XSD5NL7J.js";import{getAddress as U,isAddress as W}from"viem";var j=O[M].pendle.marketFactory.address,q=O[M].pendle.router.address,J=600,Q=/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/,X=/^(usd.*|dai|w?eth|oak)$/i,ee=t=>X.test(t.replace(/[._-]/g,"")),te=/^PT-(.+)-\d{1,2}[A-Za-z]{3}\d{4}$/,s=t=>{throw new A(`${t} Oak won't use this market.`)},r=()=>s("Oak couldn't read this Pendle market from the chain.");function S(t){return typeof t!="number"||!Number.isInteger(t)||t<0||t>36?s("A token in this market reports unusual decimals."):t}function $(t){return!Array.isArray(t)||t.some(e=>typeof e!="string"||!W(e,{strict:!1}))?r():[...new Set(t.map(e=>U(e)))]}async function B(t,e,c={}){let g=c.now??Math.floor(Date.now()/1e3),[u,o,a,f,l,E,D,P,x,I,v]=await N(t,[{address:j,abi:F,functionName:"isValidMarket",args:[e.market]},{address:e.market,abi:y,functionName:"readTokens"},{address:e.market,abi:y,functionName:"expiry"},{address:e.market,abi:y,functionName:"isExpired"},{address:e.market,abi:y,functionName:"readState",args:[q]},{address:e.sy,abi:b,functionName:"getTokensIn"},{address:e.sy,abi:b,functionName:"getTokensOut"},{address:e.sy,abi:b,functionName:"decimals"},{address:e.sy,abi:b,functionName:"exchangeRate"},{address:e.pt,abi:h,functionName:"decimals"},{address:e.pt,abi:h,functionName:"symbol"}]);if(!u.ok)return r();if(u.value!==!0)return s("This isn't a market the Pendle factory created.");if(!o.ok||!Array.isArray(o.value)||o.value.length!==3)return r();let[z,Y,Z]=o.value;if(!p(z,e.sy)||!p(Y,e.pt)||!p(Z,e.yt))return s("The market's tokens don't match what Pendle's service listed.");if(!a.ok||typeof a.value!="bigint"||!f.ok||typeof f.value!="boolean")return r();if(a.value!==BigInt(e.expiry))return s("The market's end date doesn't match what Pendle's service listed.");let T=f.value;if(T!==g>=e.expiry&&Math.abs(g-e.expiry)>J)return s("The chain and Oak's clock disagree about whether this market has ended.");if(!l.ok||typeof l.value?.lastLnImpliedRate!="bigint"||!P.ok||!I.ok||!x.ok||typeof x.value!="bigint"||!v.ok||typeof v.value!="string"||!E.ok||!D.ok)return r();let i=$(E.value),V=$(D.value);if(i.length===0||V.length===0)return s("This market lists no token to put in or take out.");let H=S(P.value),G=S(I.value),R=i.find(n=>p(n,_)),L=await N(t,i.flatMap(n=>[{address:n,abi:h,functionName:"symbol"},{address:n,abi:h,functionName:"decimals"}])),w=new Map(i.map((n,k)=>[n,{symbol:L[k*2],decimals:L[k*2+1]}])),m;if(R)m=R;else if(i.length===1)m=i[0];else{let n=te.exec(v.value)?.[1],k=i.filter(K=>{let C=w.get(K).symbol;return C.ok&&C.value===n});k.length===1&&(m=k[0])}if(!m)return s("Oak can't tell which token this market takes as input.");let d=w.get(m);return!d.symbol.ok||typeof d.symbol.value!="string"||!d.decimals.ok?r():!Q.test(d.symbol.value)||!R&&ee(d.symbol.value)?s("The market's token name looks unusual."):{verified:{market:e.market,sy:e.sy,pt:e.pt,yt:e.yt,expiry:e.expiry,expired:T,kind:R?"stable":"stock",inputToken:m,inputSymbol:d.symbol.value,inputDecimals:S(d.decimals.value),ptDecimals:G,syDecimals:H,tokensIn:i,tokensOut:V},ptSymbol:v.value,lnImpliedRate:l.value.lastLnImpliedRate,syExchangeRate:x.value}}async function oe(t,e,c={}){return(await B(t,e,c)).verified}async function de(t,e,c={}){let g=await Promise.allSettled(e.map(a=>B(t,a,c))),u=[],o=[];return g.forEach((a,f)=>{let l=e[f];a.status==="fulfilled"?u.push({row:l,facts:a.value}):o.push(`${l.market}: ${a.reason instanceof A?a.reason.message:"Oak couldn't check this market."}`)}),{ok:u,dropped:o}}export{B as a,oe as b,de as c};
@@ -0,0 +1 @@
1
+ import{e as a,f as c}from"./UMY6SP7C.js";import{a as s}from"./XSD5NL7J.js";import{decodeAbiParameters as p,encodeAbiParameters as f}from"viem";var g="LP fees only, using the pinned new HookrToken lots; no record-mode or arbitrary outflow.",u=[{type:"uint32"},{type:"uint128"}];function m(o){let t=a(o,["top","floor","horizon","unit","curve"],["top","floor","horizon","unit","curve"]),e=Number(c(t.top,8)),r=Number(c(t.floor,8)),i=Number(c(t.horizon,8)),n=Number(c(t.unit,8)),l=Number(c(t.curve,8));if(e<1||e>100||r>=e||n>1||(n===0?i<1||i>63:i<3||i>30)||l>2)throw new s("Exit Clock needs top 1\u2013100, floor below top, horizon 1\u201363 for unit 0 or 3\u201330 for unit 1, and curve 0\u20132.");return{top:e,floor:r,horizon:i,unit:n,curve:l}}function d(o){let t=m(o),e=1<<30|1<<20,r=BigInt(t.top)<<19n|BigInt(t.floor)<<26n|BigInt(t.horizon)<<33n|BigInt(t.unit)<<39n|BigInt(t.curve)<<40n;return f(u,[e,r])}function h(o){if(o.length!==130)throw new s("Exit Clock needs exactly two ABI words.");let[t,e]=p(u,o),r=m({top:String(e>>19n&127n),floor:String(e>>26n&127n),horizon:String(e>>33n&63n),unit:String(e>>39n&1n),curve:String(e>>40n&3n)});if(t!==(1<<30|1<<20)||d(Object.fromEntries(Object.entries(r).map(([i,n])=>[i,String(n)]))).toLowerCase()!==o.toLowerCase())throw new s("Exit Clock words are not canonical isolated LP-fee settings.");return r}function w(o,t){let e=d(t),[r,i]=p(u,e),n=(1n<<26n)-1n<<19n;if((o.potEveryNBuys&1<<20)!==0||(o.potMinBuyQuote&n)!==0n)throw new s("Exit Clock settings already occupy these fields.");return{...o,potEveryNBuys:o.potEveryNBuys|r,potMinBuyQuote:o.potMinBuyQuote|i}}function b(o,t){let e=o.potEveryNBuys,r=o.potMinBuyQuote;if(!(e&1<<20)||(r>>42n&7n)!==0n)throw new s("Exit Clock LP-fee settings are not active.");let i=r&(1n<<26n)-1n<<19n,n=h(f(u,[1<<30|1<<20,i]));return`Exit Clock: sells pay up to ${n.top*10} bps, falling to ${n.floor*10} bps over ${n.horizon} ${n.unit?"days":"hours"} (curve ${n.curve}). For the pinned new HookrToken, authenticated wallet sales use the fresh lot age and aged-bag floor; unknown routers or contract payers pay the top. The surcharge is clipped to available LP fee room. Hookr ${t} receives floor(charged pips * ${o.protocolShareBps}/10000) in quote; in-range LPs receive the remainder as LP fee. A mixed-age sale may reject partial fills.`}export{g as a,d as b,h as c,w as d,b as e};
@@ -0,0 +1 @@
1
+ import{e as h,f as b,h as I,i as k,k as $,p as y,q as C,s as R}from"./UMY6SP7C.js";import{a as s}from"./XSD5NL7J.js";import{bytesToHex as O,decodeAbiParameters as F,encodeAbiParameters as m,hexToBytes as U,sha256 as E,zeroAddress as N}from"viem";import{keccak256 as _,parseAbi as z}from"viem";var J="Zap Source requires its own advisory and a factory-created route vault; this launch uses the advisory slot for the agent gate.",B=[{type:"tuple",components:[{name:"takePips",type:"uint24"},{name:"vault",type:"address"}]}],H={id:"zap-source",address:"0xA3d07234F6Ecb7012b8f46F277E9BaDae6e55bAD",minGas:15e4};function Z(t){h(t,["takePips","vault"],["takePips","vault"]);let e=Number(b(t.takePips,24)),a=k(t.vault);if(e<1||e>1e5||a===N)throw new s("Zap Source requires a nonzero vault and a buy cut of 1\u2013100000 pips.");return m(B,[{takePips:e,vault:a}])}function j(t){let[e]=F(B,t);if(Z({takePips:String(e.takePips),vault:e.vault}).toLowerCase()!==t.toLowerCase())throw new s("Non-canonical Zap Source terms; session tiers are not supported.");return e}function D(t){let e=j(t);return`Zap Source: ${e.takePips} pips of gross buyer quote is credited as a Rules claim to vault ${e.vault}. The vault's immutable route controls the target buy, protocol share, caller bounty, timing and custody; those terms must be verified separately.`}var V={factory:[1518],poolManager:[70,1230,1945,3114,4382,7843,10323,12312,12365],rules:[1020,3621,3969,7980,9345],router:[122,708,4782,5484],root:[841,8417,8912,11572],gate:[2792,9035,11662],sink:[1450,5206],quote:[965,1751,3921,7503,7925,9286,9836],subject:[1092,4662,7131,10268],targetId:[2674,2998,4349,6694,7810,8871,10359,11612],mode:[4257,7015],impactBps:[2615,4531,12205],rewardBps:[2735,3836],threshold:[4058,6892,8064],maxPerZap:[1308,4123],windowBlocks:[1694,8743],windowScope:[784,11512],protocolShareBps:[6448,6954],protocolRecipient:[1819,7465],tickLower:[2098,2932,3475,10470],tickUpper:[2141,2894,3562,10511],currency0:[2297,8256],currency1:[2343,8293],fee:[8337],tickSpacing:[8376],quoteIsCurrency0:[4472,10401,12170,13590]};function K(t,e,a,d,n){if(!t||t.length!==2+e*2||!/^0x[0-9a-fA-F]+$/.test(t))throw new s("Hookr instance runtime length is incorrect.");let o=U(t);for(let[u,i]of Object.entries(d)){let l=n[u];if(!l||!/^0x[0-9a-fA-F]{64}$/.test(l))throw new s(`Missing immutable ${u}.`);for(let c of i){if(O(o.slice(c,c+32)).toLowerCase()!==l.toLowerCase())throw new s(`Hookr instance immutable ${u} differs from the requested terms.`);o.fill(0,c,c+32)}}if(E(o).toLowerCase()!==a.toLowerCase())throw new s("Hookr instance runtime does not match the pinned compiler output.")}var M={address:H.address,codeHash:"0x1c0dc634a1092cfae32474be9082583e6a94c61a49390e2bd9dfef2152dfff83",schemaHash:"0x15db6c3ca0a513c3e391f86babd70b212f39ba62eaeb11f13bd505dad632ae34",phaseMask:1,feeOnly:!0,gasMin:15e4},g=["factory","poolManager","rules","router","root","gate","sink","quote","subject"],S={mode:8,impactBps:16,rewardBps:16,threshold:128,maxPerZap:128,windowBlocks:32,windowScope:8,protocolShareBps:16},v=[...g,"targetId",...Object.keys(S),"protocolRecipient","tickLower","tickUpper","currency0","currency1","fee","tickSpacing","quoteIsCurrency0"],L=[...[...g,"protocolRecipient"].map(t=>({type:"function",name:t,stateMutability:"view",inputs:[],outputs:[{type:"address"}]})),...Object.entries({...S,tickLower:24,tickUpper:24}).map(([t,e])=>({type:"function",name:t,stateMutability:"view",inputs:[],outputs:[{type:`${t.startsWith("tick")?"int":"uint"}${e}`}]})),{type:"function",name:"targetId",stateMutability:"view",inputs:[],outputs:[{type:"bytes32"}]},{type:"function",name:"targetKey",stateMutability:"view",inputs:[],outputs:[{type:"tuple",components:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}]}]},{type:"function",name:"routeLive",stateMutability:"view",inputs:[],outputs:[{type:"bool"}]}],W=z(["function vaultRecord(address) view returns (bool exists,bytes32 target,address gate)"]);function P(t){if(typeof t!="string"||!/^(0|-?[1-9][0-9]*)$/.test(t))throw new s("Provide a signed decimal int24 string.");let e=BigInt(t);if(e<-8388608n||e>8388607n)throw new s("Provide a signed decimal int24 string.");return e}async function G(t,e,a,d){let n=h(d,v,v),o={};for(let r of[...g,"protocolRecipient","currency0","currency1"])o[r]=k(n[r]);o.targetId=I(n.targetId);for(let[r,f]of Object.entries(S))o[r]=b(n[r],f);if(o.tickLower=P(n.tickLower),o.tickUpper=P(n.tickUpper),o.tickSpacing=P(n.tickSpacing),o.fee=b(n.fee,24),typeof n.quoteIsCurrency0!="boolean")throw new s("Provide quoteIsCurrency0 as a boolean.");o.quoteIsCurrency0=n.quoteIsCurrency0;let u=k(H.address),i=[...g,"targetId",...Object.keys(S),"protocolRecipient","tickLower","tickUpper"],[l,c,p,w,x,...T]=await Promise.all([t.getCode({address:a,blockNumber:e}),t.getCode({address:u,blockNumber:e}),y(t,u,W,"vaultRecord",[a],e),y(t,a,L,"targetKey",[],e),y(t,a,L,"routeLive",[],e),...i.map(r=>y(t,a,L,r,[],e))]);if(!c||_(c)!==M.codeHash||!Array.isArray(p)||p.length!==3||p[0]!==!0||String(p[1]).toLowerCase()!==String(o.targetId).toLowerCase()||String(p[2]).toLowerCase()!==String(o.gate).toLowerCase())throw new s("Zap vault factory runtime or attestation differs from the requested route.");for(let r=0;r<i.length;r++)if(String(T[r]).toLowerCase()!==String(o[i[r]]).toLowerCase())throw new s(`Zap vault ${i[r]} differs from the requested route.`);if(!w||typeof w!="object"||Array.isArray(w))throw new s("Zap vault target key is incomplete.");let A=w;for(let r of["currency0","currency1","fee","tickSpacing"])if(String(A[r]).toLowerCase()!==String(o[r]).toLowerCase())throw new s(`Zap vault target ${r} differs from the requested route.`);if(String(A.hooks).toLowerCase()!==String(o.root).toLowerCase()||o.quoteIsCurrency0!==(String(o.quote).toLowerCase()===String(o.currency0).toLowerCase()))throw new s("Zap vault target root or quote ordering is inconsistent.");let q={};for(let r of v){let f=o[r];q[r]=[...g,"protocolRecipient","currency0","currency1"].includes(r)?m([{type:"address"}],[f]):r==="targetId"?f:r==="quoteIsCurrency0"?m([{type:"bool"}],[f]):r.startsWith("tick")?m([{type:"int256"}],[f]):m([{type:"uint256"}],[f])}if(K(l,15790,"0xc003d9e96e322d625b72aa686fae92e005f7da0374189d4079172ca84aaa1dc3",V,q),String(o.factory).toLowerCase()!==u.toLowerCase()||String(o.poolManager).toLowerCase()!==R.toLowerCase()||String(o.root).toLowerCase()!==C.toLowerCase())throw new s("Zap vault factory, pool manager or root differs from the reviewed deployment.");return{terms:o,live:$(x)}}function Q(t,e){return`Vault ${t} holds Rules ${e.rules} quote claims and idle assets; target ${e.targetId}, gate ${e.gate}, quote ${e.quote}, subject ${e.subject}, router ${e.router}, factory ${e.factory}; target key ${e.currency0}/${e.currency1}, fee ${e.fee}, tick spacing ${e.tickSpacing}, liquidity range ${e.tickLower} to ${e.tickUpper}. Mode ${e.mode} ${e.mode===0n?`sends bought subject to ${e.sink}`:"owns permanent target liquidity"}; impact ${e.impactBps} bps over ${e.windowBlocks} blocks, window scope ${e.windowScope}; threshold ${e.threshold}, max per zap ${e.maxPerZap} (zero disables that cap; the swap still has an int128 input limit). A permissionless caller chooses the bounty recipient; bounty is floor((target buy spend minus target Rules refund plus added quote) * ${e.rewardBps} / 10000). Protocol ${e.protocolRecipient} receives floor((claim minus the vault's prior target-buy refunds) * ${e.protocolShareBps} / 10000), when positive.`}async function re(t,e,a,d){h(a,["takePips","vault","route"],["takePips","vault","route"]);let n=Z({takePips:a.takePips,vault:a.vault}),{takePips:o,vault:u}=j(n),{terms:i,live:l}=await G(t,e,u,a.route),c=(w,x)=>String(w).toLowerCase()===String(x).toLowerCase(),p=$(await y(t,C,z(["function knownPool(bytes32) view returns (bool)"]),"knownPool",[i.targetId],e));if(!p||!l)throw new s(`Zap Source refused: target pool ${i.targetId} ${p?"is open, but its frozen settings do not route this vault and can never change":"is not open yet"}. This pool would still send its buyers' cut to vault ${u}, where it would be permanently locked with no recovery: the vault has no owner, rescue or removal path${p?"":", and someone else can open that target pool first without this vault"}. Launch the target pool first with this vault as a feeder, then launch this source pool.`);if(!d.rules||!c(i.rules,d.rules)||!c(i.quote,d.quote)||!c(i.gate,"0x59834ed88E72c59EB4fB0eF3cB0D95eCA98223E3")||c(i.targetId,d.poolId))throw new s("Zap Source vault rules, quote or target route do not match this launch.");return{data:n,descriptor:M,phases:1,bounds:{maxLpFeePips:0n,maxQuoteTakePips:BigInt(o),maxSubjectTakeBps:0n},summary:`${D(n)} ${Q(u,i)} The target route is live at the checked block.`}}export{J as a,B as b,H as c,Z as d,j as e,D as f,V as g,K as h,M as i,v as j,L as k,W as l,G as m,Q as n,re as o};
@@ -0,0 +1 @@
1
+ import{e as s,f as a,i as u}from"./UMY6SP7C.js";import{a as i}from"./XSD5NL7J.js";import{zeroAddress as c}from"viem";function w(e,o){if(s(o,["id","window","maximum","recipient"],["id","window","maximum","recipient"]),o.id!=="sandwich-guard")throw new i("Choose Hook Block sandwich-guard.");let t=a(o.window,8),n=a(o.maximum,8),r=u(o.recipient);if(t>3n||n<5n||n>15n||r===c||e.royaltyTo!==c&&e.royaltyTo.toLowerCase()!==r.toLowerCase()||e.potEveryNBuys&1<<17||e.potMinBuyQuote>>114n&511n)throw new i("Sandwich Guard needs window 0\u20133, maximum 5\u201315, an unoccupied carrier and one compatible nonzero recipient.");return{...e,royaltyTo:r,potEveryNBuys:e.potEveryNBuys|1<<30|1<<17,potMinBuyQuote:e.potMinBuyQuote|t<<114n|n<<116n|4n<<120n}}function l(e,o){let t=e.potMinBuyQuote>>114n&3n,n=e.potMinBuyQuote>>116n&15n;return`Sandwich Guard: window ${t+1n} execution blocks (ArbSys clock on chain 4663) after the launch guard, at most ${n*10000n} gross quote pips on a price reversal toward the window opening; Hookr ${o} receives ceil(final carved charge * ${e.protocolShareBps}/10000) quote base units; ${e.royaltyTo} receives the remainder as a claim. Each carve is floor(total collected Rules quote fee * this charge pips / final quote-take pips); residual rounding stays with Hookr. Settlement can credit an authenticated wallet payer a reprice rebate; no rebate is promised.`}export{w as a,l as b};
@@ -1 +1 @@
1
- import{m as l}from"./7OOCAZBE.js";import{a}from"./XSD5NL7J.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
1
+ import{m as l}from"./IR7KDBFU.js";import{a}from"./XSD5NL7J.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
@@ -1 +1 @@
1
- import{a as I}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,k as p}from"./TI727O2H.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as T,erc20Abi as k,getAddress as h,parseAbi as F}from"viem";var f=F(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function N(e){if(typeof e!="string")throw new n("Amount must be a positive base-unit integer string.");let a=G(e);if(a<=0n||a>=1n<<256n)throw new n("Amount must be positive and fit uint256.");return a}function E(e){if(typeof e!="bigint"||e<0n||e>=1n<<256n)throw new n("Invalid vault amount read.");return e}function J(e,a,o){return["mint",a==="steakhouse"?"redeem":"withdraw_assets"].map(v=>{let t=v==="mint",w=v==="redeem",d=t||w?"shares":"amount",q=l=>({type:"string",pattern:"^[0-9]+$",description:l}),M=t?'Exact vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.':'Vault shares to redeem for USDG, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.',O='Amount of USDG to receive, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.';return{name:`${a}_${v}`,inputSchema:{type:"object",additionalProperties:!1,required:t?["shares","maxAssets"]:[d],properties:{[d]:q(d==="shares"?M:O),...t?{maxAssets:q('Most USDG you will pay for these shares, in base units (USDG has 6 decimals). The call fails if the quote is higher. Example: "1000000" = 1 USDG.')}:{}}},execute:async(l,i)=>{try{if(I(i),Object.keys(l).some(x=>![d,...t?["maxAssets"]:[]].includes(x)))throw new n("Unexpected vault amount argument.");let s=N(l[d]),P=t?N(l.maxAssets):void 0,c=e.clientFor(r);if(await c.getChainId()!==r)throw new n("Vault amount actions require chain 4663.");let[S,R,V]=await Promise.all([c.readContract({address:o,abi:f,functionName:"asset"}),c.readContract({address:o,abi:f,functionName:"decimals"}),c.readContract({address:h(p),abi:k,functionName:"decimals"})]);if(typeof S!="string"||h(S)!==h(p)||R!==18||V!==6)throw new n("Vault amount actions require canonical USDG and the evidenced 18-decimal shares.");let m=E(await c.readContract({address:o,abi:f,functionName:t?"previewMint":w?"previewRedeem":"previewWithdraw",args:[s]}));if(m===0n)throw new n("The vault returned a zero amount quote.");if(t&&m>P)throw new n("The mint quote exceeds maxAssets.");let U=t?void 0:E(await c.readContract({address:o,abi:k,functionName:"balanceOf",args:[i]}));if(!t&&(w?s:m)>U)throw new n("The wallet share balance cannot cover this exit.");let _=t?T({abi:f,functionName:"mint",args:[s,i]}):w?T({abi:f,functionName:"redeem",args:[s,i,i]}):T({abi:f,functionName:"withdraw",args:[s,i,i]}),$=`${v} ${s} ${d==="shares"?"18-decimal share":"6-decimal USDG"} base units from ${a}; beneficiary ${i}.`,C=[...t?[e.approval(h(p),o,m.toString(),r)]:[],e.unsignedTx({to:o,data:_,value:"0",chainId:r,description:$})],y=await e.preview(C,i),D={address:h(p),chainId:r,symbol:"USDG",decimals:6},b={address:h(o),chainId:r,symbol:`${a} shares`,decimals:18},u=x=>y.changes.filter(g=>g.token.chainId===r&&g.token.address.toLowerCase()===x.address.toLowerCase()).reduce((g,A)=>{if(A.token.decimals!==x.decimals||!/^-?\d+$/.test(A.amount))throw new n("Invalid vault preview metadata.");return g+BigInt(A.amount)},0n);if(t?u(D)!==-m||u(b)!==s:w?u(b)!==-s||u(D)<=0n:u(D)!==s||-u(b)<=0n||-u(b)>U)throw new n("The preview does not match the requested vault amount and share balance.");return{txs:C,preview:y,summary:`${$} Quoted counterpart ${m} base units. ${y.summary} Standard ERC-4626 encodes no receipt minimum. Mint approvals use the exact current quote; accrual can require a new quote. Plain exits depend on available liquidity; use a separately previewed full force exit if required.`}}catch(s){throw new n(e.plainError(s))}}}})}export{J as a};
1
+ import{a as I}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,k as p}from"./EWZFZUVF.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as T,erc20Abi as k,getAddress as h,parseAbi as F}from"viem";var f=F(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function N(e){if(typeof e!="string")throw new n("Amount must be a positive base-unit integer string.");let a=G(e);if(a<=0n||a>=1n<<256n)throw new n("Amount must be positive and fit uint256.");return a}function E(e){if(typeof e!="bigint"||e<0n||e>=1n<<256n)throw new n("Invalid vault amount read.");return e}function J(e,a,o){return["mint",a==="steakhouse"?"redeem":"withdraw_assets"].map(v=>{let t=v==="mint",w=v==="redeem",d=t||w?"shares":"amount",q=l=>({type:"string",pattern:"^[0-9]+$",description:l}),M=t?'Exact vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.':'Vault shares to redeem for USDG, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.',O='Amount of USDG to receive, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.';return{name:`${a}_${v}`,inputSchema:{type:"object",additionalProperties:!1,required:t?["shares","maxAssets"]:[d],properties:{[d]:q(d==="shares"?M:O),...t?{maxAssets:q('Most USDG you will pay for these shares, in base units (USDG has 6 decimals). The call fails if the quote is higher. Example: "1000000" = 1 USDG.')}:{}}},execute:async(l,i)=>{try{if(I(i),Object.keys(l).some(x=>![d,...t?["maxAssets"]:[]].includes(x)))throw new n("Unexpected vault amount argument.");let s=N(l[d]),P=t?N(l.maxAssets):void 0,c=e.clientFor(r);if(await c.getChainId()!==r)throw new n("Vault amount actions require chain 4663.");let[S,R,V]=await Promise.all([c.readContract({address:o,abi:f,functionName:"asset"}),c.readContract({address:o,abi:f,functionName:"decimals"}),c.readContract({address:h(p),abi:k,functionName:"decimals"})]);if(typeof S!="string"||h(S)!==h(p)||R!==18||V!==6)throw new n("Vault amount actions require canonical USDG and the evidenced 18-decimal shares.");let m=E(await c.readContract({address:o,abi:f,functionName:t?"previewMint":w?"previewRedeem":"previewWithdraw",args:[s]}));if(m===0n)throw new n("The vault returned a zero amount quote.");if(t&&m>P)throw new n("The mint quote exceeds maxAssets.");let U=t?void 0:E(await c.readContract({address:o,abi:k,functionName:"balanceOf",args:[i]}));if(!t&&(w?s:m)>U)throw new n("The wallet share balance cannot cover this exit.");let _=t?T({abi:f,functionName:"mint",args:[s,i]}):w?T({abi:f,functionName:"redeem",args:[s,i,i]}):T({abi:f,functionName:"withdraw",args:[s,i,i]}),$=`${v} ${s} ${d==="shares"?"18-decimal share":"6-decimal USDG"} base units from ${a}; beneficiary ${i}.`,C=[...t?[e.approval(h(p),o,m.toString(),r)]:[],e.unsignedTx({to:o,data:_,value:"0",chainId:r,description:$})],y=await e.preview(C,i),D={address:h(p),chainId:r,symbol:"USDG",decimals:6},b={address:h(o),chainId:r,symbol:`${a} shares`,decimals:18},u=x=>y.changes.filter(g=>g.token.chainId===r&&g.token.address.toLowerCase()===x.address.toLowerCase()).reduce((g,A)=>{if(A.token.decimals!==x.decimals||!/^-?\d+$/.test(A.amount))throw new n("Invalid vault preview metadata.");return g+BigInt(A.amount)},0n);if(t?u(D)!==-m||u(b)!==s:w?u(b)!==-s||u(D)<=0n:u(D)!==s||-u(b)<=0n||-u(b)>U)throw new n("The preview does not match the requested vault amount and share balance.");return{txs:C,preview:y,summary:`${$} Quoted counterpart ${m} base units. ${y.summary} Standard ERC-4626 encodes no receipt minimum. Mint approvals use the exact current quote; accrual can require a new quote. Plain exits depend on available liquidity; use a separately previewed full force exit if required.`}}catch(s){throw new n(e.plainError(s))}}}})}export{J as a};
@@ -1,3 +1,3 @@
1
- import{b as W}from"./GBPB7JIB.js";import{a as b,b as P}from"./G2AA73ZE.js";import{fa as F,ga as G,ja as A}from"./HHYE42JG.js";import{a as M,b as U}from"./IBL6TL2Q.js";import{g as $,i as T,m as I,n as O}from"./NWNYJ26T.js";import{d as V}from"./IX3GZMTM.js";import{b as v}from"./TI727O2H.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as R}from"viem";var j={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; use vault if discovery is unavailable or ambiguous."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address verified on chain on every call; required for a rebuild without HTTP."}};function E(r){return{type:"object",additionalProperties:!1,properties:{...j,amount:{type:"string",pattern:r==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$",description:'Selected vault asset amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG); withdraw also accepts max to redeem all shares.'}},required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}}function H(r){return O(r,"Borro amount must be positive and fit uint256.",{positive:!0,notString:"Borro amount must be an integer string in asset base units."})}function B(r){return I(r,"Borro returned an invalid uint256 read.")}var L=r=>r*9950n/10000n,Z=new WeakMap;function oe(r,o){Z.set(r,{...o})}async function K(r,o,h,i=W){let k=await i(r,o).catch(()=>({kind:"unknown"})),f=k.kind!=="unknown"&&"readyBase"in k?k.readyBase:void 0,l=typeof f=="bigint"&&f>=0n&&f<1n<<256n?f:void 0,g=y=>V(y.toString(),o.assetDecimals);return{ready:l,...l!==void 0&&l<h?{refusal:A("too-little-ready",{ready:g(l),requested:g(h),maxNow:g(l),symbol:o.symbol})}:{}}}function z(r,o,h,i,k){let f=0n,l=0n;for(let g of r.changes){let y=g.token;if(typeof g.amount!="string"||!/^-?\d+$/.test(g.amount))throw new n("Borro preview returned invalid token changes. Nothing was signed.");let e=BigInt(g.amount);B(e<0n?-e:e);let d=$(y.address,o.address)?o:$(y.address,i.address)?i:void 0;if(!d||y.chainId!==v||y.decimals!==d.decimals)throw new n("Borro preview showed an unexpected token movement. Nothing was signed.");if(d===o){if(e>0n)throw new n("Borro preview showed a reversed input movement. Nothing was signed.");f-=e}else{if(e<0n)throw new n("Borro preview showed a reversed output movement. Nothing was signed.");l+=e}}if(B(f),B(l),f!==h||l<k||l===0n)throw new n("Borro preview did not match the requested receipt. Nothing was signed.")}var re=r=>{let{client:o,context:h,wallet:i}=r;async function k(e,d,s){if(T(s,"Provide a valid wallet address."),!$(s,i))throw new n("Borro action wallet differs from the signing wallet. Nothing was signed.");if(h.network==="testnet"||await o.getChainId()!==v)throw new n("Borro requires chain 4663. Nothing was signed.");if(Object.keys(e).some(m=>!["asset","vault","amount"].includes(m)))throw new n("Unsupported Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)||/^0x/i.test(e.asset)))throw new n("Provide an asset symbol, or put the vault address in vault.");let w=e.vault===void 0?void 0:T(e.vault,"Provide a valid Borro vault address.");if(!w&&e.asset===void 0)throw new n("Provide an asset symbol or a vault address.");let t=w?await r.verifyVault(o,w,d,{wallet:i}):await r.resolveVault(o,{asset:e.asset},d,i);if(w&&!$(w,t.vault)||e.asset!==void 0&&e.asset.toUpperCase()!==t.symbol.toUpperCase())throw new n("Borro vault and asset selectors do not match. Nothing was signed.");if(T(t.vault,"Borro returned an invalid vault address."),T(t.asset,"Borro returned an invalid asset address."),t.chainId!==v||t.shareDecimals!==18||$(t.asset,t.vault)||!Number.isInteger(t.assetDecimals)||t.assetDecimals<0||t.assetDecimals>255||t.mode!==d)throw new n(A("setup-mismatch",{}));let a=await r.verifySetup(o,t,d);if(!a.ok||d==="deposit"&&(!t.assetAllowed||a.drift.length>0))throw new n(A("setup-mismatch",{}));return{...t,setup:a}}function f(e){let d=e.mode==="withdraw"&&!/^[A-Za-z0-9.$_-]{1,16}$/.test(e.symbol)?"token":e.symbol;return{asset:{address:T(e.asset,"Borro returned an invalid asset."),symbol:d,decimals:e.assetDecimals,chainId:v},share:{address:T(e.vault,"Borro returned an invalid vault."),symbol:e.vaultSymbol,decimals:18,chainId:v}}}let l=(e,d)=>h.formatAmount(e.toString(),d),g="The minimum is checked in the preview; standard ERC-4626 calldata does not enforce it on chain. Re-preview before signing; execution output can change.",y=[{name:"borro_deposit",inputSchema:E("deposit"),execute:async(e,d)=>{let s=H(e.amount),w=await k(e,"deposit",d),{asset:t,share:a}=f(w),m=B(await o.readContract({address:t.address,abi:b,functionName:"balanceOf",args:[i]}));if(s>m)throw new n("This wallet does not hold enough of that asset for the Borro deposit.");let p=B(await o.readContract({address:a.address,abi:b,functionName:"previewDeposit",args:[s]}));if(p===0n)throw new n(A("deposit-would-revert",{}));let c=w.builderEligible===!0,u=Z.get(e);if(u&&(!c||!$(u.token,a.address)||!$(u.recipient,i)||u.minimum<=0n||u.minimum>p))throw new n(A("deposit-would-revert",{}));let S=u?.minimum??L(p),C=c?M.builders.address:a.address,N=[h.approval(t.address,C,s.toString(),v),h.unsignedTx({to:C,data:c?R({abi:P,functionName:"deposit",args:[a.address,s,U,S]}):R({abi:b,functionName:"deposit",args:[s,i]}),value:"0",chainId:v,description:`Deposit ${s} asset base units into Borro vault ${a.address}.`})],x;try{x=await h.preview(N,i),z(x,t,s,a,S)}catch{throw new n(A("deposit-would-revert",{}))}let D=w.deployedAt===void 0?void 0:Date.parse(w.deployedAt)/1e3,_=F({viaBuilder:c,amount:l(s,t.decimals),symbol:t.symbol,kind:t.symbol==="USDG"?"usdg":"stock",shares:l(p,18),sharesMin:l(S,18),vaultSymbol:a.symbol,deployedAtSeconds:D,nowSeconds:Math.floor(Date.now()/1e3)});return{txs:N,preview:x,vault:a.address,asset:t,shareToken:a,amount:s.toString(),shares:p.toString(),shares_min:S.toString(),summary:`${_}
1
+ import{b as W}from"./XSQJOOEY.js";import{a as b,b as P}from"./G2AA73ZE.js";import{fa as F,ga as G,ja as A}from"./HHYE42JG.js";import{a as M,b as U}from"./IBL6TL2Q.js";import{g as $,i as T,m as I,n as O}from"./NWNYJ26T.js";import{d as V}from"./IX3GZMTM.js";import{b as v}from"./EWZFZUVF.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as R}from"viem";var j={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; use vault if discovery is unavailable or ambiguous."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address verified on chain on every call; required for a rebuild without HTTP."}};function E(r){return{type:"object",additionalProperties:!1,properties:{...j,amount:{type:"string",pattern:r==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$",description:'Selected vault asset amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG); withdraw also accepts max to redeem all shares.'}},required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}}function H(r){return O(r,"Borro amount must be positive and fit uint256.",{positive:!0,notString:"Borro amount must be an integer string in asset base units."})}function B(r){return I(r,"Borro returned an invalid uint256 read.")}var L=r=>r*9950n/10000n,Z=new WeakMap;function oe(r,o){Z.set(r,{...o})}async function K(r,o,h,i=W){let k=await i(r,o).catch(()=>({kind:"unknown"})),f=k.kind!=="unknown"&&"readyBase"in k?k.readyBase:void 0,l=typeof f=="bigint"&&f>=0n&&f<1n<<256n?f:void 0,g=y=>V(y.toString(),o.assetDecimals);return{ready:l,...l!==void 0&&l<h?{refusal:A("too-little-ready",{ready:g(l),requested:g(h),maxNow:g(l),symbol:o.symbol})}:{}}}function z(r,o,h,i,k){let f=0n,l=0n;for(let g of r.changes){let y=g.token;if(typeof g.amount!="string"||!/^-?\d+$/.test(g.amount))throw new n("Borro preview returned invalid token changes. Nothing was signed.");let e=BigInt(g.amount);B(e<0n?-e:e);let d=$(y.address,o.address)?o:$(y.address,i.address)?i:void 0;if(!d||y.chainId!==v||y.decimals!==d.decimals)throw new n("Borro preview showed an unexpected token movement. Nothing was signed.");if(d===o){if(e>0n)throw new n("Borro preview showed a reversed input movement. Nothing was signed.");f-=e}else{if(e<0n)throw new n("Borro preview showed a reversed output movement. Nothing was signed.");l+=e}}if(B(f),B(l),f!==h||l<k||l===0n)throw new n("Borro preview did not match the requested receipt. Nothing was signed.")}var re=r=>{let{client:o,context:h,wallet:i}=r;async function k(e,d,s){if(T(s,"Provide a valid wallet address."),!$(s,i))throw new n("Borro action wallet differs from the signing wallet. Nothing was signed.");if(h.network==="testnet"||await o.getChainId()!==v)throw new n("Borro requires chain 4663. Nothing was signed.");if(Object.keys(e).some(m=>!["asset","vault","amount"].includes(m)))throw new n("Unsupported Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)||/^0x/i.test(e.asset)))throw new n("Provide an asset symbol, or put the vault address in vault.");let w=e.vault===void 0?void 0:T(e.vault,"Provide a valid Borro vault address.");if(!w&&e.asset===void 0)throw new n("Provide an asset symbol or a vault address.");let t=w?await r.verifyVault(o,w,d,{wallet:i}):await r.resolveVault(o,{asset:e.asset},d,i);if(w&&!$(w,t.vault)||e.asset!==void 0&&e.asset.toUpperCase()!==t.symbol.toUpperCase())throw new n("Borro vault and asset selectors do not match. Nothing was signed.");if(T(t.vault,"Borro returned an invalid vault address."),T(t.asset,"Borro returned an invalid asset address."),t.chainId!==v||t.shareDecimals!==18||$(t.asset,t.vault)||!Number.isInteger(t.assetDecimals)||t.assetDecimals<0||t.assetDecimals>255||t.mode!==d)throw new n(A("setup-mismatch",{}));let a=await r.verifySetup(o,t,d);if(!a.ok||d==="deposit"&&(!t.assetAllowed||a.drift.length>0))throw new n(A("setup-mismatch",{}));return{...t,setup:a}}function f(e){let d=e.mode==="withdraw"&&!/^[A-Za-z0-9.$_-]{1,16}$/.test(e.symbol)?"token":e.symbol;return{asset:{address:T(e.asset,"Borro returned an invalid asset."),symbol:d,decimals:e.assetDecimals,chainId:v},share:{address:T(e.vault,"Borro returned an invalid vault."),symbol:e.vaultSymbol,decimals:18,chainId:v}}}let l=(e,d)=>h.formatAmount(e.toString(),d),g="The minimum is checked in the preview; standard ERC-4626 calldata does not enforce it on chain. Re-preview before signing; execution output can change.",y=[{name:"borro_deposit",inputSchema:E("deposit"),execute:async(e,d)=>{let s=H(e.amount),w=await k(e,"deposit",d),{asset:t,share:a}=f(w),m=B(await o.readContract({address:t.address,abi:b,functionName:"balanceOf",args:[i]}));if(s>m)throw new n("This wallet does not hold enough of that asset for the Borro deposit.");let p=B(await o.readContract({address:a.address,abi:b,functionName:"previewDeposit",args:[s]}));if(p===0n)throw new n(A("deposit-would-revert",{}));let c=w.builderEligible===!0,u=Z.get(e);if(u&&(!c||!$(u.token,a.address)||!$(u.recipient,i)||u.minimum<=0n||u.minimum>p))throw new n(A("deposit-would-revert",{}));let S=u?.minimum??L(p),C=c?M.builders.address:a.address,N=[h.approval(t.address,C,s.toString(),v),h.unsignedTx({to:C,data:c?R({abi:P,functionName:"deposit",args:[a.address,s,U,S]}):R({abi:b,functionName:"deposit",args:[s,i]}),value:"0",chainId:v,description:`Deposit ${s} asset base units into Borro vault ${a.address}.`})],x;try{x=await h.preview(N,i),z(x,t,s,a,S)}catch{throw new n(A("deposit-would-revert",{}))}let D=w.deployedAt===void 0?void 0:Date.parse(w.deployedAt)/1e3,_=F({viaBuilder:c,amount:l(s,t.decimals),symbol:t.symbol,kind:t.symbol==="USDG"?"usdg":"stock",shares:l(p,18),sharesMin:l(S,18),vaultSymbol:a.symbol,deployedAtSeconds:D,nowSeconds:Math.floor(Date.now()/1e3)});return{txs:N,preview:x,vault:a.address,asset:t,shareToken:a,amount:s.toString(),shares:p.toString(),shares_min:S.toString(),summary:`${_}
2
2
  Base units: amount ${s} (${t.address}, decimals ${t.decimals}); shares ${p} (${a.address}, decimals 18); shares_min ${S}.`}}},{name:"borro_withdraw",inputSchema:E("withdraw"),execute:async(e,d)=>{let s=e.amount==="max",w=s?void 0:H(e.amount),t=await k(e,"withdraw",d),{asset:a,share:m}=f(t),p=B(await o.readContract({address:m.address,abi:b,functionName:"balanceOf",args:[i]}));if(p===0n)throw new n(A("no-shares",{symbol:a.symbol}));let c=s?p:B(await o.readContract({address:m.address,abi:b,functionName:"previewWithdraw",args:[w]}));if(c===0n||c>p)throw new n("This wallet does not hold enough Borro shares for that withdrawal.");let u=w??B(await o.readContract({address:m.address,abi:b,functionName:"previewRedeem",args:[c]}));if(u===0n)throw new n("Borro preview returned no assets for these shares. Nothing was signed.");let{ready:S,refusal:C}=await K(o,{...t,symbol:a.symbol},u,r.readLiquidity);if(C!==void 0)return{txs:[],vault:m.address,asset:a,shareToken:m,amount:u.toString(),shares:c.toString(),max_now:S.toString(),summary:C};let N=s?L(u):u,x=[h.unsignedTx({to:m.address,data:s?R({abi:b,functionName:"redeem",args:[c,i,i]}):R({abi:b,functionName:"withdraw",args:[u,i,i]}),value:"0",chainId:v,description:`Withdraw ${u} asset base units from Borro vault ${m.address}${s?` for ${c} share base units`:""}.`})],D=s?await h.preview(x,i):await h.preview(x,i,{reads:[{to:m.address,data:R({abi:b,functionName:"previewWithdraw",args:[u]}),chainId:v}]});if(!s){let q=D.readResults?.[0];if(D.readResults?.length!==1||typeof q!="string"||!/^0x[0-9a-fA-F]{64}$/.test(q))throw new n("Borro preview returned an invalid share quote. Nothing was signed.");if(c=B(BigInt(q)),c===0n||c>p)throw new n("This wallet does not hold enough Borro shares for that withdrawal.")}z(D,m,c,a,N);let _=G({amount:l(u,a.decimals),isAll:s,symbol:a.symbol,out:l(u,a.decimals),shares:l(c,18),vaultSymbol:m.symbol,drift:t.setup.drift.length>0});return{txs:x,preview:D,vault:m.address,asset:a,shareToken:m,amount:u.toString(),shares:c.toString(),assets_min:N.toString(),isMax:s,setup:t.setup,summary:`${_}
3
3
  Base units: amount ${u} (${a.address}, decimals ${a.decimals}); shares ${c} (${m.address}, decimals 18); assets_min ${N}. ${g}`}}}];for(let e of y){let d=e.execute;e.execute=async(s,w)=>{try{return await d(s,w)}catch(t){throw new n(h.plainError(t))}}}return y};export{oe as a,K as b,re as c};
@@ -1 +1 @@
1
- import{d as o}from"./JJSCDDQO.js";import{a as i}from"./LFSJDFMY.js";import{b as a}from"./TI727O2H.js";var m=s=>({tools:i.map(e=>{let t=e==="netnet_blackjack_claim"?"seriesId":"sessionId";return{name:e,inputSchema:{description:"Self-only recovery on chain 4663, available without an active identity or subscription; every action requires local human confirmation. Card counts use whole units.",type:"object",additionalProperties:!1,required:[t],properties:{[t]:{type:"string",pattern:"^[1-9][0-9]{0,77}$",description:t==="seriesId"?'Card series id holding your parked blackjack chips, as a decimal string. Example: "1".':'Blackjack session id to settle, as a decimal string. Example: "1".'}}},execute:async(n,c)=>{let r=await o(e,n,c,s.clientFor(a));return{txs:r.txs,summary:r.decision}}}})});export{m as a};
1
+ import{d as o}from"./L3IAEXQR.js";import{a as i}from"./LFSJDFMY.js";import{b as a}from"./EWZFZUVF.js";var m=s=>({tools:i.map(e=>{let t=e==="netnet_blackjack_claim"?"seriesId":"sessionId";return{name:e,inputSchema:{description:"Self-only recovery on chain 4663, available without an active identity or subscription; every action requires local human confirmation. Card counts use whole units.",type:"object",additionalProperties:!1,required:[t],properties:{[t]:{type:"string",pattern:"^[1-9][0-9]{0,77}$",description:t==="seriesId"?'Card series id holding your parked blackjack chips, as a decimal string. Example: "1".':'Blackjack session id to settle, as a decimal string. Example: "1".'}}},execute:async(n,c)=>{let r=await o(e,n,c,s.clientFor(a));return{txs:r.txs,summary:r.decision}}}})});export{m as a};
@@ -0,0 +1 @@
1
+ import{e as q,h as I,i as p,j as P,m as j,n as O,p as f,q as k,v as $}from"./UMY6SP7C.js";import{b as h,i as T,j as A,k as v}from"./CJMVRV34.js";import{a as s}from"./XSD5NL7J.js";import{a as H}from"./JXOEJPJ4.js";import{encodeFunctionData as R,getAddress as F,isAddress as U,parseAbi as M}from"viem";var _=M(["function poolConfig(bytes32 id) view returns ((address subject,address quote,address rules,address advisory,address liquidityOwner,uint24 baseLpFeePips,(uint24 maxLpFeePips,uint24 maxQuoteTakePips,uint16 maxSubjectTakeBps) caps,uint32 rulesGasLimit,uint32 advisoryGasLimit,uint8 advisoryPhases,bool advisoryFailOpen,bytes32 policyId) pc)"]),L=M(["function claimable(address currency,address beneficiary) view returns (uint256)","function claim(address currency) returns (uint256)"]),N={type:"object",additionalProperties:!1,properties:{poolId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Pool ID on the current Hookr Root and core."},currency:{type:"string",enum:["quote","subject"],description:"Which currency of this pool to claim."}},required:["poolId","currency"]};async function S(t,y,a){let e=q(y,["poolId","currency"],["poolId","currency"]),u=I(e.poolId);if(e.currency!=="quote"&&e.currency!=="subject")throw new s("Choose the Hookr pool quote or subject currency.");if(t.network==="testnet")throw new s("Hookr claims require Robinhood Chain 4663.");if(!U(a))throw new s("A valid signing wallet is required for Hookr claims.");let d=F(a),c=F(h.rulesV1),n=t.clientFor(4663),o=await A(n);await T(n,o.number,[k,c,h.poolManager]);let b=j(await f(n,k,_,"poolConfig",[u],o.number));if(p(b.rules)!==c)throw new s("This pool does not use the reviewed current Hookr core.");let w=p(b.subject),g=p(b.quote);if(w===g)throw new s("Hookr pool currencies are invalid.");let l=e.currency==="quote"?g:w,[B,m]=await Promise.all([f(n,c,L,"claimable",[l,d],o.number),$(n,l,o.number)]),i=P(B),x=(1n<<127n)-1n,r=i>x?x:i,C=`${r?"Claim":"Nothing to claim:"} ${r} base units of ${H(m.symbol)} (${m.address}, ${m.decimals} decimals) for ${d}. Current core claim ledger is per currency and wallet, and can include prizes, royalties and recapture credits from multiple pools. ${i>r?`The remaining ${i-r} base units stay in the ledger.`:""}`,D=r?[t.unsignedTx({to:c,data:R({abi:L,functionName:"claim",args:[l]}),value:"0",chainId:4663,description:C})]:[];return await v(n,o),{txs:D,inputs:[],summary:C,terms:O({poolId:u,poolCurrency:e.currency,currency:l,token:m,beneficiary:d,recipient:d,claimable:i,amount:r,remaining:i-r,blockNumber:o.number,blockHash:o.hash,core:c})}}function Q(t){return{name:"hookr_claim",inputSchema:N,async execute(y,a){let e=await S(t,y,a),u=e.txs.length?await t.preview(e.txs,a):{txs:[],changes:[],summary:e.summary};return{...e,preview:u}}}}export{L as a,N as b,S as c,Q as d};
@@ -1 +1 @@
1
- import{b as D}from"./IX3GZMTM.js";import{b as d}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
1
+ import{b as D}from"./IX3GZMTM.js";import{b as d}from"./EWZFZUVF.js";import{a as c}from"./XSD5NL7J.js";import{concat as B,encodeAbiParameters as k,getAddress as v,isAddress as F,keccak256 as g,parseAbiParameters as O,recoverAddress as q,toHex as N}from"viem";import{privateKeyToAccount as U}from"viem/accounts";var T="OakPriceNote",l="1",w=300,E="0x0000000000000000000000000000000000000000",W=g(N("PriceNote(address wallet,uint256 oakPerEthE18,uint64 timestamp,bytes32 nonce)")),L=g(N("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")),M=(1n<<64n)-1n,P=(1n<<256n)-1n,z=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,G=0x7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0n;function X(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{130}$/.test(e))return!1;let n=BigInt(`0x${e.slice(2,66)}`),t=BigInt(`0x${e.slice(66,130)}`),i=Number.parseInt(e.slice(130,132),16);return!(i!==27&&i!==28||n<=0n||n>=z||t<=0n||t>G)}function m(e,n){if(typeof e!="string"||!F(e,{strict:!1}))throw new c(`Invalid ${n} address.`);return v(e)}function p(e,n){let t;if(typeof e=="bigint")t=e;else if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new c(`Invalid ${n}.`);t=BigInt(e)}else t=D(e);if(t<0n||t>P)throw new c(`${n} exceeds uint256 bounds.`);return t}function h(e,n){let t=p(e,n);if(t>M)throw new c(`${n} exceeds uint64 bounds.`);return t}function Y(e,n){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new c(`${n} must be a 32-byte hex string.`);return e}function j(e){if(typeof e=="bigint"){if(e<=0n||e>P)throw new c("Private key must be a positive scalar.");return`0x${e.toString(16).padStart(64,"0")}`}if(typeof e=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(e))return`0x${e.slice(2).padStart(64,"0")}`;throw new c("Invalid private key format.")}function K(e){let n=p(e.chainId,"chainId"),t=m(e.verifyingContract,"verifyingContract");return g(k(O("bytes32, bytes32, bytes32, uint256, address"),[L,g(N(e.name)),g(N(e.version)),n,t]))}function ae(e,n=d,t=l){return{name:T,version:t,chainId:Number(p(n,"chainId")),verifyingContract:m(e,"consumer")}}function J(e,n=d,t=l){return K({name:T,version:t,chainId:n,verifyingContract:e})}function Q(e){let n=m(e.wallet,"wallet"),t=p(e.oakPerEthE18,"oakPerEthE18"),i=h(e.timestamp,"timestamp"),r=Y(e.nonce,"nonce");return g(k(O("bytes32, address, uint256, uint64, bytes32"),[W,n,t,i,r]))}function C(e,n,t=d,i=l){let r=J(n,t,i),o=Q(e);return g(B(["0x1901",r,o]))}async function ce(e,n,t,i=d,r=l){let o=C(e,n,i,r);return typeof t=="object"&&t!==null&&"sign"in t?t.sign({hash:o}):U(j(t)).sign({hash:o})}async function Z(e,n,t,i=d,r=l){if(!X(n))return E;try{let o=C(e,t,i,r),x=await q({hash:o,signature:n});return v(x)}catch{return E}}function ee(e,n){let t=p(e,"oakPerEthE18"),i=p(n,"spotOakPerEthE18");if(i<=0n||t<=0n)return!1;if(t>P/2n||i>P/3n)throw new c("Guard arithmetic overflow.");let r=t*2n;return r>=i&&r<=i*3n}function te(e,n,t,i){if("signature"in e&&"consumer"in e&&"note"in e&&!("average"in e))return e;if("note"in e&&"signature"in e&&"consumer"in e){let a=e,f=n??{};return{...f,note:a.note,signature:a.signature,consumer:f.consumer??a.consumer,expiresAt:f.expiresAt??a.expiresAt}}return{...i??{},note:e,signature:n,consumer:t}}async function fe(e,n,t,i){let r=te(e,n,t,i),{note:o,signature:x,consumer:S}=r,a=h(o.timestamp,"timestamp"),f=p(o.oakPerEthE18,"oakPerEthE18"),y=(a+BigInt(w)).toString(),s=(b,V,H)=>({valid:!1,ok:!1,...H?{signer:H}:{},oakPerEthE18:f.toString(),expiresAt:y,reason:b,error:V}),I=r.wallet??r.boundWallet;if(I===void 0)return s("wrong_wallet","Bound wallet context is required to verify a price note.");if(m(o.wallet,"wallet")!==m(I,"boundWallet"))return s("wrong_wallet","Price note wallet does not match the bound wallet.");if(r.now===void 0)return s("expired","Current time (now) is required to verify price note expiry.");let A=h(r.now,"now");if(a>A)return s("not_yet_valid","Price note timestamp is in the future.");if(A-a>BigInt(w))return s("expired","Price note has expired.");if(r.expiresAt!==void 0){let b=h(r.expiresAt,"expiresAt");if(b!==a+BigInt(w)||A>b)return s("expired","Price note has expired.")}let R=r.chainId??d,$=r.version??l,u=await Z(o,x,S,R,$);if(u===E)return s("bad_signature","Price note signature could not be recovered.");if(r.signer===void 0)return s("bad_signature","Expected oracle signer is required to verify a price note.",u);let _=m(r.signer,"signer");return _===E||u!==_?s("bad_signature","Price note signer does not match the oracle signer.",u):r.spotOakPerEthE18===void 0?s("outside_guard","Spot OAK/ETH price is required to verify the price note guard band.",u):ee(f,r.spotOakPerEthE18)?{valid:!0,ok:!0,signer:u,oakPerEthE18:f.toString(),expiresAt:y}:s("outside_guard","Price note is outside the 50% spot guard band.",u)}export{T as a,l as b,w as c,E as d,W as e,K as f,ae as g,J as h,Q as i,C as j,ce as k,Z as l,ee as m,fe as n};
@@ -1 +1 @@
1
- import{b}from"./C57DITTF.js";import{c as m,f as A}from"./FHB7QYJO.js";import{c as h}from"./FUP53K6G.js";import{b as w}from"./GBPB7JIB.js";import{c as u,i as v,l as y}from"./4CEV4FDG.js";import{j as f}from"./N624NR7Y.js";import{b as p}from"./SPJCSEKP.js";import{a as n}from"./XSD5NL7J.js";var $={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; for multiple USDG vaults, select the largest only with at least 100 USDG and ten times the runner-up assets. Other ambiguous symbols require a vault address."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address to verify on chain; required for a rebuild without HTTP. If asset is also supplied, both must match."}};function M(e){return{type:"object",additionalProperties:!1,properties:{...$,...e?{amount:{type:"string",pattern:e==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$",description:'Selected vault asset amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG); withdraw also accepts max to redeem all shares.'}}:{}},...e?{required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}:{}}}function O(e,o){if(Object.keys(e).some(s=>!["asset","vault",...o?["amount"]:[]].includes(s)))throw new n("Unexpected Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)))throw new n("Provide an official asset symbol.");if(e.vault!==void 0&&u(e.vault),o&&(typeof e.amount!="string"||!(o==="withdraw"?/^(?:[0-9]+|max)$/:/^[0-9]+$/).test(e.amount)||!e.asset&&!e.vault))throw new n("Provide an asset symbol or vault address and a base-unit amount.")}function x(e,o={}){let s=m(e,o);if(o.resolveAllowedAsset||o.officialStockTokens)return s;let l=m(e,{...o,resolveAllowedAsset:(r,a,i)=>v(f())(r,a,i)}),t=(r,a,i,d)=>(a.vault?l:s).resolveVault(r,a,i,d);return{...l,discoverVaults:s.discoverVaults,resolveVault:t}}function P(e,o={}){let s=x(e,o),l=["deposit","withdraw"].map((t,r)=>({name:`borro_${t}`,inputSchema:M(t),execute:async(a,i)=>{O(a,t),u(i);let d=o.createActionTools??h,T=e.clientFor(4663),c=d({context:e,client:T,wallet:i,verifySetup:y,readLiquidity:w,...s})[r];if(!c||c.name!==`borro_${t}`)throw new n("Borro action wiring is unavailable.");return c.execute(a,i)}}));return{tools:[{name:"borro_list",inputSchema:M(),execute:async(t,r)=>(O(t),A(e,r,{...typeof t.asset=="string"?{asset:t.asset}:{},...t.vault?{vault:u(t.vault)}:{}},o,s))},...l],positions:(t,r)=>b(e,t,{...o,...r,discoverVaults:s.discoverVaults})}}var _=e=>p("borro",e.network==="testnet"?[]:[P(e)]);export{x as a,P as b,_ as c};
1
+ import{b}from"./3HF6WE4L.js";import{c as m,f as A}from"./FN6XY6ET.js";import{c as h}from"./6LDC5D2S.js";import{b as w}from"./XSQJOOEY.js";import{c as u,i as v,l as y}from"./4CEV4FDG.js";import{j as f}from"./5PNFV7HH.js";import{b as p}from"./SPJCSEKP.js";import{a as n}from"./XSD5NL7J.js";var $={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; for multiple USDG vaults, select the largest only with at least 100 USDG and ten times the runner-up assets. Other ambiguous symbols require a vault address."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address to verify on chain; required for a rebuild without HTTP. If asset is also supplied, both must match."}};function M(e){return{type:"object",additionalProperties:!1,properties:{...$,...e?{amount:{type:"string",pattern:e==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$",description:'Selected vault asset amount in base units using its decimals (USDG has 6: "1000000" = 1 USDG); withdraw also accepts max to redeem all shares.'}}:{}},...e?{required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}:{}}}function O(e,o){if(Object.keys(e).some(s=>!["asset","vault",...o?["amount"]:[]].includes(s)))throw new n("Unexpected Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)))throw new n("Provide an official asset symbol.");if(e.vault!==void 0&&u(e.vault),o&&(typeof e.amount!="string"||!(o==="withdraw"?/^(?:[0-9]+|max)$/:/^[0-9]+$/).test(e.amount)||!e.asset&&!e.vault))throw new n("Provide an asset symbol or vault address and a base-unit amount.")}function x(e,o={}){let s=m(e,o);if(o.resolveAllowedAsset||o.officialStockTokens)return s;let l=m(e,{...o,resolveAllowedAsset:(r,a,i)=>v(f())(r,a,i)}),t=(r,a,i,d)=>(a.vault?l:s).resolveVault(r,a,i,d);return{...l,discoverVaults:s.discoverVaults,resolveVault:t}}function P(e,o={}){let s=x(e,o),l=["deposit","withdraw"].map((t,r)=>({name:`borro_${t}`,inputSchema:M(t),execute:async(a,i)=>{O(a,t),u(i);let d=o.createActionTools??h,T=e.clientFor(4663),c=d({context:e,client:T,wallet:i,verifySetup:y,readLiquidity:w,...s})[r];if(!c||c.name!==`borro_${t}`)throw new n("Borro action wiring is unavailable.");return c.execute(a,i)}}));return{tools:[{name:"borro_list",inputSchema:M(),execute:async(t,r)=>(O(t),A(e,r,{...typeof t.asset=="string"?{asset:t.asset}:{},...t.vault?{vault:u(t.vault)}:{}},o,s))},...l],positions:(t,r)=>b(e,t,{...o,...r,discoverVaults:s.discoverVaults})}}var _=e=>p("borro",e.network==="testnet"?[]:[P(e)]);export{x as a,P as b,_ as c};
@@ -1 +1 @@
1
- import{a as f,b as T,f as c,g as v,i as E}from"./TXGZ6NWN.js";import{c as a,g as O}from"./NWNYJ26T.js";import{b as m}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as $,parseAbi as x}from"viem";var F=["function owner() view returns (address)","function admins(address) view returns (bool)","function allowedDepositors(address) view returns (bool)","function setAdmin(address,bool)","function setDeprecated(bool)","function setTeamFeeRecipient(address)","function claimTeamFees(address)","function setHook(address,bool)","function setLocker(address,address,bool)","function setMevModule(address,bool)","function setExtension(address,bool)","function addDepositor(address)","function storeFees(address,address,uint256)","function claim(address,address)","function withdrawETH(address)","function withdrawERC20(address,address)","function transferOwnership(address)","function renounceOwnership()"],h=x(F),g={setAdmin:{contract:"factory",fields:["target","enabled"],admin:!1},setDeprecated:{contract:"factory",fields:["enabled"],admin:!1},setTeamFeeRecipient:{contract:"factory",fields:["recipient"],admin:!1},claimTeamFees:{contract:"factory",fields:["token"],admin:!0},setHook:{contract:"factory",fields:["target","enabled"],admin:!0},setLocker:{contract:"factory",fields:["target","hook","enabled"],admin:!0},setMevModule:{contract:"factory",fields:["target","enabled"],admin:!0},setExtension:{contract:"factory",fields:["target","enabled"],admin:!0},addDepositor:{contract:"fee_locker",fields:["target"],admin:!1},withdrawETH:{contract:"locker",fields:["recipient"],admin:!1},withdrawERC20:{contract:"locker",fields:["token","recipient"],admin:!1}},N=p=>{let w=()=>p.clientFor(m),k=async(e,t,o)=>({txs:e,preview:await p.preview(e,t),summary:o}),y=(e,t,o,r)=>p.unsignedTx({to:e,chainId:m,data:$({abi:h,functionName:t,args:o}),value:"0",description:r}),_={operation:{enum:[...Object.keys(g),"transferOwnership","renounceOwnership"],description:"Owner or admin call on a pinned Clanker contract: toggle admins, hooks, lockers, MEV modules, extensions or depositors, claim team fees, withdraw assets, or change ownership."},contract:{enum:["factory","locker","fee_locker"],description:"Which pinned Clanker contract to call; required only for transferOwnership and renounceOwnership, otherwise implied by the operation."},target:{...a,description:"Address of the admin, hook, locker, MEV module, extension or depositor being configured."},hook:{...a,description:"Address of the pool hook the locker is enabled for; used by setLocker."},token:{...a,description:"Address of the ERC-20 token to claim team fees on or withdraw."},recipient:{...a,description:"Address that receives funds, the new fee recipient, or the new owner, depending on the operation."},enabled:{type:"boolean",description:"True to enable (or deprecate, for setDeprecated) the target; false to disable."}},b=(e,t,o,r)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:async(n,i)=>{try{return E(n,Object.keys(t)),await r(n,c(i))}catch(d){throw new s(p.plainError(d))}}});return{tools:[b("protocol_admin",_,["operation"],async(e,t)=>{let o=String(e.operation),r=o==="transferOwnership"||o==="renounceOwnership";if(!r&&!Object.hasOwn(g,o))throw new s("Choose a supported Clanker protocol operation.");let n=r?void 0:g[o],i=n?.contract??e.contract;if(i!=="factory"&&i!=="locker"&&i!=="fee_locker")throw new s("Select factory, locker or fee_locker for an ownership change.");if(!r&&e.contract!==void 0&&e.contract!==i)throw new s("This operation targets a different pinned contract.");let d=n?.fields??(o==="transferOwnership"?["recipient"]:[]);for(let l of["target","hook","token","recipient","enabled"])if(e[l]!==void 0&&!d.includes(l))throw new s(`Input ${l} does not match this protocol operation.`);let u=f[i].address,D=c(await w().readContract({address:u,abi:h,functionName:"owner"}),!0);if(!O(D,t)&&(n?.admin&&await w().readContract({address:u,abi:h,functionName:"admins",args:[t]}))!==!0)throw new s("The connected wallet lacks the required Clanker protocol owner/admin role.");let A=d.map(l=>{if(l!=="enabled")return c(e[l]);if(typeof e.enabled!="boolean")throw new s("Provide enabled as boolean.");return e.enabled}),C=`Clanker protocol ${i}: ${o} ${JSON.stringify(A)}. Owner/admin operation; renouncing ownership permanently removes owner-only controls. Withdrawals transfer the entire recorded asset balance; team fees go to the configured team recipient.`;return k([y(u,o,A,C)],t,C)}),b("store_fees",{token:{...a,description:"Address of the ERC-20 token whose fees are deposited."},recipient:{...a,description:"Address of the fee owner who can later claim these fees."},amount:{...T,description:'Amount of the token to deposit, in base units of that token (read its decimals). Example: "1000000000000000000" = 1 token at 18 decimals.'}},["token","recipient","amount"],async(e,t)=>{let o=c(e.token),r=c(e.recipient),n=v(e.amount);if(!n)throw new s("Provide a positive fee deposit amount.");if(await w().readContract({address:f.fee_locker.address,abi:h,functionName:"allowedDepositors",args:[t]})!==!0)throw new s("This wallet is not an authorized Clanker fee depositor.");let d=`Deposit exactly ${n} base units of token ${o} into Clanker fees for ${r}. Fee-on-transfer receipts may be smaller; the recorded recipient can later claim them.`,u=[p.approval(o,f.fee_locker.address,n.toString(),m),y(f.fee_locker.address,"storeFees",[r,o,n],d)];return k(u,t,d)}),b("claim_for",{token:{...a,description:"Address of the fee token to claim for the owner."},recipient:{...a,description:"Address of the fee owner whose collected fees are claimed; receipts go to this address."}},["token","recipient"],async(e,t)=>{let o=c(e.token),r=c(e.recipient),n=`Permissionlessly claim already-collected Clanker ${o} fees for ${r}; all receipts go to that fee owner, while ${t} pays gas.`;return k([y(f.fee_locker.address,"claim",[r,o],n)],t,n)})]}};export{N as a};
1
+ import{a as f,b as T,f as c,g as v,i as E}from"./PG7HZIZL.js";import{c as a,g as O}from"./NWNYJ26T.js";import{b as m}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as $,parseAbi as x}from"viem";var F=["function owner() view returns (address)","function admins(address) view returns (bool)","function allowedDepositors(address) view returns (bool)","function setAdmin(address,bool)","function setDeprecated(bool)","function setTeamFeeRecipient(address)","function claimTeamFees(address)","function setHook(address,bool)","function setLocker(address,address,bool)","function setMevModule(address,bool)","function setExtension(address,bool)","function addDepositor(address)","function storeFees(address,address,uint256)","function claim(address,address)","function withdrawETH(address)","function withdrawERC20(address,address)","function transferOwnership(address)","function renounceOwnership()"],h=x(F),g={setAdmin:{contract:"factory",fields:["target","enabled"],admin:!1},setDeprecated:{contract:"factory",fields:["enabled"],admin:!1},setTeamFeeRecipient:{contract:"factory",fields:["recipient"],admin:!1},claimTeamFees:{contract:"factory",fields:["token"],admin:!0},setHook:{contract:"factory",fields:["target","enabled"],admin:!0},setLocker:{contract:"factory",fields:["target","hook","enabled"],admin:!0},setMevModule:{contract:"factory",fields:["target","enabled"],admin:!0},setExtension:{contract:"factory",fields:["target","enabled"],admin:!0},addDepositor:{contract:"fee_locker",fields:["target"],admin:!1},withdrawETH:{contract:"locker",fields:["recipient"],admin:!1},withdrawERC20:{contract:"locker",fields:["token","recipient"],admin:!1}},N=p=>{let w=()=>p.clientFor(m),k=async(e,t,o)=>({txs:e,preview:await p.preview(e,t),summary:o}),y=(e,t,o,r)=>p.unsignedTx({to:e,chainId:m,data:$({abi:h,functionName:t,args:o}),value:"0",description:r}),_={operation:{enum:[...Object.keys(g),"transferOwnership","renounceOwnership"],description:"Owner or admin call on a pinned Clanker contract: toggle admins, hooks, lockers, MEV modules, extensions or depositors, claim team fees, withdraw assets, or change ownership."},contract:{enum:["factory","locker","fee_locker"],description:"Which pinned Clanker contract to call; required only for transferOwnership and renounceOwnership, otherwise implied by the operation."},target:{...a,description:"Address of the admin, hook, locker, MEV module, extension or depositor being configured."},hook:{...a,description:"Address of the pool hook the locker is enabled for; used by setLocker."},token:{...a,description:"Address of the ERC-20 token to claim team fees on or withdraw."},recipient:{...a,description:"Address that receives funds, the new fee recipient, or the new owner, depending on the operation."},enabled:{type:"boolean",description:"True to enable (or deprecate, for setDeprecated) the target; false to disable."}},b=(e,t,o,r)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:t,required:o,additionalProperties:!1},execute:async(n,i)=>{try{return E(n,Object.keys(t)),await r(n,c(i))}catch(d){throw new s(p.plainError(d))}}});return{tools:[b("protocol_admin",_,["operation"],async(e,t)=>{let o=String(e.operation),r=o==="transferOwnership"||o==="renounceOwnership";if(!r&&!Object.hasOwn(g,o))throw new s("Choose a supported Clanker protocol operation.");let n=r?void 0:g[o],i=n?.contract??e.contract;if(i!=="factory"&&i!=="locker"&&i!=="fee_locker")throw new s("Select factory, locker or fee_locker for an ownership change.");if(!r&&e.contract!==void 0&&e.contract!==i)throw new s("This operation targets a different pinned contract.");let d=n?.fields??(o==="transferOwnership"?["recipient"]:[]);for(let l of["target","hook","token","recipient","enabled"])if(e[l]!==void 0&&!d.includes(l))throw new s(`Input ${l} does not match this protocol operation.`);let u=f[i].address,D=c(await w().readContract({address:u,abi:h,functionName:"owner"}),!0);if(!O(D,t)&&(n?.admin&&await w().readContract({address:u,abi:h,functionName:"admins",args:[t]}))!==!0)throw new s("The connected wallet lacks the required Clanker protocol owner/admin role.");let A=d.map(l=>{if(l!=="enabled")return c(e[l]);if(typeof e.enabled!="boolean")throw new s("Provide enabled as boolean.");return e.enabled}),C=`Clanker protocol ${i}: ${o} ${JSON.stringify(A)}. Owner/admin operation; renouncing ownership permanently removes owner-only controls. Withdrawals transfer the entire recorded asset balance; team fees go to the configured team recipient.`;return k([y(u,o,A,C)],t,C)}),b("store_fees",{token:{...a,description:"Address of the ERC-20 token whose fees are deposited."},recipient:{...a,description:"Address of the fee owner who can later claim these fees."},amount:{...T,description:'Amount of the token to deposit, in base units of that token (read its decimals). Example: "1000000000000000000" = 1 token at 18 decimals.'}},["token","recipient","amount"],async(e,t)=>{let o=c(e.token),r=c(e.recipient),n=v(e.amount);if(!n)throw new s("Provide a positive fee deposit amount.");if(await w().readContract({address:f.fee_locker.address,abi:h,functionName:"allowedDepositors",args:[t]})!==!0)throw new s("This wallet is not an authorized Clanker fee depositor.");let d=`Deposit exactly ${n} base units of token ${o} into Clanker fees for ${r}. Fee-on-transfer receipts may be smaller; the recorded recipient can later claim them.`,u=[p.approval(o,f.fee_locker.address,n.toString(),m),y(f.fee_locker.address,"storeFees",[r,o,n],d)];return k(u,t,d)}),b("claim_for",{token:{...a,description:"Address of the fee token to claim for the owner."},recipient:{...a,description:"Address of the fee owner whose collected fees are claimed; receipts go to this address."}},["token","recipient"],async(e,t)=>{let o=c(e.token),r=c(e.recipient),n=`Permissionlessly claim already-collected Clanker ${o} fees for ${r}; all receipts go to that fee owner, while ${t} pays gas.`;return k([y(f.fee_locker.address,"claim",[r,o],n)],t,n)})]}};export{N as a};
@@ -1 +1 @@
1
- import{c as D}from"./DXAPKN7H.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"./Y64GFBTA.js";import{a as w,e as _}from"./NWNYJ26T.js";import{b as y}from"./TI727O2H.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};
1
+ import{c as D}from"./NLC36QHL.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"./Y64GFBTA.js";import{a as w,e as _}from"./NWNYJ26T.js";import{b as y}from"./EWZFZUVF.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{b as s,f as C,i as k}from"./CJMVRV34.js";import{a as x}from"./B7WZJHIJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as F,getAddress as c,keccak256 as D,parseAbi as Z,zeroAddress as m,zeroHash as E}from"viem";var q="0x167ba3b15d65044b17c87154087d35fc5efde07538be66b804a54e63d6089136",N="0xc6848895ec12bfc54b1d011fdda88ab892250ccd0910f40dcf2025e17ac3225d",U=c(s.agentGateV2),M=c("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),K=c("0x8004BAa17C55a88189AE136b182e5fdA19dE9b63"),L=c("0x58daec3116aae6D93017bAAea7749052E8a04fA7"),j={schemaHash:q,termsBytes:160,healthFunction:"retired",supportsAge:!1,abi:x.agentGateV1.abi},Y={schemaHash:N,termsBytes:192,healthFunction:"suspended",supportsAge:!0,abi:x.agentGateV2.abi},ee=[{...j,address:c(s.agentGateV1),listed:!0,warning:null},{...Y,address:U,listed:!0,warning:null}],$=x.registry.abi,te=Z(["function isRevokedAdmission(address scope,address implementation) view returns (bool)"]),f=e=>{if(typeof e!="string"||!/^0x[0-9a-fA-F]{40}$/.test(e))throw new o("Hookr address read is incomplete.");return c(e)},d=(e,t=256)=>{if(typeof e!="bigint"&&(typeof e!="number"||!Number.isSafeInteger(e)))throw new o("Hookr integer read is incomplete.");let i=BigInt(e);if(i<0n||i>=1n<<BigInt(t))throw new o("Hookr integer read is outside its ABI bounds.");return i},_=e=>{if(!e||typeof e!="object"||Array.isArray(e))throw new o("Hookr admission read is incomplete.");return e},u=e=>{if(typeof e!="boolean")throw new o("Hookr boolean read is incomplete.");return e};function re(e,t){let i=f(e),a=ee.find(n=>n.address===i);if(a){if(t!==void 0&&t!==a.schemaHash)throw new o("Hookr listed gate terms layout changed.");return a}let r=t===q?j:t===N?Y:void 0;if(!r)throw new o("Hookr gate terms layout is unknown. Update Oak before using this gate.");return{...r,address:i,listed:!1,warning:"new gate, Oak has not read its code"}}function ne(e,t,i,a){let r=_(e),n=_(r.caps),g=d(r.gasLimit,32);if(u(a)||f(r.implementation)!==t.address||r.codeHash!==i||r.schemaHash!==t.schemaHash||d(r.kind,8)!==1n||d(r.phaseMask,8)!==1n||u(r.failOpen)||g<400000n||g>2000000n||d(n.maxLpFeePips,24)>50000n||d(n.maxQuoteTakePips,24)!==0n||d(n.maxSubjectTakeBps,16)!==0n)throw new o("Hookr gate admission is revoked or differs from the supported fail-closed BEFORE_SWAP caps.");return u(r.feeOnly),r}async function de(e,t,i=U,a={}){let r=f(i);await k(e,t,[s.registry,s.rootV1]);let n=(w,h=[],v=x.agentGateV2.abi)=>e.readContract({address:r,abi:v,functionName:w,args:h,blockNumber:t}),[g,O]=await Promise.all([e.getCode({address:r,blockNumber:t}),n("configSchemaHash")]);if(!g||g==="0x"||g.startsWith("0xef0100"))throw new o("Hookr gate runtime is unavailable or delegated.");let y=D(g),p=re(r,O),l=C[r];if(l&&l.codeHash!==y)throw new o("Hookr listed gate runtime drifted. Refresh the reviewed pin.");p.listed&&await k(e,t,[r]);let[b,H,z,T,W,Q,G,X,P,J,R,S]=await Promise.all([n("identity"),n("reputation"),n("poolManager"),n(p.healthFunction,[],p.abi),n("MIN_ADVISORY_GAS"),n("MAX_ADVISORY_GAS"),n("linkOf",[m]),n("isAgent",[m]),n("reviewerSet",[E]),n("terms",[s.rootV1,E],p.abi),n("scoreOf",[m,E]),n("explainLiquidity",[s.rootV1,E,m])]);if(f(b)!==M||f(H)!==K||f(z)!==c(s.poolManager)||d(W)!==400000n||d(Q)!==2000000n)throw new o("Hookr gate dependency wiring or gas bounds changed.");if(u(T),u(X),!Array.isArray(G)||G.length!==2||!Array.isArray(P)||P.length!==2||!Array.isArray(P[0])||typeof P[1]!="string"||!Array.isArray(R)||R.length!==2||typeof R[1]!="bigint"||!Array.isArray(S)||S.length!==2)throw new o("Hookr gate expected read is incomplete.");u(G[0]),d(G[1]),u(R[0]),u(S[0]),d(S[1],8);let A=_(J);u(A.bound);for(let[w,h]of[["flags",16],["minScore",32],["tierScore",32],["tierPips",24]])d(A[w],h);if(f(A.launcher),f(A.curatedRouter),typeof A.reviewers!="string"||!/^0x[0-9a-fA-F]{64}$/.test(A.reviewers))throw new o("Hookr gate reviewer ID read is incomplete.");if(p.supportsAge){let[w,h,v]=await Promise.all([n("positionManager"),n("ageOf",[m]),n("pins")]);d(A.minAge,32),d(h);let I=_(v);if(f(w)!==L||["identityCode","identityVersion","reputationCode","reputationVersion"].some(B=>typeof I[B]!="string"||!/^0x[0-9a-fA-F]{64}$/.test(I[B])))throw new o("Hookr gate position manager or registry pins are incomplete.");await k(e,t,[L,M,K])}let V=null;if(a.requireAdmission!==!1||!p.listed){let[w,h]=await Promise.all([e.readContract({address:c(s.registry),abi:$,functionName:"admission",args:[c(s.rootV1),r],blockNumber:t}),e.readContract({address:c(s.registry),abi:te,functionName:"isRevokedAdmission",args:[c(s.rootV1),r],blockNumber:t})]);V=ne(w,p,y,h)}return{profile:p,codeHash:y,admission:V,inactive:u(T),warnings:p.warning?[p.warning]:[]}}function ce(e,t){let i=[{type:"uint16"},{type:"uint32"},{type:"uint32"},{type:"uint24"},{type:"bytes32"}];if(!e.supportsAge&&(t.minAge??0)!==0)throw new o("The legacy Hookr gate has no link-age rule.");return e.supportsAge?F([...i,{type:"uint32"}],[t.flags,t.minScore,t.tierScore,t.tierPips,t.reviewers,t.minAge??0]):F(i,[t.flags,t.minScore,t.tierScore,t.tierPips,t.reviewers])}async function pe(e,t,i={}){await k(e,t,[s.registry,s.rootV1]);let a=await e.readContract({address:c(s.registry),abi:$,functionName:"activeLaneOf",args:[c(s.rootV1)],blockNumber:t});if(!Array.isArray(a)||a.length!==4||typeof a[1]!="string"||!/^0x[0-9a-fA-F]{64}$/.test(a[1]))throw new o("Hookr active executor read is incomplete.");let r=f(a[0]),n=a[1],g=d(a[2],32),O=d(a[3],16),y=C[r],p=r===c(s.recaptureExecutor)&&y?.codeHash===n,l=r!==m&&p&&g>=50000n&&g<=5000000n&&O<=2500n;if(l){let H=await e.getCode({address:r,blockNumber:t});l=!!H&&H!=="0x"&&D(H)===n}let b=i.hint&&f(i.hint)!==r?["Hookr executor hint differs from the chain; the chain result is used."]:[];if(l||b.push("Arb recapture on is unavailable: active executor or its caps are not in Oak\u2019s reviewed list. Recapture off remains available."),i.required&&!l)throw new o(b.join(" "));return{address:r,codeHash:n,gasCap:g.toString(),partnerBps:O.toString(),listed:p,allowed:l,source:"source not public",warnings:b}}export{q as a,N as b,U as c,M as d,K as e,L as f,ee as g,re as h,ne as i,de as j,ce as k,pe as l};
@@ -0,0 +1 @@
1
+ import{a as c,b as u,e as a}from"./45QP74CE.js";import{b as R}from"./3YNXQ3EZ.js";import{g as T}from"./IM7ZF7XZ.js";import{a as O,b as d,e as P}from"./GX2RCAHG.js";import{a as s,c as f,h as H}from"./XUDQYSPU.js";import{c as A}from"./6RVAV6BB.js";import{a as C}from"./ZTNBX4VH.js";import{d as L}from"./AZBTNUXF.js";import{a as h,b as m}from"./NUTTPUYJ.js";import{e as _}from"./3XY44BP5.js";import{m as n}from"./UMY6SP7C.js";import{a as k}from"./XSD5NL7J.js";var B=[...s,...O,"hookr_launch","hookr_action","hookr_revenue_action","hookr_addon_action","hookr_agent_link","hookr_reviewer_set","hookr_claim","hookr_swap",...c];async function F(o,r,i,p,e={}){if(f(o))return H(o,r,i,p);if(o==="hookr_swap")return _(r,i,p,e);if(u(o)){let t=await a(o,r,i,p,e);return{...t,terms:{...n(t.terms),gasLimits:t.txs.map(S=>S.gasLimit)}}}if(o==="hookr_agent_link")return h(r,i,p);if(o==="hookr_reviewer_set")return m(r,i,p);if(o==="hookr_claim")return A(r,i,p);if(d(o))return P(o,r,i,p);if(o==="hookr_launch")return T(r,i,p);if(o==="hookr_action")return L(r,i,p);if(o==="hookr_revenue_action")return R(r,i,p);if(o==="hookr_addon_action")return C(r,i,p);throw new k("This Hookr tool has no local action reconstruction.")}export{B as a,F as b};
@@ -1 +1 @@
1
- import{a as k}from"./A3PN3PK3.js";import{g as P}from"./NWNYJ26T.js";import{b}from"./TI727O2H.js";import{a as t}from"./XSD5NL7J.js";import{a as A}from"./JXOEJPJ4.js";import{getAddress as w,parseAbi as L}from"viem";var v={one_hour:3600n,six_hours:21600n,one_day:86400n,seven_days:604800n,thirty_days:2592000n,ninety_days:7776000n,one_year:31536000n},g=L(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewRedeem(uint256) view returns (uint256)"]);async function C(u,o,i){let a=0n,s=i.number,e=await u.getBlock({blockNumber:a});if(e.timestamp>o)throw new t("Longbow has insufficient chain history for this window.");for(let n=0;a+1n<s&&n<64;n++){let r=(a+s)/2n,c=await u.getBlock({blockNumber:r});if(c.number!==r||c.timestamp<e.timestamp||c.timestamp>i.timestamp)throw new t("Longbow historical block response is inconsistent.");c.timestamp<=o?(a=r,e=c):s=r}if(a+1n<s||e.number!==a)throw new t("Longbow historical block search exceeded its bound.");return e}async function _(u,o,i,a="six_hours"){let s=v[a];if(!Object.hasOwn(v,a)||!s)throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let e=u.clientFor(b);if(await e.getChainId()!==b)throw new t("Longbow APY assessment requires chain 4663.");let n=await e.getBlock({blockTag:"latest"});if(n.number===null||n.timestamp<s)throw new t("Longbow has insufficient chain history for this window.");let r=await C(e,n.timestamp-s,{number:n.number,timestamp:n.timestamp}),c=10n**27n,d=await Promise.all([r,n].map(async m=>{let[S,N,Y,f]=await Promise.all([e.readContract({address:o,abi:g,functionName:"asset",blockNumber:m.number}),e.readContract({address:o,abi:g,functionName:"decimals",blockNumber:m.number}),e.readContract({address:i.address,abi:g,functionName:"decimals",blockNumber:m.number}),e.readContract({address:o,abi:g,functionName:"previewRedeem",args:[c],blockNumber:m.number})]);if(w(S)!==w(i.address)||N!==18||Y!==i.decimals||typeof f!="bigint"||f<0n||f>=1n<<256n)throw new t("Longbow historical share price or token metadata is unavailable or invalid. No zero rate was inferred.");return f})),h=n.timestamp-r.timestamp;if(h<=0n||h>s+300n)throw new t("Longbow historical blocks do not cover the requested APY window within 300 seconds.");if(d[0]===0n)throw new t("Longbow starting share price is zero; a realized APY cannot be calculated.");let l=Number(d[1]-d[0])/Number(d[0]),p=Math.expm1(Math.log1p(l)*31536e3/Number(h));if(!Number.isFinite(p))throw new t("Longbow annualized share-price change is outside the supported numeric range.");let y=await k(e,o,n.number);return{chainId:b,vault:o,asset:{...i,address:w(i.address)},shareToken:{address:o,symbol:y,decimals:18,chainId:b},source:"Oak-computed on-chain",view:"apy",stale:!1,window:{lookback:a,requestedSeconds:s.toString(),elapsedSeconds:h.toString(),fromTimestamp:r.timestamp.toString(),toTimestamp:n.timestamp.toString(),fromBlock:r.number.toString(),toBlock:n.number.toString()},sharePrice:{shareUnits:c.toString(),startAssets:d[0].toString(),endAssets:d[1].toString(),assetDecimals:i.decimals},data:{annualYieldFraction:String(p),annualYieldPercent:String(p*100),lookback:a,basis:"Oak-computed realized APY: (end share price / start share price)^(31536000 / elapsed seconds) - 1, using ERC-4626 previewRedeem at two pinned blocks."},caveat:"Historical share-price change includes what the vault accounts for in previewRedeem, excludes external rewards and gas, and is not a promised return. Archive RPC history is required; missing history is not zero APY."}}async function I(u,o,i,a){if(Object.keys(a).some(d=>!["view","lookback"].includes(d)))throw new t("Longbow APY takes a lookback, not pagination.");let s=a.lookback??"six_hours";if(typeof s!="string"||!Object.hasOwn(v,s))throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let[e,n]=await Promise.allSettled([O(u,o,i,{view:"published_apy"}),_(u,o,i,s)]),r=e.status==="fulfilled"&&!e.value.stale?e.value:void 0;if(!r&&n.status==="rejected")throw new t(`Longbow APY is unavailable: the vendor figure is unavailable or stale, and the on-chain window could not be measured. ${u.plainError(n.reason)}`);return{...r??(n.status==="fulfilled"?n.value:void 0),view:"apy",shown:r?"Longbow vendor":"Oak-computed on-chain",realized:n.status==="fulfilled"?n.value:null,published:e.status==="fulfilled"?e.value:null,warnings:[...r?[]:["Longbow vendor APY is unavailable or stale; showing Oak-computed realized APY."],...n.status==="rejected"?["Oak-computed APY is unavailable: the archive RPC window could not be measured."]:[]]}}async function O(u,o,i,a){if(Object.keys(a).some(m=>m!=="view")||a.view!=="published_apy")throw new t("published_apy takes no historical lookback, cursor or limit.");let s=u.clientFor(b);if(await s.getChainId()!==b)throw new t("Longbow APY assessment requires chain 4663.");let[e,n]=await Promise.all([s.getBlock(),s.readContract({address:o,abi:L(["function asset() view returns (address)"]),functionName:"asset"})]);if(w(n)!==w(i.address))throw new t("Longbow vault does not use the pinned asset.");let r="https://longbow.credit/api/v2/vaults",c=await u.http(r,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(15e3)});if(!c.ok)throw new t(`Longbow published APY HTTP ${c.status}; the rate is unavailable.`);let d=await c.json();if(!d||typeof d!="object"||!Number.isSafeInteger(d.asOf)||Number(d.asOf)<0||!Array.isArray(d.vaults)||d.vaults.length>100)throw new t("Longbow published APY response has an invalid timestamp or vault inventory.");let h=d.vaults.filter(m=>m&&typeof m=="object"&&typeof m.address=="string"&&P(String(m.address),o));if(h.length!==1)throw new t("Longbow published APY omitted or duplicated this vault; no zero rate is inferred.");let l=h[0];if(l.error||typeof l.asset!="string"||w(l.asset)!==w(i.address)||l.decimals!==i.decimals||typeof l.apy!="number"||!Number.isFinite(l.apy)||l.apy<-100||typeof l.apyBasis!="string"||l.apyBasis.length>64)throw new t("Longbow published APY asset, units, basis or rate is invalid.");let p=BigInt(Number(d.asOf)),y=await k(s,o,e.number);return{chainId:b,vault:o,asset:{...i,address:w(i.address)},shareToken:{address:o,symbol:y,decimals:18,chainId:b},sourceUrl:r,view:"published_apy",asOf:p.toString(),stale:e.timestamp>p+900n||p>e.timestamp+60n,data:{annualYieldPercent:String(l.apy),annualYieldFraction:String(l.apy/100),basis:A(l.apyBasis)},caveat:"Longbow publisher quote, not a realized Morpho lookback series or a promised return. The app formats this field directly as percent (0.03 means 0.03%, not 3%). No bonus, future payout or fee inclusion is inferred. Onchain book and fees remain available through longbow_details."}}export{_ as a,I as b,O as c};
1
+ import{a as k}from"./A3PN3PK3.js";import{g as P}from"./NWNYJ26T.js";import{b}from"./EWZFZUVF.js";import{a as t}from"./XSD5NL7J.js";import{a as A}from"./JXOEJPJ4.js";import{getAddress as w,parseAbi as L}from"viem";var v={one_hour:3600n,six_hours:21600n,one_day:86400n,seven_days:604800n,thirty_days:2592000n,ninety_days:7776000n,one_year:31536000n},g=L(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewRedeem(uint256) view returns (uint256)"]);async function C(u,o,i){let a=0n,s=i.number,e=await u.getBlock({blockNumber:a});if(e.timestamp>o)throw new t("Longbow has insufficient chain history for this window.");for(let n=0;a+1n<s&&n<64;n++){let r=(a+s)/2n,c=await u.getBlock({blockNumber:r});if(c.number!==r||c.timestamp<e.timestamp||c.timestamp>i.timestamp)throw new t("Longbow historical block response is inconsistent.");c.timestamp<=o?(a=r,e=c):s=r}if(a+1n<s||e.number!==a)throw new t("Longbow historical block search exceeded its bound.");return e}async function _(u,o,i,a="six_hours"){let s=v[a];if(!Object.hasOwn(v,a)||!s)throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let e=u.clientFor(b);if(await e.getChainId()!==b)throw new t("Longbow APY assessment requires chain 4663.");let n=await e.getBlock({blockTag:"latest"});if(n.number===null||n.timestamp<s)throw new t("Longbow has insufficient chain history for this window.");let r=await C(e,n.timestamp-s,{number:n.number,timestamp:n.timestamp}),c=10n**27n,d=await Promise.all([r,n].map(async m=>{let[S,N,Y,f]=await Promise.all([e.readContract({address:o,abi:g,functionName:"asset",blockNumber:m.number}),e.readContract({address:o,abi:g,functionName:"decimals",blockNumber:m.number}),e.readContract({address:i.address,abi:g,functionName:"decimals",blockNumber:m.number}),e.readContract({address:o,abi:g,functionName:"previewRedeem",args:[c],blockNumber:m.number})]);if(w(S)!==w(i.address)||N!==18||Y!==i.decimals||typeof f!="bigint"||f<0n||f>=1n<<256n)throw new t("Longbow historical share price or token metadata is unavailable or invalid. No zero rate was inferred.");return f})),h=n.timestamp-r.timestamp;if(h<=0n||h>s+300n)throw new t("Longbow historical blocks do not cover the requested APY window within 300 seconds.");if(d[0]===0n)throw new t("Longbow starting share price is zero; a realized APY cannot be calculated.");let l=Number(d[1]-d[0])/Number(d[0]),p=Math.expm1(Math.log1p(l)*31536e3/Number(h));if(!Number.isFinite(p))throw new t("Longbow annualized share-price change is outside the supported numeric range.");let y=await k(e,o,n.number);return{chainId:b,vault:o,asset:{...i,address:w(i.address)},shareToken:{address:o,symbol:y,decimals:18,chainId:b},source:"Oak-computed on-chain",view:"apy",stale:!1,window:{lookback:a,requestedSeconds:s.toString(),elapsedSeconds:h.toString(),fromTimestamp:r.timestamp.toString(),toTimestamp:n.timestamp.toString(),fromBlock:r.number.toString(),toBlock:n.number.toString()},sharePrice:{shareUnits:c.toString(),startAssets:d[0].toString(),endAssets:d[1].toString(),assetDecimals:i.decimals},data:{annualYieldFraction:String(p),annualYieldPercent:String(p*100),lookback:a,basis:"Oak-computed realized APY: (end share price / start share price)^(31536000 / elapsed seconds) - 1, using ERC-4626 previewRedeem at two pinned blocks."},caveat:"Historical share-price change includes what the vault accounts for in previewRedeem, excludes external rewards and gas, and is not a promised return. Archive RPC history is required; missing history is not zero APY."}}async function I(u,o,i,a){if(Object.keys(a).some(d=>!["view","lookback"].includes(d)))throw new t("Longbow APY takes a lookback, not pagination.");let s=a.lookback??"six_hours";if(typeof s!="string"||!Object.hasOwn(v,s))throw new t("Choose a finite Longbow APY lookback from one_hour to one_year; inception is unavailable.");let[e,n]=await Promise.allSettled([O(u,o,i,{view:"published_apy"}),_(u,o,i,s)]),r=e.status==="fulfilled"&&!e.value.stale?e.value:void 0;if(!r&&n.status==="rejected")throw new t(`Longbow APY is unavailable: the vendor figure is unavailable or stale, and the on-chain window could not be measured. ${u.plainError(n.reason)}`);return{...r??(n.status==="fulfilled"?n.value:void 0),view:"apy",shown:r?"Longbow vendor":"Oak-computed on-chain",realized:n.status==="fulfilled"?n.value:null,published:e.status==="fulfilled"?e.value:null,warnings:[...r?[]:["Longbow vendor APY is unavailable or stale; showing Oak-computed realized APY."],...n.status==="rejected"?["Oak-computed APY is unavailable: the archive RPC window could not be measured."]:[]]}}async function O(u,o,i,a){if(Object.keys(a).some(m=>m!=="view")||a.view!=="published_apy")throw new t("published_apy takes no historical lookback, cursor or limit.");let s=u.clientFor(b);if(await s.getChainId()!==b)throw new t("Longbow APY assessment requires chain 4663.");let[e,n]=await Promise.all([s.getBlock(),s.readContract({address:o,abi:L(["function asset() view returns (address)"]),functionName:"asset"})]);if(w(n)!==w(i.address))throw new t("Longbow vault does not use the pinned asset.");let r="https://longbow.credit/api/v2/vaults",c=await u.http(r,{method:"GET",headers:{accept:"application/json"},redirect:"error",signal:AbortSignal.timeout(15e3)});if(!c.ok)throw new t(`Longbow published APY HTTP ${c.status}; the rate is unavailable.`);let d=await c.json();if(!d||typeof d!="object"||!Number.isSafeInteger(d.asOf)||Number(d.asOf)<0||!Array.isArray(d.vaults)||d.vaults.length>100)throw new t("Longbow published APY response has an invalid timestamp or vault inventory.");let h=d.vaults.filter(m=>m&&typeof m=="object"&&typeof m.address=="string"&&P(String(m.address),o));if(h.length!==1)throw new t("Longbow published APY omitted or duplicated this vault; no zero rate is inferred.");let l=h[0];if(l.error||typeof l.asset!="string"||w(l.asset)!==w(i.address)||l.decimals!==i.decimals||typeof l.apy!="number"||!Number.isFinite(l.apy)||l.apy<-100||typeof l.apyBasis!="string"||l.apyBasis.length>64)throw new t("Longbow published APY asset, units, basis or rate is invalid.");let p=BigInt(Number(d.asOf)),y=await k(s,o,e.number);return{chainId:b,vault:o,asset:{...i,address:w(i.address)},shareToken:{address:o,symbol:y,decimals:18,chainId:b},sourceUrl:r,view:"published_apy",asOf:p.toString(),stale:e.timestamp>p+900n||p>e.timestamp+60n,data:{annualYieldPercent:String(l.apy),annualYieldFraction:String(l.apy/100),basis:A(l.apyBasis)},caveat:"Longbow publisher quote, not a realized Morpho lookback series or a promised return. The app formats this field directly as percent (0.03 means 0.03%, not 3%). No bonus, future payout or fee inclusion is inferred. Onchain book and fees remain available through longbow_details."}}export{_ as a,I as b,O as c};
@@ -1 +1 @@
1
- import{a as z,b as K}from"./LIUXNOLP.js";import{a as q}from"./VVAM3EAK.js";import{a as _,b as D}from"./43LI5NKJ.js";import{b as B,c as G,d as O}from"./IOYRL6AY.js";import{b as R,c as M,j as U,t as E}from"./TI727O2H.js";import{a as m,b as H,c as I,e as S}from"./XSD5NL7J.js";import{decodeFunctionResult as ee,encodeFunctionData as te,erc20Abi as V,getAddress as L,isAddress as ne,toEventSelector as re,toHex as T,zeroAddress as se}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ae(e){let s=e.toLowerCase();return s===se||s===C?C:e}var oe=re("Transfer(address,address,uint256)"),W="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x(){throw new m("The endpoint returned an unexpected simulation response.")}function j(e,s,l){(!Array.isArray(e)||e.length!==1||!p(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==s+l)&&x();let d=e[0].calls,a=d.slice(0,s).map(n=>{if(!p(n)||n.status!=="0x1"||n.error||!Array.isArray(n.logs)||n.logs.length!==0||typeof n.returnData!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n.returnData))throw new m("Preview auxiliary read failed or returned invalid data.");return n.returnData});return{result:[{calls:d.slice(s)}],readResults:a}}async function N(e,s,l,d){let a=await e.getChainId();if(a!==s)throw new m(`Preview is on chain ${s}, but the endpoint reports chain ${a}.`);let n=await z(e),t=await K(e,n);if(n.number===null||typeof n.baseFeePerGas!="bigint"||n.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new m("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let r=t<n.baseFeePerGas?n.baseFeePerGas:t,A=B(n.gasLimit),c=l.map(u=>({from:d,to:u.to,data:u.data,value:T(BigInt(u.value)),gasPrice:T(r),gas:T(A)})),y=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:T(n.baseFeePerGas)},calls:c}],validation:!1,traceTransfers:!0},T(n.number)]},{retryCount:0});try{return await y()}catch(u){if(!I(u))throw u;let g=await e.getBalance({address:d,blockNumber:n.number}),w=await Promise.all(l.map(o=>e.estimateGas({account:d,to:o.to,data:o.data,value:BigInt(o.value),gas:A,blockNumber:n.number}).catch(()=>{}))),k=g;for(let[o,i]of c.entries()){let f=BigInt(i.value),F=O(B(n.gasLimit,w[o]),k,f,r,d,s),h=w[o];if(h!==void 0&&h>F)throw new m(G(d,s,g-k+f+h*r,g));i.gas=T(F),k-=f}let v=await y();if(Array.isArray(v)&&p(v[0])&&Array.isArray(v[0].calls))for(let[o,i]of v[0].calls.entries()){let f=c[o];if(f&&p(i)&&i.status==="0x0"&&typeof i.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(i.gasUsed)&&BigInt(i.gasUsed)>=BigInt(f.gas))throw new m(G(d,s,BigInt(f.value)+(BigInt(f.gas)+1n)*r,g))}return v}}function J(e,s,l,d){(!Array.isArray(e)||e.length!==1||!p(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==s)&&x();let a=new Map;for(let[n,t]of e[0].calls.entries()){if(p(t)||x(),t.status==="0x0")throw new m(`Preview call ${n+1} on chain ${d} reverted. ${S(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&x();for(let r of t.logs){if((!p(r)||!Array.isArray(r.topics))&&x(),typeof r.topics[0]!="string"||r.topics[0].toLowerCase()!==oe||r.topics.length===4)continue;(r.topics.length!==3||typeof r.address!="string"||!ne(r.address,{strict:!1})||typeof r.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(r.data)||!r.topics.slice(1).every(w=>typeof w=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(w)))&&x();let A=r.topics[1].slice(-40).toLowerCase(),c=r.topics[2].slice(-40).toLowerCase(),y=l.slice(2).toLowerCase(),u=BigInt(r.data),g=(c===y?u:0n)-(A===y?u:0n);if(g!==0n){let w=ae(r.address.toLowerCase());a.set(w,(a.get(w)??0n)+g)}}}return a}async function Q(e,s,l,d){let a=s===R?E.mainnet:s===M?E.testnet:void 0,n=a&&[{address:a.usdg,symbol:"USDG",decimals:6},{address:a.weth,symbol:"WETH",decimals:18},...s===R?[{address:U[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(r=>r.address.toLowerCase()===e);if(n)return{...n,address:L(e),chainId:s};let t;if(e===C){let r=l.chain?.nativeCurrency??(s===4663?{symbol:"ETH",decimals:18}:void 0);if(!r)throw new m(`Native token metadata is unavailable for chain ${s}.`);t={address:e,chainId:s,symbol:r.symbol,decimals:r.decimals}}else if(d)t=await d(e,s,l);else{let r=await q(l,s,e,"decimals");t={address:e,chainId:s,symbol:e,decimals:r}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==s||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new m(`Invalid token metadata for ${e} on chain ${s}.`);return{address:e===C?e:L(e),chainId:s,symbol:e===C?t.symbol:L(e),decimals:t.decimals}}function ge(e){return async(s,l,d)=>{_(l);let a=s.map(D),n=(d?.reads??[]).map(c=>D({...c,value:"0",description:"Read before simulated transactions."})),t=a[0]?.chainId;if(t===void 0&&n.length)throw new m("Preview auxiliary reads require a transaction bundle.");if(t===void 0)return{txs:a,changes:[],summary:W};let r=[...n,...a].find(c=>c.chainId!==t);if(r)throw new m(`Preview cannot combine chain ${t} with chain ${r.chainId}. Preview each chain separately.`);let A=n.length?[...n,...a]:a;try{let c=e.clientFor(t),y;try{y=await N(c,t,A,l)}catch(o){if(!H(o,-32601,-32004)||!e.anvilFor)throw o;c=await e.anvilFor(t),y=await N(c,t,A,l)}let u;n.length&&({result:y,readResults:u}=j(y,n.length,a.length));let g=J(y,a.length,l,t),w=new Map,k=[];for(let[o,i]of g)if(i!==0n)try{w.set(o,await Q(o,t,c,e.tokenFor))}catch(f){if(o===C||e.tokenFor||(await c.getCode({address:o})??"0x")!=="0x")throw f;k.push(o)}if(k.length){let o=k.flatMap(h=>["symbol","decimals"].map(b=>D({to:h,data:te({abi:V,functionName:b}),value:"0",chainId:t,description:`Read simulated token ${b}.`}))),i=await N(c,t,[...A,...o],l);if(u){let h=j(i,u.length,a.length+o.length);if(h.readResults.some((b,$)=>b!==u[$]))throw new m("Simulation changed while reading new-token metadata. Refresh the preview.");i=h.result}(!Array.isArray(i)||i.length!==1||!p(i[0])||!Array.isArray(i[0].calls)||i[0].calls.length!==a.length+o.length)&&x();let f=i[0].calls,F=J([{calls:f.slice(0,a.length)}],a.length,l,t);if(g.size!==F.size||[...g].some(([h,b])=>F.get(h)!==b))throw new m("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[h,b]of k.entries()){let $=(Y,Z)=>{let P=f[a.length+h*2+Z];if(!p(P)||P.status!=="0x1"||P.error||typeof P.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(P.returnData))throw new m(`Invalid simulated token metadata for ${b} on chain ${t}.`);return ee({abi:V,functionName:Y,data:P.returnData})},X={address:b,chainId:t,symbol:$("symbol",0),decimals:$("decimals",1)};w.set(b,await Q(b,t,c,async()=>X))}}let v=[...g].filter(([,o])=>o!==0n).map(([o,i])=>({token:w.get(o),amount:i.toString()}));return{txs:a,changes:v,summary:W,...u?{readResults:u}:{}}}catch(c){throw new m(`Preview on chain ${t} failed: ${S(c)}`)}}}export{C as a,ae as b,ge as c};
1
+ import{a as z,b as K}from"./LIUXNOLP.js";import{a as q}from"./5N6YJFFA.js";import{a as _,b as D}from"./43LI5NKJ.js";import{b as B,c as G,d as O}from"./IOYRL6AY.js";import{b as R,c as M,j as U,t as E}from"./EWZFZUVF.js";import{a as m,b as H,c as I,e as S}from"./XSD5NL7J.js";import{decodeFunctionResult as ee,encodeFunctionData as te,erc20Abi as V,getAddress as L,isAddress as ne,toEventSelector as re,toHex as T,zeroAddress as se}from"viem";var C="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";function ae(e){let s=e.toLowerCase();return s===se||s===C?C:e}var oe=re("Transfer(address,address,uint256)"),W="Preview note: simulation transfer-based token changes exclude gas and do not prove external settlement.";function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function x(){throw new m("The endpoint returned an unexpected simulation response.")}function j(e,s,l){(!Array.isArray(e)||e.length!==1||!p(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==s+l)&&x();let d=e[0].calls,a=d.slice(0,s).map(n=>{if(!p(n)||n.status!=="0x1"||n.error||!Array.isArray(n.logs)||n.logs.length!==0||typeof n.returnData!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n.returnData))throw new m("Preview auxiliary read failed or returned invalid data.");return n.returnData});return{result:[{calls:d.slice(s)}],readResults:a}}async function N(e,s,l,d){let a=await e.getChainId();if(a!==s)throw new m(`Preview is on chain ${s}, but the endpoint reports chain ${a}.`);let n=await z(e),t=await K(e,n);if(n.number===null||typeof n.baseFeePerGas!="bigint"||n.baseFeePerGas<0n||typeof t!="bigint"||t<0n)throw new m("Current block base fee and gas price are unavailable or inconsistent. Retry the preview.");let r=t<n.baseFeePerGas?n.baseFeePerGas:t,A=B(n.gasLimit),c=l.map(u=>({from:d,to:u.to,data:u.data,value:T(BigInt(u.value)),gasPrice:T(r),gas:T(A)})),y=()=>e.request({method:"eth_simulateV1",params:[{blockStateCalls:[{blockOverrides:{baseFeePerGas:T(n.baseFeePerGas)},calls:c}],validation:!1,traceTransfers:!0},T(n.number)]},{retryCount:0});try{return await y()}catch(u){if(!I(u))throw u;let g=await e.getBalance({address:d,blockNumber:n.number}),w=await Promise.all(l.map(o=>e.estimateGas({account:d,to:o.to,data:o.data,value:BigInt(o.value),gas:A,blockNumber:n.number}).catch(()=>{}))),k=g;for(let[o,i]of c.entries()){let f=BigInt(i.value),F=O(B(n.gasLimit,w[o]),k,f,r,d,s),h=w[o];if(h!==void 0&&h>F)throw new m(G(d,s,g-k+f+h*r,g));i.gas=T(F),k-=f}let v=await y();if(Array.isArray(v)&&p(v[0])&&Array.isArray(v[0].calls))for(let[o,i]of v[0].calls.entries()){let f=c[o];if(f&&p(i)&&i.status==="0x0"&&typeof i.gasUsed=="string"&&/^0x[0-9a-f]+$/i.test(i.gasUsed)&&BigInt(i.gasUsed)>=BigInt(f.gas))throw new m(G(d,s,BigInt(f.value)+(BigInt(f.gas)+1n)*r,g))}return v}}function J(e,s,l,d){(!Array.isArray(e)||e.length!==1||!p(e[0])||!Array.isArray(e[0].calls)||e[0].calls.length!==s)&&x();let a=new Map;for(let[n,t]of e[0].calls.entries()){if(p(t)||x(),t.status==="0x0")throw new m(`Preview call ${n+1} on chain ${d} reverted. ${S(t.error)}`);(t.status!=="0x1"||t.error||!Array.isArray(t.logs))&&x();for(let r of t.logs){if((!p(r)||!Array.isArray(r.topics))&&x(),typeof r.topics[0]!="string"||r.topics[0].toLowerCase()!==oe||r.topics.length===4)continue;(r.topics.length!==3||typeof r.address!="string"||!ne(r.address,{strict:!1})||typeof r.data!="string"||!/^0x[0-9a-fA-F]{64}$/.test(r.data)||!r.topics.slice(1).every(w=>typeof w=="string"&&/^0x0{24}[0-9a-fA-F]{40}$/.test(w)))&&x();let A=r.topics[1].slice(-40).toLowerCase(),c=r.topics[2].slice(-40).toLowerCase(),y=l.slice(2).toLowerCase(),u=BigInt(r.data),g=(c===y?u:0n)-(A===y?u:0n);if(g!==0n){let w=ae(r.address.toLowerCase());a.set(w,(a.get(w)??0n)+g)}}}return a}async function Q(e,s,l,d){let a=s===R?E.mainnet:s===M?E.testnet:void 0,n=a&&[{address:a.usdg,symbol:"USDG",decimals:6},{address:a.weth,symbol:"WETH",decimals:18},...s===R?[{address:U[4663].meridian.CollateralToken_USDe.address,symbol:"USDe",decimals:18}]:[]].find(r=>r.address.toLowerCase()===e);if(n)return{...n,address:L(e),chainId:s};let t;if(e===C){let r=l.chain?.nativeCurrency??(s===4663?{symbol:"ETH",decimals:18}:void 0);if(!r)throw new m(`Native token metadata is unavailable for chain ${s}.`);t={address:e,chainId:s,symbol:r.symbol,decimals:r.decimals}}else if(d)t=await d(e,s,l);else{let r=await q(l,s,e,"decimals");t={address:e,chainId:s,symbol:e,decimals:r}}if(!t||typeof t.address!="string"||t.address.toLowerCase()!==e||t.chainId!==s||typeof t.symbol!="string"||!t.symbol.trim()||!Number.isInteger(t.decimals)||t.decimals<0||t.decimals>255)throw new m(`Invalid token metadata for ${e} on chain ${s}.`);return{address:e===C?e:L(e),chainId:s,symbol:e===C?t.symbol:L(e),decimals:t.decimals}}function ge(e){return async(s,l,d)=>{_(l);let a=s.map(D),n=(d?.reads??[]).map(c=>D({...c,value:"0",description:"Read before simulated transactions."})),t=a[0]?.chainId;if(t===void 0&&n.length)throw new m("Preview auxiliary reads require a transaction bundle.");if(t===void 0)return{txs:a,changes:[],summary:W};let r=[...n,...a].find(c=>c.chainId!==t);if(r)throw new m(`Preview cannot combine chain ${t} with chain ${r.chainId}. Preview each chain separately.`);let A=n.length?[...n,...a]:a;try{let c=e.clientFor(t),y;try{y=await N(c,t,A,l)}catch(o){if(!H(o,-32601,-32004)||!e.anvilFor)throw o;c=await e.anvilFor(t),y=await N(c,t,A,l)}let u;n.length&&({result:y,readResults:u}=j(y,n.length,a.length));let g=J(y,a.length,l,t),w=new Map,k=[];for(let[o,i]of g)if(i!==0n)try{w.set(o,await Q(o,t,c,e.tokenFor))}catch(f){if(o===C||e.tokenFor||(await c.getCode({address:o})??"0x")!=="0x")throw f;k.push(o)}if(k.length){let o=k.flatMap(h=>["symbol","decimals"].map(b=>D({to:h,data:te({abi:V,functionName:b}),value:"0",chainId:t,description:`Read simulated token ${b}.`}))),i=await N(c,t,[...A,...o],l);if(u){let h=j(i,u.length,a.length+o.length);if(h.readResults.some((b,$)=>b!==u[$]))throw new m("Simulation changed while reading new-token metadata. Refresh the preview.");i=h.result}(!Array.isArray(i)||i.length!==1||!p(i[0])||!Array.isArray(i[0].calls)||i[0].calls.length!==a.length+o.length)&&x();let f=i[0].calls,F=J([{calls:f.slice(0,a.length)}],a.length,l,t);if(g.size!==F.size||[...g].some(([h,b])=>F.get(h)!==b))throw new m("Simulation changed while reading new-token metadata. Refresh the preview.");for(let[h,b]of k.entries()){let $=(Y,Z)=>{let P=f[a.length+h*2+Z];if(!p(P)||P.status!=="0x1"||P.error||typeof P.returnData!="string"||!/^0x[0-9a-fA-F]+$/.test(P.returnData))throw new m(`Invalid simulated token metadata for ${b} on chain ${t}.`);return ee({abi:V,functionName:Y,data:P.returnData})},X={address:b,chainId:t,symbol:$("symbol",0),decimals:$("decimals",1)};w.set(b,await Q(b,t,c,async()=>X))}}let v=[...g].filter(([,o])=>o!==0n).map(([o,i])=>({token:w.get(o),amount:i.toString()}));return{txs:a,changes:v,summary:W,...u?{readResults:u}:{}}}catch(c){throw new m(`Preview on chain ${t} failed: ${S(c)}`)}}}export{C as a,ae as b,ge as c};