@oakagentkit/core 0.3.4 → 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 (564) 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/actions.d.ts +13 -1
  21. package/build/dist/api/modules/chop/actions.js +1 -1
  22. package/build/dist/api/modules/chop/checks.js +1 -1
  23. package/build/dist/api/modules/chop/copy.d.ts +1 -0
  24. package/build/dist/api/modules/chop/copy.js +1 -1
  25. package/build/dist/api/modules/chop/display.d.ts +36 -0
  26. package/build/dist/api/modules/chop/display.js +1 -0
  27. package/build/dist/api/modules/chop/guard.js +1 -1
  28. package/build/dist/api/modules/chop/index.js +1 -1
  29. package/build/dist/api/modules/chop/pins.d.ts +1 -0
  30. package/build/dist/api/modules/chop/pins.js +1 -1
  31. package/build/dist/api/modules/chop/positions.js +1 -1
  32. package/build/dist/api/modules/chop/reader.d.ts +6 -1
  33. package/build/dist/api/modules/chop/reader.js +1 -1
  34. package/build/dist/api/modules/chop/types.d.ts +7 -0
  35. package/build/dist/api/modules/chop/unfarm.d.ts +16 -0
  36. package/build/dist/api/modules/chop/unfarm.js +1 -0
  37. package/build/dist/api/modules/clanker/extensions.js +1 -1
  38. package/build/dist/api/modules/clanker/index.js +1 -1
  39. package/build/dist/api/modules/clanker/manage.js +1 -1
  40. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  41. package/build/dist/api/modules/clanker/protocol.js +1 -1
  42. package/build/dist/api/modules/clanker/state.js +1 -1
  43. package/build/dist/api/modules/earn/index.js +1 -1
  44. package/build/dist/api/modules/erc8004/common.js +1 -1
  45. package/build/dist/api/modules/erc8004/domain.js +1 -1
  46. package/build/dist/api/modules/erc8004/index.js +1 -1
  47. package/build/dist/api/modules/erc8004/management.js +1 -1
  48. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  49. package/build/dist/api/modules/erc8004/services.js +1 -1
  50. package/build/dist/api/modules/erc8004/thesis.js +1 -1
  51. package/build/dist/api/modules/erc8004/validation.js +1 -1
  52. package/build/dist/api/modules/factor/actions.js +1 -1
  53. package/build/dist/api/modules/factor/api.js +1 -1
  54. package/build/dist/api/modules/factor/checks.js +1 -1
  55. package/build/dist/api/modules/factor/copy.d.ts +11 -11
  56. package/build/dist/api/modules/factor/copy.js +1 -1
  57. package/build/dist/api/modules/factor/guard.js +1 -1
  58. package/build/dist/api/modules/factor/index.js +1 -1
  59. package/build/dist/api/modules/factor/reader.js +1 -1
  60. package/build/dist/api/modules/fobo/client.js +1 -1
  61. package/build/dist/api/modules/fobo/index.js +1 -1
  62. package/build/dist/api/modules/fobo/intent.js +1 -1
  63. package/build/dist/api/modules/fobo/steps.js +1 -1
  64. package/build/dist/api/modules/fobo/verify.js +1 -1
  65. package/build/dist/api/modules/gloam/index.js +1 -1
  66. package/build/dist/api/modules/grove/index.js +1 -1
  67. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  68. package/build/dist/api/modules/heyresearch/index.js +1 -1
  69. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  70. package/build/dist/api/modules/heyresearch/scan.js +1 -1
  71. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  72. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  73. package/build/dist/api/modules/hoodag/index.js +1 -1
  74. package/build/dist/api/modules/hoodag/management.js +1 -1
  75. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  76. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  77. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  78. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  79. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  80. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  81. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  82. package/build/dist/api/modules/hoodlock/index.js +1 -1
  83. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  84. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  85. package/build/dist/api/modules/hoodlock/public.js +1 -1
  86. package/build/dist/api/modules/hookr/actions.d.ts +39 -2
  87. package/build/dist/api/modules/hookr/actions.js +1 -1
  88. package/build/dist/api/modules/hookr/addons.js +1 -1
  89. package/build/dist/api/modules/hookr/agent-gate.d.ts +14 -2
  90. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  91. package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
  92. package/build/dist/api/modules/hookr/agent-link.js +1 -0
  93. package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
  94. package/build/dist/api/modules/hookr/api-client.js +1 -0
  95. package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
  96. package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
  97. package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
  98. package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
  99. package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
  100. package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
  101. package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
  102. package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
  103. package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
  104. package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
  105. package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
  106. package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
  107. package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
  108. package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
  109. package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
  110. package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
  111. package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
  112. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
  113. package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
  114. package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
  115. package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
  116. package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
  117. package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
  118. package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
  119. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
  120. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
  121. package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
  122. package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
  123. package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
  124. package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
  125. package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
  126. package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
  127. package/build/dist/api/modules/hookr/claims.d.ts +53 -0
  128. package/build/dist/api/modules/hookr/claims.js +1 -0
  129. package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
  130. package/build/dist/api/modules/hookr/contracts.js +1 -1
  131. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  132. package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
  133. package/build/dist/api/modules/hookr/discovery.js +1 -1
  134. package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
  135. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  136. package/build/dist/api/modules/hookr/gas.d.ts +48 -0
  137. package/build/dist/api/modules/hookr/gas.js +1 -0
  138. package/build/dist/api/modules/hookr/gates.d.ts +51 -0
  139. package/build/dist/api/modules/hookr/gates.js +1 -0
  140. package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
  141. package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
  142. package/build/dist/api/modules/hookr/index.d.ts +4 -2
  143. package/build/dist/api/modules/hookr/index.js +1 -1
  144. package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
  145. package/build/dist/api/modules/hookr/jobs.js +1 -0
  146. package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
  147. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  148. package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
  149. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  150. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  151. package/build/dist/api/modules/hookr/launch.d.ts +24 -0
  152. package/build/dist/api/modules/hookr/launch.js +1 -1
  153. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  154. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  155. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  156. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  157. package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
  158. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  159. package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
  160. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
  161. package/build/dist/api/modules/hookr/pins.d.ts +5 -0
  162. package/build/dist/api/modules/hookr/pins.js +1 -1
  163. package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
  164. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
  165. package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
  166. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  167. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  168. package/build/dist/api/modules/hookr/relay.js +1 -1
  169. package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
  170. package/build/dist/api/modules/hookr/revenue.js +1 -1
  171. package/build/dist/api/modules/hookr/scan.d.ts +25 -0
  172. package/build/dist/api/modules/hookr/scan.js +1 -0
  173. package/build/dist/api/modules/hookr/swap.d.ts +161 -0
  174. package/build/dist/api/modules/hookr/swap.js +1 -0
  175. package/build/dist/api/modules/kyberswap/index.js +1 -1
  176. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  177. package/build/dist/api/modules/layerbank/abi.js +1 -1
  178. package/build/dist/api/modules/layerbank/actions.js +1 -1
  179. package/build/dist/api/modules/layerbank/checks.js +1 -1
  180. package/build/dist/api/modules/layerbank/index.js +1 -1
  181. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  182. package/build/dist/api/modules/layerbank/reader.js +1 -1
  183. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  184. package/build/dist/api/modules/lighter/index.js +1 -1
  185. package/build/dist/api/modules/longbow/administration.js +1 -1
  186. package/build/dist/api/modules/longbow/analytics.js +1 -1
  187. package/build/dist/api/modules/longbow/fixed.js +1 -1
  188. package/build/dist/api/modules/longbow/index.js +1 -1
  189. package/build/dist/api/modules/longbow/nft.js +1 -1
  190. package/build/dist/api/modules/longbow/rebates.js +1 -1
  191. package/build/dist/api/modules/longbow/staking.js +1 -1
  192. package/build/dist/api/modules/meridian/index.js +1 -1
  193. package/build/dist/api/modules/meridian/markets.js +1 -1
  194. package/build/dist/api/modules/meridian/rfq.js +1 -1
  195. package/build/dist/api/modules/merkl/discovery.js +1 -1
  196. package/build/dist/api/modules/merkl/index.js +1 -1
  197. package/build/dist/api/modules/merkl/manage.js +1 -1
  198. package/build/dist/api/modules/merkl/protocol.js +1 -1
  199. package/build/dist/api/modules/morpho/allocator.js +1 -1
  200. package/build/dist/api/modules/morpho/bundles.js +1 -1
  201. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  202. package/build/dist/api/modules/morpho/index.js +1 -1
  203. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  204. package/build/dist/api/modules/morpho/midnight.js +1 -1
  205. package/build/dist/api/modules/morpho/protocol.js +1 -1
  206. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  207. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  208. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  209. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  210. package/build/dist/api/modules/netnet/card-read.js +1 -1
  211. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  212. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  213. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  214. package/build/dist/api/modules/netnet/financial.js +1 -1
  215. package/build/dist/api/modules/netnet/index.js +1 -1
  216. package/build/dist/api/modules/netnet/staking.js +1 -1
  217. package/build/dist/api/modules/orbio/index.js +1 -1
  218. package/build/dist/api/modules/orbio/positions.js +1 -1
  219. package/build/dist/api/modules/pendle/costs.js +1 -1
  220. package/build/dist/api/modules/pendle/index.js +1 -1
  221. package/build/dist/api/modules/pendle/markets.js +1 -1
  222. package/build/dist/api/modules/pendle/positions.js +1 -1
  223. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  224. package/build/dist/api/modules/pendle/reader.js +1 -1
  225. package/build/dist/api/modules/pendle/redeem.js +1 -1
  226. package/build/dist/api/modules/pendle/trade.js +1 -1
  227. package/build/dist/api/modules/pendle/validate.js +1 -1
  228. package/build/dist/api/modules/pendle/verify.js +1 -1
  229. package/build/dist/api/modules/pons/claim.js +1 -1
  230. package/build/dist/api/modules/pons/index.js +1 -1
  231. package/build/dist/api/modules/pons/launch-status.js +1 -1
  232. package/build/dist/api/modules/pons/prices.js +1 -1
  233. package/build/dist/api/modules/pons/reads.js +1 -1
  234. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  235. package/build/dist/api/modules/pons/trade.js +1 -1
  236. package/build/dist/api/modules/poolstrade/index.js +1 -1
  237. package/build/dist/api/modules/priors/coverage.js +1 -1
  238. package/build/dist/api/modules/priors/discovery.js +1 -1
  239. package/build/dist/api/modules/priors/features.js +1 -1
  240. package/build/dist/api/modules/priors/holdings.js +1 -1
  241. package/build/dist/api/modules/priors/index.js +1 -1
  242. package/build/dist/api/modules/priors/integration.js +1 -1
  243. package/build/dist/api/modules/priors/market.js +1 -1
  244. package/build/dist/api/modules/priors/pt.js +1 -1
  245. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  246. package/build/dist/api/modules/priors/starter-line.js +1 -1
  247. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  248. package/build/dist/api/modules/raeto/index.js +1 -1
  249. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  250. package/build/dist/api/modules/relay/discovery.js +1 -1
  251. package/build/dist/api/modules/relay/inbound.js +1 -1
  252. package/build/dist/api/modules/relay/index.js +1 -1
  253. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  254. package/build/dist/api/modules/relay/reads.js +1 -1
  255. package/build/dist/api/modules/spark/actions.js +1 -1
  256. package/build/dist/api/modules/spark/details.js +1 -1
  257. package/build/dist/api/modules/spark/index.js +1 -1
  258. package/build/dist/api/modules/spark/management.js +1 -1
  259. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  260. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  261. package/build/dist/api/modules/steakhouse/index.js +1 -1
  262. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  263. package/build/dist/api/modules/steakhouse/management.js +1 -1
  264. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  265. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  266. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  267. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  268. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  269. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  270. package/build/dist/api/modules/tickerspring/index.js +1 -1
  271. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  272. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  273. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  274. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  275. package/build/dist/api/modules/tickerspring/research.js +1 -1
  276. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  277. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  278. package/build/dist/api/modules/uniswap/auction.js +1 -1
  279. package/build/dist/api/modules/uniswap/batch.js +1 -1
  280. package/build/dist/api/modules/uniswap/common.js +1 -1
  281. package/build/dist/api/modules/uniswap/fees.js +1 -1
  282. package/build/dist/api/modules/uniswap/index.js +1 -1
  283. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  284. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  285. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  286. package/build/dist/api/modules/uniswap/pools.js +1 -1
  287. package/build/dist/api/modules/uniswap/position.js +1 -1
  288. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  289. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  290. package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
  291. package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
  292. package/build/dist/api/modules/uniswap/stocks.js +1 -1
  293. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  294. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  295. package/build/dist/api/modules/uniswap/trade.js +1 -1
  296. package/build/dist/api/modules/uniswap/v2.js +1 -1
  297. package/build/dist/api/modules/uniswap/v3.js +1 -1
  298. package/build/dist/api/modules/uniswap/v4.js +1 -1
  299. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  300. package/build/dist/api/modules/velora/claims.js +1 -1
  301. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  302. package/build/dist/api/modules/velora/index.js +1 -1
  303. package/build/dist/api/modules/wormhole/index.js +1 -1
  304. package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
  305. package/build/dist/api/positions.js +1 -1
  306. package/build/dist/api/pricenote.js +1 -1
  307. package/build/dist/api/prices.d.ts +5 -0
  308. package/build/dist/api/prices.js +1 -1
  309. package/build/dist/api/rpc.js +1 -1
  310. package/build/dist/api/send.js +1 -1
  311. package/build/dist/api/signing-registry.js +1 -1
  312. package/build/dist/api/signing.js +1 -1
  313. package/build/dist/api/simulate.js +1 -1
  314. package/build/dist/api/swap.d.ts +2 -0
  315. package/build/dist/api/swap.js +1 -1
  316. package/build/dist/api/tokens.d.ts +10 -1
  317. package/build/dist/api/tokens.js +1 -1
  318. package/build/dist/api/tool-policy.js +1 -1
  319. package/build/dist/api/universal-router.js +1 -1
  320. package/build/dist/api/usd-estimate.d.ts +2 -0
  321. package/build/dist/api/usd-estimate.js +1 -1
  322. package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
  323. package/build/dist/chunks/{KNBNKG7P.js → 2BKZLF5A.js} +1 -1
  324. package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
  325. package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
  326. package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
  327. package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
  328. package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
  329. package/build/dist/chunks/{FQTO7VJG.js → 3HF6WE4L.js} +1 -1
  330. package/build/dist/chunks/3M7RMROZ.js +1 -0
  331. package/build/dist/chunks/3RGED2KO.js +1 -0
  332. package/build/dist/chunks/{RUSXMQSJ.js → 3XIJCHT7.js} +1 -1
  333. package/build/dist/chunks/3XY44BP5.js +1 -0
  334. package/build/dist/chunks/3YNXQ3EZ.js +1 -0
  335. package/build/dist/chunks/45QP74CE.js +1 -0
  336. package/build/dist/chunks/{NYHKIXJR.js → 4GAU3JLN.js} +1 -1
  337. package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
  338. package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
  339. package/build/dist/chunks/{7FYM7FJA.js → 4SXRXNHG.js} +1 -1
  340. package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
  341. package/build/dist/chunks/5677LZOV.js +1 -0
  342. package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
  343. package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
  344. package/build/dist/chunks/{PXUML7HJ.js → 5DWQUEBA.js} +1 -1
  345. package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
  346. package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
  347. package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
  348. package/build/dist/chunks/5PNFV7HH.js +1 -0
  349. package/build/dist/chunks/5RAZFRO4.js +1 -0
  350. package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
  351. package/build/dist/chunks/5VKVAUFQ.js +1 -0
  352. package/build/dist/chunks/5Y457HYC.js +1 -0
  353. package/build/dist/chunks/64LAWFBE.js +1 -0
  354. package/build/dist/chunks/{JJGZ7W3V.js → 6AS3TGOX.js} +1 -1
  355. package/build/dist/chunks/6EWSLHXL.js +1 -0
  356. package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
  357. package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
  358. package/build/dist/chunks/{YR44GQG4.js → 6QXTL65K.js} +1 -1
  359. package/build/dist/chunks/6RVAV6BB.js +1 -0
  360. package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
  361. package/build/dist/chunks/{OKXKDDBX.js → 6Y2546JA.js} +1 -1
  362. package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
  363. package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
  364. package/build/dist/chunks/7GL547YZ.js +1 -0
  365. package/build/dist/chunks/7JTXYMNP.js +1 -0
  366. package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
  367. package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
  368. package/build/dist/chunks/{3D7FXI6G.js → 7X5JVF3F.js} +1 -1
  369. package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
  370. package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
  371. package/build/dist/chunks/{AOX6DKYU.js → AL6UXNGH.js} +1 -1
  372. package/build/dist/chunks/AODUTN65.js +1 -0
  373. package/build/dist/chunks/{PQG3ULRT.js → AONO47JX.js} +1 -1
  374. package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
  375. package/build/dist/chunks/AZBTNUXF.js +1 -0
  376. package/build/dist/chunks/{O56EZB5Y.js → B5BU645H.js} +1 -1
  377. package/build/dist/chunks/{LQSPWRHN.js → B75SS7H6.js} +1 -1
  378. package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
  379. package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
  380. package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
  381. package/build/dist/chunks/BM4KHOFB.js +1 -0
  382. package/build/dist/chunks/{X3YEDVRN.js → BSV65PCA.js} +1 -1
  383. package/build/dist/chunks/{HDBDBKEA.js → BW755PNH.js} +1 -1
  384. package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
  385. package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
  386. package/build/dist/chunks/{SRHVSNPX.js → C2H3BWN5.js} +1 -1
  387. package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
  388. package/build/dist/chunks/{ZTX4WT62.js → CFPJDLTZ.js} +1 -1
  389. package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
  390. package/build/dist/chunks/CJMVRV34.js +1 -0
  391. package/build/dist/chunks/CQPIR6ER.js +1 -0
  392. package/build/dist/chunks/{FP7DHVK2.js → CR7DPGI6.js} +1 -1
  393. package/build/dist/chunks/{W5FM2OVB.js → CVVNAFUE.js} +1 -1
  394. package/build/dist/chunks/{LEHBRAZX.js → CW37EGPL.js} +1 -1
  395. package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
  396. package/build/dist/chunks/{SGHSCK22.js → DJRS3TR5.js} +1 -1
  397. package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
  398. package/build/dist/chunks/{SYERFEJ4.js → DPSFR3ZS.js} +1 -1
  399. package/build/dist/chunks/{2T6O77QZ.js → DV2HVFTM.js} +1 -1
  400. package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
  401. package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
  402. package/build/dist/chunks/EHQRAA3R.js +1 -0
  403. package/build/dist/chunks/{WX7OYCNS.js → EJIP7RBG.js} +1 -1
  404. package/build/dist/chunks/EPOIAXCV.js +3 -0
  405. package/build/dist/chunks/EWZFZUVF.js +1 -0
  406. package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
  407. package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
  408. package/build/dist/chunks/F36IA5RI.js +1 -0
  409. package/build/dist/chunks/{DD47RZFU.js → F74ARK4H.js} +1 -1
  410. package/build/dist/chunks/{Q4HSQL65.js → FGGDAAHW.js} +1 -1
  411. package/build/dist/chunks/FMEO7RX7.js +1 -0
  412. package/build/dist/chunks/{V6EVQWAL.js → FN6XY6ET.js} +1 -1
  413. package/build/dist/chunks/G4IX4CYN.js +1 -0
  414. package/build/dist/chunks/G53U6Y4L.js +1 -0
  415. package/build/dist/chunks/{XHFAF5PZ.js → GBIL2I2K.js} +1 -1
  416. package/build/dist/chunks/{RKM62HC5.js → GCFHKJIO.js} +1 -1
  417. package/build/dist/chunks/{K7HTDKAT.js → GMMTHTCP.js} +1 -1
  418. package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
  419. package/build/dist/chunks/GTJ6LBGB.js +1 -0
  420. package/build/dist/chunks/GV6Z3MET.js +1 -0
  421. package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
  422. package/build/dist/chunks/GX2RCAHG.js +1 -0
  423. package/build/dist/chunks/{O3XWE4FO.js → H5KU4DUU.js} +1 -1
  424. package/build/dist/chunks/H7ZJ7LAB.js +1 -0
  425. package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
  426. package/build/dist/chunks/{RK3PPFRX.js → HEQBTHFS.js} +1 -1
  427. package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
  428. package/build/dist/chunks/HJI7KO6F.js +1 -0
  429. package/build/dist/chunks/{L6CVMDWQ.js → HNBYPHTA.js} +1 -1
  430. package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
  431. package/build/dist/chunks/HPO673QQ.js +1 -0
  432. package/build/dist/chunks/{ZFRTBBIW.js → HRGLFGFL.js} +1 -1
  433. package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
  434. package/build/dist/chunks/IJVBCEA2.js +1 -0
  435. package/build/dist/chunks/{2TX7HP6M.js → IKVRFAUP.js} +1 -1
  436. package/build/dist/chunks/IM7ZF7XZ.js +1 -0
  437. package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
  438. package/build/dist/chunks/IR7KDBFU.js +1 -0
  439. package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
  440. package/build/dist/chunks/IYOWMW5B.js +1 -0
  441. package/build/dist/chunks/J2J73XYU.js +1 -0
  442. package/build/dist/chunks/JCS24YBB.js +1 -0
  443. package/build/dist/chunks/JQVTHPUO.js +1 -0
  444. package/build/dist/chunks/{USZCTSPI.js → JTWJT2O3.js} +1 -1
  445. package/build/dist/chunks/{2YYKQGJZ.js → K4CYAWNL.js} +1 -1
  446. package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
  447. package/build/dist/chunks/K5OXLIPK.js +1 -0
  448. package/build/dist/chunks/{4PB6MSGZ.js → K6GECT3F.js} +1 -1
  449. package/build/dist/chunks/{HU2JXDLH.js → KB2JWQZ4.js} +1 -1
  450. package/build/dist/chunks/{EFESPGA2.js → KCZUJ57H.js} +1 -1
  451. package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
  452. package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
  453. package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
  454. package/build/dist/chunks/{MOZBDCVV.js → L3IAEXQR.js} +1 -1
  455. package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
  456. package/build/dist/chunks/{DMB64UIN.js → L76P6WIH.js} +1 -1
  457. package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
  458. package/build/dist/chunks/LD3A2KLN.js +1 -0
  459. package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
  460. package/build/dist/chunks/{5ZVIAGLX.js → LKRAUTYI.js} +1 -1
  461. package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
  462. package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
  463. package/build/dist/chunks/MFQTBUSD.js +1 -0
  464. package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
  465. package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
  466. package/build/dist/chunks/{FA3GBXQP.js → MXI7LX2F.js} +1 -1
  467. package/build/dist/chunks/N6YNJGEF.js +1 -0
  468. package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
  469. package/build/dist/chunks/NUTTPUYJ.js +1 -0
  470. package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
  471. package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
  472. package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
  473. package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
  474. package/build/dist/chunks/{T3QEN3S6.js → OIGTTRN5.js} +1 -1
  475. package/build/dist/chunks/{5OTQCE2E.js → P6JE2NRA.js} +1 -1
  476. package/build/dist/chunks/PD5NXIRT.js +1 -0
  477. package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
  478. package/build/dist/chunks/{WXZ4LAKO.js → PXVF2SHU.js} +1 -1
  479. package/build/dist/chunks/{UBVE2U6X.js → Q43WPRYU.js} +1 -1
  480. package/build/dist/chunks/QA6Z2CYP.js +2 -0
  481. package/build/dist/chunks/QAAKUIWE.js +1 -0
  482. package/build/dist/chunks/{PQOWIRKQ.js → QAVP3CWL.js} +1 -1
  483. package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
  484. package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
  485. package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
  486. package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
  487. package/build/dist/chunks/{AHUCYDBC.js → QKIQ7ZKD.js} +1 -1
  488. package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
  489. package/build/dist/chunks/{N6PHSHBE.js → QP2B7AYX.js} +1 -1
  490. package/build/dist/chunks/{VHK5AYC2.js → QZ6V6J6W.js} +1 -1
  491. package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
  492. package/build/dist/chunks/RKJFSDGV.js +1 -0
  493. package/build/dist/chunks/RKS3M7L5.js +1 -0
  494. package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
  495. package/build/dist/chunks/RYEQIZ2H.js +1 -0
  496. package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
  497. package/build/dist/chunks/S47M3IPR.js +1 -0
  498. package/build/dist/chunks/S65KXMZ7.js +3 -0
  499. package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
  500. package/build/dist/chunks/{2ILYVUFA.js → SRYX65GZ.js} +1 -1
  501. package/build/dist/chunks/{GNOHIL4Q.js → TMENUIBC.js} +1 -1
  502. package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
  503. package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
  504. package/build/dist/chunks/TTBB6EFN.js +1 -0
  505. package/build/dist/chunks/{Z5YI6KLN.js → TWVDWNTG.js} +1 -1
  506. package/build/dist/chunks/TZG7HTVM.js +1 -0
  507. package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
  508. package/build/dist/chunks/UEOS6SHR.js +1 -0
  509. package/build/dist/chunks/{EIE2U4OX.js → UGFRBJDQ.js} +1 -1
  510. package/build/dist/chunks/{HUKDISRE.js → UIVOYAO2.js} +1 -1
  511. package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
  512. package/build/dist/chunks/UNBRUWSV.js +1 -0
  513. package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
  514. package/build/dist/chunks/{MHONMLF6.js → URTQNYWU.js} +1 -1
  515. package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
  516. package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
  517. package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
  518. package/build/dist/chunks/{5GQJVKVY.js → W5GWK72I.js} +1 -1
  519. package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
  520. package/build/dist/chunks/WRA3ZC6W.js +1 -0
  521. package/build/dist/chunks/{PRBIC3UK.js → WUONMIA2.js} +1 -1
  522. package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
  523. package/build/dist/chunks/{K3TZYPSV.js → X53QVHBC.js} +1 -1
  524. package/build/dist/chunks/{LVFI74ST.js → XNJ6NDQQ.js} +1 -1
  525. package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
  526. package/build/dist/chunks/XUDQYSPU.js +1 -0
  527. package/build/dist/chunks/{VKNKVUAA.js → XWZ5SL5Q.js} +1 -1
  528. package/build/dist/chunks/{365B4YEV.js → XXLQDQEX.js} +1 -1
  529. package/build/dist/chunks/{BDLV42SD.js → Y5T36EEU.js} +1 -1
  530. package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
  531. package/build/dist/chunks/{WNWRF4HE.js → YZHJ4BAP.js} +1 -1
  532. package/build/dist/chunks/ZSGW2ZSO.js +1 -0
  533. package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
  534. package/package.json +1 -1
  535. package/build/dist/chunks/2QP6WGKZ.js +0 -1
  536. package/build/dist/chunks/3AOTYJPX.js +0 -1
  537. package/build/dist/chunks/4E7FJQLL.js +0 -1
  538. package/build/dist/chunks/4J245N3F.js +0 -1
  539. package/build/dist/chunks/4M6XBG6X.js +0 -1
  540. package/build/dist/chunks/BA66J5YQ.js +0 -1
  541. package/build/dist/chunks/BIY2F6MO.js +0 -1
  542. package/build/dist/chunks/CZ66MYKR.js +0 -1
  543. package/build/dist/chunks/DFM4T6ZE.js +0 -1
  544. package/build/dist/chunks/DGCJZ3HO.js +0 -1
  545. package/build/dist/chunks/DHX3Q5RV.js +0 -2
  546. package/build/dist/chunks/DWQJ7NSX.js +0 -1
  547. package/build/dist/chunks/EFUACKDK.js +0 -1
  548. package/build/dist/chunks/EQEMI54U.js +0 -1
  549. package/build/dist/chunks/GYPMUYB5.js +0 -1
  550. package/build/dist/chunks/JFC2QCMW.js +0 -1
  551. package/build/dist/chunks/JW7GLNLB.js +0 -3
  552. package/build/dist/chunks/MEB727X5.js +0 -1
  553. package/build/dist/chunks/MIKQWF6Q.js +0 -3
  554. package/build/dist/chunks/MQK6OP7S.js +0 -1
  555. package/build/dist/chunks/OSMOBKRQ.js +0 -1
  556. package/build/dist/chunks/P6MPKIU2.js +0 -1
  557. package/build/dist/chunks/P7C3TYI4.js +0 -1
  558. package/build/dist/chunks/RN3WUJIO.js +0 -1
  559. package/build/dist/chunks/TI727O2H.js +0 -1
  560. package/build/dist/chunks/UHIJMDD2.js +0 -1
  561. package/build/dist/chunks/VQJXQLFW.js +0 -1
  562. package/build/dist/chunks/W32UECOL.js +0 -1
  563. package/build/dist/chunks/WWNAGOCD.js +0 -1
  564. package/build/dist/chunks/ZNX3YVF2.js +0 -1
