@oakagentkit/core 0.3.5 → 0.3.7
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 +14 -0
- package/build/dist/api/addresses.js +1 -1
- package/build/dist/api/chain.js +1 -1
- package/build/dist/api/history.d.ts +2 -0
- 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/borro/actions.js +1 -1
- package/build/dist/api/modules/borro/index.js +1 -1
- package/build/dist/api/modules/borro/liquidity.js +1 -1
- package/build/dist/api/modules/borro/positions.js +1 -1
- package/build/dist/api/modules/borro/reader.js +1 -1
- package/build/dist/api/modules/chop/display.js +1 -1
- package/build/dist/api/modules/chop/guard.js +1 -1
- package/build/dist/api/modules/chop/index.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/earn/index.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/thesis.js +1 -1
- package/build/dist/api/modules/erc8004/validation.js +1 -1
- package/build/dist/api/modules/fobo/index.js +1 -1
- package/build/dist/api/modules/fobo/intent.js +1 -1
- package/build/dist/api/modules/fobo/steps.js +1 -1
- package/build/dist/api/modules/fobo/verify.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
- 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 +39 -2
- 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 +14 -2
- package/build/dist/api/modules/hookr/agent-gate.js +1 -1
- package/build/dist/api/modules/hookr/agent-link.d.ts +17 -0
- package/build/dist/api/modules/hookr/agent-link.js +1 -0
- package/build/dist/api/modules/hookr/api-client.d.ts +9 -0
- package/build/dist/api/modules/hookr/api-client.js +1 -0
- package/build/dist/api/modules/hookr/blocks/advisory.d.ts +41 -0
- package/build/dist/api/modules/hookr/blocks/advisory.js +1 -0
- package/build/dist/api/modules/hookr/blocks/buy-sell-block.d.ts +7 -0
- package/build/dist/api/modules/hookr/blocks/buy-sell-block.js +1 -0
- package/build/dist/api/modules/hookr/blocks/core-settings.d.ts +6 -0
- package/build/dist/api/modules/hookr/blocks/core-settings.js +1 -0
- package/build/dist/api/modules/hookr/blocks/exit-clock.d.ts +14 -0
- package/build/dist/api/modules/hookr/blocks/exit-clock.js +1 -0
- package/build/dist/api/modules/hookr/blocks/holder-pot.d.ts +30 -0
- package/build/dist/api/modules/hookr/blocks/holder-pot.js +1 -0
- package/build/dist/api/modules/hookr/blocks/managed-fee.d.ts +96 -0
- package/build/dist/api/modules/hookr/blocks/managed-fee.js +1 -0
- package/build/dist/api/modules/hookr/blocks/market-guard.d.ts +116 -0
- package/build/dist/api/modules/hookr/blocks/market-guard.js +1 -0
- package/build/dist/api/modules/hookr/blocks/market-hours-fee.d.ts +87 -0
- package/build/dist/api/modules/hookr/blocks/market-hours-fee.js +1 -0
- package/build/dist/api/modules/hookr/blocks/pay-later.d.ts +199 -0
- package/build/dist/api/modules/hookr/blocks/pay-later.js +1 -0
- package/build/dist/api/modules/hookr/blocks/sandwich-guard.d.ts +3 -0
- package/build/dist/api/modules/hookr/blocks/sandwich-guard.js +1 -0
- package/build/dist/api/modules/hookr/blocks/storm-fee.d.ts +3 -0
- package/build/dist/api/modules/hookr/blocks/storm-fee.js +1 -0
- package/build/dist/api/modules/hookr/blocks/swap-cut.d.ts +3 -0
- package/build/dist/api/modules/hookr/blocks/swap-cut.js +1 -0
- package/build/dist/api/modules/hookr/blocks/swap-reward-mint.d.ts +125 -0
- package/build/dist/api/modules/hookr/blocks/swap-reward-mint.js +1 -0
- package/build/dist/api/modules/hookr/blocks/wallet-cap.d.ts +3 -0
- package/build/dist/api/modules/hookr/blocks/wallet-cap.js +1 -0
- package/build/dist/api/modules/hookr/blocks/zap-source.d.ts +161 -0
- package/build/dist/api/modules/hookr/blocks/zap-source.js +1 -0
- package/build/dist/api/modules/hookr/blocks/zap-target.d.ts +51 -0
- package/build/dist/api/modules/hookr/blocks/zap-target.js +1 -0
- package/build/dist/api/modules/hookr/claims.d.ts +53 -0
- package/build/dist/api/modules/hookr/claims.js +1 -0
- package/build/dist/api/modules/hookr/contracts.d.ts +3 -1
- package/build/dist/api/modules/hookr/contracts.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.d.ts +2 -2
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.d.ts +2 -0
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/gas.d.ts +48 -0
- package/build/dist/api/modules/hookr/gas.js +1 -0
- package/build/dist/api/modules/hookr/gates.d.ts +51 -0
- package/build/dist/api/modules/hookr/gates.js +1 -0
- package/build/dist/api/modules/hookr/hook-blocks.d.ts +304 -0
- package/build/dist/api/modules/hookr/hook-blocks.js +1 -0
- package/build/dist/api/modules/hookr/index.d.ts +4 -2
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/jobs.d.ts +7 -0
- package/build/dist/api/modules/hookr/jobs.js +1 -0
- package/build/dist/api/modules/hookr/launch-options.d.ts +52 -3
- package/build/dist/api/modules/hookr/launch-options.js +1 -1
- package/build/dist/api/modules/hookr/launch-profile.d.ts +8 -0
- package/build/dist/api/modules/hookr/launch-profile.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.d.ts +24 -0
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.d.ts +90 -2
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/pay-later-actions.d.ts +52 -0
- package/build/dist/api/modules/hookr/pay-later-actions.js +1 -0
- package/build/dist/api/modules/hookr/pins.d.ts +5 -0
- package/build/dist/api/modules/hookr/pins.js +1 -1
- package/build/dist/api/modules/hookr/pm-liquidity.d.ts +215 -0
- package/build/dist/api/modules/hookr/pm-liquidity.js +1 -0
- package/build/dist/api/modules/hookr/public-reads.d.ts +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/hookr/revenue.d.ts +4 -1
- package/build/dist/api/modules/hookr/revenue.js +1 -1
- package/build/dist/api/modules/hookr/scan.d.ts +25 -0
- package/build/dist/api/modules/hookr/scan.js +1 -0
- package/build/dist/api/modules/hookr/swap.d.ts +161 -0
- package/build/dist/api/modules/hookr/swap.js +1 -0
- 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/layerbank/abi.js +1 -1
- package/build/dist/api/modules/layerbank/actions.js +1 -1
- package/build/dist/api/modules/layerbank/checks.js +1 -1
- package/build/dist/api/modules/layerbank/index.js +1 -1
- package/build/dist/api/modules/layerbank/merkl.js +1 -1
- package/build/dist/api/modules/layerbank/reader.js +1 -1
- package/build/dist/api/modules/layerbank/reserve.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/merkl/stock-lp.d.ts +51 -0
- package/build/dist/api/modules/merkl/stock-lp.js +1 -0
- 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/orbio/positions.js +1 -1
- package/build/dist/api/modules/pendle/costs.js +1 -1
- package/build/dist/api/modules/pendle/index.js +1 -1
- package/build/dist/api/modules/pendle/markets.js +1 -1
- package/build/dist/api/modules/pendle/positions.js +1 -1
- package/build/dist/api/modules/pendle/pricecheck.js +1 -1
- package/build/dist/api/modules/pendle/reader.js +1 -1
- package/build/dist/api/modules/pendle/redeem.js +1 -1
- package/build/dist/api/modules/pendle/trade.js +1 -1
- package/build/dist/api/modules/pendle/validate.js +1 -1
- package/build/dist/api/modules/pendle/verify.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/holdings.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/raeto/index.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/quote-guard.js +1 -1
- package/build/dist/api/modules/uniswap/stock-prices.d.ts +25 -0
- package/build/dist/api/modules/uniswap/stock-prices.js +1 -1
- package/build/dist/api/modules/uniswap/stocks.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/upoch/index.js +1 -1
- package/build/dist/api/modules/upoch/reads.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.js +1 -1
- package/build/dist/api/modules/wormhole/scan-text.d.ts +1 -1
- 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/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.d.ts +2 -0
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.d.ts +9 -1
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.d.ts +1 -0
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/universal-router.js +1 -1
- package/build/dist/api/usd-estimate.js +1 -1
- package/build/dist/chunks/{DMDOSHV7.js → 266VIESP.js} +1 -1
- package/build/dist/chunks/{HFVXNKA5.js → 2BM2WX2G.js} +1 -1
- package/build/dist/chunks/{HDBZZOHJ.js → 2GYL3N2O.js} +1 -1
- package/build/dist/chunks/{OY5W7ZSL.js → 2H2OZE6X.js} +1 -1
- package/build/dist/chunks/{E76Z2TT4.js → 2QQ5CGQI.js} +1 -1
- package/build/dist/chunks/{4PLLS6CT.js → 2VYA6WIN.js} +1 -1
- package/build/dist/chunks/{FRT6AC6M.js → 2ZYFBBOE.js} +1 -1
- package/build/dist/chunks/{LCH6F5HT.js → 342OZP53.js} +1 -1
- package/build/dist/chunks/{XADHV2DT.js → 35DTANJW.js} +1 -1
- package/build/dist/chunks/{4IOHSX3Z.js → 37UBQQWL.js} +1 -1
- package/build/dist/chunks/3RGED2KO.js +1 -0
- package/build/dist/chunks/{4HQEJHCD.js → 3XIJCHT7.js} +1 -1
- package/build/dist/chunks/3XY44BP5.js +1 -0
- package/build/dist/chunks/3YNXQ3EZ.js +1 -0
- package/build/dist/chunks/{JDHPMS7X.js → 4JU23O3Z.js} +1 -1
- package/build/dist/chunks/{Y2QADJOB.js → 4P6DRKY3.js} +1 -1
- package/build/dist/chunks/{W3DGFMQE.js → 4RTXP2YP.js} +1 -1
- package/build/dist/chunks/{CNDIAF3P.js → 4WYTIM4T.js} +1 -1
- package/build/dist/chunks/{HPS4KOU4.js → 52AEVHKJ.js} +1 -1
- package/build/dist/chunks/{ZTKT3ZQK.js → 53VBLEYS.js} +1 -1
- package/build/dist/chunks/{ADIPEGNN.js → 5AO2QPWE.js} +1 -1
- package/build/dist/chunks/{GQITAJVF.js → 5BPFF7NX.js} +1 -1
- package/build/dist/chunks/5EQTOA5F.js +1 -0
- package/build/dist/chunks/{WAKZWSHB.js → 5KKAN7XQ.js} +1 -1
- package/build/dist/chunks/{VVAM3EAK.js → 5N6YJFFA.js} +1 -1
- package/build/dist/chunks/{QIB6OMQV.js → 5O67QQIY.js} +1 -1
- package/build/dist/chunks/{FAH7FKUT.js → 5UWVXEPD.js} +1 -1
- package/build/dist/chunks/{KKTOBXIT.js → 5VA66LFF.js} +1 -1
- package/build/dist/chunks/5VKVAUFQ.js +1 -0
- package/build/dist/chunks/5Y457HYC.js +1 -0
- package/build/dist/chunks/627SGCTU.js +1 -0
- package/build/dist/chunks/64LAWFBE.js +1 -0
- package/build/dist/chunks/{6F527FLN.js → 6HNQAYBM.js} +1 -1
- package/build/dist/chunks/{FUP53K6G.js → 6LDC5D2S.js} +1 -1
- package/build/dist/chunks/6RVAV6BB.js +1 -0
- package/build/dist/chunks/{WSILNJS2.js → 6STUQOFL.js} +1 -1
- package/build/dist/chunks/{4Z3IGMU6.js → 7AYP4ATZ.js} +1 -1
- package/build/dist/chunks/{YGW4ODAP.js → 7EPU3XGY.js} +1 -1
- package/build/dist/chunks/7GL547YZ.js +1 -0
- package/build/dist/chunks/{E47UYYK4.js → 7KK3OC7Q.js} +1 -1
- package/build/dist/chunks/{IZP3EKKS.js → 7PBCV7VS.js} +1 -1
- package/build/dist/chunks/{A3BJSQ23.js → 7VU5VCTL.js} +1 -1
- package/build/dist/chunks/{Z7FGEWO2.js → 7WXAS54T.js} +1 -1
- package/build/dist/chunks/{DRLBTB4E.js → A72ADVYF.js} +1 -1
- package/build/dist/chunks/{ANIF3JMV.js → AG66NM3J.js} +1 -1
- package/build/dist/chunks/AODUTN65.js +1 -0
- package/build/dist/chunks/{DBOGRUPS.js → AONO47JX.js} +1 -1
- package/build/dist/chunks/{2I7XHRTI.js → AOTTQPK7.js} +1 -1
- package/build/dist/chunks/{JTPHZCO3.js → AQJLEG6B.js} +1 -1
- package/build/dist/chunks/AZBTNUXF.js +1 -0
- package/build/dist/chunks/B4U43D5Z.js +1 -0
- package/build/dist/chunks/B5B7U3NZ.js +1 -0
- package/build/dist/chunks/{ZX43P4BK.js → B75SS7H6.js} +1 -1
- package/build/dist/chunks/{GBIBRYOV.js → B7HVPHSS.js} +1 -1
- package/build/dist/chunks/{LT5P6PZW.js → B7WZJHIJ.js} +1 -1
- package/build/dist/chunks/{3A2IKFTV.js → BIFANUTV.js} +1 -1
- package/build/dist/chunks/BM4KHOFB.js +1 -0
- package/build/dist/chunks/{ZVY7GGSP.js → BW755PNH.js} +1 -1
- package/build/dist/chunks/{VXCGMALF.js → BWE5PXRE.js} +1 -1
- package/build/dist/chunks/{7U62MMUQ.js → BY2OWKZB.js} +1 -1
- package/build/dist/chunks/{F7MGYRPU.js → CCPG6PRL.js} +1 -1
- package/build/dist/chunks/{OI3N4EW4.js → CG7ABZXH.js} +1 -1
- package/build/dist/chunks/{S37D7HOK.js → CITHH7NK.js} +1 -1
- package/build/dist/chunks/CJMVRV34.js +1 -0
- package/build/dist/chunks/{JJSCDDQO.js → CLHA557R.js} +1 -1
- package/build/dist/chunks/CQPIR6ER.js +1 -0
- package/build/dist/chunks/{MI5HZDMH.js → D6JOXK7Q.js} +1 -1
- package/build/dist/chunks/{IZFED3R2.js → DLNDJZR4.js} +1 -1
- package/build/dist/chunks/{UUF4Z6K6.js → DUTAMN3F.js} +1 -1
- package/build/dist/chunks/{NMJVQX5M.js → DWRRIFXS.js} +1 -1
- package/build/dist/chunks/{3ZH5SOC2.js → EFOC337C.js} +1 -1
- package/build/dist/chunks/{2PS4GCOZ.js → EKHNXPWO.js} +1 -1
- package/build/dist/chunks/EWZFZUVF.js +1 -0
- package/build/dist/chunks/EXKV6QJD.js +1 -0
- package/build/dist/chunks/{OB7BFDOV.js → EYE3ZAJB.js} +1 -1
- package/build/dist/chunks/{MQ5F2VOK.js → EZUQMTLE.js} +1 -1
- package/build/dist/chunks/FMEO7RX7.js +1 -0
- package/build/dist/chunks/{ZQPC54J5.js → FYWK3UK6.js} +1 -1
- package/build/dist/chunks/G53U6Y4L.js +1 -0
- package/build/dist/chunks/{O5QTITN6.js → GRHBE4MQ.js} +1 -1
- package/build/dist/chunks/GV6FZ6UG.js +1 -0
- package/build/dist/chunks/GV6Z3MET.js +1 -0
- package/build/dist/chunks/{GK3D7OKG.js → GVCNTGLC.js} +1 -1
- package/build/dist/chunks/H5J2LFPZ.js +1 -0
- package/build/dist/chunks/{DCGNVMKG.js → HC3QFA5I.js} +1 -1
- package/build/dist/chunks/{C76D54YG.js → HGSFRN57.js} +1 -1
- package/build/dist/chunks/HJI7KO6F.js +1 -0
- package/build/dist/chunks/{G5AMH4IP.js → HN5RBTNE.js} +1 -1
- package/build/dist/chunks/{MSRCJ2BS.js → HPBTSJW7.js} +1 -1
- package/build/dist/chunks/HPO673QQ.js +1 -0
- package/build/dist/chunks/{C57DITTF.js → HTOP2OKU.js} +1 -1
- package/build/dist/chunks/{DGDMRATN.js → ICHT3H3W.js} +1 -1
- package/build/dist/chunks/IJVBCEA2.js +1 -0
- package/build/dist/chunks/ILTGXU6G.js +1 -0
- package/build/dist/chunks/{I4473OC6.js → IMD33NQS.js} +1 -1
- package/build/dist/chunks/{X24YTJST.js → IY7FWTAL.js} +1 -1
- package/build/dist/chunks/{TOIKOIY6.js → J5624CVF.js} +1 -1
- package/build/dist/chunks/JCS24YBB.js +1 -0
- package/build/dist/chunks/JFYC2LVI.js +1 -0
- package/build/dist/chunks/JQVTHPUO.js +1 -0
- package/build/dist/chunks/{TGXEKBLV.js → JUVY6PCR.js} +1 -1
- package/build/dist/chunks/JYED2PZ3.js +1 -0
- package/build/dist/chunks/{KO7ANIKY.js → K3HCSCXE.js} +1 -1
- package/build/dist/chunks/{7VH6JQ2H.js → K5C6QBOO.js} +1 -1
- package/build/dist/chunks/{W7BFM6CK.js → KAXLZJU6.js} +1 -1
- package/build/dist/chunks/{YW4W3LPQ.js → KHLM6NIZ.js} +1 -1
- package/build/dist/chunks/{OIQTZOBN.js → KKGHXNM4.js} +1 -1
- package/build/dist/chunks/{TZ7S5KRB.js → KW5LJGNY.js} +1 -1
- package/build/dist/chunks/{SUNTJ6IU.js → KYANIEPX.js} +1 -1
- package/build/dist/chunks/{ZZ6FZGHF.js → L4UFGM7M.js} +1 -1
- package/build/dist/chunks/{YWVPK3DV.js → L76P6WIH.js} +1 -1
- package/build/dist/chunks/{QMNUB2GM.js → LBT6WR4U.js} +1 -1
- package/build/dist/chunks/LD3A2KLN.js +1 -0
- package/build/dist/chunks/{WRUTW6CG.js → LFSNAQ7V.js} +1 -1
- package/build/dist/chunks/LHC2YV2U.js +1 -0
- package/build/dist/chunks/{R66NSNNQ.js → LHVGWNMW.js} +1 -1
- package/build/dist/chunks/{RUHNLNVX.js → LOH6LUVT.js} +1 -1
- package/build/dist/chunks/{23HNDJ76.js → M2SWILNG.js} +1 -1
- package/build/dist/chunks/{IT2JLILU.js → MFKDNAHB.js} +1 -1
- package/build/dist/chunks/MFQTBUSD.js +1 -0
- package/build/dist/chunks/MFRKZOU4.js +1 -0
- package/build/dist/chunks/{V4UJMUIB.js → MLN5KTG7.js} +1 -1
- package/build/dist/chunks/{TJU644I7.js → MSIT5Q3M.js} +1 -1
- package/build/dist/chunks/{S4JUFCT4.js → MSQNOK3I.js} +1 -1
- package/build/dist/chunks/NCCKCGKL.js +1 -0
- package/build/dist/chunks/NGHRUNXO.js +1 -0
- package/build/dist/chunks/{N65J3L2H.js → NIGRNLNM.js} +1 -1
- package/build/dist/chunks/{DXAPKN7H.js → NLC36QHL.js} +1 -1
- package/build/dist/chunks/NUTTPUYJ.js +1 -0
- package/build/dist/chunks/{QMIH6HXH.js → NWW6GY5E.js} +1 -1
- package/build/dist/chunks/{O4S6XAYV.js → O7L55XM3.js} +1 -1
- package/build/dist/chunks/{NAO7VWZF.js → OCIEVYPR.js} +1 -1
- package/build/dist/chunks/{4NBXBKOX.js → OD7CY6BY.js} +1 -1
- package/build/dist/chunks/{RUTSEGGD.js → OHZHQSCA.js} +1 -1
- package/build/dist/chunks/{A4K5GXVO.js → ORKXBYVC.js} +1 -1
- package/build/dist/chunks/OUXPOFY2.js +1 -0
- package/build/dist/chunks/{NIWAVMDR.js → OWHXYE2G.js} +1 -1
- package/build/dist/chunks/PD5NXIRT.js +1 -0
- package/build/dist/chunks/{TXGZ6NWN.js → PG7HZIZL.js} +1 -1
- package/build/dist/chunks/PLEJPTTK.js +1 -0
- package/build/dist/chunks/{VREGY7E6.js → PMFR47H3.js} +1 -1
- package/build/dist/chunks/{ZXRIJG6H.js → PX2G2H6G.js} +1 -1
- package/build/dist/chunks/QAAKUIWE.js +1 -0
- package/build/dist/chunks/{YXXK6EPI.js → QBHY2QRC.js} +1 -1
- package/build/dist/chunks/{WQ2XTDHO.js → QCPJZBEO.js} +1 -1
- package/build/dist/chunks/{ELHRXA5U.js → QFK335LC.js} +1 -1
- package/build/dist/chunks/{3PHJUFU2.js → QFUSCK5C.js} +1 -1
- package/build/dist/chunks/QGO4EKXZ.js +1 -0
- package/build/dist/chunks/{IPU656WB.js → QKH7ED6B.js} +1 -1
- package/build/dist/chunks/{XW3VGWXK.js → QMWHQRYC.js} +1 -1
- package/build/dist/chunks/{USGMGKAG.js → QXBQ7WPB.js} +1 -1
- package/build/dist/chunks/{MQXSCNUL.js → R5UOFPDO.js} +1 -1
- package/build/dist/chunks/{MDLJFCT4.js → R5Z4HPCA.js} +1 -1
- package/build/dist/chunks/{A4FLWHLP.js → REXGROOD.js} +1 -1
- package/build/dist/chunks/RKJFSDGV.js +1 -0
- package/build/dist/chunks/RKS3M7L5.js +1 -0
- package/build/dist/chunks/{GDOHHXNH.js → RLX6YTNT.js} +1 -1
- package/build/dist/chunks/{PV7FEVBD.js → RWEA4SWP.js} +1 -1
- package/build/dist/chunks/{ZKBOPZH5.js → RWUF6T4I.js} +1 -1
- package/build/dist/chunks/{USEF3QKG.js → S432S6NA.js} +1 -1
- package/build/dist/chunks/{XTXXWRN2.js → SDDYM2H3.js} +1 -1
- package/build/dist/chunks/{2OVJ2BTJ.js → SEXKWYUM.js} +1 -1
- package/build/dist/chunks/TKJ4GFUP.js +1 -0
- package/build/dist/chunks/{BSX4LFYI.js → TNHU5UBQ.js} +1 -1
- package/build/dist/chunks/{PDPTJMTJ.js → TT2ST3Q3.js} +1 -1
- package/build/dist/chunks/TTBB6EFN.js +1 -0
- package/build/dist/chunks/{OVM4QIET.js → U4MSIH4G.js} +1 -1
- package/build/dist/chunks/{LKUZAJPZ.js → UCMOQAVD.js} +1 -1
- package/build/dist/chunks/{OB3YMTDI.js → UIVOYAO2.js} +1 -1
- package/build/dist/chunks/{3YH5B5NQ.js → UL4DY6GX.js} +1 -1
- package/build/dist/chunks/{XRDLMTBJ.js → UMY6SP7C.js} +1 -1
- package/build/dist/chunks/UNBRUWSV.js +1 -0
- package/build/dist/chunks/{LGLWEGPY.js → UPX3OWKA.js} +1 -1
- package/build/dist/chunks/{MJGEGNDU.js → UYYYSFMQ.js} +1 -1
- package/build/dist/chunks/{4RCYYN6O.js → V7HTGO23.js} +1 -1
- package/build/dist/chunks/{O2QBSINK.js → V7P4PCLL.js} +1 -1
- package/build/dist/chunks/{FRVCSDKU.js → VMSGNN3D.js} +1 -1
- package/build/dist/chunks/VQMBPY2P.js +1 -0
- package/build/dist/chunks/{HZSYMGJ2.js → VS7ZA4OF.js} +1 -1
- package/build/dist/chunks/{BJ2U2VXJ.js → VTWAVH74.js} +1 -1
- package/build/dist/chunks/W3M4KAPX.js +1 -0
- package/build/dist/chunks/{LZM3DO5Q.js → W5GWK72I.js} +1 -1
- package/build/dist/chunks/{65OITTDL.js → W73SLWBT.js} +1 -1
- package/build/dist/chunks/{2FOI2625.js → W7BTXU3F.js} +1 -1
- package/build/dist/chunks/{6LVHN33V.js → WADRRW3E.js} +1 -1
- package/build/dist/chunks/{ZXFJKW6H.js → WG7PMGTJ.js} +1 -1
- package/build/dist/chunks/{N742W5KX.js → WRNPYW47.js} +1 -1
- package/build/dist/chunks/{XL3W7DAQ.js → X3BB6WME.js} +1 -1
- package/build/dist/chunks/{SX5YNFHG.js → XD4JA43O.js} +1 -1
- package/build/dist/chunks/{GBPB7JIB.js → XSQJOOEY.js} +1 -1
- package/build/dist/chunks/{3BQ5XHDJ.js → Y7SKGRWC.js} +1 -1
- package/build/dist/chunks/{R73R4KN3.js → YBLJ2MCR.js} +1 -1
- package/build/dist/chunks/{6CKCZJ3F.js → YDJHXSS7.js} +1 -1
- package/build/dist/chunks/{GKUPC4DO.js → YLU5JVRI.js} +1 -1
- package/build/dist/chunks/YR6Y6UIR.js +1 -0
- package/build/dist/chunks/{FHB7QYJO.js → Z5WRTISY.js} +1 -1
- package/build/dist/chunks/ZB67QDN2.js +1 -0
- package/build/dist/chunks/{O4P5IQCP.js → ZRG34Y7Q.js} +1 -1
- package/build/dist/chunks/ZSGW2ZSO.js +1 -0
- package/build/dist/chunks/{HRAHGYNK.js → ZTNBX4VH.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/5H7NVE6O.js +0 -1
- package/build/dist/chunks/7OOCAZBE.js +0 -1
- package/build/dist/chunks/7TRO6MBQ.js +0 -1
- package/build/dist/chunks/DFM4T6ZE.js +0 -1
- package/build/dist/chunks/FCVH4FYH.js +0 -1
- package/build/dist/chunks/GDUKZYE2.js +0 -1
- package/build/dist/chunks/GYPMUYB5.js +0 -1
- package/build/dist/chunks/J7OZLXSG.js +0 -1
- package/build/dist/chunks/JFC2QCMW.js +0 -1
- package/build/dist/chunks/M267JEDO.js +0 -1
- package/build/dist/chunks/M6JNGU4E.js +0 -1
- package/build/dist/chunks/M7OVMIIE.js +0 -1
- package/build/dist/chunks/MQK6OP7S.js +0 -1
- package/build/dist/chunks/N624NR7Y.js +0 -1
- package/build/dist/chunks/OSMOBKRQ.js +0 -1
- package/build/dist/chunks/Q3Q3YHEX.js +0 -1
- package/build/dist/chunks/QBNASL3T.js +0 -1
- package/build/dist/chunks/QQD4PV64.js +0 -1
- package/build/dist/chunks/RN3WUJIO.js +0 -1
- package/build/dist/chunks/RP5VCG54.js +0 -1
- package/build/dist/chunks/TI727O2H.js +0 -1
- package/build/dist/chunks/UHIJMDD2.js +0 -1
- package/build/dist/chunks/W32UECOL.js +0 -1
- package/build/dist/chunks/WWNAGOCD.js +0 -1
- package/build/dist/chunks/XWC6IC5E.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as le,o as K}from"./GYPMUYB5.js";import{b as x}from"./66F5ZH34.js";import{c as W,f as de,h as g,i as ce,l as ue}from"./NWNYJ26T.js";import{b as k,j as oe,k as G}from"./TI727O2H.js";import{a as N}from"./XSD5NL7J.js";import{a as F}from"./JXOEJPJ4.js";import{randomBytes as ye,randomUUID as he}from"node:crypto";import{isDeepStrictEqual as pe}from"node:util";import{decodeFunctionData as me,encodeAbiParameters as ne,erc20Abi as J,keccak256 as ie,parseAbi as re,parseAbiParameters as ae,toEventSelector as be,zeroAddress as L}from"viem";var se=oe[k].meridian,Q=se.PredictionMarketEscrow.address,V=se.SecondaryMarketEscrow.address,$={address:se.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},we="wss://relayer.predict.meridian.xyz/auction",ke=ae("(address conditionResolver,bytes conditionId,uint8 predictedOutcome)[]"),Ie=ae("bytes32,uint256,uint256,address,address,address,bytes"),Se=ae("address,address,address,address,uint256,uint256"),X=re(["function isNonceUsed(address,uint256) view returns (bool)"]),Be=re(["function mint(((address conditionResolver,bytes conditionId,uint8 predictedOutcome)[] picks,uint256 predictorCollateral,uint256 counterpartyCollateral,address predictor,address counterparty,uint256 predictorNonce,uint256 counterpartyNonce,uint256 predictorDeadline,uint256 counterpartyDeadline,bytes predictorSignature,bytes counterpartySignature,bytes32 refCode,bytes predictorSessionKeyData,bytes counterpartySessionKeyData,address predictorSponsor,bytes predictorSponsorData) request)"]),Me=re(["function executeTrade((address token,address collateral,address seller,address buyer,uint256 tokenAmount,uint256 price,uint256 sellerNonce,uint256 buyerNonce,uint256 sellerDeadline,uint256 buyerDeadline,bytes sellerSignature,bytes buyerSignature,bytes32 refCode,bytes sellerSessionKeyData,bytes buyerSessionKeyData) request)"]),$e=be("Transfer(address,address,uint256)"),Ce=[{name:"predictionHash",type:"bytes32"},{name:"signer",type:"address"},{name:"collateral",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],ve=[{name:"tradeHash",type:"bytes32"},{name:"signer",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}];function i(n){throw new N(n)}function _(n){return de(n,"Meridian returned an invalid exchange object.")}function M(n,t,d=!1){return d&&typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&(n=String(n)),(typeof n!="string"||!/^\d+$/.test(n)||BigInt(n)>=1n<<256n)&&i(`Provide ${t} as a decimal base-unit integer string.`),n}function O(n){let t=Number(n);return(!Number.isSafeInteger(t)||t<0||BigInt(t)!==BigInt(n))&&i("Meridian signing terms cannot be represented exactly as JSON numbers."),t}function R(n){let t="Provide a nonzero token, resolver or wallet address.";return ue(ce(n,t),t)}function Z(n,t){return(typeof n!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n)||t!==void 0&&n.length!==2+t*2)&&i("Meridian returned invalid hexadecimal data."),n}function A(n){return(typeof n!="string"||n.length===0||n.length>256)&&i("Meridian returned an invalid exchange identifier."),n}function j(){return BigInt(Math.floor(Date.now()/1e3))}function Ae(n,t){let d=n==="buy"?["picks","stake","minCounterpartyCollateral","usdgAmountIn","slippageBps","continuation","signature"]:["token","amount","minPrice","slippageBps","continuation","signature"];Object.keys(t).some(S=>!d.includes(S))&&i("Unsupported Meridian arguments; use the tool input schema."),t.slippageBps!==void 0&&(typeof t.slippageBps!="number"||!Number.isInteger(t.slippageBps)||t.slippageBps<0||t.slippageBps>=1e4)&&i("Slippage must be an integer from 0 to 9999 basis points.");let c=t.slippageBps;if(n==="sell"){let S=M(t.amount,"the position amount");BigInt(S)===0n&&i("The position amount must be positive.");let B=R(t.token);(g(B,$.address)||g(B,G))&&i("Choose a Meridian position token to sell.");let C;if(t.minPrice!==void 0){let e=M(t.minPrice,"the minimum sale price");BigInt(e)<=1n&&i("The minimum sale price must be greater than 1 base unit."),C=e}else{let e=BigInt(S)/100n>10n**18n?BigInt(S)/100n:10n**18n;C=c===void 0?e.toString():K(e.toString(),c)}return{side:n,token:B,amount:S,minPrice:C,priceFloorSource:t.minPrice===void 0?"default":"explicit",...c===void 0?{}:{slippageBps:c}}}(!Array.isArray(t.picks)||t.picks.length<1||t.picks.length>10)&&i("Provide between one and ten Meridian picks.");let m=t.picks.map(S=>{let B=_(S);return(Object.keys(B).some(C=>!["conditionResolver","conditionId","predictedOutcome"].includes(C))||B.predictedOutcome!==0&&B.predictedOutcome!==1)&&i("Each pick needs a resolver, condition ID and outcome 0 or 1."),{conditionResolver:R(B.conditionResolver),conditionId:Z(B.conditionId),predictedOutcome:B.predictedOutcome}}).sort((S,B)=>{let C=`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}:${S.predictedOutcome}`,e=`${B.conditionResolver.toLowerCase()}:${B.conditionId.toLowerCase()}:${B.predictedOutcome}`;return C<e?-1:C>e?1:0}),y=m.map(S=>`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}`);new Set(y).size!==m.length&&i("Do not repeat a condition in the same prediction.");let l=M(t.stake,"the USDe stake");BigInt(l)<10n**18n&&i("Meridian requires a stake of at least 1 USDe.");let I=t.usdgAmountIn===void 0?void 0:M(t.usdgAmountIn,"the USDG swap amount");I!==void 0&&BigInt(I)===0n&&i("The USDG swap amount must be positive.");let D=t.minCounterpartyCollateral!==void 0?M(t.minCounterpartyCollateral,"the minimum counterparty collateral"):K(l,c??le);return BigInt(D)<=1n&&i("The minimum counterparty collateral must be greater than 1 base unit."),{side:n,picks:m,stake:l,minCounterpartyCollateral:D,...I===void 0?{}:{usdgAmountIn:I},...c===void 0?{}:{slippageBps:c}}}var ee=class{constructor(t,d){this.id=t;this.prefix=d;this.socket=new globalThis.WebSocket(we),this.socket.addEventListener("open",()=>{this.opened=!0,this.notify?.()}),this.socket.addEventListener("close",()=>this.stop("Meridian exchange socket was lost. Start a fresh auction.")),this.socket.addEventListener("error",()=>this.stop("Meridian exchange socket failed. Start a fresh auction.")),this.socket.addEventListener("message",c=>{try{(typeof c.data!="string"||c.data.length>65536)&&i("Meridian returned a malformed exchange message.");let m=_(JSON.parse(c.data));if(m.type==="pong")return;let y=A(m.type),l=_(m.payload);if(y==="error"&&i("Meridian rejected or failed the exchange. Start a fresh auction."),y===`${d}.ack`){this.auctionId===void 0?((l.id!==t||this.accepting||l.accepted!==void 0)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected the exchange: ${F(A(l.error))}.`),this.auctionId=A(l.auctionId)):((!this.accepting||l.auctionId!==this.auctionId||l.id!==void 0&&l.id!==t)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected acceptance: ${F(A(l.error))}.`),l.accepted!==!0&&i("Meridian rejected acceptance of the exchange."));return}if((!y.startsWith(`${d}.`)||l.auctionId!==this.auctionId||!this.auctionId)&&i("Meridian returned a message for a different exchange."),["error","rejected","failed","expired"].some(I=>y===`${d}.${I}`)){let I=["reason","makerReason"].flatMap(D=>l[D]===void 0?[]:[`${D}=${F(A(l[D]))}`]);i(`Meridian exchange ${y.slice(d.length+1)}${I.length?`: ${I.join("; ")}`:""}. Start a fresh auction.`)}if((y===`${d}.pending`||y===`${d}.filled`)&&!this.accepting&&i("Meridian returned settlement before acceptance."),y===`${d}.pending`)return;this.queue.length>=16&&i("Meridian returned too many exchange messages."),this.queue.push({type:y,payload:l}),this.notify?.()}catch(m){this.stop(m instanceof N?m.message:"Meridian rejected or returned an invalid exchange message. Start a fresh auction.")}})}id;prefix;socket;queue=[];notify;error;auctionId;accepting=!1;opened=!1;check(){if(this.error)throw this.error;this.socket.readyState>1&&i("Meridian exchange socket was lost. Start a fresh auction.")}stop(t){this.error??=new N(t),this.notify?.(),this.socket.readyState<2&&this.socket.close()}async wait(t,d=3e4){return new Promise((c,m)=>{let y=setTimeout(()=>this.stop("Meridian exchange timed out. Start a fresh auction."),d),l=()=>{try{if(this.check(),t===void 0?!this.opened:!this.queue.length)return;let I=t===void 0?void 0:this.queue.shift();I&&I.type!==`${this.prefix}.${t}`&&i("Meridian returned an unexpected exchange stage."),clearTimeout(y),this.notify=void 0,c(I?.payload??{})}catch(I){clearTimeout(y),this.notify=void 0,m(I)}};this.notify=l,l()})}send(t,d){this.check(),this.socket.readyState!==1&&i("Meridian exchange socket is not open."),t==="accept"&&(this.accepting=!0),this.socket.send(JSON.stringify({...t==="start"?{id:this.id}:{},type:`${this.prefix}.${t}`,payload:d}))}};function te(n){return ie(ne(ke,[n]))}function De(n,t,d){return ie(ne(Ie,[te(n.picks),BigInt(n.stake),BigInt(d.counterpartyCollateral),t,d.counterparty,L,"0x"]))}function Pe(n,t,d,c){return ie(ne(Se,[n.token,$.address,t,d,BigInt(n.amount),BigInt(c)]))}function Y(n,t){let{input:d,wallet:c,nonce:m,deadline:y}=n,l={name:d.side==="buy"?"PredictionMarketEscrow":"SecondaryMarketEscrow",version:"1",chainId:k,verifyingContract:n.continuation.escrowContract};return(!m||!y)&&i("Meridian exchange is missing its signing terms."),d.side==="buy"?(t||i("Meridian has not returned a winning bid."),{domain:l,primaryType:"MintApproval",types:{MintApproval:Ce},message:{predictionHash:De(d,c,t),signer:c,collateral:d.stake,nonce:m,deadline:y}}):{domain:l,primaryType:"TradeApproval",types:{TradeApproval:ve},message:{tradeHash:Pe(d,c,t?t.buyer:L,t?t.price:"0"),signer:c,nonce:m,deadline:y}}}function fe(n){let t=[BigInt(n.deadline)],d=n.continuation;if(d.stage==="primary_accept"||d.stage==="secondary_accept"){t.push(BigInt(d.acceptDeadline));let c=d.winningBid;d.stage==="primary_accept"&&t.push(BigInt(c.counterpartyDeadline)),c.buyerDeadline!==void 0&&t.push(BigInt(M(c.buyerDeadline,"the buyer deadline",!0)))}return t.reduce((c,m)=>c<m?c:m)}function H(n){n.channel?.check(),n.deadline&&j()>=fe(n)&&i("Meridian exchange expired. Start a fresh auction.")}var Fe=n=>{let t=new Map;function d(e){clearTimeout(e.timer),t.delete(e.continuation.requestId),e.channel?.stop("Meridian exchange is closed or expired. Start a fresh auction.")}function c(e,a){clearTimeout(e.timer),e.timer=setTimeout(()=>d(e),a),e.timer.unref?.()}function m(e){let{wallet:a,chainId:s,escrowContract:f,requestId:u}=e.continuation;return{wallet:a,chainId:s,escrowContract:f,requestId:u}}function y(e){return e.side!=="sell"?"":` Effective minimum sale proceeds: ${e.minPrice} USDe base units (${$.address}, 18 decimals). ${e.priceFloorSource==="explicit"?"Caller minPrice is unchanged; slippageBps does not reduce this floor.":`Default floor with ${e.slippageBps??0} bps slippage applied.`}`}async function l(e){let{input:a,wallet:s}=e,f=n.clientFor(k),u=a.side==="buy"?$.address:a.token,r=a.side==="buy"?a.stake:a.amount,[h,w]=await Promise.all([f.readContract({address:u,abi:J,functionName:"balanceOf",args:[s]}),f.readContract({address:u,abi:J,functionName:"allowance",args:[s,e.continuation.escrowContract]})]);if(a.side==="sell"&&await f.readContract({address:u,abi:J,functionName:"decimals"})!==18&&i("Meridian position tokens must have 18 decimals."),h>=BigInt(r)&&w>=BigInt(r))return;(e.continuation.stage==="primary_accept"||e.continuation.stage==="secondary_accept")&&i("Meridian prerequisites changed during the auction. Start a fresh auction after funding and approval.");let p,v;if(h<BigInt(r)){a.side==="sell"&&i("The wallet does not have enough position tokens to sell."),a.usdgAmountIn||i("Not enough USDe. Provide usdgAmountIn in USDG base units to quote a swap before the auction.");let b=await n.quoteSwap({from:G,to:$.address,amountIn:a.usdgAmountIn,...a.slippageBps===void 0?{}:{slippageBps:a.slippageBps}},s);(j()>=BigInt(M(b.expiresAt,"the swap expiry"))||BigInt(M(b.minAmountOut,"the swap minimum"))+h<BigInt(r))&&i("The USDG swap minimum does not cover the USDe stake, or the quote expired. Request a fresh quote with sufficient input.");let o=await n.buildSwap(b.quoteId,s);(!("txs"in o)||!o.txs.length)&&i("The swap coordinator did not return prerequisite transactions."),p=o.txs,v=`${o.summary} Minimum USDe output: ${b.minAmountOut} base units (18 decimals).`}else p=[n.approval(u,e.continuation.escrowContract,r,k)],v=`Approve exactly ${r} base units (18 decimals) of ${u} for ${e.continuation.escrowContract} on chain ${k}.`;p.some(b=>b.chainId!==k)&&i("Meridian prerequisite transactions must use chain 4663.");let P=await n.preview(p,s),T=P.changes.map(b=>{let o=b.amount.startsWith("-");return`${o?"-":"+"}${n.formatAmount(o?b.amount.slice(1):b.amount,b.token.decimals)} ${b.token.symbol} (${b.token.address}, chain ${b.token.chainId}, ${b.token.decimals} decimals)`}).join("; ");return e.channel?.stop("Meridian prerequisites must be mined before the auction."),e.channel=void 0,e.deadline=void 0,e.nonce=void 0,e.continuation={...m(e),stage:"prerequisites"},{steps:p.map(b=>({kind:"tx",tx:b})),continuation:structuredClone(e.continuation),summary:`${v}${y(a)} ${P.summary} ${T}. Mine these prerequisites before continuing; no RFQ has started.`}}function I(e){let a=e.continuation;a.stage==="prerequisites"&&i("Meridian prerequisites need to finish before signing."),H(e),c(e,Number(fe(e)-j())*1e3);let s=e.input,f=s.side==="buy"?`Stake ${s.stake} base units of USDe (${$.address}, 18 decimals)`:`Sell ${s.amount} base units of position ${s.token} (18 decimals)`,u=a.stage==="secondary_start"?"Initial buyer-zero, price-zero intent only.":a.stage==="primary_accept"?`Counterparty ${a.winningBid.counterparty}; counterparty collateral ${a.winningBid.counterpartyCollateral} USDe base units; counterparty deadline ${a.winningBid.counterpartyDeadline}.`:`Buyer ${a.winningBid.buyer}; receive ${a.winningBid.price} USDe base units (${$.address}, 18 decimals).`;return{steps:[{kind:"typedData",request:structuredClone(a.request)}],continuation:structuredClone(a),summary:`${f} on chain ${k}.${y(s)} Approval was checked on chain. ${u} Sign locally for domain ${a.request.domain.name}, version 1, escrow ${a.escrowContract}, signature deadline ${e.deadline}${"acceptDeadline"in a?`, acceptance deadline ${a.acceptDeadline}`:""}. External relayer settlement is pending; a signature is not a fill.`}}async function D(e){let a=await e.channel.wait("result"),s=_(a.winningBid),f=A(a.auctionId);s.auctionId!==f&&i("Meridian winning bid belongs to another auction.");let u=M(a.acceptDeadline,"the acceptance deadline",!0);if(e.input.side==="buy"){let r={auctionId:f,counterparty:A(s.counterparty),counterpartyCollateral:M(s.counterpartyCollateral,"the counterparty collateral"),counterpartyNonce:M(s.counterpartyNonce,"the counterparty nonce",!0),counterpartyDeadline:M(s.counterpartyDeadline,"the counterparty deadline",!0),receivedAt:A(s.receivedAt)};R(r.counterparty),(!Number.isFinite(Date.parse(r.receivedAt))||BigInt(r.counterpartyCollateral)<=1n||BigInt(r.counterpartyCollateral)<BigInt(e.input.minCounterpartyCollateral))&&i("Meridian winning bid counterparty collateral is below the caller minimum."),e.continuation={...m(e),stage:"primary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}else{let r={auctionId:f,buyer:A(s.buyer),price:M(s.price,"the sale price"),...s.buyerDeadline!==void 0?{buyerDeadline:M(s.buyerDeadline,"the buyer deadline",!0)}:{},...s.buyerNonce!==void 0?{buyerNonce:M(s.buyerNonce,"the buyer nonce",!0)}:{},...s.receivedAt!==void 0?{receivedAt:A(s.receivedAt)}:{}};R(r.buyer),(BigInt(r.price)<=1n||BigInt(r.price)<BigInt(e.input.minPrice))&&i("Meridian winning bid sale price is below the caller minimum."),e.continuation={...m(e),stage:"secondary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}return I(e)}async function S(e,a){let s=e.continuation;s.stage!=="primary_accept"&&s.stage!=="secondary_accept"&&i("Meridian exchange is not ready for acceptance."),H(e),e.channel.send("accept",{auctionId:s.auctionId,[e.input.side==="buy"?"predictorSignature":"sellerSignature"]:a}),c(e,15e4);let f=await e.channel.wait("filled",12e4),u=Z(f.transactionHash,32),r=n.clientFor(k),[h,w]=await Promise.all([r.waitForTransactionReceipt({hash:u,timeout:12e4}),r.getTransaction({hash:u})]);(h.status!=="success"||!g(h.transactionHash,u)||!g(w.hash,u)||!g(h.to,s.escrowContract)||!g(w.to,s.escrowContract)||w.chainId!==k)&&i("Meridian fill has no matching successful receipt on chain 4663.");let{input:p,wallet:v}=e;if(p.side==="buy"&&s.stage==="primary_accept"){let o=me({abi:Be,data:w.input}).args[0];(!g(te([...o.picks]),te(p.picks))||o.predictorCollateral!==BigInt(p.stake)||o.counterpartyCollateral!==BigInt(s.winningBid.counterpartyCollateral)||!g(o.predictor,v)||!g(o.counterparty,s.winningBid.counterparty)||o.predictorNonce!==BigInt(e.nonce)||o.predictorDeadline!==BigInt(e.deadline)||!g(o.predictorSponsor,L)||o.predictorSponsorData!=="0x"||!g(o.predictorSignature,a))&&i("Meridian mint receipt does not match the accepted prediction.")}else if(p.side==="sell"&&s.stage==="secondary_accept"){let o=me({abi:Me,data:w.input}).args[0];(!g(o.token,p.token)||!g(o.collateral,$.address)||!g(o.seller,v)||!g(o.buyer,s.winningBid.buyer)||o.tokenAmount!==BigInt(p.amount)||o.price!==BigInt(s.winningBid.price)||o.sellerNonce!==BigInt(e.nonce)||o.sellerDeadline!==BigInt(e.deadline)||!g(o.sellerSignature,a))&&i("Meridian sale receipt does not match the accepted trade.")}let P=new Map,T=new Map;for(let o of h.logs){if(o.topics[0]!==$e||o.topics.length!==3)continue;(!/^0x[0-9a-fA-F]{64}$/.test(o.data)||!o.topics.slice(1).every(ge=>/^0x0{24}[0-9a-fA-F]{40}$/.test(ge)))&&i("Meridian receipt has malformed transfer logs.");let U=`0x${o.topics[1].slice(-40)}`,E=`0x${o.topics[2].slice(-40)}`,q=o.address.toLowerCase(),z=BigInt(o.data);P.set(q,(P.get(q)??0n)+(g(E,v)?z:0n)-(g(U,v)?z:0n)),g(U,L)&&g(E,v)&&T.set(q,(T.get(q)??0n)+z)}let b;if(p.side==="buy"&&s.stage==="primary_accept"){let o=BigInt(p.stake)+BigInt(s.winningBid.counterpartyCollateral),U=[...T].filter(([E,q])=>!g(E,$.address)&&q===o&&P.get(E)===o);(U.length!==1||P.get($.address.toLowerCase())!==-BigInt(p.stake))&&i("Meridian mint receipt does not prove the expected collateral and position delta."),b=`${o} base units received in position ${U[0][0]}`}else p.side==="sell"&&s.stage==="secondary_accept"?((P.get(p.token.toLowerCase())!==-BigInt(p.amount)||P.get($.address.toLowerCase())!==BigInt(s.winningBid.price))&&i("Meridian sale receipt does not prove the expected collateral and position delta."),b=`${p.amount} base units sold from position ${p.token}; ${s.winningBid.price} USDe base units received`):i("Meridian fill has a different exchange stage.");return{txs:[],hashes:[u],status:"mined",summary:`Mined: ${u}. Status: mined. Meridian ${p.side} filled by the external relayer. Successful receipt and transfer deltas verified on chain ${k}: ${b} (18 decimals); collateral USDe ${$.address} (18 decimals).`}}async function B(e,a,s){let f=R(s),u=Ae(e,a),r;if(a.continuation!==void 0){let h=_(a.continuation),w=t.get(A(h.requestId));w||i("Meridian exchange is lost or expired. Start a fresh auction."),(!g(w.wallet,f)||!pe(w.input,u)||!pe(w.continuation,h))&&i("Meridian continuation or arguments do not match the active wallet exchange."),w.busy&&i("Meridian exchange is already processing this continuation."),r=w}else{a.signature!==void 0&&i("A signature requires an active Meridian continuation."),t.size>=1e3&&i("Too many active Meridian exchanges. Please try again later.");let h=he(),w=setTimeout(()=>{let p=t.get(h);p&&d(p)},9e5);w.unref?.(),r={input:u,wallet:f,continuation:{stage:"prerequisites",wallet:f,chainId:k,escrowContract:e==="buy"?Q:V,requestId:h},busy:!1,timer:w},t.set(h,r)}r.busy=!0;try{H(r),await n.clientFor(k).getChainId()!==k&&i("Meridian requires an RPC on chain 4663.");let h=r.continuation.stage;h==="prerequisites"&&a.signature!==void 0&&i("Do not sign before Meridian prerequisites have mined.");let w=await l(r);if(w)return w;if(h==="prerequisites")return r.nonce=(ye(4).readUInt32BE()+1).toString(),r.deadline=(j()+300n).toString(),await n.clientFor(k).readContract({address:r.continuation.escrowContract,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i(`Meridian ${e==="buy"?"predictor":"seller"} nonce is already used. Start a fresh auction.`),r.channel=new ee(r.continuation.requestId,e==="buy"?"auction":"secondary.auction"),await r.channel.wait(),u.side==="buy"?(r.channel.send("start",{id:r.continuation.requestId,picks:u.picks,predictorCollateral:u.stake,predictor:f,predictorNonce:O(r.nonce),predictorDeadline:O(r.deadline),chainId:k,escrowContract:Q,mode:"blind"}),await D(r)):(r.continuation={...m(r),stage:"secondary_start",request:Y(r)},I(r));let p=Z(a.signature);if(e==="sell"&&await n.clientFor(k).readContract({address:V,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),e==="buy"&&await n.clientFor(k).readContract({address:Q,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian predictor nonce is already used. Start a fresh auction."),H(r),h==="secondary_start"&&u.side==="sell")return r.channel.send("start",{id:r.continuation.requestId,token:u.token,collateral:$.address,tokenAmount:u.amount,seller:f,sellerNonce:O(r.nonce),sellerDeadline:O(r.deadline),chainId:k,escrowContract:V,mode:"blind",sellerSignature:p}),await D(r);let v=await S(r,p);return d(r),v}catch(h){throw d(r),new N(n.plainError(h))}finally{r.busy=!1}}let C={continuation:{type:"object",description:"Internal continuation returned by the previous local signing round."},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Internal hexadecimal signature supplied by local signing; never enter manually."}};return{tools:[{name:"meridian_buy",inputSchema:{type:"object",additionalProperties:!1,required:["picks","stake"],properties:{...C,stake:x('USDe stake in base units (18 decimals): "1000000000000000000" = 1 USDe.'),minCounterpartyCollateral:x('Minimum counterparty USDe collateral in base units (18 decimals): "1000000000000000000" = 1 USDe.'),usdgAmountIn:x('USDG swap input in base units if USDe is short (6 decimals): "1000000" = 1 USDG.'),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points (50 = 0.5%)."},picks:{type:"array",minItems:1,maxItems:10,items:{type:"object",additionalProperties:!1,required:["conditionResolver","conditionId","predictedOutcome"],properties:{conditionResolver:{...W,description:"Condition resolver contract address on chain 4663."},conditionId:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Condition identifier as a 0x-prefixed even-length hex string."},predictedOutcome:{type:"integer",enum:[0,1],description:"Predicted binary outcome, 0 or 1, as defined by the condition."}}},description:"Prediction picks for the auction."}}},execute:(e,a)=>B("buy",e,a)},{name:"meridian_sell",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount"],properties:{...C,token:{...W,description:"Position token address on chain 4663."},amount:x('Position token amount in base units (18 decimals): "1000000000000000000" = 1 position token.'),minPrice:x('Minimum total USDe proceeds in base units (18 decimals): "1000000000000000000" = 1 USDe. Explicit minimum is not reduced by slippage.'),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points (50 = 0.5%); applies only to the default floor when minPrice is omitted."}}},execute:(e,a)=>B("sell",e,a)}]}};export{Ce as a,ve as b,Fe as c};
|
|
1
|
+
import{b as le,o as K}from"./TTBB6EFN.js";import{b as x}from"./66F5ZH34.js";import{c as W,f as de,h as g,i as ce,l as ue}from"./NWNYJ26T.js";import{b as k,j as oe,k as G}from"./EWZFZUVF.js";import{a as N}from"./XSD5NL7J.js";import{a as F}from"./JXOEJPJ4.js";import{randomBytes as ye,randomUUID as he}from"node:crypto";import{isDeepStrictEqual as pe}from"node:util";import{decodeFunctionData as me,encodeAbiParameters as ne,erc20Abi as J,keccak256 as ie,parseAbi as re,parseAbiParameters as ae,toEventSelector as be,zeroAddress as L}from"viem";var se=oe[k].meridian,Q=se.PredictionMarketEscrow.address,V=se.SecondaryMarketEscrow.address,$={address:se.CollateralToken_USDe.address,chainId:k,symbol:"USDe",decimals:18},we="wss://relayer.predict.meridian.xyz/auction",ke=ae("(address conditionResolver,bytes conditionId,uint8 predictedOutcome)[]"),Ie=ae("bytes32,uint256,uint256,address,address,address,bytes"),Se=ae("address,address,address,address,uint256,uint256"),X=re(["function isNonceUsed(address,uint256) view returns (bool)"]),Be=re(["function mint(((address conditionResolver,bytes conditionId,uint8 predictedOutcome)[] picks,uint256 predictorCollateral,uint256 counterpartyCollateral,address predictor,address counterparty,uint256 predictorNonce,uint256 counterpartyNonce,uint256 predictorDeadline,uint256 counterpartyDeadline,bytes predictorSignature,bytes counterpartySignature,bytes32 refCode,bytes predictorSessionKeyData,bytes counterpartySessionKeyData,address predictorSponsor,bytes predictorSponsorData) request)"]),Me=re(["function executeTrade((address token,address collateral,address seller,address buyer,uint256 tokenAmount,uint256 price,uint256 sellerNonce,uint256 buyerNonce,uint256 sellerDeadline,uint256 buyerDeadline,bytes sellerSignature,bytes buyerSignature,bytes32 refCode,bytes sellerSessionKeyData,bytes buyerSessionKeyData) request)"]),$e=be("Transfer(address,address,uint256)"),Ce=[{name:"predictionHash",type:"bytes32"},{name:"signer",type:"address"},{name:"collateral",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],ve=[{name:"tradeHash",type:"bytes32"},{name:"signer",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}];function i(n){throw new N(n)}function _(n){return de(n,"Meridian returned an invalid exchange object.")}function M(n,t,d=!1){return d&&typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&(n=String(n)),(typeof n!="string"||!/^\d+$/.test(n)||BigInt(n)>=1n<<256n)&&i(`Provide ${t} as a decimal base-unit integer string.`),n}function O(n){let t=Number(n);return(!Number.isSafeInteger(t)||t<0||BigInt(t)!==BigInt(n))&&i("Meridian signing terms cannot be represented exactly as JSON numbers."),t}function R(n){let t="Provide a nonzero token, resolver or wallet address.";return ue(ce(n,t),t)}function Z(n,t){return(typeof n!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(n)||t!==void 0&&n.length!==2+t*2)&&i("Meridian returned invalid hexadecimal data."),n}function A(n){return(typeof n!="string"||n.length===0||n.length>256)&&i("Meridian returned an invalid exchange identifier."),n}function j(){return BigInt(Math.floor(Date.now()/1e3))}function Ae(n,t){let d=n==="buy"?["picks","stake","minCounterpartyCollateral","usdgAmountIn","slippageBps","continuation","signature"]:["token","amount","minPrice","slippageBps","continuation","signature"];Object.keys(t).some(S=>!d.includes(S))&&i("Unsupported Meridian arguments; use the tool input schema."),t.slippageBps!==void 0&&(typeof t.slippageBps!="number"||!Number.isInteger(t.slippageBps)||t.slippageBps<0||t.slippageBps>=1e4)&&i("Slippage must be an integer from 0 to 9999 basis points.");let c=t.slippageBps;if(n==="sell"){let S=M(t.amount,"the position amount");BigInt(S)===0n&&i("The position amount must be positive.");let B=R(t.token);(g(B,$.address)||g(B,G))&&i("Choose a Meridian position token to sell.");let C;if(t.minPrice!==void 0){let e=M(t.minPrice,"the minimum sale price");BigInt(e)<=1n&&i("The minimum sale price must be greater than 1 base unit."),C=e}else{let e=BigInt(S)/100n>10n**18n?BigInt(S)/100n:10n**18n;C=c===void 0?e.toString():K(e.toString(),c)}return{side:n,token:B,amount:S,minPrice:C,priceFloorSource:t.minPrice===void 0?"default":"explicit",...c===void 0?{}:{slippageBps:c}}}(!Array.isArray(t.picks)||t.picks.length<1||t.picks.length>10)&&i("Provide between one and ten Meridian picks.");let m=t.picks.map(S=>{let B=_(S);return(Object.keys(B).some(C=>!["conditionResolver","conditionId","predictedOutcome"].includes(C))||B.predictedOutcome!==0&&B.predictedOutcome!==1)&&i("Each pick needs a resolver, condition ID and outcome 0 or 1."),{conditionResolver:R(B.conditionResolver),conditionId:Z(B.conditionId),predictedOutcome:B.predictedOutcome}}).sort((S,B)=>{let C=`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}:${S.predictedOutcome}`,e=`${B.conditionResolver.toLowerCase()}:${B.conditionId.toLowerCase()}:${B.predictedOutcome}`;return C<e?-1:C>e?1:0}),y=m.map(S=>`${S.conditionResolver.toLowerCase()}:${S.conditionId.toLowerCase()}`);new Set(y).size!==m.length&&i("Do not repeat a condition in the same prediction.");let l=M(t.stake,"the USDe stake");BigInt(l)<10n**18n&&i("Meridian requires a stake of at least 1 USDe.");let I=t.usdgAmountIn===void 0?void 0:M(t.usdgAmountIn,"the USDG swap amount");I!==void 0&&BigInt(I)===0n&&i("The USDG swap amount must be positive.");let D=t.minCounterpartyCollateral!==void 0?M(t.minCounterpartyCollateral,"the minimum counterparty collateral"):K(l,c??le);return BigInt(D)<=1n&&i("The minimum counterparty collateral must be greater than 1 base unit."),{side:n,picks:m,stake:l,minCounterpartyCollateral:D,...I===void 0?{}:{usdgAmountIn:I},...c===void 0?{}:{slippageBps:c}}}var ee=class{constructor(t,d){this.id=t;this.prefix=d;this.socket=new globalThis.WebSocket(we),this.socket.addEventListener("open",()=>{this.opened=!0,this.notify?.()}),this.socket.addEventListener("close",()=>this.stop("Meridian exchange socket was lost. Start a fresh auction.")),this.socket.addEventListener("error",()=>this.stop("Meridian exchange socket failed. Start a fresh auction.")),this.socket.addEventListener("message",c=>{try{(typeof c.data!="string"||c.data.length>65536)&&i("Meridian returned a malformed exchange message.");let m=_(JSON.parse(c.data));if(m.type==="pong")return;let y=A(m.type),l=_(m.payload);if(y==="error"&&i("Meridian rejected or failed the exchange. Start a fresh auction."),y===`${d}.ack`){this.auctionId===void 0?((l.id!==t||this.accepting||l.accepted!==void 0)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected the exchange: ${F(A(l.error))}.`),this.auctionId=A(l.auctionId)):((!this.accepting||l.auctionId!==this.auctionId||l.id!==void 0&&l.id!==t)&&i("Meridian acknowledged a different exchange."),l.error!==void 0&&i(`Meridian rejected acceptance: ${F(A(l.error))}.`),l.accepted!==!0&&i("Meridian rejected acceptance of the exchange."));return}if((!y.startsWith(`${d}.`)||l.auctionId!==this.auctionId||!this.auctionId)&&i("Meridian returned a message for a different exchange."),["error","rejected","failed","expired"].some(I=>y===`${d}.${I}`)){let I=["reason","makerReason"].flatMap(D=>l[D]===void 0?[]:[`${D}=${F(A(l[D]))}`]);i(`Meridian exchange ${y.slice(d.length+1)}${I.length?`: ${I.join("; ")}`:""}. Start a fresh auction.`)}if((y===`${d}.pending`||y===`${d}.filled`)&&!this.accepting&&i("Meridian returned settlement before acceptance."),y===`${d}.pending`)return;this.queue.length>=16&&i("Meridian returned too many exchange messages."),this.queue.push({type:y,payload:l}),this.notify?.()}catch(m){this.stop(m instanceof N?m.message:"Meridian rejected or returned an invalid exchange message. Start a fresh auction.")}})}id;prefix;socket;queue=[];notify;error;auctionId;accepting=!1;opened=!1;check(){if(this.error)throw this.error;this.socket.readyState>1&&i("Meridian exchange socket was lost. Start a fresh auction.")}stop(t){this.error??=new N(t),this.notify?.(),this.socket.readyState<2&&this.socket.close()}async wait(t,d=3e4){return new Promise((c,m)=>{let y=setTimeout(()=>this.stop("Meridian exchange timed out. Start a fresh auction."),d),l=()=>{try{if(this.check(),t===void 0?!this.opened:!this.queue.length)return;let I=t===void 0?void 0:this.queue.shift();I&&I.type!==`${this.prefix}.${t}`&&i("Meridian returned an unexpected exchange stage."),clearTimeout(y),this.notify=void 0,c(I?.payload??{})}catch(I){clearTimeout(y),this.notify=void 0,m(I)}};this.notify=l,l()})}send(t,d){this.check(),this.socket.readyState!==1&&i("Meridian exchange socket is not open."),t==="accept"&&(this.accepting=!0),this.socket.send(JSON.stringify({...t==="start"?{id:this.id}:{},type:`${this.prefix}.${t}`,payload:d}))}};function te(n){return ie(ne(ke,[n]))}function De(n,t,d){return ie(ne(Ie,[te(n.picks),BigInt(n.stake),BigInt(d.counterpartyCollateral),t,d.counterparty,L,"0x"]))}function Pe(n,t,d,c){return ie(ne(Se,[n.token,$.address,t,d,BigInt(n.amount),BigInt(c)]))}function Y(n,t){let{input:d,wallet:c,nonce:m,deadline:y}=n,l={name:d.side==="buy"?"PredictionMarketEscrow":"SecondaryMarketEscrow",version:"1",chainId:k,verifyingContract:n.continuation.escrowContract};return(!m||!y)&&i("Meridian exchange is missing its signing terms."),d.side==="buy"?(t||i("Meridian has not returned a winning bid."),{domain:l,primaryType:"MintApproval",types:{MintApproval:Ce},message:{predictionHash:De(d,c,t),signer:c,collateral:d.stake,nonce:m,deadline:y}}):{domain:l,primaryType:"TradeApproval",types:{TradeApproval:ve},message:{tradeHash:Pe(d,c,t?t.buyer:L,t?t.price:"0"),signer:c,nonce:m,deadline:y}}}function fe(n){let t=[BigInt(n.deadline)],d=n.continuation;if(d.stage==="primary_accept"||d.stage==="secondary_accept"){t.push(BigInt(d.acceptDeadline));let c=d.winningBid;d.stage==="primary_accept"&&t.push(BigInt(c.counterpartyDeadline)),c.buyerDeadline!==void 0&&t.push(BigInt(M(c.buyerDeadline,"the buyer deadline",!0)))}return t.reduce((c,m)=>c<m?c:m)}function H(n){n.channel?.check(),n.deadline&&j()>=fe(n)&&i("Meridian exchange expired. Start a fresh auction.")}var Fe=n=>{let t=new Map;function d(e){clearTimeout(e.timer),t.delete(e.continuation.requestId),e.channel?.stop("Meridian exchange is closed or expired. Start a fresh auction.")}function c(e,a){clearTimeout(e.timer),e.timer=setTimeout(()=>d(e),a),e.timer.unref?.()}function m(e){let{wallet:a,chainId:s,escrowContract:f,requestId:u}=e.continuation;return{wallet:a,chainId:s,escrowContract:f,requestId:u}}function y(e){return e.side!=="sell"?"":` Effective minimum sale proceeds: ${e.minPrice} USDe base units (${$.address}, 18 decimals). ${e.priceFloorSource==="explicit"?"Caller minPrice is unchanged; slippageBps does not reduce this floor.":`Default floor with ${e.slippageBps??0} bps slippage applied.`}`}async function l(e){let{input:a,wallet:s}=e,f=n.clientFor(k),u=a.side==="buy"?$.address:a.token,r=a.side==="buy"?a.stake:a.amount,[h,w]=await Promise.all([f.readContract({address:u,abi:J,functionName:"balanceOf",args:[s]}),f.readContract({address:u,abi:J,functionName:"allowance",args:[s,e.continuation.escrowContract]})]);if(a.side==="sell"&&await f.readContract({address:u,abi:J,functionName:"decimals"})!==18&&i("Meridian position tokens must have 18 decimals."),h>=BigInt(r)&&w>=BigInt(r))return;(e.continuation.stage==="primary_accept"||e.continuation.stage==="secondary_accept")&&i("Meridian prerequisites changed during the auction. Start a fresh auction after funding and approval.");let p,v;if(h<BigInt(r)){a.side==="sell"&&i("The wallet does not have enough position tokens to sell."),a.usdgAmountIn||i("Not enough USDe. Provide usdgAmountIn in USDG base units to quote a swap before the auction.");let b=await n.quoteSwap({from:G,to:$.address,amountIn:a.usdgAmountIn,...a.slippageBps===void 0?{}:{slippageBps:a.slippageBps}},s);(j()>=BigInt(M(b.expiresAt,"the swap expiry"))||BigInt(M(b.minAmountOut,"the swap minimum"))+h<BigInt(r))&&i("The USDG swap minimum does not cover the USDe stake, or the quote expired. Request a fresh quote with sufficient input.");let o=await n.buildSwap(b.quoteId,s);(!("txs"in o)||!o.txs.length)&&i("The swap coordinator did not return prerequisite transactions."),p=o.txs,v=`${o.summary} Minimum USDe output: ${b.minAmountOut} base units (18 decimals).`}else p=[n.approval(u,e.continuation.escrowContract,r,k)],v=`Approve exactly ${r} base units (18 decimals) of ${u} for ${e.continuation.escrowContract} on chain ${k}.`;p.some(b=>b.chainId!==k)&&i("Meridian prerequisite transactions must use chain 4663.");let P=await n.preview(p,s),T=P.changes.map(b=>{let o=b.amount.startsWith("-");return`${o?"-":"+"}${n.formatAmount(o?b.amount.slice(1):b.amount,b.token.decimals)} ${b.token.symbol} (${b.token.address}, chain ${b.token.chainId}, ${b.token.decimals} decimals)`}).join("; ");return e.channel?.stop("Meridian prerequisites must be mined before the auction."),e.channel=void 0,e.deadline=void 0,e.nonce=void 0,e.continuation={...m(e),stage:"prerequisites"},{steps:p.map(b=>({kind:"tx",tx:b})),continuation:structuredClone(e.continuation),summary:`${v}${y(a)} ${P.summary} ${T}. Mine these prerequisites before continuing; no RFQ has started.`}}function I(e){let a=e.continuation;a.stage==="prerequisites"&&i("Meridian prerequisites need to finish before signing."),H(e),c(e,Number(fe(e)-j())*1e3);let s=e.input,f=s.side==="buy"?`Stake ${s.stake} base units of USDe (${$.address}, 18 decimals)`:`Sell ${s.amount} base units of position ${s.token} (18 decimals)`,u=a.stage==="secondary_start"?"Initial buyer-zero, price-zero intent only.":a.stage==="primary_accept"?`Counterparty ${a.winningBid.counterparty}; counterparty collateral ${a.winningBid.counterpartyCollateral} USDe base units; counterparty deadline ${a.winningBid.counterpartyDeadline}.`:`Buyer ${a.winningBid.buyer}; receive ${a.winningBid.price} USDe base units (${$.address}, 18 decimals).`;return{steps:[{kind:"typedData",request:structuredClone(a.request)}],continuation:structuredClone(a),summary:`${f} on chain ${k}.${y(s)} Approval was checked on chain. ${u} Sign locally for domain ${a.request.domain.name}, version 1, escrow ${a.escrowContract}, signature deadline ${e.deadline}${"acceptDeadline"in a?`, acceptance deadline ${a.acceptDeadline}`:""}. External relayer settlement is pending; a signature is not a fill.`}}async function D(e){let a=await e.channel.wait("result"),s=_(a.winningBid),f=A(a.auctionId);s.auctionId!==f&&i("Meridian winning bid belongs to another auction.");let u=M(a.acceptDeadline,"the acceptance deadline",!0);if(e.input.side==="buy"){let r={auctionId:f,counterparty:A(s.counterparty),counterpartyCollateral:M(s.counterpartyCollateral,"the counterparty collateral"),counterpartyNonce:M(s.counterpartyNonce,"the counterparty nonce",!0),counterpartyDeadline:M(s.counterpartyDeadline,"the counterparty deadline",!0),receivedAt:A(s.receivedAt)};R(r.counterparty),(!Number.isFinite(Date.parse(r.receivedAt))||BigInt(r.counterpartyCollateral)<=1n||BigInt(r.counterpartyCollateral)<BigInt(e.input.minCounterpartyCollateral))&&i("Meridian winning bid counterparty collateral is below the caller minimum."),e.continuation={...m(e),stage:"primary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}else{let r={auctionId:f,buyer:A(s.buyer),price:M(s.price,"the sale price"),...s.buyerDeadline!==void 0?{buyerDeadline:M(s.buyerDeadline,"the buyer deadline",!0)}:{},...s.buyerNonce!==void 0?{buyerNonce:M(s.buyerNonce,"the buyer nonce",!0)}:{},...s.receivedAt!==void 0?{receivedAt:A(s.receivedAt)}:{}};R(r.buyer),(BigInt(r.price)<=1n||BigInt(r.price)<BigInt(e.input.minPrice))&&i("Meridian winning bid sale price is below the caller minimum."),e.continuation={...m(e),stage:"secondary_accept",auctionId:f,winningBid:r,acceptDeadline:u,request:Y(e,r)}}return I(e)}async function S(e,a){let s=e.continuation;s.stage!=="primary_accept"&&s.stage!=="secondary_accept"&&i("Meridian exchange is not ready for acceptance."),H(e),e.channel.send("accept",{auctionId:s.auctionId,[e.input.side==="buy"?"predictorSignature":"sellerSignature"]:a}),c(e,15e4);let f=await e.channel.wait("filled",12e4),u=Z(f.transactionHash,32),r=n.clientFor(k),[h,w]=await Promise.all([r.waitForTransactionReceipt({hash:u,timeout:12e4}),r.getTransaction({hash:u})]);(h.status!=="success"||!g(h.transactionHash,u)||!g(w.hash,u)||!g(h.to,s.escrowContract)||!g(w.to,s.escrowContract)||w.chainId!==k)&&i("Meridian fill has no matching successful receipt on chain 4663.");let{input:p,wallet:v}=e;if(p.side==="buy"&&s.stage==="primary_accept"){let o=me({abi:Be,data:w.input}).args[0];(!g(te([...o.picks]),te(p.picks))||o.predictorCollateral!==BigInt(p.stake)||o.counterpartyCollateral!==BigInt(s.winningBid.counterpartyCollateral)||!g(o.predictor,v)||!g(o.counterparty,s.winningBid.counterparty)||o.predictorNonce!==BigInt(e.nonce)||o.predictorDeadline!==BigInt(e.deadline)||!g(o.predictorSponsor,L)||o.predictorSponsorData!=="0x"||!g(o.predictorSignature,a))&&i("Meridian mint receipt does not match the accepted prediction.")}else if(p.side==="sell"&&s.stage==="secondary_accept"){let o=me({abi:Me,data:w.input}).args[0];(!g(o.token,p.token)||!g(o.collateral,$.address)||!g(o.seller,v)||!g(o.buyer,s.winningBid.buyer)||o.tokenAmount!==BigInt(p.amount)||o.price!==BigInt(s.winningBid.price)||o.sellerNonce!==BigInt(e.nonce)||o.sellerDeadline!==BigInt(e.deadline)||!g(o.sellerSignature,a))&&i("Meridian sale receipt does not match the accepted trade.")}let P=new Map,T=new Map;for(let o of h.logs){if(o.topics[0]!==$e||o.topics.length!==3)continue;(!/^0x[0-9a-fA-F]{64}$/.test(o.data)||!o.topics.slice(1).every(ge=>/^0x0{24}[0-9a-fA-F]{40}$/.test(ge)))&&i("Meridian receipt has malformed transfer logs.");let U=`0x${o.topics[1].slice(-40)}`,E=`0x${o.topics[2].slice(-40)}`,q=o.address.toLowerCase(),z=BigInt(o.data);P.set(q,(P.get(q)??0n)+(g(E,v)?z:0n)-(g(U,v)?z:0n)),g(U,L)&&g(E,v)&&T.set(q,(T.get(q)??0n)+z)}let b;if(p.side==="buy"&&s.stage==="primary_accept"){let o=BigInt(p.stake)+BigInt(s.winningBid.counterpartyCollateral),U=[...T].filter(([E,q])=>!g(E,$.address)&&q===o&&P.get(E)===o);(U.length!==1||P.get($.address.toLowerCase())!==-BigInt(p.stake))&&i("Meridian mint receipt does not prove the expected collateral and position delta."),b=`${o} base units received in position ${U[0][0]}`}else p.side==="sell"&&s.stage==="secondary_accept"?((P.get(p.token.toLowerCase())!==-BigInt(p.amount)||P.get($.address.toLowerCase())!==BigInt(s.winningBid.price))&&i("Meridian sale receipt does not prove the expected collateral and position delta."),b=`${p.amount} base units sold from position ${p.token}; ${s.winningBid.price} USDe base units received`):i("Meridian fill has a different exchange stage.");return{txs:[],hashes:[u],status:"mined",summary:`Mined: ${u}. Status: mined. Meridian ${p.side} filled by the external relayer. Successful receipt and transfer deltas verified on chain ${k}: ${b} (18 decimals); collateral USDe ${$.address} (18 decimals).`}}async function B(e,a,s){let f=R(s),u=Ae(e,a),r;if(a.continuation!==void 0){let h=_(a.continuation),w=t.get(A(h.requestId));w||i("Meridian exchange is lost or expired. Start a fresh auction."),(!g(w.wallet,f)||!pe(w.input,u)||!pe(w.continuation,h))&&i("Meridian continuation or arguments do not match the active wallet exchange."),w.busy&&i("Meridian exchange is already processing this continuation."),r=w}else{a.signature!==void 0&&i("A signature requires an active Meridian continuation."),t.size>=1e3&&i("Too many active Meridian exchanges. Please try again later.");let h=he(),w=setTimeout(()=>{let p=t.get(h);p&&d(p)},9e5);w.unref?.(),r={input:u,wallet:f,continuation:{stage:"prerequisites",wallet:f,chainId:k,escrowContract:e==="buy"?Q:V,requestId:h},busy:!1,timer:w},t.set(h,r)}r.busy=!0;try{H(r),await n.clientFor(k).getChainId()!==k&&i("Meridian requires an RPC on chain 4663.");let h=r.continuation.stage;h==="prerequisites"&&a.signature!==void 0&&i("Do not sign before Meridian prerequisites have mined.");let w=await l(r);if(w)return w;if(h==="prerequisites")return r.nonce=(ye(4).readUInt32BE()+1).toString(),r.deadline=(j()+300n).toString(),await n.clientFor(k).readContract({address:r.continuation.escrowContract,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i(`Meridian ${e==="buy"?"predictor":"seller"} nonce is already used. Start a fresh auction.`),r.channel=new ee(r.continuation.requestId,e==="buy"?"auction":"secondary.auction"),await r.channel.wait(),u.side==="buy"?(r.channel.send("start",{id:r.continuation.requestId,picks:u.picks,predictorCollateral:u.stake,predictor:f,predictorNonce:O(r.nonce),predictorDeadline:O(r.deadline),chainId:k,escrowContract:Q,mode:"blind"}),await D(r)):(r.continuation={...m(r),stage:"secondary_start",request:Y(r)},I(r));let p=Z(a.signature);if(e==="sell"&&await n.clientFor(k).readContract({address:V,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),e==="buy"&&await n.clientFor(k).readContract({address:Q,abi:X,functionName:"isNonceUsed",args:[f,BigInt(r.nonce)]})&&i("Meridian predictor nonce is already used. Start a fresh auction."),H(r),h==="secondary_start"&&u.side==="sell")return r.channel.send("start",{id:r.continuation.requestId,token:u.token,collateral:$.address,tokenAmount:u.amount,seller:f,sellerNonce:O(r.nonce),sellerDeadline:O(r.deadline),chainId:k,escrowContract:V,mode:"blind",sellerSignature:p}),await D(r);let v=await S(r,p);return d(r),v}catch(h){throw d(r),new N(n.plainError(h))}finally{r.busy=!1}}let C={continuation:{type:"object",description:"Internal continuation returned by the previous local signing round."},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Internal hexadecimal signature supplied by local signing; never enter manually."}};return{tools:[{name:"meridian_buy",inputSchema:{type:"object",additionalProperties:!1,required:["picks","stake"],properties:{...C,stake:x('USDe stake in base units (18 decimals): "1000000000000000000" = 1 USDe.'),minCounterpartyCollateral:x('Minimum counterparty USDe collateral in base units (18 decimals): "1000000000000000000" = 1 USDe.'),usdgAmountIn:x('USDG swap input in base units if USDe is short (6 decimals): "1000000" = 1 USDG.'),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points (50 = 0.5%)."},picks:{type:"array",minItems:1,maxItems:10,items:{type:"object",additionalProperties:!1,required:["conditionResolver","conditionId","predictedOutcome"],properties:{conditionResolver:{...W,description:"Condition resolver contract address on chain 4663."},conditionId:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Condition identifier as a 0x-prefixed even-length hex string."},predictedOutcome:{type:"integer",enum:[0,1],description:"Predicted binary outcome, 0 or 1, as defined by the condition."}}},description:"Prediction picks for the auction."}}},execute:(e,a)=>B("buy",e,a)},{name:"meridian_sell",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount"],properties:{...C,token:{...W,description:"Position token address on chain 4663."},amount:x('Position token amount in base units (18 decimals): "1000000000000000000" = 1 position token.'),minPrice:x('Minimum total USDe proceeds in base units (18 decimals): "1000000000000000000" = 1 USDe. Explicit minimum is not reduced by slippage.'),slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points (50 = 0.5%); applies only to the default floor when minPrice is omitted."}}},execute:(e,a)=>B("sell",e,a)}]}};export{Ce as a,ve as b,Fe as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n,f as a,i as s,j as l,k as u}from"./
|
|
1
|
+
import{d as n,f as a,i as s,j as l,k as u}from"./IY7FWTAL.js";import{c as e}from"./GV6FZ6UG.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as J,i as K}from"./W3DGFMQE.js";import{a as H}from"./43LI5NKJ.js";import{a as I}from"./66F5ZH34.js";import{c as D,d as Y,g as N,i as V,m as Q,n as z}from"./NWNYJ26T.js";import{b as p,j as R,k as j}from"./TI727O2H.js";import{a as d}from"./XSD5NL7J.js";import{decodeFunctionData as X,encodeFunctionData as x,erc20Abi as F,getAddress as L,parseAbi as Z}from"viem";var e={router:L("0xf5198743240fac98db71868f34c70139b1eb0474"),factory:L("0xfa5429aeba338bea2bfcc1b9a889862ee395bc28"),pair:L("0x8697bb63743678640710b1270e98772a29642b3c"),weth:L("0x0bd7d308f8e1639fab988df18a8011f41eacad73"),up:L("0x57c0e45cb534413d1c20a4240955d6bb250bb4f1"),eth:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},E=Z(["function token0() view returns (address)","function token1() view returns (address)","function factory() view returns (address)","function defaultFactory() view returns (address)","function stable() view returns (bool)","function getReserves() view returns (uint112,uint112,uint32)","function poolFor(address,address,bool,address) view returns (address)","function getPool(address,address,bool) view returns (address)","function getAmountsOut(uint256,(address from,address to,bool stable,address factory)[]) view returns (uint256[])","function quoteAddLiquidity(address,address,bool,address,uint256,uint256) view returns (uint256,uint256,uint256)","function addLiquidity(address,address,bool,uint256,uint256,uint256,uint256,address,uint256) returns (uint256,uint256,uint256)","function removeLiquidity(address,address,bool,uint256,uint256,uint256,address,uint256) returns (uint256,uint256)","function swapExactTokensForTokens(uint256,uint256,(address from,address to,bool stable,address factory)[],address,uint256) returns (uint256[])","function deposit() payable"]),ee=Z(["function want() view returns (address)"]),O={vault:{...D,description:"Address of the Beefy vault contract (from beefy_list)."},chainId:{const:p,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},slippageBps:{type:"integer",minimum:0,maximum:500,description:"Maximum slippage in basis points (50 = 0.5%), 0 to 500. Default 50."}},ue=["beefy_swap","beefy_add_liquidity","beefy_remove_liquidity"];function de(s,h){let f=()=>{throw new d("Beefy calldata differs from locally reconstructed inputs, recipient, route or minimums; nothing was signed.")};s.length!==h.length&&f();for(let q=0;q<s.length;q++){let P=s[q],v=h[q];if((P.chainId!==v.chainId||!N(P.to,v.to)||P.value!==v.value)&&f(),!N(P.data,v.data))try{let B=X({abi:E,data:P.data}),n=X({abi:E,data:v.data});(B.functionName!==n.functionName||!B.args||!n.args)&&f();let t=[...B.args],a=n.args,r=B.functionName==="swapExactTokensForTokens"?[1]:B.functionName==="addLiquidity"?[5,6]:B.functionName==="removeLiquidity"?[4,5]:f(),i=x({abi:E,functionName:B.functionName,args:t});N(i,P.data)||f();let u=t.length-1;(l(t[u])<=l(a[u])-600n||l(t[u])>l(a[u]))&&f(),t[u]=a[u];for(let o of r)l(t[o])<l(a[o])&&f(),t[o]=a[o];N(x({abi:E,functionName:B.functionName,args:t}),v.data)||f()}catch{f()}}}function y(s){return V(s,"Provide a token or vault address.",Y)}function G(s){return z(s,"Amount must be positive and fit in uint256.",{notString:"Provide a positive base-unit integer string.",positive:!0})}function l(s){return Q(s,"Invalid Beefy liquidity integer.")}function M(s){let h=s??50;if(typeof h!="number"||!Number.isInteger(h)||h<0||h>500)throw new d("Use integer slippageBps from 0 to 500.");return BigInt(h)}function W(s,h){let f=s*(10000n-h)/10000n;if(f===0n)throw new d("The liquidity amount is too small for a positive minimum output.");return f}var ce=s=>{async function h(n){try{return await n()}catch(t){throw new d(s.plainError(t))}}function f(n,t){if(n.chainId!==void 0&&n.chainId!==p)throw new d("Beefy requires chain 4663.");for(let a of Object.keys(n))if(!["vault","chainId",...t].includes(a))throw new d(`Unsupported Beefy input: ${a}.`);if(y(n.vault)!==L(R[p].vaults.beefyTestedLpVault.address))throw new d("Beefy LP routes are qualified only for up33-weth-up.")}async function q(){let n=s.clientFor(p);if(await n.getChainId()!==p)throw new d("The Beefy endpoint must report chain 4663.");let t=l(await n.getBlockNumber()),a=await n.getBlock({blockNumber:t}),r=l(a.timestamp)+600n,i=(S,g,A=[])=>n.readContract({address:S,abi:E,functionName:g,args:A,blockNumber:t}),[u,o,m,c,w,b]=await Promise.all([i(e.pair,"token0"),i(e.pair,"token1"),i(e.pair,"factory"),i(e.router,"defaultFactory"),i(e.pair,"stable"),n.readContract({address:R[p].vaults.beefyTestedLpVault.address,abi:ee,functionName:"want",blockNumber:t})]);if(y(u)!==e.weth||y(o)!==e.up||y(m)!==e.factory||y(c)!==e.factory||w!==!1||y(b)!==e.pair)throw new d("The Beefy LP, vault or router no longer matches the qualified route.");if(y(await i(e.router,"poolFor",[e.weth,e.up,!1,e.factory]))!==e.pair)throw new d("The router selects a different Beefy LP.");let k=async(S,g)=>l(await n.readContract({address:S,abi:F,functionName:"balanceOf",args:[g],blockNumber:t}));async function T(S){let[g,A]=await Promise.all([n.readContract({address:S,abi:F,functionName:"symbol",blockNumber:t}),n.readContract({address:S,abi:F,functionName:"decimals",blockNumber:t})]);if(typeof g!="string"||!g.trim()||typeof A!="number"||!Number.isInteger(A)||A<0||A>255)throw new d("Invalid Beefy constituent metadata.");return{address:S,symbol:g,decimals:A,chainId:p}}return{client:n,blockNumber:t,deadline:r,read:i,balance:k,token:T}}async function P(n,t,a){let r=await s.preview(n,t);return{txs:n,preview:r,summary:`${a} ${r.summary} Re-read balances after mining each step; these transactions are separate and earlier steps can remain mined if a later step fails. Gas is additional.`}}function v(n,t,a,r="0"){return s.unsignedTx({to:n,data:t,value:r,description:a,chainId:p})}return{tools:[{name:"beefy_lp",inputSchema:{type:"object",properties:{vault:{...D,description:"Address of the Beefy vault contract (from beefy_list)."},chainId:{const:p,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},amount:{...I(),description:'Optional CLM entry budget in base units of the bridge token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals.'},slippageBps:O.slippageBps},required:["vault"],additionalProperties:!1},execute:(n,t)=>h(async()=>{if(J.some(b=>N(b.vault,y(n.vault))))return K(s).tools[0].execute(n,t);f(n,[]),H(t);let a=await q(),[r,i,u,o,m,c,w]=await Promise.all([a.token(e.weth),a.token(e.up),a.token(e.pair),a.read(e.pair,"getReserves"),a.balance(e.weth,t),a.balance(e.up,t),a.balance(e.pair,t)]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy LP reserves.");return{chainId:p,vault:y(n.vault),router:e.router,factory:e.factory,stable:!1,constituents:[{token:r,balance:m.toString(),reserve:l(o[0]).toString()},{token:i,balance:c.toString(),reserve:l(o[1]).toString()}],lp:{token:u,balance:w.toString()},block:a.blockNumber.toString(),summary:"Acquire WETH and UP with beefy_swap; add with beefy_add_liquidity, then deposit the mined LP balance with beefy_deposit. Withdraw moo shares, remove LP with beefy_remove_liquidity, then swap constituents to USDG. Every action requires its own preview and local confirmation."}})},{name:"beefy_swap",inputSchema:{type:"object",properties:{...O,from:{...D,description:"Address of the token to sell: native ETH placeholder, WETH, UP or USDG."},to:{...D,description:"Address of the token to receive: WETH, UP or USDG, different from the input token."},amount:I('Amount of the input token in base units of that token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals; "1000000000000000000" = 1 WETH.')},required:["vault","from","to","amount"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["from","to","amount","slippageBps"]),H(t);let a=y(n.from),r=y(n.to),i=G(n.amount),u=M(n.slippageBps),o=[e.weth,e.up,L(j)],m=a.toLowerCase()===e.eth;if(!m&&!o.includes(a)||!o.includes(r)||a===r)throw new d("Use ETH, WETH, UP or USDG as input and a different WETH, UP or USDG output.");let c=await q();if((m?await c.client.getBalance({address:t,blockNumber:c.blockNumber}):await c.balance(a,t))<i)throw new d("Insufficient Beefy swap input balance; keep ETH for gas.");let w=[];m&&w.push(v(e.weth,x({abi:E,functionName:"deposit"}),`Wrap ${i} ETH base units for the Beefy LP workflow.`,i.toString()));let b=m?e.weth:a,k=i,T=i;if(b!==r){let g=b===e.weth||r===e.weth?[b,r]:[b,e.weth,r],A=[];for(let U=0;U<g.length-1;U++){let C={from:g[U],to:g[U+1],stable:!1,factory:e.factory},$=y(await c.read(e.factory,"getPool",[C.from,C.to,!1]));if($==="0x0000000000000000000000000000000000000000"||$!==y(await c.read(e.router,"poolFor",[C.from,C.to,!1,e.factory])))throw new d("No verified Up33 route for these Beefy constituents.");A.push(C)}let _=await c.read(e.router,"getAmountsOut",[i,A]);if(!Array.isArray(_)||_.length!==g.length||l(_[0])!==i)throw new d("Invalid Beefy constituent quote.");for(let U of _)if(l(U)===0n)throw new d("No liquidity for this Beefy constituent swap.");k=l(_.at(-1)),T=W(k,u),w.push(s.approval(b,e.router,i.toString(),p)),w.push(v(e.router,x({abi:E,functionName:"swapExactTokensForTokens",args:[i,T,A,t,c.deadline]}),`Swap ${i} constituent base units; receive at least ${T} output base units.`))}let S=await c.token(r);return{...await P(w,t,"Prepare or convert Beefy LP constituents using the verified Up33 router."),output:{token:S,amount:k.toString()},minimumOutput:{token:S,amount:T.toString()},deadline:c.deadline.toString()}})},{name:"beefy_add_liquidity",inputSchema:{type:"object",properties:{...O,amount0:I('Amount of WETH to add in base units (WETH has 18 decimals). Example: "1000000000000000000" = 1 WETH.'),amount1:I('Amount of UP to add in base units of the UP token (read its decimals). Example: "1000000000000000000" = 1 UP at 18 decimals.')},required:["vault","amount0","amount1"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["amount0","amount1","slippageBps"]),H(t);let a=G(n.amount0),r=G(n.amount1),i=M(n.slippageBps),u=await q();if(await u.balance(e.weth,t)<a||await u.balance(e.up,t)<r)throw new d("Acquire the WETH and UP constituents with beefy_swap, then retry with their mined balances.");let o=await u.read(e.router,"quoteAddLiquidity",[e.weth,e.up,!1,e.factory,a,r]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy add-liquidity quote.");let m=l(o[0]),c=l(o[1]),w=l(o[2]);if(m>a||c>r||w===0n)throw new d("Invalid Beefy add-liquidity amounts.");let b=W(m,i),k=W(c,i),T=[s.approval(e.weth,e.router,a.toString(),p),s.approval(e.up,e.router,r.toString(),p),v(e.router,x({abi:E,functionName:"addLiquidity",args:[e.weth,e.up,!1,a,r,b,k,t,u.deadline]}),"Mint the supported Beefy want LP directly to the calling wallet."),s.approval(e.weth,e.router,"0",p),s.approval(e.up,e.router,"0",p)];return{...await P(T,t,"Mint UP\u2013WETH LP. The router may use less than the approved desired amounts; final revocations clear unused allowances. Deposit the actual LP received in a separate beefy_deposit call."),output:{token:await u.token(e.pair),amount:w.toString()},minimumInputs:[{token:await u.token(e.weth),amount:b.toString()},{token:await u.token(e.up),amount:k.toString()}],deadline:u.deadline.toString()}})},{name:"beefy_remove_liquidity",inputSchema:{type:"object",properties:{...O,amount:{description:'Amount of UP-WETH LP tokens to remove, in base units of the LP token (18 decimals). Example: "1000000000000000000" = 1 LP token. "all" removes your full LP balance.',anyOf:[I(),{const:"all"}]}},required:["vault","amount"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["amount","slippageBps"]),H(t);let a=M(n.slippageBps),r=n.amount==="all"?void 0:G(n.amount),i=await q(),u=await i.balance(e.pair,t),o=r??u;if(o===0n||o>u)throw new d("Withdraw your moo shares first, then provide a positive LP amount no greater than the fresh LP balance.");let[m,c,w]=await Promise.all([i.client.readContract({address:e.pair,abi:F,functionName:"totalSupply",blockNumber:i.blockNumber}),i.balance(e.weth,e.pair),i.balance(e.up,e.pair)]);if(l(m)===0n||o>m)throw new d("Invalid Beefy LP total supply.");let b=W(c*o/m,a),k=W(w*o/m,a),T=[s.approval(e.pair,e.router,o.toString(),p),v(e.router,x({abi:E,functionName:"removeLiquidity",args:[e.weth,e.up,!1,o,b,k,t,i.deadline]}),"Burn Beefy want LP and return WETH and UP to the calling wallet.")];return{...await P(T,t,"Remove UP\u2013WETH liquidity. Convert actual received constituents to USDG with beefy_swap after mining."),minimumOutputs:[{token:await i.token(e.weth),amount:b.toString()},{token:await i.token(e.up),amount:k.toString()}],deadline:i.deadline.toString()}})}]}};export{e as a,E as b,ue as c,de as d,ce as e};
|
|
1
|
+
import{a as J,i as K}from"./4RTXP2YP.js";import{a as H}from"./43LI5NKJ.js";import{a as I}from"./66F5ZH34.js";import{c as D,d as Y,g as N,i as V,m as Q,n as z}from"./NWNYJ26T.js";import{b as p,j as R,k as j}from"./EWZFZUVF.js";import{a as d}from"./XSD5NL7J.js";import{decodeFunctionData as X,encodeFunctionData as x,erc20Abi as F,getAddress as L,parseAbi as Z}from"viem";var e={router:L("0xf5198743240fac98db71868f34c70139b1eb0474"),factory:L("0xfa5429aeba338bea2bfcc1b9a889862ee395bc28"),pair:L("0x8697bb63743678640710b1270e98772a29642b3c"),weth:L("0x0bd7d308f8e1639fab988df18a8011f41eacad73"),up:L("0x57c0e45cb534413d1c20a4240955d6bb250bb4f1"),eth:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"},E=Z(["function token0() view returns (address)","function token1() view returns (address)","function factory() view returns (address)","function defaultFactory() view returns (address)","function stable() view returns (bool)","function getReserves() view returns (uint112,uint112,uint32)","function poolFor(address,address,bool,address) view returns (address)","function getPool(address,address,bool) view returns (address)","function getAmountsOut(uint256,(address from,address to,bool stable,address factory)[]) view returns (uint256[])","function quoteAddLiquidity(address,address,bool,address,uint256,uint256) view returns (uint256,uint256,uint256)","function addLiquidity(address,address,bool,uint256,uint256,uint256,uint256,address,uint256) returns (uint256,uint256,uint256)","function removeLiquidity(address,address,bool,uint256,uint256,uint256,address,uint256) returns (uint256,uint256)","function swapExactTokensForTokens(uint256,uint256,(address from,address to,bool stable,address factory)[],address,uint256) returns (uint256[])","function deposit() payable"]),ee=Z(["function want() view returns (address)"]),O={vault:{...D,description:"Address of the Beefy vault contract (from beefy_list)."},chainId:{const:p,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},slippageBps:{type:"integer",minimum:0,maximum:500,description:"Maximum slippage in basis points (50 = 0.5%), 0 to 500. Default 50."}},ue=["beefy_swap","beefy_add_liquidity","beefy_remove_liquidity"];function de(s,h){let f=()=>{throw new d("Beefy calldata differs from locally reconstructed inputs, recipient, route or minimums; nothing was signed.")};s.length!==h.length&&f();for(let q=0;q<s.length;q++){let P=s[q],v=h[q];if((P.chainId!==v.chainId||!N(P.to,v.to)||P.value!==v.value)&&f(),!N(P.data,v.data))try{let B=X({abi:E,data:P.data}),n=X({abi:E,data:v.data});(B.functionName!==n.functionName||!B.args||!n.args)&&f();let t=[...B.args],a=n.args,r=B.functionName==="swapExactTokensForTokens"?[1]:B.functionName==="addLiquidity"?[5,6]:B.functionName==="removeLiquidity"?[4,5]:f(),i=x({abi:E,functionName:B.functionName,args:t});N(i,P.data)||f();let u=t.length-1;(l(t[u])<=l(a[u])-600n||l(t[u])>l(a[u]))&&f(),t[u]=a[u];for(let o of r)l(t[o])<l(a[o])&&f(),t[o]=a[o];N(x({abi:E,functionName:B.functionName,args:t}),v.data)||f()}catch{f()}}}function y(s){return V(s,"Provide a token or vault address.",Y)}function G(s){return z(s,"Amount must be positive and fit in uint256.",{notString:"Provide a positive base-unit integer string.",positive:!0})}function l(s){return Q(s,"Invalid Beefy liquidity integer.")}function M(s){let h=s??50;if(typeof h!="number"||!Number.isInteger(h)||h<0||h>500)throw new d("Use integer slippageBps from 0 to 500.");return BigInt(h)}function W(s,h){let f=s*(10000n-h)/10000n;if(f===0n)throw new d("The liquidity amount is too small for a positive minimum output.");return f}var ce=s=>{async function h(n){try{return await n()}catch(t){throw new d(s.plainError(t))}}function f(n,t){if(n.chainId!==void 0&&n.chainId!==p)throw new d("Beefy requires chain 4663.");for(let a of Object.keys(n))if(!["vault","chainId",...t].includes(a))throw new d(`Unsupported Beefy input: ${a}.`);if(y(n.vault)!==L(R[p].vaults.beefyTestedLpVault.address))throw new d("Beefy LP routes are qualified only for up33-weth-up.")}async function q(){let n=s.clientFor(p);if(await n.getChainId()!==p)throw new d("The Beefy endpoint must report chain 4663.");let t=l(await n.getBlockNumber()),a=await n.getBlock({blockNumber:t}),r=l(a.timestamp)+600n,i=(S,g,A=[])=>n.readContract({address:S,abi:E,functionName:g,args:A,blockNumber:t}),[u,o,m,c,w,b]=await Promise.all([i(e.pair,"token0"),i(e.pair,"token1"),i(e.pair,"factory"),i(e.router,"defaultFactory"),i(e.pair,"stable"),n.readContract({address:R[p].vaults.beefyTestedLpVault.address,abi:ee,functionName:"want",blockNumber:t})]);if(y(u)!==e.weth||y(o)!==e.up||y(m)!==e.factory||y(c)!==e.factory||w!==!1||y(b)!==e.pair)throw new d("The Beefy LP, vault or router no longer matches the qualified route.");if(y(await i(e.router,"poolFor",[e.weth,e.up,!1,e.factory]))!==e.pair)throw new d("The router selects a different Beefy LP.");let k=async(S,g)=>l(await n.readContract({address:S,abi:F,functionName:"balanceOf",args:[g],blockNumber:t}));async function T(S){let[g,A]=await Promise.all([n.readContract({address:S,abi:F,functionName:"symbol",blockNumber:t}),n.readContract({address:S,abi:F,functionName:"decimals",blockNumber:t})]);if(typeof g!="string"||!g.trim()||typeof A!="number"||!Number.isInteger(A)||A<0||A>255)throw new d("Invalid Beefy constituent metadata.");return{address:S,symbol:g,decimals:A,chainId:p}}return{client:n,blockNumber:t,deadline:r,read:i,balance:k,token:T}}async function P(n,t,a){let r=await s.preview(n,t);return{txs:n,preview:r,summary:`${a} ${r.summary} Re-read balances after mining each step; these transactions are separate and earlier steps can remain mined if a later step fails. Gas is additional.`}}function v(n,t,a,r="0"){return s.unsignedTx({to:n,data:t,value:r,description:a,chainId:p})}return{tools:[{name:"beefy_lp",inputSchema:{type:"object",properties:{vault:{...D,description:"Address of the Beefy vault contract (from beefy_list)."},chainId:{const:p,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},amount:{...I(),description:'Optional CLM entry budget in base units of the bridge token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals.'},slippageBps:O.slippageBps},required:["vault"],additionalProperties:!1},execute:(n,t)=>h(async()=>{if(J.some(b=>N(b.vault,y(n.vault))))return K(s).tools[0].execute(n,t);f(n,[]),H(t);let a=await q(),[r,i,u,o,m,c,w]=await Promise.all([a.token(e.weth),a.token(e.up),a.token(e.pair),a.read(e.pair,"getReserves"),a.balance(e.weth,t),a.balance(e.up,t),a.balance(e.pair,t)]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy LP reserves.");return{chainId:p,vault:y(n.vault),router:e.router,factory:e.factory,stable:!1,constituents:[{token:r,balance:m.toString(),reserve:l(o[0]).toString()},{token:i,balance:c.toString(),reserve:l(o[1]).toString()}],lp:{token:u,balance:w.toString()},block:a.blockNumber.toString(),summary:"Acquire WETH and UP with beefy_swap; add with beefy_add_liquidity, then deposit the mined LP balance with beefy_deposit. Withdraw moo shares, remove LP with beefy_remove_liquidity, then swap constituents to USDG. Every action requires its own preview and local confirmation."}})},{name:"beefy_swap",inputSchema:{type:"object",properties:{...O,from:{...D,description:"Address of the token to sell: native ETH placeholder, WETH, UP or USDG."},to:{...D,description:"Address of the token to receive: WETH, UP or USDG, different from the input token."},amount:I('Amount of the input token in base units of that token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals; "1000000000000000000" = 1 WETH.')},required:["vault","from","to","amount"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["from","to","amount","slippageBps"]),H(t);let a=y(n.from),r=y(n.to),i=G(n.amount),u=M(n.slippageBps),o=[e.weth,e.up,L(j)],m=a.toLowerCase()===e.eth;if(!m&&!o.includes(a)||!o.includes(r)||a===r)throw new d("Use ETH, WETH, UP or USDG as input and a different WETH, UP or USDG output.");let c=await q();if((m?await c.client.getBalance({address:t,blockNumber:c.blockNumber}):await c.balance(a,t))<i)throw new d("Insufficient Beefy swap input balance; keep ETH for gas.");let w=[];m&&w.push(v(e.weth,x({abi:E,functionName:"deposit"}),`Wrap ${i} ETH base units for the Beefy LP workflow.`,i.toString()));let b=m?e.weth:a,k=i,T=i;if(b!==r){let g=b===e.weth||r===e.weth?[b,r]:[b,e.weth,r],A=[];for(let U=0;U<g.length-1;U++){let C={from:g[U],to:g[U+1],stable:!1,factory:e.factory},$=y(await c.read(e.factory,"getPool",[C.from,C.to,!1]));if($==="0x0000000000000000000000000000000000000000"||$!==y(await c.read(e.router,"poolFor",[C.from,C.to,!1,e.factory])))throw new d("No verified Up33 route for these Beefy constituents.");A.push(C)}let _=await c.read(e.router,"getAmountsOut",[i,A]);if(!Array.isArray(_)||_.length!==g.length||l(_[0])!==i)throw new d("Invalid Beefy constituent quote.");for(let U of _)if(l(U)===0n)throw new d("No liquidity for this Beefy constituent swap.");k=l(_.at(-1)),T=W(k,u),w.push(s.approval(b,e.router,i.toString(),p)),w.push(v(e.router,x({abi:E,functionName:"swapExactTokensForTokens",args:[i,T,A,t,c.deadline]}),`Swap ${i} constituent base units; receive at least ${T} output base units.`))}let S=await c.token(r);return{...await P(w,t,"Prepare or convert Beefy LP constituents using the verified Up33 router."),output:{token:S,amount:k.toString()},minimumOutput:{token:S,amount:T.toString()},deadline:c.deadline.toString()}})},{name:"beefy_add_liquidity",inputSchema:{type:"object",properties:{...O,amount0:I('Amount of WETH to add in base units (WETH has 18 decimals). Example: "1000000000000000000" = 1 WETH.'),amount1:I('Amount of UP to add in base units of the UP token (read its decimals). Example: "1000000000000000000" = 1 UP at 18 decimals.')},required:["vault","amount0","amount1"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["amount0","amount1","slippageBps"]),H(t);let a=G(n.amount0),r=G(n.amount1),i=M(n.slippageBps),u=await q();if(await u.balance(e.weth,t)<a||await u.balance(e.up,t)<r)throw new d("Acquire the WETH and UP constituents with beefy_swap, then retry with their mined balances.");let o=await u.read(e.router,"quoteAddLiquidity",[e.weth,e.up,!1,e.factory,a,r]);if(!Array.isArray(o)||o.length!==3)throw new d("Invalid Beefy add-liquidity quote.");let m=l(o[0]),c=l(o[1]),w=l(o[2]);if(m>a||c>r||w===0n)throw new d("Invalid Beefy add-liquidity amounts.");let b=W(m,i),k=W(c,i),T=[s.approval(e.weth,e.router,a.toString(),p),s.approval(e.up,e.router,r.toString(),p),v(e.router,x({abi:E,functionName:"addLiquidity",args:[e.weth,e.up,!1,a,r,b,k,t,u.deadline]}),"Mint the supported Beefy want LP directly to the calling wallet."),s.approval(e.weth,e.router,"0",p),s.approval(e.up,e.router,"0",p)];return{...await P(T,t,"Mint UP\u2013WETH LP. The router may use less than the approved desired amounts; final revocations clear unused allowances. Deposit the actual LP received in a separate beefy_deposit call."),output:{token:await u.token(e.pair),amount:w.toString()},minimumInputs:[{token:await u.token(e.weth),amount:b.toString()},{token:await u.token(e.up),amount:k.toString()}],deadline:u.deadline.toString()}})},{name:"beefy_remove_liquidity",inputSchema:{type:"object",properties:{...O,amount:{description:'Amount of UP-WETH LP tokens to remove, in base units of the LP token (18 decimals). Example: "1000000000000000000" = 1 LP token. "all" removes your full LP balance.',anyOf:[I(),{const:"all"}]}},required:["vault","amount"],additionalProperties:!1},execute:(n,t)=>h(async()=>{f(n,["amount","slippageBps"]),H(t);let a=M(n.slippageBps),r=n.amount==="all"?void 0:G(n.amount),i=await q(),u=await i.balance(e.pair,t),o=r??u;if(o===0n||o>u)throw new d("Withdraw your moo shares first, then provide a positive LP amount no greater than the fresh LP balance.");let[m,c,w]=await Promise.all([i.client.readContract({address:e.pair,abi:F,functionName:"totalSupply",blockNumber:i.blockNumber}),i.balance(e.weth,e.pair),i.balance(e.up,e.pair)]);if(l(m)===0n||o>m)throw new d("Invalid Beefy LP total supply.");let b=W(c*o/m,a),k=W(w*o/m,a),T=[s.approval(e.pair,e.router,o.toString(),p),v(e.router,x({abi:E,functionName:"removeLiquidity",args:[e.weth,e.up,!1,o,b,k,t,i.deadline]}),"Burn Beefy want LP and return WETH and UP to the calling wallet.")];return{...await P(T,t,"Remove UP\u2013WETH liquidity. Convert actual received constituents to USDG with beefy_swap after mining."),minimumOutputs:[{token:await i.token(e.weth),amount:b.toString()},{token:await i.token(e.up),amount:k.toString()}],deadline:i.deadline.toString()}})}]}};export{e as a,E as b,ue as c,de as d,ce as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as T,f as de,g as B,i as ce,j as O}from"./JDHPMS7X.js";import{F as I,a as te,b as se,c as _,f as L,h as S,m as ne,n as y,r as z,s as ie,t as re,v as ae}from"./FRT6AC6M.js";import{f as W,g as oe}from"./3BQ5XHDJ.js";import{a as U}from"./YEIM6BZQ.js";import{a as K}from"./Z7FGEWO2.js";import{h as ee}from"./QA6Z2CYP.js";import{c as Q}from"./CFPJDLTZ.js";import{a as J}from"./43LI5NKJ.js";import{g as E}from"./NWNYJ26T.js";import{b as k,n as Z}from"./TI727O2H.js";import{a as b,b as F,e as Y}from"./XSD5NL7J.js";import{decodeAbiParameters as be,getAddress as v,pad as le,parseAbi as me,parseAbiParameters as ke,toEventSelector as ye,toHex as ue,zeroAddress as he}from"viem";var Ae=ye("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),Ie=ke("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),ve=10000000n,Ce=10000n,ge=25,X=200,q=16,Se=3e3,_e=500,Le=500n,R=100,$=me(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ne=me(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function Ee(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===he||e===K.toLowerCase()}function fe(o,e){if(o!=null){if(typeof o!="string")throw new b(`${e} must be a token address, or "eth" for native ETH.`);return Ee(o)?{eth:!0}:(J(o),{eth:!1,address:v(o)})}}var we=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function H(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function Pe(o,e,r,i,a){let[t,s,f]=await Promise.all([o.readContract({address:e,abi:O,functionName:"slot0"}),o.readContract({address:e,abi:O,functionName:"liquidity"}),o.readContract({address:e,abi:O,functionName:"tickSpacing"})]),n=BigInt(t[0]);return{version:"v3",id:e,feePercent:U(a),highFee:a>=5e4,token0:H(r),token1:H(i),fee:a,tickSpacing:Number(f),initialized:n>0n,liquidity:BigInt(s).toString(),sqrtPriceX96:n.toString(),tick:Number(t[1]),price:n>0n?W(n,r.decimals,i.decimals):"0",addSupported:!0}}async function x(o,e,r){let i=r??re(e),[a,t]=await Promise.all([I(o,e.currency0,k),I(o,e.currency1,k)]),[s,f]=await Promise.all([o.readContract({address:_,abi:$,functionName:"getSlot0",args:[i]}),o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[i]})]),n=BigInt(s[0]),w=ae(e,Number(s[3]));return{version:"v4",id:i,feePercent:U((e.fee&8388608)!==0?Number(s[3]):e.fee),highFee:((e.fee&8388608)!==0?Number(s[3]):e.fee)>=5e4,token0:H(a),token1:H(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:v(e.hooks),initialized:n>0n,liquidity:BigInt(f).toString(),sqrtPriceX96:n.toString(),tick:Number(s[1]),price:n>0n?W(n,a.decimals,t.decimals):"0",addSupported:z.has(e.hooks.toLowerCase()),feeNote:w.feeNote,...z.has(e.hooks.toLowerCase())?{}:{note:i.toLowerCase()===Q.poolId?ee:e.hooks.toLowerCase()===Z.toLowerCase()?new ne(ie(e.currency0)?e.currency1:void 0).message:`Hook ${v(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Te(o,e,r,i){let a=await o.getBlockNumber(),t=[],s=new Set,f=!1,n=ve;for(let d=a;;){let u=d+1n>n?d-n+1n:0n,l;try{l=await o.request({method:"eth_getLogs",params:[{address:te.toLowerCase(),topics:[Ae,null,e?le(e):null,r?le(r):null],fromBlock:ue(u),toBlock:ue(d)}]})}catch(p){if(F(p,-32601)||n<=Ce)throw p;n/=2n;continue}if(!Array.isArray(l))throw new b("Invalid v4 Initialize log response.");let P=[];for(let p of l){if(!Array.isArray(p.topics)||p.topics.length!==4||typeof p.data!="string")throw new b("Invalid v4 Initialize log.");let[A,C,N]=be(Ie,p.data),D={currency0:v(`0x${p.topics[2].slice(-40)}`),currency1:v(`0x${p.topics[3].slice(-40)}`),fee:Number(A),tickSpacing:Number(C),hooks:v(N)};P.push({key:D,id:p.topics[1]}),s.add(p.topics[1].toLowerCase())}if(t.push(P),u===0n)break;if(s.size>=i){f=!0;break}d=u-1n}let w=new Map;for(let d of t.reverse())for(let u of d)w.set(u.id.toLowerCase(),u);return{pools:[...w.values()],cut:f}}async function Be(o,e,r){let i=e.eth?T.weth:e.address,a=r.eth?T.weth:r.address;if(i===a)return[];let[t,s]=we(i,a)<0?[i,a]:[a,i],[f,n]=await Promise.all([I(o,t,k),I(o,s,k)]),w=[];for(let d of Object.keys(de).map(Number)){let u=v(String(await o.readContract({address:T.factory,abi:ce,functionName:"getPool",args:[t,s,d]})));u!==he&&w.push(await Pe(o,u,f,n,d))}return w}function pe(o){return o?o.eth?[S,L]:o.address===L?[L,S]:[o.address]:null}async function Oe(o,e){let r=new Map;if(e.length===0)return r;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(a=>({address:_,abi:$,functionName:"getLiquidity",args:[a]}))})).forEach((a,t)=>r.set(e[t].toLowerCase(),a.status==="success"?BigInt(a.result):0n)),r}catch{}for(let i=0;i<e.length;i+=q)(await Promise.allSettled(e.slice(i,i+q).map(async t=>BigInt(await o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[t]}))))).forEach((t,s)=>r.set(e[i+s].toLowerCase(),t.status==="fulfilled"?t.value:0n));return r}async function Re(o,e,r,i){let a=pe(e),t=pe(r),s=new Map,f=(c,h)=>{if(c&&h){if(c===h)return;let[m,g]=we(c,h)<0?[c,h]:[h,c];s.set(`${m}/${g}`,[m,g])}else if(c||h){let m=c??h;s.set(`${m}/*0`,[m,null]),s.set(`${m}/*1`,[null,m])}};for(let c of a??[null])for(let h of t??[null])f(c,h);let n=new Map;for(let c of y)[...s.values()].some(([m,g])=>(!m||E(c.key.currency0,m))&&(!g||E(c.key.currency1,g)))&&n.set(c.poolId.toLowerCase(),{key:c.key,id:c.poolId});let d=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?Se:_e,u=!1;for(let[c,h]of s.values()){let m=await Te(o,c,h,d+y.length);u||=m.cut;for(let g of m.pools)n.set(g.id.toLowerCase(),g)}let l=new Set(y.map(c=>c.poolId.toLowerCase())),P=[...n.values()],p=P.filter(c=>l.has(c.id.toLowerCase())),A=P.filter(c=>!l.has(c.id.toLowerCase())).reverse();(A.length>d||u)&&i.push(`${u?"At least ":""}${A.length} v4 pools match; only the newest ${d} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let C=A.slice(0,d),N=await Oe(o,C.map(c=>c.id)),D=C.sort((c,h)=>{let m=N.get(c.id.toLowerCase())??0n,g=N.get(h.id.toLowerCase())??0n;return m===g?0:m<g?1:-1}),V=[...p,...D];V.length>X&&i.push(`${V.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${X} total). Pass both tokens, or a poolId, to narrow.`);let G=[],M=0,j=V.slice(0,X);for(let c=0;c<j.length;c+=q){let h=await Promise.allSettled(j.slice(c,c+q).map(({key:m,id:g})=>x(o,m,g)));for(let m of h)m.status==="fulfilled"?G.push(m.value):M++}return M>0&&i.push(`${M} pool(s) were skipped because a token or pool state could not be read.`),G}async function qe(o,e){let r=y.find(n=>E(n.poolId,e));if(r)return x(o,r.key,r.poolId);let[i,a,t,s,f]=await o.readContract({address:se,abi:Ne,functionName:"poolKeys",args:[e.slice(0,52)]});if(i===S&&a===S&&Number(s)===0)throw new b(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return x(o,{currency0:i,currency1:a,fee:Number(t),tickSpacing:Number(s),hooks:f},e)}function $e(o){let e=new Set([...y.map(t=>t.poolId.toLowerCase()),...B.map(t=>t.address.toLowerCase())]),r=new Set([S,K.toLowerCase(),L.toLowerCase()]),i=t=>r.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),a=new Map;for(let t of o.filter(s=>s.initialized&&BigInt(s.liquidity)>0n)){let s=`${i(t.token0)}/${i(t.token1)}`;a.set(s,[...a.get(s)??[],t])}for(let t of a.values()){let s=t.filter(d=>e.has(d.id.toLowerCase()));if(s.length===0&&t.length<3)continue;let n=(s.length>0?s:t).map(d=>BigInt(d.sqrtPriceX96)).sort((d,u)=>d<u?-1:d>u?1:0),w=n[Math.floor(n.length/2)];for(let d of t){if(e.has(d.id.toLowerCase()))continue;let u=oe(BigInt(d.sqrtPriceX96),w);u>Le&&(d.priceOutlierBps=Number(u),d.note=`${d.note?`${d.note} `:""}Price differs ${u} bps from the ${s.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function He(o,e){let r=e.version;if(r!==void 0&&r!=="v3"&&r!=="v4")throw new b('version must be "v3" or "v4"; omit it to search both.');let i=e.limit===void 0?ge:Number(e.limit);if(!Number.isInteger(i)||i<1||i>R)throw new b(`limit must be an integer from 1 to ${R}.`);let a=fe(e.tokenA,"tokenA"),t=fe(e.tokenB,"tokenB");if(!a&&t)throw new b("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let s=o.clientFor(k),f=[],n=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new b("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");n=[await qe(s,e.poolId)]}else if(a){if(r!=="v4"&&(t?n.push(...await Be(s,a,t)):f.push("v3 pools are looked up per pair; pass tokenB to include them.")),r!=="v3")try{n.push(...await Re(s,a,t,f))}catch(l){throw F(l,-32601)?l:new b(`Could not search v4 pools. ${Y(l)}`)}}else{f.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let l=await Promise.all(B.map(async p=>{let[A,C]=await Promise.all([I(s,p.token0,k),I(s,p.token1,k)]);return Pe(s,p.address,A,C,p.fee)})),P=await Promise.all(y.map(p=>x(s,p.key,p.poolId)));n=[...r==="v4"?[]:l,...r==="v3"?[]:P]}$e(n);let w=new Set([...y.map(l=>l.poolId.toLowerCase()),...B.map(l=>l.address.toLowerCase())]),d=0;n=n.filter(l=>!l.highFee||w.has(l.id.toLowerCase())?!0:e.includeHighFeePools===!0?(l.note=`Do not trade here: ${l.feePercent} fee.${l.note?` ${l.note}`:""}`,!0):(d++,!1)),d&&f.push(`${d} pools with fees of 5% or more were left out. To see them, pass includeHighFeePools: true.`),n.sort((l,P)=>BigInt(P.liquidity)>BigInt(l.liquidity)?1:BigInt(P.liquidity)<BigInt(l.liquidity)?-1:0),n.length>i&&f.push(`Showing the ${i} deepest of ${n.length} pools found; raise limit (max ${R}) to see more.`),n=n.slice(0,i);let u=n.filter(l=>l.initialized&&BigInt(l.liquidity)>0n).length;return n.length===0&&d===0&&f.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:n,notes:f,summary:`Found ${n.length} Uniswap pool(s), ${u} with active liquidity. price is token1 per 1 token0.`}}function Ye(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},includeHighFeePools:{description:"Include pools above the usual fee threshold in discovery.",type:"boolean"},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:R,default:ge}}},execute:async r=>He(o,r)}]}}export{He as a,Ye as b};
|
|
1
|
+
import{e as T,f as de,g as B,i as ce,j as O}from"./4JU23O3Z.js";import{F as I,a as te,b as se,c as _,f as L,h as S,m as ne,n as y,r as z,s as ie,t as re,v as ae}from"./2ZYFBBOE.js";import{a as W}from"./YEIM6BZQ.js";import{f as U,g as oe}from"./Y7SKGRWC.js";import{a as K}from"./7WXAS54T.js";import{h as ee}from"./QA6Z2CYP.js";import{c as Q}from"./CFPJDLTZ.js";import{a as J}from"./43LI5NKJ.js";import{g as E}from"./NWNYJ26T.js";import{b as k,n as Z}from"./EWZFZUVF.js";import{a as b,b as F,e as Y}from"./XSD5NL7J.js";import{decodeAbiParameters as be,getAddress as v,pad as le,parseAbi as me,parseAbiParameters as ke,toEventSelector as ye,toHex as ue,zeroAddress as he}from"viem";var Ae=ye("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),Ie=ke("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),ve=10000000n,Ce=10000n,ge=25,X=200,q=16,Se=3e3,_e=500,Le=500n,R=100,$=me(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Ne=me(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function Ee(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===he||e===K.toLowerCase()}function fe(o,e){if(o!=null){if(typeof o!="string")throw new b(`${e} must be a token address, or "eth" for native ETH.`);return Ee(o)?{eth:!0}:(J(o),{eth:!1,address:v(o)})}}var we=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function H(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function Pe(o,e,r,i,a){let[t,s,f]=await Promise.all([o.readContract({address:e,abi:O,functionName:"slot0"}),o.readContract({address:e,abi:O,functionName:"liquidity"}),o.readContract({address:e,abi:O,functionName:"tickSpacing"})]),n=BigInt(t[0]);return{version:"v3",id:e,feePercent:W(a),highFee:a>=5e4,token0:H(r),token1:H(i),fee:a,tickSpacing:Number(f),initialized:n>0n,liquidity:BigInt(s).toString(),sqrtPriceX96:n.toString(),tick:Number(t[1]),price:n>0n?U(n,r.decimals,i.decimals):"0",addSupported:!0}}async function x(o,e,r){let i=r??re(e),[a,t]=await Promise.all([I(o,e.currency0,k),I(o,e.currency1,k)]),[s,f]=await Promise.all([o.readContract({address:_,abi:$,functionName:"getSlot0",args:[i]}),o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[i]})]),n=BigInt(s[0]),w=ae(e,Number(s[3]));return{version:"v4",id:i,feePercent:W((e.fee&8388608)!==0?Number(s[3]):e.fee),highFee:((e.fee&8388608)!==0?Number(s[3]):e.fee)>=5e4,token0:H(a),token1:H(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:v(e.hooks),initialized:n>0n,liquidity:BigInt(f).toString(),sqrtPriceX96:n.toString(),tick:Number(s[1]),price:n>0n?U(n,a.decimals,t.decimals):"0",addSupported:z.has(e.hooks.toLowerCase()),feeNote:w.feeNote,...z.has(e.hooks.toLowerCase())?{}:{note:i.toLowerCase()===Q.poolId?ee:e.hooks.toLowerCase()===Z.toLowerCase()?new ne(ie(e.currency0)?e.currency1:void 0).message:`Hook ${v(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Te(o,e,r,i){let a=await o.getBlockNumber(),t=[],s=new Set,f=!1,n=ve;for(let d=a;;){let u=d+1n>n?d-n+1n:0n,l;try{l=await o.request({method:"eth_getLogs",params:[{address:te.toLowerCase(),topics:[Ae,null,e?le(e):null,r?le(r):null],fromBlock:ue(u),toBlock:ue(d)}]})}catch(p){if(F(p,-32601)||n<=Ce)throw p;n/=2n;continue}if(!Array.isArray(l))throw new b("Invalid v4 Initialize log response.");let P=[];for(let p of l){if(!Array.isArray(p.topics)||p.topics.length!==4||typeof p.data!="string")throw new b("Invalid v4 Initialize log.");let[A,C,N]=be(Ie,p.data),D={currency0:v(`0x${p.topics[2].slice(-40)}`),currency1:v(`0x${p.topics[3].slice(-40)}`),fee:Number(A),tickSpacing:Number(C),hooks:v(N)};P.push({key:D,id:p.topics[1]}),s.add(p.topics[1].toLowerCase())}if(t.push(P),u===0n)break;if(s.size>=i){f=!0;break}d=u-1n}let w=new Map;for(let d of t.reverse())for(let u of d)w.set(u.id.toLowerCase(),u);return{pools:[...w.values()],cut:f}}async function Be(o,e,r){let i=e.eth?T.weth:e.address,a=r.eth?T.weth:r.address;if(i===a)return[];let[t,s]=we(i,a)<0?[i,a]:[a,i],[f,n]=await Promise.all([I(o,t,k),I(o,s,k)]),w=[];for(let d of Object.keys(de).map(Number)){let u=v(String(await o.readContract({address:T.factory,abi:ce,functionName:"getPool",args:[t,s,d]})));u!==he&&w.push(await Pe(o,u,f,n,d))}return w}function pe(o){return o?o.eth?[S,L]:o.address===L?[L,S]:[o.address]:null}async function Oe(o,e){let r=new Map;if(e.length===0)return r;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(a=>({address:_,abi:$,functionName:"getLiquidity",args:[a]}))})).forEach((a,t)=>r.set(e[t].toLowerCase(),a.status==="success"?BigInt(a.result):0n)),r}catch{}for(let i=0;i<e.length;i+=q)(await Promise.allSettled(e.slice(i,i+q).map(async t=>BigInt(await o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[t]}))))).forEach((t,s)=>r.set(e[i+s].toLowerCase(),t.status==="fulfilled"?t.value:0n));return r}async function Re(o,e,r,i){let a=pe(e),t=pe(r),s=new Map,f=(c,h)=>{if(c&&h){if(c===h)return;let[m,g]=we(c,h)<0?[c,h]:[h,c];s.set(`${m}/${g}`,[m,g])}else if(c||h){let m=c??h;s.set(`${m}/*0`,[m,null]),s.set(`${m}/*1`,[null,m])}};for(let c of a??[null])for(let h of t??[null])f(c,h);let n=new Map;for(let c of y)[...s.values()].some(([m,g])=>(!m||E(c.key.currency0,m))&&(!g||E(c.key.currency1,g)))&&n.set(c.poolId.toLowerCase(),{key:c.key,id:c.poolId});let d=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?Se:_e,u=!1;for(let[c,h]of s.values()){let m=await Te(o,c,h,d+y.length);u||=m.cut;for(let g of m.pools)n.set(g.id.toLowerCase(),g)}let l=new Set(y.map(c=>c.poolId.toLowerCase())),P=[...n.values()],p=P.filter(c=>l.has(c.id.toLowerCase())),A=P.filter(c=>!l.has(c.id.toLowerCase())).reverse();(A.length>d||u)&&i.push(`${u?"At least ":""}${A.length} v4 pools match; only the newest ${d} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let C=A.slice(0,d),N=await Oe(o,C.map(c=>c.id)),D=C.sort((c,h)=>{let m=N.get(c.id.toLowerCase())??0n,g=N.get(h.id.toLowerCase())??0n;return m===g?0:m<g?1:-1}),V=[...p,...D];V.length>X&&i.push(`${V.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${X} total). Pass both tokens, or a poolId, to narrow.`);let G=[],M=0,j=V.slice(0,X);for(let c=0;c<j.length;c+=q){let h=await Promise.allSettled(j.slice(c,c+q).map(({key:m,id:g})=>x(o,m,g)));for(let m of h)m.status==="fulfilled"?G.push(m.value):M++}return M>0&&i.push(`${M} pool(s) were skipped because a token or pool state could not be read.`),G}async function qe(o,e){let r=y.find(n=>E(n.poolId,e));if(r)return x(o,r.key,r.poolId);let[i,a,t,s,f]=await o.readContract({address:se,abi:Ne,functionName:"poolKeys",args:[e.slice(0,52)]});if(i===S&&a===S&&Number(s)===0)throw new b(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return x(o,{currency0:i,currency1:a,fee:Number(t),tickSpacing:Number(s),hooks:f},e)}function $e(o){let e=new Set([...y.map(t=>t.poolId.toLowerCase()),...B.map(t=>t.address.toLowerCase())]),r=new Set([S,K.toLowerCase(),L.toLowerCase()]),i=t=>r.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),a=new Map;for(let t of o.filter(s=>s.initialized&&BigInt(s.liquidity)>0n)){let s=`${i(t.token0)}/${i(t.token1)}`;a.set(s,[...a.get(s)??[],t])}for(let t of a.values()){let s=t.filter(d=>e.has(d.id.toLowerCase()));if(s.length===0&&t.length<3)continue;let n=(s.length>0?s:t).map(d=>BigInt(d.sqrtPriceX96)).sort((d,u)=>d<u?-1:d>u?1:0),w=n[Math.floor(n.length/2)];for(let d of t){if(e.has(d.id.toLowerCase()))continue;let u=oe(BigInt(d.sqrtPriceX96),w);u>Le&&(d.priceOutlierBps=Number(u),d.note=`${d.note?`${d.note} `:""}Price differs ${u} bps from the ${s.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function He(o,e){let r=e.version;if(r!==void 0&&r!=="v3"&&r!=="v4")throw new b('version must be "v3" or "v4"; omit it to search both.');let i=e.limit===void 0?ge:Number(e.limit);if(!Number.isInteger(i)||i<1||i>R)throw new b(`limit must be an integer from 1 to ${R}.`);let a=fe(e.tokenA,"tokenA"),t=fe(e.tokenB,"tokenB");if(!a&&t)throw new b("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let s=o.clientFor(k),f=[],n=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new b("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");n=[await qe(s,e.poolId)]}else if(a){if(r!=="v4"&&(t?n.push(...await Be(s,a,t)):f.push("v3 pools are looked up per pair; pass tokenB to include them.")),r!=="v3")try{n.push(...await Re(s,a,t,f))}catch(l){throw F(l,-32601)?l:new b(`Could not search v4 pools. ${Y(l)}`)}}else{f.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let l=await Promise.all(B.map(async p=>{let[A,C]=await Promise.all([I(s,p.token0,k),I(s,p.token1,k)]);return Pe(s,p.address,A,C,p.fee)})),P=await Promise.all(y.map(p=>x(s,p.key,p.poolId)));n=[...r==="v4"?[]:l,...r==="v3"?[]:P]}$e(n);let w=new Set([...y.map(l=>l.poolId.toLowerCase()),...B.map(l=>l.address.toLowerCase())]),d=0;n=n.filter(l=>!l.highFee||w.has(l.id.toLowerCase())?!0:e.includeHighFeePools===!0?(l.note=`Do not trade here: ${l.feePercent} fee.${l.note?` ${l.note}`:""}`,!0):(d++,!1)),d&&f.push(`${d} pools with fees of 5% or more were left out. To see them, pass includeHighFeePools: true.`),n.sort((l,P)=>BigInt(P.liquidity)>BigInt(l.liquidity)?1:BigInt(P.liquidity)<BigInt(l.liquidity)?-1:0),n.length>i&&f.push(`Showing the ${i} deepest of ${n.length} pools found; raise limit (max ${R}) to see more.`),n=n.slice(0,i);let u=n.filter(l=>l.initialized&&BigInt(l.liquidity)>0n).length;return n.length===0&&d===0&&f.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:n,notes:f,summary:`Found ${n.length} Uniswap pool(s), ${u} with active liquidity. price is token1 per 1 token0.`}}function Ye(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},includeHighFeePools:{description:"Include pools above the usual fee threshold in discovery.",type:"boolean"},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:R,default:ge}}},execute:async r=>He(o,r)}]}}export{He as a,Ye as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as q,c as M,d as Y}from"./
|
|
1
|
+
import{a as q,c as M,d as Y}from"./7KK3OC7Q.js";import{e as Q,g as j,i as z,j as F}from"./4JU23O3Z.js";import{F as E,c as W,f as H,n as k,t as R,u as K}from"./2ZYFBBOE.js";import{a as L}from"./YEIM6BZQ.js";import{a as O}from"./XSD5NL7J.js";import{getAddress as te,parseAbi as oe,zeroAddress as ne}from"viem";var se=oe(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)"]),G=1n<<192n,m={feeRefusal:t=>`Blocked: this pool charges a ${t} fee on every trade. Oak will not quote or prepare a swap through it. Pick a pool with a normal fee. Only if the person has been told the fee and still wants it, repeat with allowHighFeePools: true.`,lossRefusal:(t,e)=>`Blocked: this route returns about ${t} less than ${e}. Oak will not prepare this swap. Only if the person has been told the loss and still wants it, repeat with acceptValueLoss: true.`,warning:(t,e,i)=>`This route returns about ${t} less than ${e} (pool fee ${i} plus price impact).`,own:"this pool's own current price",noIndependent:"No independent market price was available for this pair, so Oak compared the quote with this pool's own current price only.",feeOverride:t=>`You chose to trade through a pool with a ${t} fee.`,lossOverride:(t,e)=>`This trade returns about ${t} less than ${e}.`},l=t=>t.toLowerCase()===ne?H.toLowerCase():t.toLowerCase(),X=(t,e,i,c)=>l(t)===l(i)&&l(e)===l(c)||l(t)===l(c)&&l(e)===l(i),B=(t,e)=>e?[t*t,G]:[G,t*t];async function de(t,e){let{blockNumber:i}=e,c=[],g=[],T=new Map,V=o=>{let n=R(o),s=T.get(n);return s||(s=t.readContract({address:W,abi:se,functionName:"getSlot0",args:[n],blockNumber:i}),T.set(n,s)),s},C=e.poolKeys??[],x=o=>k.some(n=>n.poolId.toLowerCase()===R(o).toLowerCase()),d=e.version==="v4"?await Promise.all(C.map(async o=>K(o)?Number((await V(o))[3]):o.fee)):e.version==="v3"?e.fees:Array.from({length:e.path.length-1},()=>3e3);for(let o=0;o<d.length;o++){let n=L(d[o]);if(d[o]>=5e4&&!(e.version==="v4"&&x(C[o]))&&!e.allowHighFeePools)throw new O(m.feeRefusal(n));(e.allowHighFeePools||e.acceptValueLoss)&&g.push(m.feeOverride(n))}let I=1n,_=1n,a=e.input,y=[],U=!1;for(let o=0;o<d.length;o++){let n=C[o],s=n?n.currency0===a?n.currency1:n.currency0:e.path[o+1],A=e.references?.[o],p,f;if(A)p=A.numerator,f=A.denominator,y.push(A.label);else{let h=(n&&x(n)?k.find(r=>r.poolId.toLowerCase()===R(n).toLowerCase()):void 0)??k.find(r=>X(a,s,r.key.currency0,r.key.currency1)),v=j.find(r=>X(a,s,r.token0,r.token1));if(h||v){let r=h?h.key.currency0:v.token0,u=h?h.key.currency1:v.token1,J=h?(await V(h.key))[0]:(await t.readContract({address:v.address,abi:F,functionName:"slot0",blockNumber:i}))[0];[p,f]=B(J,l(a)===l(r));let[Z,ee]=await Promise.all([E(t,r),E(t,u)]);y.push(`Oak's measured ${Z.symbol}/${ee.symbol} pool`)}else if(U=!0,y.push(m.own),n)[p,f]=B((await V(n))[0],a===n.currency0);else if(e.version==="v3"){let r=await t.readContract({address:Q.factory,abi:z,functionName:"getPool",args:[a,s,d[o]],blockNumber:i}),u=await t.readContract({address:r,abi:F,functionName:"slot0",blockNumber:i});[p,f]=B(u[0],BigInt(a)<BigInt(s))}else{let r=await t.readContract({address:q,abi:M,functionName:"getPair",args:[a,s],blockNumber:i}),u=await t.readContract({address:r,abi:Y,functionName:"getReserves",blockNumber:i});[p,f]=BigInt(a)<BigInt(s)?[u[1],u[0]]:[u[0],u[1]]}}if(p<=0n||f<=0n)throw new O("No positive Uniswap quote is available.");I*=p,_*=f,a=te(s)}let P=[...new Set(y)].join(" \xD7 "),w=U?m.noIndependent:void 0,b=e.exactOutput?e.quoted*I:e.amount*I,D=e.exactOutput?e.amount*_:e.quoted*_,N=b>D?b-D:0n,S=(N*1000n+b/2n)/b,$=`${S/10n}${S%10n?`.${S%10n}`:""}%`;if(N*10n>=b&&!e.acceptValueLoss)throw new O(`${m.lossRefusal($,P)}${w?` ${w}`:""}`);if((e.allowHighFeePools||e.acceptValueLoss)&&g.push(m.lossOverride($,P)),N*100n>=b*2n){let o=d.reduce((n,s)=>n*BigInt(1e6-s),1000000n)/1000000n**BigInt(d.length);c.push(m.warning($,P,L(Number(1000000n-o))))}return c.unshift(...g),c.length&&w&&c.push(w),{reference:P,...w?{referenceNote:w}:{},...c.length?{warnings:c}:{},confirmationWarnings:g}}export{m as a,de as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as t}from"./342OZP53.js";import{c as o}from"./GV6FZ6UG.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as ee}from"./
|
|
1
|
+
import{c as ee}from"./GVCNTGLC.js";import{a as B}from"./7WXAS54T.js";import{a as q}from"./IOYRL6AY.js";import{c as J,d as X,j as Y,l as Z}from"./NWNYJ26T.js";import{b as w,j as G}from"./EWZFZUVF.js";import{a as f}from"./XSD5NL7J.js";import{a as Q}from"./JXOEJPJ4.js";import{encodeAbiParameters as de,encodeFunctionData as N,erc20Abi as ne,keccak256 as ue,parseAbi as oe,zeroAddress as le}from"viem";var s=oe(["function launchFactory() view returns (address)","function curve() view returns (address)","function factory() view returns (address)","function feeEscrow() view returns (address)","function memeHook() view returns (address)","function buybackVault() view returns (address)","function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))","function balanceOf(address) view returns (uint256)","function balanceOfToken(address account,address token) view returns (uint256)","function quoteFeeBalance() view returns (uint256)","function creatorTaxBalance() view returns (uint256)","function pendingFees(bytes32,address) view returns (uint256)","function pendingCreatorTax(bytes32,address) view returns (uint256)","function releasable(address token) view returns (uint256)","function vestedAmount(address token) view returns (uint256)"]),h=oe(["function sweepFees(uint256 minBuybackTokensOut)","function sweepPoolFees(bytes32 poolId,uint256 minConversionQuoteOut,uint256 minBuybackTokensOut)","function claim()","function claimToken(address token)","function release(address token)","error InternalSwapRequiresOperator()"]),ae={address:B,chainId:w,symbol:"ETH",decimals:18},te=G[w].pons;function c(o){let d=Y(o,"Provide a valid Pons coin address.",X);return Z(d,"Provide a nonzero Pons coin or contract address.")}function pe(o){let d=new Set;for(;o&&typeof o=="object"&&!d.has(o)&&d.size<16;){d.add(o);let l=o;if(l.data==="0x31cdb504"||l.data&&typeof l.data=="object"&&l.data.errorName==="InternalSwapRequiresOperator")return!0;o=l.cause}return!1}async function fe(o,d,l,k=!1,t){let i=c(d),b=c(l),e=o.clientFor(w);if(t===void 0&&await e.getChainId()!==w)throw new f(`Pons claims require chain ${w}.`);let n=t??await e.getBlockNumber(),[R,se]=await Promise.all([e.readContract({address:i,abi:s,functionName:"launchFactory",blockNumber:n}),e.readContract({address:i,abi:s,functionName:"curve",blockNumber:n})]),P=c(te.factory.address);if(c(R)!==P)throw new f("The coin must belong to the pinned Pons factory.");let y=c(se),[r,re,ie]=await Promise.all([e.readContract({address:P,abi:s,functionName:"getLaunchedToken",args:[i],blockNumber:n}),e.readContract({address:y,abi:s,functionName:"factory",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"feeEscrow",blockNumber:n})]);if(!r.exists||c(r.token)!==i||c(r.curve)!==y||c(re)!==P)throw new f("The coin does not resolve to a consistent Pons launch.");if(r.phase<0||r.phase>3)throw new f("This Pons launch phase is unsupported.");let H=c(r.creatorFeeRecipient),A=H===b;if(k&&!A)throw new f("Only the current creator fee recipient can claim these fees. Use the recipient wallet or Safe.");let g=r.pairToken.toLowerCase(),S=g===le,m=c(ie),M=async a=>{let[u,p]=await Promise.all([e.readContract({address:a,abi:ne,functionName:"symbol",blockNumber:n}),e.readContract({address:a,abi:ne,functionName:"decimals",blockNumber:n})]);return{address:a,chainId:w,symbol:Q(u),decimals:p}},[v,T,_,j,$]=await Promise.all([M(i),S?ae:M(g),e.readContract({address:m,abi:s,functionName:"balanceOf",args:[b],blockNumber:n}),S?0n:e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,g],blockNumber:n}),e.readContract({address:m,abi:s,functionName:"balanceOfToken",args:[b,i],blockNumber:n})]),x=[],F=[],E,C=(a,u,p)=>o.unsignedTx({to:a,data:u,value:"0",chainId:w,description:p});if(r.phase===0){let[a,u]=await Promise.all([e.readContract({address:y,abi:s,functionName:"quoteFeeBalance",blockNumber:n}),e.readContract({address:y,abi:s,functionName:"creatorTaxBalance",blockNumber:n})]);a+u>0n&&(F.push({token:T,amount:(a+u).toString()}),r.buybackEnabled?E="buyback":A&&(await e.simulateContract({address:y,abi:h,functionName:"sweepFees",args:[0n],account:b,gas:q,blockNumber:n}),x.push(C(y,N({abi:h,functionName:"sweepFees",args:[0n]}),`Sweep ${T.symbol} curve fees into the recipient escrow.`))))}else if(r.phase===2){let a=c(await e.readContract({address:P,abi:s,functionName:"memeHook",blockNumber:n})),u=ee(g,i,r.poolFee,r.tickSpacing),p=ue(de([{type:"address"},{type:"address"},{type:"uint24"},{type:"int24"},{type:"address"}],[u.currency0,u.currency1,r.poolFee,r.tickSpacing,a])),[V,z,W,U]=await Promise.all([e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,g],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingFees",args:[p,i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"pendingCreatorTax",args:[p,i],blockNumber:n})]);if(V+z>0n&&F.push({token:T,amount:(V+z).toString()}),W+U>0n&&F.push({token:v,amount:(W+U).toString()}),F.length)if(r.buybackEnabled)E="buyback";else if(A)try{await e.simulateContract({address:a,abi:h,functionName:"sweepPoolFees",args:[p,0n,0n],account:b,gas:q,blockNumber:n}),x.push(C(a,N({abi:h,functionName:"sweepPoolFees",args:[p,0n,0n]}),`Sweep ${T.symbol} pool fees into the recipient escrow.`))}catch(K){if(!pe(K))throw K;E="conversion"}else W+U>0n&&(E="conversion")}let I=0n,L=0n,D;if(r.buybackEnabled||$>0n||A){let a=c(await e.readContract({address:P,abi:s,functionName:"buybackVault",blockNumber:n}));if(a===c(te.buybackVault.address)){let[u,p,V]=await Promise.all([e.readContract({address:a,abi:s,functionName:"feeEscrow",blockNumber:n}),e.readContract({address:a,abi:s,functionName:"releasable",args:[i],blockNumber:n}),e.readContract({address:a,abi:s,functionName:"vestedAmount",args:[i],blockNumber:n})]);if(c(u)!==m)throw new f("The Pons buyback vault credits a different escrow than this coin.");[D,I,L]=[a,p,V]}else if(k)throw new f("The Pons factory reports a buyback vault outside the pinned deployment.")}let O=[...x];if(k){I>0n&&O.push(C(D,N({abi:h,functionName:"release",args:[i]}),`Release the vested ${v.symbol} buyback into the recipient escrow.`));let a=S&&x.length>0,u=!S&&x.length>0;(_>0n||a)&&O.push(C(m,N({abi:h,functionName:"claim"}),"Claim the caller\u2019s full native ETH escrow balance across all coins.")),(j>0n||u)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[g]}),`Claim the caller\u2019s full ${T.symbol} escrow balance across all coins.`)),($>0n||I>0n)&&O.push(C(m,N({abi:h,functionName:"claimToken",args:[i]}),`Claim the caller\u2019s released ${v.symbol} escrow balance.`))}let ce=[{token:ae,amount:_.toString()},...S?[]:[{token:T,amount:j.toString()}],{token:v,amount:$.toString()}];return{coin:v,pair:T,phase:r.phase,recipient:H,holder:b,isRecipient:A,escrow:m,blockNumber:n.toString(),credited:ce,pendingBeforeSweep:F,operatorWait:E,txs:O,buybackVest:{enabled:r.buybackEnabled,vault:D??null,releasable:{token:v,amount:I.toString()},vested:{token:v,amount:L.toString()},note:"Releasable is the gross vested amount; the release splits it with the Pons protocol before crediting the recipient escrow, and the preview shows the net claim."}}}function be(o){return o==="buyback"?"Buyback-enabled fee sweeps are not built here; pending fees await Pons\u2019s operator.":o==="conversion"?"Pending token-side conversion is awaiting Pons\u2019s keeper; the hook sweep was skipped.":""}async function me(o,d,l){if(!d||Object.keys(d).some(R=>R!=="token"))throw new f("Unsupported input. Provide only the Pons coin token address.");let k=c(d.token),t=await fe(o,k,c(l),!0),{txs:i}=t,b=await o.preview(i,l),e=t.credited[t.pair.address===B?0:1],n=[i.length?`Unsigned Pons fee claim prepared for the current recipient. Claims withdraw every ${t.pair.address===B?"native ETH":`native ETH and ${t.pair.symbol}`} balance owed to this wallet on this escrow across its coins.`:"No claim is available from this escrow.",be(t.operatorWait),BigInt(t.buybackVest.releasable.amount)>0n?`The buyback vest has ${t.buybackVest.releasable.amount} ${t.coin.symbol} base units releasable (gross); the release credits the escrow and the claim withdraws it.`:"","Pending amounts are pre-sweep fee and tax totals, not a guaranteed creator payout. Preview excludes gas. No transaction was sent."].filter(Boolean).join(" ");return{txs:i,summary:n,preview:b,claimable:e,credited:t.credited,pendingBeforeSweep:t.pendingBeforeSweep,waitingForKeeper:t.operatorWait!==void 0,operatorWait:t.operatorWait??null,buybackVest:t.buybackVest,recipient:t.recipient,escrow:t.escrow,phase:t.phase,blockNumber:t.blockNumber}}var Ne=o=>({tools:[{name:"pons_claim",inputSchema:{type:"object",additionalProperties:!1,required:["token"],properties:{token:{...J,description:"Pons coin address on chain 4663."}}},execute:async(d,l)=>{try{return await me(o,d,l)}catch(k){throw new f(o.plainError(k))}}}]});export{fe as a,be as b,Ne as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N,b as O,e as F,f as i,k as B,m as b,o as S}from"./
|
|
1
|
+
import{a as N,b as O,e as F,f as i,k as B,m as b,o as S}from"./DLNDJZR4.js";import{a as T}from"./KNROSKUG.js";import{c as I,e as A}from"./R5Z4HPCA.js";import{h as x}from"./TNHU5UBQ.js";import{a as o,e as k}from"./XSD5NL7J.js";function c(t,a){if(t.version!==1||t.chainId!==4663||!Object.hasOwn(F,t.kind))throw new o("Invalid FOBO pending action. Nothing further was signed.");if(!Number.isSafeInteger(a)||!Number.isSafeInteger(t.quotedAt)||a<t.quotedAt||a-t.quotedAt>=N)throw new o("This FOBO action expired. Nothing further was signed. Ask for a fresh summary, then say yes or no.")}function y(t,a){return typeof t=="string"&&t.toLowerCase()===a.toLowerCase()}function _(t){if(typeof t!="number"&&typeof t!="string"||!/^\d+$/.test(String(t)))throw new o("FOBO returned an invalid Permit2 nonce.");let a=Number(t);if(!Number.isSafeInteger(a)||a<0||a>=2**48)throw new o("FOBO returned an invalid Permit2 nonce.");return a}function v(t,a,n){let e=i(a),w=i(e.domain),d=i(e.message),u=i(d.details);if(!["buy","sell"].includes(t.kind)||![4663,"0x1237"].includes(w.chainId)||!y(w.verifyingContract,O.permit2)||e.primaryType!=="PermitSingle"||!y(d.spender,O.router)||!y(u.token,t.request._currencyIn)||!t.terms.amountIn)throw new o("FOBO permit does not match the approved token, spender or chain. Nothing further was signed.");return I({token:t.request._currencyIn,amount:BigInt(t.terms.amountIn),nonce:_(u.nonce),now:n})}async function*M(t,a,n){let e=structuredClone(a);c(e,n.now());let w=!1,d,u;try{if(e.kind==="launch"){let g=await T(t),m=async r=>{c(e,n.now());let s=i(await t.call("sign_in_start",r));if(c(e,n.now()),s.success===!1||s.ok===!1||s.isError===!0)throw new o("FOBO sign-in was refused. Nothing was signed.");if(typeof s.message!="string"||typeof s.ticket!="string"||!s.ticket||s.ticket.length>2e3)throw new o("FOBO returned an invalid sign-in ticket. Nothing was signed.");return A(s.message,e.wallet,n.now()),{message:s.message,ticket:s.ticket}},h;try{h=await m({account:e.wallet,...g})}catch(r){if(Object.keys(g).length===0)throw r;h=await m({account:e.wallet})}let l=await n.signMessage(h.message);c(e,n.now());let p=i(await t.call("sign_in_finish",{account:e.wallet,ticket:h.ticket,signature:l}));if(p.success===!1||p.ok===!1||p.isError===!0)throw new o("FOBO sign-in was refused. Nothing further was signed.");yield{kind:"signin",status:"signed"}}for(let g=0;g<4;g++){c(e,n.now());let m={...B(e),...d?{permit:d}:{}},l=g===0&&["limitOrder","cancel","claim"].includes(e.kind)&&typeof e.request._prepared=="string"?b({status:"ready",transactions:JSON.parse(String(e.request._prepared)).map(r=>({...r,from:e.wallet,gas:r.gasLimit}))}):b(await t.call(F[e.kind],m));c(e,n.now());let p=await S(e,l,n.now(),d?.message,n.readContract);if(l.status==="needs_approval"){if(w||d)throw new o("FOBO requested a repeated approval. Nothing further was signed. Ask for a fresh summary.");for(let r of p){c(e,n.now());let s=await n.sendTransaction(r);w=!0,await n.waitForReceipt(s),yield{kind:"approval",hash:s,tx:r,status:"mined"}}continue}if(l.status==="needs_signature"){if(d)throw new o("FOBO requested a repeated permit. Nothing further was signed.");u=v(e,l.typedData,n.now()),c(e,n.now());let r=await n.signTypedData(u);d={message:i(u).message,signature:r},yield{kind:"permit",status:"signed"};continue}if(u){let r=i(i(u).message),s=i(r.details);for(let P of p){let f=x(P.data,["0x0Af57F62982D03066ef917AcAd87F771c06528Ec","0x0000000000000000000000000000000000000000"]).permit;if(!f||!y(f.token,s.token)||f.amount!==BigInt(String(s.amount))||f.nonce!==Number(s.nonce)||f.expiration!==Number(s.expiration)||!y(f.spender,r.spender)||f.sigDeadline!==BigInt(String(r.sigDeadline)))throw new o("FOBO changed the exact signed permit in the swap. Nothing further was signed.")}}for(let r of p){c(e,n.now());let s=await n.sendTransaction(r);await n.waitForReceipt(s),yield{kind:"transaction",hash:s,tx:r,status:"mined"}}return}throw new o("FOBO preparation did not finish. Nothing further was signed. Ask for a fresh summary.")}catch(g){let m=w?" An exact approval was already sent; use oak_cleanup_allowances to review any allowance left.":"";throw new o(`${k(g).replaceAll("Nothing was signed.","Nothing further was signed.")} FOBO execution stopped; nothing further was signed.${m}`)}}export{v as a,M as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as ee,e as te,f as ne,i as ie,n as re,o as oe}from"./OUXPOFY2.js";import{a as L,d as J,e as Q,f as X,g as F,h as N,i as Y}from"./GV6Z3MET.js";import{a as Z}from"./4P6DRKY3.js";import{a as j,b as z,c as R}from"./CFPJDLTZ.js";import{b as U,j as V}from"./EWZFZUVF.js";import{formatUnits as he,getAddress as ge,parseAbi as ae}from"viem";var b=10n**18n,B=1n<<192n,se=ae(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function liquidity() view returns (uint128)","function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]),be=ae(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))"]),s=f=>({usdEstimate:null,estimateLabel:"price unavailable",estimateReason:f}),k=f=>`${f.chainId}:${f.address.toLowerCase()}`;async function Ee(f,v,w={}){let P=Number.isFinite(w.budgetMs)?Math.min(3e3,Math.max(0,w.budgetMs)):3e3,C=`Oak stopped pricing after ${P===3e3?"3 seconds":`${P} milliseconds`}`,E=new Map,A=[...new Map(v.map(e=>[k(e.token),e.token])).values()],h=!1,O=0,T=[];async function S(e){if(h)throw new Error(C);if(O>=6?await new Promise(t=>T.push(t)):O++,h)throw new Error(C);try{return await e()}finally{let t=T.shift();t?t():O--}}let q=new Map,H=new Map,$=new Map,M;function g(e){let t=q.get(e);if(!t){let n=f.clientFor(e);t=new Proxy(n,{get(i,r,u){let a=Reflect.get(i,r,u);return["readContract","getCode","multicall"].includes(String(r))?(...d)=>S(async()=>Reflect.apply(a,i,d)):a}}),q.set(e,t)}return t}function y(e){let t=H.get(e);return t||(t=S(()=>g(e).getBlockNumber({cacheTime:0})),H.set(e,t)),t}function I(e,t){return M??=re(e,void 0,t).then(n=>{let i=BigInt(n);if(i<=0n)throw new Error("ETH average unavailable");return i}),M}function ce(e,t){let n=`${e}:${t}`,i=$.get(n);return i||(i=S(()=>g(e).getBlock({blockNumber:t})).then(r=>{if(!(r.number!==t||typeof r.timestamp!="bigint"||r.timestamp<=0n))return r.timestamp.toString()}).catch(()=>{}),$.set(n,i)),i}async function ue(e,t){let n=g(e.chainId),i=await y(e.chainId),r;try{r=await Y(e,n,i)}catch(a){if(a instanceof Q)return s(`price unavailable for now: ${X(a.symbol,a.gap)}`);if(N(a))return s(`price unavailable for now: ${F}`);throw a}if(!r)return s("Oak has no pinned pool with sufficient in-range depth for this token");let u=BigInt(e.address)<BigInt(L.usdg);return{numerator:u?r.sqrt**2n:B,denominator:(u?B:r.sqrt**2n)*10n**6n,source:`current price in the Uniswap USDG/${t.symbol} pool; on-chain trading can differ from the stock market`,block:i}}async function de(e){let t=g(e.chainId),n=await y(e.chainId),{assets:i,isLog:r}=await te(e,t,n,w.chopShareFacts),u=10n**BigInt(e.decimals),a=await Promise.all(i.map(l=>_(l.token,!1))),d=0n,c=1n;for(let l=0;l<i.length;l++){let m=a[l];if(!("numerator"in m))return m;d=d*m.denominator+BigInt(i[l].amount)*m.numerator*c,c*=m.denominator}return{numerator:d,denominator:c*u,block:n,source:`Chop ${r?"log":"LP reserves and log"} net backing estimate; default-caller fees may differ; locks and gas excluded`}}async function _(e,t=!0){if(ne(e))return{numerator:1n,denominator:10n**6n,source:"USDG counted at $1.00"};if(e.chainId!==U)return s("Oak has no source for this token");let n=[j.oakLog.address,z].some(o=>o.toLowerCase()===e.address.toLowerCase()),i=w.chopShareFacts?.some(o=>[o.log.address,o.staking.address].some(p=>p.toLowerCase()===e.address.toLowerCase())),r=n||i;if(!r&&w.chopShareTokens?.some(o=>o.toLowerCase()===e.address.toLowerCase()))return s("chop_logs shows this log's backing");if(t&&r){if(v.filter(o=>k(o.token)===k(e)).every(o=>o.amount==="0"))return{numerator:0n,denominator:1n,source:"zero Chop share balance"};try{return await de(e)}catch{return s("chop_logs shows this log's backing")}}let u=e.symbol;if(u.startsWith("untrusted "))try{let o=JSON.parse(u.slice(10));typeof o=="string"&&(u=o)}catch{}if(ee(e))try{let o=g(e.chainId),p=await y(e.chainId),D=ge(R.stateView),G=R.poolId,[fe,pe]=await Promise.all([o.readContract({address:D,abi:se,functionName:"getSlot0",args:[G],blockNumber:p}),o.readContract({address:D,abi:se,functionName:"getLiquidity",args:[G],blockNumber:p})]),W=fe[0];return W<=0n||pe<=0n?s("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool. A quote is a sale for this amount only; Oak never uses it to value a balance."):{numerator:await I(o,p)*B,denominator:b*W**2n*10n**BigInt(e.decimals),source:"current price in the Uniswap v4 WETH/CHOP pool",block:p}}catch{return s("Oak could not verify the pinned Uniswap v4 WETH/CHOP pool for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.")}if(u==="CHOP")return s("Oak has no pinned market for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.");let a=J(e);if(a)return ue(e,a);if(Object.hasOwn(L.notOffered,u))return s("Oak has no pinned market for this token");let d=g(e.chainId),c=await y(e.chainId);if(ie(e))return{numerator:await I(d,c),denominator:b*b,source:"30-minute average of the Uniswap ETH/USDG pool",block:c};let l=(f.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS)?.toLowerCase()===e.address.toLowerCase();if(l)try{let o=f.resolvePrice?await f.resolvePrice(e,c):await oe(e,{client:d,blockNumber:c,oakTokenAddress:e.address,officialStockTokens:[]}),p=BigInt(o.usdE18);if(p<=0n)throw new Error("OAK price unavailable");return{numerator:p,denominator:b*10n**BigInt(e.decimals),source:"OAK price",block:c}}catch{}if(l&&(await d.readContract({address:V[U].pons.factory.address,abi:be,functionName:"getLaunchedToken",args:[e.address],blockNumber:c})).phase!==2)return s("Oak has no graduated Pons pool price for OAK");let m=await Z(e,d,c);return m.numerator<=0n||m.denominator<=0n?s("Oak has no source for this token"):{numerator:await I(d,c)*m.numerator,denominator:b*m.denominator*10n**BigInt(e.decimals),source:l?"OAK's current Pons pool price; fewer than enough trades in 30 minutes for a price":"current Pons pool price",block:c}}let x=0;async function le(){for(;!h&&x<A.length;){let e=A[x++],t;try{if(!Number.isInteger(e.decimals)||e.decimals<0||e.decimals>255)throw new Error("Invalid decimals");if(t=await _(e),h||E.set(k(e),t),"numerator"in t&&t.block!==void 0){let n=await ce(e.chainId,t.block);h||(t.observedAt=n)}}catch(n){t=s(N(n)?`price unavailable for now: ${F}`:"Oak has no source for this token")}h||E.set(k(e),t)}}let K,me=new Promise(e=>{K=setTimeout(()=>{h=!0;for(let t of T.splice(0))t();e()},P)});try{await Promise.race([Promise.all(Array.from({length:Math.min(6,A.length)},le)),me])}finally{clearTimeout(K),h=!0}return v.map(e=>{let t;try{if(!/^\d+$/.test(e.amount)||!Number.isInteger(e.token.decimals)||e.token.decimals<0||e.token.decimals>255)throw new Error("Invalid amount");t="humanAmount"in e&&typeof e.humanAmount=="string"?e.humanAmount:he(BigInt(e.amount),e.token.decimals);let n=E.get(k(e.token));if(n&&"numerator"in n){let r=(BigInt(e.amount)*n.numerator*100n*2n+n.denominator)/(n.denominator*2n);return{...e,humanAmount:t,usdEstimate:`${r/100n}.${(r%100n).toString().padStart(2,"0")}`,estimateLabel:"estimate, not a quote",estimateSource:n.source,unitUsdE18:(n.numerator*10n**BigInt(e.token.decimals)*b/n.denominator).toString(),...n.observedAt===void 0?{}:{observedAt:n.observedAt},...n.block===void 0?{}:{estimateAsOf:n.block.toString()}}}return{...e,humanAmount:t,...n??s(C)}}catch{return{...e,...t===void 0?{}:{humanAmount:t},...s("Oak cannot format this token amount")}}})}export{Ee as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./YZHJ4BAP.js";import{a as O,c as P,g as B}from"./GQ3XZFRL.js";import{b as h,e as r,g as F}from"./NWNYJ26T.js";import{b as g}from"./
|
|
1
|
+
import{b as C}from"./YZHJ4BAP.js";import{a as O,c as P,g as B}from"./GQ3XZFRL.js";import{b as h,e as r,g as F}from"./NWNYJ26T.js";import{b as g}from"./EWZFZUVF.js";import{a as y}from"./XSD5NL7J.js";import{a as E,b as x}from"./JXOEJPJ4.js";import{getAddress as T}from"viem";var q=["pons_status","pons_holders","pons_launch_info"],v=["getPartnerScanCard","getProjectSnapshot"],V=/^[a-z0-9][a-z0-9-]{0,79}$/,$=/^[0-9]{1,78}$/,K=/\b(?:unsafe|safe|safety|risks?|risky|recommend\w*|buy\w*|sell\w*)\b/i,z="https://heyresearch.xyz",D=["curve","pending pool creation","graduated","rescued"],G="This describes the project, not this token. HEY Research Lab does not tie this token to that activity.",X="Buyback-vault vesting only. It is not proof of vesting for any other address and not a liquidity lock. Unread figures say not read.",Z="An empty or missing source proves nothing; unread figures say not read, never zero. Address counts are Pons index figures, not on-chain counts; addresses are not people.",M=/rank|scor|trend|market|lock|sell|rating|price|signal|verdict|safe/i,c=(n,e)=>typeof n=="string"&&n.length>0&&n.length<=e&&!x(n)?n:null,k=n=>typeof n=="string"&&$.test(n)?n:null,Q=n=>typeof n=="number"&&Number.isSafeInteger(n)&&n>=0?n:null,L=n=>typeof n=="number"&&Number.isSafeInteger(n)?n:null,m=n=>typeof n=="string"&&h.test(n)?T(n):null,w=n=>(r(n)?k(n.amount):null)??"not read",d=n=>k(n)??"not read",R=n=>Q(n)??"not read",J=n=>L(n)??"not read";function W(n){if(typeof n!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(n))return null;let e=Date.parse(n);return Number.isFinite(e)&&new Date(e).toISOString().slice(0,19)===n.slice(0,19)&&e<=Date.now()+3e5?n:null}function nn(n,e){if(typeof n!="string"||n.length>2048||/[\s<>\\]/.test(n)||x(n))return null;try{let t=new URL(n);return t.origin===z&&!t.username&&!t.password&&t.pathname===`/project/${e}`?n:null}catch{return null}}function tn(n){return typeof n!="string"?null:/^untrusted "(?:[^"\\]|\\.)*"$/.test(n)?n:E(n)}function en(n){return n instanceof Error&&/supported Pons factory/i.test(n.message)}function N(n,e){if(!r(n)||n.chainId!==g||typeof n.address!="string"||!h.test(n.address)||!F(n.address,e))return null;let t=n.decimals,s=tn(n.symbol);return typeof t!="number"||!Number.isInteger(t)||t<0||t>255||!s?null:{address:T(e),chainId:g,symbol:s,decimals:t}}function _(n){if(!r(n)||!r(n.token))return null;let e=m(n.token.address);return e?N(n.token,e):null}function sn(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.blockNumber),o=L(n.phase);if(!t||!s||o===null||o<0||o>3||n.phaseName!==D[o])return;let a=n.pool,l=r(a)&&typeof a.id=="string"&&/^0x[0-9a-fA-F]{1,64}$/.test(a.id)?a.id:null,i=r(a)?k(a.liquidity):null,p=r(a)&&l&&i?{id:l,liquidity:i,sqrtPriceX96:d(a.sqrtPriceX96),tick:J(a.tick),lpFee:R(a.lpFee),protocolFee:R(a.protocolFee)}:null;return{token:t,block:s,launch:{phase:o,phaseName:D[o],curve:m(n.curve),creatorFeeRecipient:m(n.creatorFeeRecipient),progressPpm:d(n.progressPpm),graduationThreshold:w(n.graduationThreshold),raised:w(n.raised),totalSupply:w(n.totalSupply),amountUnits:{graduationThreshold:_(n.graduationThreshold),raised:_(n.raised),totalSupply:_(n.totalSupply)},pool:p}}}function on(n,e){if(!r(n))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=r(n.sources)?n.sources:{},a=(Array.isArray(n.exclusions)?n.exclusions.slice(0,10):[]).flatMap(i=>{let p=r(i)?c(i.reason,120):null;return r(i)&&p?[{reason:p,indexedBalance:d(i.indexedBalance),countedInIndex:typeof i.countedInIndex=="boolean"?i.countedInIndex:null}]:[]}),l=r(n.indexAsOf)?n.indexAsOf:null;return{token:t,addresses:{statusBlock:s,addressCountKind:"indexed",addressCount:R(n.holderCount),indexAddressCount:R(n.indexHolderCount),totalSupply:d(n.totalSupply),indexSupply:d(n.indexSupply),burned:d(n.burned),circulating:d(n.circulating),amountUnits:{totalSupply:t,indexSupply:t,burned:t,circulating:t,indexedBalance:t},exclusions:a,indexAsOf:l?{rollupBucket:c(l.rollupBucket,40),tailFromBlock:d(l.tailFromBlock)}:null,sources:{addressCount:c(o.holderCount,300)??"Pons balances index (an indexed figure, not an on-chain count)",totalSupply:c(o.totalSupply,300),burned:c(o.burned,300),circulating:c(o.circulating,300)}}}}function rn(n,e){if(!r(n)||!r(n.buybackVest))return;let t=N(n.token,e),s=k(n.statusBlock);if(!t||!s)return;let o=n.buybackVest,a={locked:d(o.locked),released:d(o.released),vested:d(o.vested),releasable:d(o.releasable),vestingStart:d(o.vestingStart),vestingDurationSeconds:d(o.vestingDurationSeconds)};return{token:t,vest:{statusBlock:s,vault:m(o.vault),enabled:typeof o.enabled=="boolean"?o.enabled:null,...a,amountUnits:{locked:t,released:t,vested:t,releasable:t},unknownFields:Object.entries(a).filter(([,l])=>l==="not read").map(([l])=>l),scope:X,source:`On-chain reads of the Pons buyback vault at block ${s}.`}}}async function I(n,e,t,s){if(!q.includes(e))throw new y("Unsupported Pons read.");try{let o=s(await n(e,{token:t}),t);return o===void 0?{state:"unavailable",value:null}:{state:"available",value:o}}catch(o){return{state:en(o)?"unsupported-origin":"unavailable",value:null}}}async function H(n,e,t){if(!v.includes(e))throw new y("Unsupported HEY read.");try{let s=await n("heyresearch_read",{operation:e,parameters:t,detail:"full"});return r(s)&&s.operation===e&&r(s.data)?s.data:null}catch{return null}}function an(n){let e={};if(!r(n))return e;for(let[t,s]of Object.entries(n).slice(0,40))!/^[A-Za-z][A-Za-z0-9_]{0,39}$/.test(t)||M.test(t)||(s===null?e[t]="not read":(typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s)||c(s,300)!==null&&!K.test(s))&&(e[t]=s));return e}function ln(n,e){let t=n?W(n.asOf):null;if(!n||!t)return null;let s=r(n.links)?n.links:{};return{asOf:t,page:nn(s.page,e),disclaimer:c(n.disclaimer,1e3),build:an(n.build),textIsData:!0}}async function bn(n,e){if(typeof n!="string"||!h.test(n)||/^0x(?:0{40}|e{40})$/i.test(n))throw new y("Provide a full token contract address on Robinhood Chain 4663.");let t=T(n),[s,o,a,l]=await Promise.all([H(e,"getPartnerScanCard",{chain:g,token:t}),I(e,"pons_status",t,sn),I(e,"pons_holders",t,on),I(e,"pons_launch_info",t,rn)]),i=s?C(s.found===!1&&s.contractAddress===void 0?{...s,contractAddress:t}:s,g,t):void 0,p=i?i.found?"available":"not-indexed":"unavailable",f=i?.found&&r(s?.project)?s.project:null,b=f&&typeof f.slug=="string"&&V.test(f.slug)?f.slug:null,U="not-read",S=null;b&&(S=ln(await H(e,"getProjectSnapshot",{slug:b}),b),U=S?"available":"unavailable");let u=i?.found?i:null,A=u?u.activity_applies_to_token&&u.token_verification==="VERIFIED"?"token":"project-only":null,j=u?.activity.last_ship&&u.activity.last_ship_url?{date:u.activity.last_ship,url:u.activity.last_ship_url,sourceHost:new URL(u.activity.last_ship_url).hostname}:null,Y=o.value?.token??a.value?.token??l.value?.token??null;return{chainId:g,token:t,checkedAt:new Date().toISOString(),hey:{provider:"HEY Research Lab",statusNote:"show exactly",status:u?B(u.status_label,u.status_help):i?.found===!1?P:"HEY Research Lab context unavailable",tie:A,qualification:A==="project-only"?G:null,tieLabel:A==="token"?O:null,verifiedBuilder:u?.verified_builder??null,projectSlug:b,projectLink:u?.project_link??null,asOf:u?.as_of??null,lastShip:j,snapshot:S},oak:{token:Y,statusBlock:o.value?.block??"not read",launch:o.value?.launch??null,addresses:a.value?.addresses??null,buybackVest:l.value?.vest??null},coverage:{hey:{scan:p,snapshot:U},oak:{status:o.state,addresses:a.state,launchInfo:l.state},note:Z}}}export{on as a,bn as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,e as A}from"./
|
|
1
|
+
import{a,e as A}from"./BWE5PXRE.js";import{a as x}from"./66F5ZH34.js";import{c as P}from"./NWNYJ26T.js";import{b as w}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{encodeFunctionData as g,getAddress as m,parseAbi as v}from"viem";var r=v(["function asset() view returns (address)","function adaptersLength() view returns (uint256)","function adapters(uint256) view returns (address)","function forceDeallocatePenalty(address) view returns (uint256)","function forceDeallocate(address adapter,bytes data,uint256 assets,address onBehalf) returns (uint256)","function withdraw(uint256 assets,address receiver,address onBehalf) returns (uint256)","function multicall(bytes[] data)"]),y=v(["function morpho() view returns (address)","function marketIdsLength() view returns (uint256)","function marketIds(uint256) view returns (bytes32)","function expectedSupplyAssets(bytes32) view returns (uint256)"]),_=v(["function idToMarketParams(bytes32) view returns (address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"]),T="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",U=v([`function market(${T})`]),G={amount:x('USDG to withdraw to this wallet, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.')};function z(p){return{tools:[{name:"priors_savings_liquidity",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(){let t=p.clientFor(w),s=await t.readContract({address:a.savings,abi:r,functionName:"asset"});if(m(s)!==a.usdg)throw new e("Savings vault asset is not USDG.");let o=await t.readContract({address:a.savings,abi:r,functionName:"adaptersLength"});if(o>100n)throw new e("Savings vault has more adapters than this bounded reader supports.");let n=await Promise.all(Array.from({length:Number(o)},async(N,h)=>{let d=await t.readContract({address:a.savings,abi:r,functionName:"adapters",args:[BigInt(h)]}),c=await t.readContract({address:a.savings,abi:r,functionName:"forceDeallocatePenalty",args:[d]}),f=await t.readContract({address:d,abi:y,functionName:"marketIdsLength"});if(f>100n)throw new e("Adapter has too many markets for this bounded reader.");let b=await Promise.all(Array.from({length:Number(f)},async(l,i)=>{let k=await t.readContract({address:d,abi:y,functionName:"marketIds",args:[BigInt(i)]}),S=await t.readContract({address:d,abi:y,functionName:"expectedSupplyAssets",args:[k]});return{marketId:k,supplied:S.toString()}}));return{adapter:d,penalty:c.toString(),markets:b}}));return{chainId:w,vault:a.savings,adapters:n,caveat:"Supplied assets are not necessarily liquid. Force exit requires a zero penalty and a successful atomic preview."}}},{name:"priors_savings_force_withdraw",inputSchema:{type:"object",properties:{...G,allocations:{type:"array",minItems:1,maxItems:16,description:"One to 16 zero-penalty markets to deallocate from first; read priors_savings_liquidity.",items:{type:"object",properties:{adapter:{...P,description:"Address of a registered savings vault adapter, from priors_savings_liquidity."},marketId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Morpho market id under that adapter: 0x followed by 64 hex digits (bytes32)."},amount:x('USDG to deallocate from this market, in base units (USDG has 6 decimals). Example: "1000000" = 1 USDG.')},required:["adapter","marketId","amount"],additionalProperties:!1}}},required:["amount","allocations"],additionalProperties:!1},async execute(t,s){if(p.network==="testnet")throw new e("Priors savings is mainnet only.");s=m(s);let o=A(t.amount,"amount");if(o===0n||!Array.isArray(t.allocations)||t.allocations.length<1||t.allocations.length>16)throw new e("Provide positive amount and 1 to 16 zero-penalty allocations.");let n=p.clientFor(w),N=await n.readContract({address:a.savings,abi:r,functionName:"asset"});if(m(N)!==a.usdg)throw new e("Savings asset is not USDG.");let h=await n.readContract({address:a.savings,abi:r,functionName:"adaptersLength"});if(h>100n)throw new e("Too many savings adapters to verify.");let d=await Promise.all(Array.from({length:Number(h)},(l,i)=>n.readContract({address:a.savings,abi:r,functionName:"adapters",args:[BigInt(i)]}))),c=[];for(let l of t.allocations){let i=m(l.adapter);if(!d.some(D=>m(D)===i)||!/^0x[0-9a-fA-F]{64}$/.test(l.marketId))throw new e("Allocation must name a registered adapter and a bytes32 market.");if(await n.readContract({address:a.savings,abi:r,functionName:"forceDeallocatePenalty",args:[i]})!==0n)throw new e("This force exit charges a penalty; Oak only builds the public zero-penalty route.");let S=await n.readContract({address:i,abi:y,functionName:"morpho"}),u=await n.readContract({address:S,abi:_,functionName:"idToMarketParams",args:[l.marketId]});if(m(u[0])!==a.usdg)throw new e("Force exit market loan token is not USDG.");let I=A(l.amount,"allocation amount");if(I===0n)throw new e("Allocation amount must be positive.");let C=`0x${g({abi:U,functionName:"market",args:[{loanToken:u[0],collateralToken:u[1],oracle:u[2],irm:u[3],lltv:u[4]}]}).slice(10)}`;c.push(g({abi:r,functionName:"forceDeallocate",args:[i,C,I,"0x0000000000000000000000000000000000000001"]}))}c.push(g({abi:r,functionName:"withdraw",args:[o,s,s]}));let f=[p.unsignedTx({to:a.savings,data:g({abi:r,functionName:"multicall",args:[c]}),value:"0",chainId:w,description:`Zero-penalty liquidity recovery then withdraw ${o} USDG base units atomically to this wallet.`})],b=await p.preview(f,s);return{txs:f,summary:`Force deallocate ${c.length-1} registered savings market allocation(s) with zero-penalty guard, then withdraw exactly ${o} USDG base units to ${s}. Market liquidity can still prevent exit. ${b.summary}`}}}]}}export{r as a,z as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c,b as F,e as P,f as T,g as I}from"./
|
|
1
|
+
import{a as c,b as F,e as P,f as T,g as I}from"./PX2G2H6G.js";import{a as l}from"./66F5ZH34.js";import{c as N,g,h as S}from"./NWNYJ26T.js";import{b as h}from"./EWZFZUVF.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as w,getAddress as _,parseAbi as Q,parseAbiItem as j,zeroAddress as H}from"viem";var x=_("0x000000001f26a0044baa66024e7b6599c61963f8"),M=j("event AuctionCreated(address indexed auction,address indexed token,uint256 amount,bytes configData)"),o=Q(["function currency() view returns (address)","function token() view returns (address)","function startBlock() view returns (uint64)","function endBlock() view returns (uint64)","function claimBlock() view returns (uint64)","function validationHook() view returns (address)","function clearingPrice() view returns (uint256)","function isGraduated() view returns (bool)","function bids(uint256) view returns ((uint64 startBlock,uint24 startCumulativeMps,uint64 exitedBlock,uint256 maxPrice,address owner,uint256 amountQ96,uint256 tokensFilled))","function submitBid(uint256 maxPrice,uint128 amount,address owner,uint256 prevTickPrice,bytes hookData) payable returns (uint256)","function exitBid(uint256)","function exitPartiallyFilledBid(uint256,uint64,uint64)","function claimTokens(uint256)","function claimTokensBatch(address,uint256[])","function checkpoint()","function sweepCurrency()","function sweepUnsoldTokens()"]);async function D(s,y){let n=F(y.auction),t=c(y.creationBlock,"creationBlock",64,!0),e=await s.getLogs({address:x,event:M,args:{auction:n},fromBlock:t,toBlock:t,strict:!0});if(e.length!==1||!g(e[0].address,x)||!S(e[0].args.auction,n))throw new u("Auction has no matching AuctionCreated event at the pinned CCA factory and creationBlock.");return n}async function E(s,y){let n=s.clientFor(h),t=await D(n,y),e=await n.getBlockNumber(),[a,b,i,k,m,v,d,B]=await Promise.all([n.readContract({address:t,abi:o,functionName:"currency",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"token",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"startBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"endBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"claimBlock",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"validationHook",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"clearingPrice",blockNumber:e}),n.readContract({address:t,abi:o,functionName:"isGraduated",blockNumber:e})]);return{auction:t,currency:a,saleToken:b,startBlock:i,endBlock:k,claimBlock:m,validationHook:v,clearingPrice:d,graduated:B,blockNumber:e}}var L={auction:{...N,description:"Address of the continuous clearing auction to verify against the pinned factory."},creationBlock:l("Auction creation block number, as a decimal string, used to verify the factory event."),bidId:l('Identifier of the auction bid, as a decimal string. Example: "1".'),amount:l('Amount of payment currency in base units; use payment currency decimals. Example: "1000000" = 1 payment currency at 6 decimals.'),maxPrice:l("Maximum bid price in Q96 payment-currency base units per sale-token base unit."),prevTickPrice:l("Previous auction price tick in Q96 payment-currency base units per sale-token base unit; zero for the first tick."),lastFullyFilledCheckpointBlock:l("Last fully filled checkpoint block number for a partial bid exit, as a decimal string."),outbidBlock:l("Block number at which the bid was outbid, as a decimal string."),mode:{description:'Choose "full" to exit a bid, or "partial" to exit using checkpoint and outbid block hints.',type:"string",enum:["full","partial"]},bidIds:{description:'One to fifty unique auction bid identifiers as decimal strings. Example: ["1", "2"].',type:"array",minItems:1,maxItems:50,items:l()}};function R(s){let n=["status","bid","exit","claim","checkpoint","sweep_currency","sweep_tokens"].map(t=>({name:`uniswap_auction_${t}`,inputSchema:{type:"object",additionalProperties:!1,required:["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode"]:[]],properties:L},async execute(e,a){I(e,["auction","creationBlock",...t==="bid"?["amount","maxPrice","prevTickPrice"]:t==="exit"?["bidId","mode","lastFullyFilledCheckpointBlock","outbidBlock"]:t==="claim"?["bidId","bidIds"]:t==="status"?["bidId"]:[]]);let i=await E(s,e),k=s.clientFor(h),[m,v]=await Promise.all([P(s,i.currency,i.blockNumber),P(s,i.saleToken,i.blockNumber)]),d=e.bidId===void 0?void 0:await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[c(e.bidId,"bidId",256,!0)],blockNumber:i.blockNumber});if(t==="status")return{auction:i.auction,paymentToken:m,saleToken:v,startBlock:i.startBlock.toString(),endBlock:i.endBlock.toString(),claimBlock:i.claimBlock.toString(),validationHook:i.validationHook,clearingPrice:i.clearingPrice.toString(),graduated:i.graduated,...d?{bid:{...d,startBlock:d.startBlock.toString(),exitedBlock:d.exitedBlock.toString(),maxPrice:d.maxPrice.toString(),amountQ96:d.amountQ96.toString(),tokensFilled:d.tokensFilled.toString()}}:{},summary:"CCA prices use currency-base-units per sale-token-base-unit in Q96. Clearing price/graduation reflect the latest checkpoint and may lag the head."};let B=[],f,A=0n;if(t==="bid"){if(i.validationHook!==H)throw new u("This auction has a validation hook. Its validation/signing contract is not configured; do not pass an off-chain signature manually.");if(i.blockNumber<i.startBlock||i.blockNumber>=i.endBlock)throw new u("Auction is not in its bidding window.");let r=c(e.amount,"amount",128),p=c(e.maxPrice,"maxPrice"),C=c(e.prevTickPrice,"prevTickPrice",256,!0);if(p<=i.clearingPrice)throw new u("Bid maxPrice must be above the checkpoint clearing price.");i.currency===H?A=r:B.push(s.approval(i.currency,i.auction,r.toString(),h)),f=w({abi:o,functionName:"submitBid",args:[p,r,a,C,"0x"]})}else if(t==="exit"){if(!d||!g(d.owner,a))throw new u("Only exit a bid owned by the signing wallet.");let r=c(e.bidId,"bidId",256,!0);if(e.mode==="full"){if(e.lastFullyFilledCheckpointBlock!==void 0||e.outbidBlock!==void 0)throw new u("Full exit takes no checkpoint hints.");f=w({abi:o,functionName:"exitBid",args:[r]})}else if(e.mode==="partial")f=w({abi:o,functionName:"exitPartiallyFilledBid",args:[r,c(e.lastFullyFilledCheckpointBlock,"lastFullyFilledCheckpointBlock",64,!0),c(e.outbidBlock,"outbidBlock",64,!0)]});else throw new u("Choose full or partial exit explicitly; partial exits require checkpoint hints.")}else if(t==="claim"){if(e.bidId===void 0==(e.bidIds===void 0))throw new u("Provide bidId or bidIds, not both.");let r=e.bidIds===void 0?[c(e.bidId,"bidId",256,!0)]:Array.isArray(e.bidIds)?e.bidIds.map(p=>c(p,"bidIds",256,!0)):[];if(r.length<1||r.length>50||new Set(r.map(String)).size!==r.length)throw new u("Provide 1 to 50 unique bid IDs.");for(let p of r){let C=await k.readContract({address:i.auction,abi:o,functionName:"bids",args:[p],blockNumber:i.blockNumber});if(!g(C.owner,a))throw new u("Claimed tokens must belong to the signing wallet.")}f=w({abi:o,functionName:"claimTokensBatch",args:[a,r]})}else f=w({abi:o,functionName:t==="checkpoint"?"checkpoint":t==="sweep_currency"?"sweepCurrency":"sweepUnsoldTokens"});return B.push(s.unsignedTx({to:i.auction,data:f,value:A.toString(),chainId:h,description:`CCA ${t} on factory-verified auction ${i.auction}. Bid owner ${a}.`})),T(s,B,a,`CCA ${t}; checkpoint/exit/claim eligibility and creator-only sweeps are checked by the contract in preview. Sweeps pay the auction's immutable funds/tokens recipient, not an arbitrary recipient.`)}}));return n.push({name:"uniswap_auctions",inputSchema:{type:"object",additionalProperties:!1,properties:{fromBlock:l("First block number of the scan, as a decimal string; inclusive."),toBlock:l("Last block number of the scan, as a decimal string; inclusive.")}},async execute(t){I(t,["fromBlock","toBlock"]);let e=s.clientFor(h),a=await e.getBlockNumber(),b=t.fromBlock===void 0?a>9999n?a-9999n:0n:c(t.fromBlock,"fromBlock",64,!0),i=t.toBlock===void 0?a:c(t.toBlock,"toBlock",64,!0);if(b>i||i>a||i-b>=10000n)throw new u("Scan an ordered range of at most 10000 blocks, ending at or before the head.");let k=await e.getLogs({address:x,event:M,fromBlock:b,toBlock:i,strict:!0});return{factory:x,fromBlock:b.toString(),toBlock:i.toString(),auctions:k.map(m=>({auction:m.args.auction,token:m.args.token,amount:m.args.amount.toString(),creationBlock:m.blockNumber.toString()})),summary:"Factory-verified auctions in this block window only. An empty result does not establish that no auctions exist outside it. Scan earlier windows for older launches."}}}),{tools:n}}export{x as a,M as b,o as c,D as d,E as e,R as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as ne}from"./FRVCSDKU.js";import{b as ee,e as te}from"./E47UYYK4.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./ZXRIJG6H.js";import{d as V,e as $,w as U}from"./FRT6AC6M.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{b as S,j as N}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as w,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),xe=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),we=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),se=T(["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)",ae=T([`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)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let s=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");s.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return s}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,s=r?[...t].reverse():t,e=l[0];return s.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));let s=t.version;if(!["v2","v3","v4"].includes(String(s)))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=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",s==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let x=u.clientFor(S),p=await x.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;if(s==="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 a=t.poolKeys.map(P=>U(P));j=a,I=ve(a,n,c,e),m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await x.simulateContract({address:re,abi:ae,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.includes(v))throw new o("Path must contain 2 to 6 distinct ERC-20 tokens in input-to-output order.");if(s==="v2"){if(t.fees!==void 0)throw new o("V2 fees are fixed by the pair; omit fees.");let a=await x.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?a[0]:a.at(-1),A=e?"0x09":"0x08"}else{let a=t.fees;if(!Array.isArray(a)||a.length!==d.length-1||a.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await x.readContract({address:ie,abi:se,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,a,e),m=(await x.simulateContract({address:ie,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(x,{version:s,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",s==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||s==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:s,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},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 q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let a=await x.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});a!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${a===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:we,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(s==="v4"){let a=I?w(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):w(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=w(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[a,w(ue,[n,h]),w(ue,[c,e?i:y])]])}else s==="v2"?O=w(Pe,[r,i,y,d,!0,[]]):O=w(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(w(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:xe,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${s} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and five-minute on-chain deadline. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,xe as c,we as d,se as e,ae as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
|
|
1
|
+
import{b as ne}from"./VMSGNN3D.js";import{b as ee,e as te}from"./7KK3OC7Q.js";import{a as D,b as W,c as _,d as J,e as z,f as Y,g as Z}from"./PX2G2H6G.js";import{d as V,e as $,w as U}from"./2ZYFBBOE.js";import{a as H}from"./IOYRL6AY.js";import{a as E}from"./66F5ZH34.js";import{c as b,g as G}from"./NWNYJ26T.js";import{b as S,j as N}from"./EWZFZUVF.js";import{a as o}from"./XSD5NL7J.js";import{encodeAbiParameters as x,encodeFunctionData as oe,encodePacked as he,erc20Abi as be,getAddress as ce,parseAbi as T,parseAbiParameters as g,zeroAddress as v}from"viem";var ie=ce("0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7"),re=ce(N[4663].ponsTrade.quoter.address),we=T(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),xe=T(["function approve(address token,address spender,uint160 amount,uint48 expiration)"]),ae=T(["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)",se=T([`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)`]),ke=g(`(address exactCurrency,${F}[] path,uint256[] minHopPriceX36,uint128 amount,uint128 limit)`);function ve(u,t,r,l){let a=[],e=l?r:t,i=new Set([e]);for(let n of l?[...u].reverse():u){let c=n.currency0===e?n.currency1:n.currency1===e?n.currency0:void 0;if(!c||i.has(c))throw new o("V4 poolKeys must form a continuous route without repeated currencies.");a.push({intermediateCurrency:c,fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks,hookData:"0x"}),e=c,i.add(e)}if(e!==(l?t:r))throw new o("V4 route does not end at the requested currency.");return a}var ge=g(`(${M} poolKey,bool zeroForOne,uint128 amount,uint128 limit,uint256 minHopPriceX36,bytes hookData)`),Ae=g("address recipient,uint256 amount,uint256 limit,bytes path,bool payerIsUser,uint256[] minHopPriceX36"),Pe=g("address recipient,uint256 amount,uint256 limit,address[] path,bool payerIsUser,uint256[] minHopPriceX36"),ue=g("address,uint256"),Ie=g("bytes,bytes[]");function Se(u,t,r){let l=r?[...u].reverse():u,a=r?[...t].reverse():t,e=l[0];return a.forEach((i,n)=>{e=`${e}${he(["uint24","address"],[i,l[n+1]]).slice(2)}`}),e}var de={version:{description:'Uniswap version: "v2" for pairs, "v3" for concentrated liquidity or "v4" for PoolManager.',type:"string",enum:["v2","v3","v4"]},tokenIn:{...b,description:"Input token address; the zero address means native ETH for v4."},tokenOut:{...b,description:"Output token address; the zero address means native ETH for v4."},path:{description:"Two to six distinct ERC-20 token addresses in input-to-output order for v2 or v3.",type:"array",minItems:2,maxItems:6,items:b},fees:{type:"array",description:"One v3 pool fee per path hop, in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",items:{type:"integer",minimum:0,maximum:1e6}},poolKeys:{description:"One to five v4 pool keys in input-to-output route order, without repeated currencies.",type:"array",minItems:1,maxItems:5,items:{type:"object",required:["currency0","currency1","fee","tickSpacing","hooks"],properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},additionalProperties:!1}},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{...b,description:"Lower sorted currency address; the zero address means native ETH."},currency1:{...b,description:"Higher sorted currency address."},fee:{type:"integer",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"integer"},hooks:{...b,description:"Hook contract address; the zero address means no hook."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},allowHighFeePools:{description:"Allow pools above Oak's usual fee threshold; review the fee warning before confirming.",type:"boolean"},acceptValueLoss:{description:"Acknowledge the quoted value-loss warning; review the measured loss before confirming.",type:"boolean"},amountIn:E('Amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),amountOut:E('Amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),minAmountOut:E('Minimum amount of output token in base units; use output token decimals. Example: "1000000" = 1 output token at 6 decimals.'),maxAmountIn:E('Maximum amount of input token in base units; use input token decimals. Example: "1000000" = 1 input token at 6 decimals.'),slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999}};async function Ee(u,t,r,l=!1){Z(t,Object.keys(de));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=D(e?t.amountOut:t.amountIn,e?"amountOut":"amountIn",a==="v4"?128:160),n=_(t.tokenIn),c=_(t.tokenOut);if(n===c)throw new o("Swap requires different input and output currencies.");let w=u.clientFor(S),p=await w.getBlock(),L=J(t.slippageBps),j,I,m,O,A,f,d,C;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 s=t.poolKeys.map(P=>U(P));j=s,I=ve(s,n,c,e),m=(await w.simulateContract({address:re,abi:se,functionName:e?"quoteExactOutput":"quoteExactInput",args:[{exactCurrency:e?c:n,path:I,exactAmount:i}],account:r,gas:H,blockNumber:p.number})).result[0]}else{if(f=U(t.poolKey),![f.currency0,f.currency1].includes(n)||![f.currency0,f.currency1].includes(c))throw new o("PoolKey currencies differ from the requested swap.");m=(await w.simulateContract({address:re,abi:se,functionName:e?"quoteExactOutputSingle":"quoteExactInputSingle",args:[{poolKey:f,zeroForOne:n===f.currency0,exactAmount:i,hookData:"0x"}],account:r,gas:H,blockNumber:p.number})).result[0]}A="0x10"}else{if(t.poolKey!==void 0||t.poolKeys!==void 0||n===v||c===v)throw new o("V2/v3 routes use ERC-20 tokens; wrap ETH to WETH first.");if(d=Array.isArray(t.path)?t.path.map(W):[n,c],d.length<2||d.length>6||d[0]!==n||d.at(-1)!==c||new Set(d).size!==d.length||d.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 s=await w.readContract({address:ee,abi:te,functionName:e?"getAmountsIn":"getAmountsOut",args:[i,d],blockNumber:p.number});m=e?s[0]:s.at(-1),A=e?"0x09":"0x08"}else{let s=t.fees;if(!Array.isArray(s)||s.length!==d.length-1||s.some(P=>typeof P!="number"||!Number.isInteger(P)||P<0||P>1e6))throw new o("Provide one integer pool fee in hundredths of a basis point (3000 = 0.3%) per v3 path hop.");if(!G(await w.readContract({address:ie,abi:ae,functionName:"factory",blockNumber:p.number}),N[4663].uniswap.v3_factory.address))throw new o("V3 quoter is not configured for the pinned factory.");C=Se(d,s,e),m=(await w.simulateContract({address:ie,abi:ae,functionName:e?"quoteExactOutput":"quoteExactInput",args:[C,i],account:r,gas:H,blockNumber:p.number})).result[0],A=e?"0x01":"0x00"}}if(m<=0n)throw new o("No positive Uniswap quote is available.");let k=await ne(w,{version:a,input:n,path:d,fees:t.fees,poolKeys:f?[f]:j,exactOutput:e,amount:i,quoted:m,blockNumber:p.number,allowHighFeePools:t.allowHighFeePools===!0,acceptValueLoss:t.acceptValueLoss===!0}),{confirmationWarnings:pe,...me}=k,R=e?t.maxAmountIn:t.minAmountOut;if(!l&&R===void 0)throw new o(`Provide ${e?"maxAmountIn":"minAmountOut"} from uniswap_quote to confirm the trade bound.`);let y=R===void 0?e?(m*BigInt(1e4+L)+9999n)/10000n:m*BigInt(1e4-L)/10000n:D(R,e?"maxAmountIn":"minAmountOut",a==="v4"?128:160);if(y<=0n||(e?y<m:y>m))throw new o("The fresh quote does not satisfy the confirmed swap bound.");let h=e?y:i;if(h>=1n<<160n||a==="v4"&&(h>=1n<<128n||y>=1n<<128n))throw new o("Swap bounds exceed the router amount range.");let[le,fe]=await Promise.all([z(u,n,p.number),z(u,c,p.number)]),X={...me,version:a,input:{token:le,amount:(e?m:i).toString()},output:{token:fe,amount:(e?i:m).toString()},[e?"maxAmountIn":"minAmountOut"]:y.toString(),blockNumber:p.number.toString(),expiresAt:(p.timestamp+60n).toString()};if(l)return{quote:X,...k.warnings?{warnings:k.warnings}:{},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 q=p.timestamp+300n,K=[],B="Native ETH input; no token approvals.";if(n!==v){let s=await w.readContract({address:n,abi:be,functionName:"allowance",args:[r,V],blockNumber:p.number});s!==h&&K.push(u.approval(n,V,h.toString(),S)),B=`${s===h?"Reuse existing exact ERC-20 allowance of":"Set ERC-20 allowance to exactly"} ${h} input base units to Permit2; exact router permit.`,K.push(u.unsignedTx({to:V,data:oe({abi:xe,functionName:"approve",args:[n,$,h,Number(q)]}),value:"0",chainId:S,description:`Permit exactly ${h} input base units to Universal Router until ${q}.`}))}if(a==="v4"){let s=I?x(ke,[{exactCurrency:e?c:n,path:I,minHopPriceX36:[],amount:i,limit:y}]):x(ge,[{poolKey:f,zeroForOne:n===f.currency0,amount:i,limit:y,minHopPriceX36:0n,hookData:"0x"}]);O=x(Ie,[I?e?"0x090c0f":"0x070c0f":e?"0x080c0f":"0x060c0f",[s,x(ue,[n,h]),x(ue,[c,e?i:y])]])}else a==="v2"?O=x(Pe,[r,i,y,d,!0,[]]):O=x(Ae,[r,i,y,C,!0,[]]);let Q=[O];return n===v&&e&&(A=`${A}04`,Q.push(x(g("address,address,uint256"),[v,r,0n]))),K.push(u.unsignedTx({to:$,data:oe({abi:we,functionName:"execute",args:[A,Q,q]}),value:n===v?h.toString():"0",chainId:S,description:`Uniswap ${a} ${e?"exact output":"exact input"} swap; recipient ${r}; deadline ${q}.`})),{...k.warnings?{warnings:k.warnings}:{},confirmationWarnings:pe,...await Y(u,K,r,`${(k.warnings??[]).join(" ")}${k.warnings?.length?" ":""}Swap through Universal Router 2.1.2. ${B} Fixed output/input bound and initial five-minute on-chain deadline; a started multi-step swap may extend only time limits within the ceiling shown in its approval summary. Venue fees included; gas excluded.`),quote:X}}function Ue(u){return{tools:[!0,!1].map(t=>({name:t?"uniswap_quote":"uniswap_swap",inputSchema:{type:"object",additionalProperties:!1,required:["version","tokenIn","tokenOut"],properties:de},execute:(r,l)=>Ee(u,r,l,t)}))}}export{ie as a,re as b,we as c,xe as d,ae as e,se as f,ke as g,ve as h,ge as i,Ae as j,Pe as k,Se as l,Ee as m,Ue as n};
|