@oakagentkit/core 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/modules/borro/actions.js +1 -1
- package/build/dist/api/modules/borro/checks.js +1 -1
- package/build/dist/api/modules/borro/copy.d.ts +4 -4
- package/build/dist/api/modules/borro/copy.js +1 -1
- package/build/dist/api/modules/borro/index.js +1 -1
- package/build/dist/api/modules/borro/liquidity.js +1 -1
- package/build/dist/api/modules/borro/positions.js +1 -1
- package/build/dist/api/modules/borro/reader.d.ts +6 -2
- package/build/dist/api/modules/borro/reader.js +1 -1
- package/build/dist/api/modules/borro/types.d.ts +6 -0
- package/build/dist/api/modules/chop/abi.d.ts +527 -0
- package/build/dist/api/modules/chop/abi.js +1 -0
- package/build/dist/api/modules/chop/actions.d.ts +24 -0
- package/build/dist/api/modules/chop/actions.js +1 -0
- package/build/dist/api/modules/chop/checks.d.ts +26 -0
- package/build/dist/api/modules/chop/checks.js +1 -0
- package/build/dist/api/modules/chop/copy.d.ts +5 -0
- package/build/dist/api/modules/chop/copy.js +1 -0
- package/build/dist/api/modules/chop/guard.d.ts +13 -0
- package/build/dist/api/modules/chop/guard.js +1 -0
- package/build/dist/api/modules/chop/index.d.ts +3 -0
- package/build/dist/api/modules/chop/index.js +1 -0
- package/build/dist/api/modules/chop/pins.d.ts +53 -0
- package/build/dist/api/modules/chop/pins.js +1 -0
- package/build/dist/api/modules/chop/positions.d.ts +3 -0
- package/build/dist/api/modules/chop/positions.js +1 -0
- package/build/dist/api/modules/chop/reader.d.ts +70 -0
- package/build/dist/api/modules/chop/reader.js +1 -0
- package/build/dist/api/modules/chop/types.d.ts +32 -0
- package/build/dist/api/modules/chop/types.js +0 -0
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/gloam/abi.d.ts +89 -0
- package/build/dist/api/modules/gloam/abi.js +1 -0
- package/build/dist/api/modules/gloam/actions.d.ts +5 -0
- package/build/dist/api/modules/gloam/actions.js +1 -0
- package/build/dist/api/modules/gloam/checks.d.ts +17 -0
- package/build/dist/api/modules/gloam/checks.js +1 -0
- package/build/dist/api/modules/gloam/copy.d.ts +22 -0
- package/build/dist/api/modules/gloam/copy.js +2 -0
- package/build/dist/api/modules/gloam/index.d.ts +6 -0
- package/build/dist/api/modules/gloam/index.js +1 -0
- package/build/dist/api/modules/gloam/pins.d.ts +41 -0
- package/build/dist/api/modules/gloam/pins.js +1 -0
- package/build/dist/api/modules/gloam/types.d.ts +308 -0
- package/build/dist/api/modules/gloam/types.js +1 -0
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/addons.js +1 -1
- package/build/dist/api/modules/hookr/agent-gate.js +1 -1
- package/build/dist/api/modules/hookr/contracts.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/layerbank/actions.js +1 -1
- package/build/dist/api/modules/layerbank/index.js +1 -1
- package/build/dist/api/modules/layerbank/reader.js +1 -1
- package/build/dist/api/modules/longbow/administration.js +1 -1
- package/build/dist/api/modules/longbow/fixed.js +1 -1
- package/build/dist/api/modules/longbow/index.js +1 -1
- package/build/dist/api/modules/meridian/index.js +1 -1
- package/build/dist/api/modules/meridian/rfq.js +1 -1
- package/build/dist/api/modules/merkl/discovery.js +1 -1
- package/build/dist/api/modules/merkl/index.js +1 -1
- package/build/dist/api/modules/merkl/manage.js +1 -1
- package/build/dist/api/modules/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.js +1 -1
- package/build/dist/api/modules/morpho/midnight.js +1 -1
- package/build/dist/api/modules/morpho/protocol.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/pendle/index.js +1 -1
- package/build/dist/api/modules/pendle/reader.js +1 -1
- package/build/dist/api/modules/pons/claim.js +1 -1
- package/build/dist/api/modules/pons/index.js +1 -1
- package/build/dist/api/modules/pons/launch-status.d.ts +1 -0
- package/build/dist/api/modules/pons/launch-status.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/trade.js +1 -1
- package/build/dist/api/modules/poolstrade/index.js +1 -1
- package/build/dist/api/modules/priors/coverage.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/relay/discovery.js +1 -1
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/spark/index.js +1 -1
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
- package/build/dist/api/modules/steakhouse/management.js +1 -1
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/token-jar.js +1 -1
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
- package/build/dist/api/modules/uniswap/trade.js +1 -1
- package/build/dist/api/modules/uniswap/v2.js +1 -1
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.js +1 -1
- package/build/dist/api/modules/velora/claims.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.d.ts +3 -0
- package/build/dist/api/modules/wormhole/index.js +1 -1
- package/build/dist/api/modules/wormhole/swap-token-verdict.d.ts +11 -0
- package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -0
- package/build/dist/api/modules/wormhole/third-party-text.d.ts +13 -0
- package/build/dist/api/modules/wormhole/third-party-text.js +1 -0
- package/build/dist/api/modules/wormhole/token-check.d.ts +2 -0
- package/build/dist/api/modules/wormhole/token-check.js +1 -1
- package/build/dist/api/modules/wormhole/x402-client.d.ts +36 -0
- package/build/dist/api/modules/wormhole/x402-client.js +1 -0
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/types.d.ts +6 -1
- package/build/dist/chunks/{3FUVMSCF.js → 2MT3G7YZ.js} +1 -1
- package/build/dist/chunks/{GEIFITAQ.js → 2THSW4QN.js} +1 -1
- package/build/dist/chunks/{GQ5GYUEH.js → 2VXLVXIB.js} +1 -1
- package/build/dist/chunks/{HCUHMCBW.js → 35KR3VSS.js} +1 -1
- package/build/dist/chunks/{P7I62KFR.js → 3GQ7A3VB.js} +1 -1
- package/build/dist/chunks/3VWVW7PX.js +1 -0
- package/build/dist/chunks/4DP2VPXR.js +3 -0
- package/build/dist/chunks/{MR5L7V6Z.js → 4EN6MQEI.js} +1 -1
- package/build/dist/chunks/{LSXUAHOE.js → 4I3OU56B.js} +1 -1
- package/build/dist/chunks/{NEEZBJBC.js → 5AXWBSPG.js} +1 -1
- package/build/dist/chunks/{VY7XRHZQ.js → 5N3O42X6.js} +1 -1
- package/build/dist/chunks/{X3PQMS4N.js → 5SZPNZG4.js} +1 -1
- package/build/dist/chunks/{VYN2NRAP.js → 6JAXZNZ3.js} +1 -1
- package/build/dist/chunks/{APGLZXIW.js → 6O3Q5B6M.js} +1 -1
- package/build/dist/chunks/6YB3VOUL.js +1 -0
- package/build/dist/chunks/77CLMPM7.js +1 -0
- package/build/dist/chunks/{GL4NCUMH.js → 7GJ6SLEV.js} +1 -1
- package/build/dist/chunks/{57MEFFCU.js → 7KWZ5QJU.js} +1 -1
- package/build/dist/chunks/{326QMOTR.js → 7QIO77VE.js} +1 -1
- package/build/dist/chunks/7QZOTRSA.js +2 -0
- package/build/dist/chunks/{UHVSINR5.js → A7I4IWUB.js} +1 -1
- package/build/dist/chunks/{6PBGEPUK.js → ACW63WIL.js} +4 -4
- package/build/dist/chunks/{P56RZC2M.js → AEL62KCG.js} +1 -1
- package/build/dist/chunks/{6B3VVISQ.js → ALLLYOUG.js} +1 -1
- package/build/dist/chunks/APQYLJGS.js +1 -0
- package/build/dist/chunks/{FQ6UZCM6.js → AW7AXQCZ.js} +1 -1
- package/build/dist/chunks/{T3AJSQYT.js → AXRL3REN.js} +1 -1
- package/build/dist/chunks/{INOZIE55.js → BBTPRZ6T.js} +1 -1
- package/build/dist/chunks/{WDK6VOG4.js → BND2UFVW.js} +1 -1
- package/build/dist/chunks/{3NJ5KQ3Q.js → BOVMED7R.js} +1 -1
- package/build/dist/chunks/{74Y2KDNR.js → CBLMQ5UU.js} +1 -1
- package/build/dist/chunks/CDPSMI3Z.js +1 -0
- package/build/dist/chunks/{XR7VK24E.js → CQEJSCFQ.js} +1 -1
- package/build/dist/chunks/{GW626GG2.js → DBNTZEAJ.js} +1 -1
- package/build/dist/chunks/{SSHCD6RZ.js → DHUDSOGR.js} +1 -1
- package/build/dist/chunks/{3GOHSYHW.js → DL6AEWEM.js} +1 -1
- package/build/dist/chunks/{UMIZMJWW.js → EGYVRQUR.js} +1 -1
- package/build/dist/chunks/{Y25EXZCO.js → FEYAY6OZ.js} +1 -1
- package/build/dist/chunks/FIO6VC2J.js +1 -0
- package/build/dist/chunks/FJ4S4GHY.js +1 -0
- package/build/dist/chunks/{X3BYCOWS.js → FUDAXV5X.js} +1 -1
- package/build/dist/chunks/{Z43BTOTE.js → GG6Y4OCJ.js} +1 -1
- package/build/dist/chunks/{ELSXLZN5.js → GGHBFLRC.js} +1 -1
- package/build/dist/chunks/{L4N2RSK2.js → GRQYTVNT.js} +1 -1
- package/build/dist/chunks/{2MAMJJJC.js → GSBIERZD.js} +1 -1
- package/build/dist/chunks/{J2OT4KAH.js → H6T5FXEX.js} +1 -1
- package/build/dist/chunks/HHXBUYHO.js +1 -0
- package/build/dist/chunks/{MJ6WEWMI.js → HQUVB7Z5.js} +1 -1
- package/build/dist/chunks/HS4DZPYT.js +1 -0
- package/build/dist/chunks/{S7IFAQPG.js → HU7IMNBI.js} +1 -1
- package/build/dist/chunks/{5APS4T2D.js → HWX36XJI.js} +1 -1
- package/build/dist/chunks/I55MURSJ.js +1 -0
- package/build/dist/chunks/I6PQW2JI.js +1 -0
- package/build/dist/chunks/{KIFSRO5K.js → IPN6Z4JM.js} +1 -1
- package/build/dist/chunks/{NDCLTVIU.js → IPRVIKYC.js} +1 -1
- package/build/dist/chunks/{VJS4DHQQ.js → IVX4R5OL.js} +1 -1
- package/build/dist/chunks/JFYBH3DX.js +1 -0
- package/build/dist/chunks/JQOQMFWD.js +3 -0
- package/build/dist/chunks/{BJ2VGRF4.js → JZS3E66E.js} +1 -1
- package/build/dist/chunks/{W6BS3T7S.js → KVFZKPJT.js} +1 -1
- package/build/dist/chunks/{QZZ4O34L.js → LKXO2BQS.js} +1 -1
- package/build/dist/chunks/{BBS3ODWZ.js → LKZX4CAA.js} +1 -1
- package/build/dist/chunks/{H2XDMFQQ.js → LYMNHO5T.js} +1 -1
- package/build/dist/chunks/{KPCY5V35.js → M2UXYCKH.js} +1 -1
- package/build/dist/chunks/{ZMFRMWHR.js → M6LC6DRE.js} +1 -1
- package/build/dist/chunks/{VOMGT5SG.js → MOE3EVAL.js} +1 -1
- package/build/dist/chunks/{2KYAMXTS.js → NOFUKKP5.js} +1 -1
- package/build/dist/chunks/{AVG4W3Y7.js → O6ROOKY2.js} +1 -1
- package/build/dist/chunks/{BTD5SMOW.js → OLSP46ZD.js} +1 -1
- package/build/dist/chunks/{E674J2MD.js → OOZSE2R7.js} +1 -1
- package/build/dist/chunks/{P3S4BR5G.js → P5AJSLZ7.js} +1 -1
- package/build/dist/chunks/{RQ4GHJXE.js → PACN53TR.js} +1 -1
- package/build/dist/chunks/{U67J4BCH.js → PAHXBLCS.js} +1 -1
- package/build/dist/chunks/PAY5PD4H.js +1 -0
- package/build/dist/chunks/{T2WHOZXM.js → PIIHOXWF.js} +1 -1
- package/build/dist/chunks/{HSCQZ66A.js → PNA6UIE5.js} +1 -1
- package/build/dist/chunks/{X2KFXCVD.js → PZGGE5D3.js} +1 -1
- package/build/dist/chunks/{553UE2ZQ.js → QA2RRIES.js} +1 -1
- package/build/dist/chunks/{Z4FZVJ5Z.js → QBIY6FQN.js} +1 -1
- package/build/dist/chunks/{D3YLXQPW.js → QFNT73OF.js} +1 -1
- package/build/dist/chunks/QHBS3PVU.js +1 -0
- package/build/dist/chunks/QW2OPEYJ.js +1 -0
- package/build/dist/chunks/{YWRDZQI6.js → QYVREJYC.js} +1 -1
- package/build/dist/chunks/{W2BYU5JQ.js → ROFPXEQ5.js} +1 -1
- package/build/dist/chunks/{OKUO3BVM.js → RTAHNWHN.js} +1 -1
- package/build/dist/chunks/{UHTRW2R6.js → RTGS7RIO.js} +1 -1
- package/build/dist/chunks/{CCTXCMH4.js → S5CBVFHY.js} +1 -1
- package/build/dist/chunks/{JVLLVNF2.js → T7TFUH5K.js} +1 -1
- package/build/dist/chunks/{OJPG45AC.js → TPBAFS7K.js} +1 -1
- package/build/dist/chunks/{B3RXD5ET.js → U2RMUVVY.js} +1 -1
- package/build/dist/chunks/{4MXM6Q4W.js → UD2XMNIT.js} +1 -1
- package/build/dist/chunks/V5JWGWXC.js +1 -0
- package/build/dist/chunks/VCOTCVKN.js +1 -0
- package/build/dist/chunks/{QO3KCJMP.js → VNV6ZISN.js} +1 -1
- package/build/dist/chunks/{TM2XCRU7.js → X2P55AC3.js} +1 -1
- package/build/dist/chunks/XD6X3KTC.js +1 -0
- package/build/dist/chunks/{C36BFZH6.js → XKSVTN5X.js} +1 -1
- package/build/dist/chunks/{IY7BXLT4.js → XL3LLGIR.js} +1 -1
- package/build/dist/chunks/XQA5LCL6.js +1 -0
- package/build/dist/chunks/{S47VUTHM.js → XSKFKBDR.js} +1 -1
- package/build/dist/chunks/{6D5DJA5B.js → YRNXGQJC.js} +1 -1
- package/build/dist/chunks/YWRLY5EA.js +1 -0
- package/build/dist/chunks/YWSX6IE6.js +1 -0
- package/build/dist/chunks/{QF52OIBS.js → Z6LZGCVW.js} +1 -1
- package/build/dist/chunks/{45BRW2ZF.js → ZQWZGH7V.js} +1 -1
- package/build/dist/chunks/{HAQPIBYR.js → ZXJ24B4L.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/3MLUCYCB.js +0 -1
- package/build/dist/chunks/3XXBLNEX.js +0 -1
- package/build/dist/chunks/4PY3UFNR.js +0 -1
- package/build/dist/chunks/EE64JSLY.js +0 -1
- package/build/dist/chunks/EJ7O75A7.js +0 -1
- package/build/dist/chunks/QC3HH5UD.js +0 -3
- package/build/dist/chunks/QSHCBASA.js +0 -1
- package/build/dist/chunks/XLOYBLFI.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as qe,d as $e,e as be,f as ie,i as ke,j as Me}from"./6B3VVISQ.js";import{b as ne,o as we}from"./3NJ5KQ3Q.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Te}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{a as y,i as O}from"./FWD4L3CJ.js";import{a,b as me,e as N}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}),Nt=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(f=>String(f).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 f=BigInt(c[1]).toString();f!=="0"&&o.add(f)}}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 _e=1n<<96n;function Ee(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,f=s*(t-o)/_e;return{amount0:r,amount1:f}}return{amount0:0n,amount1:s*(i-o)/_e}}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. ${N(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. ${N(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${Te.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. ${N(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${N(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 qe(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 f=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(f[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}. ${N(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}. ${N(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"),f;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),f=await de(o,r)}let d=f?.token0??D(e.token0,"token0"),u=f?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=f?.fee??Number(e.fee??100),p=Pe[g];if(!p)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||f))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(f?.tickLower??(e.fullRange===!0?Math.ceil(re/p)*p:e.tickLower),f?.tickUpper??(e.fullRange===!0?Math.floor(se/p)*p:e.tickUpper),p),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let q=Ve(e,v.decimals,h.decimals),E=ke(q,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:q,note:E}}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 q=>BigInt(await o.readContract({address:q,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(q,E)=>{let fe=[];if(e.wrapNative===!0){let Q=d===w.weth?q:E;Q>0n&&fe.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 pe=Q===0?q:E;pe>0n&&V[Q]<pe&&fe.push(t.approval(Ge,w.positionManager,pe.toString(),y))}return fe},L=r===void 0?"mint":"increaseLiquidity",R=(q,E)=>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:q,amount1Min:E,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:q,amount1Min:E,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),_=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=_?[_]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),T=ce(L,Ae[Ae.length-1]),We=T[T.length-2],ze=T[T.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,T[T.length-2],c,"amount0Min"),le=ae(e.amount1Min,T[T.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[q,E]of[d,u].entries())(q===0?I:S)>0n&&te.push(t.approval(E,w.positionManager,"0",y));let Ne=await t.preview(te,s);return{txs:te,preview:Ne,summary:Se(Ce.description,Ne),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:T[T.length-2].toString(),expectedAmount1:T[T.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),f=Pe[r];if(!f){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.");f=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),p=Ve(e,u.decimals,g.decimals),b=ke(p,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(p,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,p]}),`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:f,token0:u,token1:g,sqrtPriceX96:p.toString(),initialPrice:l,initialTick:be(p),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),f=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 p=[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,p,s))[0]),l=await t.preview(p,s);return{txs:p,preview:l,summary:Se(p[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:f,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function ft(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 f=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(f<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(f>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),p=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,_)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:f,amount0Min:R,amount1Min:_,deadline:d}]}),`Decrease ${f} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,_)=>{if(R!==void 0&&W(R,_)!==0n)throw new a(`${_} 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=f===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:p,liquidityRemoved:f.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function pt(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,f=!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. ${N(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,p=[],b=!0;for(let l=u;l<g;l++)try{p.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,f=u===0n&&g===d;for(let k of p)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||f)&&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),p=d,b=0;for(;p>=g&&b<u;){let l=p>=oe-1n?p-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:p});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;p=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${N(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:pt(n.cursor,s),f=o,d;if(!i){let p;if(typeof o.getBlockNumber=="function")try{p=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${N(b)}`)}if(r&&p!==void 0&&r.block>p)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${p}. Start again without a cursor.`);d=r?.block??p,d!==void 0&&(f=gt(o,d))}let u=await wt(f,s,{...n,cursor:r,blockNumber:d}),g=[];for(let p of u){let b;try{let x=await f.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[p]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${p}. ${N(x)}`)}if(b!==s)continue;let l;try{l=await de(f,p)}catch(x){throw new a(`Could not read position #${p}. ${N(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(f,l.token0,y),A=await M(f,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await f.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 f.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=Ee(l.tickLower),_=Ee(l.tickUpper),K=at(L,R,_,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${p}. ${N(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:${p.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${p.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,f=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:f,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:f.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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},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:{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 token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units. The pool is created then liquidity is minted in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps 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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},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)=>ft(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:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect. Inspects exactly these NFTs; there is no paging in this mode."},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:{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:{type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 WETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps 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}}),Tt=He,qt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,Nt 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,ft as u,Fe as v,kt as w,yt as x,He as y,Tt as z,qt as A};
|
|
1
|
+
import{c as qe,d as $e,e as be,f as ie,i as ke,j as Me}from"./ALLLYOUG.js";import{b as ne,o as we}from"./BOVMED7R.js";import{a as F,b as ge}from"./43LI5NKJ.js";import{a as Te}from"./IOYRL6AY.js";import{b as z,d as Ue}from"./IX3GZMTM.js";import{a as y,i as O}from"./FWD4L3CJ.js";import{a,b as me,e as N}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}),Nt=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(f=>String(f).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 f=BigInt(c[1]).toString();f!=="0"&&o.add(f)}}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 _e=1n<<96n;function Ee(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,f=s*(t-o)/_e;return{amount0:r,amount1:f}}return{amount0:0n,amount1:s*(i-o)/_e}}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. ${N(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. ${N(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${Te.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. ${N(i.error)}`);return i.returnData})}catch(s){throw new a(`Uniswap v3 simulation failed. ${N(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 qe(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 f=await t.readContract({address:c,abi:he,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${c}`,sqrtPriceX96:BigInt(f[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}. ${N(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}. ${N(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"),f;if(r!==void 0){if(r<=0n)throw new a("Uniswap v3 tokenId must be a positive integer.");await Ie(o,r,s),f=await de(o,r)}let d=f?.token0??D(e.token0,"token0"),u=f?.token1??D(e.token1,"token1");if(BigInt(d)>=BigInt(u))throw new a("Uniswap v3 requires distinct sorted token addresses.");let g=f?.fee??Number(e.fee??100),p=Pe[g];if(!p)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||f))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(f?.tickLower??(e.fullRange===!0?Math.ceil(re/p)*p:e.tickLower),f?.tickUpper??(e.fullRange===!0?Math.floor(se/p)*p:e.tickUpper),p),v=await M(o,d,y,e.token0Decimals),h=await M(o,u,y,e.token1Decimals),C;if(b===$){let q=Ve(e,v.decimals,h.decimals),E=ke(q,await Xe(o,d,u,g),e.acceptPriceDeviation===!0,v.decimals,h.decimals);C={sqrtPriceX96:q,note:E}}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 q=>BigInt(await o.readContract({address:q,abi:xe,functionName:"allowance",args:[s,w.positionManager]})))),X=(q,E)=>{let fe=[];if(e.wrapNative===!0){let Q=d===w.weth?q:E;Q>0n&&fe.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 pe=Q===0?q:E;pe>0n&&V[Q]<pe&&fe.push(t.approval(Ge,w.positionManager,pe.toString(),y))}return fe},L=r===void 0?"mint":"increaseLiquidity",R=(q,E)=>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:q,amount1Min:E,recipient:x,deadline:i}]}):B({abi:P,functionName:"increaseLiquidity",args:[{tokenId:r,amount0Desired:I,amount1Desired:S,amount0Min:q,amount1Min:E,deadline:i}]}),`${L==="mint"?"Mint":"Increase"} Uniswap v3 ${v.symbol}/${h.symbol} liquidity.`),_=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=_?[_]:[],Ae=await Z(o,[...K,...X(I,S),R(0n,0n)],s),T=ce(L,Ae[Ae.length-1]),We=T[T.length-2],ze=T[T.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,T[T.length-2],c,"amount0Min"),le=ae(e.amount1Min,T[T.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[q,E]of[d,u].entries())(q===0?I:S)>0n&&te.push(t.approval(E,w.positionManager,"0",y));let Ne=await t.preview(te,s);return{txs:te,preview:Ne,summary:Se(Ce.description,Ne),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:T[T.length-2].toString(),expectedAmount1:T[T.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),f=Pe[r];if(!f){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.");f=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),p=Ve(e,u.decimals,g.decimals),b=ke(p,await Xe(o,i,c,r),e.acceptPriceDeviation===!0,u.decimals,g.decimals),l=ie(p,u.decimals,g.decimals),k=[H(B({abi:P,functionName:"createAndInitializePoolIfNecessary",args:[i,c,r,p]}),`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:f,token0:u,token1:g,sqrtPriceX96:p.toString(),initialPrice:l,initialTick:be(p),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),f=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 p=[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,p,s))[0]),l=await t.preview(p,s);return{txs:p,preview:l,summary:Se(p[0].description,l),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:r,token1:f,amount0Max:u.toString(),amount1Max:g.toString(),expectedAmount0:b[0].toString(),expectedAmount1:b[1].toString()}}}async function ft(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 f=e.liquidity==="all"||e.liquidity===void 0?c.liquidity:W(e.liquidity,"liquidity");if(f<=0n&&!r)throw new a("Liquidity to remove must be positive.");if(f>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),p=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,_)=>H(B({abi:P,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:f,amount0Min:R,amount1Min:_,deadline:d}]}),`Decrease ${f} liquidity on Uniswap v3 position #${i}.`),k=r?[0n,0n]:ce("decreaseLiquidity",(await Z(o,[l(0n,0n)],s))[0]),U=(R,_)=>{if(R!==void 0&&W(R,_)!==0n)throw new a(`${_} 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=f===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:p,liquidityRemoved:f.toString(),amount0Min:A.toString(),amount1Min:v.toString(),deadline:d.toString(),expectedAmount0:X[0].toString(),expectedAmount1:X[1].toString(),fullExit:S,burned:x}}}function pt(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,f=!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. ${N(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,p=[],b=!0;for(let l=u;l<g;l++)try{p.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,f=u===0n&&g===d;for(let k of p)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||f)&&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),p=d,b=0;for(;p>=g&&b<u;){let l=p>=oe-1n?p-(oe-1n):0n,k=l<g?g:l,U=await t.getLogs({address:w.positionManager,fromBlock:k,toBlock:p});for(let A of Re({logs:U},s))o.add(A);if(b+=1,k===0n||k<=g)break;p=k-1n}}catch(d){throw new a(`Could not discover Uniswap v3 positions from logs. ${N(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:pt(n.cursor,s),f=o,d;if(!i){let p;if(typeof o.getBlockNumber=="function")try{p=await o.getBlockNumber()}catch(b){throw new a(`Could not read the latest block for the Uniswap v3 listing. ${N(b)}`)}if(r&&p!==void 0&&r.block>p)throw new a(`This cursor is from block ${r.block}, ahead of the chain's latest block ${p}. Start again without a cursor.`);d=r?.block??p,d!==void 0&&(f=gt(o,d))}let u=await wt(f,s,{...n,cursor:r,blockNumber:d}),g=[];for(let p of u){let b;try{let x=await f.readContract({address:w.positionManager,abi:P,functionName:"ownerOf",args:[p]});b=m(String(x))}catch(x){if(me(x,3))continue;throw new a(`Could not verify owner of position #${p}. ${N(x)}`)}if(b!==s)continue;let l;try{l=await de(f,p)}catch(x){throw new a(`Could not read position #${p}. ${N(x)}`)}if(l.liquidity===0n&&l.tokensOwed0===0n&&l.tokensOwed1===0n&&!n.includeEmpty)continue;let U=await M(f,l.token0,y),A=await M(f,l.token1,y),v=0n,h=0n;if(l.liquidity>0n)try{let x=await f.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 f.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=Ee(l.tickLower),_=Ee(l.tickUpper),K=at(L,R,_,l.liquidity);v=K.amount0,h=K.amount1}}catch(x){throw new a(`Could not value Uniswap v3 position #${p}. ${N(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:${p.toString()}`,chainId:y,assets:S,description:`Uniswap v3 LP position #${p.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,f=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:f,...r?.nextCursor?{nextCursor:r.nextCursor}:{},details:{version:"v3",wallet:s,count:f.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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},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:{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 token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units. The pool is created then liquidity is minted in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps 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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},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:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},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)=>ft(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:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect. Inspects exactly these NFTs; there is no paging in this mode."},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:{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:{type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 WETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps 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}}),Tt=He,qt=He;export{re as a,se as b,G as c,et as d,w as e,Pe as f,Nt 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,ft as u,Fe as v,kt as w,yt as x,He as y,Tt as z,qt as A};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as h}from"./
|
|
1
|
+
import{a as h}from"./ZQWZGH7V.js";import{c as p}from"./NWNYJ26T.js";import{a as l}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{getAddress as v}from"viem";var f={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},w=[["hookr_release",{},[],"Read verified release contracts, block and recapture lane."],["hookr_blocks",{},[],"Read all Hook Blocks and their current availability."],["hookr_kings",{poolId:f},[],"Read King of the Pool rounds, leaders, pots and endings."],["hookr_claims",{poolId:f},[],"Read the signing wallet's prizes, royalties, recapture and PoolManager claims."],["hookr_revenue_tokens",{limit:{type:"integer",minimum:1,maximum:50},cursor:{type:"string",pattern:"^(v1|v1:[1-9][0-9]{0,19}|v2:[1-9][0-9]{0,19})$"}},[],"Read revenue tokens, tokenizer provenance, streams and income, page by page."],["hookr_revenue_token",{token:p},["token"],"Read a revenue token, stream endings, income, drops and the signing wallet's claims."],["hookr_hook",{address:p},["address"],"Read shared or owned hook provenance, ownership, allowed blocks, opening and pools."]],H=[...w.map(d=>d[0]),"hookr_contracts","hookr_read","hookr_revenue_read","hookr_addon_read","hookr_api_read"];function j(d){return[...w.map(([t,c,s,o])=>({name:t,inputSchema:{type:"object",description:o,properties:c,required:s,additionalProperties:!1},execute:async(r,g)=>{if(Object.keys(r).some(n=>!Object.hasOwn(c,n))||s.some(n=>r[n]===void 0))throw new a(`Provide the documented arguments for ${t}.`);let k={};for(let[n,i]of Object.entries(r)){let u=c[n];if(u.type==="integer"){if(typeof i!="number"||!Number.isInteger(i)||i<Number(u.minimum)||i>Number(u.maximum))throw new a("Hookr revenue page limit must be an integer from 1 to 50.")}else if(typeof i!="string"||!new RegExp(String(u.pattern)).test(i))throw new a(`Provide a valid Hookr ${n}.`);k[n]=n==="token"||n==="address"?v(String(i)):i}return(t==="hookr_claims"||t==="hookr_revenue_token")&&(k.account=g),{...await h(d,t,k),chainId:l,source:"https://hookr.fun/api/mcp"}}})),y(d)]}var m={catalog:"/api/hooks/catalog",stats:"/api/protocol-stats",poolApr:"/api/pool-apr",revenueTokens:"/api/revenue-tokens",revenueIncome:"/api/revenue-tokens/income"};function y(d){return{name:"hookr_api_read",inputSchema:{type:"object",description:"Read Hookr public catalog, protocol stats, pool APR, revenue directory/income, or one token's doors/mark. Marks are project metadata, not investment or security endorsements.",properties:{resource:{type:"string",enum:[...Object.keys(m),"revenueDoors","revenueMark"]},token:p},required:["resource"],additionalProperties:!1},execute:async e=>{if(Object.keys(e).some(o=>!["resource","token"].includes(o))||typeof e.resource!="string")throw new a("Choose a documented Hookr public resource.");let t=["revenueDoors","revenueMark"].includes(e.resource);if(!t&&e.token!==void 0||t&&typeof e.token!="string")throw new a("Only the revenueDoors and revenueMark resources take a token address.");let c;if(t){let o;try{o=v(String(e.token))}catch{throw new a("Provide a valid revenue token address.")}c=`/api/revenue-tokens/${o}/${e.resource==="revenueDoors"?"doors":"mark"}`}else{if(!Object.hasOwn(m,e.resource))throw new a("Choose a documented Hookr public resource.");c=m[e.resource]}let s=`https://hookr.fun${c}`;try{let o=await d.http(s,{method:"GET",redirect:"error",signal:AbortSignal.timeout(15e3)});if(!o.ok)throw new Error("Unavailable");if(e.resource==="revenueMark"){if(!o.headers.get("content-type")?.includes("image/svg+xml"))throw new Error("Invalid mark");return{chainId:l,source:s,imageUrl:s,pngUrl:`${s}.png`,note:"Official SVG mark URL; SVG code is not executed or returned. The PNG URL has not been fetched."}}let r=await o.json();if(!r||typeof r!="object"||"error"in r||"status"in r&&r.status==="unavailable")throw new Error("Unavailable");return{chainId:l,source:s,data:r}}catch{throw new a("Hookr public resource is unavailable. Retry later; no empty or zero result is implied.")}}}}export{H as a,j as b,y as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as v,d as N,e as h}from"./
|
|
1
|
+
import{c as v,d as N,e as h}from"./5AXWBSPG.js";import{a as m}from"./66F5ZH34.js";import{c as d,f as B,g as p,i as E}from"./NWNYJ26T.js";import{a as H}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{decodeEventLog as W,encodeFunctionData as G,getAddress as V,hashStruct as Y,isHex as J,parseAbi as Q,zeroAddress as k}from"viem";var Z="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",I=Q(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",Z,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),ee={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},ne=V("0x000000000022D473030F116dDEE9F6B43aC78BA3"),F={key:{type:"object",properties:{currency0:d,currency1:d,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:d},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean"},amountSpecified:{type:"string",pattern:"^-?[0-9]+$"},amountBound:m(),sqrtPriceLimitX96:m(),recipient:d,relayer:d,relayerFee:m(),engagement:d,campaigns:{type:"array",items:m(),maxItems:8},nonce:m(),deadline:m()},x={owner:d,signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$"},intent:{type:"object",properties:F,required:Object.keys(F),additionalProperties:!1}};function D(t){return B(t,"Provide a complete trader-signed Hookr intent.")}function y(t,i=256,e=!1){if(typeof t!="string"||!/^-?\d+$/.test(t)||t.length>79)throw new o("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let n=BigInt(t);if(e?n<=-(1n<<BigInt(i-1))||n>=1n<<BigInt(i-1):n<0n||n>=1n<<BigInt(i))throw new o("Hookr intent integer is outside its ABI range.");return n}function l(t){return E(t,"Provide valid Hookr intent addresses.")}function j(t,i){if(Object.keys(t).some(s=>!Object.hasOwn(x,s)))throw new o("Provide only owner, intent and the trader signature for Hookr relay.");let e=D(t.intent);if(Object.keys(e).some(s=>!Object.hasOwn(F,s)))throw new o("Hookr intent contains an undocumented field.");let n=D(e.key);if(Object.keys(n).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof n.fee!="number"||!Number.isInteger(n.fee)||n.fee<0||n.fee>16777215||typeof n.tickSpacing!="number"||!Number.isInteger(n.tickSpacing)||n.tickSpacing<=0||n.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new o("Provide a valid canonical v4 pool key and direction.");let a={currency0:l(n.currency0),currency1:l(n.currency1),fee:n.fee,tickSpacing:n.tickSpacing,hooks:l(n.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new o("Hookr pool currencies must sort strictly by address.");let r=l(t.owner);if(r===k||p(r,i))throw new o("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new o("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:y(e.amountSpecified,128,!0),amountBound:y(e.amountBound,128),sqrtPriceLimitX96:y(e.sqrtPriceLimitX96,160),recipient:l(e.recipient),relayer:l(e.relayer),relayerFee:y(e.relayerFee),engagement:l(e.engagement),campaigns:e.campaigns.map(s=>y(s)),nonce:y(e.nonce),deadline:y(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new o("Hookr intent input/output amounts and bound must be nonzero.");if([k,h,v].some(s=>p(s,c.recipient)))throw new o("Hookr intent recipient is reserved.");if(c.relayer!==k&&!p(c.relayer,i)||c.relayer===k&&c.relayerFee!==0n)throw new o("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===k!=(c.campaigns.length===0))throw new o("Hookr engagement and campaigns must be supplied together.");let f=c.zeroForOne?a.currency0:a.currency1;if(f===k)throw new o("Hookr Permit2 relay cannot pull native ETH input.");if(typeof t.signature!="string"||!J(t.signature,{strict:!0})||t.signature.length<4||t.signature.length%2!==0||t.signature.length>16386)throw new o("Provide the trader-signed Permit2 witness signature, never a private key.");let S=t.signature,w=Y({data:c,primaryType:"HookrSwapIntent",types:ee});return{owner:r,intent:c,signature:S,input:f,intentHash:w}}function q(t,i){let{owner:e,intent:n,signature:a}=j(t,i);return{chainId:H,to:h,value:"0",data:G({abi:I,functionName:"execute",args:[n,e,a]}),description:`Relay Hookr trader ${e} to recipient ${n.recipient}; relayer fee ${n.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function ce(t,i,e){let n=q(i,e);if(t.length!==1||t[0].chainId!==n.chainId||!p(t[0].to,n.to)||t[0].value!=="0"||!p(t[0].data,n.data))throw new o("Hookr relay calldata differs from the locally requested signed intent.")}function ue(t){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:x,required:Object.keys(x),additionalProperties:!1},execute:async(i,e)=>{let n=j(i,e),{owner:a,intent:r,signature:c,input:f,intentHash:S}=n,w=t.clientFor(H),s=await w.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>r.deadline)throw new o("Hookr signed intent expired or the chain timestamp is unavailable.");let g=(X,M=[])=>w.readContract({address:h,abi:I,functionName:X,args:M,blockNumber:s.number}),[_,u,z,K,$,U]=await Promise.all([g("hashIntent",[r]),g("pullOf",[r]),g("isNonceUsed",[a,r.nonce]),g("router"),g("registry"),g("permit2")]);if(_!==S||z!==!1||K!==v||$!==N||U!==ne)throw new o("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(u)||u.length!==3||typeof u[0]!="string"||!p(u[0],f)||typeof u[1]!="bigint"||typeof u[2]!="boolean")throw new o("Hookr Permit2 pull could not be verified.");let b=u[2],P=r.amountSpecified<0n?-r.amountSpecified:r.amountBound;if(u[1]!==P+(b?r.relayerFee:0n)||r.amountSpecified>0n&&!b&&r.relayerFee>r.amountSpecified)throw new o("Hookr Permit2 pull or output-side fee differs from the signed terms.");let C=await w.simulateContract({address:h,abi:I,functionName:"execute",args:[r,a,c],account:e,blockNumber:s.number}),[A,R]=C.result,T=r.amountSpecified<0n?r.amountBound:r.amountSpecified-(b?0n:r.relayerFee);if(A>P||R<T)throw new o("Hookr relay simulation did not satisfy the signed input/output bounds.");let O=[t.unsignedTx(q(i,e))],L=await t.preview(O,e);return{txs:O,preview:L,summary:O[0].description,intentHash:S,owner:a,recipient:r.recipient,relayer:e,inputToken:f,maximumPull:u[1].toString(),feeToken:b?f:r.zeroForOne?r.key.currency1:r.key.currency0,relayerFee:r.relayerFee.toString(),feeFromInput:b,minimumOutput:T.toString(),simulatedAmountIn:A.toString(),simulatedAmountOut:R.toString(),note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}},required:["transactionHash"],additionalProperties:!1},execute:async i=>{if(Object.keys(i).some(a=>a!=="transactionHash")||typeof i.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(i.transactionHash))throw new o("Provide a Hookr relay transactionHash.");let e=await t.clientFor(H).getTransactionReceipt({hash:i.transactionHash});if(e.status!=="success")throw new o("Hookr relay reverted. No fee is proven paid.");let n=e.logs.filter(a=>p(a.address,h)).flatMap(a=>{try{let r=W({abi:I,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...r.args,amountIn:r.args.amountIn.toString(),amountOut:r.args.amountOut.toString(),relayerFee:r.args.relayerFee.toString()}]}catch{return[]}});if(!n.length)throw new o("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:H,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:n,note:"Event evidence at this mined block; check balances and finality."}}}]}export{I as a,j as b,q as c,ce as d,ue as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{erc20Abi as n,parseAbi as e}from"viem";var s=[...n,...e(["function convertToAssets(uint256 shares) view returns (uint256 assets)","function implementation() view returns (address)","function allIndexes() view returns ((address index,address creator,bool verified,bool selfLending,bool makePublic)[])","function getIndex(address _index) view returns ((address index,address creator,bool verified,bool selfLending,bool makePublic))","function isRegistered(address _index) view returns (bool)","function validateIndex(address index) view","function addLPAndStake(address _indexFund,uint256 _amountIdxTokens,address _pairedLpTokenProvided,uint256 _amtPairedLpTokenProvided,uint256 _amountPairedLpTokenMin,uint256 _slippage,uint256 _deadline) payable returns (uint256 _amountOut)","function unstakeAndRemoveLP(address _indexFund,uint256 _amountStakedTokens,uint256 _minLPTokens,uint256 _minPairedLpToken,uint256 _deadline)","function PAIRED_LP_TOKEN() view returns (address)","function bond(address _token,uint256 _amount,uint256 _amountMintMin)","function config() view returns ((address partner,uint256 debondCooldown,bool hasTransferTax,bool blacklistTKNpTKNPoolV2))","function debond(uint256 _amount,address[],uint8[])","function fees() view returns ((uint16 burn,uint16 bond,uint16 debond,uint16 buy,uint16 sell,uint16 partner))","function getAllAssets() view returns ((address token,uint256 weighting,uint256 basePriceUSDX96,address c1,uint256 q1)[])","function lpRewardsToken() view returns (address)","function lpStakingPool() view returns (address)","function totalAssets(address _asset) view returns (uint256 _totalManagedAssets)","function v2Pool() view returns (address)","function INDEX_FUND() view returns (address)","function POOL_REWARDS() view returns (address)","function stakingToken() view returns (address)","function withdrawableStake(address wallet) view returns (uint256)","function claimReward(address _wallet)","function getClaimable(address token,address wallet) view returns (uint256)","function getUnpaid(address _token,address _wallet) view returns (uint256)","function indexFund() view returns (address)","function rewardsToken() view returns (address)","function trackingToken() view returns (address)","function paused(address) view returns (bool)"])];export{s as a};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as v}from"./VHV6WQ5F.js";import{$ as M,_ as R,ca as x}from"./ACW63WIL.js";import{g as A,i as k,m as _,n as P}from"./NWNYJ26T.js";import{a as p}from"./FWD4L3CJ.js";import{a as n}from"./XSD5NL7J.js";import{encodeFunctionData as D}from"viem";var F={asset:{type:"string",pattern:"^[A-Za-z0-9.$_-]{1,32}$",description:"Official asset symbol; use vault if discovery is unavailable or ambiguous."},vault:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$",description:"Vault address verified on chain on every call; required for a rebuild without HTTP."}};function O(c){return{type:"object",additionalProperties:!1,properties:{...F,amount:{type:"string",pattern:c==="withdraw"?"^(?:[0-9]+|max)$":"^[0-9]+$"}},required:["amount"],anyOf:[{required:["asset"]},{required:["vault"]}]}}function U(c){return P(c,"Borro amount must be positive and fit uint256.",{positive:!0,notString:"Borro amount must be an integer string in asset base units."})}function g(c){return _(c,"Borro returned an invalid uint256 read.")}var W=c=>c*9950n/10000n;function z(c,l,h,d,N){let S=0n,m=0n;for(let y of c.changes){let b=y.token;if(typeof y.amount!="string"||!/^-?\d+$/.test(y.amount))throw new n("Borro preview returned invalid token changes. Nothing was signed.");let e=BigInt(y.amount);g(e<0n?-e:e);let o=A(b.address,l.address)?l:A(b.address,d.address)?d:void 0;if(!o||b.chainId!==p||b.decimals!==o.decimals)throw new n("Borro preview showed an unexpected token movement. Nothing was signed.");if(o===l){if(e>0n)throw new n("Borro preview showed a reversed input movement. Nothing was signed.");S-=e}else{if(e<0n)throw new n("Borro preview showed a reversed output movement. Nothing was signed.");m+=e}}if(g(S),g(m),S!==h||m<N||m===0n)throw new n("Borro preview did not match the requested receipt. Nothing was signed.")}var K=c=>{let{client:l,context:h,wallet:d}=c;async function N(e,o,a){if(k(a,"Provide a valid wallet address."),!A(a,d))throw new n("Borro action wallet differs from the signing wallet. Nothing was signed.");if(h.network==="testnet"||await l.getChainId()!==p)throw new n("Borro requires chain 4663. Nothing was signed.");if(Object.keys(e).some(i=>!["asset","vault","amount"].includes(i)))throw new n("Unsupported Borro argument.");if(e.asset!==void 0&&(typeof e.asset!="string"||!/^[A-Za-z0-9.$_-]{1,32}$/.test(e.asset)||/^0x/i.test(e.asset)))throw new n("Provide an asset symbol, or put the vault address in vault.");let w=e.vault===void 0?void 0:k(e.vault,"Provide a valid Borro vault address.");if(!w&&e.asset===void 0)throw new n("Provide an asset symbol or a vault address.");let t=w?await c.verifyVault(l,w,o,{wallet:d}):await c.resolveVault(l,{asset:e.asset},o,d);if(w&&!A(w,t.vault)||e.asset!==void 0&&e.asset.toUpperCase()!==t.symbol.toUpperCase())throw new n("Borro vault and asset selectors do not match. Nothing was signed.");if(k(t.vault,"Borro returned an invalid vault address."),k(t.asset,"Borro returned an invalid asset address."),t.chainId!==p||t.shareDecimals!==18||A(t.asset,t.vault)||!Number.isInteger(t.assetDecimals)||t.assetDecimals<0||t.assetDecimals>255||t.mode!==o)throw new n(x("setup-mismatch",{}));let s=await c.verifySetup(l,t,o);if(!s.ok||o==="deposit"&&(!t.assetAllowed||s.drift.length>0))throw new n(x("setup-mismatch",{}));return{...t,setup:s}}function S(e){let o=e.mode==="withdraw"&&!/^[A-Za-z0-9.$_-]{1,16}$/.test(e.symbol)?"token":e.symbol;return{asset:{address:k(e.asset,"Borro returned an invalid asset."),symbol:o,decimals:e.assetDecimals,chainId:p},share:{address:k(e.vault,"Borro returned an invalid vault."),symbol:e.vaultSymbol,decimals:18,chainId:p}}}let m=(e,o)=>h.formatAmount(e.toString(),o),y="The minimum is checked in the preview; standard ERC-4626 calldata does not enforce it on chain. Re-preview before signing; execution output can change.",b=[{name:"borro_deposit",inputSchema:O("deposit"),execute:async(e,o)=>{let a=U(e.amount),w=await N(e,"deposit",o),{asset:t,share:s}=S(w),i=g(await l.readContract({address:t.address,abi:v,functionName:"balanceOf",args:[d]}));if(a>i)throw new n("This wallet does not hold enough of that asset for the Borro deposit.");let f=g(await l.readContract({address:s.address,abi:v,functionName:"previewDeposit",args:[a]}));if(f===0n)throw new n(x("deposit-would-revert",{}));let r=W(f),u=[h.approval(t.address,s.address,a.toString(),p),h.unsignedTx({to:s.address,data:D({abi:v,functionName:"deposit",args:[a,d]}),value:"0",chainId:p,description:`Deposit ${a} asset base units into Borro vault ${s.address}.`})],$;try{$=await h.preview(u,d),z($,t,a,s,r)}catch{throw new n(x("deposit-would-revert",{}))}let T=w.deployedAt===void 0?void 0:Date.parse(w.deployedAt)/1e3,B=R({amount:m(a,t.decimals),symbol:t.symbol,kind:t.symbol==="USDG"?"usdg":"stock",shares:m(f,18),sharesMin:m(r,18),vaultSymbol:s.symbol,deployedAtSeconds:T,nowSeconds:Math.floor(Date.now()/1e3)});return{txs:u,preview:$,vault:s.address,asset:t,shareToken:s,amount:a.toString(),shares:f.toString(),shares_min:r.toString(),summary:`${B}
|
|
2
|
+
Base units: amount ${a} (${t.address}, decimals ${t.decimals}); shares ${f} (${s.address}, decimals 18); shares_min ${r}. ${y}`}}},{name:"borro_withdraw",inputSchema:O("withdraw"),execute:async(e,o)=>{let a=e.amount==="max",w=a?void 0:U(e.amount),t=await N(e,"withdraw",o),{asset:s,share:i}=S(t),f=g(await l.readContract({address:i.address,abi:v,functionName:"balanceOf",args:[d]}));if(f===0n)throw new n(x("no-shares",{symbol:s.symbol}));let r=a?f:g(await l.readContract({address:i.address,abi:v,functionName:"previewWithdraw",args:[w]}));if(r===0n||r>f)throw new n("This wallet does not hold enough Borro shares for that withdrawal.");let u=w??g(await l.readContract({address:i.address,abi:v,functionName:"previewRedeem",args:[r]}));if(u===0n)throw new n("Borro preview returned no assets for these shares. Nothing was signed.");let $=await c.readLiquidity(l,t).catch(()=>({kind:"unknown"})),T=$.kind!=="unknown"&&"readyBase"in $?$.readyBase:void 0,B=typeof T=="bigint"&&T>=0n&&T<1n<<256n?T:void 0;if(B!==void 0&&B<u)return{txs:[],vault:i.address,asset:s,shareToken:i,amount:u.toString(),shares:r.toString(),max_now:B.toString(),summary:x("too-little-ready",{ready:m(B,s.decimals),requested:m(u,s.decimals),maxNow:m(B,s.decimals),symbol:s.symbol})};let I=a?W(u):u,V=[h.unsignedTx({to:i.address,data:a?D({abi:v,functionName:"redeem",args:[r,d,d]}):D({abi:v,functionName:"withdraw",args:[u,d,d]}),value:"0",chainId:p,description:`Withdraw ${u} asset base units from Borro vault ${i.address}${a?` for ${r} share base units`:""}.`})],C=a?await h.preview(V,d):await h.preview(V,d,{reads:[{to:i.address,data:D({abi:v,functionName:"previewWithdraw",args:[u]}),chainId:p}]});if(!a){let q=C.readResults?.[0];if(C.readResults?.length!==1||typeof q!="string"||!/^0x[0-9a-fA-F]{64}$/.test(q))throw new n("Borro preview returned an invalid share quote. Nothing was signed.");if(r=g(BigInt(q)),r===0n||r>f)throw new n("This wallet does not hold enough Borro shares for that withdrawal.")}z(C,i,r,s,I);let E=M({amount:m(u,s.decimals),isAll:a,symbol:s.symbol,out:m(u,s.decimals),shares:m(r,18),vaultSymbol:i.symbol,drift:t.setup.drift.length>0});return{txs:V,preview:C,vault:i.address,asset:s,shareToken:i,amount:u.toString(),shares:r.toString(),assets_min:I.toString(),isMax:a,setup:t.setup,summary:`${E}
|
|
3
|
+
Base units: amount ${u} (${s.address}, decimals ${s.decimals}); shares ${r} (${i.address}, decimals 18); assets_min ${I}. ${y}`}}}];for(let e of b){let o=e.execute;e.execute=async(a,w)=>{try{return await o(a,w)}catch(t){throw new n(h.plainError(t))}}}return b};export{K as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as X}from"./CEQNXF6A.js";import{b as Q}from"./
|
|
1
|
+
import{a as X}from"./CEQNXF6A.js";import{b as Q}from"./AXRL3REN.js";import{a as O,b as J,d as V}from"./6OGDTEGH.js";import{a as E}from"./QYKXWBZC.js";import{K as y}from"./DHUDSOGR.js";import{c as S}from"./AEL62KCG.js";import{a as H}from"./43LI5NKJ.js";import{a as N}from"./66F5ZH34.js";import{d as G,g as U,i as K}from"./NWNYJ26T.js";import{a as b}from"./FWD4L3CJ.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as Z,erc20Abi as Y,getAddress as W,parseAbi as ee,zeroAddress as te}from"viem";var v={address:W("0xCeF73866b088766DeD46Ba71d9Bd7591B5e931d2"),symbol:"tNET",decimals:9,chainId:b},_={pair_oracle:["checkpoint"],futures:["open","close","marginCall","accrueCarry","sweepCarrySkim"],underwriting:["subscribe","redeem"],prize:["enter","enterWithNet","exit","exitToUsdg","lockTranche","earlyUnlock","pokeRebase"]},fe=x=>({tools:[{name:"netnet_desk_action",inputSchema:{type:"object",additionalProperties:!1,required:["program","operation"],properties:{program:{type:"string",enum:Object.keys(_)},operation:{type:"string",enum:[...new Set(Object.values(_).flat())]},amount:N(),minAmountOut:N(),maxPayment:N(),sizeUsdWad:N(),isLong:{type:"boolean"},account:{type:"string"},referrer:{type:"string"},trancheIndex:N(),lockDraws:{enum:["7","30"]},maxPenaltyAssets:N()}},execute:async(t,l)=>{try{if(H(l),typeof t.program!="string"||!Object.hasOwn(_,t.program)||typeof t.operation!="string"||!_[t.program].includes(t.operation))throw new e("Choose a supported finite NetNet desk operation.");let p=t.program,r=t.operation,P=E[p],q=X[p],T=x.clientFor(b);if(await T.getChainId()!==b)throw new e("NetNet desk actions require chain 4663.");let C=await T.getBlock(),z=new Set(["program","operation"]),m=(n,s=[])=>T.readContract({address:P.address,abi:q,functionName:n,args:s,blockNumber:C.number}),h=(...n)=>n.forEach(s=>z.add(s)),A=()=>(h("amount"),y(t.amount)),D=()=>(h("minAmountOut"),y(t.minAmountOut)),c=n=>K(n,"Provide an explicit checksummed account.",G),u=[],o,d=0n,w="",g;if(p==="pair_oracle"){if(c(await m("pairContract"))!==Q)throw new e("The oracle does not use the pinned canonical pair.");w="Permissionless oracle checkpoint; it sends no reward to this wallet and may not yet produce a valid TWAP."}else if(p==="futures"||p==="underwriting"){if(c(await m("token"))!==v.address||await T.readContract({address:v.address,abi:Y,functionName:"decimals",blockNumber:C.number})!==9)throw new e("This desk does not use the pinned valueless 9-decimal tNET test collateral.");let n=E.futures.address,s=E.underwriting.address;if(p==="futures"?c(await m("vault"))!==s:c(await m("clearinghouse"))!==n)throw new e("Futures and underwriting counterparties do not match the published pins.");if(w="Experimental tNET test program; tNET has no monetary value. Futures margin and underwriting capital can be lost. Utilization/ADL can prevent redemption. Prices and fees are read from the contract oracle; these calls encode no price floor.",r==="open"){if(h("isLong","sizeUsdWad","maxPayment"),typeof t.isLong!="boolean")throw new e("Provide isLong as a boolean.");let a=A(),f=y(t.sizeUsdWad);if(a>=1n<<128n||f>=1n<<128n)throw new e("Position margin and notional must fit uint128.");let k=c(await m("oracle"));if(k!==W("0xc8a11E8793F8714a159061369173dc86A0A5E23F"))throw new e("The futures oracle is not the published deployment.");let $=await T.readContract({address:k,abi:ee(["function marginPriceWad() view returns (uint256)"]),functionName:"marginPriceWad",blockNumber:C.number});if($<=0n)throw new e("Futures margin price is unavailable.");let i=f*5n/10000n*1000000000n/$;if(d=a+i,o=v,d>y(t.maxPayment))throw new e("Margin plus taker fee exceeds maxPayment.");u=[t.isLong,f,a],w+=` Entry fee ${i} tNET base units; exact approval caps price drift and may require a fresh preview.`}else if(r==="marginCall"){h("account");let a=c(t.account);if(await m("liquidatable",[a])!==!0)throw new e("The selected futures trader is not liquidatable.");u=[a]}else if(r==="subscribe"){d=A(),o=v,u=[d];let[a,f]=await Promise.all([m("totalShares"),m("equityTokens")]);if(typeof a!="bigint"||typeof f!="bigint"||a>0n&&f===0n)throw new e("Underwriting share price is invalid.");let k=a===0n?d:d*a/f;if(k===0n||k<D())throw new e("Underwriting subscription rounds to zero or misses the local share minimum.");w+=` Current quote ${k} underwriting share units; the share minimum is a local check, not encoded calldata.`}else if(r==="redeem"){let a=A();if(a>await m("sharesOf",[l]))throw new e("The wallet has insufficient underwriting shares.");u=[a],g={token:v,amount:D()}}}else{let[n,s,a,f,k,$]=await Promise.all(["net","usdg","staking","sNet","controller","book"].map(i=>m(i)));if(c(n)!==O.address||c(s)!==S.address||c(a)!==V||c(f)!==J.address||c(k)!==E.draw.address||c($)!==E.bonus.address)throw new e("WinNET token, staking, book or controller does not match its published pins.");if(w="WinNET principal is a fixed NET claim, exposed to NET price changes. Entry commits through three staking epochs; locks commit for 7 or 30 draws. Early unlock forfeits 1% of principal and cancels streak credits. Pair buys and sells each incur the NET trading tax; no prize or return is guaranteed.",r==="enter"||r==="enterWithNet"){h("referrer");let i=t.referrer===void 0?te:c(t.referrer);if(i===W(l))throw new e("WinNET does not permit self-referral.");d=A(),o=r==="enter"?S:O,u=r==="enter"?[d,D(),i]:[d,i],w+=` Referrer ${i} is recorded at the first deposit and cannot later be changed.`}else if(r==="exit"||r==="exitToUsdg"){let i=A();if(i>await m("principalOf",[l]))throw new e("WinNET exit exceeds this wallet\u2019s fixed principal.");u=r==="exit"?[i,l]:[i,D(),l],g={token:r==="exit"?O:S,amount:r==="exit"?i:y(t.minAmountOut)}}else if(r==="lockTranche"||r==="earlyUnlock"){h("trancheIndex");let i=y(t.trancheIndex,!0),I=await m("trancheAt",[l,i]);if(!Array.isArray(I)||typeof I[0]!="bigint"||I[0]===0n)throw new e("Choose a nonempty WinNET tranche.");if(r==="lockTranche"){if(h("lockDraws"),t.lockDraws!=="7"&&t.lockDraws!=="30")throw new e("Choose a 7- or 30-draw lock.");u=[i,BigInt(t.lockDraws)]}else{h("maxPenaltyAssets");let M=(I[0]+99n)/100n;if(M>y(t.maxPenaltyAssets,!0))throw new e("Early unlock exceeds maxPenaltyAssets in NET base units.");u=[i],w+=` Current irreversible forfeiture ${M} NET base units.`}}}if(Object.keys(t).some(n=>!z.has(n)))throw new e("Unexpected fields for this desk operation.");if(o&&await T.readContract({address:o.address,abi:Y,functionName:"balanceOf",args:[l],blockNumber:C.number})<d)throw new e(`Top up ${o.symbol}; this action needs ${d} base units.`);let F=`NetNet ${p}.${r}, contract ${P.address}, chain ${b}, ordered values ${JSON.stringify(u,(n,s)=>typeof s=="bigint"?String(s):s)}. ${o?`Approve exactly ${d} ${o.symbol} base units (token ${o.address}, decimals ${o.decimals}). `:""}${w}`,L=[...o?[x.approval(o.address,P.address,d.toString(),b)]:[],x.unsignedTx({to:P.address,data:Z({abi:q,functionName:r,args:u}),value:"0",chainId:b,description:F})],R=await x.preview(L,l),B=0n,j=0n;for(let n of R.changes){if(n.token.chainId!==b||!/^-?\d+$/.test(n.amount))throw new e("Invalid desk preview metadata.");let s=BigInt(n.amount);if(s<0n){if(!o||!U(n.token.address,o.address)||n.token.decimals!==o.decimals)throw new e("Desk preview spends an unexpected wallet asset.");B-=s}if(g&&U(n.token.address,g.token.address)){if(n.token.decimals!==g.token.decimals)throw new e("Desk receipt decimals mismatch.");j+=s}}if(B>d||g&&j<g.amount)throw new e("Desk preview exceeds its input budget or misses the requested receipt minimum.");return{txs:L,preview:R,summary:F}}catch(p){throw new e(x.plainError(p))}}}]});export{v as a,fe as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as q}from"./3FUVMSCF.js";import{b as S}from"./P56RZC2M.js";import{b as le}from"./SPJCSEKP.js";import{a as _}from"./43LI5NKJ.js";import{g as B,i as ue}from"./NWNYJ26T.js";import{b as H}from"./IX3GZMTM.js";import{a as c,i as N}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[c].hoodlock.locker.address),C=m(N[c].hoodlock.burner.address),v=m(N[c].hoodlock.liquidityLocker.address),j=m(N[c].uniswap.v3_position_manager.address),K=m(N[c].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new u(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new u(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new u(e.plainError(t))}}function we(e){let o=H(e);if(o<=0n)throw new u("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new u("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new u("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new u("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new u(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new u(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=c){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new u("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new u(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new u(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new u("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new u("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new u("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new u("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(c),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new u("This wallet does not own that v4 position NFT.");if(J<=0n)throw new u("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new u(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new u(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new u(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:c,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:c,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(c),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,c)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new u(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),c),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:c,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(c),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,c)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new u(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),c),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:c,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(c),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,c);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:c,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:c,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:c,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:c,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:c},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
|
|
1
|
+
import{b as q}from"./2MT3G7YZ.js";import{b as S}from"./AEL62KCG.js";import{b as le}from"./SPJCSEKP.js";import{a as _}from"./43LI5NKJ.js";import{g as B,i as ue}from"./NWNYJ26T.js";import{b as H}from"./IX3GZMTM.js";import{a as c,i as N}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{a as ce}from"./JXOEJPJ4.js";import{encodeFunctionData as z,erc20Abi as me,getAddress as m,isAddress as he,parseAbi as U,zeroAddress as ke}from"viem";var T=m(N[c].hoodlock.locker.address),C=m(N[c].hoodlock.burner.address),v=m(N[c].hoodlock.liquidityLocker.address),j=m(N[c].uniswap.v3_position_manager.address),K=m(N[c].uniswap.v4_position_manager.address),qe="0x000000000000000000000000000000000000dEaD",Ae=3153600000n,Te=1000000000000n,fe=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),ee=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),O=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),ye=U(["function approve(address to, uint256 tokenId)"]);function $e(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function pe(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${$e(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new u(`Provide a valid ${o} contract address.`);if(!he(e,{strict:!1}))throw new u(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new u(e.plainError(t))}}function we(e){let o=H(e);if(o<=0n)throw new u("Amount must be greater than zero.");return o}async function ge(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new u("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ve(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new u("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Te)throw new u("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new u(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+Ae;if(t>a)throw new u(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function oe(e,o,t=c){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:me,functionName:"symbol"}),e.readContract({address:a,abi:me,functionName:"decimals"})]);return{address:a,symbol:ce(String(k)),decimals:Number(i),chainId:t}}function Se(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>fe)throw new u("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new u(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Le(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function xe(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?K:j,g=i===K;if(i!==j&&!g)throw new u(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new u("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new u("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new u("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new u("Provide an NFT tokenId as a decimal string.");let f=String(o.tokenId).trim(),d=H(f),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),p=e.clientFor(c),[x,I,h]=await Promise.all([ge(p),p.readContract({address:v,abi:O,functionName:"fixedFee"}),p.readContract({address:v,abi:O,functionName:"collectFeeBps"})]),y,$=!0;if(g){let P=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([p.readContract({address:i,abi:P,functionName:"getPoolAndPositionInfo",args:[d]}),p.readContract({address:i,abi:P,functionName:"getPositionLiquidity",args:[d]}),p.readContract({address:i,abi:P,functionName:"ownerOf",args:[d]})]);if(m(M)!==a)throw new u("This wallet does not own that v4 position NFT.");if(J<=0n)throw new u("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===ke||await p.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new u(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=ve(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>fe)throw new u(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let P=H(String(o.maxFee));if(n>P)throw new u(`Live fixedFee (${n}) exceeds maxFee (${P}).`)}let w=Se(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:z({abi:ye,functionName:"approve",args:[v,d]}),value:"0",chainId:c,description:`Approve Uniswap ${s} position NFT #${d} on ${i} for HoodLock LiquidityLocker ${v}.`}),F=e.unsignedTx({to:v,data:z({abi:O,functionName:"lock",args:[i,d,A,l,b,w]}),value:n.toString(),chainId:c,description:`Lock Uniswap ${s} NFT #${d} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,F],V=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${d} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${w}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return q(e,{txs:V.txs,summary:Q,preview:V,kind:s,contract:v,manager:i,tokenId:d.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:w,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Ie(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(c),[g,b,s]=await Promise.all([ge(i),i.readContract({address:T,abi:D,functionName:"fee"}),oe(i,k,c)]),f=we(o.amount),d=ve(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new u(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,T,f.toString(),c),x=e.unsignedTx({to:T,data:z({abi:D,functionName:"lock",args:[s.address,f,d]}),value:l.toString(),chainId:c,description:`Lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until ${d} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and lock ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${d}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:f.toString(),unlockTime:d.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Pe(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Le(o)?xe(e,o,t):Ie(e,o,t))}}}function Ce(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(c),[g,b,s]=await Promise.all([i.readContract({address:C,abi:ee,functionName:"fee"}),i.readContract({address:C,abi:ee,functionName:"DEAD"}),oe(i,k,c)]),f=we(o.amount),d=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(d>A)throw new u(`Live burn fee (${d}) exceeds maxFee (${A}).`)}let p=e.approval(s.address,C,f.toString(),c),x=e.unsignedTx({to:C,data:z({abi:ee,functionName:"burn",args:[s.address,f]}),value:d.toString(),chainId:c,description:`Send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C} (totalSupply is unchanged) with exact fee ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei).`}),I=[p,x],h=await e.preview(I,a),y=pe(e,h.changes),$=`Approve and send ${e.formatAmount(f.toString(),s.decimals)} ${s.symbol} (${f} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${C}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(d.toString(),S.decimals)} ETH (${d} wei). Preview changes: ${y}.`;return q(e,{txs:h.txs,summary:$,preview:h,contract:C,deadAddress:l,token:s,amount:f.toString(),fee:{token:S,amount:d.toString()},totalSupplyReduced:!1},C,d)})}}}async function be(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(c),g=[],b=new Set,s=n=>{for(let r of n){let w=r.toString();b.has(w)||(b.add(w),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let d=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,p=async n=>{let r=n.toLowerCase(),w=l.get(r);if(w)return w;let L=n===ke?S:await oe(i,n,c);return l.set(r,L),L},x=[],I=[];for(let n of d){let r=await p(n.token),w=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:w};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:c,owner:n.owner,token:r,amount:w,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:c,assets:[R],description:`HoodLock token lock #${n.id} of ${e.formatAmount(w,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:O,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:O,functionName:"getLock",args:[n]}),[w,L,R,F,X,V,Q,P,Y,J]=r,M=m(w);if(V||!B(M,a))continue;let ne=m(P),te=m(Y);if(k&&!B(ne,k)&&!B(te,k))continue;let[ie,re]=await Promise.all([p(ne),p(te)]),se=m(Q),ae=Number(R),de=BigInt(L).toString(),Z=BigInt(J).toString();$.push({lockId:n.toString(),kind:F?"v4":"v3",contract:v,manager:F?K:j,chainId:c,owner:M,tokenId:Z,unlockTime:de,collectFeeBps:ae,feeRecipient:se,hookVerified:!!X,token0:ie,token1:re,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:c,assets:[{token:{address:F?K:j,symbol:`UNI-${F?"V4":"V3"} #${Z}`,decimals:0,chainId:c},amount:"1"}],description:`HoodLock Uniswap ${F?"v4":"v3"} LP lock #${n} (NFT #${Z}, ${ie.symbol}/${re.symbol}, feeRecipient ${se}, collectFeeBps ${ae}) until Unix ${de}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function Fe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>be(e,a,k))}}}function Re(e){return async o=>(await W(e,()=>be(e,o))).positions}var G=e=>({tools:[Pe(e),Ce(e),Fe(e)],positions:Re(e)}),ze=G,je=G,Ke=e=>le("hoodlock",[G(e)]),We=G;export{T as a,C as b,v as c,j as d,K as e,qe as f,Ae as g,$e as h,Pe as i,Ce as j,Fe as k,Re as l,G as m,ze as n,je as o,Ke as p,We as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as Y,e as Z}from"./
|
|
1
|
+
import{b as Y,e as Z}from"./FEYAY6OZ.js";import{a as U,b as L,c as D,d as G,e as _,f as W,g as J}from"./PIIHOXWF.js";import{d as C,e as $,v as H}from"./2THSW4QN.js";import{a as K}from"./IOYRL6AY.js";import{a as S}from"./66F5ZH34.js";import{c as h,g as Q}from"./NWNYJ26T.js";import{a as I,i as T}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as b,encodeFunctionData as ee,encodePacked as de,erc20Abi as me,getAddress as ue,parseAbi as N,parseAbiParameters as A,zeroAddress as v}from"viem";var te=ue("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),ne=ue(T[4663].ponsTrade.quoter.address),fe=N(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),le=N(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),oe=N(["function factory() view returns (address)","function quoteExactInput(bytes path,uint256 amountIn) returns (uint256,uint160[],uint32[],uint256)","function quoteExactOutput(bytes path,uint256 amountOut) returns (uint256,uint160[],uint32[],uint256)"]),F="(address intermediateCurrency,uint24 fee,int24 tickSpacing,address hooks,bytes hookData)",M="(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",re=N([`function quoteExactInput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactOutput((address exactCurrency,${F}[] path,uint128 exactAmount) params) returns (uint256,uint256)`,`function quoteExactInputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`,`function quoteExactOutputSingle((${M} poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256,uint256)`]),ye=A(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function he(u,t,r,d){let a=[],e=d?r:t,i=new Set([e]);for(let n of d?[...u].reverse():u){let s=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!s||i.has(s))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");a.push({intermediateCurrency:s,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=s,i.add(e)}if(e!==(d?t:r))throw new o("V4 route does not end at the requested currency.");return a}var xe=A(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),be=A("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),we=A("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ie=A("address,uint256"),ve=A("bytes,bytes[]");function Ae(u,t,r){let d=r?[...u].reverse():u,a=r?[...t].reverse():t,e=d[0];return a.forEach((i,n)=>{e=`${e}${de(["uint24","address"],[i,d[n+1]]).slice(2)}`}),e}var ae={version:{type:"string",enum:["v2","v3","v4"]},tokenIn:h,tokenOut:h,path:{type:"array",minItems:2,maxItems:6,items:h},fees:{type:"array",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:h,currency1:h,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:h},additionalProperties:!1}},poolKey:{type:"object",properties:{currency0:h,currency1:h,fee:{type:"integer"},tickSpacing:{type:"integer"},hooks:h},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},amountIn:S(),amountOut:S(),minAmountOut:S(),maxAmountIn:S(),slippageBps:{type:"integer",minimum:0,maximum:9999}};async function ke(u,t,r,d=!1){J(t,Object.keys(ae));let a=t.version;if(!["v2","v3","v4"].includes(String(a)))throw new o("Provide version v2, v3 or v4.");let e=t.amountOut!==void 0;if(t.amountIn!==void 0===e)throw new o("Provide exactly one of amountIn or amountOut.");if(e&&t.minAmountOut!==void 0||!e&&t.maxAmountIn!==void 0)throw new o("Use maxAmountIn for exact output, minAmountOut for exact input.");let i=U(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",a==="v4"?128:160),n=D(t.tokenIn),s=D(t.tokenOut);if(n===s)throw new o("Swap requires different input and output currencies.");let w=u.clientFor(I),m=await w.getBlock(),z=G(t.slippageBps),g,f,q,k,x,p,R;if(a==="v4"){if(t.path!==void 0||t.fees!==void 0)throw new o("V4 uses poolKey or poolKeys; omit path and fees.");if(t.poolKey===void 0==(t.poolKeys===void 0))throw new o("Provide poolKey or poolKeys, not both.");if(t.poolKeys!==void 0){if(!Array.isArray(t.poolKeys)||t.poolKeys.length<1||t.poolKeys.length>5)throw new o("Provide 1 to 5 v4 poolKeys.");let c=t.poolKeys.map(P=>H(P));g=he(c,n,s,e),f=(await w.simulateContract({address:ne,abi:re,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?s:n,path:g,exactAmount:i}],account:r,gas:K,blockNumber:m.number})).result[0]}else{if(x=H(t.poolKey),![x.currency0,x.currency1].includes(n)||![x.currency0,x.currency1].includes(s))throw new o("PoolKey currencies differ from the requested swap.");f=(await w.simulateContract({address:ne,abi:re,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:x,zeroForOne:n===x.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:K,blockNumber:m.number})).result[0]}k="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||s===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(p=Array.isArray(t.path)?t.path.map(L):[n,s],p.length<2||p.length>6||p[0]!==n||p.at(-1)!==s||new Set(p).size!==p.length||p.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(a==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let c=await w.readContract({address:Y,abi:Z,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,p],blockNumber:m.number});f=e?c[0]:c.at(-1),k=e?"0x09":"0x08"}else{let c=t.fees;if(!Array.isArray(c)||c.length!==p.length-1||c.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer v3 fee in pips per path hop.");if(!Q(await w.readContract({address:te,abi:oe,functionName:"factory",blockNumber:m.number}),T[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");R=Ae(p,c,e),f=(await w.simulateContract({address:te,abi:oe,functionName:e?"quoteExactOutput":"quoteExactInput",args:[R,i],account:r,gas:K,blockNumber:m.number})).result[0],k=e?"0x01":"0x00"}}if(f<=0n)throw new o("No positive Uniswap quote is available.");let V=e?t.maxAmountIn:t.minAmountOut;if(!d&&V===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let l=V===void 0?e?(f*BigInt(1e4+z)+9999n)/10000n:f*BigInt(1e4-z)/10000n:U(V,e?"maxAmountIn":"minAmountOut",a==="v4"?128:160);if(l<=0n||(e?l<f:l>f))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let y=e?l:i;if(y>=1n<<160n||a==="v4"&&(y>=1n<<128n||l>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[se,ce]=await Promise.all([_(u,n,m.number),_(u,s,m.number)]),j={version:a,input:{token:se,amount:(e?f:i).toString()},output:{token:ce,amount:(e?i:f).toString()},[e?"maxAmountIn":"minAmountOut"]:l.toString(),blockNumber:m.number.toString(),expiresAt:(m.timestamp+60n).toString()};if(d)return{quote:j,summary:"Read-only on-chain quote. Repeat the same route with the returned bound in uniswap_swap; execution gets a fresh quote and preview."};let O=m.timestamp+300n,E=[],X="Native ETH input; no token approvals.";if(n!==v){let c=await w.readContract({address:n,abi:me,functionName:"allowance",args:[r,C],blockNumber:m.number});c!==y&&E.push(u.approval(n,C,y.toString(),I)),X=`${c===y?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${y} input base units to Permit2; exact router permit.`,E.push(u.unsignedTx({to:C,data:ee({abi:le,functionName:"approve",args:[n,$,y,Number(O)]}),value:"0",chainId:I,description:`Permit exactly ${y} input base units to Universal Router until ${O}.`}))}if(a==="v4"){let c=g?b(ye,[{exactCurrency:e?s:n,path:g,minHopPriceX36:[],amount:i,limit:l}]):b(xe,[{poolKey:x,zeroForOne:n===x.currency0,amount:i,limit:l,minHopPriceX36:0n,hookData:"0x"}]);q=b(ve,[g?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[c,b(ie,[n,y]),b(ie,[s,e?i:l])]])}else a==="v2"?q=b(we,[r,i,l,p,!0,[]]):q=b(be,[r,i,l,R,!0,[]]);let B=[q];return n===v&&e&&(k=`${k}04`,B.push(b(A("address,address,uint256"),[v,r,0n]))),E.push(u.unsignedTx({to:$,data:ee({abi:fe,functionName:"execute",args:[k,B,O]}),value:n===v?y.toString():"0",chainId:I,description:`Uniswap ${a} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${O}.`})),{...await W(u,E,r,`Swap through Universal Router 2.1.2. ${X} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:j}}function Ne(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:ae},execute:(r,d)=>ke(u,r,d,t)}))}}export{te as a,ne as b,fe as c,le as d,oe as e,re as f,ye as g,he as h,xe as i,be as j,we as k,Ae as l,ke as m,Ne as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as s}from"./
|
|
1
|
+
import{b as s}from"./ZXJ24B4L.js";import{a as o,c as t}from"./DJN3JAWB.js";import{getAddress as i}from"viem";var u=new Set(["priors_status",...s,...t.filter(r=>r.read).map(r=>r.name),"priors_ethos_status","priors_request_borrow","priors_request_repay","priors_request_stock","priors_request_backing","priors_pt_quote","priors_pt_position","priors_stock_quote","priors_savings_liquidity","priors_market_origin","priors_market_pins","priors_capabilities"]),p=new Set(["priors_sign_consent",...t.filter(r=>r.consentRoot).map(r=>r.name)]),d=new Set([...p,"priors_starter_line"]),R=new Set([...t.filter(r=>!r.read).map(r=>r.name),"priors_root_offer","priors_autopay_on","priors_autopay_off","priors_pt_buy","priors_pt_sell","priors_pt_redeem","priors_savings_force_withdraw","priors_stock_swap","priors_market_clear_bid_budget","priors_market_revoke_nft","priors_x_link"]);function S(r){let _=t.find(e=>e.name===r);return _?[o[_.contract],..._.approval==="bid"?[o.bidSpender]:[]]:r==="priors_root_offer"?[o.pool]:r==="priors_autopay_on"||r==="priors_autopay_off"?[o.autopay]:r==="priors_savings_force_withdraw"?[o.savings]:r==="priors_stock_swap"?[i("0xCaf681a66D020601342297493863E78C959E5cb2"),i("0x7Cd4E04E433E69e588728c86A3832753B5F846d4")]:r==="priors_pt_buy"||r==="priors_pt_sell"||r==="priors_pt_redeem"?[i("0x888888888889758F76e7103c6CbF23ABbF58F946")]:r==="priors_market_clear_bid_budget"?[o.bidSpender]:r==="priors_market_revoke_nft"?[o.registry,"0x0000000000000000000000000000000000000000"]:r==="priors_x_link"?[o.registry]:[]}export{u as a,p as b,d as c,R as d,S as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as g,d as H,m as M}from"./
|
|
1
|
+
import{c as g,d as H,m as M}from"./LKXO2BQS.js";import{f as k,g as C}from"./PIIHOXWF.js";import{d,e as s,y as _}from"./2THSW4QN.js";import{g as h}from"./NWNYJ26T.js";import{a as w}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{decodeFunctionData as b,encodeFunctionData as B,erc20Abi as $,getAddress as O}from"viem";function K(u){return{tools:[{name:"uniswap_swap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["routes"],properties:{routes:{type:"array",minItems:1,maxItems:20,items:{type:"object",description:"Complete uniswap_swap arguments, including an absolute minAmountOut or maxAmountIn."}}}},async execute(n,v){if(C(n,["routes"]),!Array.isArray(n.routes)||n.routes.length<1||n.routes.length>20)throw new t("Provide 1 to 20 explicit bounded Uniswap routes.");let c=new Map,i="0x",A=0n,a,m=[],y=new Set;for(let e of n.routes){if(!e||typeof e!="object"||Array.isArray(e))throw new t("Each route must contain uniswap_swap arguments.");let I=await M(u,e,v,!1);if(!("txs"in I))throw new t("Route did not build swap transactions.");let E=I.txs;for(let r of E.slice(0,-1))if(h(r.to,d)){let[o,D,N,S]=b({abi:H,data:r.data}).args;if(D!==s)throw new t("Unexpected route approval spender.");let T=o.toLowerCase(),p=c.get(T),U=(p?.amount??0n)+N;if(U>=1n<<160n)throw new t("Combined input approvals exceed uint160.");c.set(T,{token:o,amount:U,expiration:p&&p.expiration<BigInt(S)?p.expiration:BigInt(S)})}else{let o=b({abi:$,data:r.data});if(o.functionName!=="approve"||!h(o.args[0],d))throw new t("Unexpected route prerequisite.")}let f=E.at(-1);if(f.to!==s)throw new t("Route does not use the pinned Universal Router.");A+=BigInt(f.value);let[j,x,P]=b({abi:g,data:f.data}).args,R=j.slice(2).match(/../g)??[];if(R.length!==x.length)throw new t("Unexpected route command/parameter count.");R.forEach((r,o)=>{r==="04"?y.add(x[o]):(i=`${i}${r}`,m.push(x[o]))}),a=a===void 0||P<a?P:a}for(let e of y)i=`${i}04`,m.push(e);let l=[];for(let e of c.values())l.push(u.approval(O(e.token),d,e.amount.toString(),w),_(e.token,s,e.amount.toString(),e.expiration.toString()));return l.push(u.unsignedTx({to:s,data:B({abi:g,functionName:"execute",args:[i,m,a]}),value:A.toString(),chainId:w,description:`Atomically execute ${n.routes.length} caller-selected v2/v3/v4 routes, preserving each route's trade bound.`})),k(u,l,v,"Explicit mixed-version/split routes; every route must meet its own bound. No automatic best-route search or allow-revert branch. The wallet must fund each independently previewed route.")}}]}}export{K as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as k}from"./
|
|
1
|
+
import{n as k}from"./BOVMED7R.js";import{a as y}from"./U4JGEMKT.js";import{b as T}from"./43LI5NKJ.js";import{b as R}from"./66F5ZH34.js";import{c as _,d as I,g as v,i as $,n as V}from"./NWNYJ26T.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as D,erc20Abi as O,getAddress as C,parseAbi as S}from"viem";var N=C("0x0000000000bbf5c5fd284e657f01bd000933c96d"),b=C("0x0a0d53b6684c7b32b4cbef5fe8483bfcc8406742"),U=C("0x00700052c0608F670705380a4900e0a8080010CC"),x=S(["function getCollectedFees(address partner,address token) view returns (uint256)","function withdrawAllFees(address token,address recipient) returns (uint256 amount)","function getBalance(address token,address partner) view returns (uint256)","function withdrawAllERC20(address token,address recipient) returns (bool)","function withdrawNative(uint256 amount,address owner,address receiver)"]),H=(1n<<256n)-1n,P={type:"string",enum:["market","delta"]};function p(t){return $(t,"Provide a token or wallet address.",I)}function A(t){if(t!=="market"&&t!=="delta")throw new o("Choose market or delta fees.");return t}function B(t){return V(t,"Amount must be positive and within uint256.",{notString:"Amount must be a decimal base-unit string.",positive:!0}).toString()}function E(t,m,d){if(d=p(d),t==="velora_unwrap_deth"){for(let e of Object.keys(m))if(e!=="amount")throw new o(`Unsupported ${t} argument: ${e}.`);let a=B(m.amount);return{tx:T({to:b,chainId:u,value:"0",data:D({abi:x,functionName:"withdrawNative",args:[BigInt(a),d,d]}),description:`Unwrap ${a} dETH base units into the same amount of native ETH for ${d} on chain ${u}.`}),inputs:[{token:b,amount:a}]}}if(t!=="velora_claim_fees")throw new o("Unknown Velora claim action.");for(let a of Object.keys(m))if(!["token","kind"].includes(a))throw new o(`Unsupported ${t} argument: ${a}.`);let f=p(m.token);if(k(f))throw new o("Velora fee claims require an ERC-20 token address.");let c=A(m.kind);return{tx:T({to:c==="delta"?N:U,chainId:u,value:"0",data:D({abi:x,functionName:c==="delta"?"withdrawAllFees":"withdrawAllERC20",args:[f,d]}),description:`Claim the full accrued ${c} fee balance of ${f} to ${d} on chain ${u}. Receipt amount can change before mining; no minimum is encoded.`}),inputs:[]}}function Q(t,m,d,f){let{tx:c}=E(m,d,f),a=t[0];if(t.length!==1||!a||a.chainId!==c.chainId||!v(a.to,c.to)||!v(a.data,c.data)||a.value!==c.value)throw new o("Velora claim calldata, recipient, amount or destination differs from the request.")}function X(t){let m=async()=>{let e=t.clientFor(u);if(await e.getChainId()!==u)throw new o("Velora requires an RPC on chain 4663.");return e};async function d(e){if(e===b)return{address:e,symbol:"dETH",decimals:18,chainId:u};let n=await m(),[s,i]=await Promise.all([y(n,u,e,"symbol"),y(n,u,e,"decimals")]);if(typeof s!="string"||!s.trim()||!Number.isInteger(i)||i<0||i>255)throw new o("Velora fee token metadata is unavailable.");return{address:e,symbol:s,decimals:i,chainId:u}}async function f(e,n){let s=A(e.kind),i=p(e.token);if(k(i))throw new o("Velora fee claims require an ERC-20 token address.");let r=await(await m()).readContract({address:s==="delta"?N:U,abi:x,functionName:s==="delta"?"getCollectedFees":"getBalance",args:s==="delta"?[n,i]:[i,n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Velora fee balance is unavailable.");return r}function c(e,n,s,i){return{name:e,inputSchema:{type:"object",additionalProperties:!1,properties:n,required:s},execute:async(w,r)=>{try{r=p(r);for(let l of Object.keys(w))if(!Object.hasOwn(n,l))throw new o(`Unsupported ${e} argument: ${l}.`);return await i(w,r)}catch(l){throw new o(t.plainError(l))}}}}let a={token:_,kind:P};return[c("velora_fee_balance",a,["token","kind"],async(e,n)=>({kind:A(e.kind),token:await d(p(e.token)),amount:(await f(e,n)).toString()})),c("velora_claim_fees",a,["token","kind"],async(e,n)=>{let{tx:s}=E("velora_claim_fees",e,n),i=await f(e,n);if(i===0n)throw new o("No accrued Velora fees for this wallet and token.");let w=await d(p(e.token)),r=[s],l=await t.preview(r,n);return{txs:r,preview:l,estimatedReceipt:{token:w,amount:i.toString()},summary:`${s.description} ${l.summary}`}}),c("velora_unwrap_deth",{amount:R("Positive amount of wallet-held dETH in base units (18 decimals).")},["amount"],async(e,n)=>{let{tx:s,inputs:i}=E("velora_unwrap_deth",e,n),r=await(await m()).readContract({address:b,abi:O,functionName:"balanceOf",args:[n]});if(typeof r!="bigint"||r<0n||r>H)throw new o("Wallet dETH balance is unavailable.");if(r<BigInt(i[0].amount))throw new o("Insufficient wallet-held dETH. An active native Delta order must first settle, expire or cancel.");let l=[s],g=await t.preview(l,n);if(g.changes.filter(h=>h.token.chainId===u&&k(h.token.address)).reduce((h,F)=>h+BigInt(F.amount),0n)<BigInt(i[0].amount))throw new o("Velora dETH preview does not return the requested native ETH amount.");return{txs:l,preview:g,summary:`${s.description} ${g.summary}`}})]}export{N as a,b,U as c,x as d,E as e,Q as f,X as g};
|