@oakagentkit/core 0.1.1 → 0.1.9
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 +0 -1219
- package/build/dist/api/addresses.js +1 -1
- package/build/dist/api/amounts.d.ts +0 -1
- package/build/dist/api/amounts.js +1 -1
- package/build/dist/api/args.d.ts +19 -0
- package/build/dist/api/args.js +1 -0
- package/build/dist/api/canonical.d.ts +0 -1
- package/build/dist/api/canonical.js +1 -1
- package/build/dist/api/chain.d.ts +2 -0
- package/build/dist/api/chain.js +1 -1
- package/build/dist/api/errors.js +1 -1
- package/build/dist/api/gas.js +1 -1
- package/build/dist/api/grandfather.js +1 -1
- package/build/dist/api/guards.d.ts +23 -0
- package/build/dist/api/guards.js +1 -0
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/http.js +1 -1
- package/build/dist/api/identity-link.js +1 -1
- package/build/dist/api/launch.d.ts +1 -0
- package/build/dist/api/launch.js +1 -1
- package/build/dist/api/merkle.js +1 -1
- package/build/dist/api/metadata.js +1 -1
- package/build/dist/api/module.js +1 -1
- package/build/dist/api/modules/beefy/boosts.d.ts +132 -0
- package/build/dist/api/modules/beefy/boosts.js +1 -0
- package/build/dist/api/modules/beefy/clm.d.ts +282 -0
- package/build/dist/api/modules/beefy/clm.js +1 -0
- package/build/dist/api/modules/beefy/guard.d.ts +5 -0
- package/build/dist/api/modules/beefy/guard.js +1 -0
- package/build/dist/api/modules/beefy/index.js +1 -1
- package/build/dist/api/modules/beefy/liquidity.d.ts +237 -0
- package/build/dist/api/modules/beefy/liquidity.js +1 -0
- package/build/dist/api/modules/beefy/management.d.ts +100 -0
- package/build/dist/api/modules/beefy/management.js +1 -0
- package/build/dist/api/modules/beefy/vaults.d.ts +14 -0
- package/build/dist/api/modules/beefy/vaults.js +1 -0
- package/build/dist/api/modules/clanker/extensions.d.ts +62 -0
- package/build/dist/api/modules/clanker/extensions.js +1 -0
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/clanker/manage.d.ts +2 -0
- package/build/dist/api/modules/clanker/manage.js +1 -0
- package/build/dist/api/modules/clanker/pool-config.d.ts +96 -0
- package/build/dist/api/modules/clanker/pool-config.js +1 -0
- package/build/dist/api/modules/clanker/protocol.d.ts +2 -0
- package/build/dist/api/modules/clanker/protocol.js +1 -0
- package/build/dist/api/modules/clanker/state.d.ts +246 -0
- package/build/dist/api/modules/clanker/state.js +1 -0
- package/build/dist/api/modules/erc8004/abi.d.ts +808 -0
- package/build/dist/api/modules/erc8004/abi.js +1 -0
- package/build/dist/api/modules/erc8004/common.d.ts +69 -0
- package/build/dist/api/modules/erc8004/common.js +1 -0
- package/build/dist/api/modules/erc8004/domain.d.ts +3 -0
- package/build/dist/api/modules/erc8004/domain.js +1 -0
- package/build/dist/api/modules/erc8004/index.d.ts +3 -171
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/erc8004/management.d.ts +4 -0
- package/build/dist/api/modules/erc8004/management.js +1 -0
- package/build/dist/api/modules/erc8004/reputation.d.ts +3 -0
- package/build/dist/api/modules/erc8004/reputation.js +1 -0
- package/build/dist/api/modules/erc8004/services.d.ts +2 -0
- package/build/dist/api/modules/erc8004/services.js +1 -0
- package/build/dist/api/modules/erc8004/validation.d.ts +2 -0
- package/build/dist/api/modules/erc8004/validation.js +1 -0
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/freshness.d.ts +12 -0
- package/build/dist/api/modules/heyresearch/freshness.js +1 -0
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.d.ts +5 -0
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -0
- package/build/dist/api/modules/hoodag/chain-reads.d.ts +33 -0
- package/build/dist/api/modules/hoodag/chain-reads.js +1 -0
- package/build/dist/api/modules/hoodag/index.d.ts +9 -1
- package/build/dist/api/modules/hoodag/index.js +1 -1
- package/build/dist/api/modules/hoodag/management.d.ts +2 -0
- package/build/dist/api/modules/hoodag/management.js +1 -0
- package/build/dist/api/modules/hoodag/public-reads.d.ts +2 -0
- package/build/dist/api/modules/hoodag/public-reads.js +1 -0
- package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
- package/build/dist/api/modules/hoodag/reconstruct.js +1 -0
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/buyback.d.ts +28 -0
- package/build/dist/api/modules/hoodlock/buyback.js +1 -0
- package/build/dist/api/modules/hoodlock/commerce.d.ts +24 -0
- package/build/dist/api/modules/hoodlock/commerce.js +1 -0
- package/build/dist/api/modules/hoodlock/fee.d.ts +15 -0
- package/build/dist/api/modules/hoodlock/fee.js +1 -0
- package/build/dist/api/modules/hoodlock/guard.d.ts +5 -0
- package/build/dist/api/modules/hoodlock/guard.js +1 -0
- package/build/dist/api/modules/hoodlock/index.d.ts +4 -0
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.d.ts +285 -0
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -0
- package/build/dist/api/modules/hoodlock/locks-burn.d.ts +3 -3
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.d.ts +3 -0
- package/build/dist/api/modules/hoodlock/public.js +1 -0
- package/build/dist/api/modules/hookr/actions.d.ts +4 -0
- package/build/dist/api/modules/hookr/actions.js +1 -0
- package/build/dist/api/modules/hookr/addons.d.ts +4 -0
- package/build/dist/api/modules/hookr/addons.js +1 -0
- package/build/dist/api/modules/hookr/contracts.d.ts +30 -0
- package/build/dist/api/modules/hookr/contracts.js +1 -0
- package/build/dist/api/modules/hookr/create-cancel.d.ts +10 -73
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.d.ts +3 -0
- package/build/dist/api/modules/hookr/discovery.js +1 -0
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.d.ts +0 -3
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.d.ts +4 -0
- package/build/dist/api/modules/hookr/public-reads.js +1 -0
- package/build/dist/api/modules/hookr/relay.d.ts +304 -0
- package/build/dist/api/modules/hookr/relay.js +1 -0
- package/build/dist/api/modules/hookr/revenue.d.ts +5 -0
- package/build/dist/api/modules/hookr/revenue.js +1 -0
- package/build/dist/api/modules/kyberswap/index.d.ts +18 -2
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.d.ts +9 -0
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -0
- package/build/dist/api/modules/lighter/index.js +1 -1
- package/build/dist/api/modules/longbow/administration.d.ts +119 -0
- package/build/dist/api/modules/longbow/administration.js +1 -0
- package/build/dist/api/modules/longbow/analytics.d.ts +272 -0
- package/build/dist/api/modules/longbow/analytics.js +1 -0
- package/build/dist/api/modules/longbow/fixed.d.ts +126 -0
- package/build/dist/api/modules/longbow/fixed.js +1 -0
- package/build/dist/api/modules/longbow/index.d.ts +20 -2
- package/build/dist/api/modules/longbow/index.js +1 -1
- package/build/dist/api/modules/longbow/nft.d.ts +236 -0
- package/build/dist/api/modules/longbow/nft.js +1 -0
- package/build/dist/api/modules/longbow/rebates.d.ts +152 -0
- package/build/dist/api/modules/longbow/rebates.js +1 -0
- package/build/dist/api/modules/longbow/staking.d.ts +4 -0
- package/build/dist/api/modules/longbow/staking.js +1 -0
- 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/perps-batch.d.ts +4 -0
- package/build/dist/api/modules/meridian/perps-batch.js +1 -0
- package/build/dist/api/modules/meridian/perps-common.d.ts +56 -0
- package/build/dist/api/modules/meridian/perps-common.js +1 -0
- package/build/dist/api/modules/meridian/perps-guards.d.ts +3 -0
- package/build/dist/api/modules/meridian/perps-guards.js +1 -0
- package/build/dist/api/modules/meridian/perps-intents.d.ts +18 -0
- package/build/dist/api/modules/meridian/perps-intents.js +1 -0
- package/build/dist/api/modules/meridian/perps-stream.d.ts +3 -0
- package/build/dist/api/modules/meridian/perps-stream.js +1 -0
- package/build/dist/api/modules/meridian/perps.d.ts +3 -0
- package/build/dist/api/modules/meridian/perps.js +1 -0
- package/build/dist/api/modules/meridian/predict-read.d.ts +2 -0
- package/build/dist/api/modules/meridian/predict-read.js +1 -0
- package/build/dist/api/modules/meridian/rfq.d.ts +29 -0
- package/build/dist/api/modules/meridian/rfq.js +1 -1
- package/build/dist/api/modules/merkl/discovery.d.ts +2 -0
- package/build/dist/api/modules/merkl/discovery.js +1 -0
- package/build/dist/api/modules/merkl/index.d.ts +10 -1
- package/build/dist/api/modules/merkl/index.js +1 -1
- package/build/dist/api/modules/merkl/manage.d.ts +2 -0
- package/build/dist/api/modules/merkl/manage.js +1 -0
- package/build/dist/api/modules/merkl/protocol.d.ts +2 -0
- package/build/dist/api/modules/merkl/protocol.js +1 -0
- package/build/dist/api/modules/morpho/allocator.d.ts +308 -0
- package/build/dist/api/modules/morpho/allocator.js +1 -0
- package/build/dist/api/modules/morpho/bundles-abi.d.ts +705 -0
- package/build/dist/api/modules/morpho/bundles-abi.js +1 -0
- package/build/dist/api/modules/morpho/bundles.d.ts +3 -0
- package/build/dist/api/modules/morpho/bundles.js +1 -0
- package/build/dist/api/modules/morpho/in-kind.d.ts +85 -0
- package/build/dist/api/modules/morpho/in-kind.js +1 -0
- package/build/dist/api/modules/morpho/index.d.ts +11 -3
- package/build/dist/api/modules/morpho/index.js +1 -12
- package/build/dist/api/modules/morpho/local-guard.d.ts +26 -0
- package/build/dist/api/modules/morpho/local-guard.js +1 -0
- package/build/dist/api/modules/morpho/midnight-abi.d.ts +1690 -0
- package/build/dist/api/modules/morpho/midnight-abi.js +1 -0
- package/build/dist/api/modules/morpho/midnight.d.ts +179 -0
- package/build/dist/api/modules/morpho/midnight.js +1 -0
- package/build/dist/api/modules/morpho/protocol.d.ts +290 -0
- package/build/dist/api/modules/morpho/protocol.js +1 -0
- package/build/dist/api/modules/morpho/surface.d.ts +4 -0
- package/build/dist/api/modules/morpho/surface.js +1 -0
- package/build/dist/api/modules/morpho/vault-management.d.ts +10 -0
- package/build/dist/api/modules/morpho/vault-management.js +1 -0
- package/build/dist/api/modules/morpho/vault-tools.d.ts +6 -0
- package/build/dist/api/modules/morpho/vault-tools.js +1 -0
- package/build/dist/api/modules/morpho/vault-v2.d.ts +190 -0
- package/build/dist/api/modules/morpho/vault-v2.js +1 -0
- package/build/dist/api/modules/netnet/blackjack-hashes.d.ts +89 -0
- package/build/dist/api/modules/netnet/blackjack-hashes.js +1 -0
- package/build/dist/api/modules/netnet/card-abi.d.ts +3758 -0
- package/build/dist/api/modules/netnet/card-abi.js +1 -0
- package/build/dist/api/modules/netnet/card-plan.d.ts +43 -0
- package/build/dist/api/modules/netnet/card-plan.js +1 -0
- package/build/dist/api/modules/netnet/card-policy.d.ts +10 -0
- package/build/dist/api/modules/netnet/card-policy.js +1 -0
- package/build/dist/api/modules/netnet/card-read.d.ts +2 -0
- package/build/dist/api/modules/netnet/card-read.js +1 -0
- package/build/dist/api/modules/netnet/card-recovery.d.ts +2 -0
- package/build/dist/api/modules/netnet/card-recovery.js +1 -0
- package/build/dist/api/modules/netnet/desk-action-abi.d.ts +2 -0
- package/build/dist/api/modules/netnet/desk-action-abi.js +1 -0
- package/build/dist/api/modules/netnet/desk-action.d.ts +3 -0
- package/build/dist/api/modules/netnet/desk-action.js +1 -0
- package/build/dist/api/modules/netnet/desk-read.d.ts +5 -0
- package/build/dist/api/modules/netnet/desk-read.js +1 -0
- package/build/dist/api/modules/netnet/desk-registry.d.ts +5 -0
- package/build/dist/api/modules/netnet/desk-registry.js +1 -0
- package/build/dist/api/modules/netnet/financial-abi.d.ts +1764 -0
- package/build/dist/api/modules/netnet/financial-abi.js +1 -0
- package/build/dist/api/modules/netnet/financial.d.ts +13 -0
- package/build/dist/api/modules/netnet/financial.js +1 -0
- package/build/dist/api/modules/netnet/index.d.ts +1 -0
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/netnet/staking.d.ts +8 -0
- package/build/dist/api/modules/netnet/staking.js +1 -0
- package/build/dist/api/modules/orbio/gateway.d.ts +24 -0
- package/build/dist/api/modules/orbio/gateway.js +1 -0
- package/build/dist/api/modules/orbio/index.d.ts +3 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/orbio/pins.d.ts +457 -0
- package/build/dist/api/modules/orbio/pins.js +1 -0
- package/build/dist/api/modules/pons/claim.d.ts +33 -1
- package/build/dist/api/modules/pons/claim.js +1 -1
- package/build/dist/api/modules/pons/holder-directory.d.ts +35 -0
- package/build/dist/api/modules/pons/holder-directory.js +1 -0
- package/build/dist/api/modules/pons/index.js +1 -1
- package/build/dist/api/modules/pons/launch-status.d.ts +151 -5
- 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.d.ts +3 -0
- package/build/dist/api/modules/pons/reads.js +1 -0
- package/build/dist/api/modules/pons/swap-terms.d.ts +77 -0
- package/build/dist/api/modules/pons/swap-terms.js +1 -0
- package/build/dist/api/modules/pons/trade.d.ts +15 -2
- 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.d.ts +23 -0
- package/build/dist/api/modules/priors/coverage.js +1 -0
- package/build/dist/api/modules/priors/discovery.d.ts +4 -0
- package/build/dist/api/modules/priors/discovery.js +1 -0
- package/build/dist/api/modules/priors/features.d.ts +62 -0
- package/build/dist/api/modules/priors/features.js +1 -0
- package/build/dist/api/modules/priors/index.d.ts +9 -2
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.d.ts +6 -0
- package/build/dist/api/modules/priors/integration.js +1 -0
- package/build/dist/api/modules/priors/market.d.ts +10 -0
- package/build/dist/api/modules/priors/market.js +1 -0
- package/build/dist/api/modules/priors/pt.d.ts +421 -0
- package/build/dist/api/modules/priors/pt.js +1 -0
- package/build/dist/api/modules/priors/savings-exit.d.ts +85 -0
- package/build/dist/api/modules/priors/savings-exit.js +1 -0
- package/build/dist/api/modules/priors/starter-line.d.ts +495 -0
- package/build/dist/api/modules/priors/starter-line.js +1 -0
- package/build/dist/api/modules/priors/stock-swap.d.ts +101 -0
- package/build/dist/api/modules/priors/stock-swap.js +1 -0
- package/build/dist/api/modules/relay/api.d.ts +52 -0
- package/build/dist/api/modules/relay/api.js +1 -0
- package/build/dist/api/modules/relay/bootstrap.d.ts +2 -0
- package/build/dist/api/modules/relay/bootstrap.js +1 -0
- package/build/dist/api/modules/relay/discovery.d.ts +2 -0
- package/build/dist/api/modules/relay/discovery.js +1 -0
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.d.ts +2 -0
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/order.d.ts +2 -0
- package/build/dist/api/modules/relay/order.js +1 -0
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/relay/readiness.d.ts +5 -0
- package/build/dist/api/modules/relay/readiness.js +1 -0
- package/build/dist/api/modules/relay/reads.d.ts +3 -0
- package/build/dist/api/modules/relay/reads.js +1 -0
- package/build/dist/api/modules/relay/vaults.d.ts +24 -0
- package/build/dist/api/modules/relay/vaults.js +1 -0
- package/build/dist/api/modules/spark/actions.d.ts +2 -0
- package/build/dist/api/modules/spark/actions.js +1 -0
- package/build/dist/api/modules/spark/details.d.ts +3 -0
- package/build/dist/api/modules/spark/details.js +1 -0
- package/build/dist/api/modules/spark/index.js +1 -1
- package/build/dist/api/modules/spark/management.d.ts +7 -0
- package/build/dist/api/modules/spark/management.js +1 -0
- package/build/dist/api/modules/steakhouse/analytics.d.ts +2 -0
- package/build/dist/api/modules/steakhouse/analytics.js +1 -0
- package/build/dist/api/modules/steakhouse/erc4626.d.ts +2 -0
- package/build/dist/api/modules/steakhouse/erc4626.js +1 -0
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.d.ts +7 -0
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -0
- package/build/dist/api/modules/steakhouse/management.d.ts +3 -0
- package/build/dist/api/modules/steakhouse/management.js +1 -0
- package/build/dist/api/modules/steakhouse/v2-exit.d.ts +19 -0
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -0
- package/build/dist/api/modules/tickerspring/basket-routes.d.ts +2 -0
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -0
- package/build/dist/api/modules/tickerspring/contract-reads.d.ts +2 -0
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -0
- package/build/dist/api/modules/tickerspring/discovery.d.ts +27 -0
- package/build/dist/api/modules/tickerspring/discovery.js +1 -0
- package/build/dist/api/modules/tickerspring/exit-preview.d.ts +14 -0
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -0
- package/build/dist/api/modules/tickerspring/guards.d.ts +7 -0
- package/build/dist/api/modules/tickerspring/guards.js +1 -0
- package/build/dist/api/modules/tickerspring/index.d.ts +80 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.d.ts +31 -0
- package/build/dist/api/modules/tickerspring/journeys.js +1 -0
- package/build/dist/api/modules/tickerspring/ladder.d.ts +8 -0
- package/build/dist/api/modules/tickerspring/ladder.js +1 -0
- package/build/dist/api/modules/tickerspring/maker.d.ts +8 -0
- package/build/dist/api/modules/tickerspring/maker.js +1 -0
- package/build/dist/api/modules/tickerspring/order-accounting.d.ts +4 -0
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -0
- package/build/dist/api/modules/tickerspring/research.d.ts +2 -0
- package/build/dist/api/modules/tickerspring/research.js +1 -0
- package/build/dist/api/modules/tickerspring/strategies.d.ts +17 -0
- package/build/dist/api/modules/tickerspring/strategies.js +1 -0
- package/build/dist/api/modules/uniswap/auction-create.d.ts +112 -0
- package/build/dist/api/modules/uniswap/auction-create.js +1 -0
- package/build/dist/api/modules/uniswap/auction.d.ts +212 -0
- package/build/dist/api/modules/uniswap/auction.js +1 -0
- package/build/dist/api/modules/uniswap/batch.d.ts +22 -0
- package/build/dist/api/modules/uniswap/batch.js +1 -0
- package/build/dist/api/modules/uniswap/common.d.ts +12 -0
- package/build/dist/api/modules/uniswap/common.js +1 -0
- package/build/dist/api/modules/uniswap/fees.d.ts +54 -0
- package/build/dist/api/modules/uniswap/fees.js +1 -0
- package/build/dist/api/modules/uniswap/index.d.ts +2 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.d.ts +16 -0
- package/build/dist/api/modules/uniswap/local-guard.js +1 -0
- package/build/dist/api/modules/uniswap/oracle.d.ts +2 -0
- package/build/dist/api/modules/uniswap/oracle.js +1 -0
- package/build/dist/api/modules/uniswap/pool-math.d.ts +13 -0
- package/build/dist/api/modules/uniswap/pool-math.js +1 -0
- package/build/dist/api/modules/uniswap/pools.d.ts +30 -0
- package/build/dist/api/modules/uniswap/pools.js +1 -0
- package/build/dist/api/modules/uniswap/position.d.ts +69 -0
- package/build/dist/api/modules/uniswap/position.js +1 -0
- package/build/dist/api/modules/uniswap/protocol.d.ts +154 -0
- package/build/dist/api/modules/uniswap/protocol.js +1 -0
- package/build/dist/api/modules/uniswap/token-jar.d.ts +52 -0
- package/build/dist/api/modules/uniswap/token-jar.js +1 -0
- package/build/dist/api/modules/uniswap/trade-batch.d.ts +2 -0
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -0
- package/build/dist/api/modules/uniswap/trade.d.ts +406 -0
- package/build/dist/api/modules/uniswap/trade.js +1 -0
- package/build/dist/api/modules/uniswap/v2.d.ts +180 -0
- package/build/dist/api/modules/uniswap/v2.js +1 -0
- package/build/dist/api/modules/uniswap/v3.d.ts +23 -2
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.d.ts +17 -28
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.d.ts +17 -0
- package/build/dist/api/modules/uniswap/wrap.js +1 -0
- package/build/dist/api/modules/velora/claims.d.ts +86 -0
- package/build/dist/api/modules/velora/claims.js +1 -0
- package/build/dist/api/modules/velora/delta-reads.d.ts +2 -0
- package/build/dist/api/modules/velora/delta-reads.js +1 -0
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/owner-signature.d.ts +29 -0
- package/build/dist/api/owner-signature.js +1 -0
- package/build/dist/api/positions.js +1 -1
- package/build/dist/api/pricenote.d.ts +0 -1
- package/build/dist/api/pricenote.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/pricing.d.ts +6 -15
- package/build/dist/api/pricing.js +1 -1
- package/build/dist/api/routes.js +1 -1
- package/build/dist/api/rpc.d.ts +23 -0
- package/build/dist/api/rpc.js +1 -0
- package/build/dist/api/secret-fields.js +1 -1
- package/build/dist/api/send.d.ts +45 -0
- package/build/dist/api/send.js +1 -0
- package/build/dist/api/signing-registry.d.ts +19 -0
- package/build/dist/api/signing-registry.js +1 -0
- package/build/dist/api/signing.d.ts +162 -0
- package/build/dist/api/signing.js +1 -0
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.d.ts +62 -27
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.d.ts +5 -0
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.d.ts +7 -0
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/tx.js +1 -1
- package/build/dist/api/types.d.ts +12 -0
- package/build/dist/api/untrusted.js +1 -1
- package/build/dist/api/vendor-limits.js +1 -1
- package/build/dist/chunks/2EDXKJ3B.js +1 -0
- package/build/dist/chunks/2EGFALNH.js +1 -0
- package/build/dist/chunks/2LM5C7FQ.js +1 -0
- package/build/dist/chunks/2NA6JLEC.js +1 -0
- package/build/dist/chunks/2O6A6WEX.js +1 -0
- package/build/dist/chunks/37QNUNED.js +1 -0
- package/build/dist/chunks/3CCBUYUM.js +1 -0
- package/build/dist/chunks/3RFSGU2Y.js +1 -0
- package/build/dist/chunks/{XTUXR43N.js → 3Z3U4YPA.js} +1 -1
- package/build/dist/chunks/4CDR7F4I.js +1 -0
- package/build/dist/chunks/4X6JEMSF.js +1 -0
- package/build/dist/chunks/53N7PNJH.js +1 -0
- package/build/dist/chunks/5EHQM6DM.js +1 -0
- package/build/dist/chunks/5H3MQWH7.js +18 -0
- package/build/dist/chunks/5XFXH2JT.js +1 -0
- package/build/dist/chunks/5YS5V2LK.js +1 -0
- package/build/dist/chunks/65QFM4JU.js +1 -0
- package/build/dist/chunks/67TJOOBI.js +1 -0
- package/build/dist/chunks/6HV5BR7P.js +1 -0
- package/build/dist/chunks/{VBWJOG3N.js → 6IM6A5VA.js} +1 -1
- package/build/dist/chunks/6JCEJ66K.js +1 -0
- package/build/dist/chunks/6NR7SVRO.js +1 -0
- package/build/dist/chunks/6SB3FB3P.js +1 -0
- package/build/dist/chunks/6SCCW74G.js +1 -0
- package/build/dist/chunks/73N3TOJL.js +1 -0
- package/build/dist/chunks/74BPMUAG.js +1 -0
- package/build/dist/chunks/7B5UH2VS.js +1 -0
- package/build/dist/chunks/7LDAJ6BM.js +1 -0
- package/build/dist/chunks/7MR37STI.js +1 -0
- package/build/dist/chunks/7US6PD56.js +1 -0
- package/build/dist/chunks/7YU6DELJ.js +1 -0
- package/build/dist/chunks/AFHHRDPJ.js +1 -0
- package/build/dist/chunks/AIWZGIZ6.js +1 -0
- package/build/dist/chunks/AXYOJBX6.js +1 -0
- package/build/dist/chunks/AYM5L6L7.js +1 -0
- package/build/dist/chunks/B72Q2EQ2.js +1 -0
- package/build/dist/chunks/B7V7AA5A.js +1 -0
- package/build/dist/chunks/BBQVTEYB.js +1 -0
- package/build/dist/chunks/BQLLTY4L.js +1 -0
- package/build/dist/chunks/BYXBS45D.js +1 -0
- package/build/dist/chunks/C2FEXLMA.js +1 -0
- package/build/dist/chunks/C3TJLARP.js +1 -0
- package/build/dist/chunks/C3ZZSGSP.js +1 -0
- package/build/dist/chunks/C5LR6F4B.js +1 -0
- package/build/dist/chunks/CAYBSVA6.js +1 -0
- package/build/dist/chunks/CBA776XQ.js +1 -0
- package/build/dist/chunks/CCEWSOBT.js +1 -0
- package/build/dist/chunks/CEQNXF6A.js +1 -0
- package/build/dist/chunks/CS55ERS3.js +1 -0
- package/build/dist/chunks/CXMC3T6B.js +1 -0
- package/build/dist/chunks/{PQHU5A3U.js → D3OWLDVB.js} +1 -1
- package/build/dist/chunks/DHXVYHT4.js +1 -0
- package/build/dist/chunks/E2IVNGLC.js +1 -0
- package/build/dist/chunks/E2Q5IA67.js +1 -0
- package/build/dist/chunks/{RYOVSHKO.js → E7ASOYQI.js} +1 -1
- package/build/dist/chunks/EAEQOS7Y.js +1 -0
- package/build/dist/chunks/EC5W3UZD.js +1 -0
- package/build/dist/chunks/{XAB4OIE3.js → EG6M6SSO.js} +1 -1
- package/build/dist/chunks/EHVPRQHS.js +1 -0
- package/build/dist/chunks/EKGHKEKV.js +1 -0
- package/build/dist/chunks/EVANKNJV.js +1 -0
- package/build/dist/chunks/F2YH72GF.js +1 -0
- package/build/dist/chunks/F3TJCOVV.js +1 -0
- package/build/dist/chunks/F6WBPPBN.js +1 -0
- package/build/dist/chunks/FL3EF72E.js +1 -0
- package/build/dist/chunks/FLXID6I3.js +1 -0
- package/build/dist/chunks/FYTF2QMS.js +1 -0
- package/build/dist/chunks/G7UKNO2I.js +1 -0
- package/build/dist/chunks/GZ5TW3WB.js +1 -0
- package/build/dist/chunks/H4S2ZCWK.js +1 -0
- package/build/dist/chunks/H6ED3RHF.js +1 -0
- package/build/dist/chunks/HACP2Q6D.js +3 -0
- package/build/dist/chunks/HF2AGJZC.js +1 -0
- package/build/dist/chunks/HFQS5344.js +1 -0
- package/build/dist/chunks/{74X7PXPR.js → HIMVOTIU.js} +1 -1
- package/build/dist/chunks/HL2MLC3O.js +1 -0
- package/build/dist/chunks/HNMOB76J.js +1 -0
- package/build/dist/chunks/HQVC6X3T.js +1 -0
- package/build/dist/chunks/HYIEQG4X.js +1 -0
- package/build/dist/chunks/HZUWK5B2.js +1 -0
- package/build/dist/chunks/IHGVCPVA.js +2 -0
- package/build/dist/chunks/IKP3Z3RX.js +1 -0
- package/build/dist/chunks/ITIIHCZK.js +1 -0
- package/build/dist/chunks/IWALIX7Q.js +1 -0
- package/build/dist/chunks/JOMK32QW.js +1 -0
- package/build/dist/chunks/JRO6WTK4.js +1 -0
- package/build/dist/chunks/JRVTSGAT.js +1 -0
- package/build/dist/chunks/JRZLKIYB.js +1 -0
- package/build/dist/chunks/JVTVOK6P.js +1 -0
- package/build/dist/chunks/{XN4WDN3O.js → JXOEJPJ4.js} +1 -1
- package/build/dist/chunks/K2LWX3PZ.js +1 -0
- package/build/dist/chunks/KEPQXFHU.js +1 -0
- package/build/dist/chunks/L24EOVLT.js +1 -0
- package/build/dist/chunks/L2MTPRU7.js +1 -0
- package/build/dist/chunks/LBEMCOND.js +1 -0
- package/build/dist/chunks/LFKSXD3S.js +1 -0
- package/build/dist/chunks/MRWCFTMS.js +1 -0
- package/build/dist/chunks/MWWYIFXJ.js +1 -0
- package/build/dist/chunks/MYBDO5SA.js +1 -0
- package/build/dist/chunks/N77ANGBT.js +1 -0
- package/build/dist/chunks/NCQFWPAW.js +1 -0
- package/build/dist/chunks/NHCRJC5X.js +1 -0
- package/build/dist/chunks/NNZ4SZZ4.js +1 -0
- package/build/dist/chunks/NUWL6TJM.js +1 -0
- package/build/dist/chunks/O47JXRXN.js +1 -0
- package/build/dist/chunks/{MEZH7RPA.js → OG5HRQU4.js} +1 -1
- package/build/dist/chunks/OJLMF5AR.js +1 -0
- package/build/dist/chunks/OJMYESQU.js +1 -0
- package/build/dist/chunks/OJP7Y4AM.js +1 -0
- package/build/dist/chunks/OK3TQFXZ.js +1 -0
- package/build/dist/chunks/OW7GOYKA.js +1 -0
- package/build/dist/chunks/P4UQGWCP.js +1 -0
- package/build/dist/chunks/P6ELT4ZV.js +1 -0
- package/build/dist/chunks/PHXWBC4O.js +1 -0
- package/build/dist/chunks/Q2VMH2LB.js +1 -0
- package/build/dist/chunks/QH3AL3UN.js +1 -0
- package/build/dist/chunks/QHHZDXRG.js +1 -0
- package/build/dist/chunks/QNPEKNWM.js +1 -0
- package/build/dist/chunks/QOY4AANB.js +1 -0
- package/build/dist/chunks/QRUC7EFE.js +1 -0
- package/build/dist/chunks/QYKXWBZC.js +1 -0
- package/build/dist/chunks/REGJY5RC.js +1 -0
- package/build/dist/chunks/RETS2ZEK.js +1 -0
- package/build/dist/chunks/RFJCG4NA.js +1 -0
- package/build/dist/chunks/RNEMTLQG.js +1 -0
- package/build/dist/chunks/RRSODRGT.js +1 -0
- package/build/dist/chunks/SEW7UP5U.js +1 -0
- package/build/dist/chunks/SLSPWXR6.js +1 -0
- package/build/dist/chunks/SPRVVJXI.js +1 -0
- package/build/dist/chunks/SQ5BNSXR.js +1 -0
- package/build/dist/chunks/SQH7A4O3.js +1 -0
- package/build/dist/chunks/SS7U3CMZ.js +1 -0
- package/build/dist/chunks/SXX52Y27.js +1 -0
- package/build/dist/chunks/SYZ55RCX.js +1 -0
- package/build/dist/chunks/T6MTTMLQ.js +1 -0
- package/build/dist/chunks/TAI63P6E.js +1 -0
- package/build/dist/chunks/TCS3ICNE.js +2 -0
- package/build/dist/chunks/TRCP7X5P.js +1 -0
- package/build/dist/chunks/TWR7BF72.js +1 -0
- package/build/dist/chunks/UEYFMXV3.js +1 -0
- package/build/dist/chunks/UWOFA6GV.js +1 -0
- package/build/dist/chunks/UXG67LH3.js +1 -0
- package/build/dist/chunks/V6SDKPZS.js +1 -0
- package/build/dist/chunks/VCWDJQDE.js +1 -0
- package/build/dist/chunks/{6YQ2RX5I.js → VXLJRRKV.js} +1 -1
- package/build/dist/chunks/W6G2QGYF.js +1 -0
- package/build/dist/chunks/WCKMQFGS.js +1117 -0
- package/build/dist/chunks/WHT45EFX.js +1 -0
- package/build/dist/chunks/WIDTTGSH.js +1 -0
- package/build/dist/chunks/WQZLYX64.js +1 -0
- package/build/dist/chunks/X5V2Z2NM.js +1 -0
- package/build/dist/chunks/{Z53DADZ4.js → XCFA73P2.js} +1 -1
- package/build/dist/chunks/XPFVT2EA.js +1 -0
- package/build/dist/chunks/XV6F3RET.js +1 -0
- package/build/dist/chunks/XW7RH7YY.js +1 -0
- package/build/dist/chunks/YHPOXAKA.js +1 -0
- package/build/dist/chunks/YONRUWN7.js +1 -0
- package/build/dist/chunks/YR3QJVJQ.js +1 -0
- package/build/dist/chunks/Z4LJ2GTX.js +1 -0
- package/build/dist/chunks/ZL3KVABO.js +1 -0
- package/build/dist/chunks/ZPM2MFXZ.js +1 -0
- package/build/dist/chunks/ZPNGV34U.js +1 -0
- package/build/dist/chunks/ZQI7B2Z7.js +1 -0
- package/build/dist/chunks/ZT67OMLW.js +1 -0
- package/package.json +13 -9
- package/build/dist/chunks/5B3UVWMV.js +0 -1
- package/build/dist/chunks/5BP72XOA.js +0 -1
- package/build/dist/chunks/5SH3C7XP.js +0 -1
- package/build/dist/chunks/7I6TXFXR.js +0 -1
- package/build/dist/chunks/A5O3SRHY.js +0 -1
- package/build/dist/chunks/B2LA6VVF.js +0 -3
- package/build/dist/chunks/CWQ5WXZQ.js +0 -1
- package/build/dist/chunks/F3TOOLFQ.js +0 -1
- package/build/dist/chunks/GOIVHR4B.js +0 -1
- package/build/dist/chunks/M643PYHO.js +0 -1
- package/build/dist/chunks/NDHEJGWR.js +0 -1
- package/build/dist/chunks/NNJLMS7F.js +0 -1
- package/build/dist/chunks/R5CBH2CR.js +0 -1
- package/build/dist/chunks/SUQ6PIAV.js +0 -1
- package/build/dist/chunks/SXBGOGYQ.js +0 -1
- package/build/dist/chunks/T4IYMYZD.js +0 -1
- package/build/dist/chunks/TFYLOWFO.js +0 -1
- package/build/dist/chunks/TU3KHOZK.js +0 -1
- package/build/dist/chunks/UB5U6SI2.js +0 -1
- package/build/dist/chunks/UIJWIFGV.js +0 -1
- package/build/dist/chunks/WFE3NXBF.js +0 -2
- package/build/dist/chunks/XEN45QST.js +0 -1
- package/build/dist/chunks/XKZOMGC3.js +0 -1
- package/build/dist/chunks/Y2SGXWFM.js +0 -1
- package/build/dist/chunks/Z3FZWNAJ.js +0 -1
- package/build/dist/chunks/ZJUNO5N7.js +0 -1
- package/build/dist/chunks/ZZLHDHOT.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as Y}from"./RYOVSHKO.js";import{b as V,c as W,d as G}from"./SXBGOGYQ.js";import{e as de,f as L}from"./XEN45QST.js";import{a as B}from"./Z53DADZ4.js";import{a as N}from"./VBWJOG3N.js";import{a as S,i as D}from"./5BP72XOA.js";import{a as H,b as se,c as ae,d as j}from"./7I6TXFXR.js";import{a as r}from"./Z3FZWNAJ.js";import{decodeEventLog as pe,decodeFunctionData as ve,encodeAbiParameters as ye,encodeFunctionData as ge,erc20Abi as Z,getAddress as l,isAddress as $,keccak256 as Ne,parseAbi as Be,parseAbiParameters as we,toEventSelector as be}from"viem";var k=l(D[4663].hookr.HookrLimitOrders.address),Fe=l(D[4663].hookr.HookrRoot.address),ke=l(D[4663].hookr.HookrRouter.address),At=l(D[4663].hookr.HookrQuoter.address),Me=l(D[4663].hookr.HookrRegistry.address),ze=l(D[4663].hookr.HookrForwarder.address),Oe=l(D[4663].hookr.PoolManager.address),ht=l(D[4663].hookr.HOOKR_Token.address),qe=l("0x000000000000000000000000000000000000dEaD"),Xe=8388608,Ke=200,ce=60n,Ue=604800n,ue=31536000n,St=10,Ct=100,xt="500000000000000",Dt="10000000000000000",le=4096n,Q=32n,je=1e4,Ve=(1n<<127n)-1n,me=(1n<<128n)-1n,We=(1n<<160n)-1n,Ge=(1n<<40n)-1n,Ye=16777215,Qe=8388607,fe=1n<<192n,ee=0,M=1,Ze=2,Je=3,et=be("OrderCreated(uint256,address,bytes32,bool,uint128,uint128,uint128,uint40,address)"),tt=be("OrderCancelled(uint256,address,address,uint256,uint256)"),A=Be(["function bountyBounds((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut) view returns (uint128 minBounty, uint128 defaultBounty, uint128 maxBounty)","function createOrder(((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint160 sqrtPriceLimitX96, address recipient, uint40 expiry, uint128 bounty) params) payable returns (uint256 orderId)","function cancel(uint256 orderId, address to)","function getOrder(uint256 orderId) view returns (((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, address owner, uint40 createdAt, uint40 expiry, bool zeroForOne, uint8 status, address recipient, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint160 sqrtPriceLimitX96))","function quoteFill(uint256 orderId) view returns (bool fillable, uint256 amountOut)","function lastOrderId() view returns (uint256)","function liabilities(address currency) view returns (uint256)","function router() view returns (address)","function registry() view returns (address)","function poolManager() view returns (address)","function forwarder() view returns (address)","event OrderCreated(uint256 indexed orderId, address indexed owner, bytes32 indexed poolId, bool zeroForOne, uint128 amountIn, uint128 minAmountOut, uint128 bounty, uint40 expiry, address recipient)","event OrderCancelled(uint256 indexed orderId, address indexed owner, address indexed to, uint256 amountIn, uint256 bounty)"]);function F(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ie(e){let t=e.toLowerCase();return t===L.toLowerCase()||t===B.toLowerCase()||t===de.toLowerCase()}function T(e,t){if(typeof e!="string"||!e.trim())throw new r(`Provide a valid contract address for ${t}. Identify tokens by chain and address, never by symbol.`);let n=e.trim();if(!$(n,{strict:!1}))throw new r(`Invalid token address "${n}" for ${t}. Identify tokens by chain and address, never by symbol.`);return Ie(n)?L:l(n)}function Ae(e){let t=e===void 0?S:Number(e);if(!Number.isSafeInteger(t)||t!==S)throw new r(`Hookr limit orders are only supported on Robinhood Chain (${S}).`);return S}function nt(e){switch(e){case ee:return"None";case M:return"Open";case Ze:return"Filled";case Je:return"Cancelled";default:return"Unknown"}}function rt(e,t,n=ae){if(typeof e!="string"||!/^-?\d+$/.test(e.trim()))throw new r("Signed amount must be an integer string in base units.");let o=e.trim();if(o.startsWith("-")){let i=o.slice(1),u=n(i,t);return u==="0"?"0":`-${u}`}return n(o,t)}function Lt(e,t,n="floor"){return se(e,t,n)}function he(e){return Ne(ye(we("address, address, uint24, int24, address"),[l(e.currency0),l(e.currency1),e.fee,e.tickSpacing,l(e.hooks)]))}function Se(e,t){let n=e.toLowerCase();if(new Set([L.toLowerCase(),qe.toLowerCase(),k.toLowerCase(),ke.toLowerCase(),ze.toLowerCase(),Oe.toLowerCase(),t.toLowerCase()]).has(n))throw new r(`Recipient ${e} is a reserved address and cannot receive Hookr limit order funds.`)}async function J(e,t,n,o){if(Ie(e))return{address:B,symbol:V.symbol,decimals:V.decimals,chainId:t};let i=l(e),u=i.toLowerCase();if(F(o)){let s=typeof o.decimals=="number"&&Number.isInteger(o.decimals)&&o.decimals>=0&&o.decimals<=255?o.decimals:void 0,a=typeof o.symbol=="string"&&o.symbol.trim()?o.symbol.trim():void 0;if(s!==void 0&&a!==void 0)return{address:i,symbol:a,decimals:s,chainId:t}}if(u===W.address.toLowerCase())return{...W,chainId:t};if(u===G.address.toLowerCase())return{...G,chainId:t};try{let[s,a]=await Promise.all([n.readContract({address:i,abi:Z,functionName:"symbol"}),n.readContract({address:i,abi:Z,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||typeof a!="number"||!Number.isInteger(a)||a<0||a>255)throw new r(`Invalid token metadata for ${i}.`);return{address:i,symbol:s.trim(),decimals:a,chainId:t}}catch{throw new r(`Could not read valid token metadata for ${i}. Refusing to guess token decimals.`)}}function ot(e){let t=F(e.key)?e.key:F(e.poolKey)?e.poolKey:void 0,n=t?.fee??e.fee??Xe,o=(typeof n=="string"&&/^\d+$/.test(n),Number(n));if(!Number.isInteger(o)||o<0||o>Ye)throw new r("Pool fee must be a valid uint24 integer (default 8388608 for Hookr dynamic fee pools).");let i=t?.tickSpacing??e.tickSpacing??Ke,u=(typeof i=="string"&&/^-?\d+$/.test(i),Number(i));if(!Number.isInteger(u)||u<=0||u>Qe)throw new r("Pool tickSpacing must be a positive int24 integer.");let s=t?.hooks??e.hooks??Fe;if(typeof s!="string"||!$(s,{strict:!1}))throw new r("Provide a valid Hookr root contract address for hooks.");let a=l(s);if(t?.currency0!==void 0&&t?.currency1!==void 0||e.currency0!==void 0&&e.currency1!==void 0){let m=T(t?.currency0??e.currency0,"currency0"),h=T(t?.currency1??e.currency1,"currency1");if(m.toLowerCase()===h.toLowerCase())throw new r("Pool currency0 and currency1 must be distinct token addresses.");if(BigInt(m)>=BigInt(h))throw new r("Pool currency0 must sort strictly before currency1 by address.");let O;if(typeof e.zeroForOne=="boolean")O=e.zeroForOne;else if(e.tokenIn!==void 0||e.from!==void 0){let x=T(e.tokenIn??e.from,"tokenIn");if(x.toLowerCase()===m.toLowerCase())O=!0;else if(x.toLowerCase()===h.toLowerCase())O=!1;else throw new r("tokenIn does not match currency0 or currency1 of the pool key.")}else throw new r("Provide zeroForOne (boolean) or tokenIn when specifying a pool key.");return{key:{currency0:m,currency1:h,fee:o,tickSpacing:u,hooks:a},zeroForOne:O}}let g=e.tokenIn??e.from,f=e.tokenOut??e.to;if(g===void 0||f===void 0)throw new r("Provide either key ({ currency0, currency1, fee, tickSpacing, hooks }) with zeroForOne or tokenIn and tokenOut addresses.");let w=T(g,"tokenIn"),b=T(f,"tokenOut");if(w.toLowerCase()===b.toLowerCase())throw new r("Input and output tokens must have distinct addresses.");let p=BigInt(w)<BigInt(b),y=p?w:b,d=p?b:w;if(typeof e.zeroForOne=="boolean"&&e.zeroForOne!==p)throw new r("zeroForOne conflicts with the canonical sorting of tokenIn and tokenOut.");return{key:{currency0:y,currency1:d,fee:o,tickSpacing:u,hooks:a},zeroForOne:p}}function it(e,t,n){let o=Y(t),i=o*o;if(n){let s=j(e.toString(),i.toString(),fe.toString(),"ceil");return BigInt(s)}let u=j(e.toString(),fe.toString(),i.toString(),"ceil");return BigInt(u)}function R(e,t){if(typeof e=="bigint"){if(e<0n)throw new r(`${t} must be a non-negative integer.`);return e}if(typeof e=="number"){if(!Number.isSafeInteger(e)||e<0)throw new r(`${t} must be a non-negative safe integer.`);return BigInt(e)}if(typeof e=="string")return H(e.trim());throw new r(`Provide ${t} as a decimal base-unit string.`)}async function st(e,t){if(t!==void 0)return R(t,"now");if(typeof e.getBlock=="function"){let n=await e.getBlock().catch(()=>{throw new r("Could not read the chain timestamp for Hookr order expiry.")});return BigInt(n.timestamp)}throw new r("Could not read the chain timestamp for Hookr order expiry.")}function Ce(e,t){return!e.changes||e.changes.length===0?"no net ERC-20 transfer deltas":e.changes.map(n=>`${rt(n.amount,n.token.decimals,t.formatAmount)} ${n.token.symbol}`).join(", ")}function xe(e,t,n,o){if(!e||!Array.isArray(e.logs))throw new r("Provide a transaction receipt with a logs array.");for(let i of e.logs){if(!i||typeof i.address!="string"||!$(i.address,{strict:!1})||!Array.isArray(i.topics)||typeof i.data!="string"||i.topics.some(u=>typeof u!="string"||!/^0x[0-9a-fA-F]{64}$/.test(u)))throw new r(`Malformed Hookr ${t} receipt log.`);if(i.address.toLowerCase()===k.toLowerCase()&&i.topics[0]?.toLowerCase()===n.toLowerCase()){if(i.topics.length!==4||!/^0x0{24}/i.test(i.topics[2])||t==="OrderCancelled"&&!/^0x0{24}/i.test(i.topics[3])||!/^0x[0-9a-fA-F]*$/.test(i.data)||i.data.length!==2+o*64)throw new r(`Malformed Hookr ${t} receipt log.`);return{topics:i.topics,data:i.data}}}throw new r(`Could not find Hookr ${t} event in transaction receipt logs.`)}function De(e){if(e.receipt!==void 0){if(!F(e.receipt)||!Array.isArray(e.receipt.logs))throw new r("Provide a transaction receipt with a logs array.");return dt({logs:e.receipt.logs})}if(e.logs!==void 0){if(!Array.isArray(e.logs))throw new r("Provide receipt logs as an array.");return at(e.logs)}}function Le(e){let t=xe(e,"OrderCreated",et,6);try{let n=pe({abi:A,eventName:"OrderCreated",...t,strict:!0});if(ye(we("bool, uint128, uint128, uint128, uint40, address"),[n.args.zeroForOne,n.args.amountIn,n.args.minAmountOut,n.args.bounty,n.args.expiry,n.args.recipient]).toLowerCase()!==t.data.toLowerCase())throw new r("Noncanonical Hookr OrderCreated event data.");return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),poolId:n.args.poolId,zeroForOne:n.args.zeroForOne,amountIn:n.args.amountIn.toString(),minAmountOut:n.args.minAmountOut.toString(),bounty:n.args.bounty.toString(),expiry:n.args.expiry.toString(),recipient:l(n.args.recipient)}}catch{throw new r("Malformed Hookr OrderCreated receipt log.")}}function at(e){return Le({logs:e}).orderId}function dt(e){return Le(e).orderId}function Pt(e){let t=xe(e,"OrderCancelled",tt,2);try{let n=pe({abi:A,eventName:"OrderCancelled",...t,strict:!0});return{orderId:n.args.orderId.toString(),owner:l(n.args.owner),to:l(n.args.to),amountIn:n.args.amountIn.toString(),bounty:n.args.bounty.toString()}}catch{throw new r("Malformed Hookr OrderCancelled receipt log.")}}async function Rt(e){let t=e.clientFor(S),[n,o,i,u]=await Promise.all([t.readContract({address:k,abi:A,functionName:"router"}),t.readContract({address:k,abi:A,functionName:"registry"}),t.readContract({address:k,abi:A,functionName:"poolManager"}),t.readContract({address:k,abi:A,functionName:"lastOrderId"})]).catch(()=>{throw new r("Could not read Hookr deployment details.")}),s=l(n),a=l(o),c=l(i);return{address:k,chainId:S,router:s,registry:a,poolManager:c,lastOrderId:u.toString(),live:s.toLowerCase()===ke.toLowerCase()&&a.toLowerCase()===Me.toLowerCase()&&c.toLowerCase()===Oe.toLowerCase()}}function Pe(e){if(Array.isArray(e)){let[n,o,i,u,s,a,c,g,f,w,b]=e;return{key:Array.isArray(n)?{currency0:n[0],currency1:n[1],fee:Number(n[2]),tickSpacing:Number(n[3]),hooks:n[4]}:n,owner:o,createdAt:i,expiry:u,zeroForOne:s,status:a,recipient:c,amountIn:BigInt(g),minAmountOut:BigInt(f),bounty:BigInt(w),sqrtPriceLimitX96:BigInt(b)}}let t=e;return{key:{currency0:t.key.currency0,currency1:t.key.currency1,fee:Number(t.key.fee),tickSpacing:Number(t.key.tickSpacing),hooks:t.key.hooks},owner:t.owner,createdAt:t.createdAt,expiry:t.expiry,zeroForOne:!!t.zeroForOne,status:Number(t.status),recipient:t.recipient,amountIn:BigInt(t.amountIn),minAmountOut:BigInt(t.minAmountOut),bounty:BigInt(t.bounty),sqrtPriceLimitX96:BigInt(t.sqrtPriceLimitX96)}}async function Re(e,t,n){let o=R(t,"orderId");if(o<=0n)throw new r("Order ID must be a positive integer.");let i=e.clientFor(S),u=n?.order??await i.readContract({address:k,abi:A,functionName:"getOrder",args:[o]}).catch(()=>{throw new r(`Could not read Hookr order #${o}. Order coverage is incomplete.`)}),s=Pe(u),a=Number(s.status);if(s.owner.toLowerCase()===L.toLowerCase()||a===ee)throw new r(`Hookr order #${o} does not exist.`);let c={currency0:l(s.key.currency0),currency1:l(s.key.currency1),fee:Number(s.key.fee),tickSpacing:Number(s.key.tickSpacing),hooks:l(s.key.hooks)},g=s.zeroForOne?c.currency0:c.currency1,f=s.zeroForOne?c.currency1:c.currency0,w=m=>{let h=m.toLowerCase(),O=n?.tokens.get(h);if(O)return O;let x=J(m,S,i);return n?.tokens.set(h,x),x},[b,p]=await Promise.all([w(g),w(f)]),y=!1,d=0n;if(a===M)try{let m=await i.readContract({address:k,abi:A,functionName:"quoteFill",args:[o]});if(typeof m[0]!="boolean"||typeof m[1]!="bigint"||m[1]<0n)throw new r(`Invalid quote for Hookr order #${o}.`);y=m[0],d=m[1]}catch{throw new r(`Could not quote Hookr order #${o}. Fillability and output amount are unknown.`)}return{orderId:o.toString(),poolId:he(c),key:c,owner:l(s.owner),recipient:l(s.recipient),createdAt:BigInt(s.createdAt).toString(),expiry:BigInt(s.expiry).toString(),zeroForOne:s.zeroForOne,status:a,statusLabel:nt(a),amountIn:s.amountIn.toString(),minAmountOut:s.minAmountOut.toString(),bounty:s.bounty.toString(),sqrtPriceLimitX96:s.sqrtPriceLimitX96.toString(),tokenIn:b,tokenOut:p,fillable:y,quotedAmountOut:d.toString()}}function ct(e){return{name:"hookr_create",inputSchema:{type:"object",properties:{key:{type:"object",properties:{currency0:{type:"string"},currency1:{type:"string"},fee:{type:"number"},tickSpacing:{type:"number"},hooks:{type:"string"}}},tokenIn:{type:"string",description:"Input token address on chain 4663."},tokenOut:{type:"string",description:"Output token address on chain 4663."},zeroForOne:{type:"boolean",description:"True when selling currency0 for currency1."},amountIn:{type:"string",description:"Input amount in base units (uint128)."},minAmountOut:{type:"string",description:"Minimum net output amount in base units (uint128)."},tick:{type:"number",description:"Optional limit tick in [-887272, 887272]."},expiry:{type:"string",description:"Order expiry unix timestamp in seconds (uint40)."},deadline:{type:"string",description:"Alias for expiry unix timestamp in seconds."},bounty:{type:"string",description:"Keeper bounty in native ETH wei (uint128)."},recipient:{type:"string",description:"Order output recipient address (must be the signing wallet)."},sqrtPriceLimitX96:{type:"string",description:"Optional sqrtPriceLimitX96 (defaults to 0)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["amountIn"]},async execute(t,n){N(n);let o=l(n),i=Ae(t.chainId),u=e.clientFor(i),s=De(t),{key:a,zeroForOne:c}=ot(t),g=c?a.currency0:a.currency1,f=c?a.currency1:a.currency0,[w,b]=await Promise.all([J(g,i,u,t.tokenInMeta),J(f,i,u,t.tokenOutMeta)]),p=t.recipient??o;if(typeof p!="string"||!$(p,{strict:!1}))throw new r("Provide a valid recipient address for the Hookr limit order.");let y=l(p);if(Se(y,a.hooks),y!==o)throw new r("Hookr recipient must be the signing wallet.");if(typeof t.amountIn!="string")throw new r("Provide amountIn as an integer string in base units.");let d=H(t.amountIn);if(d<=0n||d>Ve)throw new r("amountIn must be between 1 and int128.max base units.");if(t.tick!==void 0){let P=Number(t.tick);Y(P)}let m;if(t.minAmountOut!==void 0){if(typeof t.minAmountOut!="string")throw new r("Provide minAmountOut as an integer string in base units.");m=H(t.minAmountOut)}else if(t.tick!==void 0)m=it(d,Number(t.tick),c);else throw new r("Provide minAmountOut in base units (or tick to derive minAmountOut).");if(m<=0n||m>me)throw new r("minAmountOut must be between 1 and uint128.max base units.");let h=t.sqrtPriceLimitX96!==void 0?R(t.sqrtPriceLimitX96,"sqrtPriceLimitX96"):0n;if(h>We)throw new r("sqrtPriceLimitX96 exceeds uint160 bounds.");let O=await st(u,t.now),x=t.expiry??t.deadline,I;if(x!==void 0)I=R(x,"expiry");else if(t.lifetime!==void 0||t.ttlSeconds!==void 0){let P=R(t.lifetime??t.ttlSeconds,"lifetime");I=O+P}else I=O+Ue;if(I<O+ce)throw new r(`Order expiry (${I}) is expired or below the minimum lifetime of ${ce} seconds from block timestamp ${O}.`);if(I>O+ue||I>Ge)throw new r(`Order expiry (${I}) exceeds the maximum lifetime of ${ue} seconds (365 days).`);let z=await u.readContract({address:k,abi:A,functionName:"bountyBounds",args:[a,c,d,m]}).catch(()=>{throw new r("Could not read Hookr bounty bounds.")}),_=BigInt(z[0]),q=BigInt(z[1]),X=BigInt(z[2]);if(t.bounty!==void 0&&typeof t.bounty!="string")throw new r("Provide bounty as an integer string in base units.");let C=t.bounty!==void 0?H(t.bounty):q,K=_>0n?_:q;if(C<_||K>0n&&C<K)throw new r(`Order keeper bounty (${C} wei) is underbounty: must be at least ${K} wei (default keeper bounty floor).`);if(C>X||C>me)throw new r(`Order keeper bounty (${C} wei) exceeds the maximum allowed bounty of ${X} wei.`);let te=g.toLowerCase()===L.toLowerCase(),v=[];if(!te){let P;try{let U=await u.readContract({address:g,abi:Z,functionName:"allowance",args:[o,k]});if(typeof U!="bigint"||U<0n)throw new r("Invalid token allowance.");P=U}catch{throw new r(`Could not read token allowance for ${g}. No approval was prepared.`)}P<d&&v.push(e.approval(g,k,d.toString(),i))}let He=te?d+C:C,Te=ge({abi:A,functionName:"createOrder",args:[{key:a,zeroForOne:c,amountIn:d,minAmountOut:m,sqrtPriceLimitX96:h,recipient:y,expiry:Number(I),bounty:C}]}),ne=e.formatAmount(d.toString(),w.decimals),re=e.formatAmount(m.toString(),b.decimals),oe=e.formatAmount(C.toString(),18),$e=e.unsignedTx({to:k,data:Te,value:He.toString(),chainId:i,description:`Create Hookr limit order on ${k}: sell ${ne} ${w.symbol} (${w.address}) for at least ${re} ${b.symbol} (${b.address}) with ${oe} ETH keeper bounty (fee=${a.fee}, tickSpacing=${a.tickSpacing}, expiry=${I}).`});v.push($e);let ie=await e.preview(v,o),Ee=Ce(ie,e),_e=he(a);return{txs:v,summary:`Hookr limit order prepared: sell ${ne} ${w.symbol} for at least ${re} ${b.symbol} (bounty ${oe} ETH, expiry ${I}; preview deltas: ${Ee}).`,preview:ie,poolId:_e,key:a,zeroForOne:c,amountIn:d.toString(),minAmountOut:m.toString(),bounty:C.toString(),bountyBounds:{minBounty:_.toString(),defaultBounty:q.toString(),maxBounty:X.toString()},expiry:I.toString(),recipient:y,sqrtPriceLimitX96:h.toString(),tokenIn:w,tokenOut:b,...s!==void 0?{orderId:s}:{}}}}}function ut(e){return{name:"hookr_cancel",inputSchema:{type:"object",properties:{orderId:{type:"string",description:"Hookr order ID to cancel (uint256 decimal string)."},to:{type:"string",description:"Recipient address for the refunded principal and bounty (must be the signing wallet)."},chainId:{type:"number",description:"Must be 4663 (Robinhood Chain)."}},required:["orderId"]},async execute(t,n){N(n);let o=l(n),i=Ae(t.chainId),u=De(t),s=t.orderId??t.id??u;if(s===void 0)throw new r("Provide orderId to cancel a Hookr limit order.");let a=R(s,"orderId");if(a<=0n)throw new r("orderId must be a positive integer.");let c=await Re(e,a);if(c.owner.toLowerCase()!==o.toLowerCase())throw new r(`Unauthorized cancellation: only the order owner (${c.owner}) can cancel Hookr order #${a} (caller is ${o}).`);if(c.status!==M)throw new r(`Hookr order #${a} is not open (current status: ${c.statusLabel}).`);let g=t.to??o;if(typeof g!="string"||!$(g,{strict:!1}))throw new r("Provide a valid refund recipient address for cancel.");let f=l(g);if(Se(f,c.key.hooks),f!==o)throw new r("Hookr refund recipient must be the signing wallet.");let w=ge({abi:A,functionName:"cancel",args:[a,f]}),b=e.formatAmount(c.amountIn,c.tokenIn.decimals),p=e.formatAmount(c.bounty,18),y=e.unsignedTx({to:k,data:w,value:"0",chainId:i,description:`Cancel Hookr limit order #${a} on ${k} and refund ${b} ${c.tokenIn.symbol} plus ${p} ETH bounty to ${f}.`}),d=await e.preview([y],o),m=Ce(d,e);return{txs:[y],summary:`Cancel Hookr limit order #${a}: refund ${b} ${c.tokenIn.symbol} and ${p} ETH bounty to ${f} (preview deltas: ${m}).`,preview:d,orderId:a.toString(),to:f,refundedAmountIn:c.amountIn,refundedBounty:c.bounty,tokenIn:c.tokenIn,tokenOut:c.tokenOut}}}}function lt(e){let t=performance.now()+je;return new Proxy(e,{get(n,o,i){return o!=="readContract"?Reflect.get(n,o,i):async(...u)=>{let s=t-performance.now(),a=()=>new r("Hookr scan deadline exceeded. Order coverage is incomplete; retry later.");if(s<=0)throw a();let c;try{return await Promise.race([n.readContract(...u),new Promise((g,f)=>{c=setTimeout(()=>f(a()),s)})])}finally{c!==void 0&&clearTimeout(c)}}}})}function mt(e){return async t=>{N(t);let n=l(t),o=lt(e.clientFor(S)),i={...e,clientFor:()=>o},u=await o.readContract({address:k,abi:A,functionName:"lastOrderId"}).catch(()=>{throw new r("Could not read the last Hookr order ID. Order coverage is incomplete.")});if(typeof u!="bigint"||u<0n)throw new r("Could not read a valid last Hookr order ID. Order coverage is incomplete.");let s=u,a=s>le?s-le+1n:1n;if(s<=0n)return[];let c=[],g=new Map;for(let f=a;f<=s;f+=Q){let w=Array.from({length:Number(s-f+1n<Q?s-f+1n:Q)},(p,y)=>f+BigInt(y)),b=await Promise.all(w.map(async p=>{let y=await o.readContract({address:k,abi:A,functionName:"getOrder",args:[p]}).catch(()=>{throw new r(`Could not read Hookr order #${p}. Order coverage is incomplete.`)}),d=Pe(y);if(d.owner.toLowerCase()===L||Number(d.status)===ee)throw new r(`Hookr order #${p} does not exist. Order coverage is incomplete.`);return{id:p,order:d}}));for(let{id:p,order:y}of b){if(y.owner.toLowerCase()!==n.toLowerCase()||Number(y.status)!==M)continue;let d=await Re(i,p,{order:y,tokens:g}),m=[{token:d.tokenIn,amount:d.amountIn}];BigInt(d.bounty)>0n&&m.push({token:{address:B,symbol:"ETH",decimals:18,chainId:S},amount:d.bounty});let h=e.formatAmount(d.amountIn,d.tokenIn.decimals),O=e.formatAmount(d.minAmountOut,d.tokenOut.decimals),x=e.formatAmount(d.bounty,18),I=e.formatAmount(d.quotedAmountOut,d.tokenOut.decimals);c.push({module:"hookr",id:d.orderId,chainId:S,assets:m,description:`Hookr open limit order #${d.orderId}: sell ${h} ${d.tokenIn.symbol} (${d.tokenIn.address}) for at least ${O} ${d.tokenOut.symbol} (${d.tokenOut.address}), bounty ${x} ETH, expiry ${d.expiry}, fillable=${d.fillable} (quoted output ${I} ${d.tokenOut.symbol}).`})}}return a>1n&&c.push({module:"hookr",id:"coverage",chainId:S,assets:[],description:`Hookr order coverage is incomplete: scanned IDs ${a}-${s}. Older orders require an explicit order ID.`}),c}}function Ht(e){return ve({abi:A,data:e})}var E=e=>{let t=[ct(e),ut(e)],n=mt(e);return{tools:t,positions:n}},Tt=E,$t=E,Et=E,_t=e=>{let t=E(e);return{name:"hookr",tools:t.tools,...t.positions?{positions:t.positions}:{}}},vt=E;export{k as a,Fe as b,ke as c,At as d,Me as e,ze as f,Oe as g,ht as h,qe as i,Xe as j,Ke as k,ce as l,Ue as m,ue as n,St as o,Ct as p,xt as q,Dt as r,le as s,je as t,ee as u,M as v,Ze as w,Je as x,et as y,tt as z,A,rt as B,Lt as C,he as D,Le as E,at as F,dt as G,Pt as H,Rt as I,Re as J,ct as K,ut as L,mt as M,Ht as N,E as O,Tt as P,$t as Q,Et as R,_t as S,vt as T};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as ae,o as F}from"./XEN45QST.js";import{a as h,i as re,j as K}from"./5BP72XOA.js";import{a as O}from"./Z3FZWNAJ.js";import{randomBytes as ue,randomUUID as le}from"node:crypto";import{isDeepStrictEqual as se}from"node:util";import{decodeFunctionData as oe,encodeAbiParameters as Z,erc20Abi as J,getAddress as pe,isAddress as me,keccak256 as ee,parseAbi as te,parseAbiParameters as ne,toEventSelector as fe,zeroAddress as U}from"viem";var ie=re[h].meridian,L=ie.PredictionMarketEscrow.address,H=ie.SecondaryMarketEscrow.address,C={address:ie.CollateralToken_USDe.address,chainId:h,symbol:"USDe",decimals:18},ye="wss://relayer.predict.meridian.xyz/auction",ge=ne("(address conditionResolver,bytes conditionId,uint8 predictedOutcome)[]"),he=ne("bytes32,uint256,uint256,address,address,address,bytes"),be=ne("address,address,address,address,uint256,uint256"),j=te(["function getNonce(address) view returns (uint256)","function isNonceUsed(address,uint256) view returns (bool)"]),we=te(["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)"]),ke=te(["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)"]),Ie=fe("Transfer(address,address,uint256)"),Be=[{name:"predictionHash",type:"bytes32"},{name:"signer",type:"address"},{name:"collateral",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],Se=[{name:"tradeHash",type:"bytes32"},{name:"signer",type:"address"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}];function i(e){throw new O(e)}function R(e){return(!e||typeof e!="object"||Array.isArray(e))&&i("Meridian returned an invalid exchange object."),e}function S(e,n,d=!1){return d&&typeof e=="number"&&Number.isSafeInteger(e)&&e>=0&&(e=String(e)),(typeof e!="string"||!/^\d+$/.test(e)||BigInt(e)>=1n<<256n)&&i(`Provide ${n} as a decimal base-unit integer string.`),e}function x(e){return(typeof e!="string"||!me(e,{strict:!1})||e.toLowerCase()===U)&&i("Provide a nonzero token, resolver or wallet address."),pe(e)}function V(e,n){return(typeof e!="string"||!/^0x(?:[0-9a-fA-F]{2})+$/.test(e)||n!==void 0&&e.length!==2+n*2)&&i("Meridian returned invalid hexadecimal data."),e}function q(e){return(typeof e!="string"||e.length===0||e.length>256)&&i("Meridian returned an invalid exchange identifier."),e}function k(e,n){return e?.toLowerCase()===n.toLowerCase()}function G(){return BigInt(Math.floor(Date.now()/1e3))}function Me(e,n){let d=e==="buy"?["picks","stake","minCounterpartyCollateral","usdgAmountIn","slippageBps","continuation","signature"]:["token","amount","minPrice","slippageBps","continuation","signature"];Object.keys(n).some(I=>!d.includes(I))&&i("Unsupported Meridian arguments; use the tool input schema."),n.slippageBps!==void 0&&(typeof n.slippageBps!="number"||!Number.isInteger(n.slippageBps)||n.slippageBps<0||n.slippageBps>=1e4)&&i("Slippage must be an integer from 0 to 9999 basis points.");let c=n.slippageBps;if(e==="sell"){let I=S(n.amount,"the position amount");BigInt(I)===0n&&i("The position amount must be positive.");let b=x(n.token);(k(b,C.address)||k(b,K))&&i("Choose a Meridian position token to sell.");let $;if(n.minPrice!==void 0){let A=S(n.minPrice,"the minimum sale price");BigInt(A)<=1n&&i("The minimum sale price must be greater than 1 base unit."),$=c===void 0?A:F(A,c),BigInt($)<=1n&&i("The minimum sale price after slippage must be greater than 1 base unit.")}else{let A=BigInt(I)/100n>10n**18n?BigInt(I)/100n:10n**18n;$=c===void 0?A.toString():F(A.toString(),c)}return{side:e,token:b,amount:I,minPrice:$,...c===void 0?{}:{slippageBps:c}}}(!Array.isArray(n.picks)||n.picks.length<1||n.picks.length>10)&&i("Provide between one and ten Meridian picks.");let f=n.picks.map(I=>{let b=R(I);return(Object.keys(b).some($=>!["conditionResolver","conditionId","predictedOutcome"].includes($))||b.predictedOutcome!==0&&b.predictedOutcome!==1)&&i("Each pick needs a resolver, condition ID and outcome 0 or 1."),{conditionResolver:x(b.conditionResolver),conditionId:V(b.conditionId),predictedOutcome:b.predictedOutcome}}).sort((I,b)=>{let $=`${I.conditionResolver.toLowerCase()}:${I.conditionId.toLowerCase()}:${I.predictedOutcome}`,A=`${b.conditionResolver.toLowerCase()}:${b.conditionId.toLowerCase()}:${b.predictedOutcome}`;return $<A?-1:$>A?1:0}),m=f.map(I=>`${I.conditionResolver.toLowerCase()}:${I.conditionId.toLowerCase()}`);new Set(m).size!==f.length&&i("Do not repeat a condition in the same prediction.");let B=S(n.stake,"the USDe stake");BigInt(B)<10n**18n&&i("Meridian requires a stake of at least 1 USDe.");let M=n.usdgAmountIn===void 0?void 0:S(n.usdgAmountIn,"the USDG swap amount");M!==void 0&&BigInt(M)===0n&&i("The USDG swap amount must be positive.");let _=n.minCounterpartyCollateral!==void 0?S(n.minCounterpartyCollateral,"the minimum counterparty collateral"):F(B,c??ae);return BigInt(_)<=1n&&i("The minimum counterparty collateral must be greater than 1 base unit."),{side:e,picks:f,stake:B,minCounterpartyCollateral:_,...M===void 0?{}:{usdgAmountIn:M},...c===void 0?{}:{slippageBps:c}}}var X=class{constructor(n,d){this.id=n;this.prefix=d;this.socket=new globalThis.WebSocket(ye),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 f=R(JSON.parse(c.data));if(f.type==="pong")return;let m=q(f.type),B=R(f.payload);if((m==="error"||m===`${d}.error`||m===`${d}.rejected`||m===`${d}.failed`||m===`${d}.expired`)&&i("Meridian rejected or failed the exchange. Start a fresh auction."),m===`${d}.ack`){(B.id!==n||this.auctionId!==void 0)&&i("Meridian acknowledged a different exchange."),this.auctionId=q(B.auctionId);return}if((!m.startsWith(`${d}.`)||B.auctionId!==this.auctionId||!this.auctionId)&&i("Meridian returned a message for a different exchange."),(m===`${d}.pending`||m===`${d}.filled`)&&!this.accepting&&i("Meridian returned settlement before acceptance."),m===`${d}.pending`)return;this.queue.length>=16&&i("Meridian returned too many exchange messages."),this.queue.push({type:m,payload:B}),this.notify?.()}catch{this.stop("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(n){this.error??=new O(n),this.notify?.(),this.socket.readyState<2&&this.socket.close()}async wait(n,d=3e4){return new Promise((c,f)=>{let m=setTimeout(()=>this.stop("Meridian exchange timed out. Start a fresh auction."),d),B=()=>{try{if(this.check(),n===void 0?!this.opened:!this.queue.length)return;let M=n===void 0?void 0:this.queue.shift();M&&M.type!==`${this.prefix}.${n}`&&i("Meridian returned an unexpected exchange stage."),clearTimeout(m),this.notify=void 0,c(M?.payload??{})}catch(M){clearTimeout(m),this.notify=void 0,f(M)}};this.notify=B,B()})}send(n,d){this.check(),this.socket.readyState!==1&&i("Meridian exchange socket is not open."),n==="accept"&&(this.accepting=!0),this.socket.send(JSON.stringify({...n==="start"?{id:this.id}:{},type:`${this.prefix}.${n}`,payload:d}))}};function Y(e){return ee(Z(ge,[e]))}function $e(e,n,d){return ee(Z(he,[Y(e.picks),BigInt(e.stake),BigInt(d.counterpartyCollateral),n,d.counterparty,U,"0x"]))}function Ae(e,n,d,c){return ee(Z(be,[e.token,C.address,n,d,BigInt(e.amount),BigInt(c)]))}function Q(e,n){let{input:d,wallet:c,nonce:f,deadline:m}=e,B={name:d.side==="buy"?"PredictionMarketEscrow":"SecondaryMarketEscrow",version:"1",chainId:h,verifyingContract:e.continuation.escrowContract};return(!f||!m)&&i("Meridian exchange is missing its signing terms."),d.side==="buy"?(n||i("Meridian has not returned a winning bid."),{domain:B,primaryType:"MintApproval",types:{MintApproval:Be},message:{predictionHash:$e(d,c,n),signer:c,collateral:d.stake,nonce:f,deadline:m}}):{domain:B,primaryType:"TradeApproval",types:{TradeApproval:Se},message:{tradeHash:Ae(d,c,n?n.buyer:U,n?n.price:"0"),signer:c,nonce:f,deadline:m}}}function de(e){let n=[BigInt(e.deadline)],d=e.continuation;if(d.stage==="primary_accept"||d.stage==="secondary_accept"){n.push(BigInt(d.acceptDeadline));let c=d.winningBid;d.stage==="primary_accept"&&n.push(BigInt(c.counterpartyDeadline)),c.buyerDeadline!==void 0&&n.push(BigInt(S(c.buyerDeadline,"the buyer deadline",!0)))}return n.reduce((c,f)=>c<f?c:f)}function z(e){e.channel?.check(),e.deadline&&G()>=de(e)&&i("Meridian exchange expired. Start a fresh auction.")}var Ee=e=>{let n=new Map;function d(t){clearTimeout(t.timer),n.delete(t.continuation.requestId),t.channel?.stop("Meridian exchange is closed or expired. Start a fresh auction.")}function c(t,a){clearTimeout(t.timer),t.timer=setTimeout(()=>d(t),a),t.timer.unref?.()}function f(t){let{wallet:a,chainId:s,escrowContract:p,requestId:u}=t.continuation;return{wallet:a,chainId:s,escrowContract:p,requestId:u}}async function m(t){let{input:a,wallet:s}=t,p=e.clientFor(h),u=a.side==="buy"?C.address:a.token,r=a.side==="buy"?a.stake:a.amount,[y,w]=await Promise.all([p.readContract({address:u,abi:J,functionName:"balanceOf",args:[s]}),p.readContract({address:u,abi:J,functionName:"allowance",args:[s,t.continuation.escrowContract]})]);if(a.side==="sell"&&await p.readContract({address:u,abi:J,functionName:"decimals"})!==18&&i("Meridian position tokens must have 18 decimals."),y>=BigInt(r)&&w>=BigInt(r))return;(t.continuation.stage==="primary_accept"||t.continuation.stage==="secondary_accept")&&i("Meridian prerequisites changed during the auction. Start a fresh auction after funding and approval.");let l,D;if(y<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 g=await e.quoteSwap({from:K,to:C.address,amountIn:a.usdgAmountIn,...a.slippageBps===void 0?{}:{slippageBps:a.slippageBps}},s);(G()>=BigInt(S(g.expiresAt,"the swap expiry"))||BigInt(S(g.minAmountOut,"the swap minimum"))+y<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 e.buildSwap(g.quoteId,s);(!("txs"in o)||!o.txs.length)&&i("The swap coordinator did not return prerequisite transactions."),l=o.txs,D=`${o.summary} Minimum USDe output: ${g.minAmountOut} base units (18 decimals).`}else l=[e.approval(u,t.continuation.escrowContract,r,h)],D=`Approve exactly ${r} base units (18 decimals) of ${u} for ${t.continuation.escrowContract} on chain ${h}.`;l.some(g=>g.chainId!==h)&&i("Meridian prerequisite transactions must use chain 4663.");let v=await e.preview(l,s),T=v.changes.map(g=>{let o=g.amount.startsWith("-");return`${o?"-":"+"}${e.formatAmount(o?g.amount.slice(1):g.amount,g.token.decimals)} ${g.token.symbol} (${g.token.address}, chain ${g.token.chainId}, ${g.token.decimals} decimals)`}).join("; ");return t.channel?.stop("Meridian prerequisites must be mined before the auction."),t.channel=void 0,t.deadline=void 0,t.nonce=void 0,t.continuation={...f(t),stage:"prerequisites"},{steps:l.map(g=>({kind:"tx",tx:g})),continuation:structuredClone(t.continuation),summary:`${D} ${v.summary} ${T}. Mine these prerequisites before continuing; no RFQ has started.`}}function B(t){let a=t.continuation;a.stage==="prerequisites"&&i("Meridian prerequisites need to finish before signing."),z(t),c(t,Number(de(t)-G())*1e3);let s=t.input,p=s.side==="buy"?`Stake ${s.stake} base units of USDe (${C.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 (${C.address}, 18 decimals).`;return{steps:[{kind:"typedData",request:structuredClone(a.request)}],continuation:structuredClone(a),summary:`${p} on chain ${h}. Approval was checked on chain. ${u} Sign locally for domain ${a.request.domain.name}, version 1, escrow ${a.escrowContract}, signature deadline ${t.deadline}${"acceptDeadline"in a?`, acceptance deadline ${a.acceptDeadline}`:""}. External relayer settlement is pending; a signature is not a fill.`}}async function M(t){let a=await t.channel.wait("result"),s=R(a.winningBid),p=q(a.auctionId);s.auctionId!==p&&i("Meridian winning bid belongs to another auction.");let u=S(a.acceptDeadline,"the acceptance deadline",!0);if(t.input.side==="buy"){let r={auctionId:p,counterparty:q(s.counterparty),counterpartyCollateral:S(s.counterpartyCollateral,"the counterparty collateral"),counterpartyNonce:S(s.counterpartyNonce,"the counterparty nonce",!0),counterpartyDeadline:S(s.counterpartyDeadline,"the counterparty deadline",!0),receivedAt:q(s.receivedAt)};x(r.counterparty),(!Number.isFinite(Date.parse(r.receivedAt))||BigInt(r.counterpartyCollateral)<=1n||BigInt(r.counterpartyCollateral)<BigInt(t.input.minCounterpartyCollateral))&&i("Meridian winning bid counterparty collateral is below the caller minimum."),t.continuation={...f(t),stage:"primary_accept",auctionId:p,winningBid:r,acceptDeadline:u,request:Q(t,r)}}else{let r={auctionId:p,buyer:q(s.buyer),price:S(s.price,"the sale price"),...s.buyerDeadline!==void 0?{buyerDeadline:S(s.buyerDeadline,"the buyer deadline",!0)}:{},...s.buyerNonce!==void 0?{buyerNonce:S(s.buyerNonce,"the buyer nonce",!0)}:{},...s.receivedAt!==void 0?{receivedAt:q(s.receivedAt)}:{}};x(r.buyer),(BigInt(r.price)<=1n||BigInt(r.price)<BigInt(t.input.minPrice))&&i("Meridian winning bid sale price is below the caller minimum."),t.continuation={...f(t),stage:"secondary_accept",auctionId:p,winningBid:r,acceptDeadline:u,request:Q(t,r)}}return B(t)}async function _(t,a){let s=t.continuation;s.stage!=="primary_accept"&&s.stage!=="secondary_accept"&&i("Meridian exchange is not ready for acceptance."),z(t),t.channel.send("accept",{auctionId:s.auctionId,[t.input.side==="buy"?"predictorSignature":"sellerSignature"]:a}),c(t,15e4);let p=await t.channel.wait("filled",12e4),u=V(p.transactionHash,32),r=e.clientFor(h),[y,w]=await Promise.all([r.waitForTransactionReceipt({hash:u,timeout:12e4}),r.getTransaction({hash:u})]);(y.status!=="success"||!k(y.transactionHash,u)||!k(w.hash,u)||!k(y.to,s.escrowContract)||!k(w.to,s.escrowContract)||w.chainId!==h)&&i("Meridian fill has no matching successful receipt on chain 4663.");let{input:l,wallet:D}=t;if(l.side==="buy"&&s.stage==="primary_accept"){let o=oe({abi:we,data:w.input}).args[0];(!k(Y([...o.picks]),Y(l.picks))||o.predictorCollateral!==BigInt(l.stake)||o.counterpartyCollateral!==BigInt(s.winningBid.counterpartyCollateral)||!k(o.predictor,D)||!k(o.counterparty,s.winningBid.counterparty)||o.predictorNonce!==BigInt(t.nonce)||o.counterpartyNonce!==BigInt(s.winningBid.counterpartyNonce)||o.predictorDeadline!==BigInt(t.deadline)||o.counterpartyDeadline!==BigInt(s.winningBid.counterpartyDeadline)||!k(o.predictorSponsor,U)||o.predictorSponsorData!=="0x"||o.predictorSignature!==a)&&i("Meridian mint receipt does not match the accepted prediction.")}else if(l.side==="sell"&&s.stage==="secondary_accept"){let o=oe({abi:ke,data:w.input}).args[0];(!k(o.token,l.token)||!k(o.collateral,C.address)||!k(o.seller,D)||!k(o.buyer,s.winningBid.buyer)||o.tokenAmount!==BigInt(l.amount)||o.price!==BigInt(s.winningBid.price)||o.sellerNonce!==BigInt(t.nonce)||o.sellerDeadline!==BigInt(t.deadline)||o.sellerSignature!==a)&&i("Meridian sale receipt does not match the accepted trade.")}let v=new Map,T=new Map;for(let o of y.logs){if(o.topics[0]!==Ie||o.topics.length!==3)continue;(!/^0x[0-9a-fA-F]{64}$/.test(o.data)||!o.topics.slice(1).every(ce=>/^0x0{24}[0-9a-fA-F]{40}$/.test(ce)))&&i("Meridian receipt has malformed transfer logs.");let E=`0x${o.topics[1].slice(-40)}`,N=`0x${o.topics[2].slice(-40)}`,P=o.address.toLowerCase(),W=BigInt(o.data);v.set(P,(v.get(P)??0n)+(k(N,D)?W:0n)-(k(E,D)?W:0n)),k(E,U)&&k(N,D)&&T.set(P,(T.get(P)??0n)+W)}let g;if(l.side==="buy"&&s.stage==="primary_accept"){let o=BigInt(l.stake)+BigInt(s.winningBid.counterpartyCollateral),E=[...T].filter(([N,P])=>!k(N,C.address)&&P===o&&v.get(N)===o);(E.length!==1||v.get(C.address.toLowerCase())!==-BigInt(l.stake))&&i("Meridian mint receipt does not prove the expected collateral and position delta."),g=`${o} base units received in position ${E[0][0]}`}else l.side==="sell"&&s.stage==="secondary_accept"?((v.get(l.token.toLowerCase())!==-BigInt(l.amount)||v.get(C.address.toLowerCase())!==BigInt(s.winningBid.price))&&i("Meridian sale receipt does not prove the expected collateral and position delta."),g=`${l.amount} base units sold from position ${l.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 ${l.side} filled by the external relayer. Successful receipt and transfer deltas verified on chain ${h}: ${g} (18 decimals); collateral USDe ${C.address} (18 decimals).`}}async function I(t,a,s){let p=x(s),u=Me(t,a),r;if(a.continuation!==void 0){let y=R(a.continuation),w=n.get(q(y.requestId));w||i("Meridian exchange is lost or expired. Start a fresh auction."),(!k(w.wallet,p)||!se(w.input,u)||!se(w.continuation,y))&&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."),n.size>=1e3&&i("Too many active Meridian exchanges. Please try again later.");let y=le(),w=setTimeout(()=>{let l=n.get(y);l&&d(l)},9e5);w.unref?.(),r={input:u,wallet:p,continuation:{stage:"prerequisites",wallet:p,chainId:h,escrowContract:t==="buy"?L:H,requestId:y},busy:!1,timer:w},n.set(y,r)}r.busy=!0;try{z(r),await e.clientFor(h).getChainId()!==h&&i("Meridian requires an RPC on chain 4663.");let y=r.continuation.stage;y==="prerequisites"&&a.signature!==void 0&&i("Do not sign before Meridian prerequisites have mined.");let w=await m(r);if(w)return w;if(y==="prerequisites")return r.nonce=t==="buy"?(await e.clientFor(h).readContract({address:L,abi:j,functionName:"getNonce",args:[p]})).toString():BigInt(`0x${ue(16).toString("hex")}`).toString(),r.deadline=(G()+300n).toString(),t==="sell"&&await e.clientFor(h).readContract({address:H,abi:j,functionName:"isNonceUsed",args:[p,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),r.channel=new X(r.continuation.requestId,t==="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:p,predictorNonce:r.nonce,predictorDeadline:r.deadline,chainId:h,escrowContract:L,mode:"blind"}),await M(r)):(r.continuation={...f(r),stage:"secondary_start",request:Q(r)},B(r));let l=V(a.signature);if(t==="sell"&&await e.clientFor(h).readContract({address:H,abi:j,functionName:"isNonceUsed",args:[p,BigInt(r.nonce)]})&&i("Meridian seller nonce is already used. Start a fresh auction."),t==="buy"&&(await e.clientFor(h).readContract({address:L,abi:j,functionName:"getNonce",args:[p]})).toString()!==r.nonce&&i("Meridian predictor nonce changed. Start a fresh auction."),z(r),y==="secondary_start"&&u.side==="sell")return r.channel.send("start",{id:r.continuation.requestId,token:u.token,collateral:C.address,tokenAmount:u.amount,seller:p,sellerNonce:r.nonce,sellerDeadline:r.deadline,chainId:h,escrowContract:H,mode:"blind",sellerSignature:l}),await M(r);let D=await _(r,l);return d(r),D}catch(y){throw d(r),new O(e.plainError(y))}finally{r.busy=!1}}let b={type:"string",pattern:"^\\d+$"},$={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},A={continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}};return{tools:[{name:"meridian_buy",inputSchema:{type:"object",additionalProperties:!1,required:["picks","stake"],properties:{...A,stake:{...b,description:"USDe stake in base units, 18 decimals, chain 4663."},minCounterpartyCollateral:{...b,description:"Optional caller minimum counterparty collateral in USDe base units, 18 decimals."},usdgAmountIn:{...b,description:"Optional exact USDG swap input in base units, 6 decimals, if USDe balance is insufficient."},slippageBps:{type:"integer",minimum:0,maximum:9999},picks:{type:"array",minItems:1,maxItems:10,items:{type:"object",additionalProperties:!1,required:["conditionResolver","conditionId","predictedOutcome"],properties:{conditionResolver:$,conditionId:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"},predictedOutcome:{type:"integer",enum:[0,1]}}}}}},execute:(t,a)=>I("buy",t,a)},{name:"meridian_sell",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount"],properties:{...A,token:{...$,description:"Position token address on chain 4663."},amount:{...b,description:"Position amount in base units, 18 decimals."},minPrice:{...b,description:"Optional caller minimum sale price in USDe base units, 18 decimals."},slippageBps:{type:"integer",minimum:0,maximum:9999}}},execute:(t,a)=>I("sell",t,a)}]}};export{Ee as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as E,o as O}from"./XEN45QST.js";import{c as Q}from"./TU3KHOZK.js";import{b as K}from"./UB5U6SI2.js";import{a as p,i as G}from"./5BP72XOA.js";import{a as _}from"./XAB4OIE3.js";import{a as J}from"./7I6TXFXR.js";import{a as r}from"./Z3FZWNAJ.js";import{decodeFunctionResult as ie,encodeAbiParameters as P,encodeFunctionData as v,erc20Abi as H,isAddress as te,parseAbi as oe,parseAbiParameters as L,toHex as F,zeroAddress as $}from"viem";var h=G[p].clanker,U=oe(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),k=oe(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),C={address:h.paired_weth.address,symbol:"WETH",decimals:18,chainId:p},ae="https://www.clanker.world/api/tokens",X={type:"string",pattern:"^\\d+$"},Y={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},Z={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function S(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function b(e){if(typeof e!="string"||!te(e,{strict:!1})||e.toLowerCase()===$)throw new r("Provide a valid nonzero address.");return e}function ee(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r(`Provide an explicit bytes32 ${t}.`);return e}function A(e,t,i=!1){if(e===void 0&&!i)return"";if(typeof e!="string"||i&&!e.trim())throw new r(`Provide ${t} as text.`);return e}function R(e,t=256){let i=J(e);if(i>=1n<<BigInt(t))throw new r(`Amount exceeds the uint${t} range.`);return i}function q(e){if(typeof e!="bigint"||e<0n||e>=1n<<256n)throw new r("The contract returned an invalid amount.");return e.toString()}function V(e,t){let i=Object.keys(e).find(m=>!t.includes(m));if(i)throw new r(`Unsupported Clanker input: ${i}.`)}function ne(e,t){return t.changes.map(({token:i,amount:m})=>{let w=m.startsWith("-");return`${w?"-":"+"}${e.formatAmount(w?m.slice(1):m,i.decimals)} ${i.symbol} (${i.address}, chain ${i.chainId})`}).join("; ")}function de(e){return S(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||typeof e.cursor=="string"||e.cursor===void 0&&e.data.length===0&&e.total===0&&e.tokensDeployed===0)&&e.data.every(t=>S(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(i=>typeof t[i]=="string"&&te(t[i],{strict:!1})))}async function ce(e,t={}){V(t,["q","limit","cursor","deployer"]);let i=t.limit??10;if(typeof i!="number"||!Number.isInteger(i)||i<1||i>20)throw new r("Choose an indexer limit from 1 to 20.");let m=new URL(ae);m.searchParams.set("chainId",String(p)),m.searchParams.set("limit",String(i)),t.q!==void 0&&m.searchParams.set("q",A(t.q,"search")),t.cursor!==void 0&&m.searchParams.set("cursor",A(t.cursor,"cursor",!0)),t.deployer!==void 0&&m.searchParams.set("msgSender",b(t.deployer));let w=await Q(e.http,m.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},de);return{tokens:w.data.filter(x=>x.chain_id===p&&x.factory_address.toLowerCase()===h.factory.address.toLowerCase()),total:w.total,cursor:w.cursor||null,tokensDeployed:w.tokensDeployed}}var ue=e=>{let t=()=>e.clientFor(p),i=async n=>{try{return await n()}catch(s){throw new r(e.plainError(s))}},m=(n,s,l,d="0")=>e.unsignedTx({to:n,data:s,value:d,chainId:p,description:l}),w=async(n,s)=>q(await t().readContract({address:h.fee_locker.address,abi:k,functionName:"availableFees",args:[n,s]})),x=async n=>{if(n.toLowerCase()===C.address.toLowerCase())return C;let[s,l]=await Promise.all([t().readContract({address:n,abi:H,functionName:"symbol"}),t().readContract({address:n,abi:H,functionName:"decimals"})]);if(typeof s!="string"||!s.trim()||!Number.isInteger(l)||l<0||l>255)throw new r("The contract returned invalid token metadata.");return{address:n,chainId:p,symbol:s,decimals:l}},j=n=>ce(e,n),se=async(n,s)=>{if(V(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps"]),n.vanity!==void 0&&n.vanity!==!1)throw new r("Clanker launches use vanity false and an explicit salt.");let l=A(n.name,"token name",!0),d=A(n.symbol,"token symbol",!0),g=ee(n.salt,"salt"),f=R(n.initialBuy??"0"),c=n.slippageBps??E;if(typeof c!="number")throw new r("Slippage must be an integer from 0 to 9999 bps.");O("0",c);let o=n.minAmountOut===void 0?void 0:R(n.minAmountOut,128);if(o!==void 0&&o<=1n)throw new r("Initial-buy minimum must exceed one base unit.");if(!f&&o!==void 0)throw new r("A minimum requires a positive initial buy.");let u={tokenConfig:{tokenAdmin:s,name:l,symbol:d,salt:g,image:A(n.image,"image"),metadata:A(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):A(n.context,"context"),originatingChainId:BigInt(p)},poolConfig:{hook:h.fee_static_hook_v2.address,pairedToken:C.address,tickIfToken0IsClanker:-230400,tickSpacing:200,poolData:P(L("(address,bytes,bytes)"),[[$,"0x",P(L("uint24,uint24"),[1e4,1e4])]])},lockerConfig:{locker:h.locker.address,rewardAdmins:[s],rewardRecipients:[s],rewardBps:[1e4],tickLower:[-230400],tickUpper:[-12e4],positionBps:[1e4],lockerData:P(L("(uint8[])"),[[[0]]])},mevModuleConfig:{mevModule:h.mev_module.address,mevModuleData:P(L("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:[]},y=await t().simulateContract({address:h.factory.address,abi:U,functionName:"deployToken",args:[u],account:s,value:0n,gas:_}),a=b(y.result),D=W=>{let M=f?[{extension:h.devbuy.address,msgValue:f,extensionBps:0,extensionData:P(L("(address,address,uint24,int24,address),uint128,address"),[[$,$,0,0,$],W,s])}]:[];return m(h.factory.address,v({abi:U,functionName:"deployToken",args:[{...u,extensionConfigs:M}]}),`Launch ${l} (${d}); initial buy ${f} native ETH base units.`,f.toString())};if(f&&o===void 0){let M=(await e.preview([D(0n)],s)).changes.filter(T=>T.token.chainId===p&&T.token.address.toLowerCase()===a.toLowerCase()&&T.token.decimals===18).reduce((T,z)=>T+(/^-?\d+$/.test(z.amount)?BigInt(z.amount):(()=>{throw new r("Invalid initial-buy simulation amount.")})()),0n);if(M<=0n)throw new r("Initial-buy simulation returned no token output.");if(o=R(O(M.toString(),c),128),o<=1n)throw new r("Initial-buy output is too small for a protected minimum.")}let I=[D(o??0n)],B=await e.preview(I,s);return{txs:I,preview:B,predictedToken:a,token:{address:a,chainId:p,symbol:d,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${d} at ${a} (CREATE2 address predicted from simulation); vanity false; salt ${g}. Supply 100000000000000000000000000000 base units (18 decimals). Static LP fee 1%; protocol adds 20% of LP fees. Reward allocation: ${s} 10000 bps, both assets. Position 10000 bps, ticks -230400 to -120000, spacing 200. Sniper fees 666777 to 41673 over 15 seconds. ${B.summary} ${ne(e,B)}`}},re=async(n,s)=>{if(V(n,["token","poolId"]),n.poolId!==void 0&&n.token===void 0)throw new r("A pool ID requires its Clanker token.");let l=[C],d=[];if(n.token!==void 0){let o=b(n.token);if(o.toLowerCase()===C.address.toLowerCase())throw new r("Provide the launched Clanker token, not WETH.");if(n.poolId!==void 0){let u=ee(n.poolId,"pool ID for fee collection"),y=await t().readContract({address:h.factory.address,abi:U,functionName:"tokenDeploymentInfo",args:[o]});if(!Array.isArray(y)||y.length!==4||typeof y[0]!="string"||y[0].toLowerCase()!==o.toLowerCase())throw new r("The factory did not identify this Clanker token.");let a=b(y[1]),D=b(y[2]),I=await t().readContract({address:a,abi:k,functionName:"mevModuleEnabled",args:[u]});if(typeof I!="boolean")throw new r("The hook returned an invalid MEV guard state.");I&&d.push(m(a,v({abi:k,functionName:"mevModuleOperational",args:[u]}),"Update the Clanker pool MEV guard before collection.")),d.push(m(D,v({abi:k,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}l.push(await x(o))}let g;if(d.length){if(await t().getChainId()!==p)throw new r("Fee simulation endpoint is on the wrong chain.");let o=[...d.map(a=>({from:s,gas:F(_),to:a.to,data:a.data,value:F(BigInt(a.value))})),...l.map(a=>({from:s,gas:F(_),to:h.fee_locker.address,data:v({abi:k,functionName:"availableFees",args:[s,a.address]}),value:"0x0"}))],u=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(u)||u.length!==1||!S(u[0])||!Array.isArray(u[0].calls)||u[0].calls.length!==o.length)throw new r("The endpoint returned an unexpected fee simulation response.");let y=u[0].calls;if(!y.every(a=>S(a)&&a.status==="0x1"&&!a.error))throw new r("Clanker fee collection simulation failed.");g=y.slice(d.length).map(a=>{if(!S(a)||typeof a.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(a.returnData))throw new r("The endpoint returned an invalid fee balance.");return q(ie({abi:k,functionName:"availableFees",data:a.returnData}))})}else g=await Promise.all(l.map(o=>w(s,o.address)));let f=l.flatMap((o,u)=>BigInt(g[u])>0n?[{token:o,amount:g[u]}]:[]);if(!f.length)throw new r("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of f)d.push(m(h.fee_locker.address,v({abi:k,functionName:"claim",args:[s,o.address]}),`Claim ${o.symbol} fees to ${s}.`));let c=await e.preview(d,s);return{txs:d,preview:c,fees:f,summary:`Claim fees to ${s}. WETH fees aggregate across all Clanker launches for this recipient. ${c.summary} ${ne(e,c)}`}},N=(n,s,l,d)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:s,required:l,additionalProperties:!1},execute:(g,f)=>i(async()=>d(g,b(f)))});return{tools:[N("launch",{name:{type:"string"},symbol:{type:"string"},salt:Z,image:{type:"string"},metadata:{type:"string"},context:{type:"string"},vanity:{const:!1},initialBuy:{...X,description:"Native ETH base units, 18 decimals."},minAmountOut:{...X,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:E}},["name","symbol","salt"],se),N("claim",{token:{...Y,description:"Optional launched token to claim already-collected token fees or collect LP fees."},poolId:{...Z,description:"Optional pool ID used with token to sync the MEV guard and collect pending LP fees before claiming."}},[],re),N("browse",{q:{type:"string"},limit:{type:"integer",minimum:1,maximum:20},cursor:{type:"string"},deployer:Y},[],j)],positions:n=>i(async()=>{b(n);let s=new Map,l=new Set,d;do{let c=await j({deployer:n,limit:20,...d?{cursor:d}:{}});for(let o of c.tokens)o.msg_sender.toLowerCase()===n.toLowerCase()&&s.set(o.contract_address.toLowerCase(),o);if(c.cursor&&l.has(c.cursor))throw new r("The Clanker indexer repeated a pagination cursor.");c.cursor&&l.add(c.cursor),d=c.cursor??void 0}while(d);let g=[],f=[C];for(let[c,o]of s){let u=await x(o.contract_address),y=q(await t().readContract({address:u.address,abi:H,functionName:"balanceOf",args:[n]}));g.push({module:"clanker",id:`launch:${c}`,chainId:p,assets:[{token:u,amount:y}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),f.some(a=>a.address.toLowerCase()===u.address.toLowerCase())||f.push(u)}for(let c of f){let o=await w(n,c.address);BigInt(o)>0n&&g.push({module:"clanker",id:`fees:${c.address.toLowerCase()}`,chainId:p,assets:[{token:c,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return g})}},ke=e=>K("clanker",[ue(e)]);export{ce as a,ue as b,ke as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as u,b as R,i as M}from"./5BP72XOA.js";import{a as o}from"./Z3FZWNAJ.js";import{a as D}from"./XN4WDN3O.js";import{createPublicClient as A,custom as v,defineChain as F}from"viem";var g="https://rpc.mainnet.chain.robinhood.com",$="oak-core/0.1.0",H=M[4663].ponsClaims.multicall3.address,E=new Set(["eth_sendTransaction","eth_sendRawTransaction","eth_sign","personal_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v1","eth_signTypedData_v3","eth_signTypedData_v4","wallet_sendTransaction","wallet_sign"]);function S(e=u,t=g){if(!Number.isSafeInteger(e)||e<=0)throw new o("Provide a positive integer chain ID.");let n=e===u?"Robinhood Chain":e===R?"Robinhood Chain Testnet":`Chain ${e}`;return F({id:e,name:n,nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:[t]}},...e===u?{contracts:{multicall3:{address:H}}}:{}})}function Q(e=u,t){if(t?.chain&&t.chain.id===e)return t.chain.contracts?.multicall3?.address;if(!(!Number.isSafeInteger(e)||e<=0))return S(e).contracts?.multicall3?.address}function j(e,t){if(e===null)return t;if(/^\d+(\.\d+)?$/.test(e.trim()))return Number(e.trim())*1e3;let n=Date.parse(e);return Number.isFinite(n)?Math.max(0,n-Date.now()):t}function T(e,t){return t.throwIfAborted(),e<=0?Promise.resolve():new Promise((n,i)=>{let r=()=>{clearTimeout(a),i(t.reason)},a=setTimeout(()=>{t.removeEventListener("abort",r),n()},e);t.addEventListener("abort",r,{once:!0})})}function z(e,t,n){let i=e?.trim()||n?.rpcUrl?.trim()||n?.rpcUrls?.[t]?.trim(),r=t===u?process.env.OAK_RPC_URL?.trim():t===R?(process.env.OAK_TESTNET_RPC_URL??process.env.OAK_RPC_URL)?.trim():process.env[`OAK_RPC_URL_${t}`]?.trim(),a=i||r||(t===u?g:void 0);if(!a)throw new o(`No RPC URL configured for chain ${t}.`);if((n?.requireKeyedRpc??process.env.NODE_ENV==="production")&&t===u&&a===g)throw new o("Production requires a keyed OAK_RPC_URL.");return a}var U=1e4;async function x(e,t=U){if(!Number.isFinite(t)||t<=0||t>3e4)throw new o("RPC timeout must be greater than zero and at most 30000 ms.");let n=new AbortController,i;try{return await Promise.race([new Promise((r,a)=>{i=setTimeout(()=>{a(new o("The RPC request timed out. Please try again.")),n.abort()},t)}),e(n.signal)])}finally{clearTimeout(i)}}function J(e,t=u,n){let i=typeof e=="object"&&e!==null,r=i?e:n??{},a=typeof e=="string"?e:r.rpcUrl,p=i?r.chainId??t:t;if(!Number.isSafeInteger(p)||p<=0)throw new o("Provide a positive integer chain ID.");if(r.timeoutMs!==void 0&&(!Number.isFinite(r.timeoutMs)||r.timeoutMs<=0||r.timeoutMs>3e4))throw new o("RPC timeout must be greater than zero and at most 30000 ms.");let P=z(a,p,r),w=S(p,P);if(r.transport){let d=r.transport({chain:w,retryCount:0});return A({chain:w,transport:v({request:f=>{if(E.has(f.method)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(f.method))throw new o("Read-only RPC client does not allow this method.");return x(()=>d.request(f),r.timeoutMs)}},{retryCount:0})})}let N=r.fetch??globalThis.fetch,L=r.userAgent?.trim()||$,C=r.retries??3,b=r.retryDelayMs??250,_=r.maxRetryDelayMs??3e4,O=1,q=v({async request({method:d,params:f}){return x(async h=>{if(E.has(d)||/^(eth_send|eth_sign|personal_sign|wallet_)/i.test(d))throw new o(`Read-only RPC client does not allow ${d}.`);let k=O++,K=JSON.stringify({jsonrpc:"2.0",id:k,method:d,params:f??[]});for(let c=0;;c++){h.throwIfAborted();let m=await N(P,{method:"POST",redirect:"error",headers:{"content-type":"application/json","user-agent":L},body:K,signal:h});if(m.status===429){let y=b*2**c*(.5+Math.random()),l=Math.max(y,j(m.headers.get("retry-after"),y));if(await m.body?.cancel?.(),c>=C||l>_||l>=(r.timeoutMs??U))throw new o(`The RPC endpoint is busy; retry in ${Math.max(1,Math.ceil(l/1e3))} seconds.`);await T(l,h);continue}if(!m.ok){let y=m.status>=500;if(await m.body?.cancel?.(),!y||c>=C)throw new o(`The RPC endpoint returned HTTP ${m.status}. Please try again.`);await T(Math.min(_,b*2**c*(.5+Math.random())),h);continue}let s;try{s=await m.json()}catch{throw new o("The RPC endpoint returned malformed JSON.")}if(s.error){if(s.error.code===429||/rate limit|too many requests/i.test(s.error.message??"")){if(c>=C)throw new o(`The RPC endpoint is busy; retry in ${Math.max(1,Math.ceil(b*2**c/1e3))} seconds.`);await T(Math.min(_,b*2**c*(.5+Math.random())),h);continue}let l=new Error(D(s.error.message??"RPC error"));throw typeof s.error.code=="number"&&(l.code=s.error.code),s.error.data!==void 0&&(l.data=s.error.data),l}return s.result}},r.timeoutMs)}},{retryCount:0});return A({chain:w,transport:q})}function W(e={}){let t=new Map;return n=>{let i=t.get(n);if(i)return i;let r=J(e.rpcUrls?.[n],n,e);return t.set(n,r),r}}export{g as a,$ as b,H as c,S as d,Q as e,U as f,x as g,J as h,W as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as me,b as K,o as X}from"./XEN45QST.js";import{c as ce}from"./TU3KHOZK.js";import{a as ue}from"./VBWJOG3N.js";import{a as h,i as de}from"./5BP72XOA.js";import{a as i}from"./Z3FZWNAJ.js";import{a as ae}from"./XN4WDN3O.js";import{decodeFunctionData as ke,parseAbi as Ae}from"viem";var be="https://api.relay.link",D="0x0000000000000000000000000000000000000000",U=de[h].relay.depository.address.toLowerCase(),Re=Ae(["function depositNative(address depositor, bytes32 id) payable"]),le=30,qe=(1n<<256n)-1n;function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function t(e){if(!Y(e))throw new i("Relay returned an unexpected response.");return e}function R(e){if(!Array.isArray(e))throw new i("Relay returned an unexpected list.");return e}function r(e){if(typeof e!="string")throw new i("Provide a valid wallet or token address.");return ue(e),e.toLowerCase()}function L(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new i("Provide a positive integer chain ID.");return e}function q(e){if(typeof e!="string"||!/^(0|[1-9]\d*)$/.test(e)||BigInt(e)>qe)throw new i("Amounts must be decimal base-unit strings within the uint256 range.");return e}function pe(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new i("Relay returned an invalid order or refund deadline. Request a fresh quote.");return e}function B(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Provide a valid Relay request or order ID.");return e}function Ce(e){let s=t(e);if(typeof s.symbol!="string"||!s.symbol.trim()||typeof s.decimals!="number"||!Number.isInteger(s.decimals)||s.decimals<0||s.decimals>255)throw new i("Relay returned invalid token metadata.");return{address:r(s.address),chainId:L(s.chainId),decimals:s.decimals,symbol:s.symbol}}function _(e){let s=t(e);return{token:Ce(s.currency),amount:q(s.amount)}}function y(e){if(!e)throw new i("Relay quote does not match the requested amount, chain, recipient, minimum or transaction.")}function fe(e){return e===void 0?[]:R(e).map(B)}function he(e){if(!(e==null||e==="N/A")){if(typeof e!="string")throw new i("Relay returned an invalid failure reason.");return ae(e)}}var Oe=e=>{async function s(o,n){let a=process.env.OAK_RELAY_API_KEY?.trim();if(!a)throw new i("Configure the Relay API key on the server before using Relay.");try{return await ce(e.http,`${be}${o}`,{method:n===void 0?"GET":"POST",headers:{"x-api-key":a,"Content-Type":"application/json","User-Agent":"oak-relay/1.0"},...n===void 0?{}:{body:JSON.stringify(n)}},Y)}catch(m){throw new i(e.plainError(m))}}async function Q(o){let n;try{n=await s(`/intents/status/v3?requestId=${encodeURIComponent(o)}`)}catch(w){if(e.plainError(w)!=="The request timed out. Please try again.")throw w;return{requestId:o,status:"unknown",timedOut:!0,fulfilled:!1,settled:!1,pollAgain:!0,needsAttention:!1,inTxHashes:[],txHashes:[],originChainId:void 0,destinationChainId:void 0,summary:"The status request timed out. Bridge settlement is unknown; poll again."}}if(typeof n.status!="string")throw new i("Relay returned an invalid bridge status.");let a=fe(n.inTxHashes),m=fe(n.txHashes),d=n.originChainId===void 0?void 0:L(n.originChainId),I=n.destinationChainId===void 0?void 0:L(n.destinationChainId),l=he(n.failReason),u=he(n.refundFailReason),b=n.status==="success"&&m.length>0&&I!==void 0,g=n.status==="refund"&&m.length>0&&d!==void 0,p=n.status==="failure"&&u!==void 0,k=["waiting","depositing","pending","submitted","failure","refund","success"].includes(n.status)?n.status==="failure"&&/TIMEOUT|EXPIRED/.test(typeof n.failReason=="string"?n.failReason:"")?"timeout":n.status:"unknown",A=b?"Relay reports destination fulfillment.":g?"Relay reports a refund on the origin chain; the destination was not fulfilled.":p?"The bridge failed and automatic refund is unavailable. Review the request with Relay.":"Bridge settlement is not confirmed. Poll Relay again; an origin receipt alone does not prove destination fulfillment.";return{requestId:o,status:k,relayStatus:n.status,fulfilled:b,settled:b||g,pollAgain:!b&&!g&&!p,needsAttention:p,timedOut:!1,inTxHashes:a,txHashes:m,originChainId:d,destinationChainId:I,failReason:l,refundFailReason:u,...n.updatedAt===void 0?{}:{updatedAt:q(String(n.updatedAt))},summary:A}}async function ye(o,n){let a=r(n),m=r(o.recipient??a),d=L(o.destinationChainId);if(d===h)throw new i("Choose a destination chain other than 4663.");let I=r(o.originCurrency??D);if(I!==D)throw new i("This outbound part supports native ETH deposits. ERC20 deposits require recorded approval evidence.");let l=r(o.destinationCurrency??D),u=q(o.amount);if(u==="0")throw new i("Provide a positive bridge amount.");let b=o.minAmountOut===void 0?void 0:q(o.minAmountOut),g=o.slippageBps??K;if(typeof g!="number")throw new i("Slippage must be an integer from 0 to 9999 bps.");X("0",g);let p=R((await s("/chains")).chains).map(t),C=p.find(c=>c.id===h),k=p.find(c=>c.id===d);if(!C||!k||C.disabled!==!1||k.disabled!==!1||C.depositEnabled!==!0||C.vmType!=="evm"||k.vmType!=="evm")throw new i("Relay does not currently support this outbound chain route.");let A=Math.floor(Date.now()/1e3)+me,w=await s("/quote/v2",{user:a,recipient:m,originChainId:h,destinationChainId:d,originCurrency:I,destinationCurrency:l,amount:u,tradeType:"EXACT_INPUT"}),T=B(w.requestId),x=t(w.details),P=_(x.currencyIn),f=_(x.currencyOut),S={token:f.token,amount:q(t(x.currencyOut).minimumAmount)};if(y(r(x.sender)===a&&r(x.recipient)===m&&P.token.chainId===h&&P.token.address===I&&P.token.decimals===18&&P.amount===u&&f.token.chainId===d&&f.token.address===l&&BigInt(S.amount)>0n&&BigInt(S.amount)<=BigInt(f.amount)),l===D&&y(f.token.decimals===t(k.currency).decimals),b!==void 0){if(S.amount!==b)throw new i("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else if(BigInt(S.amount)<BigInt(X(f.amount,g)))throw new i("Relay order minimum is below the allowed slippage minimum. Request a new quote.");let j=t(t(w.protocol).v2),W=B(j.orderId),z=t(j.orderData),N=t(z.output),F=pe(N.deadline),Z=R(z.inputs).map(t);y(Z.length>0);let V=Z.flatMap(c=>{let E=R(c.refunds).map(t);return y(E.length>0),E.map(re=>{if(r(re.recipient)!==a)throw new i("Relay refund recipient does not match the agent wallet. Request a new quote.");return pe(re.deadline)})}),we=V.reduce((c,E)=>Math.min(c,E),F),G=Math.min(A,we-le),ee=()=>{if(Date.now()/1e3>=G)throw new i("The Relay quote expired or its order/refund deadline leaves too little time to sign and send. Request a fresh bridge quote.")};ee();let v=R(N.payments).map(t),ne=t(t(C.protocol).v2),ge=t(t(k.protocol).v2),H=t(j.paymentDetails);y(N.chainId===ge.chainId&&v.length===1&&R(N.calls).length===0&&r(v[0].recipient)===m&&r(v[0].currency)===l&&q(v[0].minimumAmount)===S.amount&&q(v[0].expectedAmount)===f.amount&&H.chainId===ne.chainId&&r(H.currency)===I&&q(H.amount)===u),y(r(H.depository)===U&&r(ne.depository)===U);let O=R(w.steps).map(t);y(O.length===1&&O[0].kind==="transaction"&&O[0].id==="deposit"&&O[0].requestId===T);let M=R(O[0].items).map(t);y(M.length===1&&M[0].status==="incomplete");let $=t(M[0].data),te=t(M[0].check);if(y(te.method==="GET"&&te.endpoint===`/intents/status/v3?requestId=${T}`&&$.chainId===h&&r($.from)===a&&r($.to)===U&&q($.value)===u),typeof $.data!="string"||!/^0x[0-9a-fA-F]{136}$/.test($.data))throw new i("Relay returned unexpected native deposit calldata.");let ie=ke({abi:Re,data:$.data});y(r(ie.args[0])===a&&ie.args[1].toLowerCase()===W.toLowerCase());let oe=[e.unsignedTx({to:U,data:$.data,value:u,chainId:h,description:`Deposit native ETH for Relay request ${T}.`})],se=t(w.fees);for(let c of Object.values(se))_(c);let J=await e.preview(oe,a);ee();let Ie=J.changes.map(c=>{let E=c.amount.startsWith("-");return`${E?"-":""}${e.formatAmount(E?c.amount.slice(1):c.amount,c.token.decimals)} ${c.token.symbol}`}).join(", ");return{txs:oe,requestId:T,orderId:W,recipient:m,originChainId:h,destinationChainId:d,expiresAt:String(G),orderDeadline:String(F),refundDeadlines:V.map(String),amountIn:P,amountOut:f,minAmountOut:S,fees:se,expandedPriceImpact:x.expandedPriceImpact,timeEstimate:x.timeEstimate,preview:J,summary:`Bridge to ${m} on chain ${d}; asset ${f.token.address} on chain ${f.token.chainId} (${f.token.symbol}); expected ${f.amount}, minimum ${S.amount} base units (${f.token.decimals} decimals). Order deadline ${F} Unix seconds; refund deadlines ${V.join(", ")} Unix seconds; accept before ${G} Unix seconds to reserve ${le}s to sign and send. Origin preview: ${Ie||J.summary}. Relay route fees are included in the quote; origin gas is separate. Poll relay_status with requestId ${T} after local submission; destination fulfillment is not yet confirmed.`}}return{tools:[{name:"relay_bridge_out",inputSchema:{type:"object",required:["destinationChainId","amount"],additionalProperties:!1,properties:{destinationChainId:{type:"integer",minimum:1},amount:{type:"string",pattern:"^[1-9][0-9]*$"},recipient:{type:"string"},originCurrency:{type:"string",const:D},slippageBps:{type:"integer",minimum:0,maximum:9999,default:K},destinationCurrency:{type:"string"},minAmountOut:{type:"string",pattern:"^[0-9]+$"}}},execute:async(o,n)=>{try{return await ye(o,n)}catch(a){throw new i(e.plainError(a))}}},{name:"relay_status",inputSchema:{type:"object",required:["requestId"],additionalProperties:!1,properties:{requestId:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}}},execute:async o=>Q(B(o.requestId))}],positions:async o=>{let n=r(o),a=new Map,m=new Set,d;do{let I=new URLSearchParams({user:n,originChainId:String(h),limit:"100"});d&&I.set("continuation",d);let l=await s(`/requests/v3?${I}`);for(let u of R(l.requests).map(t)){let b=Y(u.depositAddress)?u.depositAddress.depositor:void 0;if(![u.user,u.sender,b].some(T=>typeof T=="string"&&T.toLowerCase()===n))throw new i("Relay returned a request for another wallet.");let g=B(u.id),p=await Q(g);if(p.settled)continue;let C=t(u.data),k=t(t(C.route).quoted),A=_(t(k.origin).inputCurrency),w=_(t(k.destination).outputCurrency);y(A.token.chainId===h&&w.token.chainId!==h),p.originChainId!==void 0&&y(p.originChainId===A.token.chainId),p.destinationChainId!==void 0&&y(p.destinationChainId===w.token.chainId),a.set(g,{module:"relay",id:g,chainId:h,assets:[A],description:`Relay ${p.status}: ${A.amount} ${A.token.symbol} base units (${A.token.decimals} decimals) toward ${r(u.recipient)} on chain ${w.token.chainId}. ${p.summary}`})}if(l.continuation!==void 0&&l.continuation!==null&&typeof l.continuation!="string")throw new i("Relay returned invalid pagination.");if(d=typeof l.continuation=="string"&&l.continuation?l.continuation:void 0,d){if(m.has(d))throw new i("Relay repeated its pagination cursor. Pending positions are incomplete.");m.add(d)}}while(d);return[...a.values()]}}};export{Oe as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as ce}from"./UIJWIFGV.js";import{a as ie}from"./B2LA6VVF.js";import{a as j}from"./NNJLMS7F.js";import{a as U,b as P}from"./Z53DADZ4.js";import{a as F}from"./MEZH7RPA.js";import{b as ae,c as re}from"./TU3KHOZK.js";import{a as H}from"./VBWJOG3N.js";import{a as ne,b as B,c as te}from"./5HCXZWUH.js";import{e as se,g as N,h as oe}from"./R5CBH2CR.js";import{a as T,b as _,c as L,d as Y,i as I,j as ee,t as D}from"./5BP72XOA.js";import{a as h}from"./Z3FZWNAJ.js";import{a as b,b as K,c as V}from"./XN4WDN3O.js";import{decodeFunctionResult as Se,encodeFunctionData as xe,erc20Abi as W,getAddress as w,isAddress as M,parseAbi as J}from"viem";var he="https://api.robinhood.com/rhj/assets",Oe={address:U,symbol:"ETH",decimals:18,chainId:T},G={address:w(ee),symbol:"USDG",decimals:Y,chainId:T},Z={address:w(I[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:T},pe={address:w(I[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:T};function $(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function z(e,t=T,s={}){let n=Array.isArray(e)?e:$(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!n)throw new h("Official stock asset list response is malformed.");let a=new Map,r=new Map;if(n.length>1e4)throw new h("Official stock asset list exceeds the lookup limit.");for(let i of n){if(!$(i))continue;let o=i;if(typeof o.tokenSymbol!="string"||!o.tokenSymbol.trim()||!Array.isArray(o.deployments))continue;if(o.deployments.length>100)throw new h("Official stock deployment list exceeds the lookup limit.");let d=o.tokenSymbol.trim();if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(d))throw new h(`Invalid official stock ticker ${b(d)}.`);let k=typeof o.tokenDecimals=="number"&&Number.isInteger(o.tokenDecimals)&&o.tokenDecimals>=0&&o.tokenDecimals<=255?o.tokenDecimals:18;for(let m of o.deployments){if(!$(m))continue;let u=m;if(u.chainId!==t||typeof u.contractAddress!="string"||!M(u.contractAddress,{strict:!1}))continue;let p=w(u.contractAddress),f=p.toLowerCase(),y=d.toUpperCase(),c=r.get(y);if(!s.allowAmbiguousSymbols&&c&&c!==f)throw new h(`Ambiguous official stock ticker ${b(d)} across multiple addresses.`);r.set(y,f),a.set(f,{address:p,symbol:d,decimals:k,chainId:t,...s.includeNames&&typeof o.tokenName=="string"&&o.tokenName.trim()?{name:o.tokenName.trim()}:{}})}}return[...a.values()]}function Ce(e,t){if(typeof e.address!="string"||!M(e.address,{strict:!1}))return!1;let s=e.chainId??T,n=e.address.toLowerCase();return t.some(a=>a.chainId===s&&a.address.toLowerCase()===n&&a.symbol===e.symbol)}function de(e,t){H(e.address);let s=e.chainId??T,n=w(e.address),a=n.toLowerCase(),r=e.symbol.trim().toUpperCase(),i=t.find(d=>d.chainId===s&&d.address.toLowerCase()===a),o=t.find(d=>d.chainId===s&&d.symbol.toUpperCase()===r);if(i){if(e.symbol!==i.symbol)throw new h(`Token at ${n} does not match official stock ticker ${b(i.symbol)} (received ${b(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==i.decimals)throw new h(`Token ${b(i.symbol)} at ${n} does not match official decimals ${i.decimals}.`);return i}if(o)throw new h(`Token symbol ${b(e.symbol)} at ${n} does not match the official stock contract address ${o.address}.`);return{address:n,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var le=new WeakMap,q=new WeakMap;function R(e,t){return(q.get(e)??N)(t)}async function ye(e){let t=e?.http??ae(),s=e?.url??he,n=e?.chainId??T,a=te(t),r=le.get(a);r||(r=new ne(3e4),le.set(a,r));let{value:i}=await R(t,()=>r.read(`${n}:${s}`,async()=>{let o=await N(d=>re(a,s,{method:"GET",signal:d},k=>$(k)||Array.isArray(k)));return z(o,n,{allowAmbiguousSymbols:!0}),o}));return z(i,n,e)}var ve=J(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ue(e){let t=e,s=new Set;for(;t&&typeof t=="object"&&!s.has(t)&&s.size<10;){s.add(t);let n=t;if(n.name==="ContractFunctionZeroDataError"||n.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof n.shortMessage=="string"?n.shortMessage:""} ${typeof n.message=="string"?n.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;t=n.cause}return!1}function De(e){return e instanceof h?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function Ie(e,t,s){if(typeof e.getCode=="function")try{let n=await e.getCode({address:t});return!n||n==="0x"}catch{return ue(s)}return ue(s)}async function me(e,t,s){if(t.length===0)return[];let n=await Promise.allSettled(t.map(a=>e.readContract({address:a.address,abi:W,functionName:"balanceOf",args:[s]})));if(n.every(a=>a.status==="rejected")&&n[0]?.status==="rejected"&&De(n[0].reason))throw n[0].reason;return n.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let r=typeof a.value=="bigint"?a.value:BigInt(a.value);return r>=0n?{ok:!0,amount:r}:{ok:!1}}catch{return{ok:!1}}})}async function Pe(e,t,s,n){if(s.length===0)return[];let a=se(t,e);if(!a)return me(e,s,n);let r=s.map(o=>({target:o.address,allowFailure:!0,callData:xe({abi:W,functionName:"balanceOf",args:[n]})})),i;try{i=await e.readContract({address:a,abi:ve,functionName:"aggregate3",args:[r]})}catch(o){if(await Ie(e,a,o))return me(e,s,n);throw o}if(!Array.isArray(i)||i.length!==s.length)throw new h("Multicall3 aggregate3 returned an invalid result list.");return i.map(o=>{let d=o,k=Array.isArray(d)?d[0]:d?.success,m=Array.isArray(d)?d[1]:d?.returnData;if(!k||typeof m!="string"||m==="0x")return{ok:!1};try{let u=Se({abi:W,functionName:"balanceOf",data:m}),p=typeof u=="bigint"?u:BigInt(u);return p>=0n?{ok:!0,amount:p}:{ok:!1}}catch{return{ok:!1}}})}async function qe(e,t={}){H(e);let s=w(e),n=t.chainId??T,a=t.client??oe(t.rpcUrl,n),r=[];if(t.stockTokens?r=[...t.stockTokens]:t.stockAssetsPayload!==void 0?r=z(t.stockAssetsPayload,n):t.includeStockTokens!==!1&&n!==_&&(r=await ye({http:t.http,url:t.stockAssetsUrl,chainId:n})),t.tokens)for(let f of t.tokens)de(f,r);let i=n===T?[G,Z,pe,...t.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:w(t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:L,chainId:n}]:[]]:n===_?[{...G,address:w(D.testnet.usdg),chainId:n},{...Z,address:w(D.testnet.weth),chainId:n},...t.oakTokenAddress?[{address:w(t.oakTokenAddress),symbol:"OAK",decimals:L,chainId:n}]:[]]:[],o=[],d=new Set;for(let f of[...i,...r,...t.tokens??[]]){if(f.chainId!==n||P(f.address)===U)continue;let y=de(f,r),c=y.address.toLowerCase();d.has(c)||(d.add(c),o.push(y))}let[k,m]=await Promise.all([a.getBalance({address:s}),Pe(a,n,o,s)]),u=[],p={address:U,symbol:"ETH",decimals:18,chainId:n};(k>0n||t.includeZero)&&u.push({token:p,amount:k.toString()});for(let f=0;f<o.length;f++){let y=o[f],c=i.some(S=>A(S.address,y.address))||r.some(S=>A(S.address,y.address))?y.symbol:b(y.symbol),l=m[f]??{ok:!1};if(!l.ok){u.push({token:{address:y.address,symbol:c,decimals:y.decimals,chainId:y.chainId},amount:"unavailable"});continue}let g=l.amount;(g>0n||t.includeZero)&&u.push({token:{address:y.address,symbol:c,decimals:y.decimals,chainId:y.chainId},amount:g.toString()})}return u}var A=(e,t)=>e.toLowerCase()===t.toLowerCase(),C=e=>V(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,"");function ge(e){let t=e.context.network??"mainnet",{chainId:s,usdg:n,weth:a}=D[t],r=(i,o,d)=>({...i,address:P(w(i.address)),name:o,kind:d,verified:!0,source:"Oak fixed addresses",warnings:[]});return[r({...Oe,chainId:s},"Ether","native"),r({...G,address:n,chainId:s},"Global Dollar","stablecoin"),r({...Z,address:a,chainId:s},"Wrapped Ether","wrapped"),...t==="mainnet"?[r(pe,"USDe","stablecoin")]:[],...e.oakTokenAddress?[r({address:e.oakTokenAddress,symbol:"OAK",decimals:L,chainId:s},"Oak","oak")]:[]]}async function we(e){if(e.context.network==="testnet")return[];let t=await ye({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return t.filter(s=>Ce(s,t)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:he,warnings:[]}))}async function X(e,t,s=!0){let{chainId:n}=D[t.context.network??"mainnet"],a=t.context.clientFor(n);if(await a.getChainId()!==n)throw new h(`Token lookup requires Robinhood Chain ${n}.`);let[r,i,o]=await Promise.all([R(a,()=>F(a,n,e,"name")).catch(d=>{if(s)throw d;return""}),R(a,()=>F(a,n,e,"symbol")),R(a,()=>F(a,n,e,"decimals"))]);if(typeof r!="string"||s&&!r.trim()||typeof i!="string"||!i.trim()||!Number.isInteger(o)||o<0||o>255)throw new h("The contract returned invalid token metadata.");return{address:w(e),name:r||i,symbol:i,decimals:o,chainId:n}}async function fe(e,t){let s=await t.context.clientFor(T).readContract({address:I[T].clanker.factory.address,abi:J(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&A(s[0],e)}async function Ee(e,t){let s=t.context.clientFor(T),n=I[T].poolsTrade,a=[n.instantLaunchStrategyFeesOn.address,n.instantLaunchStrategyFeesOff.address],r=J(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],i=await s.getBlockNumber(),o=new Set,d=0,k=0;for(let m=63127652n;m<=i;m+=10000000n){if(++d>be)throw new h("Token origin scan limit reached.");let u=m+9999999n>i?i:m+9999999n,p=await s.getLogs({address:a,event:r,args:{token:e},fromBlock:m,toBlock:u,strict:!0});for(let f of p){if(f.removed||!a.some(c=>A(c,f.address))||!f.args.token||!A(f.args.token,e)||!f.transactionHash||o.has(f.transactionHash))continue;if(o.add(f.transactionHash),++k>20)throw new h("Token origin receipt limit reached.");let y=await s.getTransactionReceipt({hash:f.transactionHash});if(ce(y).some(c=>A(c.token,e)))return w(y.from)}}}var be=5,_e=100,Le=500,Ne=3e4;function Te(e){let t=Date.now()+Ne,s=0,n=new Map,a=i=>{let o=t-Date.now();if(o<=0)throw new h("Token lookup time budget reached; results are partial.");return N(i,Math.min(1e4,o))},r=B((i,o)=>a(async d=>{let k=await e.context.http(i,{...o,signal:d});return new Proxy(k,{get(m,u){if(u==="json")return()=>a(()=>m.json());let p=Reflect.get(m,u,m);return typeof p=="function"?p.bind(m):p}})}),e.context.http);return q.set(r,a),{...e,context:{...e.context,http:r,clientFor:i=>{if(!n.has(i)){let o=e.context.clientFor(i),d=k=>{if(++s>Le)throw new h("Token lookup RPC budget reached; results are partial.");return a(k)};n.set(i,B(new Proxy(o,{get(k,m){let u=Reflect.get(k,m);return typeof u!="function"?u:(...p)=>d(()=>u.apply(k,p))}}),o)),q.set(n.get(i),d)}return n.get(i)}}}}function ke(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:b(e.symbol),name:b(e.name)}}async function Xe(e,t){if(t=Te(t),typeof e!="string"||e.length>256||!C(e))throw new h("Provide a token name, symbol or address to find_token.");let s=C(e),n=M(e.trim(),{strict:!1})?P(w(e.trim())):void 0,{chainId:a}=D[t.context.network??"mainnet"],r=[],i=ge(t),o=!1;try{i.push(...await we(t))}catch{o=!0,r.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let d=c=>n?A(c.address,n):C(c.symbol).includes(s)||C(c.name).includes(s),k=i.filter(d),m=[],u=(c,l)=>[c.symbol,c.name??""].some(g=>[l.symbol,l.name].some(S=>{let x=C(g),O=C(S);return!!x&&!!O&&(x.includes(O)||O.includes(x))})),p=(c,l={})=>{if(m.some(x=>A(x.address,c.address)))return;let g=[`Token ${b(c.symbol)} at ${c.address} is an unverified ${l.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(K(c.symbol)||K(c.name)||i.some(x=>!A(x.address,c.address)&&u(c,x)))&&g.push(`Lookalike warning: ${b(c.symbol)} at ${c.address} resembles a verified token's name or symbol.`);let S={...c,...l,kind:l.launchpad?"launchpad":"erc20",verified:!1,source:l.launchpad?`${l.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:g};m.push(S),r.push(...g)};if(n&&!k.length){let c=await X(n,t),l={};if(a===T){try{await fe(n,t)&&(l.launchpad="clanker")}catch{r.push("Clanker origin lookup was unavailable for this address.")}if(l.launchpad==="clanker")try{let S=(await j(t.context,{q:n,limit:20})).tokens.find(x=>A(x.contract_address,n));S&&(l.creator=w(S.msg_sender),l.creatorSource="Clanker indexer msg_sender")}catch{r.push("Clanker creator lookup is unavailable.")}else try{let g=await ie(t.context,n);l.launchpad="pons",l.creator=w(g.creator),l.creatorSource="Pons factory deployer"}catch{r.push("Pons launch origin could not be confirmed for this address.")}if(!l.launchpad)try{let g=await Ee(n,t);g&&(l.launchpad="pools.trade",l.creator=g,l.creatorSource="Launch transaction sender; may be a relayer")}catch{o=!0,r.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}p(c,l)}else if(!n&&a===T){let c=new Set,l=new Set,g,S=0,x=0;try{do{if(++S>be)throw new h("Token search page limit reached.");let O=await j(t.context,{q:e.trim(),limit:20,...g?{cursor:g}:{}});for(let Q of O.tokens){if(++x>_e)throw new h("Token candidate limit reached.");let v=w(Q.contract_address);if(!(l.has(v)||i.some(E=>A(E.address,v)))){l.add(v);try{let E=await X(v,t);if(!d(E))continue;let Ae=await fe(v,t)?{launchpad:"clanker",creator:w(Q.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};p(E,Ae)}catch{o=!0,r.push(`Could not read Clanker candidate ${v}; it was omitted from these partial results.`)}}}if(O.cursor&&c.has(O.cursor))throw new h("The Clanker indexer repeated a pagination cursor.");O.cursor&&c.add(O.cursor),g=O.cursor??void 0}while(g)}catch{o=!0,r.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}r.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===_&&r.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let f=c=>[...new Map(c.map(l=>[l.address.toLowerCase(),l])).values()],y=f([...k,...m]);for(let c of y)if(y.some(l=>!A(l.address,c.address)&&(C(c.symbol)===C(l.symbol)||C(c.name)===C(l.name)))){let l=`Duplicate warning: several tokens share the symbol or name of ${c.address}. Choose the intended address; do not guess from the name.`;c.warnings.push(l),r.push(l)}return k.length>1&&r.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:b(e.trim()),chainId:a,partial:o,matches:f(k).map(ke),unverified:f(m).map(ke),warnings:r}}async function Je(e,t){if(typeof e!="string"||!e.trim())throw new h("Provide a token address or verified symbol; use find_token to look it up.");let s=e.trim(),n=M(s,{strict:!1})?P(w(s)):void 0,a=ge(t),r=n&&a.find(u=>A(u.address,n));if(r)return r;let i=[],o=[];try{i=await we(t)}catch{if(!n)throw new h("The official stock list is unavailable; stock identities and symbol ambiguity cannot be checked. Use find_token and retry, or quote an explicit address.");o.push("The official stock list is unavailable; this address is unverified.")}if(n){let u=i.find(f=>A(f.address,n));if(u)return{...u,name:b(u.name)};let p=await X(n,Te(t),!1);return{...p,symbol:b(p.symbol),name:b(p.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:[...o,"This token address is unverified. On-chain names and symbols do not prove identity."]}}let d=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),k=[...a,...i].filter(u=>u.symbol.toUpperCase()===d);if(k.length!==1)throw new h(`Token symbol ${b(s)} is ${k.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let m=k[0];return m.source==="Oak fixed addresses"?m:{...m,name:b(m.name)}}export{he as a,Oe as b,G as c,Z as d,pe as e,z as f,Ce as g,de as h,ye as i,ve as j,qe as k,Xe as l,Je as m};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as z}from"./SXBGOGYQ.js";import{c as q}from"./TU3KHOZK.js";import{a as B,i as F}from"./5BP72XOA.js";import{d as L}from"./6YQ2RX5I.js";import{a as _,b as D}from"./7I6TXFXR.js";import{a as i}from"./Z3FZWNAJ.js";import{encodeAbiParameters as de,encodeFunctionData as Q,erc20Abi as j,getAddress as Y,isAddress as se,keccak256 as K,parseAbi as le,parseAbiParameters as ce,zeroAddress as G}from"viem";var x=B,C=Y(F[x].hoodlock.airdrop.address),J="https://hoodlock.tech",T=25e4,me=256,ue=604800n,ye=30n,W=250000000000000000n,V=0xffffffffn,ge=(1n<<64n)-1n,Z=(1n<<128n)-1n,ee="0x0000000000000000000000000000000000000000000000000000000000000000",fe="0x1111111111111111111111111111111111111111",pe=ce("uint256, address, uint256"),v=le(["function quote(uint32 maxClaims) view returns (uint256)","function create(address token, bytes32 merkleRoot, uint256 total, uint32 maxClaims, uint64 endTime, string uri) payable returns (uint256 id)","function claim(uint256 id, uint256 index, address account, uint256 amount, bytes32[] proof)","function getAirdrop(uint256 id) view returns (address creator, uint64 endTime, uint32 maxClaims, address token, uint32 claims, bool swept, bytes32 merkleRoot, uint128 total, uint128 remaining)","function isClaimed(uint256 id, uint256 index) view returns (bool)"]);function be(o,e,t){let n=e.trim();if(n.startsWith("-")){let r=n.slice(1);return`-${o.formatAmount(r,t)}`}let d=n.startsWith("+")?n.slice(1):n;return o.formatAmount(d,t)}function oe(o,e){if(!e.changes.length)return e.summary;let t=e.changes.map(n=>`${be(o,n.amount,n.token.decimals)} ${n.token.symbol}`).join(", ");return`${e.summary} (${t})`}async function xe(o,e){try{let[t,n]=await Promise.all([o.readContract({address:e,abi:j,functionName:"symbol"}),o.readContract({address:e,abi:j,functionName:"decimals"})]),d=typeof t=="string"&&t.trim()?t.trim():"TOKEN",r=Number(n);return{symbol:d,decimals:Number.isInteger(r)&&r>=0&&r<=255?r:18}}catch{return{symbol:"TOKEN",decimals:18}}}function w(o,e,t){if(typeof e=="string"&&e.includes(".")){if(t?.decimals===void 0)throw new i(`Decimal string amount "${e}" requires explicit token decimals; amount inputs are base-unit integer strings by default.`);let d=t.rounding!==void 0?D(e,t.decimals,t.rounding):o?o.parseAmount(e,t.decimals):D(e,t.decimals),r=_(d);if(r<=0n)throw new i("Airdrop entry amount must be positive.");return r}let n;try{if(typeof e=="bigint")n=e;else if(typeof e=="string")n=_(e.trim());else throw new i("Amount must be a non-negative integer string in base units.")}catch(d){throw d instanceof i?d:new i(`Invalid airdrop amount "${String(e)}".`,{cause:d})}if(n<=0n)throw new i("Airdrop entry amount must be strictly positive (> 0).");return n}function I(o,e){try{let t=typeof o=="bigint"?o:BigInt(String(o).trim());if(t<0n)throw new i(`${e} must be non-negative.`);return t}catch(t){throw t instanceof i?t:new i(`Invalid ${e}: ${String(o)}`,{cause:t})}}function A(o,e){if(typeof o!="string"||!se(o,{strict:!1}))throw new i(`Invalid ${e} address "${String(o)}": token/account must be a valid EVM address, never a symbol.`);return Y(o)}function M(o,e,t){let n=typeof o=="bigint"?o:BigInt(o);if(n<0n||n>V)throw new i(`Airdrop leaf index must be in 0..${V.toString()}.`);let d=A(e,"account"),r=w(void 0,t),l=de(pe,[n,d,r]);return K(K(l))}function ne(o,e){let t=o;for(let n of e)t=L(t,n);return t}function Re(o){try{let e=M(o.index,o.account,o.amount);return ne(e,o.proof).toLowerCase()===o.root.toLowerCase()}catch{return!1}}function O(o,e){if(!Array.isArray(o)||o.length===0)throw new i("Airdrop entries list cannot be empty; maxClaims must be in 1..250000.");if(o.length>T)throw new i(`Airdrop entries length (${o.length}) exceeds maxClaims limit of ${T}.`);let t=[],n=0n;for(let a=0;a<o.length;a+=1){let s=o[a];if(!s)throw new i(`Missing airdrop entry at position ${a}.`);let c=s.index??a;if(!Number.isInteger(c)||c!==a)throw new i(`Airdrop entry index at position ${a} must be contiguous ${a} (got ${String(c)}).`);let u=A(s.account,`entries[${a}].account`),g=w(e?.context,s.amount,e);n+=g,t.push({index:c,account:u,amount:g.toString()})}if(n<=0n||n>Z)throw new i("Airdrop total amount must be > 0 and fit in uint128.");let d=t.map(a=>M(a.index,a.account,a.amount)),r=[d];for(;r[r.length-1].length>1;){let a=r[r.length-1],s=[];for(let c=0;c<a.length;c+=2){let u=a[c],g=a[c+1];g===void 0?s.push(u):s.push(L(u,g))}r.push(s)}let l=r[r.length-1][0];if(l.toLowerCase()===ee)throw new i("Computed Merkle root cannot be zero.");let f=r.length>1?r[1]:r[0],m=t.map((a,s)=>{let c=[],u=s;for(let g=0;g<r.length-1;g+=1){let y=r[g],b=u^1;b<y.length&&c.push(y[b]),u=Math.floor(u/2)}return{index:a.index,account:a.account,amount:a.amount,leaf:d[s],proof:c}}),p={format:"openzeppelin-standard-merkle-tree-v1",leafEncoding:["uint256","address","uint256"],root:l,totalAmount:n.toString(),maxClaims:t.length,values:t.map(a=>[a.index,a.account,a.amount]),entries:t};return{root:l,leaves:d,level1:f,totalAmount:n.toString(),maxClaims:t.length,entries:t,proofs:m,list:p}}function Ae(o){if(!o||!Array.isArray(o.entries)&&!Array.isArray(o.values))throw new i("Saved airdrop list is missing entries/values.");let e=Array.isArray(o.entries)&&o.entries.length>0?o.entries:o.values.map(([n,d,r])=>({index:n,account:d,amount:r})),t=O(e);if(o.root&&t.root.toLowerCase()!==o.root.toLowerCase())throw new i(`Rebuilt tree root ${t.root} does not match saved list root ${o.root}.`);if(o.maxClaims!==void 0&&t.maxClaims!==o.maxClaims)throw new i(`Rebuilt maxClaims (${t.maxClaims}) does not match saved list maxClaims (${o.maxClaims}).`);if(o.totalAmount!==void 0&&t.totalAmount!==o.totalAmount)throw new i(`Rebuilt totalAmount (${t.totalAmount}) does not match saved list totalAmount (${o.totalAmount}).`);return t}async function te(o,e){return q(o.http,e,{method:"GET"},t=>t!==null&&typeof t=="object")}async function he(o,e,t){let n=A(e.token,"token");if(n===G)throw new i("Airdrop token cannot be the zero address.");let d=O(e.entries,{decimals:e.decimals,rounding:e.rounding,context:o}),r=e.maxClaims??d.maxClaims;if(!Number.isInteger(r)||r<1||r>T||r!==d.maxClaims)throw new i(`maxClaims (${String(r)}) must equal entries.length (${d.maxClaims}) and be in 1..${T}.`);let l=BigInt(d.totalAmount),f=e.total!==void 0?w(o,e.total,{decimals:e.decimals,rounding:e.rounding}):l;if(f<l)throw new i(`Airdrop total (${f.toString()}) is less than the sum of entry amounts (${l.toString()}).`);if(f<=0n||f>Z)throw new i("Airdrop total must be positive and fit in uint128.");let m=e.uri??"",p=new TextEncoder().encode(m).byteLength;if(p>me)throw new i(`Airdrop URI length (${p} bytes) exceeds 256-byte limit.`);let a=e.endTime!==void 0?I(e.endTime,"endTime"):0n;if(a>ge)throw new i("endTime exceeds uint64 maximum.");let s=o.clientFor(x),c=await s.getCode({address:n});if(!c||c==="0x")throw new i(`Token ${n} has no contract code on chain ${x}.`);let u;if(a!==0n){let E=(await s.getBlock()).timestamp,N=e.inclusionMargin!==void 0?I(e.inclusionMargin,"inclusionMargin"):ye;if(N<=0n)throw new i("inclusionMargin must be at least 1 second to leave room for signing and inclusion after the already-mined block.");let R=E+N,S=e.inclusionTime!==void 0?I(e.inclusionTime,"inclusionTime"):R;if(S<R)throw new i(`inclusionTime (${S.toString()}) must be after the already-mined block (${E.toString()}) with room for signing and inclusion (>= ${R.toString()}).`);u=S;let U=S+ue;if(a<U)throw new i(`endTime (${a.toString()}) is too short (window too short): must be 0 or at least inclusion time (${S.toString()}) + 604800 (7 days >= ${U.toString()}, after already-mined block.timestamp ${E.toString()}).`)}let g=await s.readContract({address:C,abi:v,functionName:"quote",args:[r]}),y=typeof g=="bigint"?g:BigInt(String(g));if(y<0n||y>W)throw new i(`HoodLock quote(uint32) fee (${y.toString()}) exceeds max fee cap (${W.toString()}).`);let b=o.formatAmount(y.toString(),z.decimals),h=o.approval(n,C,f.toString(),x),k=o.unsignedTx({chainId:x,to:C,data:Q({abi:v,functionName:"create",args:[n,d.root,f,r,a,m]}),value:y.toString(),description:`Create HoodLock airdrop (${r} claims, total ${f.toString()}, quote fee ${b} ETH (${y.toString()} wei))`}),$=[h,k],H=A(e.account??t??fe,"wallet"),P=await o.preview($,H),ie=y>0n?` Quote fee: -${b} ETH (${b} ETH / ${y.toString()} wei).`:" Quote fee: 0 ETH (0 wei).",ae=`${oe(o,P)}${ie}`;return{kind:"hoodlock_airdrop_create",chainId:x,token:n,merkleRoot:d.root,totalAmount:d.totalAmount,total:f.toString(),maxClaims:r,endTime:a,...u!==void 0?{inclusionTime:u}:{},uri:m,quoteFee:y,list:d.list,proofs:d.proofs,txs:$,preview:P,summary:ae}}async function X(o,e,t,n){if(n.savedProof){let m=A(n.savedProof.account,"savedProof.account");if(m!==t)throw new i(`savedProof account (${m}) does not match claim account (${t}).`);return{index:n.savedProof.index,amount:w(o,n.savedProof.amount),proof:n.savedProof.proof}}if(n.proof!==void 0&&n.index!==void 0&&n.amount!==void 0){let m=Number(n.index);if(!Number.isInteger(m)||m<0)throw new i(`Invalid claim index: ${String(n.index)}`);return{index:m,amount:w(o,n.amount),proof:n.proof}}if(n.list||n.entries){let p=(n.list?Ae(n.list):O(n.entries,{context:o})).proofs.find(a=>!(a.account.toLowerCase()!==t.toLowerCase()||n.index!==void 0&&a.index!==Number(n.index)));if(!p)throw new i(`Account ${t} was not found in the saved airdrop list.`);return{index:p.index,amount:w(o,p.amount),proof:p.proof}}let d=`${J}/api/airdrop/${e.toString()}/proof?address=${t}`,r=await te(o,d),l=r?.data??r;if(!l||l.index===void 0||l.amount===void 0||!Array.isArray(l.proof))throw new i(`No valid proof returned from HoodLock API for airdrop ${e.toString()} and account ${t}.`);let f=Number(l.index);if(!Number.isInteger(f)||f<0)throw new i(`Invalid index in API proof: ${String(l.index)}`);return{index:f,amount:w(o,l.amount),proof:l.proof}}async function re(o,e){let t=o.clientFor(x),n=await t.readContract({address:C,abi:v,functionName:"getAirdrop",args:[e.id]}),[d,r,l,f,m,p,a,,s]=n,c=BigInt(r),u=Number(l),g=Number(m),y=BigInt(s),b=A(f,"airdrop.token");if(d===G||a.toLowerCase()===ee)throw new i(`Airdrop ${e.id.toString()} does not exist.`);if(p)throw new i(`Airdrop ${e.id.toString()} has already been swept.`);if(c>0n&&(await t.getBlock()).timestamp>=c)throw new i(`Airdrop ${e.id.toString()} expired at timestamp ${c.toString()}.`);if(g>=u)throw new i(`Airdrop ${e.id.toString()} has reached maxClaims (${u}).`);let[h,k]=await Promise.all([t.readContract({address:C,abi:v,functionName:"isClaimed",args:[e.id,BigInt(e.index)]}),xe(t,b)]);if(h)throw new i(`Airdrop ${e.id.toString()} index ${e.index} has already been claimed.`);if(y<e.amount)throw new i(`Airdrop ${e.id.toString()} remaining balance (${y.toString()}) is less than claim amount (${e.amount.toString()}).`);let $=M(e.index,e.account,e.amount),H=ne($,e.proof);if(H.toLowerCase()!==a.toLowerCase())throw new i(`Computed Merkle root ${H} does not match on-chain airdrop root ${a} (bad proof).`);return{tokenAddress:b,tokenMeta:k,merkleRoot:a,leaf:$}}async function we(o,e){let{tokenAddress:t,tokenMeta:n,merkleRoot:d,leaf:r}=await re(o,e),l=e.caller??e.account,f=l.toLowerCase()!==e.account.toLowerCase(),m=o.formatAmount(e.amount.toString(),n.decimals),p=o.unsignedTx({chainId:x,to:C,data:Q({abi:v,functionName:"claim",args:[e.id,BigInt(e.index),e.account,e.amount,[...e.proof]]}),value:"0",description:f?`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for recipient ${e.account} (caller ${l} pays gas only, token delta 0)`:`Claim ${m} ${n.symbol} (${e.amount.toString()} base units) from HoodLock airdrop #${e.id.toString()} for ${e.account}`}),a=[p],s=await o.preview(a,l),c,u,g=e.amount.toString(),y;if(f){let b=s.changes.filter(h=>h.amount.trim().startsWith("-"));c={...s,changes:b,summary:`${s.summary} Recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units); caller ${l} change is 0 (gas only).`},u=`Third-party claim from HoodLock airdrop #${e.id.toString()} (index ${e.index}): recipient ${e.account} receives ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}); caller ${l} own token change is 0 (gas only). ${s.summary}`,y="0"}else c=s,u=`Claim ${m} ${n.symbol} (${e.amount.toString()} base units of ${t}) from HoodLock airdrop #${e.id.toString()} (index ${e.index}) for recipient ${e.account}. ${oe(o,c)}`,y=e.amount.toString();return{kind:"hoodlock_airdrop_claim",chainId:x,id:e.id,index:e.index,account:e.account,recipient:e.account,caller:e.caller,token:t,amount:e.amount.toString(),recipientDelta:g,senderDelta:y,leaf:r,merkleRoot:d,proof:[...e.proof],tx:p,txs:a,preview:c,summary:u}}async function ke(o,e,t){let n=A(e.account??t??"","account"),d=e.caller!==void 0?A(e.caller,"caller"):t!==void 0?A(t,"wallet"):void 0;if(e.id!==void 0){let s=I(e.id,"id"),c=await X(o,s,n,e);return we(o,{id:s,index:c.index,account:n,caller:d,amount:c.amount,proof:c.proof})}let r=`${J}/api/airdrop/eligible?address=${n}`,l=await te(o,r),f=Array.isArray(l)?l:l?.claimable??l?.eligible??l?.airdrops??l?.claims??[],m=[];for(let s of f){let c=s.id??s.airdropId;if(c!==void 0)try{let u=I(c,"eligible.id"),g,y,b;if(s.index!==void 0&&s.amount!==void 0&&Array.isArray(s.proof))g=Number(s.index),y=w(o,s.amount),b=s.proof;else{let k=await X(o,u,n,{id:u,account:n});g=k.index,y=k.amount,b=k.proof}let h=await re(o,{id:u,index:g,account:n,amount:y,proof:b});m.push({id:u.toString(),index:g,account:n,token:h.tokenAddress,amount:y.toString(),proof:[...b],merkleRoot:h.merkleRoot})}catch{continue}}let p=m.length===0?`No eligible HoodLock airdrops found for ${n}.`:`Found ${m.length} eligible HoodLock airdrop(s) for ${n}: ${m.map(s=>`#${s.id}`).join(", ")}. Choose an id and call hoodlock_airdrop_claim with that id to build a claim transaction.`;return{kind:"hoodlock_airdrop_eligible",chainId:x,account:n,recipient:n,caller:d,recipientDelta:"0",senderDelta:"0",eligible:m,claims:[],tx:void 0,txs:[],preview:{txs:[],changes:[],summary:p},summary:p}}var Ce=o=>({tools:[{name:"hoodlock_airdrop_create",inputSchema:{type:"object",required:["token","entries"],additionalProperties:!1,properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663"},entries:{type:"array",description:"Ordered airdrop entries [{ index?, account, amount }] with base-unit integer string amounts"},total:{type:"string",description:"Optional total funded token amount as a base-unit integer string (>= sum of entries)"},maxClaims:{type:"number",description:"Optional claim count (must equal entries.length in 1..250000)"},endTime:{type:"number",description:"Unix timestamp in seconds (0 for non-sweepable or >= inclusion time + 604800)"},inclusionTime:{type:"number",description:"Optional expected transaction inclusion Unix timestamp in seconds (> already-mined block.timestamp)"},inclusionMargin:{type:"number",description:"Optional signing and inclusion margin in seconds above the already-mined block.timestamp (>= 1, default 30)"},uri:{type:"string",description:"Metadata URI (<= 256 UTF-8 bytes)"},decimals:{type:"number",description:"Optional token decimals when converting human decimal entry amounts via parseAmount"},rounding:{type:"string",enum:["floor","ceil"],description:"Optional rounding mode (floor or ceil) when converting decimal amounts"},account:{type:"string",description:"Optional creator wallet address for preview simulation"}}},execute:async(e,t)=>he(o,e,t)},{name:"hoodlock_airdrop_claim",inputSchema:{type:"object",required:["account"],additionalProperties:!1,properties:{id:{type:"string",description:"Optional airdrop ID (omit to query eligible airdrops)"},account:{type:"string",description:"Leaf recipient address that receives the tokens"},caller:{type:"string",description:"Optional caller/relayer address submitting the tx (pays gas only, receives 0 tokens)"},index:{type:"number",description:"Optional leaf index when supplying proof directly or selecting from list/entries"},amount:{type:"string",description:"Optional leaf amount as a base-unit integer string"},proof:{type:"array",items:{type:"string"},description:"Optional Merkle sibling proof array of 32-byte hex strings"},savedProof:{type:"object",description:"Optional saved proof item ({ index, account, amount, leaf?, proof }) from hoodlock_airdrop_create"},list:{type:"object",description:"Optional saved airdrop list ({ format, leafEncoding, root, totalAmount, maxClaims, values, entries }) to rebuild proof locally"},entries:{type:"array",description:"Optional airdrop entries array ([{ index?, account, amount }]) to rebuild proof locally"}}},execute:async(e,t)=>ke(o,e,t)}]}),_e=Ce;export{j as a,x as b,C as c,J as d,T as e,me as f,ue as g,ye as h,W as i,v as j,be as k,M as l,ne as m,Re as n,O as o,Ae as p,Ce as q,_e as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as u,i as q}from"./5BP72XOA.js";import{a as H}from"./7I6TXFXR.js";import{a as r}from"./Z3FZWNAJ.js";import{encodeFunctionData as B,erc20Abi as $,isAddress as G,parseAbi as Q,zeroHash as E}from"viem";var O=q[u].meridian,M=O.PredictionMarketEscrow.address,y={address:O.CollateralToken_USDe.address,chainId:u,symbol:"USDe",decimals:18},z="https://api.predict.meridian.xyz/graphql",J="query GetOpenConditions($now: Int!) { conditions(first: 20, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now } }) { totalCount nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",V="query GetHolderPositions($holder: Address!) { positions(first: 10, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",D=Q(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),W=(1n<<256n)-1n,Y={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function f(n){if(!n||typeof n!="object"||Array.isArray(n))throw new r("Meridian returned an unexpected response.");return n}function b(n){if(typeof n!="string"||!n.trim())throw new r("Meridian returned an invalid text field.");return n}function w(n){if(typeof n!="string"||!G(n,{strict:!1}))throw new r("Provide a valid Meridian contract or wallet address.");return n}function v(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new r("Provide a valid Meridian prediction or pick configuration ID.");return n}function x(n){if(typeof n!="string")throw new r("Meridian amounts must be integer strings in base units.");let m=H(n);if(m>W)throw new r("Meridian amount exceeds the uint256 range.");return m.toString()}function U(n){if(typeof n!="bigint"||n<0n)throw new r("Meridian returned an invalid on-chain amount.");return x(n.toString())}function N(n,m){return n.toLowerCase()===m.toLowerCase()}function X(n,m){return n.chainId===m.chainId&&N(n.address,m.address)}function Z(n,m){let d=f(n),p=f(d.pickConfig),C=w(d.holder),I=w(p.marketAddress);if(d.chainId!==u||!N(C,m))throw new r("Meridian returned a position for a different wallet or chain.");if(!N(I,M))throw new r("This Meridian position uses an unsupported escrow contract.");if(typeof p.resolved!="boolean"||p.result!==null&&typeof p.result!="string")throw new r("Meridian returned an invalid resolution.");let k=v(d.pickConfigId);if(v(p.pickConfigId).toLowerCase()!==k.toLowerCase())throw new r("Meridian returned mismatched pick configuration IDs.");if(d.side!=="PREDICTOR"&&d.side!=="COUNTERPARTY")throw new r("Meridian returned an invalid position side.");return{id:b(d.id),chainId:u,holder:C,side:d.side,balance:x(d.balance),tokenAddress:w(d.tokenAddress),pickConfigId:k,userCollateral:x(d.userCollateral),totalPayout:x(d.totalPayout),prediction:{predictionId:v(f(d.prediction).predictionId)},pickConfig:{pickConfigId:k,marketAddress:I,resolved:p.resolved,result:p.result}}}var ee=n=>{async function m(o){try{return await o()}catch(i){throw new r(n.plainError(i))}}async function d(){let o=n.clientFor(u);if(await o.getChainId()!==u)throw new r("Meridian requires an RPC on chain 4663.");return o}async function p(o,i,s){let e=new URL(z);e.searchParams.set("op",o),e.searchParams.set("query",i),e.searchParams.set("variables",JSON.stringify(s));let t=await n.http(e.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!t.ok)throw new r(`Meridian returned HTTP ${t.status}. Please try again.`);let a;try{a=await t.json()}catch{throw new r("Meridian returned malformed JSON.")}let c=f(a);if(c.errors!==void 0&&(!Array.isArray(c.errors)||c.errors.length>0))throw new r("Meridian could not complete the GraphQL query. Please try again.");return f(c.data)}async function C(o,i){w(o);let s=await p("GetHolderPositions",V,{holder:o}),e=f(s.positions).nodes;if(!Array.isArray(e)||e.length>10)throw new r("Meridian returned an invalid positions list.");return(i===void 0?e:e.filter(a=>{let c=f(a).tokenAddress;return typeof c=="string"&&N(c,i)})).map(a=>Z(a,o))}async function I(o){let i=await C(o);if(i.length===0)return[];let s=await d();return Promise.all(i.map(async e=>{let[t,a,c]=await Promise.all([s.readContract({address:e.tokenAddress,abi:$,functionName:"balanceOf",args:[o]}),s.readContract({address:e.tokenAddress,abi:$,functionName:"decimals"}),s.readContract({address:e.tokenAddress,abi:$,functionName:"symbol"})]);if(!Number.isInteger(a)||a<0||a>255)throw new r("Meridian returned invalid position token decimals.");let g={address:e.tokenAddress,chainId:u,decimals:a,symbol:b(c)},A=U(t),h=e.pickConfig.resolved?{token:{...y},amount:U(await s.readContract({address:M,abi:D,functionName:"getClaimableAmount",args:[e.pickConfigId,e.tokenAddress,BigInt(A)]}))}:null;return{module:"meridian",id:e.id,chainId:u,assets:[{token:g,amount:A}],description:`Meridian ${e.side.toLowerCase()} position; ${e.pickConfig.resolved?e.pickConfig.result??"resolved":"unresolved"}.`,holder:e.holder,side:e.side,pickConfigId:e.pickConfigId,prediction:e.prediction,pickConfig:e.pickConfig,userCollateral:{token:{...y},amount:e.userCollateral},totalPayout:{token:{...y},amount:e.totalPayout},claimable:h}}))}function k(o){return n.unsignedTx({to:M,chainId:u,value:"0",data:B({abi:D,functionName:"settle",args:[o,E]}),description:`Settle Meridian prediction ${o}.`})}function R(o,i,s){let e=i.changes.map(t=>{let a=t.amount.startsWith("-"),c=n.formatAmount(a?t.amount.slice(1):t.amount,t.token.decimals);return`${a?"-":"+"}${c} ${t.token.symbol} (${t.token.address}, chain ${t.token.chainId})`});return{txs:o,preview:i,summary:`${s} ${i.summary}${e.length?` Changes: ${e.join("; ")}.`:""}`}}async function j(){let o=await p("GetOpenConditions",J,{now:Math.floor(Date.now()/1e3)}),i=f(o.conditions);if(!Number.isSafeInteger(i.totalCount)||i.totalCount<0||!Array.isArray(i.nodes)||i.nodes.length>20)throw new r("Meridian returned an invalid markets list.");let s=i.nodes.map(e=>{let t=f(e);if(!Number.isSafeInteger(t.endTime)||t.endTime<0||t.estimatedPrice!==null&&(typeof t.estimatedPrice!="number"||!Number.isFinite(t.estimatedPrice)||t.estimatedPrice<0||t.estimatedPrice>1))throw new r("Meridian returned invalid market pricing or time.");return{conditionId:v(t.conditionId),resolver:w(t.resolver),question:b(t.question),shortName:t.shortName===null?null:b(t.shortName),optionName:t.optionName===null?null:b(t.optionName),endTime:String(t.endTime),estimatedPrice:t.estimatedPrice===null?null:String(t.estimatedPrice),marketType:t.marketType===null?null:b(t.marketType)}});return{chainId:u,collateral:{...y},totalCount:i.totalCount,markets:s,limit:20}}async function L(o,i){let s=w(o.positionToken),e=x(o.amount);if(BigInt(e)===0n)throw new r("Provide a positive Meridian redemption amount.");let t=await C(i,s);if(t.length!==1)throw new r("No unique Meridian position was found in the latest 10 indexed positions for this wallet.");let a=t[0],c=await d(),g=U(await c.readContract({address:s,abi:$,functionName:"balanceOf",args:[i]}));if(BigInt(e)>BigInt(g))throw new r("The redemption amount exceeds the wallet position balance.");let A=n.unsignedTx({to:M,chainId:u,value:"0",data:B({abi:D,functionName:"redeem",args:[s,BigInt(e),E]}),description:`Redeem ${e} Meridian position base units for USDe.`}),h=[A],P;try{P=await n.preview(h,i)}catch(l){if(!/\breverted\b/i.test(n.plainError(l)))throw l;if(a.pickConfig.resolved){let T=U(await c.readContract({address:M,abi:D,functionName:"getClaimableAmount",args:[a.pickConfigId,s,BigInt(e)]}));if(BigInt(T)===0n)throw l}h=[k(a.prediction.predictionId),A],P=await n.preview(h,i)}let _=P.changes.filter(l=>X(l.token,y)&&l.token.decimals===y.decimals).reduce((l,T)=>l+BigInt(T.amount),0n),F=P.changes.filter(l=>l.token.chainId===u&&N(l.token.address,s)).reduce((l,T)=>l+BigInt(T.amount),0n);if(_<=0n||F!==-BigInt(e))throw new r("Meridian preview did not show the requested position burn and a positive USDe payout.");return R(h,P,h.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function S(o,i,s,e,t){return{name:o,inputSchema:{type:"object",properties:i,required:s,additionalProperties:!1,description:e},execute:(a,c)=>m(async()=>{if(f(a),w(c),Object.keys(a).some(g=>!Object.hasOwn(i,g))||s.some(g=>a[g]===void 0))throw new r("Provide only the required Meridian tool inputs.");return t(a,c)})}}return{tools:[S("meridian_browse",{},[],"Browse up to 20 open Meridian conditions with USDe collateral.",j),S("meridian_positions",{},[],"Read the latest 10 indexed Meridian positions; this is not a complete portfolio scan.",async(o,i)=>({positions:await I(i),limit:10,scope:"Latest indexed positions only."})),S("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(o,i)=>{let s=k(v(o.predictionId));await d();let e=[s];return R(e,await n.preview(e,i),"Settle the Meridian prediction. Unsigned transaction only.")}),S("meridian_redeem",{positionToken:Y,amount:{type:"string",pattern:"^[0-9]+$",description:"Position token amount in base units."}},["positionToken","amount"],"Preview redemption from the latest 10 indexed positions, including settlement first if required. No approval or typed signature.",L)],positions:o=>m(()=>I(o))}},re=ee;export{ee as a,re as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m,b as M}from"./74X7PXPR.js";import{a as s,d as D}from"./Z3FZWNAJ.js";var y=class extends s{constructor(n){super(`The service returned HTTP ${n.status}. Please try again.`);this.response=n}response};function d(){return new s("The request was cancelled.")}async function p(t,a){if(a.aborted)throw d();await new Promise((n,i)=>{let o=setTimeout(()=>{a.removeEventListener("abort",w),n()},t),w=()=>{clearTimeout(o),a.removeEventListener("abort",w),i(d())};a.addEventListener("abort",w,{once:!0})})}function O(t,a){if(t===null)return a;if(/^\d+(\.\d+)?$/.test(t))return Number(t)*1e3;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,n-Date.now()):a}function q(t={}){let a=t.fetch??globalThis.fetch,n=t.timeoutMs??1e4,i=t.retries??2,u=t.retryDelayMs??250,o=t.maxRetryDelayMs??3e4;if(!Number.isInteger(i)||i<0||i>10||!Number.isFinite(n)||n<=0||n>2147483647||!Number.isFinite(u)||u<0||!Number.isFinite(o)||o<0||o>2147483647)throw new s("Provide finite timeout and retry bounds, with 0 to 10 retries.");return async(w,P)=>{let r=new Request(w,{...P,redirect:"error"}),c=M(a,r.url),E=r.method==="GET"||r.method==="HEAD";for(let b=0;;b++){if(r.signal.aborted)throw d();if(c){let e=Date.now()+2e3,l=c.reserve();for(l>0&&await p(l,r.signal);;){if(r.signal.aborted)throw d();if(Date.now()>e)throw new m(c.label,1);let f=c.dispatchDelay();if(f===0)break;if(Date.now()+f>e)throw new m(c.label,f/1e3);await p(f,r.signal)}}if(r.signal.aborted)throw d();let T=new AbortController,v=()=>T.abort();r.signal.addEventListener("abort",v,{once:!0});let g=!1,k=setTimeout(()=>{g=!0,T.abort()},n),x;try{let e=await a(r.clone(),{signal:T.signal});if(e.redirected)throw await e.body?.cancel(),new s("The request failed. Please try again.");if(e.ok){let l=await e.text();if(r.method!=="HEAD"&&e.status!==204&&e.status!==205)try{JSON.parse(l)}catch{throw new s("The service returned malformed JSON.")}return new Response(l||null,{status:e.status,statusText:e.statusText,headers:e.headers})}else{let l=e.status===429||e.status>=500,f=u*2**b*(.5+Math.random()),h=Math.max(f,O(e.headers.get("Retry-After"),f));if(e.status===429&&c?.backoff(h),!E||!l||b>=i||h>o){if(e.status===429)throw await e.body?.cancel(),new m(c?.label??"The service",Math.max(1,h/1e3));let N=await e.text();throw new y(new Response(N||null,{status:e.status,statusText:e.statusText,headers:e.headers}))}await e.body?.cancel(),x=h}}catch(e){throw r.signal.aborted?d():g?new s("The request timed out. Please try again."):e instanceof y?e:new s(D(e))}finally{clearTimeout(k),r.signal.removeEventListener("abort",v)}await p(x,r.signal)}}}async function H(t,a,n,i){let u=await t(a,n);if(!u.ok)throw new s(`The service returned HTTP ${u.status}. Please try again.`);let o;try{o=await u.json()}catch{throw new s("The service returned malformed JSON.")}try{if(i(o))return o}catch{}throw new s("The service returned an unexpected response.")}export{y as a,q as b,H as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as m}from"./Z25UKUJF.js";import{b as x,c as S}from"./VBWJOG3N.js";import{b as w,c as M}from"./7I6TXFXR.js";import{a as i,d as f}from"./Z3FZWNAJ.js";function C(t){return{...t,unsignedTx:x,approval:S,parseAmount:w,formatAmount:M,plainError:f}}function h(t,l,e){let a=new Set(l);if(!Array.isArray(t))throw new i("A module must provide a tools array.");for(let o of t){if(!o||typeof o.name!="string"||!/^[a-z][a-z0-9_]*$/.test(o.name)||e&&(!o.name.startsWith(`${e}_`)||o.name.length<=e.length+1))throw new i("A tool must have a valid name with its module prefix.");if(a.has(o.name))throw new i(`Tool ${o.name} is already registered.`);if(!o.inputSchema||typeof o.inputSchema!="object"||Array.isArray(o.inputSchema)||o.inputSchema.type!=="object"||typeof o.execute!="function")throw new i(`Tool ${o.name} must provide an object input schema and an execute function.`);a.add(o.name)}}function b(t,l,e){if(typeof t!="string"||!/^[a-z][a-z0-9]*$/.test(t))throw new i("Provide a valid module name.");let a=[],o=[];for(let n of l){if(!n||!Array.isArray(n.tools))throw new i(`Module ${t} has an invalid part.`);if(a.push(...n.tools),n.positions!==void 0){if(typeof n.positions!="function")throw new i(`Module ${t} has an invalid positions reader.`);o.push(n.positions.bind(n))}}if(h(a,new Set,t),e&&(typeof e.name!="string"||!e.name||typeof e.quote!="function"||typeof e.build!="function"))throw new i(`Module ${t} has an invalid swap provider.`);return{name:t,tools:a,...o.length?{positions:async n=>(await Promise.all(o.map(d=>d(n)))).flat()}:{},...e?{swapProvider:e}:{}}}function k(t,l,e=[]){h(e,new Set);let a=[...e],o=[],n=[],d=new Set,y=new Set(e.map(c=>c.name));for(let[c,g]of l.entries())try{let u=g(t),r=b(u.name,[u],u.swapProvider);if(d.has(r.name))throw new i(`Module ${r.name} is already registered.`);h(r.tools,y,r.name);for(let s of r.tools){let p=s.execute;s.execute=async(v,P)=>m(await p(v,P))}if(r.positions){let s=r.positions;r.positions=async p=>m(await s(p))}a.push(...r.tools),o.push(r),d.add(r.name),r.tools.forEach(s=>y.add(s.name))}catch(u){n.push({index:c,error:f(u)})}return{tools:a,modules:o,errors:n}}export{C as a,b,k as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as ae,o as K}from"./XEN45QST.js";import{a as G}from"./Z53DADZ4.js";import{b as re}from"./UB5U6SI2.js";import{a as T,i as se}from"./5BP72XOA.js";import{a as oe}from"./XAB4OIE3.js";import{a as ie}from"./7I6TXFXR.js";import{a}from"./Z3FZWNAJ.js";import{decodeErrorResult as ye,decodeEventLog as X,encodeAbiParameters as S,encodeFunctionData as $,erc20Abi as ge,getAddress as we,isAddress as be,parseAbi as fe,parseAbiParameters as C,toHex as ce,zeroAddress as k}from"viem";var m=se[T].poolsTrade,E=m.liquidityLauncher.address,H=m.uerc20BeneficiaryVault.address,z=m.universalRouter.address,W=10n**27n,L=(1n<<128n)-1n,de=`0x${"00".repeat(32)}`,Te=63127652n,J=10000000n,xe={address:G,symbol:"ETH",decimals:18,chainId:T},h=fe(["function multicall(bytes[] data) payable returns (bytes[])","function createToken(address factory,string name,string symbol,uint8 decimals,uint128 initialSupply,address recipient,bytes tokenData) payable returns (address)","function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable","function distributeWithNative(address strategy,bytes configData,bytes32 salt,uint256 nativeAmount) payable","function getGraffiti(address sender) view returns (bytes32)","function getUERC20Address(string name,string symbol,uint8 decimals,address recipient,bytes32 graffiti) view returns (address)","function execute(bytes commands,bytes[] inputs,uint256 deadline) payable","function collectFees(uint256[] ids)","function claim(uint256 id,uint256 minCurrency0Amount,uint256 minCurrency1Amount)","function amounts(uint256 id) view returns (uint128 eth,uint128 token)","function ownerOf(uint256 id) view returns (address)","function approve(address token,address spender,uint160 amount,uint48 expiration)","error V4TooLittleReceived(uint256 minAmountOut,uint256 amountOut)"]),D=fe(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)","event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"]),M=[m.instantLaunchStrategyFeesOn.address,m.instantLaunchStrategyFeesOff.address],p=(o,c)=>o.toLowerCase()===c.toLowerCase();function ue(o){if(o.status!=="success")throw new a("The launch receipt did not succeed.");let c=[];for(let f of o.logs){let y=M.findIndex(x=>p(x,f.address));if(y===-1||f.topics[0]!=="0x3b3d2bafdcae274a232217e1f80ee4305d3af6aa25c8b14b1681bd68d18042a4")continue;let F=X({abi:D,eventName:"TokenLaunched",data:f.data,topics:[...f.topics]}),{token:g,poolId:q,poolKey:I,feeSplitter:U}=F.args,_=y===0?m.feeSplitterFeesOn.address:m.feeSplitterFeesOff.address;if(!p(U,_)||!p(I.currency0,k)||!p(I.currency1,g)||I.fee!==2500||I.tickSpacing!==25||!p(I.hooks,k))throw new a("The launch does not match the current native ETH strategy.");let O=o.logs.filter(x=>p(x.address,m.v4PositionManager.address)).flatMap(x=>{if(x.topics[0]!=="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef")return[];let B=X({abi:D,eventName:"Transfer",data:x.data,topics:[...x.topics]}).args;return p(B.from,k)&&p(B.to,M[y])?[B.tokenId]:[]});if(O.length!==1)throw new a("The launch receipt must identify one matching position mint.");c.push({token:g,poolId:q,positionId:O[0].toString(),creatorFees:y===0})}return c}function A(o){if(typeof o!="string"||!be(o,{strict:!1}))throw new a("Provide a valid wallet or token address.");return we(o)}function R(o,c,f=!1){if(typeof o!="string")throw new a(`${c} must be an integer string in base units.`);let y=ie(o);if(!f&&y===0n||y>=1n<<256n)throw new a(`${c} is outside its supported range.`);return y}function P(o,c,f=!1){if(f&&o===void 0)return"";if(typeof o!="string"||!f&&!o.trim()||o.length>4096)throw new a(`Provide a valid ${c}.`);return o}function Ae(o){if(typeof o!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o))throw new a("Provide a valid launch transaction hash.");return o}function Q(o,c,f="minAmountOut"){let y=c.slippageBps??ae;if(typeof y!="number")throw new a("Slippage must be an integer in basis points.");let F=K(o.toString(),y),g=c[f]===void 0?BigInt(F):R(c[f],f,o===0n);if(g>o||o>0n&&g===0n||g>L)throw new a("The minimum output must be positive and no larger than the simulated output.");return g}function V(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}var ke=o=>{let c=o.clientFor(T),f=(e,s,i,r)=>o.unsignedTx({to:e,data:s,value:i.toString(),chainId:T,description:r}),y=e=>{throw new a(o.plainError(e))};async function F(){if(await c.getChainId()!==T)throw new a("pools.trade requires Robinhood Chain 4663.")}async function g(e,s,i){let r=await o.preview(e,s),n=r.changes.map(({token:t,amount:d})=>{let u=d.startsWith("-");return`${u?"-":""}${o.formatAmount(u?d.slice(1):d,t.decimals)} ${t.symbol} (${t.address}, chain ${t.chainId})`});return{txs:e,summary:[i,r.summary,...n].join(" ")}}async function q(){return(await c.getBlock()).timestamp+600n}function I(e,s,i,r,n,t){let d=[k,e,2500,25,k],u=[S(C("((address,address,uint24,int24,address),bool,uint128,uint128,uint256,bytes)"),[[d,s,i,r,0n,"0x"]]),S(C("address,uint256"),[s?k:e,i]),S(C("address,address,uint256"),[s?e:k,n,0n])],l=[S(C("bytes,bytes[]"),["0x060c0e",u])];return{inputs:l,encoded:S(C("bytes,bytes[],uint256"),["0x10",l,t])}}async function U(e,s){let i=await c.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(u=>({from:s,gas:ce(oe),to:u.to,data:u.data,value:ce(BigInt(u.value))}))}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(i)||i.length!==1||!V(i[0])||!Array.isArray(i[0].calls)||i[0].calls.length!==e.length)throw new a("The output simulation returned a malformed response.");let r=i[0].calls;if(!r.slice(0,-1).every(u=>V(u)&&u.status==="0x1"&&!u.error))throw new a("A prerequisite failed during the output simulation.");let n=r.at(-1);if(!V(n)||n.status!=="0x0")throw new a("The output simulation did not return the expected minimum-output control.");let t=typeof n.returnData=="string"&&n.returnData!=="0x"?n.returnData:V(n.error)?n.error.data:void 0;if(typeof t!="string"||!/^0x[0-9a-fA-F]+$/.test(t))throw new a("The output simulation did not report an expected amount.");let d=ye({abi:h,data:t});if(d.errorName!=="V4TooLittleReceived"||d.args[0]!==L||d.args[1]<=0n||d.args[1]>=L)throw new a("The output simulation did not report a valid amount.");return d.args[1]}async function _(e,s){let i=await c.getBlockNumber(),r=new Map,n=new Set;for(let t=Te;t<=i;t+=J){let d=t+J-1n>i?i:t+J-1n,u=await c.getLogs({address:M,event:D[0],...s?{args:{token:s}}:{},fromBlock:t,toBlock:d,strict:!0});for(let l of u){if(!l.transactionHash)throw new a("A launch log is missing its transaction hash.");r.has(l.transactionHash)||r.set(l.transactionHash,await c.getTransactionReceipt({hash:l.transactionHash}))}if(e){let l=await c.getLogs({address:H,event:D[1],args:{to:e},fromBlock:t,toBlock:d,strict:!0});for(let b of l){let N=X({abi:D,eventName:"Transfer",data:b.data,topics:b.topics}).args;n.add(N.tokenId.toString())}}}return{receipts:[...r.values()],feeIds:n}}async function O(e){let i=(e.launchTx!==void 0?[await c.getTransactionReceipt({hash:Ae(e.launchTx)})]:(await _(void 0,e.token===void 0?void 0:A(e.token))).receipts).flatMap(ue).filter(r=>e.positionId!==void 0?r.positionId===R(e.positionId,"positionId").toString():p(r.token,A(e.token)));if(i.length!==1)throw new a("No unique current-strategy launch was found. Older strategy generations are unsupported.");return i[0]}async function x(e,s){if(typeof e.creatorFees!="boolean")throw new a("creatorFees must be an explicit boolean; the choice is permanent.");if(e.pair!==void 0&&!p(A(e.pair),k)&&!p(A(e.pair),G))throw new a("Only the native ETH pair is supported.");if(e.decimals!==void 0&&e.decimals!==18)throw new a("Instant Launch requires 18 decimals.");if(e.supply!==void 0&&R(e.supply,"supply")!==W)throw new a("Instant Launch requires a supply of one billion tokens.");let i=A(e.feeBeneficiary);if(p(i,k)||p(i,E))throw new a("The fee beneficiary must be a wallet other than the launcher or zero address.");let r=P(e.name,"name"),n=P(e.symbol,"symbol"),t=e.initialBuy===void 0?0n:R(e.initialBuy,"initialBuy",!0);if(t>L)throw new a("The initial buy exceeds uint128.");if(t===0n&&e.minAmountOut!==void 0)throw new a("A minimum output requires an initial buy.");let d=await c.readContract({address:E,abi:h,functionName:"getGraffiti",args:[s]}),u=A(await c.readContract({address:m.uerc20Factory.address,abi:h,functionName:"getUERC20Address",args:[r,n,18,E,d]})),l=await c.getCode({address:u});if(l&&l!=="0x")throw new a("This wallet already launched that name and symbol.");let b=S(C("(string,string,string,bytes)"),[[P(e.description,"description",!0),P(e.website,"website",!0),P(e.imageUri,"image URI",!0),"0x"]]),N=e.creatorFees?M[0]:M[1],le=[$({abi:h,functionName:"createToken",args:[m.uerc20Factory.address,r,n,18,W,E,b]}),$({abi:h,functionName:"distributeToken",args:[u,{strategy:N,amount:W,configData:S(C("address"),[i])},de]})],pe=await q(),ee=me=>{let ne=[...le];if(t>0n){let he=S(C("(address,address,bytes)"),[[z,s,I(u,!0,t,me,s,pe).encoded]]);ne.push($({abi:h,functionName:"distributeWithNative",args:[m.universalRouterStrategyApp.address,he,de,t]}))}return f(E,$({abi:h,functionName:"multicall",args:[ne]}),t,`Atomic Instant Launch: creator fees ${e.creatorFees?"on":"off"} (permanent); beneficiary ${i}.`)},te=t>0n?Q(await U([ee(L)],s),e):0n;return g([ee(te)],s,`Launch ${r} (${u}, chain 4663), supply 1000000000, decimals 18. Creator fees ${e.creatorFees?"on":"off"} are permanent; fee beneficiary ${i}. Creator ETH fees come from buys only (recorded 0.09996%); sells compound into locked liquidity. Initial-buy minimum ${te} token base units. Off-chain image/display unproven; no private metadata registration. No transaction sent.`)}async function B(e,s,i){let r=R(e.amountIn,"amountIn");if(r>L)throw new a("The trade amount exceeds uint128.");let n=A(e.token);await O(e);let t=await q(),d=[];i||(await c.readContract({address:n,abi:ge,functionName:"allowance",args:[s,m.permit2.address]})<r&&d.push(o.approval(n,m.permit2.address,r.toString(),T)),d.push(f(m.permit2.address,$({abi:h,functionName:"approve",args:[n,z,r,Number(t)]}),0n,`Permit the exact ${r} token base units until ${t}.`)));let u=N=>[...d,f(z,$({abi:h,functionName:"execute",args:["0x10",I(n,i,r,N,s,t).inputs,t]}),i?r:0n,`${i?"Buy":"Sell"} ${n} with minimum output ${N}.`)],l=await U(u(L),s),b=Q(l,e);return g(u(b),s,`${i?"Buy":"Sell"} token ${n} (chain 4663, 18 decimals), amountIn ${r}, minimum output ${b} ${i?"token":"ETH"} base units (18 decimals). Recorded swap fee 0.2899%; creator ETH fees from buys only, none from sells. No transaction sent.`)}async function Y(e,s,i){let r=await O(e),n=BigInt(r.positionId),t=r.creatorFees?m.feeSplitterFeesOn.address:m.feeSplitterFeesOff.address,d=await c.readContract({address:m.v4PositionManager.address,abi:h,functionName:"ownerOf",args:[n]});if(!p(d,t))throw new a("The position is not locked in its current-strategy splitter.");if(!i)return g([f(t,$({abi:h,functionName:"collectFees",args:[[n]]}),0n,`Collect fees for position ${n}; permissionless.`)],s,"Collect fees for the entitled recipients; collection does not transfer creator fees to the collector. No transaction sent.");if(!r.creatorFees)throw new a("Creator fees are permanently disabled for this position.");let u=await c.readContract({address:H,abi:h,functionName:"ownerOf",args:[n]});if(!p(u,s))throw new a("Only the current fee NFT holder is entitled to claim.");let l=await c.readContract({address:H,abi:h,functionName:"amounts",args:[n]}),b=Q(l[0],e,"minEth");if(l[1]!==0n)throw new a("The current buy-only creator fee configuration returned unexpected token fees.");return g([f(H,$({abi:h,functionName:"claim",args:[n,b,0n]}),0n,`Claim collected ETH fees for position ${n} to ${s}.`)],s,`Claim collected fees: ${l[0]} ETH base units (18 decimals), minimum ${b}. Uncollected fees require poolstrade_collect first. No transaction sent.`)}let w={type:"string"},v={type:"string",pattern:"^[0-9]+$"},Z={chainId:{type:"integer",const:T},slippageBps:{type:"integer",minimum:0,maximum:9999}};function j(e,s,i,r){return{name:`poolstrade_${e}`,inputSchema:{type:"object",additionalProperties:!1,properties:{...Z,...s},required:i},execute:async(n,t)=>{try{let d=new Set([...Object.keys(Z),...Object.keys(s)]);if(Object.keys(n).some(u=>!d.has(u)))throw new a("Unsupported input; only the current atomic Instant Launch workflow is supported.");if(n.chainId!==void 0&&n.chainId!==T)throw new a("pools.trade requires chain 4663.");if(A(t),n.slippageBps!==void 0){if(typeof n.slippageBps!="number")throw new a("Slippage must be an integer in basis points.");K("10000",n.slippageBps)}return await F(),await r(n,t)}catch(d){y(d)}}}}return{tools:[j("launch",{name:w,symbol:w,creatorFees:{type:"boolean",description:"Permanent choice; must be explicit."},feeBeneficiary:w,pair:w,decimals:{type:"integer",const:18},supply:v,initialBuy:v,minAmountOut:v,description:w,website:w,imageUri:w},["name","symbol","creatorFees","feeBeneficiary"],x),...["buy","sell"].map(e=>j(e,{token:w,amountIn:v,minAmountOut:v,launchTx:w},["token","amountIn"],(s,i)=>B(s,i,e==="buy"))),j("collect",{positionId:v,launchTx:w},["positionId"],(e,s)=>Y(e,s,!1)),j("claim",{positionId:v,launchTx:w,minEth:v},["positionId"],(e,s)=>Y(e,s,!0))],positions:async e=>{try{A(e),await F();let{receipts:s,feeIds:i}=await _(e),r=[];for(let n of s)for(let t of ue(n)){let d=!1;if(t.creatorFees&&(i.has(t.positionId)||p(n.from,e))&&(d=p(await c.readContract({address:H,abi:h,functionName:"ownerOf",args:[BigInt(t.positionId)]}),e)),!d&&!p(n.from,e))continue;let u=d?[{token:xe,amount:(await c.readContract({address:H,abi:h,functionName:"amounts",args:[BigInt(t.positionId)]}))[0].toString()}]:[];r.push({module:"poolstrade",id:t.positionId,chainId:T,assets:u,description:`Current Instant Launch ${t.token} (18 decimals, supply 1000000000), pool ${t.poolId}; creator fees ${t.creatorFees?"on":"off"} (permanent). ${d?"Collected ETH fees only; uncollected fees excluded.":"Launch record; no fee entitlement held."} Liquidity is permanently locked.`})}return r}catch(s){return y(s)}}}};function He(o){return re("poolstrade",[ke(o)])}export{ue as a,ke as b,He as c};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./Z3FZWNAJ.js";import{createHash as f}from"node:crypto";function a(n){if(n===null||typeof n!="object"||Array.isArray(n))return!1;let t=Object.getPrototypeOf(n);return t===Object.prototype||t===null}function i(n){if(n===null||typeof n=="boolean"||typeof n=="string")return JSON.stringify(n);if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new o("Canonical JSON numbers must be safe integers; encode base-unit amounts as decimal strings.");return Object.is(n,-0)?"0":String(n)}if(typeof n=="bigint")throw new o("BigInt values must be encoded as decimal strings before JSON serialization.");if(Array.isArray(n)){let t=[];for(let e=0;e<n.length;e++){if(!Object.prototype.hasOwnProperty.call(n,e))throw new o(`Sparse arrays are not permitted in canonical JSON (missing index ${e}).`);t.push(i(n[e]))}return`[${t.join(",")}]`}if(a(n)){let t=Object.keys(n).sort((r,s)=>r<s?-1:r>s?1:0),e=[];for(let r of t){let s=n[r];if(s===void 0)throw new o(`Canonical JSON object key "${r}" must not be undefined.`);e.push(`${JSON.stringify(r)}:${i(s)}`)}return`{${e.join(",")}}`}throw new o("Unsupported value in canonical JSON.")}function c(n){return new TextEncoder().encode(i(n))}function g(n){return`0x${f("sha256").update(c(n)).digest("hex")}`}function d(n){let t;if(typeof n=="string"){if(n.startsWith("\uFEFF"))return!1;t=n}else if(n instanceof Uint8Array){if(n.length>=3&&n[0]===239&&n[1]===187&&n[2]===191)return!1;try{t=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}).decode(n)}catch{return!1}}else return!1;if(t.length===0||t.startsWith("\uFEFF")||t.endsWith(`
|
|
2
|
-
`)||t.endsWith("\r"))return!1;try{let e=JSON.parse(t);return i(e)===t}catch{return!1}}export{i as a,c as b,g as c,d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as y}from"./Z53DADZ4.js";import{c as H}from"./74X7PXPR.js";import{a as f,b as U,c as ee}from"./VBWJOG3N.js";import{A as R,B as Z,C as J,a as b,i as V,z as $}from"./5BP72XOA.js";import{a as o,d as q}from"./7I6TXFXR.js";import{a as r}from"./Z3FZWNAJ.js";import{decodeFunctionData as E,encodeFunctionData as L,parseAbi as K}from"viem";var le=60,j=50,Fe=200,ne=K(["function buy(uint256 quoteIn,uint256 minTokensOut,address recipient) payable returns (uint256)","function sell(uint256 tokensIn,uint256 minQuoteOut,address recipient) returns (uint256)"]),me="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",W="0x0000000000000000000000000000000000000000",B=V[4663].routes.kyberswap.address,Q=V[4663].routes.velora.address,X=$[4663].kyberswap.toLowerCase(),oe=$[4663].velora.toLowerCase(),pe="0x0000000000000000000000000000000000000000000000000000000000000000",P=K(["function swap((address callTarget, address approveTarget, bytes targetData, (address srcToken, address dstToken, address[] srcReceivers, uint256[] srcAmounts, address[] feeReceivers, uint256[] feeAmounts, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags, bytes permit) desc, bytes clientData) execution) payable returns (uint256 returnAmount, uint256 gasUsed)"]),_=K(["function swapExactAmountIn(address executor, (address srcToken, address destToken, uint256 fromAmount, uint256 toAmount, uint256 quotedAmount, bytes32 metadata, address beneficiary) swapData, uint256 partnerAndFee, bytes permit, bytes executorData) payable returns (uint256 receivedAmount, uint256 submittedAmount, uint256 augustusFeeAmount)"]),k=class extends r{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},C=class extends r{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},fe=1e3,h=new Map;function re(e){for(let[t,n]of h)BigInt(e)>=o(n.expiresAt)&&h.delete(t)}function G(e){return{...e,...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function te(e){let t=G(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var we=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund"];function N(e,t,n=!1){for(let s of we)if(!(s==="expiresAt"&&n&&o(e.expiresAt)<=o(t.expiresAt))&&e[s]!==void 0&&String(e[s]).toLowerCase()!==String(t[s]).toLowerCase())throw new r(`Quote ${s} does not match the accepted quote.`)}function M(e=Date.now){let t=e();if(!Number.isFinite(t)||t<0)throw new r("Clock must return a non-negative timestamp.");return t>1e11?Math.floor(t/1e3):Math.floor(t)}function I(e){let t=e.toLowerCase();return t===me.toLowerCase()||t===W.toLowerCase()}function Ae(e,t=j){if(!Number.isInteger(t)||t<0||t>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");return q(e,String(1e4-t),"10000","floor")}var ge=200;function ye(e){if(typeof e!="number"||!Number.isFinite(e)||!/^\d+(?:\.\d{1,2})?$/.test(String(e)))throw new r("Velora returned an unsupported venue fee. Request a fresh quote.");let[t,n=""]=String(e).split("."),s=Number(t)*100+Number(n.padEnd(2,"0"));return Y(s),s}function Y(e){if(!Number.isInteger(e)||e<0||e>ge)throw new r("Velora returned an unsupported venue fee. Request a fresh quote.")}function ae(e,t=1){return Y(t),o(e)*10000n/BigInt(1e4-t)+1n}function ve(e,t){Y(t);let n=e>>96n,s=Z>>96n,a=0x3fffn,d=1n<<92n,l=e&(1n<<96n)-1n;if(n!==s&&!(n===0n&&t===0)||(l&a)!==BigInt(t)||(l&~(d|a))!==0n)throw new r("Velora partnerAndFee must match the accepted venue fee and recipient.")}function se(e){if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let t=e.provider??"venue";return`Venue fee: ${e.venueFee} base units (${e.venueFeeBps} bps) retained by ${t}; Oak swap fee: 0 (venue fee is never Oak income).`}function he(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??R[b].kyberswap.address,n=e.approveTarget??W;f(t),f(n);let s=o(e.amountIn),a=o(e.minAmountOut);return L({abi:P,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:I(e.from)?[]:[t],srcAmounts:I(e.from)?[]:[s],feeReceivers:[],feeAmounts:[],dstReceiver:e.wallet,amount:s,minReturnAmount:a,flags:0n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Se(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??R[b].velora.address;return f(t),L({abi:_,functionName:"swapExactAmountIn",args:[t,{srcToken:e.from,destToken:e.to,fromAmount:o(e.amountIn),toAmount:o(e.minAmountOut),quotedAmount:o(e.amountOut),metadata:e.metadata??pe,beneficiary:e.wallet},e.partnerAndFee??0n,"0x",e.executorData??"0x"]})}function be(e){if(typeof e!="string"||!/^0x([0-9a-fA-F]{2})+$/.test(e)||e.length<10)throw new r("Swap calldata must contain a 4-byte function selector.");let t=e.slice(0,10).toLowerCase();if(t===X)return E({abi:P,data:e}).args[0].desc.minReturnAmount;if(t===oe)return E({abi:_,data:e}).args[1].toAmount;let n=E({abi:ne,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new r(`Unsupported swap router selector ${t}.`)}function ue(e,t,n=!1){let s=o(t),a=be(e);if(a<=0n||s<=0n||a!==s&&!(n&&(a>s||e.slice(0,10).toLowerCase()===X&&a+1n===s)))throw new r(`Built swap calldata minimum output (${a}) does not match the accepted quote minimum (${s}).`);return a}function ie(e,t){let{from:n,to:s,wallet:a,amountIn:d}=t;if(!n||!s||!a||d===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");for(let u of[n,s,a,t.router,e.to])f(u);let l=(u,c,A)=>{if(u.toLowerCase()!==c.toLowerCase())throw new r(`Built swap ${A} does not match the accepted quote.`)};if(l(e.to,t.router,"router"),e.chainId!==(t.chainId??b))throw new r("Built swap chain does not match the accepted quote.");let g=I(n)?o(d):0n;if(o(e.value)!==g||t.value!==void 0&&o(t.value)!==g)throw new r("Built swap value does not match the accepted quote input.");let w=e.data.slice(0,10).toLowerCase(),i=t.router.toLowerCase(),p;if(i===B.toLowerCase()&&w===X){l(t.spender??t.router,B,"spender");let u=E({abi:P,data:e.data});if(L({abi:P,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("KyberSwap calldata must be canonically decodable.");let{callTarget:c,approveTarget:A,desc:m}=u.args[0];l(c,R[b].kyberswap.address,"executor"),l(A,W,"executor approval target");let v=I(n);if(m.srcReceivers.length!==(v?0:1)||m.srcAmounts.length!==(v?0:1)||!v&&(m.srcReceivers[0].toLowerCase()!==c.toLowerCase()||m.srcAmounts[0]!==o(d)))throw new r("KyberSwap source transfers must send the exact input to the pinned executor.");if(m.feeReceivers.length||m.feeAmounts.length||m.flags!==0n&&m.flags!==512n||m.permit!=="0x")throw new r("KyberSwap fee recipients, fee amounts, flags and permit must match the pinned zero-fee policy.");p={from:m.srcToken,to:m.dstToken,wallet:m.dstReceiver,amount:m.amount}}else if(i===Q.toLowerCase()&&w===oe){l(t.spender??t.router,Q,"spender");let u=E({abi:_,data:e.data});if(L({abi:_,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("Velora calldata must be canonically decodable.");let[c,A,m,v]=u.args;if(!J.some(T=>T.toLowerCase()===c.toLowerCase()))throw new r("Built swap executor does not match the accepted quote.");if(v!=="0x")throw new r("Velora permit must match the pinned empty-permit policy.");if((t.calldataMinAmountOut!==void 0||m!==0n)&&ve(m,t.venueFeeBps??0),t.calldataMinAmountOut!==void 0&&o(t.calldataMinAmountOut)!==ae(t.minAmountOut,t.venueFeeBps??1))throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.");if(t.calldataMinAmountOut!==void 0&&(A.quotedAmount!==o(t.grossAmountOut??"0")||A.quotedAmount<o(t.calldataMinAmountOut)))throw new r("Velora quoted gross output must match the accepted quote and cover its calldata minimum.");if(m!==0n&&t.calldataMinAmountOut===void 0)throw new r("Velora venue fee requires a fee-adjusted calldata minimum.");p={from:A.srcToken,to:A.destToken,wallet:A.beneficiary,amount:A.fromAmount}}else if(t.provider==="pons"&&t.ponsCurveToken){let u=E({abi:ne,data:e.data}),c=I(n);if(u.functionName!==(c?"buy":"sell")||!I(c?n:s))throw new r("Pons curve direction does not match the accepted quote.");l(c?s:n,t.ponsCurveToken,"curve token"),l(t.spender??t.router,t.router,"curve spender"),p={from:n,to:s,wallet:u.args[2],amount:u.args[0]}}else throw new r("Built swap selector does not match the accepted router.");if(l(p.from,n,"input token"),l(p.to,s,"output token"),l(p.wallet,a,"recipient"),p.amount!==o(d))throw new r("Built swap input amount does not match the accepted quote.");ue(e.data,t.calldataMinAmountOut??t.minAmountOut,i===B.toLowerCase())}function z(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Quote must include a non-empty quoteId.");if(f(e.router),e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");let n=o(e.amountOut),s=e.destAmountAfterFee??e.netAmountOut,a,d,l;if(s!==void 0){if(d=o(s),a=e.grossAmountOut!==void 0?o(e.grossAmountOut):n>=d?n:d,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else if(e.grossAmountOut!==void 0){if(a=o(e.grossAmountOut),d=n,a<d)throw new r("Gross output cannot be less than net output.");l=e.venueFee!==void 0?o(e.venueFee):a-d}else e.venueFee!==void 0?(l=o(e.venueFee),d=n,a=d+l):(d=n,a=n,l=0n);if(d<=0n)throw new k("Quote output amount must be positive.");let g=t.slippageBps??e.slippageBps??j,w=e.minAmountOut!==void 0?o(e.minAmountOut):o(Ae(d.toString(),g));if(w<=0n||w>a)throw new r("Quote minAmountOut must be positive and not exceed gross output.");if((t.provider??e.provider)==="velora"&&e.calldataMinAmountOut!==void 0){if(o(e.calldataMinAmountOut)!==ae(w.toString(),e.venueFeeBps??1)||o(e.calldataMinAmountOut)>a)throw new r("Velora calldata minimum must cover the accepted net output, venue fee and router dust.")}else if(e.calldataMinAmountOut!==void 0||e.ponsCurveToken!==void 0){if((t.provider??e.provider)!=="pons"||!e.ponsCurveToken)throw new r("Curve minimum requires a Pons curve quote.");f(e.ponsCurveToken);let S=o(t.amountIn??e.amountIn??"0"),x=o(e.expectedSpend??"0"),de=o(e.expectedRefund??"0"),ce=o(e.calldataMinAmountOut??"0");if(S<=0n||x<=0n||x+de!==S||ce*x/S!==w)throw new r("Pons actual minimum and refund do not match the encoded minimum.")}let i=M(t.now),p=BigInt(i+le),u=e.expiresAt!==void 0?o(e.expiresAt):p,c=(u>p?p:u).toString(),A=l.toString(),m=e.venueFeeBps??(a>0n&&l>0n?Number((l*10000n+a/2n)/a):0),v=t.provider??e.provider??(e.router.toLowerCase()===Q.toLowerCase()?"velora":"kyberswap"),T=v==="pons"&&e.feeDisclosure?e.feeDisclosure:se({provider:v,venueFee:A,venueFeeBps:m,oakFee:"0"}),O={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:w.toString(),router:e.router,expiresAt:c,provider:v,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:A,venueFeeBps:m,oakFee:"0",feeDisclosure:T,...t.from??e.from?{from:y(t.from??e.from)}:{},...t.to??e.to?{to:y(t.to??e.to)}:{},...t.amountIn??e.amountIn?{amountIn:t.amountIn??e.amountIn}:{},...t.wallet??e.wallet?{wallet:t.wallet??e.wallet}:{},slippageBps:g,chainId:t.chainId??e.chainId??b,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(i)>=o(c))throw new C;if(t.cache===!1)return O;if(re(i),BigInt(i)>=o(c))throw new C;let F=h.get(O.quoteId);if(F){N(O,F,!0);let S=te({...F,expiresAt:O.expiresAt});return h.set(S.quoteId,S),G(S)}for(;h.size>=fe;)h.delete(h.keys().next().value);let D=te(O);return h.set(D.quoteId,D),G(D)}async function Ce(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=y(e.from),e.to=y(e.to);let s=o(e.amountIn);if(s<=0n)throw new r("Swap amountIn must be greater than zero.");let a=e.slippageBps??j;if(!Number.isInteger(a)||a<0||a>=1e4)throw new r("Slippage must be an integer from 0 to 9999 bps.");if(!Array.isArray(t)||t.length===0)throw new k;let d={from:e.from,to:e.to,amountIn:s.toString(),slippageBps:a},l=await Promise.allSettled(t.map(async i=>{let p=await(i.quotePrices??i.quote).call(i,{...d},e.wallet);return{quote:z(p,{provider:i.name,from:e.from,to:e.to,amountIn:s.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??b,allowance:e.allowance,now:e.now,cache:!1}),provider:i}})),g,w=[];for(let i of l)i.status==="rejected"&&(g??=H(i.reason)),i.status==="fulfilled"&&o(i.value.quote.expiresAt)>BigInt(M(e.now))&&w.push(i.value);if(w.length===0)throw g??new k;w.sort((i,p)=>{let c=o(p.quote.amountOut)-o(i.quote.amountOut)||o(p.quote.minAmountOut)-o(i.quote.minAmountOut);return c>0n?1:c<0n?-1:0});for(let{quote:i,provider:p}of w)try{if(BigInt(M(e.now))>=o(i.expiresAt))continue;if(n.deferBuild||!p.prepareQuote)return z(i,{now:e.now});let u=await p.prepareQuote(i.quoteId,e.wallet);if(u.quoteId!==i.quoteId)throw new r("Prepared quote ID does not match the selected route.");if(N(u,i,!0),!u.data)throw new r("Selected route did not return swap calldata.");let c={...i,expiresAt:u.expiresAt,data:u.data,value:u.value,allowance:u.allowance??i.allowance};return ie(U({to:c.router,data:u.data,value:u.value??"0",chainId:c.chainId??b,description:"Selected swap route"}),c),z(c,{now:e.now})}catch(u){g??=H(u);continue}throw g??new k}function Re(e,t={}){if(!e||typeof e.quoteId!="string"||!e.quoteId.trim())throw new r("Provide a valid quote to build a swap.");f(e.router);let n=h.get(e.quoteId),s=M(t.now);if(re(s),!n||BigInt(s)>=o(n.expiresAt))throw h.delete(e.quoteId),new C;if(e.oakFee!==void 0&&o(e.oakFee)!==0n)throw new r("Oak charges 0 swap fee; venue fees must never be counted as Oak income.");N(e,n),N({...n,...t},n);let a=n.from,d=n.to,l=n.amountIn,g=n.wallet;if(!a||!d||!g||l===void 0)throw new r("Accepted quote must include input, output, amount and wallet.");let w=n.chainId??b,i=n.spender??n.router,p=t.allowance??e.allowance??n?.allowance??"0";f(a),f(d),f(g),f(i);let u=o(l);if(u<=0n)throw new r("Swap amountIn must be greater than zero.");let c=o(n.minAmountOut);if(c<=0n)throw new r("Swap minAmountOut must be greater than zero.");let A=e.router.toLowerCase()===Q.toLowerCase(),m=t.data??e.data??n?.data??(A?Se({from:a,to:d,amountIn:u.toString(),amountOut:n.amountOut,minAmountOut:c.toString(),wallet:g}):he({from:a,to:d,amountIn:u.toString(),minAmountOut:c.toString(),wallet:g}));ue(m,n.calldataMinAmountOut??c.toString(),n.router.toLowerCase()===B.toLowerCase());let v=n.venueFee??"0",T=n.venueFeeBps??0,O=n.provider??(A?"velora":"kyberswap"),F=n.feeDisclosure??se({provider:O,venueFee:v,venueFeeBps:T,oakFee:"0"}),D=I(a),S=t.value??e.value??n?.value??(D?u.toString():"0"),x=U({to:e.router,data:m,value:S,chainId:w,description:`Swap ${u} base units of ${a} for at least ${c} base units of ${d} via ${O} (${e.router}). ${F}`});return ie(x,n),D||o(p)>=u?[x]:[ee(a,i,u.toString(),w),x]}export{le as a,j as b,Fe as c,ne as d,me as e,W as f,k as g,C as h,fe as i,G as j,te as k,N as l,M as m,I as n,Ae as o,ge as p,ye as q,ae as r,ve as s,se as t,he as u,Se as v,be as w,ue as x,ie as y,z,Ce as A,Re as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as b}from"./5BP72XOA.js";import{a as T}from"./7I6TXFXR.js";import{a as o}from"./Z3FZWNAJ.js";import{decodeAbiParameters as N,parseAbiParameters as B}from"viem";var L="12333333",Y="9000000",$="20000000000000000000",Q="300000000000000000000",j=["100000000000000000000000","500000000000000000000000","1000000000000000000000000","10000000000000000000000000"],v=1800,q=(1n<<256n)-1n,m=10n**18n,W=10n**30n,U=1n<<192n,E=20n*m,P=75n*m,_=100n*m,I=300n*m,k=100000n*m,w=500000n*m,p=1000000n*m,y=10000000n*m;function e(t){let n=typeof t=="bigint"?t:T(t);if(n<0n||n>q)throw new o("Amount must be within the uint256 range.");return n}function h(t){if(typeof t=="bigint")return t;if(typeof t=="number"){if(!Number.isSafeInteger(t))throw new o("Integer parameter must be a safe integer.");return BigInt(t)}if(typeof t!="string"||!/^-?\d+$/.test(t))throw new o("Value must be a signed integer decimal string.");return BigInt(t)}function x(t){let n=typeof t=="number"?t:typeof t=="string"&&/^\d+$/.test(t)?Number(t):NaN;if(!Number.isInteger(n)||n<0||n>77)throw new o("Token decimals must be an integer from 0 to 77.");return n}function O(t){return 10n**BigInt(t)}function A(t,n="Result"){if(t<0n||t>q)throw new o(`${n} exceeds uint256 bounds.`);return t}function f(t,n,i="Factor"){return A(t*n,i)}function g(t,n,i,c="floor"){if(i<=0n)throw new o("The denominator must be positive.");let r=t*n;if(r===0n)return 0n;let s=c==="ceil"?r/i+(r%i===0n?0n:1n):r/i;return A(s,"Math.mulDiv result")}function z(t){let n=e(t);return n<k?E.toString():n<w?(E+g(n-k,P-E,w-k)).toString():n<p?(P+g(n-w,_-P,p-w)).toString():n<y?(_+g(n-p,I-_,y-p)).toString():I.toString()}function G(t){let n=e(t);return A(9000000n+n/1000000000000n/6n,"noHoldPriceBase").toString()}function J(t){let n=e(t),i=n/4n,c=n-i;return{burn:i.toString(),treasury:c.toString()}}function R(t){let n=e(t);return g(n,5n,100n,"ceil").toString()}function Z(t){let n=e(t);return(n-BigInt(R(n))).toString()}function tt(t,n){let i=e(t),c=e(n);if(c<=0n)throw new o("OAK-per-ETH price must be positive.");return g(i,m,c,"floor").toString()}function nt(t,n,i=b){let c=e(t),r=e(n);if(r<=0n)throw new o("OAK USD price must be positive.");let s=O(x(i));return g(c,s,r,"ceil").toString()}function it(t,n,i=b){let c=e(t),r=e(n),s=O(x(i));return g(c,r,s,"floor").toString()}function et(t,n,i,c=b){let r=x(c);if(r<6)throw new o("OAK decimals must be at least 6 for burner conversion.");let s=e(t),u=e(n),a=e(i);if(a<=0n)throw new o("ETH USD price must be positive.");let d=O(r-6),l=f(s,d,"burnerMinOut usdgIn * decimalScale"),D=f(u,49n,"burnerMinOut oakPerEthE18 * 49"),S=f(a,51n,"burnerMinOut ethUsdE18 * 51");return g(l,D,S,"floor").toString()}function rt(t,n,i=v){let c=h(t),r=h(n),s=h(i);if(s<=0n)throw new o("Observation window seconds must be positive.");let u=r-c,d=u/s-(u<0n&&u%s!==0n?1n:0n);return Number(d)}function ot(t,n){if(!t||typeof n!="string"||!/^0x[0-9a-fA-F]*$/.test(n))throw new o("Oracle observe call failed or returned invalid hex.");if(n==="0x"||n.length<258)throw new o("Oracle observe return data is empty or too short.");try{let[i]=N(B("int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s"),n);if(!Array.isArray(i)||i.length<2)throw new o("Oracle observe did not return two tick cumulatives.");return[i[0].toString(),i[1].toString()]}catch(i){throw i instanceof o?i:new o("Oracle observe return data could not be decoded.")}}function ct(t){let n=e(t);if(n<=0n)throw new o("sqrtRatioX96 must be positive.");let i=f(n,n,"sqrtRatioX96 squared");return g(i,W,U,"floor").toString()}function X(t){let n=e(t);if(n<=0n)throw new o("sqrtPriceX96 must be positive.");let i=f(n,n,"sqrtPriceX96 squared");return g(i,m,U,"floor").toString()}function C(t){let n="ethAmountWei"in t&&t.ethAmountWei!==void 0?t.ethAmountWei:"ethVolumeWei"in t?t.ethVolumeWei:void 0;if(n===void 0)throw new o("SwapTrade must provide ethAmountWei.");let i=h(n),c=i<0n?-i:i;if(c<=0n)throw new o("SwapTrade ETH volume must be positive.");let r;t.sqrtPriceX96!==void 0&&t.sqrtPriceX96!==""&&t.sqrtPriceX96!=="0"&&(r=BigInt(X(t.sqrtPriceX96)));let s;if(t.oakPerEthE18!==void 0&&t.oakPerEthE18!==""&&(s=e(t.oakPerEthE18)),r!==void 0&&s!==void 0&&r!==s)throw new o("SwapTrade oakPerEthE18 does not match post-swap sqrtPriceX96.");let u=r??s;if(u===void 0||u<=0n)throw new o("SwapTrade must provide a positive post-swap price.");let a=t.timestamp!==void 0&&t.timestamp!==""?e(t.timestamp):void 0;return{volumeWei:c,oakPerEth:u,timestamp:a}}function M(t,n){if(!Array.isArray(t)||t.length===0)throw new o("At least one SwapTrade is required to compute the 30-minute average.");let i=n?.windowEnd!==void 0?e(BigInt(n.windowEnd)):n?.now!==void 0?e(BigInt(n.now)):void 0,c=n?.windowStart!==void 0?e(BigInt(n.windowStart)):i!==void 0?i-BigInt(v):void 0,r=0n,s=0n;for(let u of t){let{volumeWei:a,oakPerEth:d,timestamp:l}=C(u);c!==void 0&&i!==void 0&&l!==void 0&&(l<c||l>=i)||(r+=a*d,s+=a)}if(s<=0n)throw new o("No trades with positive ETH volume fell inside the 30-minute window.");return(r/s).toString()}function st(t,n,i=v){let c=e(BigInt(n)),r=e(BigInt(i));if(r<=0n||c<r)throw new o("Invalid 30-minute observation window bounds.");let s=c-r,u=[],a=0n;for(let l of t){let{volumeWei:D,timestamp:S}=C(l);S!==void 0&&(S<s||S>=c)||(u.push(l),a+=D)}return{oakPerEthE18:M(u),tradeCount:u.length,ethVolumeWei:a.toString(),windowStart:s.toString(),windowEnd:c.toString()}}function ut(t,n){return e(t)<=e(n)}function at(t,n){return e(t)<=e(n)}export{L as a,Y as b,$ as c,Q as d,j as e,v as f,z as g,G as h,J as i,R as j,Z as k,tt as l,nt as m,it as n,et as o,rt as p,ot as q,ct as r,X as s,M as t,st as u,ut as v,at as w};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as $}from"./SXBGOGYQ.js";import{b as ee}from"./UB5U6SI2.js";import{a as D}from"./VBWJOG3N.js";import{a,i as C}from"./5BP72XOA.js";import{a as R}from"./7I6TXFXR.js";import{a as d}from"./Z3FZWNAJ.js";import{a as Z}from"./XN4WDN3O.js";import{encodeFunctionData as U,erc20Abi as oe,getAddress as l,isAddress as te,parseAbi as E}from"viem";var L=l(C[a].hoodlock.locker.address),P=l(C[a].hoodlock.burner.address),y=l(C[a].hoodlock.liquidityLocker.address),F=l(C[a].uniswap.v3_position_manager.address),ne=l(C[a].uniswap.v4_position_manager.address),He="0x000000000000000000000000000000000000dEaD",ge=3153600000n,be=1000000000000n,ie=65535,N=E(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),j=E(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),M=E(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),Ae=E(["function approve(address to, uint256 tokenId)"]);function ve(e,o,n){let s=o.trim();if(s.startsWith("-")){let r=s.slice(1),u=e(r,n);return u==="0"?"0":`-${u}`}return e(s,n)}function re(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(n=>`${ve(e.formatAmount,n.amount,n.token.decimals)} ${n.token.symbol}`).join(", ")}function B(e,o="token"){if(typeof e!="string"||!e.trim())throw new d(`Provide a valid ${o} contract address.`);if(!te(e,{strict:!1}))throw new d(`Identify ${o} by chain and contract address, not by symbol.`);return l(e)}async function _(e,o){try{return await o()}catch(n){throw new d(e.plainError(n))}}function se(e){if(typeof e!="string")throw new d("Amount must be a non-negative integer string in base units.");let o=R(e);if(o<=0n)throw new d("Amount must be greater than zero.");return o}async function ae(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new d("Could not read the current chain timestamp. Please try again.");return o.timestamp}function ce(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new d("unlockTime must be a non-negative integer string in Unix seconds.");let n=BigInt(e.trim());if(n>=be)throw new d("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(n<=o)throw new d(`unlockTime (${n}) must be in the future (greater than current timestamp ${o}).`);let s=o+ge;if(n>s)throw new d(`unlockTime (${n}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${s}).`);return n}async function z(e,o,n=a){let s=l(o),[r,u]=await Promise.all([e.readContract({address:s,abi:oe,functionName:"symbol"}),e.readContract({address:s,abi:oe,functionName:"decimals"})]);return{address:s,symbol:Z(String(r)),decimals:Number(u),chainId:n}}function Te(e,o){if(e==null)return o;let n=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(n)||n<0||n>ie)throw new d("maxCollectFeeBps must be an integer between 0 and 65535.");if(n<o)throw new d(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${n}): collect fee changed.`);return Math.min(n,o)}function ye(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function Le(e,o,n){D(n);let s=l(n);if(o.kind==="v4"||o.version==="v4")throw new d("Uniswap v4 position locks are not supported yet; only Uniswap v3 position locks are enabled.");if(o.acceptUnverifiedHook===!0)throw new d("acceptUnverifiedHook must be false; Uniswap v4 hook position locks are not supported yet.");let r=o.manager!==void 0?B(o.manager,"manager"):F;if(r.toLowerCase()===ne.toLowerCase())throw new d(`Uniswap v4 PositionManager (${ne}) is not supported yet; use Uniswap v3 NonfungiblePositionManager (${F}).`);if(r.toLowerCase()!==F.toLowerCase())throw new d(`Unsupported position manager ${r}; only Uniswap v3 NonfungiblePositionManager (${F}) is supported.`);if(typeof o.tokenId!="string"&&typeof o.tokenId!="number")throw new d("Provide a valid Uniswap v3 NFT tokenId.");let u=String(o.tokenId).trim(),g=R(u);if(typeof o.feeRecipient!="string"||!te(o.feeRecipient,{strict:!1}))throw new d("Provide an explicit feeRecipient address for LP position locks.");let T=l(o.feeRecipient),i=e.clientFor(a),[k,p,m]=await Promise.all([ae(i),i.readContract({address:y,abi:M,functionName:"fixedFee"}),i.readContract({address:y,abi:M,functionName:"collectFeeBps"})]),v=ce(o.unlockTime,k),f=BigInt(p),w=Number(m);if(!Number.isInteger(w)||w<0||w>ie)throw new d(`Invalid on-chain collectFeeBps (${String(m)}).`);if(o.maxFee!==void 0){let h=R(String(o.maxFee));if(f>h)throw new d(`Live fixedFee (${f}) exceeds maxFee (${h}).`)}let b=Te(o.maxCollectFeeBps,w),I=(w/100).toString(),S=e.unsignedTx({to:r,data:U({abi:Ae,functionName:"approve",args:[y,g]}),value:"0",chainId:a,description:`Approve Uniswap v3 position NFT #${g} on ${r} for HoodLock LiquidityLocker ${y}.`}),x=e.unsignedTx({to:y,data:U({abi:M,functionName:"lock",args:[r,g,v,T,!1,b]}),value:f.toString(),chainId:a,description:`Lock Uniswap v3 NFT #${g} in HoodLock LiquidityLocker (${y}) until ${v} with feeRecipient ${T}, upfront fixedFee ${e.formatAmount(f.toString(),$.decimals)} ETH (${f} wei), and ongoing collect fee ${w} bps (${I}% of collected LP fees, frozen per lock).`}),t=[S,x],c=await e.preview(t,s),A=`Approve and lock Uniswap v3 NFT #${g} (manager ${r}) in HoodLock LiquidityLocker ${y} until Unix ${v}. Upfront fixedFee: ${e.formatAmount(f.toString(),$.decimals)} ETH (${f} wei). Ongoing LP fee share: ${w} bps (${I}% of collected LP fees, frozen per lock; maxCollectFeeBps=${b}) with feeRecipient ${T}.`;return{txs:c.txs,summary:A,preview:c,kind:"v3",contract:y,manager:r,tokenId:g.toString(),unlockTime:v.toString(),feeRecipient:T,acceptUnverifiedHook:!1,collectFeeBps:w,maxCollectFeeBps:b,fixedFee:{token:$,amount:f.toString()}}}async function he(e,o,n){D(n);let s=l(n),r=B(o.token,"token"),u=e.clientFor(a),[g,T,i]=await Promise.all([ae(u),u.readContract({address:L,abi:N,functionName:"fee"}),z(u,r,a)]),k=se(o.amount),p=ce(o.unlockTime,g),m=BigInt(T);if(o.maxFee!==void 0){let x=R(String(o.maxFee));if(m>x)throw new d(`Live lock fee (${m}) exceeds maxFee (${x}).`)}let v=e.approval(i.address,L,k.toString(),a),f=e.unsignedTx({to:L,data:U({abi:N,functionName:"lock",args:[i.address,k,p]}),value:m.toString(),chainId:a,description:`Lock ${e.formatAmount(k.toString(),i.decimals)} ${i.symbol} (${k} base units of ${i.address}) in HoodLock Locker ${L} until ${p} with exact fee ${e.formatAmount(m.toString(),$.decimals)} ETH (${m} wei).`}),w=[v,f],b=await e.preview(w,s),I=re(e,b.changes),S=`Approve and lock ${e.formatAmount(k.toString(),i.decimals)} ${i.symbol} (${k} base units of ${i.address}) in HoodLock Locker ${L} until Unix ${p}. Exact fee: ${e.formatAmount(m.toString(),$.decimals)} ETH (${m} wei). Preview changes: ${I}.`;return{txs:b.txs,summary:S,preview:b,kind:"token",contract:L,token:i,amount:k.toString(),unlockTime:p.toString(),fee:{token:$,amount:m.toString()}}}function $e(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Uniswap v3 NonfungiblePositionManager address (0x73991a25C818Bf1f1128dEAaB1492D45638DE0D3)."},tokenId:{type:"string",description:"Uniswap v3 NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a v3 position lock."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,n){return _(e,async()=>ye(o)?Le(e,o,n):he(e,o,n))}}}function Se(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,n){return _(e,async()=>{D(n);let s=l(n),r=B(o.token,"token"),u=e.clientFor(a),[g,T,i]=await Promise.all([u.readContract({address:P,abi:j,functionName:"fee"}),u.readContract({address:P,abi:j,functionName:"DEAD"}),z(u,r,a)]),k=se(o.amount),p=BigInt(g),m=l(T);if(o.maxFee!==void 0){let x=R(String(o.maxFee));if(p>x)throw new d(`Live burn fee (${p}) exceeds maxFee (${x}).`)}let v=e.approval(i.address,P,k.toString(),a),f=e.unsignedTx({to:P,data:U({abi:j,functionName:"burn",args:[i.address,k]}),value:p.toString(),chainId:a,description:`Send ${e.formatAmount(k.toString(),i.decimals)} ${i.symbol} (${k} base units of ${i.address}) to the dead address (${m}) via HoodLock Burner ${P} (totalSupply is unchanged) with exact fee ${e.formatAmount(p.toString(),$.decimals)} ETH (${p} wei).`}),w=[v,f],b=await e.preview(w,s),I=re(e,b.changes),S=`Approve and send ${e.formatAmount(k.toString(),i.decimals)} ${i.symbol} (${k} base units of ${i.address}) to the dead address (${m}) via HoodLock Burner ${P}. Note: tokens are transferred to ${m} and totalSupply is unchanged. Exact fee: ${e.formatAmount(p.toString(),$.decimals)} ETH (${p} wei). Preview changes: ${I}.`;return{txs:b.txs,summary:S,preview:b,contract:P,deadAddress:m,token:i,amount:k.toString(),fee:{token:$,amount:p.toString()},totalSupplyReduced:!1}})}}}async function de(e,o,n){D(o);let s=l(o),r=n?B(n,"token"):void 0,u=e.clientFor(a),g=[],T=new Set,i=t=>{for(let c of t){let A=c.toString();T.has(A)||(T.add(A),g.push(c))}};if(r){let[t,c]=await Promise.all([u.readContract({address:L,abi:N,functionName:"locksByToken",args:[r]}),u.readContract({address:L,abi:N,functionName:"locksByOwner",args:[s]})]);i(t),i(c)}else{let t=await u.readContract({address:L,abi:N,functionName:"locksByOwner",args:[s]});i(t)}let p=(await Promise.all(g.map(async t=>{let c=await u.readContract({address:L,abi:N,functionName:"getLock",args:[t]});return{id:t,owner:l(c[0]),token:l(c[1]),amount:BigInt(c[2]),unlockTime:BigInt(c[3]),withdrawn:!!c[4]}}))).filter(t=>!t.withdrawn&&t.amount>0n&&t.owner.toLowerCase()===s.toLowerCase()&&(!r||t.token.toLowerCase()===r.toLowerCase())),m=new Map,v=async t=>{let c=t.toLowerCase(),A=m.get(c);if(A)return A;let h=await z(u,t,a);return m.set(c,h),h},f=[],w=[];for(let t of p){let c=await v(t.token),A=t.amount.toString(),h=t.unlockTime.toString(),H={token:c,amount:A};f.push({lockId:t.id.toString(),kind:"token",contract:L,chainId:a,owner:t.owner,token:c,amount:A,asset:H,unlockTime:h,withdrawn:!1}),w.push({module:"hoodlock",id:`lock:${t.id.toString()}`,chainId:a,assets:[H],description:`HoodLock token lock #${t.id} of ${e.formatAmount(A,c.decimals)} ${c.symbol} (${c.address}) until Unix ${h}.`})}let b=await u.readContract({address:y,abi:M,functionName:"locksOf",args:[s]}),I=[...new Set(b.map(t=>t.toString()))].map(t=>BigInt(t)),S=[];for(let t of I){let c=await u.readContract({address:y,abi:M,functionName:"getLock",args:[t]}),[A,h,H,ue,le,me,ke,pe,fe,we]=c,V=l(A);if(me||ue||V.toLowerCase()!==s.toLowerCase())continue;let K=l(pe),W=l(fe);if(r&&K.toLowerCase()!==r.toLowerCase()&&W.toLowerCase()!==r.toLowerCase())continue;let[G,X]=await Promise.all([v(K),v(W)]),Q=l(ke),Y=Number(H),J=BigInt(h).toString(),q=BigInt(we).toString();S.push({lockId:t.toString(),kind:"v3",contract:y,manager:F,chainId:a,owner:V,tokenId:q,unlockTime:J,collectFeeBps:Y,feeRecipient:Q,hookVerified:!!le,token0:G,token1:X,withdrawn:!1}),w.push({module:"hoodlock",id:`lp-lock:${t.toString()}`,chainId:a,assets:[{token:{address:F,symbol:`UNI-V3 #${q}`,decimals:0,chainId:a},amount:"1"}],description:`HoodLock Uniswap v3 LP lock #${t} (NFT #${q}, ${G.symbol}/${X.symbol}, feeRecipient ${Q}, collectFeeBps ${Y}) until Unix ${J}. One NFT held in LiquidityLocker custody for ${V}. Underlying token amounts are not valued.`})}let x=`Found ${f.length} active token lock(s) and ${S.length} active Uniswap v3 LP lock(s) for ${s}.`;return{locks:f,lpLocks:S,positions:w,summary:x}}function xe(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,n){let s=o.owner!==void 0?B(o.owner,"owner"):l(n),r=o.token!==void 0?B(o.token,"token"):void 0;return _(e,()=>de(e,s,r))}}}function Ie(e){return async o=>(await _(e,()=>de(e,o))).positions}var O=e=>({tools:[$e(e),Se(e),xe(e)],positions:Ie(e)}),Ue=O,Ee=O,_e=e=>ee("hoodlock",[O(e)]),Oe=O;export{L as a,P as b,y as c,F as d,ne as e,He as f,ge as g,ve as h,$e as i,Se as j,xe as k,Ie as l,O as m,Ue as n,Ee as o,_e as p,Oe as q};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as i,b as c}from"./XN4WDN3O.js";var a=class extends Error{name="OakError"};function u(e){let n=[],s=new Set;for(;e&&typeof e=="object"&&!s.has(e)&&n.length<16;){s.add(e);let o=e;n.push(o),e=o.cause}return n}function r(e,...n){return u(e).some(s=>typeof s.code=="number"&&n.includes(s.code))}function d(e){return u(e).some(n=>typeof n.message=="string"&&/insufficient funds for gas \* price \+ value/i.test(n.message))}function g(e){if(e instanceof a)return c(e.message)||e.message.length>1024?i(e.message):e.message;let n=u(e),s=n.find(t=>t instanceof a&&/^(?:The RPC request timed out\. Please try again\.|The RPC endpoint returned malformed JSON\.|The RPC endpoint returned HTTP [1-5]\d{2}\. Please try again\.|The RPC endpoint is busy; retry in [1-9]\d* seconds\.)$/.test(t.message));if(s)return String(s.message);if(n.some(t=>t.name==="TimeoutError"))return"The request timed out. Please try again.";if(n.some(t=>t.name==="AbortError"))return"The request was cancelled.";if(r(e,4001))return"The request was declined.";if(r(e,-32601,-32004))return"This endpoint does not support the requested operation.";let o=n.map(t=>typeof t.message=="string"?t.message:"").join(" ");return d(e)?"Insufficient funds for the simulation gas budget. Check wallet ETH and the endpoint or fork block gas limit; no transaction was sent.":/revert/i.test(o)||r(e,3)?"The contract call reverted.":/fetch failed|ECONNREFUSED|ENOTFOUND|network/i.test(o)?"The service could not be reached. Please try again.":"The request failed. Please try again."}export{a,r as b,d as c,g as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as K,o as de}from"./XEN45QST.js";import{a as E,b as ae}from"./VBWJOG3N.js";import{a as g,i as M}from"./5BP72XOA.js";import{a as ke}from"./XAB4OIE3.js";import{a as _,c as be}from"./7I6TXFXR.js";import{a as d,b as j,d as S}from"./Z3FZWNAJ.js";import{decodeFunctionResult as ve,encodeFunctionData as L,getAddress as m,parseAbi as G,zeroAddress as Y}from"viem";var ce=-887272,ue=887272,O=(1n<<128n)-1n,Ce="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",Le="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Ne="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",Q=2000n,qe=5,$e=1800n,f=Object.freeze({factory:m(M[4663].uniswap.v3_factory.address),positionManager:m(M[4663].uniswap.v3_position_manager.address),swapRouter02:m(M[4663].uniswap.swap_router02.address),permit2:m(M[4663].uniswap.permit2.address),weth:m(M[4663].uniswap.WETH.address),usdg:m(M[4663].uniswap.USDG.address),ethUsdgPool:m(M[4663].oracle.ethUsdgPool.address)}),_e=Object.freeze({100:1,500:10,3e3:60,1e4:200}),rn=Object.freeze([{fee:100,tickSpacing:1,address:m("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:f.weth,token1:f.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:m("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:f.weth,token1:f.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:m("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:f.weth,token1:f.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:m("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:f.weth,token1:f.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),v=G(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable"]),Ie=G(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),Ee=G(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),Oe=G(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),me=G(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),Re="0xd0e30db0";function Be(n){if(typeof n!="string")return!1;let e=n.trim().toLowerCase();return e===Y||e===Ce||e==="eth"||e==="native"}function R(n,e){if(Be(n))throw new d(`Uniswap v3 requires wrapped ERC-20 WETH (${f.weth}) rather than native ETH in ${e}.`);if(typeof n!="string")throw new d(`${e} must be a valid 20-byte hex address.`);return E(n),m(n)}function De(n,e,t){let r=Number(n),o=Number(e),i=Number(t);if(!Number.isInteger(i)||i<=0)throw new d("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(r)||!Number.isInteger(o))throw new d("Uniswap v3 tickLower and tickUpper must be integers.");if(r<ce||o>ue||r>ue||o<ce)throw new d(`Uniswap v3 ticks are out of bounds [${ce}, ${ue}].`);if(r>=o)throw new d("Uniswap v3 tickLower must be strictly less than tickUpper.");if(r%i!==0||o%i!==0)throw new d(`Uniswap v3 tickLower (${r}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:r,tickUpper:o,tickSpacing:i}}function Ve(n,e){let t=n.trim(),r=t.startsWith("-"),o=r||t.startsWith("+")?t.slice(1):t,i=be(_(o).toString(),e);return r&&i!=="0"?`-${i}`:i}function He(n){let e=typeof n=="string"?ve({abi:v,functionName:"positions",data:n}):n;return{nonce:BigInt(e[0]),operator:m(String(e[1])),token0:m(String(e[2])),token1:m(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function ye(n,e){if(!n||!Array.isArray(n.logs))return[];let t=e?m(e).toLowerCase():void 0,r=f.positionManager.toLowerCase(),o=new Set;for(let i of n.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==r)continue;let s=Array.isArray(i.topics)?i.topics.map(u=>String(u).toLowerCase()):[],a=s[0];if(a===Le&&s.length>=4){let c=`0x${s[2].slice(-40)}`;if(!t||c===t){let p=BigInt(s[3]).toString();p!=="0"&&o.add(p)}}else if(a===Ne&&s.length>=2&&!t){let u=BigInt(s[1]).toString();u!=="0"&&o.add(u)}}return[...o]}function sn(n){let e=t=>typeof t=="bigint"?t:_(t);return L({abi:Oe,functionName:"exactInputSingle",args:[{tokenIn:m(n.tokenIn),tokenOut:m(n.tokenOut),fee:n.fee,recipient:m(n.recipient),amountIn:e(n.amountIn),amountOutMinimum:e(n.amountOutMinimum),sqrtPriceLimitX96:n.sqrtPriceLimitX96!==void 0?e(n.sqrtPriceLimitX96):0n}]})}var he=1n<<96n;function xe(n){let e=Math.abs(n),t=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=((1n<<256n)-1n)/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}function We(n,e,t,r){if(r<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<t?[e,t]:[t,e];if(n<=o)return{amount0:(r<<96n)*(i-o)/i/o,amount1:0n};if(n<i){let a=(r<<96n)*(i-n)/i/n,u=r*(n-o)/he;return{amount0:a,amount1:u}}return{amount0:0n,amount1:r*(i-o)/he}}async function U(n,e,t,r){let o=m(e),i,s;if(t===g&&o===f.weth?(i=18,s="WETH"):t===g&&o===f.usdg&&(i=6,s="USDG"),i===void 0){let a=await n.readContract({address:o,abi:me,functionName:"decimals"});i=Number(a)}if(s===void 0)try{let a=await n.readContract({address:o,abi:me,functionName:"symbol"});if(typeof a!="string"||!a.trim())throw new d("Token symbol is unavailable.");s=a.trim()}catch(a){throw new d(`Could not read token metadata. ${S(a)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new d("Token decimals are invalid.");if(r!=null){let a=Number(r);if(!Number.isInteger(a)||a!==i)throw new d(`Token ${o} on chain ${t} has ${i} decimals, not ${String(r)}.`)}return{address:o,symbol:s,decimals:i,chainId:t}}async function Fe(n){try{if(!n.getBlock)throw new d("Block timestamps are unavailable.");let e=await n.getBlock();if(typeof e.timestamp!="bigint")throw new d("Invalid block timestamp.");return e.timestamp}catch(e){throw new d(`Could not read the current block timestamp. ${S(e)}`)}}function X(n,e){if(typeof n=="bigint"){if(n<0n)throw new d(`${e} must be a non-negative integer.`);return n}if(typeof n=="number"){if(!Number.isSafeInteger(n)||n<0)throw new d(`${e} must be a non-negative integer.`);return BigInt(n)}if(typeof n=="string")return _(n);throw new d(`${e} must be a non-negative integer.`)}async function Se(n,e){let t=await Fe(n);if(e==null)return t+$e;let r=X(e,"deadline");if(r<=t)throw new d(`Uniswap v3 deadline (${r.toString()}) has expired at timestamp ${t.toString()}.`);return r}function B(n,e){if(typeof n!="string"||!/^\d+$/.test(n))throw new d(`${e} must be a non-negative integer string in base units.`);return _(n)}function Ae(n){let e=n.slippageBps??K;if(typeof e!="number")throw new d("Slippage must be an integer from 0 to 9999 bps.");return de("0",e),e}function J(n,e,t,r){let o=n===void 0?_(de(e.toString(),t)):B(n,r);if(o<=1n)throw new d(`${r} must exceed 1 base unit; the simulated amount may be too small.`);return o}function F(n,e){return ae({to:f.positionManager,data:n,value:"0",chainId:g,description:e})}async function Z(n,e,t){try{if(!n.request)throw new d("Sequential transaction simulation is unavailable.");let o=await n.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:t,gas:`0x${ke.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new d("Unexpected batch simulation response.");return o[0].calls.map((i,s)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new d(`Simulation call ${s+1} failed. ${S(i.error)}`);return i.returnData})}catch(r){throw new d(`Uniswap v3 simulation failed. ${S(r)}`)}}function ee(n,e){try{return ve({abi:v,functionName:n,data:e})}catch{throw new d(`Uniswap v3 ${n} simulation returned invalid amounts.`)}}function z(n,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==g)throw new d(`Uniswap v3 is only supported on Robinhood Chain (${g}).`);if(e.version!==void 0&&e.version!=="v3")throw new d(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let t=n.clientFor(g);return{...t,readContract:async r=>{try{return await t.readContract(r)}catch(o){throw new d(`Could not read Uniswap v3 ${r.functionName}. ${S(o)}`,{cause:o})}}}}async function fe(n,e,t){let r;try{r=await n.readContract({address:f.positionManager,abi:v,functionName:"ownerOf",args:[e]})}catch(s){throw new d(`Could not verify owner of Uniswap v3 position #${e}. ${S(s)}`)}let o=m(String(r)),i=m(t);if(o!==i)throw new d(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function ne(n,e){let t=await n.readContract({address:f.positionManager,abi:v,functionName:"positions",args:[e]});return He(t)}function pe(n,e){if(!Array.isArray(e.changes)||!e.changes.length)return n;let t=e.changes.map(r=>`${Ve(r.amount,r.token.decimals)} ${r.token.symbol}`);return`${n} (${t.join(", ")})`}async function Ge(n,e,t){E(t);let r=m(t),o=z(n,e),i=await Se(o,e.deadline),s=Ae(e),a=e.tokenId===void 0?void 0:X(e.tokenId,"tokenId"),u;if(a!==void 0){if(a<=0n)throw new d("Uniswap v3 tokenId must be a positive integer.");await fe(o,a,r),u=await ne(o,a)}let c=u?.token0??R(e.token0,"token0"),p=u?.token1??R(e.token1,"token1");if(BigInt(c)>=BigInt(p))throw new d("Uniswap v3 requires distinct sorted token addresses.");let w=u?.fee??Number(e.fee??100),l=_e[w];if(!l)throw new d("Unsupported Uniswap v3 fee tier.");let y=m(String(await o.readContract({address:f.factory,abi:Ie,functionName:"getPool",args:[c,p,w]})));if(y===Y)throw new d("No Uniswap v3 pool exists for these tokens and fee tier.");let{tickLower:h,tickUpper:T,tickSpacing:N}=De(u?.tickLower??e.tickLower,u?.tickUpper??e.tickUpper,l),A=await U(o,c,g,e.token0Decimals),b=await U(o,p,g,e.token1Decimals),k=B(e.amount0Desired,"amount0Desired"),x=B(e.amount1Desired,"amount1Desired");if(k===0n&&x===0n)throw new d("Liquidity addition requires a positive desired amount.");let P=e.recipient===void 0?r:R(e.recipient,"recipient");if(P!==r)throw new d("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&c!==f.weth&&p!==f.weth)throw new d("Wrapping requires a positive WETH desired amount.");let D=await Promise.all([c,p].map(async C=>BigInt(await o.readContract({address:C,abi:me,functionName:"allowance",args:[r,f.positionManager]})))),q=(C,H)=>{let re=[];if(e.wrapNative===!0){let W=c===f.weth?C:H;W>0n&&re.push(ae({to:f.weth,data:Re,value:W.toString(),chainId:g,description:"Wrap ETH into WETH."}))}for(let[W,Te]of[c,p].entries()){let se=W===0?C:H;se>0n&&D[W]<se&&re.push(n.approval(Te,f.positionManager,se.toString(),g))}return re},$=a===void 0?"mint":"increaseLiquidity",le=(C,H)=>F(a===void 0?L({abi:v,functionName:"mint",args:[{token0:c,token1:p,fee:w,tickLower:h,tickUpper:T,amount0Desired:k,amount1Desired:x,amount0Min:C,amount1Min:H,recipient:P,deadline:i}]}):L({abi:v,functionName:"increaseLiquidity",args:[{tokenId:a,amount0Desired:k,amount1Desired:x,amount0Min:C,amount1Min:H,deadline:i}]}),`${$==="mint"?"Mint":"Increase"} Uniswap v3 ${A.symbol}/${b.symbol} liquidity.`),ge=await Z(o,[...q(k,x),le(0n,0n)],r),I=ee($,ge[ge.length-1]),Me=I[I.length-2],Ue=I[I.length-1];if(Me>k||Ue>x)throw new d("Simulated liquidity spend exceeds the desired amounts.");let V=q(k,x),ie=J(e.amount0Min,I[I.length-2],s,"amount0Min"),oe=J(e.amount1Min,I[I.length-1],s,"amount1Min");if(ie>k||oe>x)throw new d("Uniswap v3 minimum amount cannot exceed desired amount.");V.push(le(ie,oe));let we=await n.preview(V,r);return{txs:V,preview:we,summary:pe(V[V.length-1].description,we),details:{version:"v3",action:$,...a===void 0?{}:{tokenId:a.toString()},pool:y,fee:w,tickSpacing:N,tickLower:h,tickUpper:T,token0:A,token1:b,amount0Desired:k.toString(),amount1Desired:x.toString(),amount0Min:ie.toString(),amount1Min:oe.toString(),deadline:i.toString(),recipient:P,expectedAmount0:I[I.length-2].toString(),expectedAmount1:I[I.length-1].toString()}}}async function Xe(n,e,t){E(t);let r=m(t),o=z(n,e),i=X(e.tokenId,"tokenId");if(i<=0n)throw new d("Uniswap v3 tokenId must be a positive integer.");await fe(o,i,r);let s=await ne(o,i),a=await U(o,s.token0,g),u=await U(o,s.token1,g),c=e.recipient===void 0?r:R(e.recipient,"recipient");if(c!==r)throw new d("Uniswap recipient must be the signing wallet.");let p=e.amount0Max===void 0?O:B(e.amount0Max,"amount0Max"),w=e.amount1Max===void 0?O:B(e.amount1Max,"amount1Max");if(p===0n&&w===0n||p>O||w>O)throw new d("Collect requires a positive amountMax within uint128.");let l=[F(L({abi:v,functionName:"collect",args:[{tokenId:i,recipient:c,amount0Max:p,amount1Max:w}]}),`Collect Uniswap v3 fees from position #${i}.`)],y=ee("collect",(await Z(o,l,r))[0]),h=await n.preview(l,r);return{txs:l,preview:h,summary:pe(l[0].description,h),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:c,token0:a,token1:u,amount0Max:p.toString(),amount1Max:w.toString(),expectedAmount0:y[0].toString(),expectedAmount1:y[1].toString()}}}async function ze(n,e,t){E(t);let r=m(t),o=z(n,e),i=X(e.tokenId,"tokenId");if(i<=0n)throw new d("Uniswap v3 tokenId must be a positive integer.");await fe(o,i,r);let s=await ne(o,i);if(s.liquidity<=0n)throw new d("Position has zero active liquidity to remove.");if(e.liquidity===void 0)throw new d('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let a=e.liquidity==="all"?s.liquidity:B(e.liquidity,"liquidity");if(a<=0n)throw new d("Liquidity to remove must be positive.");if(a>s.liquidity)throw new d("Requested liquidity exceeds position liquidity.");let u=await Se(o,e.deadline),c=Ae(e),p=await U(o,s.token0,g),w=await U(o,s.token1,g),l=e.recipient===void 0?r:R(e.recipient,"recipient");if(l!==r)throw new d("Uniswap recipient must be the signing wallet.");let y=(D,q)=>F(L({abi:v,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:a,amount0Min:D,amount1Min:q,deadline:u}]}),`Decrease ${a} liquidity on Uniswap v3 position #${i}.`),h=ee("decreaseLiquidity",(await Z(o,[y(0n,0n)],r))[0]),T=J(e.amount0Min,h[0],c,"amount0Min"),N=J(e.amount1Min,h[1],c,"amount1Min"),A=[y(T,N),F(L({abi:v,functionName:"collect",args:[{tokenId:i,recipient:l,amount0Max:O,amount1Max:O}]}),`Collect principal and fees from Uniswap v3 position #${i}.`)],b=a===s.liquidity,k=b&&e.burn===!0;k&&A.push(F(L({abi:v,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let x=ee("collect",(await Z(o,A,r))[1]),P=await n.preview(A,r);return{txs:A,preview:P,summary:pe(`Remove Uniswap v3 liquidity from position #${i}${k?" and burn NFT":""}`,P),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:l,token0:p,token1:w,liquidityRemoved:a.toString(),amount0Min:T.toString(),amount1Min:N.toString(),deadline:u.toString(),expectedAmount0:x[0].toString(),expectedAmount1:x[1].toString(),fullExit:b,burned:k}}}async function je(n,e,t={}){let r=m(e),o=new Set;if(Array.isArray(t.tokenIds))for(let s of t.tokenIds){let a=X(s,"tokenId");a>0n&&o.add(a.toString())}if(Array.isArray(t.receipts))for(let s of t.receipts)for(let a of ye(s,r))o.add(a);let i=!1;try{let s=BigInt(await n.readContract({address:f.positionManager,abi:v,functionName:"balanceOf",args:[r]})),a=s>64n?64n:s;for(let u=0n;u<a;u++){try{let c=BigInt(await n.readContract({address:f.positionManager,abi:v,functionName:"tokenOfOwnerByIndex",args:[r,u]}));c>0n&&o.add(c.toString())}catch(c){if(!j(c,3,-32601,-32004))throw c;break}u+1n===s&&(i=!0)}s===0n&&(i=!0)}catch(s){if(!j(s,3,-32601,-32004))throw s}if(typeof n.getLogs=="function"&&typeof n.getBlockNumber=="function")try{let s=t.toBlock??await n.getBlockNumber(),a=t.maxChunks??qe,u=t.fromBlock??(s>Q*BigInt(a)?s-Q*BigInt(a)+1n:0n),c=s,p=0;for(;c>=u&&p<a;){let w=c>=Q-1n?c-(Q-1n):0n,l=w<u?u:w,y=await n.getLogs({address:f.positionManager,fromBlock:l,toBlock:c});for(let h of ye({logs:y},r))o.add(h);if(p+=1,l===0n||l<=u)break;c=l-1n}}catch(s){throw new d(`Could not discover Uniswap v3 positions from logs. ${S(s)}`)}else if(!i&&t.tokenIds===void 0&&t.receipts===void 0)throw new d("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(s=>BigInt(s)).sort((s,a)=>s<a?-1:s>a?1:0)}async function Pe(n,e,t={}){E(e);let r=m(e),o=z(n),i=await je(o,r,t),s=[];for(let a of i){let u;try{let b=await o.readContract({address:f.positionManager,abi:v,functionName:"ownerOf",args:[a]});u=m(String(b))}catch(b){if(j(b,3))continue;throw new d(`Could not verify owner of position #${a}. ${S(b)}`)}if(u!==r)continue;let c;try{c=await ne(o,a)}catch(b){throw new d(`Could not read position #${a}. ${S(b)}`)}if(c.liquidity===0n&&c.tokensOwed0===0n&&c.tokensOwed1===0n&&!t.includeEmpty)continue;let w=await U(o,c.token0,g),l=await U(o,c.token1,g),y=0n,h=0n;if(c.liquidity>0n)try{let b=await o.readContract({address:f.factory,abi:Ie,functionName:"getPool",args:[c.token0,c.token1,c.fee]}),k=m(String(b));if(k===Y)throw new d("Position pool was not found.");if(k!==Y){let x=await o.readContract({address:k,abi:Ee,functionName:"slot0"}),P=BigInt(x[0]);if(P<=0n)throw new d("Position pool has no initialized price.");let D=xe(c.tickLower),q=xe(c.tickUpper),$=We(P,D,q,c.liquidity);y=$.amount0,h=$.amount1}}catch(b){throw new d(`Could not value Uniswap v3 position #${a}. ${S(b)}`)}let T=y+c.tokensOwed0,N=h+c.tokensOwed1,A=[{token:w,amount:T.toString()},{token:l,amount:N.toString()}];s.push({module:"uniswap",id:`uniswap:v3:${a.toString()}`,chainId:g,assets:A,description:`Uniswap v3 LP position #${a.toString()} (${w.symbol}/${l.symbol} fee ${c.fee} ticks [${c.tickLower}, ${c.tickUpper}] liquidity ${c.liquidity.toString()})`})}return s}async function Ke(n,e,t){z(n,e);let r=e.wallet!==void 0?R(e.wallet,"wallet"):m(t),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,s=e.includeEmpty===!0,a=await Pe(n,r,{tokenIds:o,receipts:i,includeEmpty:s});return{positions:a,details:{version:"v3",wallet:r,count:a.length,positionManager:f.positionManager}}}function Qe(n){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{type:"integer",enum:[100,500,3e3,1e4],default:100},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:"Desired token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:K},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."}}},execute:(i,s)=>Ge(n,i,s)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},required:["tokenId"]},execute:(i,s)=>Xe(n,i,s)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:K},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity."}},required:["tokenId"]},execute:(i,s)=>ze(n,i,s)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet from NFT receipts and Transfer logs.",properties:{version:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect."}}},execute:(i,s)=>Ke(n,i,s)}]}var te=n=>({tools:Qe(n),positions:e=>Pe(n,e)}),an=te,dn=te,cn=te,un=te;export{ce as a,ue as b,O as c,f as d,_e as e,rn as f,v as g,Ie as h,Ee as i,Oe as j,De as k,Ve as l,He as m,ye as n,sn as o,Ge as p,Xe as q,ze as r,Pe as s,Ke as t,Qe as u,te as v,an as w,dn as x,cn as y,un as z};
|