@oakagentkit/core 0.2.1 → 0.2.2
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/addresses.d.ts +93 -0
- package/build/dist/api/addresses.js +1 -1
- package/build/dist/api/chain.js +1 -1
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/identity-link.js +1 -1
- package/build/dist/api/metadata.js +1 -1
- package/build/dist/api/modules/beefy/boosts.js +1 -1
- package/build/dist/api/modules/beefy/clm.js +1 -1
- package/build/dist/api/modules/beefy/guard.js +1 -1
- package/build/dist/api/modules/beefy/index.js +1 -1
- package/build/dist/api/modules/beefy/liquidity.js +1 -1
- package/build/dist/api/modules/beefy/management.js +1 -1
- package/build/dist/api/modules/beefy/vaults.js +1 -1
- package/build/dist/api/modules/clanker/extensions.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/clanker/manage.js +1 -1
- package/build/dist/api/modules/clanker/pool-config.js +1 -1
- package/build/dist/api/modules/clanker/protocol.js +1 -1
- package/build/dist/api/modules/clanker/state.js +1 -1
- package/build/dist/api/modules/erc8004/common.js +1 -1
- package/build/dist/api/modules/erc8004/domain.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/erc8004/management.js +1 -1
- package/build/dist/api/modules/erc8004/reputation.js +1 -1
- package/build/dist/api/modules/erc8004/services.js +1 -1
- package/build/dist/api/modules/erc8004/validation.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/backoff.d.ts +6 -0
- package/build/dist/api/modules/heyresearch/backoff.js +1 -0
- package/build/dist/api/modules/heyresearch/builder-feed.d.ts +62 -0
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -0
- package/build/dist/api/modules/heyresearch/index.d.ts +3 -0
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/proof-reads.d.ts +7 -0
- package/build/dist/api/modules/heyresearch/proof-reads.js +1 -0
- package/build/dist/api/modules/heyresearch/public-reads.d.ts +1 -0
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/heyresearch/scan.d.ts +31 -0
- package/build/dist/api/modules/heyresearch/scan.js +1 -0
- package/build/dist/api/modules/heyresearch/status-labels.d.ts +5 -0
- package/build/dist/api/modules/heyresearch/status-labels.js +1 -0
- package/build/dist/api/modules/heyresearch/token-facts.d.ts +123 -0
- package/build/dist/api/modules/heyresearch/token-facts.js +1 -0
- package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
- package/build/dist/api/modules/hoodag/index.js +1 -1
- package/build/dist/api/modules/hoodag/management.js +1 -1
- package/build/dist/api/modules/hoodag/public-reads.js +1 -1
- package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/buyback.js +1 -1
- package/build/dist/api/modules/hoodlock/commerce.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.d.ts +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.d.ts +63 -0
- package/build/dist/api/modules/hookr/agent-gate.js +1 -0
- 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.d.ts +1 -0
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.d.ts +119 -0
- package/build/dist/api/modules/hookr/launch-options.js +1 -0
- package/build/dist/api/modules/hookr/launch-profile.d.ts +5 -0
- package/build/dist/api/modules/hookr/launch-profile.js +1 -0
- package/build/dist/api/modules/hookr/launch-receipt.d.ts +144 -0
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -0
- package/build/dist/api/modules/hookr/launch.d.ts +58 -0
- package/build/dist/api/modules/hookr/launch.js +1 -0
- package/build/dist/api/modules/hookr/liquidity.d.ts +48 -0
- package/build/dist/api/modules/hookr/liquidity.js +1 -0
- package/build/dist/api/modules/hookr/lp-positions.d.ts +2 -0
- package/build/dist/api/modules/hookr/lp-positions.js +1 -0
- package/build/dist/api/modules/hookr/lp-reads.d.ts +52 -0
- package/build/dist/api/modules/hookr/lp-reads.js +1 -0
- package/build/dist/api/modules/hookr/lp-receipt.d.ts +136 -0
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -0
- package/build/dist/api/modules/hookr/lp-state.d.ts +33 -0
- package/build/dist/api/modules/hookr/lp-state.js +1 -0
- package/build/dist/api/modules/hookr/pins.d.ts +43 -0
- package/build/dist/api/modules/hookr/pins.js +1 -0
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.d.ts +59 -0
- package/build/dist/api/modules/hookr/read-utils.js +1 -0
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/hookr/revenue.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
- package/build/dist/api/modules/lighter/index.js +1 -1
- package/build/dist/api/modules/longbow/administration.js +1 -1
- package/build/dist/api/modules/longbow/analytics.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/longbow/nft.js +1 -1
- package/build/dist/api/modules/longbow/rebates.js +1 -1
- package/build/dist/api/modules/longbow/staking.js +1 -1
- package/build/dist/api/modules/meridian/index.js +1 -1
- package/build/dist/api/modules/meridian/markets.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/merkl/protocol.js +1 -1
- package/build/dist/api/modules/morpho/allocator.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-management.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/morpho/vault-v2.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/desk-read.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/netnet/staking.js +1 -1
- package/build/dist/api/modules/orbio/index.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.js +1 -1
- package/build/dist/api/modules/pons/prices.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/swap-terms.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/features.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/market.js +1 -1
- package/build/dist/api/modules/priors/pt.js +1 -1
- package/build/dist/api/modules/priors/savings-exit.js +1 -1
- package/build/dist/api/modules/priors/starter-line.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/relay/bootstrap.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/relay/reads.js +1 -1
- package/build/dist/api/modules/spark/actions.js +1 -1
- package/build/dist/api/modules/spark/details.js +1 -1
- package/build/dist/api/modules/spark/index.js +1 -1
- package/build/dist/api/modules/spark/management.js +1 -1
- package/build/dist/api/modules/steakhouse/analytics.js +1 -1
- package/build/dist/api/modules/steakhouse/erc4626.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/discovery.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/delta-reads.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.d.ts +5 -0
- package/build/dist/api/modules/wormhole/index.js +1 -0
- package/build/dist/api/modules/wormhole/license.d.ts +2 -0
- package/build/dist/api/modules/wormhole/license.js +1 -0
- package/build/dist/api/modules/wormhole/quotetext.d.ts +36 -0
- package/build/dist/api/modules/wormhole/quotetext.js +1 -0
- package/build/dist/api/modules/wormhole/scan-text.d.ts +40 -0
- package/build/dist/api/modules/wormhole/scan-text.js +1 -0
- package/build/dist/api/modules/wormhole/token-check.d.ts +54 -0
- package/build/dist/api/modules/wormhole/token-check.js +1 -0
- package/build/dist/api/positions.js +1 -1
- package/build/dist/api/pricenote.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/pricing.js +1 -1
- package/build/dist/api/rpc.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/signing.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 +7 -0
- package/build/dist/chunks/{QHHZDXRG.js → 2FSX7MMR.js} +1 -1
- package/build/dist/chunks/{RTBOMWCB.js → 2LM7U4S7.js} +1 -1
- package/build/dist/chunks/{BBVKWG65.js → 2MSQ6JII.js} +1 -1
- package/build/dist/chunks/{T6MTTMLQ.js → 2UU5TBBB.js} +1 -1
- package/build/dist/chunks/{OW7GOYKA.js → 2W46IRX6.js} +1 -1
- package/build/dist/chunks/{6LLOTPH2.js → 3EFV4FQF.js} +1 -1
- package/build/dist/chunks/{IAXKPME3.js → 3NDVXEBR.js} +1 -1
- package/build/dist/chunks/3SC5UI35.js +1 -0
- package/build/dist/chunks/{TCS3ICNE.js → 3WBDHUV2.js} +1 -1
- package/build/dist/chunks/{UPPYXY74.js → 4AKIXLXH.js} +1 -1
- package/build/dist/chunks/{RRSODRGT.js → 4GAWMCQC.js} +1 -1
- package/build/dist/chunks/{ZGXNTWYG.js → 4GHVIBL5.js} +1 -1
- package/build/dist/chunks/{NHCRJC5X.js → 4KQZTPMS.js} +1 -1
- package/build/dist/chunks/{N77ANGBT.js → 4X2JOQ2L.js} +1 -1
- package/build/dist/chunks/{ZPM2MFXZ.js → 52DHGSG4.js} +1 -1
- package/build/dist/chunks/{2CS3M32D.js → 57HAXNQV.js} +1 -1
- package/build/dist/chunks/5IIR3GIN.js +1 -0
- package/build/dist/chunks/{CAU44UWP.js → 5O5ZE3ZV.js} +1 -1
- package/build/dist/chunks/5OEHZJ6X.js +1 -0
- package/build/dist/chunks/{CBA776XQ.js → 5VHH5PW3.js} +1 -1
- package/build/dist/chunks/{NCEJZWGX.js → 66VBACC2.js} +1 -1
- package/build/dist/chunks/{6HV5BR7P.js → 6AWTAE4Q.js} +1 -1
- package/build/dist/chunks/{JRVTSGAT.js → 6UPPUHCL.js} +1 -1
- package/build/dist/chunks/{MEMVFR7Z.js → 6ZYLNB2B.js} +1 -1
- package/build/dist/chunks/7XLEYOZH.js +1 -0
- package/build/dist/chunks/{Q4RZQCDS.js → AAGDMH54.js} +1 -1
- package/build/dist/chunks/ACN2BFMA.js +1 -0
- package/build/dist/chunks/{L24EOVLT.js → AJP5LDM2.js} +1 -1
- package/build/dist/chunks/{F2YH72GF.js → ALK6NKFP.js} +1 -1
- package/build/dist/chunks/{EC5W3UZD.js → AMICUXS6.js} +1 -1
- package/build/dist/chunks/{5LQBHXFA.js → BX7XQANB.js} +1 -1
- package/build/dist/chunks/{QNPEKNWM.js → CEIPDEXZ.js} +1 -1
- package/build/dist/chunks/{HFQS5344.js → CQCVFRQ5.js} +1 -1
- package/build/dist/chunks/{OJLMF5AR.js → CUNQ5RG5.js} +1 -1
- package/build/dist/chunks/{IWALIX7Q.js → CXLEQCP3.js} +1 -1
- package/build/dist/chunks/{VJ3W2V3B.js → CY75R4FK.js} +1 -1
- package/build/dist/chunks/{65QFM4JU.js → DCTUYDWF.js} +1 -1
- package/build/dist/chunks/DHOBTJRD.js +1 -0
- package/build/dist/chunks/{N37ZLNCT.js → DRWWPBOQ.js} +1 -1
- package/build/dist/chunks/{7B5UH2VS.js → DZGEQBO7.js} +1 -1
- package/build/dist/chunks/{RFJCG4NA.js → E7R3J4H7.js} +1 -1
- package/build/dist/chunks/{7T4BYFD4.js → EGUMOD3A.js} +1 -1
- package/build/dist/chunks/ELZNT5Q3.js +1 -0
- package/build/dist/chunks/EPZ7SWKM.js +1 -0
- package/build/dist/chunks/{IUETZH6I.js → EXRKBBX2.js} +1 -1
- package/build/dist/chunks/{K7HIKXNT.js → FBSUTF3B.js} +1 -1
- package/build/dist/chunks/{LFN3OODW.js → FUXT7GRK.js} +1 -1
- package/build/dist/chunks/G6HCV67X.js +1 -0
- package/build/dist/chunks/{HNMOB76J.js → GGUEKSR4.js} +1 -1
- package/build/dist/chunks/{GZ5TW3WB.js → GIV5JMTE.js} +1 -1
- package/build/dist/chunks/{OMTCWXQR.js → GJY3P6OG.js} +1 -1
- package/build/dist/chunks/HOEQVPY7.js +1 -0
- package/build/dist/chunks/{3R3C3CU5.js → IBXYIN7Q.js} +1 -1
- package/build/dist/chunks/{SXX52Y27.js → IUE6RASI.js} +1 -1
- package/build/dist/chunks/J2XAEVKC.js +1 -0
- package/build/dist/chunks/{AYM5L6L7.js → J3GFCBZZ.js} +1 -1
- package/build/dist/chunks/JNZZLA2A.js +1 -0
- package/build/dist/chunks/{T3MGNKA6.js → JPOYTTTW.js} +1 -1
- package/build/dist/chunks/{AZGMF26W.js → JST5JGAP.js} +1 -1
- package/build/dist/chunks/{BG4S6MSN.js → JVI26KQO.js} +1 -1
- package/build/dist/chunks/{FBQWTWPT.js → JWCOXLYA.js} +1 -1
- package/build/dist/chunks/{G7UKNO2I.js → KHJFXJBU.js} +1 -1
- package/build/dist/chunks/{HQVC6X3T.js → KSZMMNXK.js} +1 -1
- package/build/dist/chunks/{O7PQDUVT.js → L3ZM77SJ.js} +1 -1
- package/build/dist/chunks/{QRUC7EFE.js → L62M7LOB.js} +1 -1
- package/build/dist/chunks/{22S4SFD5.js → L7YBCMZU.js} +1 -1
- package/build/dist/chunks/{H6ED3RHF.js → LMVB3B6T.js} +1 -1
- package/build/dist/chunks/{UIIJWIR6.js → LQGPMOD2.js} +1 -1
- package/build/dist/chunks/{WLACEU2Y.js → LQUDJCAR.js} +1 -1
- package/build/dist/chunks/LT5P6PZW.js +1 -0
- package/build/dist/chunks/M7U3A4EH.js +3 -0
- package/build/dist/chunks/MFNP4KOK.js +1 -0
- package/build/dist/chunks/MKQVS3IO.js +1 -0
- package/build/dist/chunks/{7US6PD56.js → MLPWQTBS.js} +1 -1
- package/build/dist/chunks/{5XFXH2JT.js → NATG6YA6.js} +1 -1
- package/build/dist/chunks/{O47JXRXN.js → NAYRD43N.js} +1 -1
- package/build/dist/chunks/{6L6DSMCU.js → NMYGNJIJ.js} +1 -1
- package/build/dist/chunks/NRBIXV7V.js +1 -0
- package/build/dist/chunks/{D6VP3N27.js → NSOEDRBU.js} +1 -1
- package/build/dist/chunks/{HL2MLC3O.js → NU4K3TEZ.js} +1 -1
- package/build/dist/chunks/NWSPC3NH.js +1 -0
- package/build/dist/chunks/{I7NUTSSX.js → OE3CLZHR.js} +1 -1
- package/build/dist/chunks/{2NA6JLEC.js → OQVZVR2S.js} +1 -1
- package/build/dist/chunks/{D3OWLDVB.js → OVK4EEOD.js} +1 -1
- package/build/dist/chunks/{Q2VMH2LB.js → PARWLWXW.js} +1 -1
- package/build/dist/chunks/{DHXVYHT4.js → PTAWEHKB.js} +1 -1
- package/build/dist/chunks/{DVKDWXEJ.js → PWBL4WKB.js} +1 -1
- package/build/dist/chunks/{PR2QED25.js → PZHR4ITH.js} +1 -1
- package/build/dist/chunks/{JG24LNUI.js → Q356HHCL.js} +1 -1
- package/build/dist/chunks/{OG5HRQU4.js → QRDDKA4I.js} +1 -1
- package/build/dist/chunks/{YR3QJVJQ.js → QXNPPCOU.js} +1 -1
- package/build/dist/chunks/{6NR7SVRO.js → QYYFRAWY.js} +1 -1
- package/build/dist/chunks/{QR7ALOR4.js → R53P2K3C.js} +1 -1
- package/build/dist/chunks/{5RKWSFD2.js → R7FXNZRM.js} +1 -1
- package/build/dist/chunks/{CCEWSOBT.js → R7QPJQP6.js} +1 -1
- package/build/dist/chunks/{SLSPWXR6.js → R7SXC74O.js} +1 -1
- package/build/dist/chunks/{IHGVCPVA.js → RAKUK5VR.js} +1 -1
- package/build/dist/chunks/{7LDAJ6BM.js → S3HNPTXA.js} +1 -1
- package/build/dist/chunks/SI6GCOAS.js +1 -0
- package/build/dist/chunks/{WIDTTGSH.js → SJPM5ST4.js} +1 -1
- package/build/dist/chunks/{QYHJWU5T.js → SJPYXNOK.js} +1 -1
- package/build/dist/chunks/{VY3P34PY.js → SKQGLGES.js} +1 -1
- package/build/dist/chunks/{ZT67OMLW.js → SOYQOE5P.js} +1 -1
- package/build/dist/chunks/{GUBB5P6V.js → SQZRVIVF.js} +1 -1
- package/build/dist/chunks/{E24S22BZ.js → SSTROLQM.js} +1 -1
- package/build/dist/chunks/{DGGOO4RN.js → SXAIXD56.js} +1 -1
- package/build/dist/chunks/{D4WURN33.js → SXX3VTBP.js} +1 -1
- package/build/dist/chunks/{UXG67LH3.js → TCPPYBGQ.js} +1 -1
- package/build/dist/chunks/TFVWAYHY.js +1 -0
- package/build/dist/chunks/{67TJOOBI.js → TLJPVYRJ.js} +1 -1
- package/build/dist/chunks/{ULJ6E4HP.js → TMGWXDCZ.js} +1 -1
- package/build/dist/chunks/{NMFVXBTL.js → TNSKEHPC.js} +1 -1
- package/build/dist/chunks/{C2FEXLMA.js → TQL7UDFL.js} +1 -1
- package/build/dist/chunks/{QXFJZGVB.js → TWCSCRFS.js} +1 -1
- package/build/dist/chunks/{2EDXKJ3B.js → TWSTOFN3.js} +1 -1
- package/build/dist/chunks/{X6G4BD35.js → U3F6DDML.js} +1 -1
- package/build/dist/chunks/{XGUKLFBU.js → UFS2RVEZ.js} +1 -1
- package/build/dist/chunks/{RM5W63LO.js → UNZRE3YU.js} +1 -1
- package/build/dist/chunks/{GECX5U3F.js → USSOVTD5.js} +1 -1
- package/build/dist/chunks/V2OOOV6B.js +1 -0
- package/build/dist/chunks/{IRWEY7TQ.js → V5LTA42G.js} +1 -1
- package/build/dist/chunks/{TAI63P6E.js → VC2RCYQE.js} +1 -1
- package/build/dist/chunks/{3ZVGHC6S.js → VFSRRDLY.js} +1 -1
- package/build/dist/chunks/{XW7RH7YY.js → VVEUJ36E.js} +1 -1
- package/build/dist/chunks/{5EHQM6DM.js → WQ6H62DM.js} +1 -1
- package/build/dist/chunks/{TDN3C4IG.js → WQQJ7UPJ.js} +1 -1
- package/build/dist/chunks/{F3TJCOVV.js → WTSMPDT5.js} +1 -1
- package/build/dist/chunks/{BYXBS45D.js → WVXW6VL3.js} +1 -1
- package/build/dist/chunks/WWFOYZT2.js +1 -0
- package/build/dist/chunks/WWNAGOCD.js +1 -0
- package/build/dist/chunks/X2NJSQUY.js +203 -0
- package/build/dist/chunks/{FKAA7VUR.js → XMA25DXR.js} +1 -1
- package/build/dist/chunks/{C3ZZSGSP.js → XQUPZ3GU.js} +1 -1
- package/build/dist/chunks/XQXLFF7Y.js +1 -0
- package/build/dist/chunks/XV2HQKND.js +1 -0
- package/build/dist/chunks/{QZM7CWZW.js → XVFLT275.js} +1 -1
- package/build/dist/chunks/{BV3AHLH5.js → XWEFKXKA.js} +1 -1
- package/build/dist/chunks/{BEPSWFJX.js → Y2KH6DCE.js} +1 -1
- package/build/dist/chunks/{NKY3DT34.js → YA5WWDEW.js} +1 -1
- package/build/dist/chunks/YHB55C5T.js +1 -0
- package/build/dist/chunks/YQUKU2LS.js +1 -0
- package/build/dist/chunks/{72AWP4BM.js → YZSTP2E6.js} +1 -1
- package/build/dist/chunks/{T3NPRRTY.js → Z7RL4NGX.js} +1 -1
- package/build/dist/chunks/{YMB553OJ.js → ZT47KN7A.js} +1 -1
- package/build/dist/chunks/{NUTHT4FE.js → ZUG6MG46.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/6SCCW74G.js +0 -1
- package/build/dist/chunks/DD7755AW.js +0 -1
- package/build/dist/chunks/EYYUWFUR.js +0 -1
- package/build/dist/chunks/JRO6WTK4.js +0 -1
- package/build/dist/chunks/MNFU7PO3.js +0 -1
- package/build/dist/chunks/N3GWFLG6.js +0 -1
- package/build/dist/chunks/UMK564HS.js +0 -1
- package/build/dist/chunks/XPFVT2EA.js +0 -1
- package/build/dist/chunks/XUJSQV52.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as E}from"./YHB55C5T.js";import{b as q,c as _,d as O,e as R}from"./PWBL4WKB.js";import{a as N}from"./VVEUJ36E.js";import{a as I}from"./6UPPUHCL.js";import{c as M}from"./AMICUXS6.js";import{b as G}from"./AXYOJBX6.js";import{a as b}from"./6IM6A5VA.js";import{a as x}from"./RETS2ZEK.js";import{a as o,d as P,i as U,j as y}from"./G6HCV67X.js";import{a as r}from"./5YS5V2LK.js";import{encodeFunctionData as g,erc20Abi as k,parseAbi as L}from"viem";var i=U[o].vaults.steakhouse.address,j=(1n<<256n)-1n,l=L(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function A(e){if(typeof e!="bigint"||e<0n||e>j)throw new r("The vault returned an invalid base-unit amount.");return e}function T(e){if(typeof e!="string")throw new r("Amount must be an integer string in base units.");let c=x(e);if(c===0n)throw new r("Amount must be positive.");if(c>j)throw new r("Amount exceeds the uint256 range.");return c}function D(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new r("Unexpected Steakhouse argument.")}var W=e=>{async function c(t){try{return await t()}catch(s){throw new r(e.plainError(s))}}async function h(){let t=e.clientFor(o);if(await t.getChainId()!==o)throw new r("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new r("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:k,functionName:"decimals"}),t.readContract({address:i,abi:k,functionName:"decimals"})]);if(a!==P||!Number.isInteger(n)||n<0||n>255)throw new r("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:o},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:o}}}async function w(t,s){return A(await t.readContract({address:i,abi:k,functionName:"balanceOf",args:[s]}))}async function C(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new r("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[_(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),E(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{D(t,!1);let{client:s,asset:a,shares:n}=await h(),u=A(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:$(!1),execute:async(t,s)=>c(async()=>{D(t,!0);let a=T(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),o),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:o,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return C(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...$(!0),properties:{...$(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$"},minAmountOut:{type:"string",pattern:"^[0-9]+$"}}},execute:async(t,s)=>c(async()=>{D(t,!0,!0);let a=t.amount==="max"?null:T(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new r("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new r("force must be a boolean.");if(t.force===!0){if(a!==null)throw new r("Force exit currently requires amount max.");let p=M(t.maxPenaltyAssets),F=T(t.minAmountOut),v=await q(e,n,i,s,d,p),S=await e.preview([v.tx],s);return R(S.changes,i,d,F),{txs:[v.tx],preview:S,summary:`${O(v.plan)} ${S.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new r("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:o,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=A(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new r("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:o,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return C([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=A(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${o}:${i.toLowerCase()}`,chainId:o,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${o}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function $(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`USDG base-unit integer string (6 decimals)${e?", or max to redeem every share":""}.`}}}}var te=e=>G("steakhouse",[W(e)]);export{W as a,te as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;function l(r,e){let t=r?.trim()??"",n=Number.NaN;return/^\d{1,9}$/.test(t)?n=Number(t)*1e3:u.test(t)&&(n=Date.parse(t)-e),Number.isFinite(n)&&n>0?Math.min(n,36e5):6e4}function c(r=()=>Date.now()){let e=0,t=!1;return{blocked:()=>r()<e,limited:()=>r()<e&&t,defer(n,i=!1){let o=r(),a=o+l(n,o);(a>e||a===e&&i)&&(t=i),e=Math.max(e,a)}}}export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Ce,d as Me,e as we,f as ie,i as be,j as Ne}from"./MEMVFR7Z.js";import{b as ne,o as ge}from"./CAU44UWP.js";import{a as O,b as pe}from"./6IM6A5VA.js";import{a as Te}from"./EG6M6SSO.js";import{a as F,c as Ue}from"./RETS2ZEK.js";import{a as k,i as _}from"./XPFVT2EA.js";import{a as c,b as te,d as U}from"./5YS5V2LK.js";import{decodeFunctionResult as he,encodeFunctionData as R,getAddress as l,parseAbi as Z,zeroAddress as C}from"viem";var re=-887272,se=887272,z=(1n<<128n)-1n,Fe="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",ze="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Ge="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,je=5,Ke=1800n,f=Object.freeze({factory:l(_[4663].uniswap.v3_factory.address),positionManager:l(_[4663].uniswap.v3_position_manager.address),swapRouter02:l(_[4663].uniswap.swap_router02.address),permit2:l(_[4663].uniswap.permit2.address),weth:l(_[4663].uniswap.WETH.address),usdg:l(_[4663].uniswap.USDG.address),ethUsdgPool:l(_[4663].oracle.ethUsdgPool.address)}),xe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),yt=Object.freeze([{fee:100,tickSpacing:1,address:l("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:f.weth,token1:f.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:l("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:f.weth,token1:f.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:l("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:f.weth,token1:f.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:l("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:f.weth,token1:f.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),x=Z(["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)"]),Q=Z(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),ke=Z(["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)"]),Qe=Z(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),ye=Z(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),Ye="0xd0e30db0";function Ze(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===C||e===Fe||e==="eth"||e==="native"}function E(t,e){if(Ze(t))throw new c(`Uniswap v3 requires wrapped ERC-20 WETH (${f.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new c(`${e} must be a valid 20-byte hex address.`);return O(t),l(t)}function Je(t,e,n){let a=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new c("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(a)||!Number.isInteger(o))throw new c("Uniswap v3 tickLower and tickUpper must be integers.");if(a<re||o>se||a>se||o<re)throw new c(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(a>=o)throw new c("Uniswap v3 tickLower must be strictly less than tickUpper.");if(a%i!==0||o%i!==0)throw new c(`Uniswap v3 tickLower (${a}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:a,tickUpper:o,tickSpacing:i}}function et(t,e){let n=t.trim(),a=n.startsWith("-"),o=a||n.startsWith("+")?n.slice(1):n,i=Ue(F(o).toString(),e);return a&&i!=="0"?`-${i}`:i}function tt(t){let e=typeof t=="string"?he({abi:x,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:l(String(e[1])),token0:l(String(e[2])),token1:l(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 $e(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?l(e).toLowerCase():void 0,a=f.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==a)continue;let r=Array.isArray(i.topics)?i.topics.map(u=>String(u).toLowerCase()):[],s=r[0];if(s===ze&&r.length>=4){let d=`0x${r[2].slice(-40)}`;if(!n||d===n){let m=BigInt(r[3]).toString();m!=="0"&&o.add(m)}}else if(s===Ge&&r.length>=2&&!n){let u=BigInt(r[1]).toString();u!=="0"&&o.add(u)}}return[...o]}function ht(t){let e=n=>typeof n=="bigint"?n:F(n);return R({abi:Qe,functionName:"exactInputSingle",args:[{tokenIn:l(t.tokenIn),tokenOut:l(t.tokenOut),fee:t.fee,recipient:l(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Le=1n<<96n;function Re(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 nt(t,e,n,a){if(a<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(a<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let s=(a<<96n)*(i-t)/i/t,u=a*(t-o)/Le;return{amount0:s,amount1:u}}return{amount0:0n,amount1:a*(i-o)/Le}}async function M(t,e,n,a){let o=l(e),i,r;if(n===k&&o===f.weth?(i=18,r="WETH"):n===k&&o===f.usdg&&(i=6,r="USDG"),i===void 0){let s=await t.readContract({address:o,abi:ye,functionName:"decimals"});i=Number(s)}if(r===void 0)try{let s=await t.readContract({address:o,abi:ye,functionName:"symbol"});if(typeof s!="string"||!s.trim())throw new c("Token symbol is unavailable.");r=Ne(s.trim(),o)}catch(s){throw new c(`Could not read token metadata. ${U(s)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new c("Token decimals are invalid.");if(a!=null){let s=Number(a);if(!Number.isInteger(s)||s!==i)throw new c(`Token ${o} on chain ${n} has ${i} decimals, not ${String(a)}.`)}return{address:o,symbol:r,decimals:i,chainId:n}}async function it(t){try{if(!t.getBlock)throw new c("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new c("Invalid block timestamp.");return e.timestamp}catch(e){throw new c(`Could not read the current block timestamp. ${U(e)}`)}}function J(t,e){if(typeof t=="bigint"){if(t<0n)throw new c(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new c(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return F(t);throw new c(`${e} must be a non-negative integer.`)}async function _e(t,e){let n=await it(t);if(e==null)return n+Ke;let a=J(e,"deadline");if(a<=n)throw new c(`Uniswap v3 deadline (${a.toString()}) has expired at timestamp ${n.toString()}.`);return a}function V(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new c(`${e} must be a non-negative integer string in base units.`);return F(t)}function Ee(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new c("Slippage must be an integer from 0 to 9999 bps.");return ge("0",e),e}function ae(t,e,n,a){let o=t===void 0?F(ge(e.toString(),n)):V(t,a);if(o<=1n)throw new c(`${a} must exceed 1 base unit; the simulated amount may be too small.`);return o}function X(t,e){return pe({to:f.positionManager,data:t,value:"0",chainId:k,description:e})}async function Y(t,e,n){try{if(!t.request)throw new c("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 c("Unexpected batch simulation response.");return o[0].calls.map((i,r)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new c(`Simulation call ${r+1} failed. ${U(i.error)}`);return i.returnData})}catch(a){throw new c(`Uniswap v3 simulation failed. ${U(a)}`)}}function ce(t,e){try{return he({abi:x,functionName:t,data:e})}catch{throw new c(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Be(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new c("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new c("sqrtPriceX96 must be a non-negative integer string.");return Me(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new c("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Ce(t.initialPrice,e,n)}async function De(t,e,n,a){let o=[];for(let i of Object.keys(xe).map(Number)){if(i===a)continue;let r=l(String(await t.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[e,n,i]})));if(r===C||BigInt(await t.readContract({address:r,abi:ke,functionName:"liquidity"}))===0n)continue;let u=await t.readContract({address:r,abi:ke,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${r}`,sqrtPriceX96:BigInt(u[0])})}return o}function G(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==k)throw new c(`Uniswap v3 is only supported on Robinhood Chain (${k}).`);if(e.version!==void 0&&e.version!=="v3")throw new c(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(k);return{...n,readContract:async a=>{try{return await n.readContract(a)}catch(o){throw new c(`Could not read Uniswap v3 ${a.functionName}. ${U(o)}`,{cause:o})}}}}async function ve(t,e,n){let a;try{a=await t.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[e]})}catch(r){throw new c(`Could not verify owner of Uniswap v3 position #${e}. ${U(r)}`)}let o=l(String(a)),i=l(n);if(o!==i)throw new c(`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:f.positionManager,abi:x,functionName:"positions",args:[e]});return tt(n)}function Ie(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(a=>`${et(a.amount,a.token.decimals)} ${a.token.symbol}`);return`${t} (${n.join(", ")})`}async function ot(t,e,n){O(n);let a=l(n),o=G(t,e),i=await _e(o,e.deadline),r=Ee(e),s=e.tokenId===void 0?void 0:J(e.tokenId,"tokenId"),u;if(s!==void 0){if(s<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,s,a),u=await de(o,s)}let d=u?.token0??E(e.token0,"token0"),m=u?.token1??E(e.token1,"token1");if(BigInt(d)>=BigInt(m))throw new c("Uniswap v3 requires distinct sorted token addresses.");let p=u?.fee??Number(e.fee??100),g=xe[p];if(!g)throw new c("Unsupported Uniswap v3 fee tier.");let y=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d,m,p]}))),h=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(y===C&&!h)throw new c("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(y!==C&&h)throw new c(`The Uniswap v3 pool already exists at ${y}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(s!==void 0&&h)throw new c("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new c("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||u))throw new c("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:S,tickUpper:N,tickSpacing:T}=Je(u?.tickLower??(e.fullRange===!0?Math.ceil(re/g)*g:e.tickLower),u?.tickUpper??(e.fullRange===!0?Math.floor(se/g)*g:e.tickUpper),g),w=await M(o,d,k,e.token0Decimals),b=await M(o,m,k,e.token1Decimals),P;if(y===C){let q=Be(e,w.decimals,b.decimals),L=be(q,await De(o,d,m,p),e.acceptPriceDeviation===!0,w.decimals,b.decimals);P={sqrtPriceX96:q,note:L}}let v=V(e.amount0Desired,"amount0Desired"),I=V(e.amount1Desired,"amount1Desired");if(v===0n&&I===0n)throw new c("Liquidity addition requires a positive desired amount.");let $=e.recipient===void 0?a:E(e.recipient,"recipient");if($!==a)throw new c("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==f.weth&&m!==f.weth)throw new c("Wrapping requires a positive WETH desired amount.");let H=await Promise.all([d,m].map(async q=>BigInt(await o.readContract({address:q,abi:ye,functionName:"allowance",args:[a,f.positionManager]})))),j=(q,L)=>{let fe=[];if(e.wrapNative===!0){let K=d===f.weth?q:L;K>0n&&fe.push(pe({to:f.weth,data:Ye,value:K.toString(),chainId:k,description:"Wrap ETH into WETH."}))}for(let[K,We]of[d,m].entries()){let me=K===0?q:L;me>0n&&H[K]<me&&fe.push(t.approval(We,f.positionManager,me.toString(),k))}return fe},W=s===void 0?"mint":"increaseLiquidity",B=(q,L)=>X(s===void 0?R({abi:x,functionName:"mint",args:[{token0:d,token1:m,fee:p,tickLower:S,tickUpper:N,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,recipient:$,deadline:i}]}):R({abi:x,functionName:"increaseLiquidity",args:[{tokenId:s,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,deadline:i}]}),`${W==="mint"?"Mint":"Increase"} Uniswap v3 ${w.symbol}/${b.symbol} liquidity.`),D=P&&X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[d,m,p,P.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${w.symbol}/${b.symbol} fee ${p} pool at ${ie(P.sqrtPriceX96,w.decimals,b.decimals)} ${b.symbol} per ${w.symbol}.`),Pe=D?[D]:[],Se=await Y(o,[...Pe,...j(v,I),B(0n,0n)],a),A=ce(W,Se[Se.length-1]),Ve=A[A.length-2],He=A[A.length-1];if(Ve>v||He>I)throw new c("Simulated liquidity spend exceeds the desired amounts.");let ee=[...Pe,...j(v,I)],ue=ae(e.amount0Min,A[A.length-2],r,"amount0Min"),le=ae(e.amount1Min,A[A.length-1],r,"amount1Min");if(ue>v||le>I)throw new c("Uniswap v3 minimum amount cannot exceed desired amount.");let Ae=B(ue,le);ee.push(Ae);for(let[q,L]of[d,m].entries())(q===0?v:I)>0n&&ee.push(t.approval(L,f.positionManager,"0",k));let qe=await t.preview(ee,a);return{txs:ee,preview:qe,summary:Ie(Ae.description,qe),details:{version:"v3",action:W,...s===void 0?{}:{tokenId:s.toString()},pool:y===C?null:y,fee:p,tickSpacing:T,tickLower:S,tickUpper:N,token0:w,token1:b,amount0Desired:v.toString(),amount1Desired:I.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:$,expectedAmount0:A[A.length-2].toString(),expectedAmount1:A[A.length-1].toString(),...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:ie(P.sqrtPriceX96,w.decimals,b.decimals),initialTick:we(P.sqrtPriceX96),priceCheck:P.note}:{}}}}async function rt(t,e,n){O(n);let a=l(n),o=G(t,e),i=E(e.token0,"token0"),r=E(e.token1,"token1");if(BigInt(i)>=BigInt(r))throw new c(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(r)?i:r}, token1=${BigInt(i)<BigInt(r)?r:i}; initialPrice is token1 per 1 token0 in that order.`);let s=Number(e.fee),u=xe[s];if(!u){let b=Number(await o.readContract({address:f.factory,abi:Q,functionName:"feeAmountTickSpacing",args:[s]}));if(!Number.isInteger(s)||b<=0)throw new c("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");u=b}let d=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[i,r,s]})));if(d!==C)throw new c(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let m=await M(o,i,k,e.token0Decimals),p=await M(o,r,k,e.token1Decimals),g=Be(e,m.decimals,p.decimals),y=be(g,await De(o,i,r,s),e.acceptPriceDeviation===!0,m.decimals,p.decimals),h=ie(g,m.decimals,p.decimals),S=[X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[i,r,s,g]}),`Create and initialize the Uniswap v3 ${m.symbol}/${p.symbol} fee ${s} pool at ${h} ${p.symbol} per ${m.symbol}.`)],N=await Y(o,S,a),T;try{T=l(String(he({abi:x,functionName:"createAndInitializePoolIfNecessary",data:N[0]})))}catch{throw new c("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(T===C)throw new c("Uniswap v3 pool creation simulation returned no pool.");let w=await t.preview(S,a);return{txs:S,preview:w,summary:`${S[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:T,fee:s,tickSpacing:u,token0:m,token1:p,sqrtPriceX96:g.toString(),initialPrice:h,initialTick:we(g),priceCheck:y}}}async function st(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=await M(o,r.token0,k),u=await M(o,r.token1,k),d=e.recipient===void 0?a:E(e.recipient,"recipient");if(d!==a)throw new c("Uniswap recipient must be the signing wallet.");let m=e.amount0Max===void 0?z:V(e.amount0Max,"amount0Max"),p=e.amount1Max===void 0?z:V(e.amount1Max,"amount1Max");if(m===0n&&p===0n||m>z||p>z)throw new c("Collect requires a positive amountMax within uint128.");let g=[X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:m,amount1Max:p}]}),`Collect Uniswap v3 fees from position #${i}.`)],y=ce("collect",(await Y(o,g,a))[0]),h=await t.preview(g,a);return{txs:g,preview:h,summary:Ie(g[0].description,h),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:s,token1:u,amount0Max:m.toString(),amount1Max:p.toString(),expectedAmount0:y[0].toString(),expectedAmount1:y[1].toString()}}}async function at(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=r.liquidity===0n&&e.burn===!0;if(r.liquidity<=0n&&!s)throw new c("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!s)throw new c('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let u=e.liquidity==="all"||e.liquidity===void 0?r.liquidity:V(e.liquidity,"liquidity");if(u<=0n&&!s)throw new c("Liquidity to remove must be positive.");if(u>r.liquidity)throw new c("Requested liquidity exceeds position liquidity.");let d=await _e(o,e.deadline),m=Ee(e),p=await M(o,r.token0,k),g=await M(o,r.token1,k),y=e.recipient===void 0?a:E(e.recipient,"recipient");if(y!==a)throw new c("Uniswap recipient must be the signing wallet.");let h=(B,D)=>X(R({abi:x,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:u,amount0Min:B,amount1Min:D,deadline:d}]}),`Decrease ${u} liquidity on Uniswap v3 position #${i}.`),S=s?[0n,0n]:ce("decreaseLiquidity",(await Y(o,[h(0n,0n)],a))[0]),N=(B,D)=>{if(B!==void 0&&V(B,D)!==0n)throw new c(`${D} must be zero for an empty position burn.`);return 0n},T=s?N(e.amount0Min,"amount0Min"):ae(e.amount0Min,S[0],m,"amount0Min"),w=s?N(e.amount1Min,"amount1Min"):ae(e.amount1Min,S[1],m,"amount1Min"),b=s?[]:[h(T,w)],P=b.length,v=!s||r.tokensOwed0>0n||r.tokensOwed1>0n;v&&b.push(X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:y,amount0Max:z,amount1Max:z}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let I=u===r.liquidity,$=I&&e.burn===!0;$&&b.push(X(R({abi:x,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let H=await Y(o,b,a),j=v?ce("collect",H[P]):[0n,0n],W=await t.preview(b,a);return{txs:b,preview:W,summary:Ie(`Remove Uniswap v3 liquidity from position #${i}${$?`; burns position #${i} at ${f.positionManager}`:""}`,W),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:y,token0:p,token1:g,liquidityRemoved:u.toString(),amount0Min:T.toString(),amount1Min:w.toString(),deadline:d.toString(),expectedAmount0:j[0].toString(),expectedAmount1:j[1].toString(),fullExit:I,burned:$}}}async function ct(t,e,n={}){let a=l(e),o=new Set;if(Array.isArray(n.tokenIds))for(let r of n.tokenIds){let s=J(r,"tokenId");s>0n&&o.add(s.toString())}if(Array.isArray(n.receipts))for(let r of n.receipts)for(let s of $e(r,a))o.add(s);let i=!1;try{let r=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"balanceOf",args:[a]})),s=r>64n?64n:r;for(let u=0n;u<s;u++){try{let d=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"tokenOfOwnerByIndex",args:[a,u]}));d>0n&&o.add(d.toString())}catch(d){if(!te(d,3,-32601,-32004))throw d;break}u+1n===r&&(i=!0)}r===0n&&(i=!0)}catch(r){if(!te(r,3,-32601,-32004))throw r}if(typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let r=n.toBlock??await t.getBlockNumber(),s=n.maxChunks??je,u=n.fromBlock??(r>oe*BigInt(s)?r-oe*BigInt(s)+1n:0n),d=r,m=0;for(;d>=u&&m<s;){let p=d>=oe-1n?d-(oe-1n):0n,g=p<u?u:p,y=await t.getLogs({address:f.positionManager,fromBlock:g,toBlock:d});for(let h of $e({logs:y},a))o.add(h);if(m+=1,g===0n||g<=u)break;d=g-1n}}catch(r){throw new c(`Could not discover Uniswap v3 positions from logs. ${U(r)}`)}else if(!i&&n.tokenIds===void 0&&n.receipts===void 0)throw new c("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(r=>BigInt(r)).sort((r,s)=>r<s?-1:r>s?1:0)}async function Oe(t,e,n={}){O(e);let a=l(e),o=G(t),i=await ct(o,a,n),r=[];for(let s of i){let u;try{let w=await o.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[s]});u=l(String(w))}catch(w){if(te(w,3))continue;throw new c(`Could not verify owner of position #${s}. ${U(w)}`)}if(u!==a)continue;let d;try{d=await de(o,s)}catch(w){throw new c(`Could not read position #${s}. ${U(w)}`)}if(d.liquidity===0n&&d.tokensOwed0===0n&&d.tokensOwed1===0n&&!n.includeEmpty)continue;let p=await M(o,d.token0,k),g=await M(o,d.token1,k),y=0n,h=0n;if(d.liquidity>0n)try{let w=await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d.token0,d.token1,d.fee]}),b=l(String(w));if(b===C)throw new c("Position pool was not found.");if(b!==C){let P=await o.readContract({address:b,abi:ke,functionName:"slot0"}),v=BigInt(P[0]);if(v<=0n)throw new c("Position pool has no initialized price.");let I=Re(d.tickLower),$=Re(d.tickUpper),H=nt(v,I,$,d.liquidity);y=H.amount0,h=H.amount1}}catch(w){throw new c(`Could not value Uniswap v3 position #${s}. ${U(w)}`)}let S=y+d.tokensOwed0,N=h+d.tokensOwed1,T=[{token:p,amount:S.toString()},{token:g,amount:N.toString()}];r.push({module:"uniswap",id:`uniswap:v3:${s.toString()}`,chainId:k,assets:T,description:`Uniswap v3 LP position #${s.toString()} (${p.symbol}/${g.symbol} fee ${d.fee} ticks [${d.tickLower}, ${d.tickUpper}] liquidity ${d.liquidity.toString()})`})}return r}async function dt(t,e,n){G(t,e);let a=e.wallet!==void 0?E(e.wallet,"wallet"):l(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,r=e.includeZero===!0||e.includeEmpty===!0,s=await Oe(t,a,{tokenIds:o,receipts:i,includeEmpty:r});return{positions:s,details:{version:"v3",wallet:a,count:s.length,positionManager:f.positionManager}}}function ut(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:(r,s)=>ot(t,r,s)},{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:(r,s)=>st(t,r,s)},{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:(r,s)=>at(t,r,s)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet from NFT receipts and Transfer logs.",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."}}},execute:(r,s)=>dt(t,r,s)},{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:(r,s)=>rt(t,r,s)}]}var Xe=t=>({tools:ut(t),positions:e=>Oe(t,e)}),xt=Xe,vt=Xe;export{re as a,se as b,z as c,f as d,xe as e,yt as f,x as g,Q as h,ke as i,Qe as j,Je as k,et as l,tt as m,$e as n,ht as o,Be as p,ot as q,rt as r,st as s,at as t,Oe as u,dt as v,ut as w,Xe as x,xt as y,vt as z};
|
|
1
|
+
import{c as Ce,d as Me,e as we,f as ie,i as be,j as Ne}from"./6ZYLNB2B.js";import{b as ne,o as ge}from"./5O5ZE3ZV.js";import{a as O,b as pe}from"./6IM6A5VA.js";import{a as Te}from"./EG6M6SSO.js";import{a as F,c as Ue}from"./RETS2ZEK.js";import{a as k,i as _}from"./G6HCV67X.js";import{a as c,b as te,d as U}from"./5YS5V2LK.js";import{decodeFunctionResult as he,encodeFunctionData as R,getAddress as l,parseAbi as Z,zeroAddress as C}from"viem";var re=-887272,se=887272,z=(1n<<128n)-1n,Fe="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",ze="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Ge="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,je=5,Ke=1800n,f=Object.freeze({factory:l(_[4663].uniswap.v3_factory.address),positionManager:l(_[4663].uniswap.v3_position_manager.address),swapRouter02:l(_[4663].uniswap.swap_router02.address),permit2:l(_[4663].uniswap.permit2.address),weth:l(_[4663].uniswap.WETH.address),usdg:l(_[4663].uniswap.USDG.address),ethUsdgPool:l(_[4663].oracle.ethUsdgPool.address)}),xe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),yt=Object.freeze([{fee:100,tickSpacing:1,address:l("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:f.weth,token1:f.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:l("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:f.weth,token1:f.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:l("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:f.weth,token1:f.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:l("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:f.weth,token1:f.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),x=Z(["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)"]),Q=Z(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),ke=Z(["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)"]),Qe=Z(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),ye=Z(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),Ye="0xd0e30db0";function Ze(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===C||e===Fe||e==="eth"||e==="native"}function E(t,e){if(Ze(t))throw new c(`Uniswap v3 requires wrapped ERC-20 WETH (${f.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new c(`${e} must be a valid 20-byte hex address.`);return O(t),l(t)}function Je(t,e,n){let a=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new c("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(a)||!Number.isInteger(o))throw new c("Uniswap v3 tickLower and tickUpper must be integers.");if(a<re||o>se||a>se||o<re)throw new c(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(a>=o)throw new c("Uniswap v3 tickLower must be strictly less than tickUpper.");if(a%i!==0||o%i!==0)throw new c(`Uniswap v3 tickLower (${a}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:a,tickUpper:o,tickSpacing:i}}function et(t,e){let n=t.trim(),a=n.startsWith("-"),o=a||n.startsWith("+")?n.slice(1):n,i=Ue(F(o).toString(),e);return a&&i!=="0"?`-${i}`:i}function tt(t){let e=typeof t=="string"?he({abi:x,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:l(String(e[1])),token0:l(String(e[2])),token1:l(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 $e(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?l(e).toLowerCase():void 0,a=f.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==a)continue;let r=Array.isArray(i.topics)?i.topics.map(u=>String(u).toLowerCase()):[],s=r[0];if(s===ze&&r.length>=4){let d=`0x${r[2].slice(-40)}`;if(!n||d===n){let m=BigInt(r[3]).toString();m!=="0"&&o.add(m)}}else if(s===Ge&&r.length>=2&&!n){let u=BigInt(r[1]).toString();u!=="0"&&o.add(u)}}return[...o]}function ht(t){let e=n=>typeof n=="bigint"?n:F(n);return R({abi:Qe,functionName:"exactInputSingle",args:[{tokenIn:l(t.tokenIn),tokenOut:l(t.tokenOut),fee:t.fee,recipient:l(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Le=1n<<96n;function Re(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 nt(t,e,n,a){if(a<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(a<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let s=(a<<96n)*(i-t)/i/t,u=a*(t-o)/Le;return{amount0:s,amount1:u}}return{amount0:0n,amount1:a*(i-o)/Le}}async function M(t,e,n,a){let o=l(e),i,r;if(n===k&&o===f.weth?(i=18,r="WETH"):n===k&&o===f.usdg&&(i=6,r="USDG"),i===void 0){let s=await t.readContract({address:o,abi:ye,functionName:"decimals"});i=Number(s)}if(r===void 0)try{let s=await t.readContract({address:o,abi:ye,functionName:"symbol"});if(typeof s!="string"||!s.trim())throw new c("Token symbol is unavailable.");r=Ne(s.trim(),o)}catch(s){throw new c(`Could not read token metadata. ${U(s)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new c("Token decimals are invalid.");if(a!=null){let s=Number(a);if(!Number.isInteger(s)||s!==i)throw new c(`Token ${o} on chain ${n} has ${i} decimals, not ${String(a)}.`)}return{address:o,symbol:r,decimals:i,chainId:n}}async function it(t){try{if(!t.getBlock)throw new c("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new c("Invalid block timestamp.");return e.timestamp}catch(e){throw new c(`Could not read the current block timestamp. ${U(e)}`)}}function J(t,e){if(typeof t=="bigint"){if(t<0n)throw new c(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new c(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return F(t);throw new c(`${e} must be a non-negative integer.`)}async function _e(t,e){let n=await it(t);if(e==null)return n+Ke;let a=J(e,"deadline");if(a<=n)throw new c(`Uniswap v3 deadline (${a.toString()}) has expired at timestamp ${n.toString()}.`);return a}function V(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new c(`${e} must be a non-negative integer string in base units.`);return F(t)}function Ee(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new c("Slippage must be an integer from 0 to 9999 bps.");return ge("0",e),e}function ae(t,e,n,a){let o=t===void 0?F(ge(e.toString(),n)):V(t,a);if(o<=1n)throw new c(`${a} must exceed 1 base unit; the simulated amount may be too small.`);return o}function X(t,e){return pe({to:f.positionManager,data:t,value:"0",chainId:k,description:e})}async function Y(t,e,n){try{if(!t.request)throw new c("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 c("Unexpected batch simulation response.");return o[0].calls.map((i,r)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new c(`Simulation call ${r+1} failed. ${U(i.error)}`);return i.returnData})}catch(a){throw new c(`Uniswap v3 simulation failed. ${U(a)}`)}}function ce(t,e){try{return he({abi:x,functionName:t,data:e})}catch{throw new c(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Be(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new c("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new c("sqrtPriceX96 must be a non-negative integer string.");return Me(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new c("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Ce(t.initialPrice,e,n)}async function De(t,e,n,a){let o=[];for(let i of Object.keys(xe).map(Number)){if(i===a)continue;let r=l(String(await t.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[e,n,i]})));if(r===C||BigInt(await t.readContract({address:r,abi:ke,functionName:"liquidity"}))===0n)continue;let u=await t.readContract({address:r,abi:ke,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${r}`,sqrtPriceX96:BigInt(u[0])})}return o}function G(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==k)throw new c(`Uniswap v3 is only supported on Robinhood Chain (${k}).`);if(e.version!==void 0&&e.version!=="v3")throw new c(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(k);return{...n,readContract:async a=>{try{return await n.readContract(a)}catch(o){throw new c(`Could not read Uniswap v3 ${a.functionName}. ${U(o)}`,{cause:o})}}}}async function ve(t,e,n){let a;try{a=await t.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[e]})}catch(r){throw new c(`Could not verify owner of Uniswap v3 position #${e}. ${U(r)}`)}let o=l(String(a)),i=l(n);if(o!==i)throw new c(`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:f.positionManager,abi:x,functionName:"positions",args:[e]});return tt(n)}function Ie(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(a=>`${et(a.amount,a.token.decimals)} ${a.token.symbol}`);return`${t} (${n.join(", ")})`}async function ot(t,e,n){O(n);let a=l(n),o=G(t,e),i=await _e(o,e.deadline),r=Ee(e),s=e.tokenId===void 0?void 0:J(e.tokenId,"tokenId"),u;if(s!==void 0){if(s<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,s,a),u=await de(o,s)}let d=u?.token0??E(e.token0,"token0"),m=u?.token1??E(e.token1,"token1");if(BigInt(d)>=BigInt(m))throw new c("Uniswap v3 requires distinct sorted token addresses.");let p=u?.fee??Number(e.fee??100),g=xe[p];if(!g)throw new c("Unsupported Uniswap v3 fee tier.");let y=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d,m,p]}))),h=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(y===C&&!h)throw new c("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(y!==C&&h)throw new c(`The Uniswap v3 pool already exists at ${y}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(s!==void 0&&h)throw new c("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new c("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||u))throw new c("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:S,tickUpper:N,tickSpacing:T}=Je(u?.tickLower??(e.fullRange===!0?Math.ceil(re/g)*g:e.tickLower),u?.tickUpper??(e.fullRange===!0?Math.floor(se/g)*g:e.tickUpper),g),w=await M(o,d,k,e.token0Decimals),b=await M(o,m,k,e.token1Decimals),P;if(y===C){let q=Be(e,w.decimals,b.decimals),L=be(q,await De(o,d,m,p),e.acceptPriceDeviation===!0,w.decimals,b.decimals);P={sqrtPriceX96:q,note:L}}let v=V(e.amount0Desired,"amount0Desired"),I=V(e.amount1Desired,"amount1Desired");if(v===0n&&I===0n)throw new c("Liquidity addition requires a positive desired amount.");let $=e.recipient===void 0?a:E(e.recipient,"recipient");if($!==a)throw new c("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==f.weth&&m!==f.weth)throw new c("Wrapping requires a positive WETH desired amount.");let H=await Promise.all([d,m].map(async q=>BigInt(await o.readContract({address:q,abi:ye,functionName:"allowance",args:[a,f.positionManager]})))),j=(q,L)=>{let fe=[];if(e.wrapNative===!0){let K=d===f.weth?q:L;K>0n&&fe.push(pe({to:f.weth,data:Ye,value:K.toString(),chainId:k,description:"Wrap ETH into WETH."}))}for(let[K,We]of[d,m].entries()){let me=K===0?q:L;me>0n&&H[K]<me&&fe.push(t.approval(We,f.positionManager,me.toString(),k))}return fe},W=s===void 0?"mint":"increaseLiquidity",B=(q,L)=>X(s===void 0?R({abi:x,functionName:"mint",args:[{token0:d,token1:m,fee:p,tickLower:S,tickUpper:N,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,recipient:$,deadline:i}]}):R({abi:x,functionName:"increaseLiquidity",args:[{tokenId:s,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,deadline:i}]}),`${W==="mint"?"Mint":"Increase"} Uniswap v3 ${w.symbol}/${b.symbol} liquidity.`),D=P&&X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[d,m,p,P.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${w.symbol}/${b.symbol} fee ${p} pool at ${ie(P.sqrtPriceX96,w.decimals,b.decimals)} ${b.symbol} per ${w.symbol}.`),Pe=D?[D]:[],Se=await Y(o,[...Pe,...j(v,I),B(0n,0n)],a),A=ce(W,Se[Se.length-1]),Ve=A[A.length-2],He=A[A.length-1];if(Ve>v||He>I)throw new c("Simulated liquidity spend exceeds the desired amounts.");let ee=[...Pe,...j(v,I)],ue=ae(e.amount0Min,A[A.length-2],r,"amount0Min"),le=ae(e.amount1Min,A[A.length-1],r,"amount1Min");if(ue>v||le>I)throw new c("Uniswap v3 minimum amount cannot exceed desired amount.");let Ae=B(ue,le);ee.push(Ae);for(let[q,L]of[d,m].entries())(q===0?v:I)>0n&&ee.push(t.approval(L,f.positionManager,"0",k));let qe=await t.preview(ee,a);return{txs:ee,preview:qe,summary:Ie(Ae.description,qe),details:{version:"v3",action:W,...s===void 0?{}:{tokenId:s.toString()},pool:y===C?null:y,fee:p,tickSpacing:T,tickLower:S,tickUpper:N,token0:w,token1:b,amount0Desired:v.toString(),amount1Desired:I.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:$,expectedAmount0:A[A.length-2].toString(),expectedAmount1:A[A.length-1].toString(),...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:ie(P.sqrtPriceX96,w.decimals,b.decimals),initialTick:we(P.sqrtPriceX96),priceCheck:P.note}:{}}}}async function rt(t,e,n){O(n);let a=l(n),o=G(t,e),i=E(e.token0,"token0"),r=E(e.token1,"token1");if(BigInt(i)>=BigInt(r))throw new c(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(r)?i:r}, token1=${BigInt(i)<BigInt(r)?r:i}; initialPrice is token1 per 1 token0 in that order.`);let s=Number(e.fee),u=xe[s];if(!u){let b=Number(await o.readContract({address:f.factory,abi:Q,functionName:"feeAmountTickSpacing",args:[s]}));if(!Number.isInteger(s)||b<=0)throw new c("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");u=b}let d=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[i,r,s]})));if(d!==C)throw new c(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let m=await M(o,i,k,e.token0Decimals),p=await M(o,r,k,e.token1Decimals),g=Be(e,m.decimals,p.decimals),y=be(g,await De(o,i,r,s),e.acceptPriceDeviation===!0,m.decimals,p.decimals),h=ie(g,m.decimals,p.decimals),S=[X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[i,r,s,g]}),`Create and initialize the Uniswap v3 ${m.symbol}/${p.symbol} fee ${s} pool at ${h} ${p.symbol} per ${m.symbol}.`)],N=await Y(o,S,a),T;try{T=l(String(he({abi:x,functionName:"createAndInitializePoolIfNecessary",data:N[0]})))}catch{throw new c("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(T===C)throw new c("Uniswap v3 pool creation simulation returned no pool.");let w=await t.preview(S,a);return{txs:S,preview:w,summary:`${S[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:T,fee:s,tickSpacing:u,token0:m,token1:p,sqrtPriceX96:g.toString(),initialPrice:h,initialTick:we(g),priceCheck:y}}}async function st(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=await M(o,r.token0,k),u=await M(o,r.token1,k),d=e.recipient===void 0?a:E(e.recipient,"recipient");if(d!==a)throw new c("Uniswap recipient must be the signing wallet.");let m=e.amount0Max===void 0?z:V(e.amount0Max,"amount0Max"),p=e.amount1Max===void 0?z:V(e.amount1Max,"amount1Max");if(m===0n&&p===0n||m>z||p>z)throw new c("Collect requires a positive amountMax within uint128.");let g=[X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:m,amount1Max:p}]}),`Collect Uniswap v3 fees from position #${i}.`)],y=ce("collect",(await Y(o,g,a))[0]),h=await t.preview(g,a);return{txs:g,preview:h,summary:Ie(g[0].description,h),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:s,token1:u,amount0Max:m.toString(),amount1Max:p.toString(),expectedAmount0:y[0].toString(),expectedAmount1:y[1].toString()}}}async function at(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=r.liquidity===0n&&e.burn===!0;if(r.liquidity<=0n&&!s)throw new c("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!s)throw new c('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let u=e.liquidity==="all"||e.liquidity===void 0?r.liquidity:V(e.liquidity,"liquidity");if(u<=0n&&!s)throw new c("Liquidity to remove must be positive.");if(u>r.liquidity)throw new c("Requested liquidity exceeds position liquidity.");let d=await _e(o,e.deadline),m=Ee(e),p=await M(o,r.token0,k),g=await M(o,r.token1,k),y=e.recipient===void 0?a:E(e.recipient,"recipient");if(y!==a)throw new c("Uniswap recipient must be the signing wallet.");let h=(B,D)=>X(R({abi:x,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:u,amount0Min:B,amount1Min:D,deadline:d}]}),`Decrease ${u} liquidity on Uniswap v3 position #${i}.`),S=s?[0n,0n]:ce("decreaseLiquidity",(await Y(o,[h(0n,0n)],a))[0]),N=(B,D)=>{if(B!==void 0&&V(B,D)!==0n)throw new c(`${D} must be zero for an empty position burn.`);return 0n},T=s?N(e.amount0Min,"amount0Min"):ae(e.amount0Min,S[0],m,"amount0Min"),w=s?N(e.amount1Min,"amount1Min"):ae(e.amount1Min,S[1],m,"amount1Min"),b=s?[]:[h(T,w)],P=b.length,v=!s||r.tokensOwed0>0n||r.tokensOwed1>0n;v&&b.push(X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:y,amount0Max:z,amount1Max:z}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let I=u===r.liquidity,$=I&&e.burn===!0;$&&b.push(X(R({abi:x,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let H=await Y(o,b,a),j=v?ce("collect",H[P]):[0n,0n],W=await t.preview(b,a);return{txs:b,preview:W,summary:Ie(`Remove Uniswap v3 liquidity from position #${i}${$?`; burns position #${i} at ${f.positionManager}`:""}`,W),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:y,token0:p,token1:g,liquidityRemoved:u.toString(),amount0Min:T.toString(),amount1Min:w.toString(),deadline:d.toString(),expectedAmount0:j[0].toString(),expectedAmount1:j[1].toString(),fullExit:I,burned:$}}}async function ct(t,e,n={}){let a=l(e),o=new Set;if(Array.isArray(n.tokenIds))for(let r of n.tokenIds){let s=J(r,"tokenId");s>0n&&o.add(s.toString())}if(Array.isArray(n.receipts))for(let r of n.receipts)for(let s of $e(r,a))o.add(s);let i=!1;try{let r=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"balanceOf",args:[a]})),s=r>64n?64n:r;for(let u=0n;u<s;u++){try{let d=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"tokenOfOwnerByIndex",args:[a,u]}));d>0n&&o.add(d.toString())}catch(d){if(!te(d,3,-32601,-32004))throw d;break}u+1n===r&&(i=!0)}r===0n&&(i=!0)}catch(r){if(!te(r,3,-32601,-32004))throw r}if(typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let r=n.toBlock??await t.getBlockNumber(),s=n.maxChunks??je,u=n.fromBlock??(r>oe*BigInt(s)?r-oe*BigInt(s)+1n:0n),d=r,m=0;for(;d>=u&&m<s;){let p=d>=oe-1n?d-(oe-1n):0n,g=p<u?u:p,y=await t.getLogs({address:f.positionManager,fromBlock:g,toBlock:d});for(let h of $e({logs:y},a))o.add(h);if(m+=1,g===0n||g<=u)break;d=g-1n}}catch(r){throw new c(`Could not discover Uniswap v3 positions from logs. ${U(r)}`)}else if(!i&&n.tokenIds===void 0&&n.receipts===void 0)throw new c("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(r=>BigInt(r)).sort((r,s)=>r<s?-1:r>s?1:0)}async function Oe(t,e,n={}){O(e);let a=l(e),o=G(t),i=await ct(o,a,n),r=[];for(let s of i){let u;try{let w=await o.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[s]});u=l(String(w))}catch(w){if(te(w,3))continue;throw new c(`Could not verify owner of position #${s}. ${U(w)}`)}if(u!==a)continue;let d;try{d=await de(o,s)}catch(w){throw new c(`Could not read position #${s}. ${U(w)}`)}if(d.liquidity===0n&&d.tokensOwed0===0n&&d.tokensOwed1===0n&&!n.includeEmpty)continue;let p=await M(o,d.token0,k),g=await M(o,d.token1,k),y=0n,h=0n;if(d.liquidity>0n)try{let w=await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d.token0,d.token1,d.fee]}),b=l(String(w));if(b===C)throw new c("Position pool was not found.");if(b!==C){let P=await o.readContract({address:b,abi:ke,functionName:"slot0"}),v=BigInt(P[0]);if(v<=0n)throw new c("Position pool has no initialized price.");let I=Re(d.tickLower),$=Re(d.tickUpper),H=nt(v,I,$,d.liquidity);y=H.amount0,h=H.amount1}}catch(w){throw new c(`Could not value Uniswap v3 position #${s}. ${U(w)}`)}let S=y+d.tokensOwed0,N=h+d.tokensOwed1,T=[{token:p,amount:S.toString()},{token:g,amount:N.toString()}];r.push({module:"uniswap",id:`uniswap:v3:${s.toString()}`,chainId:k,assets:T,description:`Uniswap v3 LP position #${s.toString()} (${p.symbol}/${g.symbol} fee ${d.fee} ticks [${d.tickLower}, ${d.tickUpper}] liquidity ${d.liquidity.toString()})`})}return r}async function dt(t,e,n){G(t,e);let a=e.wallet!==void 0?E(e.wallet,"wallet"):l(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,r=e.includeZero===!0||e.includeEmpty===!0,s=await Oe(t,a,{tokenIds:o,receipts:i,includeEmpty:r});return{positions:s,details:{version:"v3",wallet:a,count:s.length,positionManager:f.positionManager}}}function ut(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:(r,s)=>ot(t,r,s)},{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:(r,s)=>st(t,r,s)},{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:(r,s)=>at(t,r,s)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet from NFT receipts and Transfer logs.",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."}}},execute:(r,s)=>dt(t,r,s)},{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:(r,s)=>rt(t,r,s)}]}var Xe=t=>({tools:ut(t),positions:e=>Oe(t,e)}),xt=Xe,vt=Xe;export{re as a,se as b,z as c,f as d,xe as e,yt as f,x as g,Q as h,ke as i,Qe as j,Je as k,et as l,tt as m,$e as n,ht as o,Be as p,ot as q,rt as r,st as s,at as t,Oe as u,dt as v,ut as w,Xe as x,xt as y,vt as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./UWOFA6GV.js";import{c as B,f as z,g as I,k as F,n as G}from"./73N3TOJL.js";import{a as g,i as j}from"./XPFVT2EA.js";import{a}from"./5YS5V2LK.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=j[g].meridian,S=ne.PredictionMarketEscrow.address,v={address:ne.CollateralToken_USDe.address,chainId:g,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(n,y){if(n===void 0)return y;if(!Number.isSafeInteger(n)||n<1||n>E)throw new a("Provide a Meridian page limit from 1 to 25.");return n}function X(n){if(n!==void 0){if(typeof n!="string"||!n.trim()||n.length>4096)throw new a("Provide the opaque Meridian nextCursor returned by the previous page.");return n}}function Z(n,y,u,w=!1){let l=C(n),m=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!w||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>y||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof m.hasNextPage!="boolean"||u===void 0&&!m.hasNextPage&&l.totalCount>l.nodes.length||m.endCursor!==null&&(typeof m.endCursor!="string"||!m.endCursor.trim()||m.endCursor.length>4096)||m.hasNextPage&&(l.nodes.length===0||m.endCursor===null||m.endCursor===u))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:m.hasNextPage?m.endCursor:null,complete:!m.hasNextPage&&u===void 0}}function C(n){return z(n,"Meridian returned an unexpected response.")}function A(n){if(typeof n!="string"||!n.trim())throw new a("Meridian returned an invalid text field.");return n}function b(n){return F(n,"Provide a valid Meridian contract or wallet address.")}function M(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return n}function R(n){return G(n,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(n){return n===0?"0":R(n)}function D(n){if(typeof n!="bigint"||n<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(n.toString())}function ue(n,y){return n.chainId===y.chainId&&I(n.address,y.address)}function ee(n,y){let u=C(n),w=C(u.pickConfig),l=b(u.holder),m=b(w.marketAddress);if(u.chainId!==g||!I(l,y))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(m,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof w.resolved!="boolean"||w.result!==null&&typeof w.result!="string")throw new a("Meridian returned an invalid resolution.");let P=M(u.pickConfigId);if(!I(M(w.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(u.side!=="PREDICTOR"&&u.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(u.id),chainId:g,holder:l,side:u.side,balance:N(u.balance),tokenAddress:b(u.tokenAddress),pickConfigId:P,userCollateral:N(u.userCollateral),totalPayout:N(u.totalPayout),prediction:{predictionId:M(C(u.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:m,resolved:w.resolved,result:w.result}}}var le=n=>{async function y(t){try{return await t()}catch(o){throw new a(n.plainError(o))}}async function u(){let t=n.clientFor(g);if(await t.getChainId()!==g)throw new a("Meridian requires an RPC on chain 4663.");return t}async function w(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let e=await n.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new a(`Meridian returned HTTP ${e.status}. Please try again.`);let c;try{c=await e.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(c);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await w("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return Z(s.positions,o,r,!0)}async function m(t,o){let r=[],s=new Set,e=new Set,c,d,f=0;for(let p=0;p<ce;p++){let h=await l(t,E,c);if(d!==void 0&&d!==h.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=h.totalCount;for(let x of h.nodes){let i=C(x),k=A(i.id);if(e.has(k))throw new a("Meridian repeated a position during pagination; retry from the first page.");e.add(k),N(i.balance)!=="0"&&f++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(h.nextCursor===null){if(f>d||e.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(h.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(h.nextCursor),c=h.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await u();return(await Promise.all(t.map(async e=>{let[c,d,f]=await Promise.all([r.readContract({address:e.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:e.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:e.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let p={address:e.tokenAddress,chainId:g,decimals:d,symbol:A(f)},h=D(c),x=e.pickConfig.resolved?{token:{...v},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[e.pickConfigId,e.tokenAddress,BigInt(h)]}))}:null;return{module:"meridian",id:e.id,chainId:g,assets:[{token:p,amount:h}],description:`Meridian ${e.side.toLowerCase()} position; ${e.pickConfig.resolved?e.pickConfig.result??"resolved":"unresolved"}.`,holder:e.holder,side:e.side,pickConfigId:e.pickConfigId,prediction:e.prediction,pickConfig:e.pickConfig,userCollateral:{token:{...v},amount:e.userCollateral},totalPayout:{token:{...v},amount:e.totalPayout},claimable:x}}))).filter(e=>BigInt(e.assets[0].amount)>0n)}async function q(t){return P(await m(t),t)}function L(t){return n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function _(t,o,r){let s=o.changes.map(e=>{let c=e.amount.startsWith("-"),d=n.formatAmount(c?e.amount.slice(1):e.amount,e.token.decimals);return`${c?"-":"+"}${d} ${e.token.symbol} (${e.token.address}, chain ${e.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=X(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let e;if(t.search!==void 0&&(e=A(t.search).trim(),e.length>500))throw new a("Keep the Meridian market search to 500 characters.");let c=t.conditionId===void 0?void 0:M(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),f=await w("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...e===void 0?{}:{search:e},...c===void 0?{}:{conditionIds:[c]},...d===void 0?{}:{resolvers:[d]}}),p=Z(f.conditions,o,r),h=p.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let k=M(i.conditionId),T=b(i.resolver);if(c!==void 0&&!I(k,c)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:k,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:g,collateral:{...v},totalCount:p.totalCount,markets:h,limit:o,nextCursor:p.nextCursor,complete:p.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let e=await u(),c=D(await e.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(c))throw new a("The redemption amount exceeds the wallet position balance.");let d=n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),f=[d],p;try{p=await n.preview(f,o)}catch(i){if(!/\breverted\b/i.test(n.plainError(i)))throw i;let k=await m(o,r);if(k.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=k[0];if(T.pickConfig.resolved){let re=D(await e.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}f=[L(T.prediction.predictionId),d],p=await n.preview(f,o)}let h=p.changes.filter(i=>ue(i.token,v)&&i.token.decimals===v.decimals).reduce((i,k)=>i+BigInt(k.amount),0n),x=p.changes.filter(i=>i.token.chainId===g&&I(i.token.address,r)).reduce((i,k)=>i+BigInt(k.amount),0n);if(h<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return _(f,p,f.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,e){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(c,d)=>y(async()=>{if(C(c),b(d),Object.keys(c).some(f=>!Object.hasOwn(o,f))||r.some(f=>c[f]===void 0))throw new a("Provide only the required Meridian tool inputs.");return e(c,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=X(t.cursor),e=await l(o,r,s);return{positions:await P(e.nodes.map(c=>ee(c,o)),o),totalCount:e.totalCount,limit:r,nextCursor:e.nextCursor,complete:e.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=L(M(t.predictionId));await u();let s=[r];return _(s,await n.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>y(()=>q(t))}},we=le;export{le as a,we as b};
|
|
1
|
+
import{a as H}from"./UWOFA6GV.js";import{c as B,f as z,g as I,k as F,n as G}from"./73N3TOJL.js";import{a as g,i as j}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=j[g].meridian,S=ne.PredictionMarketEscrow.address,v={address:ne.CollateralToken_USDe.address,chainId:g,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(n,y){if(n===void 0)return y;if(!Number.isSafeInteger(n)||n<1||n>E)throw new a("Provide a Meridian page limit from 1 to 25.");return n}function X(n){if(n!==void 0){if(typeof n!="string"||!n.trim()||n.length>4096)throw new a("Provide the opaque Meridian nextCursor returned by the previous page.");return n}}function Z(n,y,u,w=!1){let l=C(n),m=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!w||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>y||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof m.hasNextPage!="boolean"||u===void 0&&!m.hasNextPage&&l.totalCount>l.nodes.length||m.endCursor!==null&&(typeof m.endCursor!="string"||!m.endCursor.trim()||m.endCursor.length>4096)||m.hasNextPage&&(l.nodes.length===0||m.endCursor===null||m.endCursor===u))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:m.hasNextPage?m.endCursor:null,complete:!m.hasNextPage&&u===void 0}}function C(n){return z(n,"Meridian returned an unexpected response.")}function A(n){if(typeof n!="string"||!n.trim())throw new a("Meridian returned an invalid text field.");return n}function b(n){return F(n,"Provide a valid Meridian contract or wallet address.")}function M(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return n}function R(n){return G(n,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(n){return n===0?"0":R(n)}function D(n){if(typeof n!="bigint"||n<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(n.toString())}function ue(n,y){return n.chainId===y.chainId&&I(n.address,y.address)}function ee(n,y){let u=C(n),w=C(u.pickConfig),l=b(u.holder),m=b(w.marketAddress);if(u.chainId!==g||!I(l,y))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(m,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof w.resolved!="boolean"||w.result!==null&&typeof w.result!="string")throw new a("Meridian returned an invalid resolution.");let P=M(u.pickConfigId);if(!I(M(w.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(u.side!=="PREDICTOR"&&u.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(u.id),chainId:g,holder:l,side:u.side,balance:N(u.balance),tokenAddress:b(u.tokenAddress),pickConfigId:P,userCollateral:N(u.userCollateral),totalPayout:N(u.totalPayout),prediction:{predictionId:M(C(u.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:m,resolved:w.resolved,result:w.result}}}var le=n=>{async function y(t){try{return await t()}catch(o){throw new a(n.plainError(o))}}async function u(){let t=n.clientFor(g);if(await t.getChainId()!==g)throw new a("Meridian requires an RPC on chain 4663.");return t}async function w(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let e=await n.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new a(`Meridian returned HTTP ${e.status}. Please try again.`);let c;try{c=await e.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(c);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await w("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return Z(s.positions,o,r,!0)}async function m(t,o){let r=[],s=new Set,e=new Set,c,d,f=0;for(let p=0;p<ce;p++){let h=await l(t,E,c);if(d!==void 0&&d!==h.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=h.totalCount;for(let x of h.nodes){let i=C(x),k=A(i.id);if(e.has(k))throw new a("Meridian repeated a position during pagination; retry from the first page.");e.add(k),N(i.balance)!=="0"&&f++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(h.nextCursor===null){if(f>d||e.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(h.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(h.nextCursor),c=h.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await u();return(await Promise.all(t.map(async e=>{let[c,d,f]=await Promise.all([r.readContract({address:e.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:e.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:e.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let p={address:e.tokenAddress,chainId:g,decimals:d,symbol:A(f)},h=D(c),x=e.pickConfig.resolved?{token:{...v},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[e.pickConfigId,e.tokenAddress,BigInt(h)]}))}:null;return{module:"meridian",id:e.id,chainId:g,assets:[{token:p,amount:h}],description:`Meridian ${e.side.toLowerCase()} position; ${e.pickConfig.resolved?e.pickConfig.result??"resolved":"unresolved"}.`,holder:e.holder,side:e.side,pickConfigId:e.pickConfigId,prediction:e.prediction,pickConfig:e.pickConfig,userCollateral:{token:{...v},amount:e.userCollateral},totalPayout:{token:{...v},amount:e.totalPayout},claimable:x}}))).filter(e=>BigInt(e.assets[0].amount)>0n)}async function q(t){return P(await m(t),t)}function L(t){return n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function _(t,o,r){let s=o.changes.map(e=>{let c=e.amount.startsWith("-"),d=n.formatAmount(c?e.amount.slice(1):e.amount,e.token.decimals);return`${c?"-":"+"}${d} ${e.token.symbol} (${e.token.address}, chain ${e.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=X(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let e;if(t.search!==void 0&&(e=A(t.search).trim(),e.length>500))throw new a("Keep the Meridian market search to 500 characters.");let c=t.conditionId===void 0?void 0:M(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),f=await w("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...e===void 0?{}:{search:e},...c===void 0?{}:{conditionIds:[c]},...d===void 0?{}:{resolvers:[d]}}),p=Z(f.conditions,o,r),h=p.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let k=M(i.conditionId),T=b(i.resolver);if(c!==void 0&&!I(k,c)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:k,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:g,collateral:{...v},totalCount:p.totalCount,markets:h,limit:o,nextCursor:p.nextCursor,complete:p.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let e=await u(),c=D(await e.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(c))throw new a("The redemption amount exceeds the wallet position balance.");let d=n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),f=[d],p;try{p=await n.preview(f,o)}catch(i){if(!/\breverted\b/i.test(n.plainError(i)))throw i;let k=await m(o,r);if(k.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=k[0];if(T.pickConfig.resolved){let re=D(await e.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}f=[L(T.prediction.predictionId),d],p=await n.preview(f,o)}let h=p.changes.filter(i=>ue(i.token,v)&&i.token.decimals===v.decimals).reduce((i,k)=>i+BigInt(k.amount),0n),x=p.changes.filter(i=>i.token.chainId===g&&I(i.token.address,r)).reduce((i,k)=>i+BigInt(k.amount),0n);if(h<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return _(f,p,f.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,e){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(c,d)=>y(async()=>{if(C(c),b(d),Object.keys(c).some(f=>!Object.hasOwn(o,f))||r.some(f=>c[f]===void 0))throw new a("Provide only the required Meridian tool inputs.");return e(c,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=X(t.cursor),e=await l(o,r,s);return{positions:await P(e.nodes.map(c=>ee(c,o)),o),totalCount:e.totalCount,limit:r,nextCursor:e.nextCursor,complete:e.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=L(M(t.predictionId));await u();let s=[r];return _(s,await n.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>y(()=>q(t))}},we=le;export{le as a,we as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Y,e as Z}from"./WQQJ7UPJ.js";import{a as U,b as L,c as D,d as G,e as _,f as W,g as J}from"./3NDVXEBR.js";import{d as C,e as $,v as H}from"./Q356HHCL.js";import{a as K}from"./EG6M6SSO.js";import{a as S}from"./UWOFA6GV.js";import{c as h,g as Q}from"./73N3TOJL.js";import{a as I,i as T}from"./G6HCV67X.js";import{a as o}from"./5YS5V2LK.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{a as k}from"./UWOFA6GV.js";import{c as l}from"./73N3TOJL.js";import{a as p}from"./
|
|
1
|
+
import{a as k}from"./UWOFA6GV.js";import{c as l}from"./73N3TOJL.js";import{a as p}from"./G6HCV67X.js";import{a as s}from"./5YS5V2LK.js";import{encodeFunctionData as H,getAddress as m,parseAbi as f,zeroAddress as w}from"viem";var x=f(["function tokenizations(address token) view returns ((address creator,address forwarder,bytes32 marketFamilyId,uint64 createdAt))"]),S=f(["function tokenizations(address token) view returns ((address creator,uint8 way,address forwarder,address adapter,address door,bytes32 familyId,bytes32 marketFamilyId,uint64 unlockBlock,uint16 legBps))"]),b=f(["function name() view returns (string)","function symbol() view returns (string)","function decimals() view returns (uint8)","function balanceOf(address account) view returns (uint256)","function totalSupply() view returns (uint256)","function assetCount() view returns (uint256)","function claimable(address account,uint256 asset) view returns (uint256)","function streamSeconds() view returns (uint32)","function tipBps() view returns (uint16)","function doorCount() view returns (uint256)","function dropBox() view returns (address)","function bridge() view returns (address)","function claim(uint256 asset,address to) returns (uint256 amount)","function claimAll(address to) returns (uint256[] amounts)","function sync() returns (uint256 tip)","function syncRange(uint256 start,uint256 count) returns (uint256 tip)","function syncSome(uint256[] doorIds) returns (uint256 tip)"]),C=f(["function dropCount() view returns (uint256)","function claimable(uint256 dropId,address holder) view returns (uint256)","function claim(uint256[] dropIds,address to) returns (uint256[] amounts)"]),y=["0x522723A7a09684515881568Ab8247f3846D66F43","0xfb3c1501c727f30883cd7B36Ec380381af7412Ef"].map(m),I={token:b,drops:C};function O(n){return{type:"object",properties:Object.fromEntries(n.inputs.map(t=>[t.name,t.type==="address"?l:t.type==="uint256[]"?{type:"array",items:k(),maxItems:128}:k()])),required:n.inputs.map(t=>t.name),additionalProperties:!1}}function h(n){return Object.entries(I).flatMap(([t,o])=>o.filter(r=>r.stateMutability==="view"===n).map(r=>({target:t,fn:r})))}function v(n){return{type:"object",oneOf:h(n).map(({target:t,fn:o})=>({type:"object",properties:{token:l,target:{const:t},function:{const:o.name},params:O(o)},required:["token","target","function","params"],additionalProperties:!1}))}}function A(n,t){if(Object.keys(n).length!==4||Object.keys(n).some(e=>!["token","target","function","params"].includes(e)))throw new s("Provide token, target, function and params for the Hookr revenue operation.");let o=h(t).find(e=>e.target===n.target&&e.fn.name===n.function);if(!o||!n.params||typeof n.params!="object"||Array.isArray(n.params))throw new s("Choose a documented Hookr revenue function and parameter object.");let r;try{r=m(String(n.token))}catch{throw new s("Provide a valid Hookr revenue token address.")}let i=n.params,a=o.fn;if(Object.keys(i).length!==a.inputs.length||Object.keys(i).some(e=>!a.inputs.some(u=>u.name===e)))throw new s("Provide exactly the documented Hookr revenue parameters.");let c=e=>{if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new s("Revenue token indices and amounts must be decimal base-unit strings.");return BigInt(e)},d=a.inputs.map(e=>{let u=i[e.name];if(e.type==="address")try{return m(String(u))}catch{throw new s("Provide a valid Hookr revenue address.")}if(e.type==="uint256[]"){if(!Array.isArray(u)||u.length>128)throw new s("Provide at most 128 Hookr revenue indices.");return u.map(c)}return c(u)});return{token:r,fn:a,values:d,operation:o}}async function g(n,t,o){let r=n.clientFor(p),i;for(let c of y){let d=c===y[0],e=await r.readContract({address:c,abi:d?x:S,functionName:"tokenizations",args:[t]});if(!e||typeof e.creator!="string"||d&&(!("createdAt"in e)||typeof e.createdAt!="bigint"||e.createdAt<0n||e.createdAt>=1n<<64n))throw new s("Hookr token provenance is unavailable.");if(m(e.creator)!==w&&(!d||"createdAt"in e&&e.createdAt>0n)){i=c;break}}if(!i)throw new s("This token has no record on a pinned Hookr tokenizer.");let a=o?m(await r.readContract({address:t,abi:b,functionName:"dropBox"})):t;if(a===w)throw new s("Hookr revenue drop box is unavailable.");return{to:a,tokenizer:i}}async function j(n,t,o){if(n.network==="testnet")throw new s("Hookr revenue actions require mainnet, chain 4663.");let{token:r,fn:i,values:a}=A(t,!1),{to:c}=await g(n,r,t.target==="drops"),d=i.inputs.findIndex(e=>e.name==="to");if(d>=0&&[w,r,c].includes(a[d]))throw new s("Choose a valid revenue claim recipient.");return{txs:[n.unsignedTx({chainId:p,to:c,value:"0",data:H({abi:[i],functionName:i.name,args:a}),description:`Hookr revenue ${t.target}.${i.name}: ${JSON.stringify(t.params)}. No token approval or principal deposit.`})],inputs:[]}}function T(n){return[{name:"hookr_revenue_read",inputSchema:{...v(!0),description:"Read a registered Hookr revenue token or its derived drop box: balance, claimable, terms and indices. Checks tokenizer provenance on chain."},execute:async t=>{let{token:o,fn:r,values:i}=A(t,!0),{to:a,tokenizer:c}=await g(n,o,t.target==="drops"),d=await n.clientFor(p).readContract({address:a,abi:[r],functionName:r.name,args:i});return{chainId:p,token:o,tokenizer:c,contract:a,function:r.name,result:JSON.parse(JSON.stringify(d,(e,u)=>typeof u=="bigint"?u.toString():u))}}},{name:"hookr_revenue_action",inputSchema:{...v(!1),description:"Preview holder income/drop claims or permissionless sync/syncRange/syncSome on a registered Hookr revenue token. No approvals; local human confirmation required. Claims and syncs are separate actions."},execute:async(t,o)=>{let{txs:r}=await j(n,t,o),i=await n.preview(r,o);return{txs:r,preview:i,summary:`Hookr revenue ${t.function}; verify receipt and holder balances after confirmation.`}}}]}export{y as a,j as b,T as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as R}from"./J2XAEVKC.js";import{a as L,f as N,g as b}from"./3NDVXEBR.js";import{H,J as j,K as O,b as p,d as l,y as D}from"./Q356HHCL.js";import{g as d}from"./73N3TOJL.js";import{a as y}from"./G6HCV67X.js";import{a as e}from"./5YS5V2LK.js";import{decodeAbiParameters as J,decodeFunctionData as A,encodeAbiParameters as K,encodeFunctionData as Q,erc20Abi as W,getAddress as Y,parseAbi as Z,parseAbiParameters as ee}from"viem";var U=Z(["function modifyLiquidities(bytes unlockData,uint256 deadline) payable"]),V=ee("bytes actions,bytes[] params");function de(f,$){return{tools:[{name:"uniswap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["operations"],properties:{operations:{type:"array",minItems:1,maxItems:20,items:{type:"object",additionalProperties:!1,required:["name","arguments"],properties:{name:{type:"string",enum:["uniswap_add","uniswap_collect","uniswap_remove"]},arguments:{anyOf:[H,j,O]}}}}}},async execute(a,v){if(b(a,["operations"]),!Array.isArray(a.operations)||a.operations.length<1||a.operations.length>20)throw new e("Provide 1 to 20 v4 liquidity operations.");let s="0x",c,h=[],P=0n,g=new Map,_=new Set,E=new Set;for(let t of a.operations){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each operation needs name and arguments.");let o=t;if(b(o,["name","arguments"]),!["uniswap_add","uniswap_collect","uniswap_remove"].includes(String(o.name))||!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))throw new e("Batch supports v4 add, collect and remove operations only.");let r=o.arguments;if(r.version!=="v4")throw new e("Every batch operation must explicitly select version v4.");if(r.initialPrice!==void 0||r.sqrtPriceX96!==void 0)throw new e("Create a pool before batching its liquidity operations.");if(r.tokenId!==void 0){let n=L(r.tokenId,"tokenId").toString();if(E.has(n))throw new e("Batch tokenIds must be distinct decimal strings.");E.add(n)}else if(o.name!=="uniswap_add")throw new e("Existing-position operations require tokenId.");let I=await $.tools.find(n=>n.name===o.name).execute(r,v),u=I.txs.at(-1);if(!u||!d(u.to,p))throw new e("Batch operation returned an unexpected destination.");P+=BigInt(u.value);for(let n of I.txs.slice(0,-1)){if(BigInt(n.value)!==0n)throw new e("Batch prerequisite cannot send native currency.");if(d(n.to,l)){let i=A({abi:R,data:n.data}),[B,G,X,z]=i.args;if(!d(G,p))throw new e("Batch Permit2 spender must be PositionManager.");let T=B.toLowerCase(),m=g.get(T),q=BigInt(z),C=(m?.amount??0n)+X;if(C>=1n<<160n)throw new e("Batch approval exceeds uint160.");g.set(T,{token:B,amount:C,expiration:m&&m.expiration<q?m.expiration:q})}else{let i=A({abi:W,data:n.data});if(i.functionName!=="approve"||!d(i.args[0],l))throw new e("Unexpected batch prerequisite.")}}let S=A({abi:U,data:u.data}),[F,x]=J(V,S.args[0]),k=F.slice(2).match(/../g)??[];if(k.length!==x.length)throw new e("Batch action/parameter count differs.");k.forEach((n,i)=>{n==="14"?_.add(x[i]):(s=`${s}${n}`,h.push(x[i]))});let M=S.args[1];c=c===void 0||M<c?M:c}for(let t of _)s=`${s}14`,h.push(t);let w=[];for(let t of g.values())w.push(f.approval(Y(t.token),l,t.amount.toString(),y),D(t.token,p,t.amount.toString(),t.expiration.toString()));return w.push(f.unsignedTx({to:p,data:Q({abi:U,functionName:"modifyLiquidities",args:[K(V,[s,h]),c]}),value:P.toString(),chainId:y,description:`Atomically modify ${a.operations.length} v4 positions; recipients are the signing wallet.`})),N(f,w,v,"Atomic v4 batch: every operation must succeed. Each position retains its own minimums; preview covers the complete action stream.")}}]}}export{U as a,V as b,de as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ue}from"./UIIJWIR6.js";import{c as le}from"./D6VP3N27.js";import{a as X}from"./QZM7CWZW.js";import{a as x,b as v}from"./VJ3W2V3B.js";import{a as L}from"./OG5HRQU4.js";import{a as de}from"./P4UQGWCP.js";import{a as E}from"./6IM6A5VA.js";import{b as ie,c as ce}from"./MYBDO5SA.js";import{a as oe,b as G,c as V}from"./5HCXZWUH.js";import{l as ae,n as F,o as re}from"./IWALIX7Q.js";import{a as w,b as U,c as B,d as te,i as P,j as se,s as N}from"./XPFVT2EA.js";import{a as m}from"./5YS5V2LK.js";import{a as p,b as W,c as ne}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeFunctionData as Le,erc20Abi as Z,getAddress as b,isAddress as H,parseAbi as ee}from"viem";var Te="https://api.robinhood.com/rhj/assets",Ne={address:x,symbol:"ETH",decimals:18,chainId:w},j={address:b(se),symbol:"USDG",decimals:te,chainId:w},Y={address:b(P[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},be={address:b(P[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q(e,t=w,s={}){let n=Array.isArray(e)?e:_(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new m("Official stock asset list response is malformed.");let o=new Map,d=new Map;if(n.length>1e4)throw new m("Official stock asset list exceeds the lookup limit.");for(let a of n){if(!_(a))continue;let r=a;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new m("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new m(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new m("Official stock asset has invalid token decimals.");let f=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let k of r.deployments){if(!_(k))continue;let h=k;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!H(h.contractAddress,{strict:!1}))throw new m("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),u=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==u)throw new m(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=o.get(u);if(c&&(c.symbol!==l||c.decimals!==f))throw new m(`Conflicting official stock identity at ${y}.`);d.set(g,u),o.set(u,{address:y,symbol:l,decimals:f,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...o.values()]}function De(e,t){if(typeof e.address!="string"||!H(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(o=>o.chainId===s&&o.address.toLowerCase()===n&&o.symbol===e.symbol)}function $(e,t){E(e.address);let s=e.chainId??w,n=b(e.address),o=n.toLowerCase(),d=C(e.symbol),a=t.find(l=>l.chainId===s&&l.address.toLowerCase()===o),r=t.find(l=>l.chainId===s&&C(l.symbol)===d);if(a){if(e.symbol!==a.symbol)throw new m(`Token at ${n} does not match official stock ticker ${p(a.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==a.decimals)throw new m(`Token ${p(a.symbol)} at ${n} does not match official decimals ${a.decimals}.`);return a}if(r)throw new m(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var ve=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],J=new WeakMap,me=new WeakMap,z=new WeakMap;function K(e,t){return(z.get(e)??F)(t)}async function pe(e){let t=e?.http??ie(),s=e?.url??Te,n=e?.chainId??w,o=V(t),d=me.get(o);d||(d=new oe(3e4),me.set(o,d));let{value:a}=await K(t,()=>d.read(`${n}:${s}`,async()=>{let l=await F(k=>ce(o,s,{method:"GET",signal:k},h=>_(h)||Array.isArray(h))),f=Q(l,n,{allowAmbiguousSymbols:!0});if(n===w&&f.length===0)throw new m("Official stock asset list has no mainnet deployments; retry when the list is available.");return l})),r=Q(a,n,e);if(n===w){let l=J.get(o);l||(l=new Set,J.set(o,l));for(let f of r)l.add(C(f.symbol))}return r}var Pe=ee(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function fe(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let o=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(o))return!0;t=n.cause}return!1}function Ee(e){return e instanceof m?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function xe(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return fe(s)}return fe(s)}async function ke(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(o=>e.readContract({address:o.address,abi:Z,functionName:"balanceOf",args:[s]})));if(n.every(o=>o.status==="rejected")&&n[0]?.status==="rejected"&&Ee(n[0].reason))throw n[0].reason;return n.map(o=>{if(o.status!=="fulfilled"||o.value===void 0||o.value===null)return{ok:!1};try{let d=typeof o.value=="bigint"?o.value:BigInt(o.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function we(e,t,s,n){if(s.length===0)return[];let o=ae(t,e);if(!o)return ke(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:Le({abi:Z,functionName:"balanceOf",args:[n]})})),a;try{a=await e.readContract({address:o,abi:Pe,functionName:"aggregate3",args:[d]})}catch(r){if(await xe(e,o,r))return ke(e,s,n);throw r}if(!Array.isArray(a)||a.length!==s.length)throw new m("Multicall3 aggregate3 returned an invalid result list.");return a.map(r=>{let l=r,f=Array.isArray(l)?l[0]:l?.success,k=Array.isArray(l)?l[1]:l?.returnData;if(!f||typeof k!="string"||k==="0x")return{ok:!1};try{let h=Ie({abi:Z,functionName:"balanceOf",data:k}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function ze(e,t={}){E(e);let s=b(e),n=t.chainId??w,o=t.client??re(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=Q(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==U&&(d=await pe({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)$(i,d);let a=n===w?[j,Y,be,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===U?[{...j,address:b(N.testnet.usdg),chainId:n},{...Y,address:b(N.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?de.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),f=[],k=new Set;for(let i of[...a,...d,...t.tokens??[],...r]){if(i.chainId!==n||v(i.address)===x)continue;let c=$(i,d),T=c.address.toLowerCase();k.has(T)||(k.add(T),f.push(c))}let[h,y]=await Promise.all([o.getBalance({address:s}),we(o,n,f,s)]),u=[],g={address:x,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&u.push({token:g,amount:h.toString()});for(let i=0;i<f.length;i++){let c=f[i],T=a.some(S=>O(S.address,c.address))||d.some(S=>O(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,M]=await Promise.all([L(o,n,c.address,"symbol"),L(o,n,c.address,"decimals")]);T=p(S),c.decimals=M}catch{}(A>0n||t.includeZero)&&u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return u}async function qe(e,t,s){if(E(e),t.length>1e4)throw new m("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(a=>(E(a),b(a))))].filter(a=>v(a)!==x).map(a=>({address:a,symbol:a,decimals:0,chainId:s.chainId})),o=await we(s.client,s.chainId,n,b(e)),d=n.flatMap((a,r)=>{let l=o[r];return l.ok&&l.amount===0n?[]:[{token:a,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:a,amount:r})=>{let[l,f]=await Promise.all([L(s.client,s.chainId,a.address,"symbol").catch(()=>a.address),L(s.client,s.chainId,a.address,"decimals").catch(()=>{throw new m(`Token decimals are unavailable for journal-received token ${a.address}; retry balances when RPC metadata is available.`)})]);return{token:{...a,symbol:p(l),decimals:f},amount:r}}))}var O=(e,t)=>e.toLowerCase()===t.toLowerCase(),C=e=>ne(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function ge(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:o}=N[t],d=(a,r,l)=>({...a,address:v(b(a.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Ne,chainId:s},"Ether","native"),d({...j,address:n,chainId:s},"Global Dollar","stablecoin"),d({...Y,address:o,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(be,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ae(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await pe({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>De(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:Te,warnings:[]}))}async function q(e,t,s=!0){let{chainId:n}=N[t.context.network??"mainnet"],o=t.context.clientFor(n);if(await o.getChainId()!==n)throw new m(`Token lookup requires Robinhood Chain ${n}.`);let[d,a,r]=await Promise.all([K(o,()=>L(o,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),K(o,()=>L(o,n,e,"symbol",t.blockNumber)),K(o,()=>L(o,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new m("The contract returned invalid token metadata.");return{address:b(e),name:d||a,symbol:a,decimals:r,chainId:n}}async function he(e,t){let s=await t.context.clientFor(w).readContract({address:P[w].clanker.factory.address,abi:ee(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&O(s[0],e)}async function Me(e,t){let s=t.context.clientFor(w),n=P[w].poolsTrade,o=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=ee(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],a=await s.getBlockNumber(),r=new Set,l=0,f=0;for(let k=63127652n;k<=a;k+=10000000n){if(++l>Se)throw new m("Token origin scan limit reached.");let h=k+9999999n>a?a:k+9999999n,y=await s.getLogs({address:o,event:d,args:{token:e},fromBlock:k,toBlock:h,strict:!0});for(let u of y){if(u.removed||!o.some(i=>O(i,u.address))||!u.args.token||!O(u.args.token,e)||!u.transactionHash||r.has(u.transactionHash))continue;if(r.add(u.transactionHash),++f>20)throw new m("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:u.transactionHash});if(ue(g).some(i=>O(i.token,e)))return b(g.from)}}}var Se=5,Re=100,Ue=500,Be=3e4;function Ce(e){let t=Date.now()+Be,s=0,n=new Map,o=a=>{let r=t-Date.now();if(r<=0)throw new m("Token lookup time budget reached; results are partial.");return F(a,Math.min(1e4,r))},d=G((a,r)=>o(async l=>{let f=await e.context.http(a,{...r,signal:l});return new Proxy(f,{get(k,h){if(h==="json")return()=>o(()=>k.json());let y=Reflect.get(k,h,k);return typeof y=="function"?y.bind(k):y}})}),e.context.http);return z.set(d,o),{...e,context:{...e.context,http:d,clientFor:a=>{if(!n.has(a)){let r=e.context.clientFor(a),l=f=>{if(++s>Ue)throw new m("Token lookup RPC budget reached; results are partial.");return o(f)};n.set(a,G(new Proxy(r,{get(f,k){let h=Reflect.get(f,k);return typeof h!="function"?h:(...y)=>l(()=>h.apply(f,y))}}),r)),z.set(n.get(a),l)}return n.get(a)}}}}function ye(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function en(e,t){if(t=Ce(t),typeof e!="string"||e.length>256||!C(e))throw new m("Provide a token name, symbol or address to find_token.");let s=C(e),n=H(e.trim(),{strict:!1})?v(b(e.trim())):void 0,{chainId:o}=N[t.context.network??"mainnet"],d=[],a=ge(t),r=!1;try{a.push(...await Ae(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?O(i.address,n):C(i.symbol).includes(s)||C(i.name).includes(s),f=a.filter(l),k=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=C(T),S=C(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(k.some(A=>O(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(W(i.symbol)||W(i.name)||a.some(A=>!O(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};k.push(I),d.push(...T)};if(n&&!f.length){let i=await q(n,t),c={};if(o===w){try{await he(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await X(t.context,{q:n,limit:20})).tokens.find(A=>O(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await le(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await Me(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&o===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Se)throw new m("Token search page limit reached.");let S=await X(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let M of S.tokens){if(++A>Re)throw new m("Token candidate limit reached.");let D=b(M.contract_address);if(!(c.has(D)||a.some(R=>O(R.address,D)))){c.add(D);try{let R=await q(D,t);if(!l(R))continue;let Oe=await he(D,t)?{launchpad:"clanker",creator:b(M.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(R,Oe)}catch{r=!0,d.push(`Could not read Clanker candidate ${D}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new m("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}o===U&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let u=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=u([...f,...k]);for(let i of g)if(g.some(c=>!O(c.address,i.address)&&(C(i.symbol)===C(c.symbol)||C(i.name)===C(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return f.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:o,partial:r,matches:u(f).map(ye),unverified:u(k).map(ye),warnings:d}}async function nn(e,t){if(typeof e!="string"||!e.trim())throw new m("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new m("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=H(s,{strict:!1})?v(b(s)):void 0,o=ge(t),d=n&&o.find(y=>O(y.address,n));if(d)return d;let a=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&o.find(y=>y.symbol.toUpperCase()===a),l=[],f=!1;try{l=await Ae(t)}catch{if(r)return r;if(!n)throw new m("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");f=!0}if(n){let y=l.find(i=>O(i.address,n));if(y)return t.tokenMetadata&&$(t.tokenMetadata,l),{...y,name:p(y.name)};let u=t.tokenMetadata??await t.readMetadata?.(n);if(u&&(!O(u.address,n)||u.chainId!==N[t.context.network??"mainnet"].chainId))throw new m("Token metadata does not match the requested address and chain.");if(u&&(typeof u.symbol!="string"||!u.symbol.trim()||!Number.isInteger(u.decimals)||u.decimals<0||u.decimals>255))throw new m("The contract returned invalid token metadata.");let g=u?{...u,name:u.symbol}:await q(n,Ce(t),!1);if(f){let i=C(g.symbol),c=J.get(V(t.context.http));if(ve.some(T=>C(T)===i)||c?.has(i))throw new m("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return $(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...f?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let k=[...o,...l].filter(y=>y.symbol.toUpperCase()===a);if(k.length!==1)throw new m(`Token symbol ${p(s)} is ${k.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=k[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new m(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{Te as a,Ne as b,j as c,Y as d,be as e,Q as f,De as g,$ as h,pe as i,Pe as j,ze as k,qe as l,en as m,nn as n};
|
|
1
|
+
import{a as ue}from"./LQGPMOD2.js";import{c as le}from"./NSOEDRBU.js";import{a as X}from"./XVFLT275.js";import{a as x,b as v}from"./CY75R4FK.js";import{a as L}from"./QRDDKA4I.js";import{a as de}from"./P4UQGWCP.js";import{a as E}from"./6IM6A5VA.js";import{b as ie,c as ce}from"./MYBDO5SA.js";import{a as oe,b as G,c as V}from"./5HCXZWUH.js";import{l as ae,n as F,o as re}from"./CXLEQCP3.js";import{a as w,b as U,c as B,d as te,i as P,j as se,s as N}from"./G6HCV67X.js";import{a as m}from"./5YS5V2LK.js";import{a as p,b as W,c as ne}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ie,encodeFunctionData as Le,erc20Abi as Z,getAddress as b,isAddress as H,parseAbi as ee}from"viem";var Te="https://api.robinhood.com/rhj/assets",Ne={address:x,symbol:"ETH",decimals:18,chainId:w},j={address:b(se),symbol:"USDG",decimals:te,chainId:w},Y={address:b(P[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},be={address:b(P[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function _(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Q(e,t=w,s={}){let n=Array.isArray(e)?e:_(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new m("Official stock asset list response is malformed.");let o=new Map,d=new Map;if(n.length>1e4)throw new m("Official stock asset list exceeds the lookup limit.");for(let a of n){if(!_(a))continue;let r=a;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new m("Official stock deployment list exceeds the lookup limit.");let l=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(l))throw new m(`Invalid official stock ticker ${p(l)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new m("Official stock asset has invalid token decimals.");let f=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let k of r.deployments){if(!_(k))continue;let h=k;if(h.chainId!==t)continue;if(typeof h.contractAddress!="string"||!H(h.contractAddress,{strict:!1}))throw new m("Official stock deployment has an invalid contract address.");let y=b(h.contractAddress),u=y.toLowerCase(),g=l.toUpperCase(),i=d.get(g);if(!s.allowAmbiguousSymbols&&i&&i!==u)throw new m(`Ambiguous official stock ticker ${p(l)} across multiple addresses.`);let c=o.get(u);if(c&&(c.symbol!==l||c.decimals!==f))throw new m(`Conflicting official stock identity at ${y}.`);d.set(g,u),o.set(u,{address:y,symbol:l,decimals:f,chainId:t,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...o.values()]}function De(e,t){if(typeof e.address!="string"||!H(e.address,{strict:!1}))return!1;let s=e.chainId??w,n=e.address.toLowerCase();return t.some(o=>o.chainId===s&&o.address.toLowerCase()===n&&o.symbol===e.symbol)}function $(e,t){E(e.address);let s=e.chainId??w,n=b(e.address),o=n.toLowerCase(),d=C(e.symbol),a=t.find(l=>l.chainId===s&&l.address.toLowerCase()===o),r=t.find(l=>l.chainId===s&&C(l.symbol)===d);if(a){if(e.symbol!==a.symbol)throw new m(`Token at ${n} does not match official stock ticker ${p(a.symbol)} (received ${p(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==a.decimals)throw new m(`Token ${p(a.symbol)} at ${n} does not match official decimals ${a.decimals}.`);return a}if(r)throw new m(`Token symbol ${p(e.symbol)} at ${n} does not match the official stock contract address ${r.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var ve=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],J=new WeakMap,me=new WeakMap,z=new WeakMap;function K(e,t){return(z.get(e)??F)(t)}async function pe(e){let t=e?.http??ie(),s=e?.url??Te,n=e?.chainId??w,o=V(t),d=me.get(o);d||(d=new oe(3e4),me.set(o,d));let{value:a}=await K(t,()=>d.read(`${n}:${s}`,async()=>{let l=await F(k=>ce(o,s,{method:"GET",signal:k},h=>_(h)||Array.isArray(h))),f=Q(l,n,{allowAmbiguousSymbols:!0});if(n===w&&f.length===0)throw new m("Official stock asset list has no mainnet deployments; retry when the list is available.");return l})),r=Q(a,n,e);if(n===w){let l=J.get(o);l||(l=new Set,J.set(o,l));for(let f of r)l.add(C(f.symbol))}return r}var Pe=ee(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function fe(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let o=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(o))return!0;t=n.cause}return!1}function Ee(e){return e instanceof m?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function xe(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return fe(s)}return fe(s)}async function ke(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(o=>e.readContract({address:o.address,abi:Z,functionName:"balanceOf",args:[s]})));if(n.every(o=>o.status==="rejected")&&n[0]?.status==="rejected"&&Ee(n[0].reason))throw n[0].reason;return n.map(o=>{if(o.status!=="fulfilled"||o.value===void 0||o.value===null)return{ok:!1};try{let d=typeof o.value=="bigint"?o.value:BigInt(o.value);return d>=0n?{ok:!0,amount:d}:{ok:!1}}catch{return{ok:!1}}})}async function we(e,t,s,n){if(s.length===0)return[];let o=ae(t,e);if(!o)return ke(e,s,n);let d=s.map(r=>({target:r.address,allowFailure:!0,callData:Le({abi:Z,functionName:"balanceOf",args:[n]})})),a;try{a=await e.readContract({address:o,abi:Pe,functionName:"aggregate3",args:[d]})}catch(r){if(await xe(e,o,r))return ke(e,s,n);throw r}if(!Array.isArray(a)||a.length!==s.length)throw new m("Multicall3 aggregate3 returned an invalid result list.");return a.map(r=>{let l=r,f=Array.isArray(l)?l[0]:l?.success,k=Array.isArray(l)?l[1]:l?.returnData;if(!f||typeof k!="string"||k==="0x")return{ok:!1};try{let h=Ie({abi:Z,functionName:"balanceOf",data:k}),y=typeof h=="bigint"?h:BigInt(h);return y>=0n?{ok:!0,amount:y}:{ok:!1}}catch{return{ok:!1}}})}async function ze(e,t={}){E(e);let s=b(e),n=t.chainId??w,o=t.client??re(t.rpcUrl,n),d=[];if(t.stockTokens?d=[...t.stockTokens]:t.stockAssetsPayload!==void 0?d=Q(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==U&&(d=await pe({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let i of t.tokens)$(i,d);let a=n===w?[j,Y,be,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:b(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:B,chainId:n}]:[]]:n===U?[{...j,address:b(N.testnet.usdg),chainId:n},{...Y,address:b(N.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:b(t.oakTokenAddress),symbol:"OAK",decimals:B,chainId:n}]:[]]:[],r=n===w&&t.includePoolTokens!==!1?de.vaults.flatMap(i=>[{address:b(i.tokenAddress),symbol:b(i.tokenAddress),decimals:i.tokenDecimals,chainId:n},{address:b(i.earnContractAddress),symbol:b(i.earnContractAddress),decimals:18,chainId:n}]):[],l=new Set(r.map(i=>i.address.toLowerCase())),f=[],k=new Set;for(let i of[...a,...d,...t.tokens??[],...r]){if(i.chainId!==n||v(i.address)===x)continue;let c=$(i,d),T=c.address.toLowerCase();k.has(T)||(k.add(T),f.push(c))}let[h,y]=await Promise.all([o.getBalance({address:s}),we(o,n,f,s)]),u=[],g={address:x,symbol:"ETH",decimals:18,chainId:n};(h>0n||t.includeZero)&&u.push({token:g,amount:h.toString()});for(let i=0;i<f.length;i++){let c=f[i],T=a.some(S=>O(S.address,c.address))||d.some(S=>O(S.address,c.address))?c.symbol:p(c.symbol),I=y[i]??{ok:!1};if(!I.ok){u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:"unavailable"});continue}let A=I.amount;if(A>0n&&l.has(c.address.toLowerCase()))try{let[S,M]=await Promise.all([L(o,n,c.address,"symbol"),L(o,n,c.address,"decimals")]);T=p(S),c.decimals=M}catch{}(A>0n||t.includeZero)&&u.push({token:{address:c.address,symbol:T,decimals:c.decimals,chainId:c.chainId},amount:A.toString()})}return u}async function qe(e,t,s){if(E(e),t.length>1e4)throw new m("Journal token discovery exceeds the balance lookup limit.");let n=[...new Set(t.map(a=>(E(a),b(a))))].filter(a=>v(a)!==x).map(a=>({address:a,symbol:a,decimals:0,chainId:s.chainId})),o=await we(s.client,s.chainId,n,b(e)),d=n.flatMap((a,r)=>{let l=o[r];return l.ok&&l.amount===0n?[]:[{token:a,amount:l.ok?l.amount.toString():"unavailable"}]});return Promise.all(d.map(async({token:a,amount:r})=>{let[l,f]=await Promise.all([L(s.client,s.chainId,a.address,"symbol").catch(()=>a.address),L(s.client,s.chainId,a.address,"decimals").catch(()=>{throw new m(`Token decimals are unavailable for journal-received token ${a.address}; retry balances when RPC metadata is available.`)})]);return{token:{...a,symbol:p(l),decimals:f},amount:r}}))}var O=(e,t)=>e.toLowerCase()===t.toLowerCase(),C=e=>ne(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function ge(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:o}=N[t],d=(a,r,l)=>({...a,address:v(b(a.address)),name:r,kind:l,verified:!0,source:"Oak fixed addresses",warnings:[]});return[d({...Ne,chainId:s},"Ether","native"),d({...j,address:n,chainId:s},"Global Dollar","stablecoin"),d({...Y,address:o,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[d(be,"USDe","stablecoin")]:[],...e.oakTokenAddress?[d({address:e.oakTokenAddress,symbol:"OAK",decimals:B,chainId:s},"Oak","oak")]:[]]}async function Ae(e){if(e.context.network==="testnet")return[];let t=e.officialStockTokens??await pe({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>De(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:Te,warnings:[]}))}async function q(e,t,s=!0){let{chainId:n}=N[t.context.network??"mainnet"],o=t.context.clientFor(n);if(await o.getChainId()!==n)throw new m(`Token lookup requires Robinhood Chain ${n}.`);let[d,a,r]=await Promise.all([K(o,()=>L(o,n,e,"name",t.blockNumber)).catch(l=>{if(s)throw l;return""}),K(o,()=>L(o,n,e,"symbol",t.blockNumber)),K(o,()=>L(o,n,e,"decimals",t.blockNumber))]);if(typeof d!="string"||s&&!d.trim()||typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new m("The contract returned invalid token metadata.");return{address:b(e),name:d||a,symbol:a,decimals:r,chainId:n}}async function he(e,t){let s=await t.context.clientFor(w).readContract({address:P[w].clanker.factory.address,abi:ee(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&O(s[0],e)}async function Me(e,t){let s=t.context.clientFor(w),n=P[w].poolsTrade,o=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],d=ee(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],a=await s.getBlockNumber(),r=new Set,l=0,f=0;for(let k=63127652n;k<=a;k+=10000000n){if(++l>Se)throw new m("Token origin scan limit reached.");let h=k+9999999n>a?a:k+9999999n,y=await s.getLogs({address:o,event:d,args:{token:e},fromBlock:k,toBlock:h,strict:!0});for(let u of y){if(u.removed||!o.some(i=>O(i,u.address))||!u.args.token||!O(u.args.token,e)||!u.transactionHash||r.has(u.transactionHash))continue;if(r.add(u.transactionHash),++f>20)throw new m("Token origin receipt limit reached.");let g=await s.getTransactionReceipt({hash:u.transactionHash});if(ue(g).some(i=>O(i.token,e)))return b(g.from)}}}var Se=5,Re=100,Ue=500,Be=3e4;function Ce(e){let t=Date.now()+Be,s=0,n=new Map,o=a=>{let r=t-Date.now();if(r<=0)throw new m("Token lookup time budget reached; results are partial.");return F(a,Math.min(1e4,r))},d=G((a,r)=>o(async l=>{let f=await e.context.http(a,{...r,signal:l});return new Proxy(f,{get(k,h){if(h==="json")return()=>o(()=>k.json());let y=Reflect.get(k,h,k);return typeof y=="function"?y.bind(k):y}})}),e.context.http);return z.set(d,o),{...e,context:{...e.context,http:d,clientFor:a=>{if(!n.has(a)){let r=e.context.clientFor(a),l=f=>{if(++s>Ue)throw new m("Token lookup RPC budget reached; results are partial.");return o(f)};n.set(a,G(new Proxy(r,{get(f,k){let h=Reflect.get(f,k);return typeof h!="function"?h:(...y)=>l(()=>h.apply(f,y))}}),r)),z.set(n.get(a),l)}return n.get(a)}}}}function ye(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:p(e.symbol),name:p(e.name)}}async function en(e,t){if(t=Ce(t),typeof e!="string"||e.length>256||!C(e))throw new m("Provide a token name, symbol or address to find_token.");let s=C(e),n=H(e.trim(),{strict:!1})?v(b(e.trim())):void 0,{chainId:o}=N[t.context.network??"mainnet"],d=[],a=ge(t),r=!1;try{a.push(...await Ae(t))}catch{r=!0,d.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let l=i=>n?O(i.address,n):C(i.symbol).includes(s)||C(i.name).includes(s),f=a.filter(l),k=[],h=(i,c)=>[i.symbol,i.name??""].some(T=>[c.symbol,c.name].some(I=>{let A=C(T),S=C(I);return!!A&&!!S&&(A.includes(S)||S.includes(A))})),y=(i,c={})=>{if(k.some(A=>O(A.address,i.address)))return;let T=[`Token ${p(i.symbol)} at ${i.address} is an unverified ${c.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(W(i.symbol)||W(i.name)||a.some(A=>!O(A.address,i.address)&&h(i,A)))&&T.push(`Lookalike warning: ${p(i.symbol)} at ${i.address} resembles a verified token's name or symbol.`);let I={...i,...c,kind:c.launchpad?"launchpad":"erc20",verified:!1,source:c.launchpad?`${c.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:T};k.push(I),d.push(...T)};if(n&&!f.length){let i=await q(n,t),c={};if(o===w){try{await he(n,t)&&(c.launchpad="clanker")}catch{d.push("Clanker origin lookup was unavailable for this address.")}if(c.launchpad==="clanker")try{let I=(await X(t.context,{q:n,limit:20})).tokens.find(A=>O(A.contract_address,n));I&&(c.creator=b(I.msg_sender),c.creatorSource="Clanker indexer msg_sender")}catch{d.push("Clanker creator lookup is unavailable.")}else try{let T=await le(t.context,n);c.launchpad="pons",c.creator=b(T.creator),c.creatorSource="Pons factory deployer"}catch{d.push("Pons launch origin could not be confirmed for this address.")}if(!c.launchpad)try{let T=await Me(n,t);T&&(c.launchpad="pools.trade",c.creator=T,c.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,d.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}y(i,c)}else if(!n&&o===w){let i=new Set,c=new Set,T,I=0,A=0;try{do{if(++I>Se)throw new m("Token search page limit reached.");let S=await X(t.context,{q:e.trim(),limit:20,...T?{cursor:T}:{}});for(let M of S.tokens){if(++A>Re)throw new m("Token candidate limit reached.");let D=b(M.contract_address);if(!(c.has(D)||a.some(R=>O(R.address,D)))){c.add(D);try{let R=await q(D,t);if(!l(R))continue;let Oe=await he(D,t)?{launchpad:"clanker",creator:b(M.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};y(R,Oe)}catch{r=!0,d.push(`Could not read Clanker candidate ${D}; it was omitted from these partial results.`)}}}if(S.cursor&&i.has(S.cursor))throw new m("The Clanker indexer repeated a pagination cursor.");S.cursor&&i.add(S.cursor),T=S.cursor??void 0}while(T)}catch{r=!0,d.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}d.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}o===U&&d.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let u=i=>[...new Map(i.map(c=>[c.address.toLowerCase(),c])).values()],g=u([...f,...k]);for(let i of g)if(g.some(c=>!O(c.address,i.address)&&(C(i.symbol)===C(c.symbol)||C(i.name)===C(c.name)))){let c=`Duplicate warning: several tokens share the symbol or name of ${i.address}. Choose the intended address; do not guess from the name.`;i.warnings.push(c),d.push(c)}return f.length>1&&d.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:p(e.trim()),chainId:o,partial:r,matches:u(f).map(ye),unverified:u(k).map(ye),warnings:d}}async function nn(e,t){if(typeof e!="string"||!e.trim())throw new m("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new m("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,n=H(s,{strict:!1})?v(b(s)):void 0,o=ge(t),d=n&&o.find(y=>O(y.address,n));if(d)return d;let a=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!n&&o.find(y=>y.symbol.toUpperCase()===a),l=[],f=!1;try{l=await Ae(t)}catch{if(r)return r;if(!n)throw new m("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");f=!0}if(n){let y=l.find(i=>O(i.address,n));if(y)return t.tokenMetadata&&$(t.tokenMetadata,l),{...y,name:p(y.name)};let u=t.tokenMetadata??await t.readMetadata?.(n);if(u&&(!O(u.address,n)||u.chainId!==N[t.context.network??"mainnet"].chainId))throw new m("Token metadata does not match the requested address and chain.");if(u&&(typeof u.symbol!="string"||!u.symbol.trim()||!Number.isInteger(u.decimals)||u.decimals<0||u.decimals>255))throw new m("The contract returned invalid token metadata.");let g=u?{...u,name:u.symbol}:await q(n,Ce(t),!1);if(f){let i=C(g.symbol),c=J.get(V(t.context.http));if(ve.some(T=>C(T)===i)||c?.has(i))throw new m("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return $(g,l),{...g,symbol:p(g.symbol),name:p(g.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...f?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let k=[...o,...l].filter(y=>y.symbol.toUpperCase()===a);if(k.length!==1)throw new m(`Token symbol ${p(s)} is ${k.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let h=k[0];if(h.kind==="official_stock"&&s!==h.symbol)throw new m(`Use the exact official stock ticker ${p(h.symbol)}; case variants are refused.`);return h.source==="Oak fixed addresses"?h:{...h,name:p(h.name)}}export{Te as a,Ne as b,j as c,Y as d,be as e,Q as f,De as g,$ as h,pe as i,Pe as j,ze as k,qe as l,en as m,nn as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as w,e as R,f as N,g as S}from"./
|
|
1
|
+
import{a as b,b as w,e as R,f as N,g as S}from"./3NDVXEBR.js";import{a as h}from"./UWOFA6GV.js";import{c as g,g as E}from"./73N3TOJL.js";import{a as d}from"./G6HCV67X.js";import{a as r}from"./5YS5V2LK.js";import{encodeFunctionData as v,erc20Abi as I,getAddress as _,parseAbi as O,zeroAddress as C}from"viem";var k=_("0x2ac03e14cfe755426daaee0a4994184ce81482f8"),a=_("0x7a8f74c2585f84c781f951b7f2ff21337d5b630b"),o=O(["function RESOURCE() view returns (address)","function TOKEN_JAR() view returns (address)","function threshold() view returns (uint256)","function nonce() view returns (uint256)","function release(uint256 nonce,address[] assets,address recipient)"]),B={assets:{type:"array",minItems:1,maxItems:20,items:g},nonce:h(),maxResourceAmount:h()};function F(n){return{tools:[!1,!0].map(i=>({name:i?"uniswap_token_jar_release":"uniswap_token_jar",inputSchema:{type:"object",additionalProperties:!1,required:i?["assets","nonce","maxResourceAmount"]:["assets"],properties:B},async execute(t,m){if(S(t,i?["assets","nonce","maxResourceAmount"]:["assets"]),!Array.isArray(t.assets)||t.assets.length<1||t.assets.length>20)throw new r("Provide 1 to 20 unique assets to release.");let c=t.assets.map(w);if(new Set(c).size!==c.length)throw new r("Token Jar assets must be unique.");let s=n.clientFor(d),e=await s.getBlockNumber(),[x,P,u,f]=await Promise.all([s.readContract({address:a,abi:o,functionName:"RESOURCE",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"TOKEN_JAR",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"threshold",blockNumber:e}),s.readContract({address:a,abi:o,functionName:"nonce",blockNumber:e})]);if(!E(String(P),k)||x===C)throw new r("Releaser deployment does not match the pinned Token Jar and ERC-20 resource.");let p=await R(n,w(x),e),T=await Promise.all(c.map(async l=>({token:await R(n,l,e),amount:(l===C?await s.getBalance({address:k,blockNumber:e}):await s.readContract({address:l,abi:I,functionName:"balanceOf",args:[k],blockNumber:e})).toString()}))),y={payment:{token:p,amount:String(u)},nonce:String(f),assets:T,blockNumber:e.toString()};if(!i)return{...y,summary:"Resource payment buys the listed jar contents; no profit is promised. Release uses a nonce to refuse competing releases."};let J=b(t.maxResourceAmount,"maxResourceAmount"),A=b(t.nonce,"nonce",256,!0);if(A!==BigInt(f)||BigInt(u)>J)throw new r("Token Jar nonce or resource cost changed. Read uniswap_token_jar and confirm fresh terms.");let j=[n.approval(p.address,a,String(u),d),n.unsignedTx({to:a,data:v({abi:o,functionName:"release",args:[A,c,m]}),value:"0",chainId:d,description:`Pay ${u} base units of ${p.address} to release Token Jar assets to ${m}, nonce ${f}.`})];return{...await N(n,j,m,"Exchange resource tokens for Token Jar assets. Check the full payment, assets and recipient in the preview; gas is additional."),...y}}}))}}export{k as a,a as b,o as c,F as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as h}from"./WQQJ7UPJ.js";import{d as k,h as V}from"./IBXYIN7Q.js";import{a as P,b as f,f as O,g as A}from"./3NDVXEBR.js";import{a as g,v as M}from"./Q356HHCL.js";import{a as b}from"./UWOFA6GV.js";import{c as _,g as T}from"./73N3TOJL.js";import{a as y}from"./G6HCV67X.js";import{a as l}from"./5YS5V2LK.js";import{encodeFunctionData as c,parseAbi as j,zeroAddress as I}from"viem";var n=j(["function owner() view returns (address)","function feeTo() view returns (address)","function feeToSetter() view returns (address)","function protocolFeeController() view returns (address)","function setFeeTo(address)","function setFeeToSetter(address)","function setOwner(address)","function enableFeeAmount(uint24,int24)","function setFeeProtocol(uint8,uint8)","function collectProtocol(address,uint128,uint128) returns (uint128,uint128)","function transferOwnership(address)","function setProtocolFeeController(address)","function setProtocolFee((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks),uint24)","function collectProtocolFees(address recipient,address currency,uint256 amount) returns (uint256)"]),E=["set_fee_recipient","set_fee_setter","set_owner","enable_fee","set_pool_fee","collect_protocol","set_controller"],R={version:{type:"string",enum:["v2","v3","v4"]},operation:{type:"string",enum:E},target:_,token0:_,token1:_,fee:{type:"integer"},tickSpacing:{type:"integer"},fee0:{type:"integer"},fee1:{type:"integer"},currency:_,amount:b(),amount0Max:b(),amount1Max:b(),poolKey:{type:"object"}};function L(w){let x=async e=>{let i=w.clientFor(y);if(e==="v2"){let[o,t]=await Promise.all([i.readContract({address:h,abi:n,functionName:"feeToSetter"}),i.readContract({address:h,abi:n,functionName:"feeTo"})]);return{version:e,contract:h,owner:o,feeRecipient:t}}if(e==="v3")return{version:e,contract:k.factory,owner:await i.readContract({address:k.factory,abi:n,functionName:"owner"})};if(e==="v4"){let[o,t]=await Promise.all([i.readContract({address:g,abi:n,functionName:"owner"}),i.readContract({address:g,abi:n,functionName:"protocolFeeController"})]);return{version:e,contract:g,owner:o,controller:t}}throw new l("Provide protocol version v2, v3 or v4.")};return{tools:[{name:"uniswap_protocol_status",inputSchema:{type:"object",additionalProperties:!1,required:["version"],properties:{version:R.version}},async execute(e){return A(e,["version"]),x(e.version)}},{name:"uniswap_protocol_admin",inputSchema:{type:"object",additionalProperties:!1,required:["version","operation"],properties:R},async execute(e,i){let{version:o,operation:t}=e,v=await x(o),K=w.clientFor(y),C=o==="v4"&&["set_pool_fee","collect_protocol"].includes(String(t))?"controller"in v?v.controller:void 0:v.owner;if(!C||!T(C,i))throw new l("The signing wallet does not hold the required Uniswap owner/controller role.");let N=v.contract,s,a,F=()=>{let r=f(e.target);if(r===I)throw new l("Administration target must be nonzero.");return r},u=(r,d,p,m)=>{if(typeof r!="number"||!Number.isInteger(r)||r<p||r>m)throw new l(`${d} must be an integer from ${p} to ${m}.`);return r};if(o==="v2"&&t==="set_fee_recipient")a=["target"],s=c({abi:n,functionName:"setFeeTo",args:[f(e.target)]});else if(o==="v2"&&t==="set_fee_setter")a=["target"],s=c({abi:n,functionName:"setFeeToSetter",args:[F()]});else if(o==="v3"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"setOwner",args:[F()]});else if(o==="v3"&&t==="enable_fee")a=["fee","tickSpacing"],s=c({abi:n,functionName:"enableFeeAmount",args:[u(e.fee,"fee",0,999999),u(e.tickSpacing,"tickSpacing",1,16383)]});else if(o==="v3"&&["set_pool_fee","collect_protocol"].includes(String(t))){a=["token0","token1","fee",...t==="set_pool_fee"?["fee0","fee1"]:["amount0Max","amount1Max"]];let r=f(e.token0),d=f(e.token1),p=u(e.fee,"fee",0,999999);if(N=await K.readContract({address:k.factory,abi:V,functionName:"getPool",args:[r,d,p]}),N===I)throw new l("No factory-verified v3 pool exists for these tokens and fee.");if(t==="set_pool_fee"){let m=$=>{let S=u($,"fee divisor",0,10);if(S!==0&&S<4)throw new l("V3 protocol fee divisors must be zero or 4 through 10.");return S};s=c({abi:n,functionName:"setFeeProtocol",args:[m(e.fee0),m(e.fee1)]})}else s=c({abi:n,functionName:"collectProtocol",args:[i,P(e.amount0Max,"amount0Max",128,!0),P(e.amount1Max,"amount1Max",128,!0)]})}else if(o==="v4"&&t==="set_owner")a=["target"],s=c({abi:n,functionName:"transferOwnership",args:[F()]});else if(o==="v4"&&t==="set_controller")a=["target"],s=c({abi:n,functionName:"setProtocolFeeController",args:[f(e.target)]});else if(o==="v4"&&t==="set_pool_fee"){a=["poolKey","fee0","fee1"];let r=M(e.poolKey),d=u(e.fee0,"fee0 pips",0,1e3),p=u(e.fee1,"fee1 pips",0,1e3);s=c({abi:n,functionName:"setProtocolFee",args:[r,d+(p<<12)]})}else if(o==="v4"&&t==="collect_protocol")a=["currency","amount"],s=c({abi:n,functionName:"collectProtocolFees",args:[i,f(e.currency),P(e.amount,"amount",256,!0)]});else throw new l("This operation is not supported by the selected Uniswap protocol version.");return A(e,["version","operation",...a]),O(w,[w.unsignedTx({to:N,data:s,value:"0",chainId:y,description:`Uniswap ${o} protocol administration: ${t}. Role holder ${i}.`})],i,"Privileged protocol operation. Review the exact role/recipient/fee changes. Protocol fee collections pay the signing wallet; no wallet token approval is required.")}}]}}export{n as a,L as b};
|