@oakagentkit/core 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/build/dist/api/addresses.d.ts +14 -0
  2. package/build/dist/api/addresses.js +1 -1
  3. package/build/dist/api/chain.js +1 -1
  4. package/build/dist/api/history.d.ts +2 -0
  5. package/build/dist/api/history.js +1 -1
  6. package/build/dist/api/identity-link.js +1 -1
  7. package/build/dist/api/metadata.js +1 -1
  8. package/build/dist/api/modules/beefy/boosts.js +1 -1
  9. package/build/dist/api/modules/beefy/clm.js +1 -1
  10. package/build/dist/api/modules/beefy/guard.js +1 -1
  11. package/build/dist/api/modules/beefy/index.js +1 -1
  12. package/build/dist/api/modules/beefy/liquidity.js +1 -1
  13. package/build/dist/api/modules/beefy/management.js +1 -1
  14. package/build/dist/api/modules/beefy/vaults.js +1 -1
  15. package/build/dist/api/modules/borro/actions.js +1 -1
  16. package/build/dist/api/modules/borro/index.js +1 -1
  17. package/build/dist/api/modules/borro/liquidity.js +1 -1
  18. package/build/dist/api/modules/borro/positions.js +1 -1
  19. package/build/dist/api/modules/borro/reader.js +1 -1
  20. package/build/dist/api/modules/chop/display.js +1 -1
  21. package/build/dist/api/modules/chop/guard.js +1 -1
  22. package/build/dist/api/modules/chop/index.js +1 -1
  23. package/build/dist/api/modules/clanker/extensions.js +1 -1
  24. package/build/dist/api/modules/clanker/index.js +1 -1
  25. package/build/dist/api/modules/clanker/manage.js +1 -1
  26. package/build/dist/api/modules/clanker/pool-config.js +1 -1
  27. package/build/dist/api/modules/clanker/protocol.js +1 -1
  28. package/build/dist/api/modules/clanker/state.js +1 -1
  29. package/build/dist/api/modules/earn/index.js +1 -1
  30. package/build/dist/api/modules/erc8004/common.js +1 -1
  31. package/build/dist/api/modules/erc8004/domain.js +1 -1
  32. package/build/dist/api/modules/erc8004/index.js +1 -1
  33. package/build/dist/api/modules/erc8004/management.js +1 -1
  34. package/build/dist/api/modules/erc8004/reputation.js +1 -1
  35. package/build/dist/api/modules/erc8004/services.js +1 -1
  36. package/build/dist/api/modules/erc8004/thesis.js +1 -1
  37. package/build/dist/api/modules/erc8004/validation.js +1 -1
  38. package/build/dist/api/modules/fobo/index.js +1 -1
  39. package/build/dist/api/modules/fobo/intent.js +1 -1
  40. package/build/dist/api/modules/fobo/steps.js +1 -1
  41. package/build/dist/api/modules/fobo/verify.js +1 -1
  42. package/build/dist/api/modules/grove/index.js +1 -1
  43. package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
  44. package/build/dist/api/modules/heyresearch/index.js +1 -1
  45. package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
  46. package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
  47. package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
  48. package/build/dist/api/modules/hoodag/index.js +1 -1
  49. package/build/dist/api/modules/hoodag/management.js +1 -1
  50. package/build/dist/api/modules/hoodag/public-reads.js +1 -1
  51. package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
  52. package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
  53. package/build/dist/api/modules/hoodlock/buyback.js +1 -1
  54. package/build/dist/api/modules/hoodlock/commerce.js +1 -1
  55. package/build/dist/api/modules/hoodlock/fee.js +1 -1
  56. package/build/dist/api/modules/hoodlock/guard.js +1 -1
  57. package/build/dist/api/modules/hoodlock/index.js +1 -1
  58. package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
  59. package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
  60. package/build/dist/api/modules/hoodlock/public.js +1 -1
  61. package/build/dist/api/modules/hookr/actions.d.ts +39 -2
  62. package/build/dist/api/modules/hookr/actions.js +1 -1
  63. package/build/dist/api/modules/hookr/addons.js +1 -1
  64. package/build/dist/api/modules/hookr/agent-gate.d.ts +14 -2
  65. package/build/dist/api/modules/hookr/agent-gate.js +1 -1
  66. package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
  67. package/build/dist/api/modules/hookr/agent-link.js +1 -0
  68. package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
  69. package/build/dist/api/modules/hookr/api-client.js +1 -0
  70. package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
  71. package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
  72. package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
  73. package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
  74. package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
  75. package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
  76. package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
  77. package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
  78. package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
  79. package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
  80. package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
  81. package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
  82. package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
  83. package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
  84. package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
  85. package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
  86. package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
  87. package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
  88. package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
  89. package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
  90. package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
  91. package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
  92. package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
  93. package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
  94. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
  95. package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
  96. package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
  97. package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
  98. package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
  99. package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
  100. package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
  101. package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
  102. package/build/dist/api/modules/hookr/claims.d.ts +53 -0
  103. package/build/dist/api/modules/hookr/claims.js +1 -0
  104. package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
  105. package/build/dist/api/modules/hookr/contracts.js +1 -1
  106. package/build/dist/api/modules/hookr/create-cancel.js +1 -1
  107. package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
  108. package/build/dist/api/modules/hookr/discovery.js +1 -1
  109. package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
  110. package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
  111. package/build/dist/api/modules/hookr/gas.d.ts +48 -0
  112. package/build/dist/api/modules/hookr/gas.js +1 -0
  113. package/build/dist/api/modules/hookr/gates.d.ts +51 -0
  114. package/build/dist/api/modules/hookr/gates.js +1 -0
  115. package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
  116. package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
  117. package/build/dist/api/modules/hookr/index.d.ts +4 -2
  118. package/build/dist/api/modules/hookr/index.js +1 -1
  119. package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
  120. package/build/dist/api/modules/hookr/jobs.js +1 -0
  121. package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
  122. package/build/dist/api/modules/hookr/launch-options.js +1 -1
  123. package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
  124. package/build/dist/api/modules/hookr/launch-profile.js +1 -1
  125. package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
  126. package/build/dist/api/modules/hookr/launch.d.ts +24 -0
  127. package/build/dist/api/modules/hookr/launch.js +1 -1
  128. package/build/dist/api/modules/hookr/liquidity.js +1 -1
  129. package/build/dist/api/modules/hookr/lp-positions.js +1 -1
  130. package/build/dist/api/modules/hookr/lp-reads.js +1 -1
  131. package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
  132. package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
  133. package/build/dist/api/modules/hookr/lp-state.js +1 -1
  134. package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
  135. package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
  136. package/build/dist/api/modules/hookr/pins.d.ts +5 -0
  137. package/build/dist/api/modules/hookr/pins.js +1 -1
  138. package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
  139. package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
  140. package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
  141. package/build/dist/api/modules/hookr/public-reads.js +1 -1
  142. package/build/dist/api/modules/hookr/read-utils.js +1 -1
  143. package/build/dist/api/modules/hookr/relay.js +1 -1
  144. package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
  145. package/build/dist/api/modules/hookr/revenue.js +1 -1
  146. package/build/dist/api/modules/hookr/scan.d.ts +25 -0
  147. package/build/dist/api/modules/hookr/scan.js +1 -0
  148. package/build/dist/api/modules/hookr/swap.d.ts +161 -0
  149. package/build/dist/api/modules/hookr/swap.js +1 -0
  150. package/build/dist/api/modules/kyberswap/index.js +1 -1
  151. package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
  152. package/build/dist/api/modules/layerbank/abi.js +1 -1
  153. package/build/dist/api/modules/layerbank/actions.js +1 -1
  154. package/build/dist/api/modules/layerbank/checks.js +1 -1
  155. package/build/dist/api/modules/layerbank/index.js +1 -1
  156. package/build/dist/api/modules/layerbank/merkl.js +1 -1
  157. package/build/dist/api/modules/layerbank/reader.js +1 -1
  158. package/build/dist/api/modules/layerbank/reserve.js +1 -1
  159. package/build/dist/api/modules/lighter/index.js +1 -1
  160. package/build/dist/api/modules/longbow/administration.js +1 -1
  161. package/build/dist/api/modules/longbow/analytics.js +1 -1
  162. package/build/dist/api/modules/longbow/fixed.js +1 -1
  163. package/build/dist/api/modules/longbow/index.js +1 -1
  164. package/build/dist/api/modules/longbow/nft.js +1 -1
  165. package/build/dist/api/modules/longbow/rebates.js +1 -1
  166. package/build/dist/api/modules/longbow/staking.js +1 -1
  167. package/build/dist/api/modules/meridian/index.js +1 -1
  168. package/build/dist/api/modules/meridian/markets.js +1 -1
  169. package/build/dist/api/modules/meridian/rfq.js +1 -1
  170. package/build/dist/api/modules/merkl/discovery.js +1 -1
  171. package/build/dist/api/modules/merkl/index.js +1 -1
  172. package/build/dist/api/modules/merkl/manage.js +1 -1
  173. package/build/dist/api/modules/merkl/protocol.js +1 -1
  174. package/build/dist/api/modules/morpho/allocator.js +1 -1
  175. package/build/dist/api/modules/morpho/bundles.js +1 -1
  176. package/build/dist/api/modules/morpho/in-kind.js +1 -1
  177. package/build/dist/api/modules/morpho/index.js +1 -1
  178. package/build/dist/api/modules/morpho/local-guard.js +1 -1
  179. package/build/dist/api/modules/morpho/midnight.js +1 -1
  180. package/build/dist/api/modules/morpho/protocol.js +1 -1
  181. package/build/dist/api/modules/morpho/vault-management.js +1 -1
  182. package/build/dist/api/modules/morpho/vault-tools.js +1 -1
  183. package/build/dist/api/modules/morpho/vault-v2.js +1 -1
  184. package/build/dist/api/modules/netnet/card-plan.js +1 -1
  185. package/build/dist/api/modules/netnet/card-read.js +1 -1
  186. package/build/dist/api/modules/netnet/card-recovery.js +1 -1
  187. package/build/dist/api/modules/netnet/desk-action.js +1 -1
  188. package/build/dist/api/modules/netnet/desk-read.js +1 -1
  189. package/build/dist/api/modules/netnet/financial.js +1 -1
  190. package/build/dist/api/modules/netnet/index.js +1 -1
  191. package/build/dist/api/modules/netnet/staking.js +1 -1
  192. package/build/dist/api/modules/orbio/index.js +1 -1
  193. package/build/dist/api/modules/orbio/positions.js +1 -1
  194. package/build/dist/api/modules/pendle/costs.js +1 -1
  195. package/build/dist/api/modules/pendle/index.js +1 -1
  196. package/build/dist/api/modules/pendle/markets.js +1 -1
  197. package/build/dist/api/modules/pendle/positions.js +1 -1
  198. package/build/dist/api/modules/pendle/pricecheck.js +1 -1
  199. package/build/dist/api/modules/pendle/reader.js +1 -1
  200. package/build/dist/api/modules/pendle/redeem.js +1 -1
  201. package/build/dist/api/modules/pendle/trade.js +1 -1
  202. package/build/dist/api/modules/pendle/validate.js +1 -1
  203. package/build/dist/api/modules/pendle/verify.js +1 -1
  204. package/build/dist/api/modules/pons/claim.js +1 -1
  205. package/build/dist/api/modules/pons/index.js +1 -1
  206. package/build/dist/api/modules/pons/launch-status.js +1 -1
  207. package/build/dist/api/modules/pons/prices.js +1 -1
  208. package/build/dist/api/modules/pons/reads.js +1 -1
  209. package/build/dist/api/modules/pons/swap-terms.js +1 -1
  210. package/build/dist/api/modules/pons/trade.js +1 -1
  211. package/build/dist/api/modules/poolstrade/index.js +1 -1
  212. package/build/dist/api/modules/priors/coverage.js +1 -1
  213. package/build/dist/api/modules/priors/discovery.js +1 -1
  214. package/build/dist/api/modules/priors/features.js +1 -1
  215. package/build/dist/api/modules/priors/holdings.js +1 -1
  216. package/build/dist/api/modules/priors/index.js +1 -1
  217. package/build/dist/api/modules/priors/integration.js +1 -1
  218. package/build/dist/api/modules/priors/market.js +1 -1
  219. package/build/dist/api/modules/priors/pt.js +1 -1
  220. package/build/dist/api/modules/priors/savings-exit.js +1 -1
  221. package/build/dist/api/modules/priors/starter-line.js +1 -1
  222. package/build/dist/api/modules/priors/stock-swap.js +1 -1
  223. package/build/dist/api/modules/raeto/index.js +1 -1
  224. package/build/dist/api/modules/relay/bootstrap.js +1 -1
  225. package/build/dist/api/modules/relay/discovery.js +1 -1
  226. package/build/dist/api/modules/relay/inbound.js +1 -1
  227. package/build/dist/api/modules/relay/index.js +1 -1
  228. package/build/dist/api/modules/relay/outbound-status.js +1 -1
  229. package/build/dist/api/modules/relay/reads.js +1 -1
  230. package/build/dist/api/modules/spark/actions.js +1 -1
  231. package/build/dist/api/modules/spark/details.js +1 -1
  232. package/build/dist/api/modules/spark/index.js +1 -1
  233. package/build/dist/api/modules/spark/management.js +1 -1
  234. package/build/dist/api/modules/steakhouse/analytics.js +1 -1
  235. package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
  236. package/build/dist/api/modules/steakhouse/index.js +1 -1
  237. package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
  238. package/build/dist/api/modules/steakhouse/management.js +1 -1
  239. package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
  240. package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
  241. package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
  242. package/build/dist/api/modules/tickerspring/discovery.js +1 -1
  243. package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
  244. package/build/dist/api/modules/tickerspring/guards.js +1 -1
  245. package/build/dist/api/modules/tickerspring/index.js +1 -1
  246. package/build/dist/api/modules/tickerspring/journeys.js +1 -1
  247. package/build/dist/api/modules/tickerspring/ladder.js +1 -1
  248. package/build/dist/api/modules/tickerspring/maker.js +1 -1
  249. package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
  250. package/build/dist/api/modules/tickerspring/research.js +1 -1
  251. package/build/dist/api/modules/tickerspring/strategies.js +1 -1
  252. package/build/dist/api/modules/uniswap/auction-create.js +1 -1
  253. package/build/dist/api/modules/uniswap/auction.js +1 -1
  254. package/build/dist/api/modules/uniswap/batch.js +1 -1
  255. package/build/dist/api/modules/uniswap/common.js +1 -1
  256. package/build/dist/api/modules/uniswap/fees.js +1 -1
  257. package/build/dist/api/modules/uniswap/index.js +1 -1
  258. package/build/dist/api/modules/uniswap/local-guard.js +1 -1
  259. package/build/dist/api/modules/uniswap/oracle.js +1 -1
  260. package/build/dist/api/modules/uniswap/pool-math.js +1 -1
  261. package/build/dist/api/modules/uniswap/pools.js +1 -1
  262. package/build/dist/api/modules/uniswap/position.js +1 -1
  263. package/build/dist/api/modules/uniswap/protocol.js +1 -1
  264. package/build/dist/api/modules/uniswap/quote-guard.js +1 -1
  265. package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
  266. package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
  267. package/build/dist/api/modules/uniswap/stocks.js +1 -1
  268. package/build/dist/api/modules/uniswap/token-jar.js +1 -1
  269. package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
  270. package/build/dist/api/modules/uniswap/trade.js +1 -1
  271. package/build/dist/api/modules/uniswap/v2.js +1 -1
  272. package/build/dist/api/modules/uniswap/v3.js +1 -1
  273. package/build/dist/api/modules/uniswap/v4.js +1 -1
  274. package/build/dist/api/modules/uniswap/wrap.js +1 -1
  275. package/build/dist/api/modules/upoch/index.js +1 -1
  276. package/build/dist/api/modules/upoch/reads.js +1 -1
  277. package/build/dist/api/modules/velora/claims.js +1 -1
  278. package/build/dist/api/modules/velora/delta-reads.js +1 -1
  279. package/build/dist/api/modules/velora/index.js +1 -1
  280. package/build/dist/api/modules/wormhole/index.js +1 -1
  281. package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
  282. package/build/dist/api/positions.js +1 -1
  283. package/build/dist/api/pricenote.js +1 -1
  284. package/build/dist/api/prices.js +1 -1
  285. package/build/dist/api/rpc.js +1 -1
  286. package/build/dist/api/send.js +1 -1
  287. package/build/dist/api/signing-registry.js +1 -1
  288. package/build/dist/api/signing.js +1 -1
  289. package/build/dist/api/simulate.js +1 -1
  290. package/build/dist/api/swap.d.ts +2 -0
  291. package/build/dist/api/swap.js +1 -1
  292. package/build/dist/api/tokens.d.ts +9 -1
  293. package/build/dist/api/tokens.js +1 -1
  294. package/build/dist/api/tool-policy.js +1 -1
  295. package/build/dist/api/universal-router.js +1 -1
  296. package/build/dist/api/usd-estimate.js +1 -1
  297. package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
  298. package/build/dist/chunks/{R66NSNNQ.js → 2BKZLF5A.js} +1 -1
  299. package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
  300. package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
  301. package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
  302. package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
  303. package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
  304. package/build/dist/chunks/{C57DITTF.js → 3HF6WE4L.js} +1 -1
  305. package/build/dist/chunks/3M7RMROZ.js +1 -0
  306. package/build/dist/chunks/3RGED2KO.js +1 -0
  307. package/build/dist/chunks/{4HQEJHCD.js → 3XIJCHT7.js} +1 -1
  308. package/build/dist/chunks/3XY44BP5.js +1 -0
  309. package/build/dist/chunks/3YNXQ3EZ.js +1 -0
  310. package/build/dist/chunks/45QP74CE.js +1 -0
  311. package/build/dist/chunks/{SX5YNFHG.js → 4GAU3JLN.js} +1 -1
  312. package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
  313. package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
  314. package/build/dist/chunks/{QMIH6HXH.js → 4SXRXNHG.js} +1 -1
  315. package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
  316. package/build/dist/chunks/{FRT6AC6M.js → 5677LZOV.js} +1 -1
  317. package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
  318. package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
  319. package/build/dist/chunks/{JDHPMS7X.js → 5DWQUEBA.js} +1 -1
  320. package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
  321. package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
  322. package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
  323. package/build/dist/chunks/5PNFV7HH.js +1 -0
  324. package/build/dist/chunks/5RAZFRO4.js +1 -0
  325. package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
  326. package/build/dist/chunks/5VKVAUFQ.js +1 -0
  327. package/build/dist/chunks/5Y457HYC.js +1 -0
  328. package/build/dist/chunks/64LAWFBE.js +1 -0
  329. package/build/dist/chunks/{3BQ5XHDJ.js → 6EWSLHXL.js} +1 -1
  330. package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
  331. package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
  332. package/build/dist/chunks/{TZ7S5KRB.js → 6QXTL65K.js} +1 -1
  333. package/build/dist/chunks/6RVAV6BB.js +1 -0
  334. package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
  335. package/build/dist/chunks/{RUHNLNVX.js → 6Y2546JA.js} +1 -1
  336. package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
  337. package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
  338. package/build/dist/chunks/7GL547YZ.js +1 -0
  339. package/build/dist/chunks/7JTXYMNP.js +1 -0
  340. package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
  341. package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
  342. package/build/dist/chunks/{WQ2XTDHO.js → 7X5JVF3F.js} +1 -1
  343. package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
  344. package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
  345. package/build/dist/chunks/AODUTN65.js +1 -0
  346. package/build/dist/chunks/{DBOGRUPS.js → AONO47JX.js} +1 -1
  347. package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
  348. package/build/dist/chunks/AZBTNUXF.js +1 -0
  349. package/build/dist/chunks/{TOIKOIY6.js → B5BU645H.js} +1 -1
  350. package/build/dist/chunks/{ZX43P4BK.js → B75SS7H6.js} +1 -1
  351. package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
  352. package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
  353. package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
  354. package/build/dist/chunks/BM4KHOFB.js +1 -0
  355. package/build/dist/chunks/{N65J3L2H.js → BSV65PCA.js} +1 -1
  356. package/build/dist/chunks/{ZVY7GGSP.js → BW755PNH.js} +1 -1
  357. package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
  358. package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
  359. package/build/dist/chunks/{CNDIAF3P.js → C2H3BWN5.js} +1 -1
  360. package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
  361. package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
  362. package/build/dist/chunks/CJMVRV34.js +1 -0
  363. package/build/dist/chunks/CQPIR6ER.js +1 -0
  364. package/build/dist/chunks/{A4K5GXVO.js → CR7DPGI6.js} +1 -1
  365. package/build/dist/chunks/{UUF4Z6K6.js → CVVNAFUE.js} +1 -1
  366. package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
  367. package/build/dist/chunks/{2PS4GCOZ.js → DJRS3TR5.js} +1 -1
  368. package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
  369. package/build/dist/chunks/{MQXSCNUL.js → DPSFR3ZS.js} +1 -1
  370. package/build/dist/chunks/{LKUZAJPZ.js → DV2HVFTM.js} +1 -1
  371. package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
  372. package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
  373. package/build/dist/chunks/EHQRAA3R.js +1 -0
  374. package/build/dist/chunks/{A4FLWHLP.js → EJIP7RBG.js} +1 -1
  375. package/build/dist/chunks/EWZFZUVF.js +1 -0
  376. package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
  377. package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
  378. package/build/dist/chunks/{O2QBSINK.js → F36IA5RI.js} +1 -1
  379. package/build/dist/chunks/{XTXXWRN2.js → F74ARK4H.js} +1 -1
  380. package/build/dist/chunks/{HPS4KOU4.js → FGGDAAHW.js} +1 -1
  381. package/build/dist/chunks/FMEO7RX7.js +1 -0
  382. package/build/dist/chunks/{FHB7QYJO.js → FN6XY6ET.js} +1 -1
  383. package/build/dist/chunks/G4IX4CYN.js +1 -0
  384. package/build/dist/chunks/G53U6Y4L.js +1 -0
  385. package/build/dist/chunks/{HDBZZOHJ.js → GBIL2I2K.js} +1 -1
  386. package/build/dist/chunks/{MJGEGNDU.js → GCFHKJIO.js} +1 -1
  387. package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
  388. package/build/dist/chunks/GTJ6LBGB.js +1 -0
  389. package/build/dist/chunks/GV6Z3MET.js +1 -0
  390. package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
  391. package/build/dist/chunks/GX2RCAHG.js +1 -0
  392. package/build/dist/chunks/{7TRO6MBQ.js → H5KU4DUU.js} +1 -1
  393. package/build/dist/chunks/H7ZJ7LAB.js +1 -0
  394. package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
  395. package/build/dist/chunks/{6CKCZJ3F.js → HEQBTHFS.js} +1 -1
  396. package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
  397. package/build/dist/chunks/HJI7KO6F.js +1 -0
  398. package/build/dist/chunks/{KO7ANIKY.js → HNBYPHTA.js} +1 -1
  399. package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
  400. package/build/dist/chunks/HPO673QQ.js +1 -0
  401. package/build/dist/chunks/{4IOHSX3Z.js → HRGLFGFL.js} +1 -1
  402. package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
  403. package/build/dist/chunks/IJVBCEA2.js +1 -0
  404. package/build/dist/chunks/{N742W5KX.js → IKVRFAUP.js} +1 -1
  405. package/build/dist/chunks/IM7ZF7XZ.js +1 -0
  406. package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
  407. package/build/dist/chunks/IR7KDBFU.js +1 -0
  408. package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
  409. package/build/dist/chunks/IYOWMW5B.js +1 -0
  410. package/build/dist/chunks/J2J73XYU.js +1 -0
  411. package/build/dist/chunks/JCS24YBB.js +1 -0
  412. package/build/dist/chunks/JQVTHPUO.js +1 -0
  413. package/build/dist/chunks/{USGMGKAG.js → JTWJT2O3.js} +1 -1
  414. package/build/dist/chunks/{W7BFM6CK.js → K4CYAWNL.js} +1 -1
  415. package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
  416. package/build/dist/chunks/K5OXLIPK.js +1 -0
  417. package/build/dist/chunks/{ZKBOPZH5.js → K6GECT3F.js} +1 -1
  418. package/build/dist/chunks/{6LVHN33V.js → KB2JWQZ4.js} +1 -1
  419. package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
  420. package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
  421. package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
  422. package/build/dist/chunks/{JJSCDDQO.js → L3IAEXQR.js} +1 -1
  423. package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
  424. package/build/dist/chunks/{YWVPK3DV.js → L76P6WIH.js} +1 -1
  425. package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
  426. package/build/dist/chunks/LD3A2KLN.js +1 -0
  427. package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
  428. package/build/dist/chunks/{ZQPC54J5.js → LKRAUTYI.js} +1 -1
  429. package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
  430. package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
  431. package/build/dist/chunks/MFQTBUSD.js +1 -0
  432. package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
  433. package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
  434. package/build/dist/chunks/{O4P5IQCP.js → MXI7LX2F.js} +1 -1
  435. package/build/dist/chunks/N6YNJGEF.js +1 -0
  436. package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
  437. package/build/dist/chunks/NUTTPUYJ.js +1 -0
  438. package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
  439. package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
  440. package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
  441. package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
  442. package/build/dist/chunks/{E47UYYK4.js → OIGTTRN5.js} +1 -1
  443. package/build/dist/chunks/{2I7XHRTI.js → P6JE2NRA.js} +1 -1
  444. package/build/dist/chunks/PD5NXIRT.js +1 -0
  445. package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
  446. package/build/dist/chunks/{VREGY7E6.js → PMFR47H3.js} +1 -1
  447. package/build/dist/chunks/{PV7FEVBD.js → PXVF2SHU.js} +1 -1
  448. package/build/dist/chunks/{2FOI2625.js → Q43WPRYU.js} +1 -1
  449. package/build/dist/chunks/QAAKUIWE.js +1 -0
  450. package/build/dist/chunks/{ZXFJKW6H.js → QAVP3CWL.js} +1 -1
  451. package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
  452. package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
  453. package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
  454. package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
  455. package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
  456. package/build/dist/chunks/{ZXRIJG6H.js → QP2B7AYX.js} +1 -1
  457. package/build/dist/chunks/{TJU644I7.js → QZ6V6J6W.js} +1 -1
  458. package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
  459. package/build/dist/chunks/RKJFSDGV.js +1 -0
  460. package/build/dist/chunks/RKS3M7L5.js +1 -0
  461. package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
  462. package/build/dist/chunks/{IZP3EKKS.js → RYEQIZ2H.js} +1 -1
  463. package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
  464. package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
  465. package/build/dist/chunks/{KKTOBXIT.js → SRYX65GZ.js} +1 -1
  466. package/build/dist/chunks/{GKUPC4DO.js → TMENUIBC.js} +1 -1
  467. package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
  468. package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
  469. package/build/dist/chunks/TTBB6EFN.js +1 -0
  470. package/build/dist/chunks/{FRVCSDKU.js → TWVDWNTG.js} +1 -1
  471. package/build/dist/chunks/TZG7HTVM.js +1 -0
  472. package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
  473. package/build/dist/chunks/{G5AMH4IP.js → UGFRBJDQ.js} +1 -1
  474. package/build/dist/chunks/{OB3YMTDI.js → UIVOYAO2.js} +1 -1
  475. package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
  476. package/build/dist/chunks/UNBRUWSV.js +1 -0
  477. package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
  478. package/build/dist/chunks/{TGXEKBLV.js → URTQNYWU.js} +1 -1
  479. package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
  480. package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
  481. package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
  482. package/build/dist/chunks/{LZM3DO5Q.js → W5GWK72I.js} +1 -1
  483. package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
  484. package/build/dist/chunks/{3YH5B5NQ.js → WUONMIA2.js} +1 -1
  485. package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
  486. package/build/dist/chunks/{XADHV2DT.js → X53QVHBC.js} +1 -1
  487. package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
  488. package/build/dist/chunks/XUDQYSPU.js +1 -0
  489. package/build/dist/chunks/{S37D7HOK.js → XWZ5SL5Q.js} +1 -1
  490. package/build/dist/chunks/{NIWAVMDR.js → XXLQDQEX.js} +1 -1
  491. package/build/dist/chunks/{QBNASL3T.js → Y5T36EEU.js} +1 -1
  492. package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
  493. package/build/dist/chunks/ZSGW2ZSO.js +1 -0
  494. package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
  495. package/package.json +1 -1
  496. package/build/dist/chunks/5H7NVE6O.js +0 -1
  497. package/build/dist/chunks/7OOCAZBE.js +0 -1
  498. package/build/dist/chunks/DFM4T6ZE.js +0 -1
  499. package/build/dist/chunks/FCVH4FYH.js +0 -1
  500. package/build/dist/chunks/GDUKZYE2.js +0 -1
  501. package/build/dist/chunks/GYPMUYB5.js +0 -1
  502. package/build/dist/chunks/J7OZLXSG.js +0 -1
  503. package/build/dist/chunks/JFC2QCMW.js +0 -1
  504. package/build/dist/chunks/M6JNGU4E.js +0 -1
  505. package/build/dist/chunks/M7OVMIIE.js +0 -1
  506. package/build/dist/chunks/MQK6OP7S.js +0 -1
  507. package/build/dist/chunks/N624NR7Y.js +0 -1
  508. package/build/dist/chunks/OSMOBKRQ.js +0 -1
  509. package/build/dist/chunks/Q3Q3YHEX.js +0 -1
  510. package/build/dist/chunks/QQD4PV64.js +0 -1
  511. package/build/dist/chunks/RN3WUJIO.js +0 -1
  512. package/build/dist/chunks/RP5VCG54.js +0 -1
  513. package/build/dist/chunks/TI727O2H.js +0 -1
  514. package/build/dist/chunks/UHIJMDD2.js +0 -1
  515. package/build/dist/chunks/W32UECOL.js +0 -1
  516. package/build/dist/chunks/WWNAGOCD.js +0 -1
  517. package/build/dist/chunks/XWC6IC5E.js +0 -1