@@ -1 +1 @@
1
- import{d as A,e as G,f as O,h as U,i as x,l as T,m as D,n as L,o as B,p as I,q as j,w as C,z as E}from"./3A2IKFTV.js";import{a as N,b as m}from"./X5V2Z2NM.js";import{a as M}from"./43LI5NKJ.js";import{c as H,g as S}from"./NWNYJ26T.js";import{a as f}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeFunctionData as q}from"viem";var z=10n**38n,W=`0x${"00".repeat(32)}`;function _(o,g){let k=o<0n,l=(k?-o:o).toString().padStart(g+1,"0"),P=l.slice(0,l.length-g),v=g?l.slice(l.length-g).replace(/0+$/,""):"";return`${k?"-":""}${P}${v?`.${v}`:""}`}var ie=o=>{let g=(e,a,i)=>({name:e,inputSchema:a,execute:async(t,n)=>{try{return M(n),L(o,t.chainId),await i(t,n)}catch(r){throw new f(o.plainError(r))}}}),k={transactionHash:{...G,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},l=(e,a,i)=>o.clientFor(U(o).chainId).readContract({address:e,abi:m,functionName:a,args:i});async function P(e){let{chainId:a,registry:i}=U(o),t=await o.clientFor(a).readContract({address:i,abi:N,functionName:"ownerOf",args:[e]});return M(t),t}let v=e=>{if(typeof e!="string"||!/^[1-9][0-9]{0,18}$/.test(e)||BigInt(e)>=2n**64n)throw new f("Provide feedbackIndex as a decimal integer string of at least 1 (indexes are 1-based).");return BigInt(e)},X=g("erc8004_give_feedback",{type:"object",additionalProperties:!1,required:["agentId","value"],description:"Post public, permanent-by-hash feedback about an agent (ERC-8004 Reputation Registry giveFeedback). You cannot rate an agent you own or operate.",properties:{agentId:A,value:{type:"string",pattern:"^-?[0-9]+$",description:'Signed integer in fixed point, e.g. "87" with valueDecimals 0 is 87; "9977" with valueDecimals 2 is 99.77.'},valueDecimals:{type:"integer",minimum:0,maximum:18,default:0,description:'Decimal places of the signed feedback value, from 0 to 18; "9977" with 2 means 99.77.'},tag1:{type:"string",description:"Optional filter tag such as starred, uptime, successRate, responseTime."},tag2:{type:"string",description:"Second feedback category tag to record or filter."},endpoint:{type:"string",description:"Optional endpoint the feedback is about."},feedbackURI:{type:"string",description:"Optional HTTPS/IPFS URI of an off-chain feedback file."},feedbackHash:{...O,description:"keccak256 of the feedbackURI content; optional for IPFS, recommended for HTTPS."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId);if(typeof e.value!="string"||!/^-?[0-9]+$/.test(e.value))throw new f("Provide value as a signed integer string.");let n=BigInt(e.value);if(n>z||n<-z)throw new f("The feedback value is out of range (\xB11e38).");let r=e.valueDecimals===void 0?0:e.valueDecimals;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>18)throw new f("valueDecimals must be an integer from 0 to 18.");let s=I(e.tag1,"tag1",128),b=I(e.tag2,"tag2",128),p=e.endpoint===void 0?"":I(e.endpoint,"endpoint",2048),u=e.feedbackURI===void 0?"":j(e.feedbackURI,"feedbackURI"),w=e.feedbackHash===void 0?W:B(e.feedbackHash,"feedbackHash"),R=q({abi:m,functionName:"giveFeedback",args:[t,n,r,s,b,p,u,w]});return E(o,a,e,{to:i,data:R,description:`Give feedback ${e.value}e-${r} to ERC-8004 agent ${t}.`,summary:`Publishes feedback ${_(n,r)} about agent ${t}${s?` (tag ${$(s)})`:""} from this wallet. Feedback is public and attributable to this wallet; it can be revoked later but never erased. Repeat with transactionHash to read back the feedback index.`,authority:async()=>{await P(t);let{registry:h,chainId:d}=U(o);if(await o.clientFor(d).readContract({address:h,abi:N,functionName:"isAuthorizedOrOwner",args:[a,t]})===!0)throw new f("The registry refuses feedback from the owner or an approved operator of the same agent.")},verify:async h=>{let d=C(h,i,m,"NewFeedback"),c=d.feedbackIndex,F=await l(i,"readFeedback",[t,a,c]);if(d.agentId!==t||!S(String(d.clientAddress),a)||d.value!==n||F[0]!==n||F[4])throw new f("The registry event or stored feedback does not match.");return{agentId:t.toString(),feedbackIndex:c.toString(),value:_(n,r),confirmed:!0}}})}),Y=g("erc8004_revoke_feedback",{type:"object",additionalProperties:!1,required:["agentId","feedbackIndex"],properties:{agentId:A,feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId),n=v(e.feedbackIndex);return E(o,a,e,{to:i,data:q({abi:m,functionName:"revokeFeedback",args:[t,n]}),description:`Revoke feedback #${n} on ERC-8004 agent ${t}.`,summary:`Marks your feedback #${n} about agent ${t} as revoked. The original entry stays on-chain, flagged revoked. Repeat with transactionHash to verify.`,authority:async()=>{let r=await l(i,"getLastIndex",[t,a]);if(n>r)throw new f(`This wallet has given only ${r} feedback entries on agent ${t}.`);if((await l(i,"readFeedback",[t,a,n]))[4])throw new f("That feedback is already revoked.")},verify:async r=>{let s=C(r,i,m,"FeedbackRevoked"),b=await l(i,"readFeedback",[t,a,n]);if(s.agentId!==t||s.feedbackIndex!==n||!S(String(s.clientAddress),a)||!b[4])throw new f("The registry event or stored feedback does not show a revocation.");return{agentId:t.toString(),feedbackIndex:n.toString(),revoked:!0}}})}),Z=g("erc8004_append_response",{type:"object",additionalProperties:!1,required:["agentId","clientAddress","feedbackIndex","responseURI"],description:"Append a public response to a feedback entry (the agent showing a refund, or anyone tagging spam).",properties:{agentId:A,clientAddress:{...H,description:"The wallet that gave the feedback."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."},responseURI:{type:"string",description:"HTTPS or IPFS URI of the response file."},responseHash:{...O,description:"keccak256 of the response content; optional for IPFS."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId),n=D(e.clientAddress,"clientAddress"),r=v(e.feedbackIndex),s=j(e.responseURI,"responseURI"),b=e.responseHash===void 0?W:B(e.responseHash,"responseHash");return E(o,a,e,{to:i,data:q({abi:m,functionName:"appendResponse",args:[t,n,r,s,b]}),description:`Append a response to feedback #${r} by ${n} on ERC-8004 agent ${t}.`,summary:`Publishes a response (${$(s)}) under feedback #${r} that ${n} gave agent ${t}, attributed to this wallet. Responses are append-only. Repeat with transactionHash to verify.`,authority:async()=>{let p=await l(i,"getLastIndex",[t,n]);if(r>p)throw new f(`${n} has given only ${p} feedback entries on agent ${t}.`)},verify:async p=>{let u=C(p,i,m,"ResponseAppended");if(u.agentId!==t||u.feedbackIndex!==r||!S(String(u.clientAddress),n)||!S(String(u.responder),a)||u.responseURI!==s)throw new f("The registry event does not match the response.");return{agentId:t.toString(),clientAddress:n,feedbackIndex:r.toString(),responder:a,confirmed:!0}}})}),J=g("erc8004_reputation",{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only: an agent's feedback summary and entries. Pass the reviewers you trust in clients; without it the summary counts every wallet, which anyone can spam.",properties:{agentId:A,clients:{type:"array",maxItems:200,items:H,description:"Reviewer wallets to count (recommended)."},tag1:{type:"string",description:"First feedback category tag to filter."},tag2:{type:"string",description:"Second feedback category tag to record or filter."},includeRevoked:{type:"boolean",default:!1,description:"Include feedback entries revoked by their authors."},limit:{type:"integer",minimum:1,maximum:200,default:50,description:"Maximum feedback entries to return, from 1 to 200."},clientAddress:{...H,description:"With feedbackIndex: also count responses to that one entry."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."}}},async e=>{let{address:a}=x(o),i=T(e.agentId);await P(i);let t=I(e.tag1,"tag1",128),n=I(e.tag2,"tag2",128),r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),200):50,s=Array.isArray(e.clients)?e.clients.map(d=>D(d,"client")):void 0;if(s&&s.length>200)throw new f("Provide at most 200 reviewer wallets.");let b=s??await l(a,"getClients",[i]),p=b.slice(0,200),u={count:"0",value:"0",valueDecimals:0},w=[],R=0;if(p.length){let[d,c]=await Promise.all([l(a,"getSummary",[i,p,t,n]),l(a,"readAllFeedback",[i,p,t,n,e.includeRevoked===!0])]);u={count:d[0].toString(),value:_(d[1],d[2]),valueDecimals:d[2]},R=c[0].length,w=c[0].slice(0,r).map((F,y)=>({clientAddress:F,feedbackIndex:c[1][y].toString(),value:_(c[2][y],c[3][y]),valueDecimals:c[3][y],tag1:$(c[4][y]),tag2:$(c[5][y]),revoked:c[6][y]}))}let h;if(e.clientAddress!==void 0){let d=D(e.clientAddress,"clientAddress"),c=e.feedbackIndex===void 0?0n:v(e.feedbackIndex);h=(await l(a,"getResponseCount",[i,d,c,[]])).toString()}return{agentId:i.toString(),registry:a,clientsTotal:b.length,clientsUsed:p.length,filteredByClients:s!==void 0,summary:u,feedback:w,feedbackTotal:R,truncated:R>w.length||b.length>p.length,...h===void 0?{}:{responseCount:h},note:s?"Summary counts only the reviewers you named.":"Unfiltered: every reviewer wallet counts, and anyone can post feedback for free, so a high score is not evidence. Name trusted reviewers in clients for a meaningful score."}});return{tools:[X,Y,Z,J]}};export{_ as a,ie as b};
1
+ import{d as A,e as G,f as O,h as U,i as x,l as T,m as D,n as L,o as B,p as I,q as j,w as C,z as E}from"./BIFANUTV.js";import{a as N,b as m}from"./X5V2Z2NM.js";import{a as M}from"./43LI5NKJ.js";import{c as H,g as S}from"./NWNYJ26T.js";import{a as f}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeFunctionData as q}from"viem";var z=10n**38n,W=`0x${"00".repeat(32)}`;function _(o,g){let k=o<0n,l=(k?-o:o).toString().padStart(g+1,"0"),P=l.slice(0,l.length-g),v=g?l.slice(l.length-g).replace(/0+$/,""):"";return`${k?"-":""}${P}${v?`.${v}`:""}`}var ie=o=>{let g=(e,a,i)=>({name:e,inputSchema:a,execute:async(t,n)=>{try{return M(n),L(o,t.chainId),await i(t,n)}catch(r){throw new f(o.plainError(r))}}}),k={transactionHash:{...G,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},l=(e,a,i)=>o.clientFor(U(o).chainId).readContract({address:e,abi:m,functionName:a,args:i});async function P(e){let{chainId:a,registry:i}=U(o),t=await o.clientFor(a).readContract({address:i,abi:N,functionName:"ownerOf",args:[e]});return M(t),t}let v=e=>{if(typeof e!="string"||!/^[1-9][0-9]{0,18}$/.test(e)||BigInt(e)>=2n**64n)throw new f("Provide feedbackIndex as a decimal integer string of at least 1 (indexes are 1-based).");return BigInt(e)},X=g("erc8004_give_feedback",{type:"object",additionalProperties:!1,required:["agentId","value"],description:"Post public, permanent-by-hash feedback about an agent (ERC-8004 Reputation Registry giveFeedback). You cannot rate an agent you own or operate.",properties:{agentId:A,value:{type:"string",pattern:"^-?[0-9]+$",description:'Signed integer in fixed point, e.g. "87" with valueDecimals 0 is 87; "9977" with valueDecimals 2 is 99.77.'},valueDecimals:{type:"integer",minimum:0,maximum:18,default:0,description:'Decimal places of the signed feedback value, from 0 to 18; "9977" with 2 means 99.77.'},tag1:{type:"string",description:"Optional filter tag such as starred, uptime, successRate, responseTime."},tag2:{type:"string",description:"Second feedback category tag to record or filter."},endpoint:{type:"string",description:"Optional endpoint the feedback is about."},feedbackURI:{type:"string",description:"Optional HTTPS/IPFS URI of an off-chain feedback file."},feedbackHash:{...O,description:"keccak256 of the feedbackURI content; optional for IPFS, recommended for HTTPS."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId);if(typeof e.value!="string"||!/^-?[0-9]+$/.test(e.value))throw new f("Provide value as a signed integer string.");let n=BigInt(e.value);if(n>z||n<-z)throw new f("The feedback value is out of range (\xB11e38).");let r=e.valueDecimals===void 0?0:e.valueDecimals;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>18)throw new f("valueDecimals must be an integer from 0 to 18.");let s=I(e.tag1,"tag1",128),b=I(e.tag2,"tag2",128),p=e.endpoint===void 0?"":I(e.endpoint,"endpoint",2048),u=e.feedbackURI===void 0?"":j(e.feedbackURI,"feedbackURI"),w=e.feedbackHash===void 0?W:B(e.feedbackHash,"feedbackHash"),R=q({abi:m,functionName:"giveFeedback",args:[t,n,r,s,b,p,u,w]});return E(o,a,e,{to:i,data:R,description:`Give feedback ${e.value}e-${r} to ERC-8004 agent ${t}.`,summary:`Publishes feedback ${_(n,r)} about agent ${t}${s?` (tag ${$(s)})`:""} from this wallet. Feedback is public and attributable to this wallet; it can be revoked later but never erased. Repeat with transactionHash to read back the feedback index.`,authority:async()=>{await P(t);let{registry:h,chainId:d}=U(o);if(await o.clientFor(d).readContract({address:h,abi:N,functionName:"isAuthorizedOrOwner",args:[a,t]})===!0)throw new f("The registry refuses feedback from the owner or an approved operator of the same agent.")},verify:async h=>{let d=C(h,i,m,"NewFeedback"),c=d.feedbackIndex,F=await l(i,"readFeedback",[t,a,c]);if(d.agentId!==t||!S(String(d.clientAddress),a)||d.value!==n||F[0]!==n||F[4])throw new f("The registry event or stored feedback does not match.");return{agentId:t.toString(),feedbackIndex:c.toString(),value:_(n,r),confirmed:!0}}})}),Y=g("erc8004_revoke_feedback",{type:"object",additionalProperties:!1,required:["agentId","feedbackIndex"],properties:{agentId:A,feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId),n=v(e.feedbackIndex);return E(o,a,e,{to:i,data:q({abi:m,functionName:"revokeFeedback",args:[t,n]}),description:`Revoke feedback #${n} on ERC-8004 agent ${t}.`,summary:`Marks your feedback #${n} about agent ${t} as revoked. The original entry stays on-chain, flagged revoked. Repeat with transactionHash to verify.`,authority:async()=>{let r=await l(i,"getLastIndex",[t,a]);if(n>r)throw new f(`This wallet has given only ${r} feedback entries on agent ${t}.`);if((await l(i,"readFeedback",[t,a,n]))[4])throw new f("That feedback is already revoked.")},verify:async r=>{let s=C(r,i,m,"FeedbackRevoked"),b=await l(i,"readFeedback",[t,a,n]);if(s.agentId!==t||s.feedbackIndex!==n||!S(String(s.clientAddress),a)||!b[4])throw new f("The registry event or stored feedback does not show a revocation.");return{agentId:t.toString(),feedbackIndex:n.toString(),revoked:!0}}})}),Z=g("erc8004_append_response",{type:"object",additionalProperties:!1,required:["agentId","clientAddress","feedbackIndex","responseURI"],description:"Append a public response to a feedback entry (the agent showing a refund, or anyone tagging spam).",properties:{agentId:A,clientAddress:{...H,description:"The wallet that gave the feedback."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."},responseURI:{type:"string",description:"HTTPS or IPFS URI of the response file."},responseHash:{...O,description:"keccak256 of the response content; optional for IPFS."},...k}},async(e,a)=>{let{address:i}=x(o),t=T(e.agentId),n=D(e.clientAddress,"clientAddress"),r=v(e.feedbackIndex),s=j(e.responseURI,"responseURI"),b=e.responseHash===void 0?W:B(e.responseHash,"responseHash");return E(o,a,e,{to:i,data:q({abi:m,functionName:"appendResponse",args:[t,n,r,s,b]}),description:`Append a response to feedback #${r} by ${n} on ERC-8004 agent ${t}.`,summary:`Publishes a response (${$(s)}) under feedback #${r} that ${n} gave agent ${t}, attributed to this wallet. Responses are append-only. Repeat with transactionHash to verify.`,authority:async()=>{let p=await l(i,"getLastIndex",[t,n]);if(r>p)throw new f(`${n} has given only ${p} feedback entries on agent ${t}.`)},verify:async p=>{let u=C(p,i,m,"ResponseAppended");if(u.agentId!==t||u.feedbackIndex!==r||!S(String(u.clientAddress),n)||!S(String(u.responder),a)||u.responseURI!==s)throw new f("The registry event does not match the response.");return{agentId:t.toString(),clientAddress:n,feedbackIndex:r.toString(),responder:a,confirmed:!0}}})}),J=g("erc8004_reputation",{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only: an agent's feedback summary and entries. Pass the reviewers you trust in clients; without it the summary counts every wallet, which anyone can spam.",properties:{agentId:A,clients:{type:"array",maxItems:200,items:H,description:"Reviewer wallets to count (recommended)."},tag1:{type:"string",description:"First feedback category tag to filter."},tag2:{type:"string",description:"Second feedback category tag to record or filter."},includeRevoked:{type:"boolean",default:!1,description:"Include feedback entries revoked by their authors."},limit:{type:"integer",minimum:1,maximum:200,default:50,description:"Maximum feedback entries to return, from 1 to 200."},clientAddress:{...H,description:"With feedbackIndex: also count responses to that one entry."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"Feedback entry identifier as a one-based decimal string."}}},async e=>{let{address:a}=x(o),i=T(e.agentId);await P(i);let t=I(e.tag1,"tag1",128),n=I(e.tag2,"tag2",128),r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),200):50,s=Array.isArray(e.clients)?e.clients.map(d=>D(d,"client")):void 0;if(s&&s.length>200)throw new f("Provide at most 200 reviewer wallets.");let b=s??await l(a,"getClients",[i]),p=b.slice(0,200),u={count:"0",value:"0",valueDecimals:0},w=[],R=0;if(p.length){let[d,c]=await Promise.all([l(a,"getSummary",[i,p,t,n]),l(a,"readAllFeedback",[i,p,t,n,e.includeRevoked===!0])]);u={count:d[0].toString(),value:_(d[1],d[2]),valueDecimals:d[2]},R=c[0].length,w=c[0].slice(0,r).map((F,y)=>({clientAddress:F,feedbackIndex:c[1][y].toString(),value:_(c[2][y],c[3][y]),valueDecimals:c[3][y],tag1:$(c[4][y]),tag2:$(c[5][y]),revoked:c[6][y]}))}let h;if(e.clientAddress!==void 0){let d=D(e.clientAddress,"clientAddress"),c=e.feedbackIndex===void 0?0n:v(e.feedbackIndex);h=(await l(a,"getResponseCount",[i,d,c,[]])).toString()}return{agentId:i.toString(),registry:a,clientsTotal:b.length,clientsUsed:p.length,filteredByClients:s!==void 0,summary:u,feedback:w,feedbackTotal:R,truncated:R>w.length||b.length>p.length,...h===void 0?{}:{responseCount:h},note:s?"Summary counts only the reviewers you named.":"Unfiltered: every reviewer wallet counts, and anyone can post feedback for free, so a high score is not evidence. Name trusted reviewers in clients for a meaningful score."}});return{tools:[X,Y,Z,J]}};export{_ as a,ie as b};
@@ -1 +1 @@
1
- import{c as i,d as T,e as O,f as C}from"./OUROA7XR.js";import{b as A}from"./43LI5NKJ.js";import{b as F,j as R}from"./TI727O2H.js";import{a as y}from"./XSD5NL7J.js";import{decodeFunctionData as U,encodeFunctionData as N,parseAbi as Q,zeroAddress as S}from"viem";var v=R[4663].pendle.router.address,I=Q(["struct SwapData { uint8 swapType; address extRouter; bytes extCalldata; bool needScale; }","struct TokenInput { address tokenIn; uint256 netTokenIn; address tokenMintSy; address pendleSwap; SwapData swapData; }","struct TokenOutput { address tokenOut; uint256 minTokenOut; address tokenRedeemSy; address pendleSwap; SwapData swapData; }","struct ApproxParams { uint256 guessMin; uint256 guessMax; uint256 guessOffchain; uint256 maxIteration; uint256 eps; }","struct Order { uint256 salt; uint256 expiry; uint256 nonce; uint8 orderType; address token; address YT; address maker; address receiver; uint256 makingAmount; uint256 lnImpliedRate; uint256 failSafeRate; bytes permit; }","struct FillOrderParams { Order order; bytes signature; uint256 makingAmount; }","struct LimitOrderData { address limitRouter; uint256 epsSkipMarket; FillOrderParams[] normalFills; FillOrderParams[] flashFills; bytes optData; }","function swapExactTokenForPt(address receiver,address market,uint256 minPtOut,ApproxParams approx,TokenInput input,LimitOrderData limit) payable returns(uint256,uint256,uint256)","function swapExactPtForToken(address receiver,address market,uint256 netPtIn,TokenOutput output,LimitOrderData limit) returns(uint256,uint256,uint256)","function redeemPyToToken(address receiver,address YT,uint256 netPyIn,TokenOutput output) returns(uint256,uint256)"]);function e(n,t){if(!n)throw new y(`Pendle quote refused: ${t}. Nothing was signed.`)}function a(n,t){return typeof n=="string"&&n.toLowerCase()===t.toLowerCase()}function Y(n,t){return e(Number.isInteger(t)&&t>=0&&t<=1e4,"invalid slippage limit"),n*BigInt(1e4-t)/10000n}function M(n){e(a(n.pendleSwap,S),"unexpected swap contract"),e(n.swapData.swapType===0,"unexpected swap type"),e(a(n.swapData.extRouter,S),"unexpected external router"),e(n.swapData.extCalldata==="0x","unexpected external calldata"),e(n.swapData.needScale===!1,"unexpected swap scaling")}function V(n){e(a(n.limitRouter,S),"limit orders are not supported"),e(n.normalFills.length===0,"unexpected normal limit fills"),e(n.flashFills.length===0,"unexpected flash limit fills"),e(n.optData==="0x","unexpected limit order data"),e(n.epsSkipMarket===0n,"unexpected limit order tolerance")}function E(n,t,d){let g=C(n),s=i(g.tx);e(a(s.to,v),"wrong router"),e(s.value===void 0||s.value==="0","unexpected or malformed ETH value"),e(t.amount>0n&&t.amount<1n<<256n,"invalid requested amount");let P=g.outputs;e(P.length===1,"expected exactly one output token");let h=i(P[0]);e(a(O(h.token),d==="buy"?t.market.pt:t.market.inputToken),"wrong quoted output token");let w=T(h.amount);e(w>0n,"empty quoted output");let q=Y(w,t.slippageBps),D=i(n).requiredApprovals;e(D.length===1,"expected exactly one approval");let p=i(D[0]);e(a(O(p.token),d==="buy"?t.market.inputToken:t.market.pt),"wrong approval token"),e(T(p.amount)===t.amount,"wrong approval amount"),e(p.spender===void 0||a(p.spender,v),"wrong approval spender");let l=i(g.data),m=i(l.fee);e(typeof l.priceImpact=="number"&&Number.isFinite(l.priceImpact),"unreadable price impact"),e(typeof m.usd=="number"&&Number.isFinite(m.usd)&&m.usd>=0,"unreadable trading fee");let o;try{o=$(s.data)}catch{throw new y("Pendle quote refused: unknown or malformed router call. Nothing was signed.")}let c,k;if(d==="buy"){e(o.functionName==="swapExactTokenForPt","wrong buy selector");let[f,x,b,r,u,L]=o.args;e(a(f,t.wallet),"wrong receiver"),e(a(x,t.market.market),"wrong market"),e(a(u.tokenIn,t.market.inputToken),"wrong input token"),e(a(u.tokenMintSy,t.market.inputToken),"wrong SY mint token"),e(u.netTokenIn===t.amount,"wrong input amount"),M(u),V(L),e(r.guessMin<=r.guessOffchain,"invalid lower approximation guess"),e(r.guessOffchain<=r.guessMax,"invalid upper approximation guess"),e(r.maxIteration<=256n,"too many approximation iterations"),c=b,k=N({abi:I,functionName:o.functionName,args:o.args})}else{e(o.functionName==="swapExactPtForToken","wrong sell selector");let[f,x,b,r,u]=o.args;e(a(f,t.wallet),"wrong receiver"),e(a(x,t.market.market),"wrong market"),e(b===t.amount,"wrong PT input amount"),e(a(r.tokenOut,t.market.inputToken),"wrong output token"),e(a(r.tokenRedeemSy,t.market.inputToken),"wrong SY redeem token"),M(r),V(u),c=r.minTokenOut,k=N({abi:I,functionName:o.functionName,args:o.args})}return e(c>=q,"minimum output is below Oak\u2019s slippage floor"),e(k.toLowerCase()===s.data.toLowerCase(),"calldata does not match Oak\u2019s encoding"),{tx:A({to:v,data:k,value:"0",chainId:F,description:d==="buy"?"Buy Pendle PT with the exact input amount.":"Sell Pendle PT to the market input token."}),amountOut:w,minOut:c,feeUsd:m.usd,priceImpact:l.priceImpact}}function $(n){return U({abi:I,data:n})}function G(n,t){return E(n,t,"buy")}function J(n,t){return E(n,t,"sell")}export{v as a,I as b,e as c,a as d,Y as e,G as f,J as g};
1
+ import{c as i,d as T,e as O,f as C}from"./OUROA7XR.js";import{b as A}from"./43LI5NKJ.js";import{b as F,j as R}from"./EWZFZUVF.js";import{a as y}from"./XSD5NL7J.js";import{decodeFunctionData as U,encodeFunctionData as N,parseAbi as Q,zeroAddress as S}from"viem";var v=R[4663].pendle.router.address,I=Q(["struct SwapData { uint8 swapType; address extRouter; bytes extCalldata; bool needScale; }","struct TokenInput { address tokenIn; uint256 netTokenIn; address tokenMintSy; address pendleSwap; SwapData swapData; }","struct TokenOutput { address tokenOut; uint256 minTokenOut; address tokenRedeemSy; address pendleSwap; SwapData swapData; }","struct ApproxParams { uint256 guessMin; uint256 guessMax; uint256 guessOffchain; uint256 maxIteration; uint256 eps; }","struct Order { uint256 salt; uint256 expiry; uint256 nonce; uint8 orderType; address token; address YT; address maker; address receiver; uint256 makingAmount; uint256 lnImpliedRate; uint256 failSafeRate; bytes permit; }","struct FillOrderParams { Order order; bytes signature; uint256 makingAmount; }","struct LimitOrderData { address limitRouter; uint256 epsSkipMarket; FillOrderParams[] normalFills; FillOrderParams[] flashFills; bytes optData; }","function swapExactTokenForPt(address receiver,address market,uint256 minPtOut,ApproxParams approx,TokenInput input,LimitOrderData limit) payable returns(uint256,uint256,uint256)","function swapExactPtForToken(address receiver,address market,uint256 netPtIn,TokenOutput output,LimitOrderData limit) returns(uint256,uint256,uint256)","function redeemPyToToken(address receiver,address YT,uint256 netPyIn,TokenOutput output) returns(uint256,uint256)"]);function e(n,t){if(!n)throw new y(`Pendle quote refused: ${t}. Nothing was signed.`)}function a(n,t){return typeof n=="string"&&n.toLowerCase()===t.toLowerCase()}function Y(n,t){return e(Number.isInteger(t)&&t>=0&&t<=1e4,"invalid slippage limit"),n*BigInt(1e4-t)/10000n}function M(n){e(a(n.pendleSwap,S),"unexpected swap contract"),e(n.swapData.swapType===0,"unexpected swap type"),e(a(n.swapData.extRouter,S),"unexpected external router"),e(n.swapData.extCalldata==="0x","unexpected external calldata"),e(n.swapData.needScale===!1,"unexpected swap scaling")}function V(n){e(a(n.limitRouter,S),"limit orders are not supported"),e(n.normalFills.length===0,"unexpected normal limit fills"),e(n.flashFills.length===0,"unexpected flash limit fills"),e(n.optData==="0x","unexpected limit order data"),e(n.epsSkipMarket===0n,"unexpected limit order tolerance")}function E(n,t,d){let g=C(n),s=i(g.tx);e(a(s.to,v),"wrong router"),e(s.value===void 0||s.value==="0","unexpected or malformed ETH value"),e(t.amount>0n&&t.amount<1n<<256n,"invalid requested amount");let P=g.outputs;e(P.length===1,"expected exactly one output token");let h=i(P[0]);e(a(O(h.token),d==="buy"?t.market.pt:t.market.inputToken),"wrong quoted output token");let w=T(h.amount);e(w>0n,"empty quoted output");let q=Y(w,t.slippageBps),D=i(n).requiredApprovals;e(D.length===1,"expected exactly one approval");let p=i(D[0]);e(a(O(p.token),d==="buy"?t.market.inputToken:t.market.pt),"wrong approval token"),e(T(p.amount)===t.amount,"wrong approval amount"),e(p.spender===void 0||a(p.spender,v),"wrong approval spender");let l=i(g.data),m=i(l.fee);e(typeof l.priceImpact=="number"&&Number.isFinite(l.priceImpact),"unreadable price impact"),e(typeof m.usd=="number"&&Number.isFinite(m.usd)&&m.usd>=0,"unreadable trading fee");let o;try{o=$(s.data)}catch{throw new y("Pendle quote refused: unknown or malformed router call. Nothing was signed.")}let c,k;if(d==="buy"){e(o.functionName==="swapExactTokenForPt","wrong buy selector");let[f,x,b,r,u,L]=o.args;e(a(f,t.wallet),"wrong receiver"),e(a(x,t.market.market),"wrong market"),e(a(u.tokenIn,t.market.inputToken),"wrong input token"),e(a(u.tokenMintSy,t.market.inputToken),"wrong SY mint token"),e(u.netTokenIn===t.amount,"wrong input amount"),M(u),V(L),e(r.guessMin<=r.guessOffchain,"invalid lower approximation guess"),e(r.guessOffchain<=r.guessMax,"invalid upper approximation guess"),e(r.maxIteration<=256n,"too many approximation iterations"),c=b,k=N({abi:I,functionName:o.functionName,args:o.args})}else{e(o.functionName==="swapExactPtForToken","wrong sell selector");let[f,x,b,r,u]=o.args;e(a(f,t.wallet),"wrong receiver"),e(a(x,t.market.market),"wrong market"),e(b===t.amount,"wrong PT input amount"),e(a(r.tokenOut,t.market.inputToken),"wrong output token"),e(a(r.tokenRedeemSy,t.market.inputToken),"wrong SY redeem token"),M(r),V(u),c=r.minTokenOut,k=N({abi:I,functionName:o.functionName,args:o.args})}return e(c>=q,"minimum output is below Oak\u2019s slippage floor"),e(k.toLowerCase()===s.data.toLowerCase(),"calldata does not match Oak\u2019s encoding"),{tx:A({to:v,data:k,value:"0",chainId:F,description:d==="buy"?"Buy Pendle PT with the exact input amount.":"Sell Pendle PT to the market input token."}),amountOut:w,minOut:c,feeUsd:m.usd,priceImpact:l.priceImpact}}function $(n){return U({abi:I,data:n})}function G(n,t){return E(n,t,"buy")}function J(n,t){return E(n,t,"sell")}export{v as a,I as b,e as c,a as d,Y as e,G as f,J as g};
@@ -1 +1 @@
1
- import{c as Te,d as $e,e as be,f as ie,i as ke,j as Me}from"./P7C3TYI4.js";import{b as ne,o as we}from"./GYPMUYB5.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Ne}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{b as y,j as O}from"./TI727O2H.js";import{a,b as me,e as q}from"./XSD5NL7J.js";import{decodeFunctionResult as ve,encodeFunctionData as B,getAddress as m,parseAbi as J,zeroAddress as $}from"viem";var re=-887272,se=887272,G=(1n<<128n)-1n,je="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ke="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Qe="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,Ye=5,Le=64n,Ze=1800n,Be="^v3:(0x[0-9a-fA-F]{40}):(0|[1-9][0-9]{0,19}):(0|[1-9][0-9]{0,19})$",Je=new RegExp(Be),et=Object.freeze({type:"string",pattern:Be,description:"v3 only. Pass the nextCursor of the previous page to read the next 64 owner indices at the same block. Cannot be combined with tokenIds."}),w=Object.freeze({factory:m(O[4663].uniswap.v3_factory.address),positionManager:m(O[4663].uniswap.v3_position_manager.address),swapRouter02:m(O[4663].uniswap.swap_router02.address),permit2:m(O[4663].uniswap.permit2.address),weth:m(O[4663].uniswap.WETH.address),usdg:m(O[4663].uniswap.USDG.address),ethUsdgPool:m(O[4663].oracle.ethUsdgPool.address)}),Pe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),qt=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:w.weth,token1:w.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:w.weth,token1:w.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:w.weth,token1:w.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:w.weth,token1:w.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),P=J(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Y=J(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),he=J(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),tt=J(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),xe=J(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),nt="0xd0e30db0";function it(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===$||e===je||e==="eth"||e==="native"}function D(t,e){if(it(t))throw new a(`Uniswap v3 requires wrapped ERC-20 WETH (${w.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new a(`${e} must be a valid 20-byte hex address.`);return F(t),m(t)}function ot(t,e,n){let s=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new a("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(s)||!Number.isInteger(o))throw new a("Uniswap v3 tickLower and tickUpper must be integers.");if(s<re||o>se||s>se||o<re)throw new a(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(s>=o)throw new a("Uniswap v3 tickLower must be strictly less than tickUpper.");if(s%i!==0||o%i!==0)throw new a(`Uniswap v3 tickLower (${s}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:s,tickUpper:o,tickSpacing:i}}function rt(t,e){let n=t.trim(),s=n.startsWith("-"),o=s||n.startsWith("+")?n.slice(1):n,i=Ue(z(o).toString(),e);return s&&i!=="0"?`-${i}`:i}function st(t){let e=typeof t=="string"?ve({abi:P,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function Re(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?m(e).toLowerCase():void 0,s=w.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==s)continue;let c=Array.isArray(i.topics)?i.topics.map(p=>String(p).toLowerCase()):[],r=c[0];if(r===Ke&&c.length>=4){let d=`0x${c[2].slice(-40)}`;if(!n||d===n){let u=BigInt(c[3]).toString();u!=="0"&&o.add(u)}}else if(r===Qe&&c.length>=2&&!n){let p=BigInt(c[1]).toString();p!=="0"&&o.add(p)}}return[...o]}function Ut(t){let e=n=>typeof n=="bigint"?n:z(n);return B({abi:tt,functionName:"exactInputSingle",args:[{tokenIn:m(t.tokenIn),tokenOut:m(t.tokenOut),fee:t.fee,recipient:m(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Ee=1n<<96n;function _e(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function at(t,e,n,s){if(s<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(s<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let r=(s<<96n)*(i-t)/i/t,p=s*(t-o)/Ee;return{amount0:r,amount1:p}}return{amount0:0n,amount1:s*(i-o)/Ee}}async function M(t,e,n,s){let o=m(e),i,c;if(n===y&&o===w.weth?(i=18,c="WETH"):n===y&&o===w.usdg&&(i=6,c="USDG"),i===void 0){let r=await t.readContract({address:o,abi:xe,functionName:"decimals"});i=Number(r)}if(c===void 0)try{let r=await t.readContract({address:o,abi:xe,functionName:"symbol"});if(typeof r!="string"||!r.trim())throw new a("Token symbol is unavailable.");c=Me(r.trim(),o)}catch(r){throw new a(`Could not read token metadata. ${q(r)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new a("Token decimals are invalid.");if(s!=null){let r=Number(s);if(!Number.isInteger(r)||r!==i)throw new a(`Token ${o} on chain ${n} has ${i} decimals, not ${String(s)}.`)}return{address:o,symbol:c,decimals:i,chainId:n}}async function ct(t){try{if(!t.getBlock)throw new a("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new a("Invalid block timestamp.");return e.timestamp}catch(e){throw new a(`Could not read the current block timestamp. ${q(e)}`)}}function ee(t,e){if(typeof t=="bigint"){if(t<0n)throw new a(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new a(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return z(t);throw new a(`${e} must be a non-negative integer.`)}async function Oe(t,e){let n=await ct(t);if(e==null)return n+Ze;let s=ee(e,"deadline");if(s<=n)throw new a(`Uniswap v3 deadline (${s.toString()}) has expired at timestamp ${n.toString()}.`);return s}function W(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new a(`${e} must be a non-negative integer string in base units.`);return z(t)}function De(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new a("Slippage must be an integer from 0 to 9999 bps.");return we("0",e),e}function ae(t,e,n,s){let o=t===void 0?z(we(e.toString(),n)):W(t,s);if(o<=1n)throw new a(`${s} must exceed 1 base unit; the simulated amount may be too small.`);return o}function H(t,e){return ge({to:w.positionManager,data:t,value:"0",chainId:y,description:e})}async function Z(t,e,n){try{if(!t.request)throw new a("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Ne.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new a("Unexpected batch simulation response.");return o[0].calls.map((i,c)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new a(`Simulation call ${c+1} failed. ${q(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${q(s)}`)}}function ce(t,e){try{return ve({abi:P,functionName:t,data:e})}catch{throw new a(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Ve(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new a("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new a("sqrtPriceX96 must be a non-negative integer string.");return $e(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new a("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Te(t.initialPrice,e,n)}async function Xe(t,e,n,s){let o=[];for(let i of Object.keys(Pe).map(Number)){if(i===s)continue;let c=m(String(await t.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[e,n,i]})));if(c===$||BigInt(await t.readContract({address:c,abi:he,functionName:"liquidity"}))===0n)continue;let p=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(p[0])})}return o}function j(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==y)throw new a(`Uniswap v3 is only supported on Robinhood Chain (${y}).`);if(e.version!==void 0&&e.version!=="v3")throw new a(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(y);return{...n,readContract:async s=>{try{return await n.readContract(s)}catch(o){throw new a(`Could not read Uniswap v3 ${s.functionName}. ${q(o)}`,{cause:o})}}}}async function Ie(t,e,n){let s;try{s=await t.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[e]})}catch(c){throw new a(`Could not verify owner of Uniswap v3 position #${e}. ${q(c)}`)}let o=m(String(s)),i=m(n);if(o!==i)throw new a(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:w.positionManager,abi:P,functionName:"positions",args:[e]});return st(n)}function Se(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(s=>`${rt(s.amount,s.token.decimals)} ${s.token.symbol}`);return`${t} (${n.join(", ")})`}async function dt(t,e,n){F(n);let s=m(n),o=j(t,e),i=await Oe(o,e.deadline),c=De(e),r=e.tokenId===void 0?void 0:ee(e.tokenId,"tokenId"),p;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),p=await de(o,r)}let d=p?.token0??D(e.token0,"token0"),u=p?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=p?.fee??Number(e.fee??100),f=Pe[g];if(!f)throw new a("Unsupported Uniswap v3 fee tier.");let b=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[d,u,g]}))),l=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(b===$&&!l)throw new a("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(b!==$&&l)throw new a(`The Uniswap v3 pool already exists at ${b}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(r!==void 0&&l)throw new a("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new a("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||p))throw new a("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:k,tickUpper:U,tickSpacing:A}=ot(p?.tickLower??(e.fullRange===!0?Math.ceil(re/f)*f:e.tickLower),p?.tickUpper??(e.fullRange===!0?Math.floor(se/f)*f:e.tickUpper),f),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let T=Ve(e,v.decimals,h.decimals),_=ke(T,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:T,note:_}}let I=W(e.amount0Desired,"amount0Desired"),S=W(e.amount1Desired,"amount1Desired");if(I===0n&&S===0n)throw new a("Liquidity addition requires a positive desired amount.");let x=e.recipient===void 0?s:D(e.recipient,"recipient");if(x!==s)throw new a("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==w.weth&&u!==w.weth)throw new a("Wrapping requires a positive WETH desired amount.");let V=await Promise.all([d,u].map(async T=>BigInt(await o.readContract({address:T,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(T,_)=>{let pe=[];if(e.wrapNative===!0){let Q=d===w.weth?T:_;Q>0n&&pe.push(ge({to:w.weth,data:nt,value:Q.toString(),chainId:y,description:"Wrap ETH into WETH."}))}for(let[Q,Ge]of[d,u].entries()){let fe=Q===0?T:_;fe>0n&&V[Q]<fe&&pe.push(t.approval(Ge,w.positionManager,fe.toString(),y))}return pe},L=r===void 0?"mint":"increaseLiquidity",R=(T,_)=>H(r===void 0?B({abi:P,functionName:"mint",args:[{token0:d,token1:u,fee:g,tickLower:k,tickUpper:U,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),E=C&&H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[d,u,g,C.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${v.symbol}/${h.symbol} fee ${g} pool at ${ie(C.sqrtPriceX96,v.decimals,h.decimals)} ${h.symbol} per ${v.symbol}.`),K=E?[E]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),N=ce(L,Ae[Ae.length-1]),We=N[N.length-2],ze=N[N.length-1];if(We>I||ze>S)throw new a("Simulated liquidity spend exceeds the desired amounts.");let te=[...K,...X(I,S)],ue=ae(e.amount0Min,N[N.length-2],c,"amount0Min"),le=ae(e.amount1Min,N[N.length-1],c,"amount1Min");if(ue>I||le>S)throw new a("Uniswap v3 minimum amount cannot exceed desired amount.");let Ce=R(ue,le);te.push(Ce);for(let[T,_]of[d,u].entries())(T===0?I:S)>0n&&te.push(t.approval(_,w.positionManager,"0",y));let qe=await t.preview(te,s);return{txs:te,preview:qe,summary:Se(Ce.description,qe),details:{version:"v3",action:L,...r===void 0?{}:{tokenId:r.toString()},pool:b===$?null:b,fee:g,tickSpacing:A,tickLower:k,tickUpper:U,token0:v,token1:h,amount0Desired:I.toString(),amount1Desired:S.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:x,expectedAmount0:N[N.length-2].toString(),expectedAmount1:N[N.length-1].toString(),...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:ie(C.sqrtPriceX96,v.decimals,h.decimals),initialTick:be(C.sqrtPriceX96),priceCheck:C.note}:{}}}}async function ut(t,e,n){F(n);let s=m(n),o=j(t,e),i=D(e.token0,"token0"),c=D(e.token1,"token1");if(BigInt(i)>=BigInt(c))throw new a(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(c)?i:c}, token1=${BigInt(i)<BigInt(c)?c:i}; initialPrice is token1 per 1 token0 in that order.`);let r=Number(e.fee),p=Pe[r];if(!p){let h=Number(await o.readContract({address:w.factory,abi:Y,functionName:"feeAmountTickSpacing",args:[r]}));if(!Number.isInteger(r)||h<=0)throw new a("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");p=h}let d=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[i,c,r]})));if(d!==$)throw new a(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let u=await M(o,i,y,e.token0Decimals),g=await M(o,c,y,e.token1Decimals),f=Ve(e,u.decimals,g.decimals),b=ke(f,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(f,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,f]}),`Create and initialize the Uniswap v3 ${u.symbol}/${g.symbol} fee ${r} pool at ${l} ${g.symbol} per ${u.symbol}.`)],U=await Z(o,k,s),A;try{A=m(String(ve({abi:P,functionName:"createAndInitializePoolIfNecessary",data:U[0]})))}catch{throw new a("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(A===$)throw new a("Uniswap v3 pool creation simulation returned no pool.");let v=await t.preview(k,s);return{txs:k,preview:v,summary:`${k[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:A,fee:r,tickSpacing:p,token0:u,token1:g,sqrtPriceX96:f.toString(),initialPrice:l,initialTick:be(f),priceCheck:b}}}async function lt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=await M(o,c.token0,y),p=await M(o,c.token1,y),d=e.recipient===void 0?s:D(e.recipient,"recipient");if(d!==s)throw new a("Uniswap recipient must be the signing wallet.");let u=e.amount0Max===void 0?G:W(e.amount0Max,"amount0Max"),g=e.amount1Max===void 0?G:W(e.amount1Max,"amount1Max");if(u===0n&&g===0n||u>G||g>G)throw new a("Collect requires a positive amountMax within uint128.");let f=[H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:u,amount1Max:g}]}),`Collect Uniswap v3 fees from position #${i}.`)],b=ce("collect",(await Z(o,f,s))[0]),l=await t.preview(f,s);return{txs:f,preview:l,summary:Se(f[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:p,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function pt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=c.liquidity===0n&&e.burn===!0;if(c.liquidity<=0n&&!r)throw new a("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!r)throw new a('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let p=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(p<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(p>c.liquidity)throw new a("Requested liquidity exceeds position liquidity.");let d=await Oe(o,e.deadline),u=De(e),g=await M(o,c.token0,y),f=await M(o,c.token1,y),b=e.recipient===void 0?s:D(e.recipient,"recipient");if(b!==s)throw new a("Uniswap recipient must be the signing wallet.");let l=(R,E)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:p,amount0Min:R,amount1Min:E,deadline:d}]}),`Decrease ${p} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,E)=>{if(R!==void 0&&W(R,E)!==0n)throw new a(`${E} must be zero for an empty position burn.`);return 0n},A=r?U(e.amount0Min,"amount0Min"):ae(e.amount0Min,k[0],u,"amount0Min"),v=r?U(e.amount1Min,"amount1Min"):ae(e.amount1Min,k[1],u,"amount1Min"),h=r?[]:[l(A,v)],C=h.length,I=!r||c.tokensOwed0>0n||c.tokensOwed1>0n;I&&h.push(H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:b,amount0Max:G,amount1Max:G}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let S=p===c.liquidity,x=S&&e.burn===!0;x&&h.push(H(B({abi:P,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let V=await Z(o,h,s),X=I?ce("collect",V[C]):[0n,0n],L=await t.preview(h,s);return{txs:h,preview:L,summary:Se(`Remove Uniswap v3 liquidity from position #${i}${x?`; burns position #${i} at ${w.positionManager}`:""}`,L),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:b,token0:g,token1:f,liquidityRemoved:p.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function ft(t,e){let n=typeof t=="string"?Je.exec(t):null;if(!n)throw new a('cursor is not a Uniswap v3 position cursor. Pass the nextCursor exactly as a previous uniswap_list_positions {"version":"v3"} page returned it.');if(m(n[1])!==e)throw new a("This cursor was issued for a different wallet. Start again without a cursor to page this wallet.");return{block:BigInt(n[2]),next:BigInt(n[3])}}function mt(t,e,n){return`v3:${t.toLowerCase()}:${e}:${n}`}function gt(t,e){return{...t,readContract:n=>t.readContract({...n,blockNumber:e})}}var ye=t=>me(t,3,-32601,-32004);async function wt(t,e,n={}){let s=m(e),o=new Set;if(Array.isArray(n.tokenIds))for(let d of n.tokenIds){let u=ee(d,"tokenId");u>0n&&o.add(u.toString())}if(Array.isArray(n.receipts))for(let d of n.receipts)for(let u of Re(d,s))o.add(u);if(Array.isArray(n.tokenIds)&&n.tokenIds.length>0)return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0);let i=n.cursor,c=()=>new a("This Uniswap v3 position manager cannot enumerate NFTs by owner, so there are no pages to continue. Pass tokenIds to check specific positions."),r=!1,p=!1;try{let d;try{d=BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"balanceOf",args:[s]}))}catch(l){throw ye(l)||!i?l:new a(`Could not read this wallet's Uniswap v3 holdings at the cursor's snapshot block ${i.block}; the node may no longer serve it. Start again without a cursor. ${q(l)}`)}let u=i?.next??0n;if(u>d)throw new a(`This cursor starts at owner index ${u}, but the wallet held ${d} Uniswap v3 NFTs at block ${i?.block}. Start again without a cursor.`);let g=d-u>Le?u+Le:d,f=[],b=!0;for(let l=u;l<g;l++)try{f.push(BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"tokenOfOwnerByIndex",args:[s,l]})))}catch(k){if(!ye(k))throw k;b=!1;break}if(b){r=!0,p=u===0n&&g===d;for(let k of f)k>0n&&o.add(k.toString());let l=n.blockNumber;n.onPage?.({balance:d,from:u,to:g,blockNumber:l,...g<d&&l!==void 0?{nextCursor:mt(s,l,g)}:{}})}}catch(d){if(!ye(d))throw d}if(i&&!r)throw c();if((!r||p)&&typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let d=n.toBlock??await t.getBlockNumber(),u=n.maxChunks??Ye,g=n.fromBlock??(d>oe*BigInt(u)?d-oe*BigInt(u)+1n:0n),f=d,b=0;for(;f>=g&&b<u;){let l=f>=oe-1n?f-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:f});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;f=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${q(d)}`)}else if(!r&&n.tokenIds===void 0&&n.receipts===void 0)throw new a("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0)}async function Fe(t,e,n={}){F(e);let s=m(e),o=j(t),i=Array.isArray(n.tokenIds)&&n.tokenIds.length>0,c=Array.isArray(n.receipts)&&n.receipts.length>0;if(n.cursor!==void 0&&(i||c))throw new a(`${i?"tokenIds":"receipts"} and cursor cannot be combined: ${i?"tokenIds":"receipts"} inspects exactly those NFTs and has no pages. Send one or the other.`);let r=n.cursor===void 0?void 0:ft(n.cursor,s),p=o,d;if(!i){let f;if(typeof o.getBlockNumber=="function")try{f=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${q(b)}`)}if(r&&f!==void 0&&r.block>f)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${f}. Start again without a cursor.`);d=r?.block??f,d!==void 0&&(p=gt(o,d))}let u=await wt(p,s,{...n,cursor:r,blockNumber:d}),g=[];for(let f of u){let b;try{let x=await p.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[f]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${f}. ${q(x)}`)}if(b!==s)continue;let l;try{l=await de(p,f)}catch(x){throw new a(`Could not read position #${f}. ${q(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(p,l.token0,y),A=await M(p,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await p.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[l.token0,l.token1,l.fee]}),V=m(String(x));if(V===$)throw new a("Position pool was not found.");if(V!==$){let X=await p.readContract({address:V,abi:he,functionName:"slot0"}),L=BigInt(X[0]);if(L<=0n)throw new a("Position pool has no initialized price.");let R=_e(l.tickLower),E=_e(l.tickUpper),K=at(L,R,E,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${f}. ${q(x)}`)}let C=v+l.tokensOwed0,I=h+l.tokensOwed1,S=[{token:U,amount:C.toString()},{token:A,amount:I.toString()}];g.push({module:"uniswap",id:`uniswap:v3:${f.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${f.toString()} (${U.symbol}/${A.symbol} fee ${l.fee} ticks [${l.tickLower}, ${l.tickUpper}] liquidity ${l.liquidity.toString()})`})}return g}function bt(t){let e=t.nextCursor?`Pass cursor "${t.nextCursor}" to read the next page, or tokenIds to check specific positions.`:"Pass tokenIds to check specific positions.";return t.from===0n?`This wallet holds ${t.balance} Uniswap v3 position NFTs and only the first ${t.to} were checked, so later positions are not listed. ${e}`:`This page checked owner indices ${t.from}-${t.to-1n} of ${t.balance} Uniswap v3 position NFTs, so later positions are not listed. ${e}`}async function kt(t,e,n){j(t,e);let s=e.wallet!==void 0?D(e.wallet,"wallet"):m(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,c=e.includeZero===!0||e.includeEmpty===!0,r,p=await Fe(t,s,{tokenIds:o,receipts:i,includeEmpty:c,cursor:e.cursor,onPage:u=>{r=u}}),d=r!==void 0&&r.to<r.balance;return{positions:p,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:p.length,positionManager:w.positionManager,...r?{balance:Number(r.balance),from:Number(r.from),to:Number(r.to),examined:Number(r.to-r.from),...r.blockNumber!==void 0?{blockNumber:r.blockNumber.toString()}:{}}:{},...r&&d?{truncated:!0,incomplete:!0,note:bt(r)}:{}}}}function yt(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Optional existing v3 position NFT identifier to increase, as a decimal string; omit to mint. Example: "1".'},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:'Desired amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Desired:{type:"string",description:'Desired amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},execute:(c,r)=>dt(t,c,r)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:'Maximum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Max:{type:"string",description:'Maximum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'}},required:["tokenId"]},execute:(c,r)=>lt(t,c,r)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},liquidity:{type:"string",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(c,r)=>pt(t,c,r)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet, 64 owner indices per page at one pinned block; follow nextCursor for more. Falls back to a bounded Transfer-log scan for managers that cannot enumerate by owner.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:'Optional v3 NFT identifiers as decimal strings, e.g. ["1", "2"]. Inspects exactly these NFTs without paging.'},cursor:et}},execute:(c,r)=>kt(t,c,r)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(c,r)=>ut(t,c,r)}]}var He=t=>({tools:yt(t),positions:async e=>{let n,s=await Fe(t,e,{onPage:o=>{o.to>=o.balance||(n={module:"uniswap",id:"uniswap-v3-discovery-truncated",chainId:y,assets:[],incomplete:!0,description:`This wallet holds ${o.balance} Uniswap v3 position NFTs and only the first ${o.to} were checked, so later positions may be missing. Pass tokenIds to uniswap_list_positions to check the others, or page through them with uniswap_list_positions {"version":"v3"} and each nextCursor.`})}});return n?[...s,n]:s}}),Nt=He,Tt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,qt as g,P as h,Y as i,he as j,tt as k,ot as l,rt as m,st as n,Re as o,Ut as p,Ve as q,dt as r,ut as s,lt as t,pt as u,Fe as v,kt as w,yt as x,He as y,Nt as z,Tt as A};
1
+ import{c as Te,d as $e,e as be,f as ie,i as ke,j as Me}from"./6EWSLHXL.js";import{b as ne,o as we}from"./TTBB6EFN.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Ne}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{b as y,j as O}from"./EWZFZUVF.js";import{a,b as me,e as q}from"./XSD5NL7J.js";import{decodeFunctionResult as ve,encodeFunctionData as B,getAddress as m,parseAbi as J,zeroAddress as $}from"viem";var re=-887272,se=887272,G=(1n<<128n)-1n,je="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Ke="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Qe="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,Ye=5,Le=64n,Ze=1800n,Be="^v3:(0x[0-9a-fA-F]{40}):(0|[1-9][0-9]{0,19}):(0|[1-9][0-9]{0,19})$",Je=new RegExp(Be),et=Object.freeze({type:"string",pattern:Be,description:"v3 only. Pass the nextCursor of the previous page to read the next 64 owner indices at the same block. Cannot be combined with tokenIds."}),w=Object.freeze({factory:m(O[4663].uniswap.v3_factory.address),positionManager:m(O[4663].uniswap.v3_position_manager.address),swapRouter02:m(O[4663].uniswap.swap_router02.address),permit2:m(O[4663].uniswap.permit2.address),weth:m(O[4663].uniswap.WETH.address),usdg:m(O[4663].uniswap.USDG.address),ethUsdgPool:m(O[4663].oracle.ethUsdgPool.address)}),Pe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),qt=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:w.weth,token1:w.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:w.weth,token1:w.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:w.weth,token1:w.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:w.weth,token1:w.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),P=J(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Y=J(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),he=J(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),tt=J(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),xe=J(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),nt="0xd0e30db0";function it(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===$||e===je||e==="eth"||e==="native"}function D(t,e){if(it(t))throw new a(`Uniswap v3 requires wrapped ERC-20 WETH (${w.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new a(`${e} must be a valid 20-byte hex address.`);return F(t),m(t)}function ot(t,e,n){let s=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new a("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(s)||!Number.isInteger(o))throw new a("Uniswap v3 tickLower and tickUpper must be integers.");if(s<re||o>se||s>se||o<re)throw new a(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(s>=o)throw new a("Uniswap v3 tickLower must be strictly less than tickUpper.");if(s%i!==0||o%i!==0)throw new a(`Uniswap v3 tickLower (${s}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:s,tickUpper:o,tickSpacing:i}}function rt(t,e){let n=t.trim(),s=n.startsWith("-"),o=s||n.startsWith("+")?n.slice(1):n,i=Ue(z(o).toString(),e);return s&&i!=="0"?`-${i}`:i}function st(t){let e=typeof t=="string"?ve({abi:P,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function Re(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?m(e).toLowerCase():void 0,s=w.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==s)continue;let c=Array.isArray(i.topics)?i.topics.map(p=>String(p).toLowerCase()):[],r=c[0];if(r===Ke&&c.length>=4){let d=`0x${c[2].slice(-40)}`;if(!n||d===n){let u=BigInt(c[3]).toString();u!=="0"&&o.add(u)}}else if(r===Qe&&c.length>=2&&!n){let p=BigInt(c[1]).toString();p!=="0"&&o.add(p)}}return[...o]}function Ut(t){let e=n=>typeof n=="bigint"?n:z(n);return B({abi:tt,functionName:"exactInputSingle",args:[{tokenIn:m(t.tokenIn),tokenOut:m(t.tokenOut),fee:t.fee,recipient:m(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Ee=1n<<96n;function _e(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function at(t,e,n,s){if(s<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(s<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let r=(s<<96n)*(i-t)/i/t,p=s*(t-o)/Ee;return{amount0:r,amount1:p}}return{amount0:0n,amount1:s*(i-o)/Ee}}async function M(t,e,n,s){let o=m(e),i,c;if(n===y&&o===w.weth?(i=18,c="WETH"):n===y&&o===w.usdg&&(i=6,c="USDG"),i===void 0){let r=await t.readContract({address:o,abi:xe,functionName:"decimals"});i=Number(r)}if(c===void 0)try{let r=await t.readContract({address:o,abi:xe,functionName:"symbol"});if(typeof r!="string"||!r.trim())throw new a("Token symbol is unavailable.");c=Me(r.trim(),o)}catch(r){throw new a(`Could not read token metadata. ${q(r)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new a("Token decimals are invalid.");if(s!=null){let r=Number(s);if(!Number.isInteger(r)||r!==i)throw new a(`Token ${o} on chain ${n} has ${i} decimals, not ${String(s)}.`)}return{address:o,symbol:c,decimals:i,chainId:n}}async function ct(t){try{if(!t.getBlock)throw new a("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new a("Invalid block timestamp.");return e.timestamp}catch(e){throw new a(`Could not read the current block timestamp. ${q(e)}`)}}function ee(t,e){if(typeof t=="bigint"){if(t<0n)throw new a(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new a(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return z(t);throw new a(`${e} must be a non-negative integer.`)}async function Oe(t,e){let n=await ct(t);if(e==null)return n+Ze;let s=ee(e,"deadline");if(s<=n)throw new a(`Uniswap v3 deadline (${s.toString()}) has expired at timestamp ${n.toString()}.`);return s}function W(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new a(`${e} must be a non-negative integer string in base units.`);return z(t)}function De(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new a("Slippage must be an integer from 0 to 9999 bps.");return we("0",e),e}function ae(t,e,n,s){let o=t===void 0?z(we(e.toString(),n)):W(t,s);if(o<=1n)throw new a(`${s} must exceed 1 base unit; the simulated amount may be too small.`);return o}function H(t,e){return ge({to:w.positionManager,data:t,value:"0",chainId:y,description:e})}async function Z(t,e,n){try{if(!t.request)throw new a("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Ne.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new a("Unexpected batch simulation response.");return o[0].calls.map((i,c)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new a(`Simulation call ${c+1} failed. ${q(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${q(s)}`)}}function ce(t,e){try{return ve({abi:P,functionName:t,data:e})}catch{throw new a(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Ve(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new a("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new a("sqrtPriceX96 must be a non-negative integer string.");return $e(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new a("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Te(t.initialPrice,e,n)}async function Xe(t,e,n,s){let o=[];for(let i of Object.keys(Pe).map(Number)){if(i===s)continue;let c=m(String(await t.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[e,n,i]})));if(c===$||BigInt(await t.readContract({address:c,abi:he,functionName:"liquidity"}))===0n)continue;let p=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(p[0])})}return o}function j(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==y)throw new a(`Uniswap v3 is only supported on Robinhood Chain (${y}).`);if(e.version!==void 0&&e.version!=="v3")throw new a(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(y);return{...n,readContract:async s=>{try{return await n.readContract(s)}catch(o){throw new a(`Could not read Uniswap v3 ${s.functionName}. ${q(o)}`,{cause:o})}}}}async function Ie(t,e,n){let s;try{s=await t.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[e]})}catch(c){throw new a(`Could not verify owner of Uniswap v3 position #${e}. ${q(c)}`)}let o=m(String(s)),i=m(n);if(o!==i)throw new a(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:w.positionManager,abi:P,functionName:"positions",args:[e]});return st(n)}function Se(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(s=>`${rt(s.amount,s.token.decimals)} ${s.token.symbol}`);return`${t} (${n.join(", ")})`}async function dt(t,e,n){F(n);let s=m(n),o=j(t,e),i=await Oe(o,e.deadline),c=De(e),r=e.tokenId===void 0?void 0:ee(e.tokenId,"tokenId"),p;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),p=await de(o,r)}let d=p?.token0??D(e.token0,"token0"),u=p?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=p?.fee??Number(e.fee??100),f=Pe[g];if(!f)throw new a("Unsupported Uniswap v3 fee tier.");let b=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[d,u,g]}))),l=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(b===$&&!l)throw new a("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(b!==$&&l)throw new a(`The Uniswap v3 pool already exists at ${b}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(r!==void 0&&l)throw new a("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new a("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||p))throw new a("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:k,tickUpper:U,tickSpacing:A}=ot(p?.tickLower??(e.fullRange===!0?Math.ceil(re/f)*f:e.tickLower),p?.tickUpper??(e.fullRange===!0?Math.floor(se/f)*f:e.tickUpper),f),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let T=Ve(e,v.decimals,h.decimals),_=ke(T,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:T,note:_}}let I=W(e.amount0Desired,"amount0Desired"),S=W(e.amount1Desired,"amount1Desired");if(I===0n&&S===0n)throw new a("Liquidity addition requires a positive desired amount.");let x=e.recipient===void 0?s:D(e.recipient,"recipient");if(x!==s)throw new a("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==w.weth&&u!==w.weth)throw new a("Wrapping requires a positive WETH desired amount.");let V=await Promise.all([d,u].map(async T=>BigInt(await o.readContract({address:T,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(T,_)=>{let pe=[];if(e.wrapNative===!0){let Q=d===w.weth?T:_;Q>0n&&pe.push(ge({to:w.weth,data:nt,value:Q.toString(),chainId:y,description:"Wrap ETH into WETH."}))}for(let[Q,Ge]of[d,u].entries()){let fe=Q===0?T:_;fe>0n&&V[Q]<fe&&pe.push(t.approval(Ge,w.positionManager,fe.toString(),y))}return pe},L=r===void 0?"mint":"increaseLiquidity",R=(T,_)=>H(r===void 0?B({abi:P,functionName:"mint",args:[{token0:d,token1:u,fee:g,tickLower:k,tickUpper:U,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:T,amount1Min:_,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),E=C&&H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[d,u,g,C.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${v.symbol}/${h.symbol} fee ${g} pool at ${ie(C.sqrtPriceX96,v.decimals,h.decimals)} ${h.symbol} per ${v.symbol}.`),K=E?[E]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),N=ce(L,Ae[Ae.length-1]),We=N[N.length-2],ze=N[N.length-1];if(We>I||ze>S)throw new a("Simulated liquidity spend exceeds the desired amounts.");let te=[...K,...X(I,S)],ue=ae(e.amount0Min,N[N.length-2],c,"amount0Min"),le=ae(e.amount1Min,N[N.length-1],c,"amount1Min");if(ue>I||le>S)throw new a("Uniswap v3 minimum amount cannot exceed desired amount.");let Ce=R(ue,le);te.push(Ce);for(let[T,_]of[d,u].entries())(T===0?I:S)>0n&&te.push(t.approval(_,w.positionManager,"0",y));let qe=await t.preview(te,s);return{txs:te,preview:qe,summary:Se(Ce.description,qe),details:{version:"v3",action:L,...r===void 0?{}:{tokenId:r.toString()},pool:b===$?null:b,fee:g,tickSpacing:A,tickLower:k,tickUpper:U,token0:v,token1:h,amount0Desired:I.toString(),amount1Desired:S.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:x,expectedAmount0:N[N.length-2].toString(),expectedAmount1:N[N.length-1].toString(),...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:ie(C.sqrtPriceX96,v.decimals,h.decimals),initialTick:be(C.sqrtPriceX96),priceCheck:C.note}:{}}}}async function ut(t,e,n){F(n);let s=m(n),o=j(t,e),i=D(e.token0,"token0"),c=D(e.token1,"token1");if(BigInt(i)>=BigInt(c))throw new a(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(c)?i:c}, token1=${BigInt(i)<BigInt(c)?c:i}; initialPrice is token1 per 1 token0 in that order.`);let r=Number(e.fee),p=Pe[r];if(!p){let h=Number(await o.readContract({address:w.factory,abi:Y,functionName:"feeAmountTickSpacing",args:[r]}));if(!Number.isInteger(r)||h<=0)throw new a("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");p=h}let d=m(String(await o.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[i,c,r]})));if(d!==$)throw new a(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let u=await M(o,i,y,e.token0Decimals),g=await M(o,c,y,e.token1Decimals),f=Ve(e,u.decimals,g.decimals),b=ke(f,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(f,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,f]}),`Create and initialize the Uniswap v3 ${u.symbol}/${g.symbol} fee ${r} pool at ${l} ${g.symbol} per ${u.symbol}.`)],U=await Z(o,k,s),A;try{A=m(String(ve({abi:P,functionName:"createAndInitializePoolIfNecessary",data:U[0]})))}catch{throw new a("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(A===$)throw new a("Uniswap v3 pool creation simulation returned no pool.");let v=await t.preview(k,s);return{txs:k,preview:v,summary:`${k[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:A,fee:r,tickSpacing:p,token0:u,token1:g,sqrtPriceX96:f.toString(),initialPrice:l,initialTick:be(f),priceCheck:b}}}async function lt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=await M(o,c.token0,y),p=await M(o,c.token1,y),d=e.recipient===void 0?s:D(e.recipient,"recipient");if(d!==s)throw new a("Uniswap recipient must be the signing wallet.");let u=e.amount0Max===void 0?G:W(e.amount0Max,"amount0Max"),g=e.amount1Max===void 0?G:W(e.amount1Max,"amount1Max");if(u===0n&&g===0n||u>G||g>G)throw new a("Collect requires a positive amountMax within uint128.");let f=[H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:u,amount1Max:g}]}),`Collect Uniswap v3 fees from position #${i}.`)],b=ce("collect",(await Z(o,f,s))[0]),l=await t.preview(f,s);return{txs:f,preview:l,summary:Se(f[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:p,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function pt(t,e,n){F(n);let s=m(n),o=j(t,e),i=ee(e.tokenId,"tokenId");if(i<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,i,s);let c=await de(o,i),r=c.liquidity===0n&&e.burn===!0;if(c.liquidity<=0n&&!r)throw new a("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!r)throw new a('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let p=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(p<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(p>c.liquidity)throw new a("Requested liquidity exceeds position liquidity.");let d=await Oe(o,e.deadline),u=De(e),g=await M(o,c.token0,y),f=await M(o,c.token1,y),b=e.recipient===void 0?s:D(e.recipient,"recipient");if(b!==s)throw new a("Uniswap recipient must be the signing wallet.");let l=(R,E)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:p,amount0Min:R,amount1Min:E,deadline:d}]}),`Decrease ${p} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,E)=>{if(R!==void 0&&W(R,E)!==0n)throw new a(`${E} must be zero for an empty position burn.`);return 0n},A=r?U(e.amount0Min,"amount0Min"):ae(e.amount0Min,k[0],u,"amount0Min"),v=r?U(e.amount1Min,"amount1Min"):ae(e.amount1Min,k[1],u,"amount1Min"),h=r?[]:[l(A,v)],C=h.length,I=!r||c.tokensOwed0>0n||c.tokensOwed1>0n;I&&h.push(H(B({abi:P,functionName:"collect",args:[{tokenId:i,recipient:b,amount0Max:G,amount1Max:G}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let S=p===c.liquidity,x=S&&e.burn===!0;x&&h.push(H(B({abi:P,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let V=await Z(o,h,s),X=I?ce("collect",V[C]):[0n,0n],L=await t.preview(h,s);return{txs:h,preview:L,summary:Se(`Remove Uniswap v3 liquidity from position #${i}${x?`; burns position #${i} at ${w.positionManager}`:""}`,L),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:b,token0:g,token1:f,liquidityRemoved:p.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function ft(t,e){let n=typeof t=="string"?Je.exec(t):null;if(!n)throw new a('cursor is not a Uniswap v3 position cursor. Pass the nextCursor exactly as a previous uniswap_list_positions {"version":"v3"} page returned it.');if(m(n[1])!==e)throw new a("This cursor was issued for a different wallet. Start again without a cursor to page this wallet.");return{block:BigInt(n[2]),next:BigInt(n[3])}}function mt(t,e,n){return`v3:${t.toLowerCase()}:${e}:${n}`}function gt(t,e){return{...t,readContract:n=>t.readContract({...n,blockNumber:e})}}var ye=t=>me(t,3,-32601,-32004);async function wt(t,e,n={}){let s=m(e),o=new Set;if(Array.isArray(n.tokenIds))for(let d of n.tokenIds){let u=ee(d,"tokenId");u>0n&&o.add(u.toString())}if(Array.isArray(n.receipts))for(let d of n.receipts)for(let u of Re(d,s))o.add(u);if(Array.isArray(n.tokenIds)&&n.tokenIds.length>0)return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0);let i=n.cursor,c=()=>new a("This Uniswap v3 position manager cannot enumerate NFTs by owner, so there are no pages to continue. Pass tokenIds to check specific positions."),r=!1,p=!1;try{let d;try{d=BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"balanceOf",args:[s]}))}catch(l){throw ye(l)||!i?l:new a(`Could not read this wallet's Uniswap v3 holdings at the cursor's snapshot block ${i.block}; the node may no longer serve it. Start again without a cursor. ${q(l)}`)}let u=i?.next??0n;if(u>d)throw new a(`This cursor starts at owner index ${u}, but the wallet held ${d} Uniswap v3 NFTs at block ${i?.block}. Start again without a cursor.`);let g=d-u>Le?u+Le:d,f=[],b=!0;for(let l=u;l<g;l++)try{f.push(BigInt(await t.readContract({address:w.positionManager,abi:P,functionName:"tokenOfOwnerByIndex",args:[s,l]})))}catch(k){if(!ye(k))throw k;b=!1;break}if(b){r=!0,p=u===0n&&g===d;for(let k of f)k>0n&&o.add(k.toString());let l=n.blockNumber;n.onPage?.({balance:d,from:u,to:g,blockNumber:l,...g<d&&l!==void 0?{nextCursor:mt(s,l,g)}:{}})}}catch(d){if(!ye(d))throw d}if(i&&!r)throw c();if((!r||p)&&typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let d=n.toBlock??await t.getBlockNumber(),u=n.maxChunks??Ye,g=n.fromBlock??(d>oe*BigInt(u)?d-oe*BigInt(u)+1n:0n),f=d,b=0;for(;f>=g&&b<u;){let l=f>=oe-1n?f-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:f});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;f=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${q(d)}`)}else if(!r&&n.tokenIds===void 0&&n.receipts===void 0)throw new a("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(d=>BigInt(d)).sort((d,u)=>d<u?-1:d>u?1:0)}async function Fe(t,e,n={}){F(e);let s=m(e),o=j(t),i=Array.isArray(n.tokenIds)&&n.tokenIds.length>0,c=Array.isArray(n.receipts)&&n.receipts.length>0;if(n.cursor!==void 0&&(i||c))throw new a(`${i?"tokenIds":"receipts"} and cursor cannot be combined: ${i?"tokenIds":"receipts"} inspects exactly those NFTs and has no pages. Send one or the other.`);let r=n.cursor===void 0?void 0:ft(n.cursor,s),p=o,d;if(!i){let f;if(typeof o.getBlockNumber=="function")try{f=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${q(b)}`)}if(r&&f!==void 0&&r.block>f)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${f}. Start again without a cursor.`);d=r?.block??f,d!==void 0&&(p=gt(o,d))}let u=await wt(p,s,{...n,cursor:r,blockNumber:d}),g=[];for(let f of u){let b;try{let x=await p.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[f]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${f}. ${q(x)}`)}if(b!==s)continue;let l;try{l=await de(p,f)}catch(x){throw new a(`Could not read position #${f}. ${q(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(p,l.token0,y),A=await M(p,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await p.readContract({address:w.factory,abi:Y,functionName:"getPool",args:[l.token0,l.token1,l.fee]}),V=m(String(x));if(V===$)throw new a("Position pool was not found.");if(V!==$){let X=await p.readContract({address:V,abi:he,functionName:"slot0"}),L=BigInt(X[0]);if(L<=0n)throw new a("Position pool has no initialized price.");let R=_e(l.tickLower),E=_e(l.tickUpper),K=at(L,R,E,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${f}. ${q(x)}`)}let C=v+l.tokensOwed0,I=h+l.tokensOwed1,S=[{token:U,amount:C.toString()},{token:A,amount:I.toString()}];g.push({module:"uniswap",id:`uniswap:v3:${f.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${f.toString()} (${U.symbol}/${A.symbol} fee ${l.fee} ticks [${l.tickLower}, ${l.tickUpper}] liquidity ${l.liquidity.toString()})`})}return g}function bt(t){let e=t.nextCursor?`Pass cursor "${t.nextCursor}" to read the next page, or tokenIds to check specific positions.`:"Pass tokenIds to check specific positions.";return t.from===0n?`This wallet holds ${t.balance} Uniswap v3 position NFTs and only the first ${t.to} were checked, so later positions are not listed. ${e}`:`This page checked owner indices ${t.from}-${t.to-1n} of ${t.balance} Uniswap v3 position NFTs, so later positions are not listed. ${e}`}async function kt(t,e,n){j(t,e);let s=e.wallet!==void 0?D(e.wallet,"wallet"):m(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,c=e.includeZero===!0||e.includeEmpty===!0,r,p=await Fe(t,s,{tokenIds:o,receipts:i,includeEmpty:c,cursor:e.cursor,onPage:u=>{r=u}}),d=r!==void 0&&r.to<r.balance;return{positions:p,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:p.length,positionManager:w.positionManager,...r?{balance:Number(r.balance),from:Number(r.from),to:Number(r.to),examined:Number(r.to-r.from),...r.blockNumber!==void 0?{blockNumber:r.blockNumber.toString()}:{}}:{},...r&&d?{truncated:!0,incomplete:!0,note:bt(r)}:{}}}}function yt(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Optional existing v3 position NFT identifier to increase, as a decimal string; omit to mint. Example: "1".'},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:'Desired amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Desired:{type:"string",description:'Desired amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},execute:(c,r)=>dt(t,c,r)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:'Maximum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Max:{type:"string",description:'Maximum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'}},required:["tokenId"]},execute:(c,r)=>lt(t,c,r)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:'Identifier of the position NFT, as a decimal string. Example: "1".'},liquidity:{type:"string",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},amount0Min:{type:"string",description:'Minimum amount of token0 in base units; use token0 decimals. Example: "1000000" = 1 token0 at 6 decimals.'},amount1Min:{type:"string",description:'Minimum amount of token1 in base units; use token1 decimals. Example: "1000000" = 1 token1 at 6 decimals.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(c,r)=>pt(t,c,r)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet, 64 owner indices per page at one pinned block; follow nextCursor for more. Falls back to a bounded Transfer-log scan for managers that cannot enumerate by owner.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:'Optional v3 NFT identifiers as decimal strings, e.g. ["1", "2"]. Inspects exactly these NFTs without paging.'},cursor:et}},execute:(c,r)=>kt(t,c,r)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v3 concentrated-liquidity version.",type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(c,r)=>ut(t,c,r)}]}var He=t=>({tools:yt(t),positions:async e=>{let n,s=await Fe(t,e,{onPage:o=>{o.to>=o.balance||(n={module:"uniswap",id:"uniswap-v3-discovery-truncated",chainId:y,assets:[],incomplete:!0,description:`This wallet holds ${o.balance} Uniswap v3 position NFTs and only the first ${o.to} were checked, so later positions may be missing. Pass tokenIds to uniswap_list_positions to check the others, or page through them with uniswap_list_positions {"version":"v3"} and each nextCursor.`})}});return n?[...s,n]:s}}),Nt=He,Tt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,qt as g,P as h,Y as i,he as j,tt as k,ot as l,rt as m,st as n,Re as o,Ut as p,Ve as q,dt as r,ut as s,lt as t,pt as u,Fe as v,kt as w,yt as x,He as y,Nt as z,Tt as A};
@@ -1 +1 @@
1
- import{b as e,e as t,j as r}from"./TI727O2H.js";import{getAddress as s,parseAbi as a}from"viem";var n=r[e],u=s(n.layerbank.pool.address),o=s(n.layerbank.aToken.address),c={address:s(n.tokens.USDG.address),symbol:"USDG",decimals:t,chainId:e},l={address:o,symbol:"lRobUSDG",decimals:t,chainId:e},p=(1n<<256n)-1n,f=10n**27n,m=a(["function getReserveData(address asset) view returns (((uint256 data) configuration,uint128 liquidityIndex,uint128 currentLiquidityRate,uint128 variableBorrowIndex,uint128 currentVariableBorrowRate,uint128 currentStableBorrowRate,uint40 lastUpdateTimestamp,uint16 id,address aTokenAddress,address stableDebtTokenAddress,address variableDebtTokenAddress,address interestRateStrategyAddress,uint128 accruedToTreasury,uint128 unbacked,uint128 isolationModeTotalDebt) reserve)","function getConfiguration(address asset) view returns ((uint256 data) configuration)","function getReserveNormalizedIncome(address asset) view returns (uint256)","function supply(address asset,uint256 amount,address onBehalfOf,uint16 referralCode)","function withdraw(address asset,uint256 amount,address to) returns (uint256)"]),b=a(["function POOL() view returns (address)","function UNDERLYING_ASSET_ADDRESS() view returns (address)","function decimals() view returns (uint8)","function scaledTotalSupply() view returns (uint256)"]);export{u as a,o as b,c,l as d,p as e,f,m as g,b as h};
1
+ import{b as e,e as t,j as r}from"./EWZFZUVF.js";import{getAddress as s,parseAbi as a}from"viem";var n=r[e],u=s(n.layerbank.pool.address),o=s(n.layerbank.aToken.address),c={address:s(n.tokens.USDG.address),symbol:"USDG",decimals:t,chainId:e},l={address:o,symbol:"lRobUSDG",decimals:t,chainId:e},p=(1n<<256n)-1n,f=10n**27n,m=a(["function getReserveData(address asset) view returns (((uint256 data) configuration,uint128 liquidityIndex,uint128 currentLiquidityRate,uint128 variableBorrowIndex,uint128 currentVariableBorrowRate,uint128 currentStableBorrowRate,uint40 lastUpdateTimestamp,uint16 id,address aTokenAddress,address stableDebtTokenAddress,address variableDebtTokenAddress,address interestRateStrategyAddress,uint128 accruedToTreasury,uint128 unbacked,uint128 isolationModeTotalDebt) reserve)","function getConfiguration(address asset) view returns ((uint256 data) configuration)","function getReserveNormalizedIncome(address asset) view returns (uint256)","function supply(address asset,uint256 amount,address onBehalfOf,uint16 referralCode)","function withdraw(address asset,uint256 amount,address to) returns (uint256)"]),b=a(["function POOL() view returns (address)","function UNDERLYING_ASSET_ADDRESS() view returns (address)","function decimals() view returns (uint8)","function scaledTotalSupply() view returns (uint256)"]);export{u as a,o as b,c,l as d,p as e,f,m as g,b as h};
@@ -1 +1 @@
1
- import{c as A}from"./5HCXZWUH.js";import{s as y}from"./MQ5F2VOK.js";import{a as b}from"./XSD5NL7J.js";import{erc20Abi as F,getAddress as $}from"viem";var P=new WeakMap,E=3e3,k=new WeakMap;async function q(C,h,u,m,c){u=$(u);let n=A(C),e=P.get(n);e||(e=new Map,P.set(n,e));let i=`${h}:${u.toLowerCase()}:${m}:${c??"latest"}`,t=e.get(i);if(t&&(e.delete(i),e.set(i,t)),!t){for(t=new Promise((s,T)=>{let a=k.get(n);a||(a=new Map,k.set(n,a));let f=`${h}:${c??"latest"}`,l=a.get(f);if(!l){l=[],a.set(f,l);let d=l;queueMicrotask(async()=>{a.delete(f);let w=d.map(r=>({address:r.address,abi:F,functionName:r.field}));try{if(d.length>1&&n.chain?.contracts?.multicall3&&typeof n.multicall=="function"){let r=await y(()=>n.multicall({contracts:w,blockNumber:c,allowFailure:!0}));d.forEach((o,p)=>{let g=r[p];g?.status==="success"?o.resolve(g.result):o.reject(g?.error??new b("Token metadata could not be read."))})}else await Promise.all(d.map(async(r,o)=>{try{r.resolve(await y(()=>n.readContract({...w[o],blockNumber:c})))}catch(p){r.reject(p)}}))}catch(r){d.forEach(o=>o.reject(r))}})}l.push({address:u,field:m,resolve:s,reject:T})}).then(s=>{if(m==="decimals"?!Number.isInteger(s)||Number(s)<0||Number(s)>255:typeof s!="string"||!s.trim())throw new b("The contract returned invalid token metadata.");return s});e.size>=E;)e.delete(e.keys().next().value);e.set(i,t);let M=t;t.catch(()=>{e.get(i)===M&&e.delete(i)})}try{return await t}finally{c!==void 0&&e.get(i)===t&&e.delete(i)}}export{q as a};
1
+ import{c as A}from"./5HCXZWUH.js";import{s as y}from"./EZUQMTLE.js";import{a as b}from"./XSD5NL7J.js";import{erc20Abi as F,getAddress as $}from"viem";var P=new WeakMap,E=3e3,k=new WeakMap;async function q(C,h,u,m,c){u=$(u);let n=A(C),e=P.get(n);e||(e=new Map,P.set(n,e));let i=`${h}:${u.toLowerCase()}:${m}:${c??"latest"}`,t=e.get(i);if(t&&(e.delete(i),e.set(i,t)),!t){for(t=new Promise((s,T)=>{let a=k.get(n);a||(a=new Map,k.set(n,a));let f=`${h}:${c??"latest"}`,l=a.get(f);if(!l){l=[],a.set(f,l);let d=l;queueMicrotask(async()=>{a.delete(f);let w=d.map(r=>({address:r.address,abi:F,functionName:r.field}));try{if(d.length>1&&n.chain?.contracts?.multicall3&&typeof n.multicall=="function"){let r=await y(()=>n.multicall({contracts:w,blockNumber:c,allowFailure:!0}));d.forEach((o,p)=>{let g=r[p];g?.status==="success"?o.resolve(g.result):o.reject(g?.error??new b("Token metadata could not be read."))})}else await Promise.all(d.map(async(r,o)=>{try{r.resolve(await y(()=>n.readContract({...w[o],blockNumber:c})))}catch(p){r.reject(p)}}))}catch(r){d.forEach(o=>o.reject(r))}})}l.push({address:u,field:m,resolve:s,reject:T})}).then(s=>{if(m==="decimals"?!Number.isInteger(s)||Number(s)<0||Number(s)>255:typeof s!="string"||!s.trim())throw new b("The contract returned invalid token metadata.");return s});e.size>=E;)e.delete(e.keys().next().value);e.set(i,t);let M=t;t.catch(()=>{e.get(i)===M&&e.delete(i)})}try{return await t}finally{c!==void 0&&e.get(i)===t&&e.delete(i)}}export{q as a};
@@ -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{a as f,b as a}from"./CZL6T2ZQ.js";import{a as s,b as c}from"./ZQ6AF3VX.js";import{a as w}from"./DGCJZ3HO.js";import{a as r}from"./XSD5NL7J.js";import{getAddress as d,isAddressEqual as n,keccak256 as b}from"viem";function u(e){if(!/^[0-9]+$/.test(String(e)))throw new r("Provide a Factor job ID as a non-negative integer.");let t=BigInt(e);if(t>=2n**256n)throw new r("The Factor job ID exceeds uint256.");return t}function y(e,t){if(e.codeHash.toLowerCase()!==a.desk.codeHash)throw new r("Factor desk code hash does not match the pin.");if(!n(e.burnPot,a.burnPot.address))throw new r("Factor desk burn pot does not match the pin.");if(!n(e.gateway,a.gateway.address))throw new r("Factor desk gateway does not match the pin.");if(e.stateDesk==="unreachable"){if(t)throw new r(w.stateUnavailable)}else if(!n(e.stateDesk,a.desk.address))throw new r(w.stateMismatch)}async function P(e){if(await e.getChainId()!==f.chainId)throw new r("Factor requires Robinhood Chain 4663.");let[t,o,i,C]=await Promise.all([e.getCode({address:a.desk.address}),e.readContract({address:a.desk.address,abi:s,functionName:"burnPot"}),e.readContract({address:a.desk.address,abi:s,functionName:"gateway"}),e.readContract({address:a.line.address,abi:c,functionName:"desk"})]);if(!n(C,a.desk.address))throw new r("Factor line desk does not match the pin.");return{codeHash:b(t??"0x"),burnPot:d(o),gateway:d(i)}}async function A(e,t){return e.readContract({address:a.desk.address,abi:s,functionName:"job",args:[u(t)]})}async function D(e,t){let[o,i]=await e.readContract({address:a.desk.address,abi:s,functionName:"canDrawOn",args:[u(t)]});return{early:o.toString(),pool:i.toString()}}async function F(e,t){let o=await e.readContract({address:a.line.address,abi:c,functionName:"keyOf",args:[d(t)]});return d(o)}async function I(e,t){let o=await e.getCode({address:d(t)});return o!==void 0&&o!=="0x"}export{y as a,P as b,A as c,D as d,F as e,I as f};
1
+ import{a as f,b as a}from"./CZL6T2ZQ.js";import{a as s,b as c}from"./ZQ6AF3VX.js";import{a as w}from"./UEOS6SHR.js";import{a as r}from"./XSD5NL7J.js";import{getAddress as d,isAddressEqual as n,keccak256 as b}from"viem";function u(e){if(!/^[0-9]+$/.test(String(e)))throw new r("Provide a Factor job ID as a non-negative integer.");let t=BigInt(e);if(t>=2n**256n)throw new r("The Factor job ID exceeds uint256.");return t}function y(e,t){if(e.codeHash.toLowerCase()!==a.desk.codeHash)throw new r("Factor desk code hash does not match the pin.");if(!n(e.burnPot,a.burnPot.address))throw new r("Factor desk burn pot does not match the pin.");if(!n(e.gateway,a.gateway.address))throw new r("Factor desk gateway does not match the pin.");if(e.stateDesk==="unreachable"){if(t)throw new r(w.stateUnavailable)}else if(!n(e.stateDesk,a.desk.address))throw new r(w.stateMismatch)}async function P(e){if(await e.getChainId()!==f.chainId)throw new r("Factor requires Robinhood Chain 4663.");let[t,o,i,C]=await Promise.all([e.getCode({address:a.desk.address}),e.readContract({address:a.desk.address,abi:s,functionName:"burnPot"}),e.readContract({address:a.desk.address,abi:s,functionName:"gateway"}),e.readContract({address:a.line.address,abi:c,functionName:"desk"})]);if(!n(C,a.desk.address))throw new r("Factor line desk does not match the pin.");return{codeHash:b(t??"0x"),burnPot:d(o),gateway:d(i)}}async function A(e,t){return e.readContract({address:a.desk.address,abi:s,functionName:"job",args:[u(t)]})}async function D(e,t){let[o,i]=await e.readContract({address:a.desk.address,abi:s,functionName:"canDrawOn",args:[u(t)]});return{early:o.toString(),pool:i.toString()}}async function F(e,t){let o=await e.readContract({address:a.line.address,abi:c,functionName:"keyOf",args:[d(t)]});return d(o)}async function I(e,t){let o=await e.getCode({address:d(t)});return o!==void 0&&o!=="0x"}export{y as a,P as b,A as c,D as d,F as e,I as f};
@@ -0,0 +1 @@
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};