@@ -1 +1 @@
1
- import{e as h,i as y}from"./JDHPMS7X.js";import{b as l,e as f,g as v}from"./ZXRIJG6H.js";import{c as p}from"./NWNYJ26T.js";import{b as g}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{parseAbi as C,zeroAddress as I}from"viem";var N=C(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function B(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:{...p,description:"Lower sorted ERC-20 token address; use WETH for native ETH in v3."},token1:{...p,description:"Higher sorted ERC-20 token address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",minimum:0,maximum:999999},secondsAgo:{description:"Oracle lookback duration in seconds; a positive integer.",type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=l(t.token0),c=l(t.token1),o=t.fee,e=t.secondsAgo;if(BigInt(a)>=BigInt(c))throw new r("Oracle tokens must be strictly sorted token0 < token1.");if(typeof o!="number"||!Number.isInteger(o)||o<0||o>=1e6||typeof e!="number"||!Number.isInteger(e)||e<=0||e>4294967295)throw new r("Provide integer fee pips and a positive uint32 secondsAgo.");let d=s.clientFor(g),i=await d.getBlockNumber(),m=await d.readContract({address:h.factory,abi:y,functionName:"getPool",args:[a,c,o],blockNumber:i});if(m===I)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,A]=await Promise.all([d.readContract({address:m,abi:N,functionName:"observe",args:[[e,0]],blockNumber:i}),f(s,a,i),f(s,c,i)]);if(n.length!==2||k.length!==2)throw new r("Oracle returned an unexpected observation count.");let u=n[1]-n[0],b=BigInt(e),P=u/b-(u<0n&&u%b!==0n?1n:0n);return{pool:m,token0:w,token1:A,secondsAgo:e,blockNumber:i.toString(),tickCumulatives:n.map(String),secondsPerLiquidityCumulativeX128s:k.map(String),arithmeticMeanTick:P.toString(),summary:"V3 time-weighted arithmetic mean tick, rounded toward negative infinity. Price is token1-base-units per token0-base-unit before decimal adjustment. Insufficient pool history reverts; an unavailable oracle is never reported as zero."}}}]}}export{B as a};
1
+ import{e as h,i as y}from"./5DWQUEBA.js";import{b as l,e as f,g as v}from"./QP2B7AYX.js";import{c as p}from"./NWNYJ26T.js";import{b as g}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{parseAbi as C,zeroAddress as I}from"viem";var N=C(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function B(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:{...p,description:"Lower sorted ERC-20 token address; use WETH for native ETH in v3."},token1:{...p,description:"Higher sorted ERC-20 token address."},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"integer",minimum:0,maximum:999999},secondsAgo:{description:"Oracle lookback duration in seconds; a positive integer.",type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=l(t.token0),c=l(t.token1),o=t.fee,e=t.secondsAgo;if(BigInt(a)>=BigInt(c))throw new r("Oracle tokens must be strictly sorted token0 < token1.");if(typeof o!="number"||!Number.isInteger(o)||o<0||o>=1e6||typeof e!="number"||!Number.isInteger(e)||e<=0||e>4294967295)throw new r("Provide integer fee pips and a positive uint32 secondsAgo.");let d=s.clientFor(g),i=await d.getBlockNumber(),m=await d.readContract({address:h.factory,abi:y,functionName:"getPool",args:[a,c,o],blockNumber:i});if(m===I)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,A]=await Promise.all([d.readContract({address:m,abi:N,functionName:"observe",args:[[e,0]],blockNumber:i}),f(s,a,i),f(s,c,i)]);if(n.length!==2||k.length!==2)throw new r("Oracle returned an unexpected observation count.");let u=n[1]-n[0],b=BigInt(e),P=u/b-(u<0n&&u%b!==0n?1n:0n);return{pool:m,token0:w,token1:A,secondsAgo:e,blockNumber:i.toString(),tickCumulatives:n.map(String),secondsPerLiquidityCumulativeX128s:k.map(String),arithmeticMeanTick:P.toString(),summary:"V3 time-weighted arithmetic mean tick, rounded toward negative infinity. Price is token1-base-units per token0-base-unit before decimal adjustment. Insufficient pool history reverts; an unavailable oracle is never reported as zero."}}}]}}export{B as a};
@@ -1 +1 @@
1
- import{d as O}from"./X24YTJST.js";import{a as V}from"./43LI5NKJ.js";import{a as I}from"./66F5ZH34.js";import{g as D}from"./NWNYJ26T.js";import{b as v,j as _}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{decodeAbiParameters as E,encodeAbiParameters as K,encodeFunctionData as h,getAddress as P,keccak256 as Y,parseAbi as H,parseAbiParameters as B}from"viem";var y=P("0xCe5c1aFa115fF8b1D6913509bfc79D9AE08CC857"),G=P("0x0FBad98595b0186dA120E41f77C102beb49f803c"),N=B("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),A="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",m=H(["function vaultV2Factory() view returns (address)","function vaultData(address) view returns (bool canPullFromIdle,uint64 penalty)","function absoluteCap(address,bytes32) view returns (uint256)","function canPullFromMarket(address,bytes32) view returns (bool)","function isActiveAdapter(address,address) view returns (bool)",`function reallocate(address vault,address deallocateAdapter,${A} deallocateMarketParams,address allocateAdapter,${A} allocateMarketParams,uint128 assets,uint64 penalty)`,`function allocateFromIdle(address vault,address adapter,${A} marketParams,uint128 assets,uint64 penalty)`,`function setAbsoluteCap(address vault,address adapter,${A} marketParams,uint256 newAbsoluteCap)`,`function setCanPullFromMarket(address vault,address adapter,${A} marketParams,bool newCanPullFromMarket)`,"function setCanPullFromIdle(address vault,bool newCanPullFromIdle)","function setIsActiveAdapter(address vault,address adapter,bool newIsActiveAdapter)","function setPenalty(address vault,uint64 newPenalty)"]),$=H(["function isAllocator(address) view returns (bool)","function allocation(bytes32) view returns (uint256)"]),z=H(["function isVaultV2(address) view returns (bool)"]),w=_[v],L=[{vault:w.vaults.netnet.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowCore.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowFrontier.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowEth.address,underlying:w.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(n,c=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(c))throw new r("Provide uint decimal base-unit strings.");return BigInt(n)}function q(n){if(typeof n!="string"||!/^0x[0-9a-f]{64}$/i.test(n))throw new r("Provide the exact bytes32 marketId.");return n.toLowerCase()}var M=(n,c)=>n<c?n:c;async function Q(n,c){let l=L.find(u=>typeof c.vault=="string"&&D(u.vault,c.vault));if(!l)throw new r("Choose a pinned NetNet or Longbow V2 vault.");let a={address:P(l.underlying),chainId:v,symbol:l.symbol,decimals:l.decimals},o=n.clientFor(v),e=await O(o,l.vault,a),i=(u,T,j,J=[])=>o.readContract({address:u,abi:T,functionName:j,args:J,blockNumber:e.blockNumber}),t=q(c.marketId),s=e.markets.find(u=>u.id.toLowerCase()===t);if(!s)throw new r("Target market is not in this verified vault adapter inventory.");let[p,b,k,f,U]=await Promise.all([i(y,m,"vaultV2Factory"),i(G,z,"isVaultV2",[l.vault]),i(l.vault,$,"isAllocator",[y]),i(y,m,"vaultData",[l.vault]),i(y,m,"isActiveAdapter",[l.vault,s.adapter])]);if(typeof p!="string"||P(p)!==G||b!==!0||!Array.isArray(f)||f.length!==2||typeof f[0]!="boolean"||typeof f[1]!="bigint")throw new r("Invalid Public Allocator deployment or vault configuration.");let[d]=E(N,s.data);if(P(d.irm)!==P(w.morpho.adaptive_curve_irm.address))throw new r("Public allocation requires the pinned Adaptive Curve IRM.");let g=(u,T)=>Y(K(B(`string,address,${A}`),["this/marketParams",T,E(N,u)[0]])),C=g(s.data,s.adapter),[S,F]=await Promise.all([i(y,m,"absoluteCap",[l.vault,C]),i(l.vault,$,"allocation",[C])]);if(typeof S!="bigint"||typeof F!="bigint")throw new r("Invalid allocator cap read.");let R=S>F?S-F:0n,W=await Promise.all(e.markets.filter(u=>u.id.toLowerCase()!==t).map(async u=>({...u,canPull:await i(y,m,"canPullFromMarket",[l.vault,g(u.data,u.adapter)])===!0})));return{client:o,read:i,asset:a,definition:l,data:e,target:s,params:d,permission:k===!0&&U===!0,canIdle:f[0],penalty:f[1],headroom:R,sources:W}}var st=n=>{let c=a=>Q(n,a),l=(a,o,e,i)=>{let t={vault:{type:"string",enum:L.map(s=>s.vault),description:"Pinned NetNet or Longbow V2 vault address on chain 4663; use netnet_list or longbow_list for vault names."},marketId:{type:"string",description:"Target Morpho Blue market id (0x + 64 hex digits) that must be in this vault's adapter inventory."},...o};return{name:a,inputSchema:{type:"object",properties:t,required:["vault","marketId",...e],additionalProperties:!1},execute:async(s,p)=>{try{if(V(p),Object.keys(s).some(b=>!Object.hasOwn(t,b)))throw new r("Unsupported Public Allocator argument.");return await i(s,p)}catch(b){throw new r(n.plainError(b))}}}};return{tools:[l("morpho_allocator",{},[],async a=>{let o=await c(a);return{chainId:v,allocator:y,vault:o.definition.vault,targetMarketId:o.target.id,asset:o.asset,blockNumber:o.data.blockNumber.toString(),enabled:o.permission,penaltyWad:o.penalty.toString(),absoluteCapHeadroom:o.headroom.toString(),idleUpperBound:(o.permission&&o.canIdle?M(o.data.idle,o.headroom):0n).toString(),sources:o.sources.map(e=>({marketId:e.id,canPull:e.canPull,assetsUpperBound:(o.permission&&e.canPull?M(M(e.capacity,o.data.blueCash),o.headroom):0n).toString()})),caveat:"Upper bounds only; vault relative/absolute caps, accrual and liquidity still constrain execution. Preview an explicit source and amount with morpho_reallocate. This standalone allocation charges its disclosed penalty; a later borrow is a separate transaction and can fail or lose the added liquidity to another borrower."}}),l("morpho_reallocate",{sourceMarketId:{type:"string",description:"A returned source market ID, or omit to allocate idle assets."},assets:I(`Amount to move into the target market, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "1000000" = 1 USDG.`),maxPenaltyAssets:I(`Highest penalty you accept, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "10000" = 0.01 USDG.`)},["assets","maxPenaltyAssets"],async(a,o)=>{let e=x(a.assets,128),i=x(a.maxPenaltyAssets),t=await c(a);if(!t.permission||e===0n||e>t.headroom||t.penalty>10n**18n)throw new r("Public allocation is disabled or the requested amount exceeds target headroom.");let s=(e*t.penalty+10n**18n-1n)/10n**18n;if(s>i)throw new r("Allocator penalty exceeds maxPenaltyAssets.");let p;if(a.sourceMarketId===void 0){if(!t.canIdle||e>t.data.idle)throw new r("Public idle allocation is disabled or idle funds are insufficient.");p=h({abi:m,functionName:"allocateFromIdle",args:[t.definition.vault,t.target.adapter,t.params,e,t.penalty]})}else{let d=t.sources.find(C=>C.id.toLowerCase()===q(a.sourceMarketId));if(!d||!d.canPull||e>M(d.capacity,t.data.blueCash))throw new r("The source cannot publicly supply the requested liquidity.");let[g]=E(N,d.data);p=h({abi:m,functionName:"reallocate",args:[t.definition.vault,d.adapter,g,t.target.adapter,t.params,e,t.penalty]})}let b=`Move ${e} ${t.asset.symbol} base units inside ${t.definition.vault} to market ${t.target.id}; pay ${s} ${t.asset.symbol} base units as a donation penalty. This is a standalone reallocation; a subsequent borrow is separate and not guaranteed.`,k=[...s?[n.approval(t.asset.address,y,s.toString(),v)]:[],n.unsignedTx({to:y,data:p,value:"0",chainId:v,description:b})],f=await n.preview(k,o);if(f.changes.filter(d=>d.token.chainId===v&&D(d.token.address,t.asset.address)&&d.token.decimals===t.asset.decimals).reduce((d,g)=>d+BigInt(g.amount),0n)!==-s)throw new r("Allocator preview does not match the exact donation penalty.");return{txs:k,preview:f,penaltyAmount:s.toString(),summary:`${b} The calldata binds the current penalty rate. ${f.summary}`}}),l("morpho_manage_allocator",{operation:{enum:["setIsActiveAdapter","setCanPullFromMarket","setCanPullFromIdle","setAbsoluteCap","setPenalty"],description:"Allocator setting to change: adapter active flag, market pull permission, idle pull permission, absolute cap, or penalty rate."},enabled:{type:"boolean",description:"New true/false value for setIsActiveAdapter, setCanPullFromMarket or setCanPullFromIdle."},amount:I(`For setAbsoluteCap: cap in base units of the vault's asset ("1000000" = 1 USDG). For setPenalty: 18-decimal wad base units (1e18 = 100%).`)},["operation"],async(a,o)=>{let e=await c(a);if(await e.read(e.definition.vault,$,"isAllocator",[o])!==!0)throw new r("This wallet is not an allocator of this vault.");let i=a.enabled,t;if(a.operation==="setAbsoluteCap")t=h({abi:m,functionName:"setAbsoluteCap",args:[e.definition.vault,e.target.adapter,e.params,x(a.amount)]});else if(a.operation==="setPenalty"){let b=x(a.amount,64);if(b>10n**18n)throw new r("Public Allocator penalty must not exceed 1e18.");t=h({abi:m,functionName:"setPenalty",args:[e.definition.vault,b]})}else{if(typeof i!="boolean")throw new r("Provide enabled as a boolean.");if(a.operation==="setIsActiveAdapter")t=h({abi:m,functionName:"setIsActiveAdapter",args:[e.definition.vault,e.target.adapter,i]});else if(a.operation==="setCanPullFromMarket")t=h({abi:m,functionName:"setCanPullFromMarket",args:[e.definition.vault,e.target.adapter,e.params,i]});else if(a.operation==="setCanPullFromIdle")t=h({abi:m,functionName:"setCanPullFromIdle",args:[e.definition.vault,i]});else throw new r("Choose a supported allocator configuration operation.")}let s=`Configure Morpho Public Allocator ${String(a.operation)}: ${JSON.stringify(a)}.`,p=[n.unsignedTx({to:y,data:t,value:"0",chainId:v,description:s})];return{txs:p,preview:await n.preview(p,o),summary:s}})]}};export{y as a,G as b,m as c,Q as d,st as e};
1
+ import{d as O}from"./IY7FWTAL.js";import{a as V}from"./43LI5NKJ.js";import{a as I}from"./66F5ZH34.js";import{g as D}from"./NWNYJ26T.js";import{b as v,j as _}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{decodeAbiParameters as E,encodeAbiParameters as K,encodeFunctionData as h,getAddress as P,keccak256 as Y,parseAbi as H,parseAbiParameters as B}from"viem";var y=P("0xCe5c1aFa115fF8b1D6913509bfc79D9AE08CC857"),G=P("0x0FBad98595b0186dA120E41f77C102beb49f803c"),N=B("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),A="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",m=H(["function vaultV2Factory() view returns (address)","function vaultData(address) view returns (bool canPullFromIdle,uint64 penalty)","function absoluteCap(address,bytes32) view returns (uint256)","function canPullFromMarket(address,bytes32) view returns (bool)","function isActiveAdapter(address,address) view returns (bool)",`function reallocate(address vault,address deallocateAdapter,${A} deallocateMarketParams,address allocateAdapter,${A} allocateMarketParams,uint128 assets,uint64 penalty)`,`function allocateFromIdle(address vault,address adapter,${A} marketParams,uint128 assets,uint64 penalty)`,`function setAbsoluteCap(address vault,address adapter,${A} marketParams,uint256 newAbsoluteCap)`,`function setCanPullFromMarket(address vault,address adapter,${A} marketParams,bool newCanPullFromMarket)`,"function setCanPullFromIdle(address vault,bool newCanPullFromIdle)","function setIsActiveAdapter(address vault,address adapter,bool newIsActiveAdapter)","function setPenalty(address vault,uint64 newPenalty)"]),$=H(["function isAllocator(address) view returns (bool)","function allocation(bytes32) view returns (uint256)"]),z=H(["function isVaultV2(address) view returns (bool)"]),w=_[v],L=[{vault:w.vaults.netnet.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowCore.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowFrontier.address,underlying:w.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:w.vaults.longbowEth.address,underlying:w.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(n,c=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(c))throw new r("Provide uint decimal base-unit strings.");return BigInt(n)}function q(n){if(typeof n!="string"||!/^0x[0-9a-f]{64}$/i.test(n))throw new r("Provide the exact bytes32 marketId.");return n.toLowerCase()}var M=(n,c)=>n<c?n:c;async function Q(n,c){let l=L.find(u=>typeof c.vault=="string"&&D(u.vault,c.vault));if(!l)throw new r("Choose a pinned NetNet or Longbow V2 vault.");let a={address:P(l.underlying),chainId:v,symbol:l.symbol,decimals:l.decimals},o=n.clientFor(v),e=await O(o,l.vault,a),i=(u,T,j,J=[])=>o.readContract({address:u,abi:T,functionName:j,args:J,blockNumber:e.blockNumber}),t=q(c.marketId),s=e.markets.find(u=>u.id.toLowerCase()===t);if(!s)throw new r("Target market is not in this verified vault adapter inventory.");let[p,b,k,f,U]=await Promise.all([i(y,m,"vaultV2Factory"),i(G,z,"isVaultV2",[l.vault]),i(l.vault,$,"isAllocator",[y]),i(y,m,"vaultData",[l.vault]),i(y,m,"isActiveAdapter",[l.vault,s.adapter])]);if(typeof p!="string"||P(p)!==G||b!==!0||!Array.isArray(f)||f.length!==2||typeof f[0]!="boolean"||typeof f[1]!="bigint")throw new r("Invalid Public Allocator deployment or vault configuration.");let[d]=E(N,s.data);if(P(d.irm)!==P(w.morpho.adaptive_curve_irm.address))throw new r("Public allocation requires the pinned Adaptive Curve IRM.");let g=(u,T)=>Y(K(B(`string,address,${A}`),["this/marketParams",T,E(N,u)[0]])),C=g(s.data,s.adapter),[S,F]=await Promise.all([i(y,m,"absoluteCap",[l.vault,C]),i(l.vault,$,"allocation",[C])]);if(typeof S!="bigint"||typeof F!="bigint")throw new r("Invalid allocator cap read.");let R=S>F?S-F:0n,W=await Promise.all(e.markets.filter(u=>u.id.toLowerCase()!==t).map(async u=>({...u,canPull:await i(y,m,"canPullFromMarket",[l.vault,g(u.data,u.adapter)])===!0})));return{client:o,read:i,asset:a,definition:l,data:e,target:s,params:d,permission:k===!0&&U===!0,canIdle:f[0],penalty:f[1],headroom:R,sources:W}}var st=n=>{let c=a=>Q(n,a),l=(a,o,e,i)=>{let t={vault:{type:"string",enum:L.map(s=>s.vault),description:"Pinned NetNet or Longbow V2 vault address on chain 4663; use netnet_list or longbow_list for vault names."},marketId:{type:"string",description:"Target Morpho Blue market id (0x + 64 hex digits) that must be in this vault's adapter inventory."},...o};return{name:a,inputSchema:{type:"object",properties:t,required:["vault","marketId",...e],additionalProperties:!1},execute:async(s,p)=>{try{if(V(p),Object.keys(s).some(b=>!Object.hasOwn(t,b)))throw new r("Unsupported Public Allocator argument.");return await i(s,p)}catch(b){throw new r(n.plainError(b))}}}};return{tools:[l("morpho_allocator",{},[],async a=>{let o=await c(a);return{chainId:v,allocator:y,vault:o.definition.vault,targetMarketId:o.target.id,asset:o.asset,blockNumber:o.data.blockNumber.toString(),enabled:o.permission,penaltyWad:o.penalty.toString(),absoluteCapHeadroom:o.headroom.toString(),idleUpperBound:(o.permission&&o.canIdle?M(o.data.idle,o.headroom):0n).toString(),sources:o.sources.map(e=>({marketId:e.id,canPull:e.canPull,assetsUpperBound:(o.permission&&e.canPull?M(M(e.capacity,o.data.blueCash),o.headroom):0n).toString()})),caveat:"Upper bounds only; vault relative/absolute caps, accrual and liquidity still constrain execution. Preview an explicit source and amount with morpho_reallocate. This standalone allocation charges its disclosed penalty; a later borrow is a separate transaction and can fail or lose the added liquidity to another borrower."}}),l("morpho_reallocate",{sourceMarketId:{type:"string",description:"A returned source market ID, or omit to allocate idle assets."},assets:I(`Amount to move into the target market, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "1000000" = 1 USDG.`),maxPenaltyAssets:I(`Highest penalty you accept, in base units of the vault's asset (USDG 6 decimals, WETH 18). Example: "10000" = 0.01 USDG.`)},["assets","maxPenaltyAssets"],async(a,o)=>{let e=x(a.assets,128),i=x(a.maxPenaltyAssets),t=await c(a);if(!t.permission||e===0n||e>t.headroom||t.penalty>10n**18n)throw new r("Public allocation is disabled or the requested amount exceeds target headroom.");let s=(e*t.penalty+10n**18n-1n)/10n**18n;if(s>i)throw new r("Allocator penalty exceeds maxPenaltyAssets.");let p;if(a.sourceMarketId===void 0){if(!t.canIdle||e>t.data.idle)throw new r("Public idle allocation is disabled or idle funds are insufficient.");p=h({abi:m,functionName:"allocateFromIdle",args:[t.definition.vault,t.target.adapter,t.params,e,t.penalty]})}else{let d=t.sources.find(C=>C.id.toLowerCase()===q(a.sourceMarketId));if(!d||!d.canPull||e>M(d.capacity,t.data.blueCash))throw new r("The source cannot publicly supply the requested liquidity.");let[g]=E(N,d.data);p=h({abi:m,functionName:"reallocate",args:[t.definition.vault,d.adapter,g,t.target.adapter,t.params,e,t.penalty]})}let b=`Move ${e} ${t.asset.symbol} base units inside ${t.definition.vault} to market ${t.target.id}; pay ${s} ${t.asset.symbol} base units as a donation penalty. This is a standalone reallocation; a subsequent borrow is separate and not guaranteed.`,k=[...s?[n.approval(t.asset.address,y,s.toString(),v)]:[],n.unsignedTx({to:y,data:p,value:"0",chainId:v,description:b})],f=await n.preview(k,o);if(f.changes.filter(d=>d.token.chainId===v&&D(d.token.address,t.asset.address)&&d.token.decimals===t.asset.decimals).reduce((d,g)=>d+BigInt(g.amount),0n)!==-s)throw new r("Allocator preview does not match the exact donation penalty.");return{txs:k,preview:f,penaltyAmount:s.toString(),summary:`${b} The calldata binds the current penalty rate. ${f.summary}`}}),l("morpho_manage_allocator",{operation:{enum:["setIsActiveAdapter","setCanPullFromMarket","setCanPullFromIdle","setAbsoluteCap","setPenalty"],description:"Allocator setting to change: adapter active flag, market pull permission, idle pull permission, absolute cap, or penalty rate."},enabled:{type:"boolean",description:"New true/false value for setIsActiveAdapter, setCanPullFromMarket or setCanPullFromIdle."},amount:I(`For setAbsoluteCap: cap in base units of the vault's asset ("1000000" = 1 USDG). For setPenalty: 18-decimal wad base units (1e18 = 100%).`)},["operation"],async(a,o)=>{let e=await c(a);if(await e.read(e.definition.vault,$,"isAllocator",[o])!==!0)throw new r("This wallet is not an allocator of this vault.");let i=a.enabled,t;if(a.operation==="setAbsoluteCap")t=h({abi:m,functionName:"setAbsoluteCap",args:[e.definition.vault,e.target.adapter,e.params,x(a.amount)]});else if(a.operation==="setPenalty"){let b=x(a.amount,64);if(b>10n**18n)throw new r("Public Allocator penalty must not exceed 1e18.");t=h({abi:m,functionName:"setPenalty",args:[e.definition.vault,b]})}else{if(typeof i!="boolean")throw new r("Provide enabled as a boolean.");if(a.operation==="setIsActiveAdapter")t=h({abi:m,functionName:"setIsActiveAdapter",args:[e.definition.vault,e.target.adapter,i]});else if(a.operation==="setCanPullFromMarket")t=h({abi:m,functionName:"setCanPullFromMarket",args:[e.definition.vault,e.target.adapter,e.params,i]});else if(a.operation==="setCanPullFromIdle")t=h({abi:m,functionName:"setCanPullFromIdle",args:[e.definition.vault,i]});else throw new r("Choose a supported allocator configuration operation.")}let s=`Configure Morpho Public Allocator ${String(a.operation)}: ${JSON.stringify(a)}.`,p=[n.unsignedTx({to:y,data:t,value:"0",chainId:v,description:s})];return{txs:p,preview:await n.preview(p,o),summary:s}})]}};export{y as a,G as b,m as c,Q as d,st as e};
@@ -1 +1 @@
1
- import{c as tn,d as on,e as _e,f as he,i as Ue,j as rn}from"./3BQ5XHDJ.js";import{a as $e,b as Ee}from"./YEIM6BZQ.js";import{m as ue}from"./7OOCAZBE.js";import{b as Te,o as Me}from"./GYPMUYB5.js";import{a as de}from"./Z7FGEWO2.js";import{h as nn}from"./QA6Z2CYP.js";import{c as en}from"./CFPJDLTZ.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{b as y,e as Ze,j as Q,k as Ye,n as Qe}from"./TI727O2H.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as sn,getAddress as w,isAddress as Hn,keccak256 as Fn,pad as Vn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Bn,toHex as an}from"viem";var On=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),me=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),qt=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Oe=8388608,Fe=-887272,ve=887272,In=(1n<<48n)-1n,J=(1n<<128n)-1n,Xn=(1n<<160n)-1n,le=1n<<96n,cn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",dn=1800n,fe=50n,un=(e,n=fe)=>e*(10000n-n)/10000n,pn=(e,n,i=fe)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Rn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Xe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Cn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",zn={currency0:k,currency1:D,fee:Oe,tickSpacing:1,hooks:Re},jn=new Set([...Xe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),Wn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),Gn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Zn=z("address currency0, address currency1"),Yn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Qn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),pe=z("bytes actions, bytes[] params"),O=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Jn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),ln=z("address currency"),mn=1e6,ye=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),et=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),nt=Bn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Hn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===de.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===de.toLowerCase()}function ae(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Fn(S(Wn,[n,i,e.fee,e.tickSpacing,r]))}function qn(e){return((typeof e=="number"?e:e.fee)&Oe)!==0}function fn(e,n){return qn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ee(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ee(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=qn(e.fee);if(!s&&e.fee>mn)throw new o(`PoolKey static fee ${$e(e.fee)} exceeds the v4 maximum of ${$e(mn)}.`);if(s&&e.fee!==Oe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!jn.has(c.toLowerCase()))throw ae({currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c}).toLowerCase()===en.poolId?new o(nn):c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ae(t);if(c===Re&&d.toLowerCase()!==Cn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function tt(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function it(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function yn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Xn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>In)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:et,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function wn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function ot(e){let n=(e&0xffn)!==0n,i=wn(e>>8n&0xffffffn),r=wn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function bn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function hn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+le-1n)/le:t/le}function Ln(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:bn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:bn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:hn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:hn(n,i,e.liquidity,e.roundUp)}}function rt(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/le/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*le/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function gn(e,n=y){if(H(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return gn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return gn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:sn,functionName:"symbol"}),e.readContract({address:r,abi:sn,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:rn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function kn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function Tn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await Tn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ae(u),poolKey:u}}let s=(i??Rn).toLowerCase();if(s===Cn)return{poolId:s,poolKey:ke(zn,s)};let t=Xe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:O,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:O,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ae(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=ot(BigInt(c));return{poolKey:s,poolId:ae(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function st(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function Pn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[nt,null,Vn(r)],fromBlock:an(p),toBlock:an(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:O,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:me,abi:ye,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Ln({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(fe)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},ct={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ut={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},pt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function vn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function xn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return on(BigInt(e.sqrtPriceX96))}return tn(e.initialPrice,n,i)}async function lt(e,n,i){let r;try{r=await e.readContract({address:M,abi:O,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function An(e,n){let i=ae(n).toLowerCase(),r=new Map;for(let s of Xe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:me,abi:ye,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:me,abi:ye,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function Sn(e,n,i,r,c,s){return e.unsignedTx({to:On.toLowerCase(),data:re({abi:Jn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var mt=e=>({tools:[{name:"uniswap_add",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(cn);let m=t.slippageBps===void 0?Number(fe):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(cn);let f=BigInt(m),P=e.clientFor(y);p&&vn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await lt(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=tt(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),it(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:me,abi:ye,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=xn(t,h.decimals,g.decimals),V=Ue(q,await An(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):rt({amount0:un(A,f),amount1:un(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Ln({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:pn(ee,A,f),Y=l?I:pn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await Tn(P),X=await Ke(P,t.deadline,U.toString()),te=X<U+dn?X:U+dn,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>In)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[Sn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),q.toString(),y)),G.push(yn(ce,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ce=u.currency1.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),V.toString(),y)),G.push(yn(ce,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(Gn,[R,v,x,E,q,V,$.toLowerCase(),ie]),_n=S(Zn,[R.currency0,R.currency1]),We=S(Yn,[k,$.toLowerCase()]),Un=S(ge,[a??0n,E,q,V,ie]),Dn=a===void 0?S(pe,["0x020d14",[Le,_n,We]]):S(pe,["0x00121214",[Un,S(ln,[R.currency0]),S(ln,[R.currency1]),We]]),Nn=re({abi:O,functionName:"modifyLiquidities",args:[Dn,X]}),Kn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Nn,value:Kn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?de:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Mn=Ne(we.changes,e.formatAmount),qe=fn(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],$n=Se.length,En=a===void 0?`This deposit takes ${$n} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(fe)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:X.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:_e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${En}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Mn.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(pe,["0x0111",[g,A]]),F=re({abi:O,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ut,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,X)=>{let te=h?S(Qn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,X]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),X=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=X(b),j=X(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):kn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):kn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:pt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):st(t.wallet),m=await Pn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');vn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:me,abi:ye,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=xn(t,m.decimals,f.decimals),u=Ue(b,await An(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[Sn(e,l,p,b,m,f)],h=await e.preview(x,d),g=fn(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:_e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>Pn(e,t)}),Lt=mt;export{On as a,M as b,me as c,He as d,qt as e,se as f,D as g,k as h,Oe as i,Fe as j,ve as k,Rn as l,Ve as m,Xe as n,Re as o,Cn as p,zn as q,jn as r,H as s,ae as t,qn as u,fn as v,ke as w,tt as x,it as y,yn as z,ot as A,Ln as B,rt as C,Ne as D,gn as E,B as F,Pe as G,Pn as H,at as I,ct as J,dt as K,ut as L,pt as M,An as N,mt as O,Lt as P};
1
+ import{c as tn,d as on,e as $e,f as he,i as Ee,j as rn}from"./6EWSLHXL.js";import{a as _e,b as Ue}from"./YEIM6BZQ.js";import{m as ue}from"./IR7KDBFU.js";import{b as Te,o as Me}from"./TTBB6EFN.js";import{a as de}from"./7WXAS54T.js";import{h as nn}from"./QA6Z2CYP.js";import{c as en}from"./CFPJDLTZ.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{b as y,e as Ze,j as Q,k as Ye,n as Qe}from"./EWZFZUVF.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as sn,getAddress as w,isAddress as Hn,keccak256 as Fn,pad as Vn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Bn,toHex as an}from"viem";var On=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),me=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),qt=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Oe=8388608,Fe=-887272,ve=887272,In=(1n<<48n)-1n,J=(1n<<128n)-1n,Xn=(1n<<160n)-1n,le=1n<<96n,cn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",dn=1800n,fe=50n,un=(e,n=fe)=>e*(10000n-n)/10000n,pn=(e,n,i=fe)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Rn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Xe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Cn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",zn={currency0:k,currency1:D,fee:Oe,tickSpacing:1,hooks:Re},jn=new Set([...Xe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),Wn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),Gn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Zn=z("address currency0, address currency1"),Yn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Qn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),pe=z("bytes actions, bytes[] params"),O=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Jn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),ln=z("address currency"),mn=1e6,ye=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),et=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),nt=Bn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Hn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===de.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===de.toLowerCase()}function ae(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Fn(S(Wn,[n,i,e.fee,e.tickSpacing,r]))}function qn(e){return((typeof e=="number"?e:e.fee)&Oe)!==0}function fn(e,n){return qn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ue(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ue(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=qn(e.fee);if(!s&&e.fee>mn)throw new o(`PoolKey static fee ${_e(e.fee)} exceeds the v4 maximum of ${_e(mn)}.`);if(s&&e.fee!==Oe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!jn.has(c.toLowerCase()))throw ae({currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c}).toLowerCase()===en.poolId?new o(nn):c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ae(t);if(c===Re&&d.toLowerCase()!==Cn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function tt(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function it(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function yn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Xn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>In)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:et,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function wn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function ot(e){let n=(e&0xffn)!==0n,i=wn(e>>8n&0xffffffn),r=wn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function bn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function hn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+le-1n)/le:t/le}function Ln(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:bn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:bn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:hn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:hn(n,i,e.liquidity,e.roundUp)}}function rt(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/le/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*le/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function gn(e,n=y){if(H(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return gn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return gn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:sn,functionName:"symbol"}),e.readContract({address:r,abi:sn,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:rn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function kn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function Tn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await Tn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ae(u),poolKey:u}}let s=(i??Rn).toLowerCase();if(s===Cn)return{poolId:s,poolKey:ke(zn,s)};let t=Xe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:O,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:O,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ae(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=ot(BigInt(c));return{poolKey:s,poolId:ae(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function st(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function Pn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[nt,null,Vn(r)],fromBlock:an(p),toBlock:an(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:O,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:me,abi:ye,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Ln({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(fe)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},ct={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ut={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},pt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function vn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function xn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return on(BigInt(e.sqrtPriceX96))}return tn(e.initialPrice,n,i)}async function lt(e,n,i){let r;try{r=await e.readContract({address:M,abi:O,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function An(e,n){let i=ae(n).toLowerCase(),r=new Map;for(let s of Xe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:me,abi:ye,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:me,abi:ye,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function Sn(e,n,i,r,c,s){return e.unsignedTx({to:On.toLowerCase(),data:re({abi:Jn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var mt=e=>({tools:[{name:"uniswap_add",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(cn);let m=t.slippageBps===void 0?Number(fe):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(cn);let f=BigInt(m),P=e.clientFor(y);p&&vn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await lt(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=tt(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),it(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:me,abi:ye,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=xn(t,h.decimals,g.decimals),V=Ee(q,await An(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):rt({amount0:un(A,f),amount1:un(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Ln({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:pn(ee,A,f),Y=l?I:pn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await Tn(P),X=await Ke(P,t.deadline,U.toString()),te=X<U+dn?X:U+dn,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>In)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[Sn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),q.toString(),y)),G.push(yn(ce,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ce=u.currency1.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),V.toString(),y)),G.push(yn(ce,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(Gn,[R,v,x,E,q,V,$.toLowerCase(),ie]),_n=S(Zn,[R.currency0,R.currency1]),We=S(Yn,[k,$.toLowerCase()]),Un=S(ge,[a??0n,E,q,V,ie]),Dn=a===void 0?S(pe,["0x020d14",[Le,_n,We]]):S(pe,["0x00121214",[Un,S(ln,[R.currency0]),S(ln,[R.currency1]),We]]),Nn=re({abi:O,functionName:"modifyLiquidities",args:[Dn,X]}),Kn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Nn,value:Kn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?de:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Mn=Ne(we.changes,e.formatAmount),qe=fn(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],$n=Se.length,En=a===void 0?`This deposit takes ${$n} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(fe)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:X.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:$e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${En}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Mn.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(pe,["0x0111",[g,A]]),F=re({abi:O,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ut,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,X)=>{let te=h?S(Qn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,X]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),X=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=X(b),j=X(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):kn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):kn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:pt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):st(t.wallet),m=await Pn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');vn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:me,abi:ye,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=xn(t,m.decimals,f.decimals),u=Ee(b,await An(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[Sn(e,l,p,b,m,f)],h=await e.preview(x,d),g=fn(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:$e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>Pn(e,t)}),Lt=mt;export{On as a,M as b,me as c,He as d,qt as e,se as f,D as g,k as h,Oe as i,Fe as j,ve as k,Rn as l,Ve as m,Xe as n,Re as o,Cn as p,zn as q,jn as r,H as s,ae as t,qn as u,fn as v,ke as w,tt as x,it as y,yn as z,ot as A,Ln as B,rt as C,Ne as D,gn as E,B as F,Pe as G,Pn as H,at as I,ct as J,dt as K,ut as L,pt as M,An as N,mt as O,Lt as P};
@@ -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"./3BQ5XHDJ.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};