@oakagentkit/core 0.2.6 → 0.3.0
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/abort-scope.d.ts +2 -0
- package/build/dist/api/abort-scope.js +1 -0
- package/build/dist/api/addresses.d.ts +9 -0
- package/build/dist/api/addresses.js +1 -1
- package/build/dist/api/chain.d.ts +4 -0
- package/build/dist/api/chain.js +1 -1
- 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/metadata.js +1 -1
- package/build/dist/api/modules/beefy/boosts.js +1 -1
- package/build/dist/api/modules/beefy/clm.js +1 -1
- package/build/dist/api/modules/beefy/guard.js +1 -1
- package/build/dist/api/modules/beefy/index.js +1 -1
- package/build/dist/api/modules/beefy/liquidity.js +1 -1
- package/build/dist/api/modules/beefy/management.js +1 -1
- package/build/dist/api/modules/beefy/vaults.js +1 -1
- package/build/dist/api/modules/borro/abi.d.ts +54 -0
- package/build/dist/api/modules/borro/abi.js +1 -1
- package/build/dist/api/modules/borro/actions.d.ts +14 -1
- package/build/dist/api/modules/borro/actions.js +1 -1
- package/build/dist/api/modules/borro/checks.js +1 -1
- package/build/dist/api/modules/borro/copy.d.ts +23 -10
- package/build/dist/api/modules/borro/copy.js +1 -1
- package/build/dist/api/modules/borro/index.js +1 -1
- package/build/dist/api/modules/borro/liquidity.js +1 -1
- package/build/dist/api/modules/borro/pins.d.ts +30 -14
- package/build/dist/api/modules/borro/pins.js +1 -1
- package/build/dist/api/modules/borro/positions.js +1 -1
- package/build/dist/api/modules/borro/reader.js +1 -1
- package/build/dist/api/modules/borro/types.d.ts +1 -0
- package/build/dist/api/modules/chop/abi.d.ts +31 -0
- package/build/dist/api/modules/chop/abi.js +1 -1
- package/build/dist/api/modules/chop/actions.js +1 -1
- package/build/dist/api/modules/chop/checks.d.ts +13 -5
- package/build/dist/api/modules/chop/checks.js +1 -1
- package/build/dist/api/modules/chop/copy.d.ts +11 -1
- package/build/dist/api/modules/chop/copy.js +1 -1
- package/build/dist/api/modules/chop/guard.js +1 -1
- package/build/dist/api/modules/chop/index.js +1 -1
- package/build/dist/api/modules/chop/positions.js +1 -1
- package/build/dist/api/modules/chop/reader.d.ts +132 -7
- package/build/dist/api/modules/chop/reader.js +1 -1
- package/build/dist/api/modules/chop/types.d.ts +12 -0
- package/build/dist/api/modules/clanker/extensions.d.ts +9 -0
- package/build/dist/api/modules/clanker/extensions.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/clanker/manage.js +1 -1
- package/build/dist/api/modules/clanker/pool-config.d.ts +15 -0
- package/build/dist/api/modules/clanker/pool-config.js +1 -1
- package/build/dist/api/modules/clanker/protocol.js +1 -1
- package/build/dist/api/modules/clanker/state.js +1 -1
- package/build/dist/api/modules/earn/copy.d.ts +36 -14
- package/build/dist/api/modules/earn/copy.js +1 -1
- package/build/dist/api/modules/earn/cost.d.ts +11 -1
- package/build/dist/api/modules/earn/cost.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/earn/lp.d.ts +14 -1
- package/build/dist/api/modules/earn/lp.js +1 -1
- package/build/dist/api/modules/earn/options.d.ts +6 -4
- package/build/dist/api/modules/earn/options.js +1 -1
- package/build/dist/api/modules/erc8004/common.d.ts +1 -1
- package/build/dist/api/modules/erc8004/common.js +1 -1
- package/build/dist/api/modules/erc8004/domain.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/erc8004/management.js +1 -1
- package/build/dist/api/modules/erc8004/reputation.js +1 -1
- package/build/dist/api/modules/erc8004/services.js +1 -1
- package/build/dist/api/modules/erc8004/thesis.d.ts +61 -0
- package/build/dist/api/modules/erc8004/thesis.js +1 -0
- package/build/dist/api/modules/erc8004/validation.js +1 -1
- package/build/dist/api/modules/factor/abi.d.ts +642 -0
- package/build/dist/api/modules/factor/abi.js +1 -0
- package/build/dist/api/modules/factor/actions.d.ts +15 -0
- package/build/dist/api/modules/factor/actions.js +1 -0
- package/build/dist/api/modules/factor/api.d.ts +7 -0
- package/build/dist/api/modules/factor/api.js +1 -0
- package/build/dist/api/modules/factor/checks.d.ts +11 -0
- package/build/dist/api/modules/factor/checks.js +1 -0
- package/build/dist/api/modules/factor/copy.d.ts +33 -0
- package/build/dist/api/modules/factor/copy.js +1 -0
- package/build/dist/api/modules/factor/guard.d.ts +12 -0
- package/build/dist/api/modules/factor/guard.js +1 -0
- package/build/dist/api/modules/factor/index.d.ts +16 -0
- package/build/dist/api/modules/factor/index.js +8 -0
- package/build/dist/api/modules/factor/messages.d.ts +46 -0
- package/build/dist/api/modules/factor/messages.js +1 -0
- package/build/dist/api/modules/factor/pins.d.ts +64 -0
- package/build/dist/api/modules/factor/pins.js +1 -0
- package/build/dist/api/modules/factor/reader.d.ts +17 -0
- package/build/dist/api/modules/factor/reader.js +1 -0
- package/build/dist/api/modules/factor/types.d.ts +18 -0
- package/build/dist/api/modules/factor/types.js +0 -0
- package/build/dist/api/modules/gloam/copy.d.ts +4 -3
- package/build/dist/api/modules/gloam/copy.js +2 -2
- package/build/dist/api/modules/gloam/index.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.d.ts +29 -1
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/heyresearch/scan.js +1 -1
- package/build/dist/api/modules/heyresearch/status-labels.d.ts +2 -0
- package/build/dist/api/modules/heyresearch/status-labels.js +1 -1
- package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
- package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
- package/build/dist/api/modules/hoodag/index.d.ts +12 -1
- package/build/dist/api/modules/hoodag/index.js +1 -1
- package/build/dist/api/modules/hoodag/management.js +1 -1
- package/build/dist/api/modules/hoodag/public-reads.js +1 -1
- package/build/dist/api/modules/hoodag/reconstruct.d.ts +14 -0
- package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/buyback.js +1 -1
- package/build/dist/api/modules/hoodlock/commerce.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/addons.js +1 -1
- package/build/dist/api/modules/hookr/agent-gate.js +1 -1
- package/build/dist/api/modules/hookr/contracts.d.ts +2 -1
- package/build/dist/api/modules/hookr/contracts.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.d.ts +2 -0
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/hookr/revenue.js +1 -1
- package/build/dist/api/modules/kyberswap/index.d.ts +2 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
- package/build/dist/api/modules/layerbank/abi.js +1 -1
- package/build/dist/api/modules/layerbank/actions.js +1 -1
- package/build/dist/api/modules/layerbank/checks.js +1 -1
- package/build/dist/api/modules/layerbank/index.js +1 -1
- package/build/dist/api/modules/layerbank/merkl.js +1 -1
- package/build/dist/api/modules/layerbank/reader.js +1 -1
- package/build/dist/api/modules/layerbank/reserve.js +1 -1
- package/build/dist/api/modules/lighter/index.js +1 -1
- package/build/dist/api/modules/longbow/administration.js +1 -1
- package/build/dist/api/modules/longbow/analytics.js +1 -1
- package/build/dist/api/modules/longbow/fixed.js +1 -1
- package/build/dist/api/modules/longbow/index.js +1 -1
- package/build/dist/api/modules/longbow/nft.js +1 -1
- package/build/dist/api/modules/longbow/rebates.js +1 -1
- package/build/dist/api/modules/longbow/staking.js +1 -1
- package/build/dist/api/modules/meridian/index.js +1 -1
- package/build/dist/api/modules/meridian/markets.js +1 -1
- package/build/dist/api/modules/meridian/perps-batch.js +1 -1
- package/build/dist/api/modules/meridian/perps-stream.js +1 -1
- package/build/dist/api/modules/meridian/perps.js +1 -1
- package/build/dist/api/modules/meridian/predict-read.js +1 -1
- package/build/dist/api/modules/meridian/rfq.js +1 -1
- package/build/dist/api/modules/merkl/discovery.js +1 -1
- package/build/dist/api/modules/merkl/index.js +1 -1
- package/build/dist/api/modules/merkl/manage.js +1 -1
- package/build/dist/api/modules/merkl/protocol.js +1 -1
- package/build/dist/api/modules/morpho/allocator.js +1 -1
- package/build/dist/api/modules/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.js +1 -1
- package/build/dist/api/modules/morpho/midnight.js +1 -1
- package/build/dist/api/modules/morpho/protocol.js +1 -1
- package/build/dist/api/modules/morpho/vault-management.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/morpho/vault-v2.d.ts +2 -0
- package/build/dist/api/modules/morpho/vault-v2.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-policy.d.ts +1 -0
- package/build/dist/api/modules/netnet/card-policy.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/desk-read.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/netnet/staking.js +1 -1
- package/build/dist/api/modules/orbio/gateway.js +1 -1
- package/build/dist/api/modules/orbio/index.d.ts +6 -0
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/orbio/positions.js +1 -1
- package/build/dist/api/modules/pendle/convert.js +1 -1
- package/build/dist/api/modules/pendle/costs.js +1 -1
- package/build/dist/api/modules/pendle/index.js +1 -1
- package/build/dist/api/modules/pendle/markets.js +1 -1
- package/build/dist/api/modules/pendle/positions.js +1 -1
- package/build/dist/api/modules/pendle/pricecheck.js +1 -1
- package/build/dist/api/modules/pendle/reader.js +1 -1
- package/build/dist/api/modules/pendle/redeem.js +1 -1
- package/build/dist/api/modules/pendle/trade.js +1 -1
- package/build/dist/api/modules/pendle/validate.js +1 -1
- package/build/dist/api/modules/pendle/verify.js +1 -1
- package/build/dist/api/modules/pons/claim.js +1 -1
- package/build/dist/api/modules/pons/holder-directory.js +1 -1
- package/build/dist/api/modules/pons/index.js +1 -1
- package/build/dist/api/modules/pons/launch-status.js +1 -1
- package/build/dist/api/modules/pons/prices.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/swap-terms.js +1 -1
- package/build/dist/api/modules/pons/trade.d.ts +3 -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.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/features.js +1 -1
- package/build/dist/api/modules/priors/holdings.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.d.ts +1 -0
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/market.js +1 -1
- package/build/dist/api/modules/priors/pt.js +1 -1
- package/build/dist/api/modules/priors/savings-exit.js +1 -1
- package/build/dist/api/modules/priors/starter-line.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/raeto/authorization.d.ts +30 -0
- package/build/dist/api/modules/raeto/authorization.js +1 -0
- package/build/dist/api/modules/raeto/copy.d.ts +46 -0
- package/build/dist/api/modules/raeto/copy.js +1 -0
- package/build/dist/api/modules/raeto/errors.d.ts +4 -0
- package/build/dist/api/modules/raeto/errors.js +1 -0
- package/build/dist/api/modules/raeto/estimate.d.ts +2 -0
- package/build/dist/api/modules/raeto/estimate.js +1 -0
- package/build/dist/api/modules/raeto/index.d.ts +16 -0
- package/build/dist/api/modules/raeto/index.js +1 -0
- package/build/dist/api/modules/raeto/pairing.d.ts +40 -0
- package/build/dist/api/modules/raeto/pairing.js +1 -0
- package/build/dist/api/modules/raeto/pins.d.ts +24 -0
- package/build/dist/api/modules/raeto/pins.js +1 -0
- package/build/dist/api/modules/raeto/templates.d.ts +22 -0
- package/build/dist/api/modules/raeto/templates.js +1 -0
- package/build/dist/api/modules/raeto/terms.d.ts +8 -0
- package/build/dist/api/modules/raeto/terms.js +1 -0
- package/build/dist/api/modules/raeto/types.d.ts +64 -0
- package/build/dist/api/modules/raeto/types.js +0 -0
- package/build/dist/api/modules/relay/api.d.ts +16 -0
- package/build/dist/api/modules/relay/api.js +1 -1
- package/build/dist/api/modules/relay/bootstrap.js +1 -1
- package/build/dist/api/modules/relay/discovery.js +1 -1
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.d.ts +1 -0
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/order.js +1 -1
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/relay/readiness.d.ts +1 -0
- package/build/dist/api/modules/relay/readiness.js +1 -1
- package/build/dist/api/modules/relay/reads.js +1 -1
- package/build/dist/api/modules/relay/vaults.js +1 -1
- package/build/dist/api/modules/spark/actions.js +1 -1
- package/build/dist/api/modules/spark/details.js +1 -1
- package/build/dist/api/modules/spark/index.js +1 -1
- package/build/dist/api/modules/spark/management.js +1 -1
- package/build/dist/api/modules/steakhouse/analytics.js +1 -1
- package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
- package/build/dist/api/modules/steakhouse/management.js +1 -1
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
- package/build/dist/api/modules/tickerspring/discovery.js +1 -1
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.d.ts +1 -0
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fee-percent.d.ts +4 -0
- package/build/dist/api/modules/uniswap/fee-percent.js +1 -0
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.d.ts +2 -0
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.d.ts +2 -0
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/quote-guard.d.ts +38 -0
- package/build/dist/api/modules/uniswap/quote-guard.js +1 -0
- package/build/dist/api/modules/uniswap/token-jar.js +1 -1
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
- package/build/dist/api/modules/uniswap/trade.d.ts +10 -3
- package/build/dist/api/modules/uniswap/trade.js +1 -1
- package/build/dist/api/modules/uniswap/v2.js +1 -1
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.d.ts +6 -0
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.js +1 -1
- package/build/dist/api/modules/upoch/copy.d.ts +5 -0
- package/build/dist/api/modules/upoch/copy.js +1 -0
- package/build/dist/api/modules/upoch/index.d.ts +8 -0
- package/build/dist/api/modules/upoch/index.js +1 -0
- package/build/dist/api/modules/upoch/pins.d.ts +8 -0
- package/build/dist/api/modules/upoch/pins.js +1 -0
- package/build/dist/api/modules/upoch/reads.d.ts +509 -0
- package/build/dist/api/modules/upoch/reads.js +1 -0
- package/build/dist/api/modules/velora/claims.js +1 -1
- package/build/dist/api/modules/velora/delta-reads.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.js +1 -1
- package/build/dist/api/modules/wormhole/scan-text.js +1 -1
- package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -1
- package/build/dist/api/modules/wormhole/third-party-text.d.ts +14 -3
- package/build/dist/api/modules/wormhole/third-party-text.js +1 -1
- package/build/dist/api/modules/wormhole/token-check.js +1 -1
- package/build/dist/api/modules/wormhole/x402-client.d.ts +17 -1
- package/build/dist/api/modules/wormhole/x402-client.js +1 -1
- package/build/dist/api/oak-fee.d.ts +12 -0
- package/build/dist/api/oak-fee.js +1 -0
- package/build/dist/api/param-text.d.ts +22 -0
- package/build/dist/api/param-text.js +1 -0
- package/build/dist/api/position-economics.d.ts +70 -0
- package/build/dist/api/position-economics.js +1 -0
- package/build/dist/api/positions.d.ts +8 -5
- package/build/dist/api/positions.js +1 -1
- package/build/dist/api/pricenote.js +1 -1
- package/build/dist/api/prices.d.ts +3 -0
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/pricing.js +1 -1
- package/build/dist/api/progress.d.ts +7 -0
- package/build/dist/api/progress.js +1 -0
- package/build/dist/api/read-budgets.d.ts +4 -0
- package/build/dist/api/read-budgets.js +1 -0
- package/build/dist/api/read-shape.d.ts +45 -0
- package/build/dist/api/read-shape.js +1 -0
- package/build/dist/api/revert.d.ts +23 -0
- package/build/dist/api/revert.js +1 -0
- package/build/dist/api/routes.js +1 -1
- package/build/dist/api/rpc.d.ts +1 -0
- package/build/dist/api/rpc.js +1 -1
- package/build/dist/api/secret-fields.d.ts +2 -0
- package/build/dist/api/secret-fields.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.d.ts +8 -0
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/signing.js +1 -1
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.d.ts +4 -0
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.d.ts +1 -0
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.d.ts +1 -0
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/types.d.ts +3 -0
- package/build/dist/api/untrusted-unwrap.d.ts +1 -0
- package/build/dist/api/untrusted-unwrap.js +1 -0
- package/build/dist/api/usd-estimate.d.ts +23 -0
- package/build/dist/api/usd-estimate.js +1 -0
- package/build/dist/api/vendor-limits.js +1 -1
- package/build/dist/chunks/23HNDJ76.js +2 -0
- package/build/dist/chunks/24Q3FNGX.js +1 -0
- package/build/dist/chunks/25C4DTVA.js +1 -0
- package/build/dist/chunks/2GXHYI23.js +1 -0
- package/build/dist/chunks/2HN3U6OG.js +1 -0
- package/build/dist/chunks/{QU5XKRGK.js → 2OVJ2BTJ.js} +1 -1
- package/build/dist/chunks/{FUDAXV5X.js → 2QGLPY2D.js} +1 -1
- package/build/dist/chunks/2WRXH6BL.js +1 -0
- package/build/dist/chunks/2ZBSE2LD.js +2 -0
- package/build/dist/chunks/2ZQ7X223.js +1 -0
- package/build/dist/chunks/2ZWKIBJT.js +1 -0
- package/build/dist/chunks/3A2IKFTV.js +1 -0
- package/build/dist/chunks/3CH2IPQL.js +1 -0
- package/build/dist/chunks/3PU2SD3U.js +2 -0
- package/build/dist/chunks/{ER47KGRM.js → 3ZH5SOC2.js} +1 -1
- package/build/dist/chunks/4NBXBKOX.js +2 -0
- package/build/dist/chunks/{WV3A3OUU.js → 4PLLS6CT.js} +1 -1
- package/build/dist/chunks/4R3G3H42.js +1 -0
- package/build/dist/chunks/4TTDAF4B.js +1 -0
- package/build/dist/chunks/4Z3IGMU6.js +1 -0
- package/build/dist/chunks/5DPJQCKJ.js +68 -0
- package/build/dist/chunks/{SJJR4ZBZ.js → 5GQJVKVY.js} +1 -1
- package/build/dist/chunks/5R576SDB.js +1 -0
- package/build/dist/chunks/5RXALTDT.js +1 -0
- package/build/dist/chunks/5TUXSOMI.js +1 -0
- package/build/dist/chunks/5UAXLWJ2.js +1 -0
- package/build/dist/chunks/{QQECG3WP.js → 5W74Z4WZ.js} +1 -1
- package/build/dist/chunks/5XAXJEWM.js +5 -0
- package/build/dist/chunks/65356YKW.js +1 -0
- package/build/dist/chunks/65OITTDL.js +1 -0
- package/build/dist/chunks/6F527FLN.js +1 -0
- package/build/dist/chunks/6MDYKE2O.js +1 -0
- package/build/dist/chunks/6OCLWSMZ.js +1 -0
- package/build/dist/chunks/75SULXNT.js +1 -0
- package/build/dist/chunks/{WU7XIAXB.js → 7EACRKFV.js} +1 -1
- package/build/dist/chunks/7U62MMUQ.js +1 -0
- package/build/dist/chunks/{DW4V5PUY.js → 7VH6JQ2H.js} +1 -1
- package/build/dist/chunks/A2V4NFVA.js +1 -0
- package/build/dist/chunks/A3BJSQ23.js +1 -0
- package/build/dist/chunks/ACH4BSME.js +3 -0
- package/build/dist/chunks/ADIPEGNN.js +1 -0
- package/build/dist/chunks/AHUCYDBC.js +1 -0
- package/build/dist/chunks/ANIF3JMV.js +4 -0
- package/build/dist/chunks/{ALLLYOUG.js → ATEVAJ5Y.js} +1 -1
- package/build/dist/chunks/B2HSLY5F.js +1 -0
- package/build/dist/chunks/{WTXC3XKW.js → B7BNDW35.js} +1 -1
- package/build/dist/chunks/BE3A7677.js +1 -0
- package/build/dist/chunks/{PAY5PD4H.js → BX46C5ZP.js} +1 -1
- package/build/dist/chunks/C3WBHFLX.js +1 -0
- package/build/dist/chunks/C6VJAL5B.js +1 -0
- package/build/dist/chunks/C76D54YG.js +1 -0
- package/build/dist/chunks/CD2JQ32C.js +1 -0
- package/build/dist/chunks/CI5ENLYA.js +1 -0
- package/build/dist/chunks/CNLL4NCR.js +1 -0
- package/build/dist/chunks/{P5PYFK7L.js → CQ5WRWV4.js} +1 -1
- package/build/dist/chunks/CSOO4SW7.js +1 -0
- package/build/dist/chunks/CZL6T2ZQ.js +1 -0
- package/build/dist/chunks/CZQ2CGYV.js +1 -0
- package/build/dist/chunks/D2IYA4LP.js +1 -0
- package/build/dist/chunks/D7QXZM3S.js +1 -0
- package/build/dist/chunks/{GNC6RXLT.js → DBOGRUPS.js} +1 -1
- package/build/dist/chunks/DGCJZ3HO.js +1 -0
- package/build/dist/chunks/DGDMRATN.js +1 -0
- package/build/dist/chunks/DMB64UIN.js +1 -0
- package/build/dist/chunks/DMDOSHV7.js +1 -0
- package/build/dist/chunks/DRLBTB4E.js +1 -0
- package/build/dist/chunks/E76Z2TT4.js +1 -0
- package/build/dist/chunks/EFESPGA2.js +1 -0
- package/build/dist/chunks/EHK7CDTU.js +1 -0
- package/build/dist/chunks/ELHRXA5U.js +1 -0
- package/build/dist/chunks/F7MGYRPU.js +1 -0
- package/build/dist/chunks/{MRMR4QHA.js → FAH7FKUT.js} +1 -1
- package/build/dist/chunks/{QBIY6FQN.js → FGEGJOAA.js} +1 -1
- package/build/dist/chunks/FHTNMGFR.js +1 -0
- package/build/dist/chunks/FN6GNTPR.js +1 -0
- package/build/dist/chunks/{EGYVRQUR.js → FTMA24EC.js} +1 -1
- package/build/dist/chunks/FXOFR432.js +1 -0
- package/build/dist/chunks/{VHV6WQ5F.js → G2AA73ZE.js} +1 -1
- package/build/dist/chunks/G2LAO23N.js +1 -0
- package/build/dist/chunks/{WIRBCS4W.js → GBIBRYOV.js} +1 -1
- package/build/dist/chunks/GDOHHXNH.js +1 -0
- package/build/dist/chunks/{GSBIERZD.js → GP6YO24Z.js} +1 -1
- package/build/dist/chunks/GQ3XZFRL.js +1 -0
- package/build/dist/chunks/{4HG6FRVH.js → GQITAJVF.js} +1 -1
- package/build/dist/chunks/H3E7UD2X.js +1 -0
- package/build/dist/chunks/HFVXNKA5.js +1 -0
- package/build/dist/chunks/HHYE42JG.js +21 -0
- package/build/dist/chunks/HRAHGYNK.js +1 -0
- package/build/dist/chunks/HS5HWBMU.js +1 -0
- package/build/dist/chunks/{BND2UFVW.js → HVFMIURK.js} +1 -1
- package/build/dist/chunks/IBL6TL2Q.js +1 -0
- package/build/dist/chunks/IT2JLILU.js +1 -0
- package/build/dist/chunks/IV4K7FMD.js +1 -0
- package/build/dist/chunks/{PNA6UIE5.js → JDSSYT6R.js} +1 -1
- package/build/dist/chunks/JFWJBZ7M.js +1 -0
- package/build/dist/chunks/JI5DXDMY.js +1 -0
- package/build/dist/chunks/JJGZ7W3V.js +1 -0
- package/build/dist/chunks/JPPQDELB.js +18 -0
- package/build/dist/chunks/{OLSP46ZD.js → K4P5VYDP.js} +1 -1
- package/build/dist/chunks/{JFYBH3DX.js → K6D6SDIG.js} +1 -1
- package/build/dist/chunks/K7HTDKAT.js +1 -0
- package/build/dist/chunks/KBU3PYP7.js +1 -0
- package/build/dist/chunks/KH4QFN72.js +3 -0
- package/build/dist/chunks/KMSAUFYV.js +1 -0
- package/build/dist/chunks/{RTAHNWHN.js → KOTGFD2V.js} +1 -1
- package/build/dist/chunks/KZA5GYZR.js +1 -0
- package/build/dist/chunks/LCH6F5HT.js +1 -0
- package/build/dist/chunks/LDJI2JAL.js +1 -0
- package/build/dist/chunks/LEV5SNNC.js +3 -0
- package/build/dist/chunks/{SPRVVJXI.js → LFSJDFMY.js} +1 -1
- package/build/dist/chunks/{PIIHOXWF.js → LJJYYUEG.js} +1 -1
- package/build/dist/chunks/LKX5WDOQ.js +1 -0
- package/build/dist/chunks/LVFI74ST.js +1 -0
- package/build/dist/chunks/M7BUKZW2.js +1 -0
- package/build/dist/chunks/{C5ZZAYXD.js → MI5HZDMH.js} +1 -1
- package/build/dist/chunks/MMCM3GSM.js +1 -0
- package/build/dist/chunks/MQ5F2VOK.js +1 -0
- package/build/dist/chunks/MSMHS456.js +1 -0
- package/build/dist/chunks/{JKD2B6OX.js → MSRCJ2BS.js} +1 -1
- package/build/dist/chunks/{XSKFKBDR.js → N64JJN37.js} +1 -1
- package/build/dist/chunks/NAO7VWZF.js +1 -0
- package/build/dist/chunks/ND32LJWI.js +1 -0
- package/build/dist/chunks/{Q42YI3EP.js → NMJVQX5M.js} +1 -1
- package/build/dist/chunks/NMQBOBWJ.js +1 -0
- package/build/dist/chunks/NQ4MTIU3.js +1 -0
- package/build/dist/chunks/NWPAQER2.js +1 -0
- package/build/dist/chunks/O2J5I4VA.js +1 -0
- package/build/dist/chunks/O4S6XAYV.js +1 -0
- package/build/dist/chunks/{TAEZTP4L.js → O5QTITN6.js} +1 -1
- package/build/dist/chunks/{RUC7KH7A.js → OB7BFDOV.js} +1 -1
- package/build/dist/chunks/OEZ7FCLF.js +1 -0
- package/build/dist/chunks/{GW5IXLKU.js → OI3N4EW4.js} +1 -1
- package/build/dist/chunks/{WP6RHXGN.js → OIQTZOBN.js} +1 -1
- package/build/dist/chunks/OODSXDIH.js +1 -0
- package/build/dist/chunks/OOPMZIG7.js +1 -0
- package/build/dist/chunks/OQFNUDMQ.js +1 -0
- package/build/dist/chunks/ORG6LVKJ.js +1 -0
- package/build/dist/chunks/{CBLMQ5UU.js → OSMOBKRQ.js} +1 -1
- package/build/dist/chunks/OTLUQWLF.js +1 -0
- package/build/dist/chunks/{2MT3G7YZ.js → OTYB6BHK.js} +1 -1
- package/build/dist/chunks/{H43RNCX2.js → OUROA7XR.js} +1 -1
- package/build/dist/chunks/{SMYWWIE6.js → OVM4QIET.js} +1 -1
- package/build/dist/chunks/OYDKAIS2.js +1 -0
- package/build/dist/chunks/P6OB2AFW.js +1 -0
- package/build/dist/chunks/PDPTJMTJ.js +1 -0
- package/build/dist/chunks/PEHXHQVA.js +1 -0
- package/build/dist/chunks/PMFR47H3.js +1 -0
- package/build/dist/chunks/PQXYTOV5.js +1 -0
- package/build/dist/chunks/PSGRZWES.js +1 -0
- package/build/dist/chunks/PZEF5LBL.js +2 -0
- package/build/dist/chunks/Q7L3BX6U.js +1 -0
- package/build/dist/chunks/QBYV7NXH.js +1 -0
- package/build/dist/chunks/QIB6OMQV.js +1 -0
- package/build/dist/chunks/QLAOBULN.js +1 -0
- package/build/dist/chunks/QLFPAN6S.js +1 -0
- package/build/dist/chunks/QMEGAKLI.js +1 -0
- package/build/dist/chunks/QMNUB2GM.js +2 -0
- package/build/dist/chunks/QMZEGT5B.js +1 -0
- package/build/dist/chunks/R73R4KN3.js +1 -0
- package/build/dist/chunks/RN3WUJIO.js +1 -0
- package/build/dist/chunks/RNCMXKKS.js +1 -0
- package/build/dist/chunks/ROQQ62LP.js +1 -0
- package/build/dist/chunks/RUTSEGGD.js +1 -0
- package/build/dist/chunks/{TFDPEAVZ.js → S4JUFCT4.js} +1 -1
- package/build/dist/chunks/{2VXLVXIB.js → S4UJDZGN.js} +1 -1
- package/build/dist/chunks/SCG5HWMN.js +1 -0
- package/build/dist/chunks/{XQA5LCL6.js → SENOU5JR.js} +1 -1
- package/build/dist/chunks/SMSXZ3FN.js +1 -0
- package/build/dist/chunks/SUNTJ6IU.js +1 -0
- package/build/dist/chunks/SZ466I5X.js +1 -0
- package/build/dist/chunks/TGFQQCRY.js +1 -0
- package/build/dist/chunks/{K4DHHQBI.js → THL4TMQW.js} +2 -2
- package/build/dist/chunks/TI727O2H.js +1 -0
- package/build/dist/chunks/{UD2XMNIT.js → TMRAF2L2.js} +1 -1
- package/build/dist/chunks/TNJTET4G.js +1 -0
- package/build/dist/chunks/TVIMP5CK.js +1 -0
- package/build/dist/chunks/{PV5FDT6O.js → TXGZ6NWN.js} +1 -1
- package/build/dist/chunks/U243AWCH.js +1 -0
- package/build/dist/chunks/U762746N.js +1 -0
- package/build/dist/chunks/U7UPLF4F.js +1 -0
- package/build/dist/chunks/{7QIO77VE.js → UPKVD7WG.js} +1 -1
- package/build/dist/chunks/{ZQAFFWDK.js → URBEK2VV.js} +1 -1
- package/build/dist/chunks/USEF3QKG.js +1 -0
- package/build/dist/chunks/UVAR6BHU.js +1 -0
- package/build/dist/chunks/V5YSJKRH.js +70 -0
- package/build/dist/chunks/VB36EHIR.js +1 -0
- package/build/dist/chunks/VMZYFO6I.js +1 -0
- package/build/dist/chunks/{TX2EOIRS.js → VST6LFUB.js} +1 -1
- package/build/dist/chunks/{U4JGEMKT.js → VVAM3EAK.js} +1 -1
- package/build/dist/chunks/VVJO6OYK.js +1 -0
- package/build/dist/chunks/VVWFB53Q.js +1 -0
- package/build/dist/chunks/VXCGMALF.js +1 -0
- package/build/dist/chunks/VZVW5J7J.js +1 -0
- package/build/dist/chunks/W32UECOL.js +1 -0
- package/build/dist/chunks/{XD6X3KTC.js → W4RYRLL5.js} +1 -1
- package/build/dist/chunks/{2MZXTOZU.js → WAKZWSHB.js} +1 -1
- package/build/dist/chunks/WBNFRPAT.js +1 -0
- package/build/dist/chunks/{AFBEZXNV.js → WNWRF4HE.js} +1 -1
- package/build/dist/chunks/{4DP2VPXR.js → WOGWLFAL.js} +1 -1
- package/build/dist/chunks/{HM72DH4V.js → WRUTW6CG.js} +1 -1
- package/build/dist/chunks/{VYYSL557.js → WSILNJS2.js} +1 -1
- package/build/dist/chunks/X24YTJST.js +1 -0
- package/build/dist/chunks/{IPN6Z4JM.js → X5AL3DUK.js} +1 -1
- package/build/dist/chunks/XBNZ7GTY.js +1 -0
- package/build/dist/chunks/{XL3LLGIR.js → XEBMS5KU.js} +1 -1
- package/build/dist/chunks/XEPCDGN2.js +1 -0
- package/build/dist/chunks/{KIFZ5ZSK.js → XL3W7DAQ.js} +1 -1
- package/build/dist/chunks/{DL6AEWEM.js → XPWGPZ2C.js} +1 -1
- package/build/dist/chunks/{T7TFUH5K.js → XRDLMTBJ.js} +1 -1
- package/build/dist/chunks/XTFRPI4G.js +1 -0
- package/build/dist/chunks/XV3YJ4P6.js +1 -0
- package/build/dist/chunks/XW3VGWXK.js +1 -0
- package/build/dist/chunks/{6WD4HHID.js → Y2QADJOB.js} +1 -1
- package/build/dist/chunks/Y64GFBTA.js +1 -0
- package/build/dist/chunks/YARZE7SJ.js +1 -0
- package/build/dist/chunks/YBLJ75U5.js +1 -0
- package/build/dist/chunks/YEIM6BZQ.js +1 -0
- package/build/dist/chunks/YRSAZTTC.js +7 -0
- package/build/dist/chunks/YXXK6EPI.js +1 -0
- package/build/dist/chunks/Z3IBPCY4.js +2 -0
- package/build/dist/chunks/{QHBS3PVU.js → Z7FGEWO2.js} +1 -1
- package/build/dist/chunks/ZNPVBNC5.js +1 -0
- package/build/dist/chunks/ZQ6AF3VX.js +1 -0
- package/build/dist/chunks/ZTKT3ZQK.js +1 -0
- package/build/dist/chunks/{4BVP652W.js → ZZ6FZGHF.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/2THSW4QN.js +0 -1
- package/build/dist/chunks/2TK3ETUO.js +0 -1
- package/build/dist/chunks/35KR3VSS.js +0 -1
- package/build/dist/chunks/3GQ7A3VB.js +0 -1
- package/build/dist/chunks/3XNZUIRU.js +0 -1
- package/build/dist/chunks/46547QT3.js +0 -1
- package/build/dist/chunks/4EN6MQEI.js +0 -1
- package/build/dist/chunks/4I3OU56B.js +0 -1
- package/build/dist/chunks/52ELWNXJ.js +0 -2
- package/build/dist/chunks/5AXWBSPG.js +0 -1
- package/build/dist/chunks/5N3O42X6.js +0 -1
- package/build/dist/chunks/5SMVQCAP.js +0 -1
- package/build/dist/chunks/5SZPNZG4.js +0 -1
- package/build/dist/chunks/64GOINYS.js +0 -1
- package/build/dist/chunks/6I4NTKB2.js +0 -1
- package/build/dist/chunks/6JAXZNZ3.js +0 -1
- package/build/dist/chunks/6O3Q5B6M.js +0 -1
- package/build/dist/chunks/6OGDTEGH.js +0 -1
- package/build/dist/chunks/6WZX7C4T.js +0 -2
- package/build/dist/chunks/6YB3VOUL.js +0 -1
- package/build/dist/chunks/7GJ6SLEV.js +0 -1
- package/build/dist/chunks/7KWZ5QJU.js +0 -1
- package/build/dist/chunks/7QZOTRSA.js +0 -2
- package/build/dist/chunks/7WSHW7KW.js +0 -1
- package/build/dist/chunks/A7I4IWUB.js +0 -1
- package/build/dist/chunks/ABPL3ZZI.js +0 -1
- package/build/dist/chunks/ACW63WIL.js +0 -20
- package/build/dist/chunks/AEL62KCG.js +0 -1
- package/build/dist/chunks/AKYF5264.js +0 -7
- package/build/dist/chunks/AW7AXQCZ.js +0 -1
- package/build/dist/chunks/AXRL3REN.js +0 -1
- package/build/dist/chunks/BBTPRZ6T.js +0 -1
- package/build/dist/chunks/BOVMED7R.js +0 -1
- package/build/dist/chunks/BTPXJAUX.js +0 -1
- package/build/dist/chunks/C7AXJHBT.js +0 -1
- package/build/dist/chunks/CBG5HARQ.js +0 -2
- package/build/dist/chunks/CDPSMI3Z.js +0 -1
- package/build/dist/chunks/CHXBOXOD.js +0 -1
- package/build/dist/chunks/CQEJSCFQ.js +0 -1
- package/build/dist/chunks/DBNTZEAJ.js +0 -1
- package/build/dist/chunks/DHUDSOGR.js +0 -18
- package/build/dist/chunks/DJN3JAWB.js +0 -1
- package/build/dist/chunks/E3RACZUY.js +0 -1
- package/build/dist/chunks/FEYAY6OZ.js +0 -1
- package/build/dist/chunks/FJ4S4GHY.js +0 -1
- package/build/dist/chunks/FWD4L3CJ.js +0 -1
- package/build/dist/chunks/GG6Y4OCJ.js +0 -1
- package/build/dist/chunks/GGHBFLRC.js +0 -1
- package/build/dist/chunks/GGSAKCND.js +0 -1
- package/build/dist/chunks/GRQYTVNT.js +0 -1
- package/build/dist/chunks/H6T5FXEX.js +0 -1
- package/build/dist/chunks/HHXBUYHO.js +0 -1
- package/build/dist/chunks/HKEMQBFA.js +0 -1
- package/build/dist/chunks/HQUVB7Z5.js +0 -3
- package/build/dist/chunks/HU7IMNBI.js +0 -1
- package/build/dist/chunks/HWX36XJI.js +0 -1
- package/build/dist/chunks/I26DMNJG.js +0 -1
- package/build/dist/chunks/I55MURSJ.js +0 -1
- package/build/dist/chunks/IMO3GDA5.js +0 -1
- package/build/dist/chunks/IPRVIKYC.js +0 -1
- package/build/dist/chunks/IVX4R5OL.js +0 -1
- package/build/dist/chunks/JQOQMFWD.js +0 -3
- package/build/dist/chunks/JUZ5JU6D.js +0 -70
- package/build/dist/chunks/JZS3E66E.js +0 -1
- package/build/dist/chunks/K3RDPI5J.js +0 -1
- package/build/dist/chunks/KBKK7UNY.js +0 -1
- package/build/dist/chunks/KVFZKPJT.js +0 -1
- package/build/dist/chunks/L5BLHY34.js +0 -1
- package/build/dist/chunks/LKXO2BQS.js +0 -1
- package/build/dist/chunks/LKZX4CAA.js +0 -1
- package/build/dist/chunks/LYMNHO5T.js +0 -1
- package/build/dist/chunks/M2UXYCKH.js +0 -1
- package/build/dist/chunks/M37654RL.js +0 -1
- package/build/dist/chunks/M6LC6DRE.js +0 -1
- package/build/dist/chunks/MOE3EVAL.js +0 -1
- package/build/dist/chunks/N4Q6GN65.js +0 -1
- package/build/dist/chunks/NAZPDRIF.js +0 -1
- package/build/dist/chunks/NKX3FE34.js +0 -1
- package/build/dist/chunks/NKZKKCK2.js +0 -1
- package/build/dist/chunks/NOFUKKP5.js +0 -1
- package/build/dist/chunks/O6ROOKY2.js +0 -1
- package/build/dist/chunks/OJ4WJUPP.js +0 -1
- package/build/dist/chunks/OOZSE2R7.js +0 -1
- package/build/dist/chunks/OTXSKFUD.js +0 -1
- package/build/dist/chunks/P5AJSLZ7.js +0 -1
- package/build/dist/chunks/PACN53TR.js +0 -1
- package/build/dist/chunks/PAHXBLCS.js +0 -1
- package/build/dist/chunks/PK66GCDT.js +0 -1
- package/build/dist/chunks/PSBQWDYI.js +0 -1
- package/build/dist/chunks/PXT5YTWU.js +0 -1
- package/build/dist/chunks/PZGGE5D3.js +0 -1
- package/build/dist/chunks/QA2RRIES.js +0 -1
- package/build/dist/chunks/QA3UHEO3.js +0 -1
- package/build/dist/chunks/QFNT73OF.js +0 -1
- package/build/dist/chunks/QW2OPEYJ.js +0 -1
- package/build/dist/chunks/QYVREJYC.js +0 -1
- package/build/dist/chunks/ROFPXEQ5.js +0 -2
- package/build/dist/chunks/RTGS7RIO.js +0 -1
- package/build/dist/chunks/RUX3RY7Y.js +0 -1
- package/build/dist/chunks/RVDUSNWW.js +0 -1
- package/build/dist/chunks/S5CBVFHY.js +0 -1
- package/build/dist/chunks/SIYUNOLI.js +0 -1
- package/build/dist/chunks/TEJ7W534.js +0 -1
- package/build/dist/chunks/TPBAFS7K.js +0 -1
- package/build/dist/chunks/TVWMTMEF.js +0 -1
- package/build/dist/chunks/U2RMUVVY.js +0 -1
- package/build/dist/chunks/U5PMVP56.js +0 -1
- package/build/dist/chunks/V5JWGWXC.js +0 -1
- package/build/dist/chunks/VCOTCVKN.js +0 -1
- package/build/dist/chunks/VEQBHI6O.js +0 -1
- package/build/dist/chunks/VNV6ZISN.js +0 -1
- package/build/dist/chunks/VYAJXLND.js +0 -1
- package/build/dist/chunks/WCNHZYQQ.js +0 -1
- package/build/dist/chunks/WLMWWEP7.js +0 -2
- package/build/dist/chunks/X2P55AC3.js +0 -1
- package/build/dist/chunks/XBE3B6Y2.js +0 -1
- package/build/dist/chunks/XKSVTN5X.js +0 -1
- package/build/dist/chunks/XSRIJUFU.js +0 -1
- package/build/dist/chunks/YCZPSMZ5.js +0 -1
- package/build/dist/chunks/YDNTY67T.js +0 -1
- package/build/dist/chunks/YN56C7PN.js +0 -1
- package/build/dist/chunks/YRNXGQJC.js +0 -1
- package/build/dist/chunks/YWRLY5EA.js +0 -1
- package/build/dist/chunks/YWSX6IE6.js +0 -1
- package/build/dist/chunks/YXTSWRV5.js +0 -1
- package/build/dist/chunks/Z6LZGCVW.js +0 -1
- package/build/dist/chunks/ZQWZGH7V.js +0 -1
- package/build/dist/chunks/ZSN4IRI5.js +0 -1
- package/build/dist/chunks/ZV5HIQXC.js +0 -1
- package/build/dist/chunks/ZXJ24B4L.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as me,c as De}from"./QA3UHEO3.js";import{c as Te,d as a,r as Ee}from"./64GOINYS.js";import{o as pe}from"./BOVMED7R.js";import{a as M}from"./QHBS3PVU.js";import{a as xe}from"./43LI5NKJ.js";import{a as te}from"./66F5ZH34.js";import{c as G,j as ve}from"./NWNYJ26T.js";import{b as ke}from"./IX3GZMTM.js";import{a as R,i as Ce}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{decodeFunctionData as Se,erc20Abi as Oe}from"viem";var Fe="https://api.relay.link",q="0x0000000000000000000000000000000000000000",Le=60,Pe=30,n=Ce[R].relay.depository.address.toLowerCase(),ne="0x59916da825d2d2ec1bf878d71c88826f6633ecca",ie=new Map([[1,{chainId:"ethereum",depository:n}],[10,{chainId:"optimism",depository:n}],[25,{chainId:"cronos",depository:ne}],[56,{chainId:"bnb",depository:n}],[100,{chainId:"gnosis",depository:n}],[130,{chainId:"unichain",depository:n}],[137,{chainId:"polygon",depository:n}],[143,{chainId:"monad",depository:n}],[146,{chainId:"sonic",depository:n}],[169,{chainId:"manta",depository:n}],[196,{chainId:"xlayer",depository:n}],[288,{chainId:"boba",depository:n}],[324,{chainId:"zksync",depository:n}],[360,{chainId:"shape",depository:n}],[480,{chainId:"worldchain",depository:n}],[747,{chainId:"flow",depository:n}],[988,{chainId:"stable",depository:n}],[999,{chainId:"hyperevm",depository:n}],[1088,{chainId:"metis",depository:ne}],[1135,{chainId:"lisk",depository:n}],[1868,{chainId:"soneium",depository:n}],[2020,{chainId:"ronin",depository:n}],[2741,{chainId:"abstract",depository:n}],[2818,{chainId:"morph",depository:n}],[4217,{chainId:"tempo",depository:n}],[4326,{chainId:"megaeth",depository:n}],[5e3,{chainId:"mantle",depository:ne}],[5031,{chainId:"somnia",depository:n}],[5042,{chainId:"arc",depository:n}],[8453,{chainId:"base",depository:n}],[9745,{chainId:"plasma",depository:n}],[33139,{chainId:"apechain",depository:n}],[34443,{chainId:"mode",depository:n}],[42018,{chainId:"mythos",depository:n}],[42161,{chainId:"arbitrum",depository:n}],[42220,{chainId:"celo",depository:n}],[43114,{chainId:"avalanche",depository:n}],[48900,{chainId:"zircuit",depository:n}],[57073,{chainId:"ink",depository:n}],[59144,{chainId:"linea",depository:ne}],[60808,{chainId:"bob",depository:n}],[80094,{chainId:"berachain",depository:n}],[97477,{chainId:"doma",depository:n}],[98866,{chainId:"plume",depository:n}],[534352,{chainId:"scroll",depository:n}],[685689,{chainId:"gensyn",depository:n}],[747474,{chainId:"katana",depository:n}],[5064014,{chainId:"ethereal",depository:n}],[7777777,{chainId:"zora",depository:n}]]),nt=Object.freeze(["robinhood",...Array.from(ie.values(),e=>e.chainId)]);function ot(e){return e===R?"robinhood":ie.get(e)?.chainId}function it(e){return ie.get(e)?.depository}function j(e){return ve(e,"Provide a token or wallet address.")}function I(e){let o=j(e);return o===M?q:o}function f(e,o){return j(e)===j(o)}function l(e){if(typeof e!="string")throw new t("Provide a decimal base-unit amount string.");return ke(e),e}function oe(e){let o=l(e);if(BigInt(o)<=0n)throw new t("Provide a positive base-unit amount.");return o}function ze(e){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t("Provide a positive integer origin chain ID.");return e}function Ne(e,o){if(typeof e!="number"||!Number.isSafeInteger(e)||e<=0)throw new t(`${o} is missing or invalid.`);return e}async function V(e,o,c,i,p){let r=a(c);if(r.chainId!==i||I(r.address)!==p||typeof r.symbol!="string"||!/^[A-Za-z0-9._-]{1,32}$/.test(r.symbol))throw new t("Relay quote token metadata does not match the requested chain and address.");if(p===q){if(r.decimals!==18)throw new t("Native token decimals must be 18.");return{address:M,chainId:i,symbol:r.symbol,decimals:18}}let g=`${i}:${p}`,m=o.get(g);if(m===void 0){let d=await e.clientFor(i).readContract({address:p,abi:Oe,functionName:"decimals"}),w=typeof d=="bigint"?Number(d):d;if(typeof w!="number"||!Number.isInteger(w)||w<0||w>255)throw new t("Could not read valid ERC-20 decimals() on-chain.");m=w,o.set(g,m)}return{address:p,chainId:i,symbol:r.symbol,decimals:m}}async function Ke(e,o,c,i,p,r,g){if(c.swap===void 0)return[];let m=a(c.swap),d=a(m.from);if(d.chainId!==p)throw new t("The swap prerequisite token must be on the origin chain.");let w=await V(e,o,d,p,I(d.address)),F=r===q?M:r;if(f(w.address,F))throw new t("The swap prerequisite must use a different input token.");let he=oe(m.amountIn),y=m.slippageBps;if(y!==void 0&&(typeof y!="number"||!Number.isInteger(y)||y<0||y>1e4))throw new t("Provide swap slippage in basis points from 0 to 10000.");let D=await e.quoteSwap({from:w.address,to:F,amountIn:he,...y===void 0?{}:{slippageBps:y}},i);if(BigInt(l(D.expiresAt))<=BigInt(Math.floor(Date.now()/1e3)))throw new t("The swap prerequisite quote expired. Request a fresh quote.");if(BigInt(l(D.minAmountOut))<BigInt(g))throw new t("The swap prerequisite minimum cannot cover the bridge amount.");let C=await e.buildSwap(D.quoteId,i);if(!("txs"in C)||!C.txs.length)throw new t("The swap prerequisite must return unsigned transactions.");if(C.txs.some(S=>S.chainId!==p))throw new t("The injected swap coordinator does not support this origin chain.");return C.txs.map(S=>e.unsignedTx(S))}async function Ue(e,o,c){xe(c);let i=ze(o.originChainId);if(i===R)throw new t("Inbound bridging requires an origin chain other than 4663.");let p=ie.get(i);if(!p)throw new t("Relay inbound does not support this origin chain.");if(o.destinationChainId!==void 0&&o.destinationChainId!==R)throw new t("Inbound bridge destination must be chain 4663.");let r=I(o.originCurrency??M),g=I(o.destinationCurrency??M),m=j(o.recipient??c),d=oe(o.amount),w=o.minAmountOut===void 0?void 0:l(o.minAmountOut),F=o.slippageBps===void 0?me:o.slippageBps;if(pe("0",F),await e.clientFor(i).getChainId()!==i)throw new t("The RPC chain does not match the inbound origin chain.");let y=new Map,D=await Ke(e,y,o,c,i,r,d),C,S=process.env.OAK_RELAY_API_KEY?.trim();if(!S)throw new t("Configure OAK_RELAY_API_KEY on the server: Relay quote/v2 requires a valid API key since October 2, 2026. Status and chain reads remain available without it.");try{let s=await e.http(`${Fe}/quote/v2`,{method:"POST",headers:{"content-type":"application/json","user-agent":"oak-core/0.1.0","x-api-key":S},body:JSON.stringify({user:c,recipient:m,originChainId:i,destinationChainId:R,originCurrency:r,destinationCurrency:g,amount:d,tradeType:"EXACT_INPUT",includeProtocolData:!0,...r===q?{}:{explicitDeposit:!0}})});if(!s.ok)throw new Error("Relay HTTP failure.");C=await s.json()}catch{throw new t("Relay quote request failed. Please try again.")}let b=a(C);if(typeof b.requestId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(b.requestId))throw new t("Relay returned an invalid request ID.");let P=b.requestId,ye=`/intents/status/v3?requestId=${P}`,L=a(b.details);if(!f(L.sender,c)||!f(L.recipient,m))throw new t("Relay quote sender or recipient does not match the request.");let le=a(L.currencyIn),re=a(L.currencyOut),N=await V(e,y,le.currency,i,r),O=await V(e,y,re.currency,R,g);if(l(le.amount)!==d)throw new t("Relay quote input amount does not match the request.");let _=oe(re.amount),k=oe(re.minimumAmount);if(BigInt(k)>BigInt(_))throw new t("Relay quote minimum output exceeds the expected output.");if(w!==void 0){if(k!==w)throw new t("Relay order minimum must exactly match minAmountOut. Request a new quote.")}else{let s=pe(_,F);if(BigInt(k)<BigInt(s))throw De(_,k)}let fe=a(a(b.fees).relayer),we=a(fe.currency),Q=await V(e,y,we,i,I(we.address)),Ie={token:Q,amount:l(fe.amount)},ge=a(L.refundCurrency),_e=a(ge.currency),z=await V(e,y,_e,i,r),se=l(ge.amount),K=a(a(b.protocol).v2);if(typeof K.orderId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(K.orderId))throw new t("Relay returned an invalid order ID.");let W=K.orderId.toLowerCase(),J=a(K.paymentDetails),$=j(J.depository);if(J.chainId!==p.chainId||$!==p.depository||I(J.currency)!==r||l(J.amount)!==d)throw new t("Relay payment details do not match the origin chain depository and input.");let U=a(K.orderData),v=a(U.output);if(v.chainId!=="robinhood"||!Array.isArray(v.calls)||v.calls.length!==0||!Array.isArray(v.payments)||v.payments.length!==1)throw new t("Relay order output does not match destination chain 4663.");let X=a(v.payments[0]);if(!f(X.recipient,m)||I(X.currency)!==g||l(X.minimumAmount)!==k||l(X.expectedAmount)!==_)throw new t("Relay order output payment does not match the quoted recipient and amounts.");let ae=Ne(v.deadline,"Relay order output deadline");if(!Array.isArray(U.inputs)||!U.inputs.length)throw new t("Relay order has no inputs.");let Z=[],de=[];for(let s of U.inputs){let u=a(s),T=a(u.payment);if(T.chainId!==p.chainId||I(T.currency)!==r||l(T.amount)!==d||!Array.isArray(u.refunds)||!u.refunds.length)throw new t("Relay order input does not match the quoted input.");for(let E of u.refunds){let h=a(E);if(!f(h.recipient,c))throw new t("Relay refund recipient does not match the agent wallet. Request a new quote.");if(Z.push(Ne(h.deadline,"Relay order refund deadline")),de.push(l(h.minimumAmount)),!(h.chainId===p.chainId?f(h.recipient,c)&&I(h.currency)===r:h.chainId==="robinhood"&&I(h.currency)===g))throw new t("Relay order refund terms do not match the sender or recipient.")}}let be=Math.min(ae,...Z),Y=0,Ae=()=>{let s=Math.floor(Date.now()/1e3),u=Y||s+Le;if(be-s<=Pe)throw new t("Relay order deadline is expired or too soon to sign safely. Request a new quote.");if(Y=Math.min(u,be-Pe),Y<=s)throw new t("Relay quote expired before signing. Request a new quote.")};if(Ae(),!Array.isArray(b.steps)||!b.steps.length)throw new t("Relay returned no origin transactions.");let x=[];for(let s of b.steps){let u=a(s);if(u.kind!=="transaction"||u.requestId!==P||!Array.isArray(u.items)||!u.items.length)throw new t("Relay returned an unsupported origin step.");for(let T of u.items){let E=a(T),h=a(E.data),ce=a(E.check);if(E.status!=="incomplete"||h.chainId!==i||!f(h.from,c))throw new t("Relay transaction does not match the origin chain and sender.");if(ce.method!=="GET"||ce.endpoint!==ye)throw new t("Relay status endpoint does not match the request ID.");x.push(e.unsignedTx({to:j(h.to),data:h.data,value:l(h.value),chainId:i,description:`Relay inbound deposit for request ${P}; destination chain 4663.`}))}}if(!x.length)throw new t("Relay returned no origin transactions.");if(r===q&&x.length!==1)throw new t("Relay native deposit must be a single depositNative transaction.");if(r!==q&&x.length>2)throw new t("Relay ERC-20 deposit allows at most one exact-amount approval before depositErc20.");for(let s of x.slice(0,-1)){if(!s.data.toLowerCase().startsWith("0x095ea7b3"))throw new t("Relay returned an unsupported prerequisite transaction.");let u=Se({abi:Oe,data:s.data});if(u.functionName!=="approve")throw new t("Relay returned an invalid approval.");let[T,E]=u.args;if(r===q||!f(s.to,r)||!f(T,$)||E!==BigInt(d)||s.value!=="0")throw new t("Relay approval must authorize the exact input amount for the origin depository.");s.description=`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`}let B=x[x.length-1],H=r===q,ee=H?"depositNative":"depositErc20",Re=H?"depositNative(address,bytes32)":"depositErc20(address,address,uint256,bytes32)";if(!f(B.to,$)||B.value!==(H?d:"0")||!(H?/^0x[0-9a-fA-F]{136}$/:/^0x[0-9a-fA-F]{264}$/).test(B.data))throw new t(`Relay deposit transaction does not target the origin depository with ${ee} calldata.`);let A;try{A=Se({abi:Te,data:B.data})}catch{throw new t(`Relay deposit transaction must call ${Re}.`)}if(A.functionName!==ee)throw new t(`Relay deposit transaction must call ${Re}.`);let Be=A.args[0],Me=A.functionName==="depositErc20"?A.args[3]:A.args[1];if(A.functionName==="depositErc20"&&(!f(A.args[1],r)||A.args[2]!==BigInt(d)))throw new t("Relay depositErc20 token or amount does not match the quoted input.");if(!f(Be,c)||Me.toLowerCase()!==W)throw new t(`Relay ${ee} depositor or orderId does not match the wallet and quoted protocol.v2.orderId.`);B.description=`Relay inbound ${ee} for order ${W} (request ${P}); destination chain 4663.`;let ue=H?[]:await Ee(e,r,$,d,i,c);for(let[s,u]of ue.entries())u.description=ue.length===2&&s===0?`Reset the existing ${N.symbol} allowance for ${$} on chain ${i} to zero.`:`Approve exactly ${e.formatAmount(d,N.decimals)} ${N.symbol} (${d} base units of ${r}) for ${$} on chain ${i}.`;let $e=[...D,...ue,B],qe=await e.preview($e,c);Ae();let je=qe.changes.map(s=>{let u=s.amount.startsWith("-");return`${u?"-":""}${e.formatAmount(u?s.amount.slice(1):s.amount,s.token.decimals)} ${s.token.symbol} (${s.token.address}, chain ${s.token.chainId})`});return{txs:$e,preview:qe,requestId:P,orderId:W,orderData:U,depository:$,originChainId:i,destinationChainId:R,recipient:m,amountIn:{token:N,amount:d},amountOut:{token:O,amount:_},minAmountOut:k,relayerFee:Ie,refundCurrency:{token:z,amount:se,minimumAmounts:de},orderDeadline:String(ae),refundDeadlines:Z.map(String),expiresAt:String(Y),status:"pending",statusEndpoint:ye,summary:`${D.length?"Swap prerequisite first, then ":""}Relay inbound from chain ${i} to chain 4663 for ${m}; expected ${e.formatAmount(_,O.decimals)} ${O.symbol}, minimum ${e.formatAmount(k,O.decimals)} ${O.symbol} (${O.address}). Quoted relay fee ${e.formatAmount(Ie.amount,Q.decimals)} ${Q.symbol} (${Q.address}, chain ${i}); output is net of quoted fees. Order ${W} (request ${P}); output deadline ${ae}, refund deadlines ${Z.join(", ")}, quote expires ${Y}. Refund terms: details.refundCurrency quotes ${e.formatAmount(se,z.decimals)} ${z.symbol} (${se} base units) on chain ${z.chainId} (${z.address}), but protocol.v2 order refund floor is ${de.join(", ")} base units. ${je.join("; ")}. Unsigned origin transactions only; destination fulfillment remains pending. Track with relay_status; timeout or refund is not fulfillment.`}}var rt=e=>({tools:[{name:"relay_bridge_in",inputSchema:{type:"object",additionalProperties:!1,required:["originChainId","amount"],properties:{originChainId:{type:"integer",minimum:1},destinationChainId:{const:R},originCurrency:G,destinationCurrency:G,amount:te(),minAmountOut:te(),slippageBps:{type:"integer",minimum:0,maximum:9999,default:me},recipient:G,swap:{type:"object",additionalProperties:!1,required:["from","amountIn"],properties:{from:{type:"object",additionalProperties:!1,required:["address","chainId","symbol","decimals"],properties:{address:G,chainId:{type:"integer",minimum:1},symbol:{type:"string"},decimals:{type:"integer",minimum:0,maximum:255}}},amountIn:te(),slippageBps:{type:"integer",minimum:0,maximum:1e4}}}}},async execute(o,c){try{return await Ue(e,o,c)}catch(i){throw new t(e.plainError(i))}}}]});export{nt as a,ot as b,it as c,rt as d};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as v}from"./6OGDTEGH.js";import{a as j}from"./NCQFWPAW.js";import{K as A}from"./DHUDSOGR.js";import{c as k}from"./AEL62KCG.js";import{a as O}from"./43LI5NKJ.js";import{a as x}from"./66F5ZH34.js";import{d as F,g as M,i as q,m as $}from"./NWNYJ26T.js";import{a as y}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{encodeFunctionData as G,erc20Abi as R,getAddress as g,zeroAddress as z}from"viem";var D={genesis:g("0x575b7B7c97Ef3E21C82DAeB427899d583e1E913f"),bond:g("0xff32a969A0c567129eECD926D04657728E1980C1"),inverse:g("0x92166e94Eea5B7799b761653881692f881dFC4C9"),treasury:g("0x04822Ea321A0DEE6F40656172F29312104855d66"),pteam:g("0x650F58079dAa17ee28928c2F92d22291d038B2B0"),rwa:g("0x99B6eE6eDe47d9a8a9bfd03F728a99B789df1961"),premium:g("0x346e1a31171A0f7aC73909010b5435768d3B5462"),tax:g("0x086C58400b8708Ef993f256E12e752dcF0AC918e")},H=g("0x59F95461E68e0c77605299791E1449f175165B54"),_={genesis:["purchase","finalize","refund","claim"],bond:["deposit","redeem"],inverse:["swap"],treasury:["rebalanceToMorpho","rebalanceFromMorpho","mintNet","spendUsdg"],pteam:["exercise"],rwa:["redeem","depositInventory","pokeHwm","setDiscount","setInventoryMax","setHalt","setMenu","skim"],premium:["execute"],tax:["convert"]},V={genesis:["wired","finalized","finalizeTime","saleStart","saleDeadline","raisedRaw","totalRaised","registryLength"],bond:["wired","enabled","startTime","marketCount"],inverse:["active","price","capacityRemaining","spreadBps"],treasury:["wired","rfv","backingPerToken","liquidUsdg","morphoAssets","polRfv","morphoCapBps","morphoVault","canonicalPair"],pteam:["wired","holder","vestedFraction","exercisableNow","exercised","strikeWad","capBps","circulatingSupply","excludedFromFloat"],rwa:["manager","halted","inventory","inventoryMax","owedNet","bHwm","deskDiscountBps","VEST","MAX_DISCOUNT_BPS","INVENTORY_HARD_CAP","menu","routerSource","sleeve"],premium:["active","clipSize","lastExecuteAt","premiumThresholdWad","router","pairContract"],tax:["wired","pendingNet","teamBps","treasuryBps","teamWallet","router","pairContract"]},T=h=>JSON.parse(JSON.stringify(h,(P,E)=>typeof E=="bigint"?E.toString():E));function N(h){return q(h,"Provide a checksummed address.",F)}var ae=h=>{async function P(t){if(typeof t!="string"||!Object.hasOwn(D,t))throw new a("Choose a published NetNet financial product.");let c=t,e=D[c],r=j[c],u=h.clientFor(y);if(await u.getChainId()!==y)throw new a("NetNet requires chain 4663.");let n=await u.getBlock(),o=(w,I=[])=>u.readContract({address:e,abi:r,functionName:w,args:I,blockNumber:n.number}),[i,s,l,p]=await Promise.all([o("net"),o("usdg"),u.readContract({address:v.address,abi:R,functionName:"decimals",blockNumber:n.number}),u.readContract({address:k.address,abi:R,functionName:"decimals",blockNumber:n.number})]);if(N(i)!==v.address||N(s)!==k.address||l!==v.decimals||p!==k.decimals)throw new a("NetNet financial token pins or decimals do not match the deployment.");return{product:c,contract:e,abi:r,rpc:u,block:n,read:o}}async function E(t){O(t);let c=(e,r)=>({module:"netnet",id:`4663:${D.bond.toLowerCase()}:${e}`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond notes unreadable: ${h.plainError(r)} Use netnet_financial_status with product bond to inspect notes.`});try{let e=await P("bond"),r=$(await e.read("noteCount",[t]),"Invalid NetNet bond note count."),u=r<50n?Number(r):50,n=[];for(let o=0;o<u;o++)try{let i=await e.read("notes",[t,BigInt(o)]);if(!Array.isArray(i)||i.length!==4)throw new a("Invalid NetNet bond note.");let[s,l,p,w]=i.map(C=>$(C,"Invalid NetNet bond note amount or timestamp."));if(l>s||w<=p||w>=1n<<64n)throw new a("Invalid NetNet bond note vesting or claimed amount.");let I=s-l;if(I===0n)continue;let S=e.block.timestamp>=w?s:e.block.timestamp<=p?0n:s*(e.block.timestamp-p)/(w-p),B=S>l?S-l:0n;n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:${o}`,chainId:y,matured:e.block.timestamp>=w,assets:[{token:v,amount:I.toString()}],description:`NetNet bond note ${o}: ${I} NET base units outstanding; ${B} claimable now, vesting ends at Unix ${w}. Redeem vested NET with netnet_financial_action product bond operation redeem. Payment cannot be withdrawn. Block ${e.block.number}.`})}catch(i){n.push(c(String(o),i))}return r>BigInt(u)&&n.push({module:"netnet",id:`4663:${e.contract.toLowerCase()}:coverage`,chainId:y,incomplete:!0,assets:[],description:`NetNet bond positions checked the first ${u} of ${r} notes. Use netnet_financial_status product bond offset ${u} to read the remaining notes.`}),n}catch(e){return[c("unreadable",e)]}}let U=(t,c,e,r)=>({name:t,inputSchema:{type:"object",properties:c,required:e,additionalProperties:!1},execute:async(u,n)=>{try{if(O(n),Object.keys(u).some(o=>!Object.hasOwn(c,o)))throw new a("Unsupported NetNet financial argument.");return await r(u,n)}catch(o){throw new a(h.plainError(o))}}}),W={type:"string",enum:Object.keys(D)};return{positions:E,tools:[U("netnet_financial_status",{product:W,offset:{type:"integer",minimum:0},limit:{type:"integer",minimum:1,maximum:50}},["product"],async(t,c)=>{let e=await P(t.product),r=V[e.product],u=t.offset??0,n=t.limit??20;if(!Number.isSafeInteger(u)||Number(u)<0||!Number.isSafeInteger(n)||Number(n)<1||Number(n)>50)throw new a("Use a nonnegative offset and limit 1..50.");let o=await Promise.all(r.map(async s=>{try{return[s,{value:T(await e.read(s))}]}catch(l){return[s,{unavailable:h.plainError(l)}]}})),i={};if(e.product==="genesis")for(let s of["purchasedRaw","purchasedNetOf","claimedNet","claimableNetOf"])i[s]=T(await e.read(s,[c]));if(e.product==="bond"||e.product==="rwa"){i.pending=T(await e.read("pendingFor",[c]));let s=await e.read("noteCount",[c]);if(typeof s!="bigint"||s<0n)throw new a("Invalid NetNet note count.");let l=s<BigInt(Number(u)+Number(n))?s:BigInt(Number(u)+Number(n));i.noteCount=s.toString(),i.notes=await Promise.all(Array.from({length:Math.max(0,Number(l-BigInt(Number(u))))},async(p,w)=>({id:String(Number(u)+w),note:T(await e.read(e.product==="bond"?"notes":"noteAt",[c,BigInt(Number(u)+w)]))}))),i.nextOffset=l<s?l.toString():null,e.product==="bond"&&(i.markets=await Promise.all([0n,1n].map(async p=>{try{return{id:p.toString(),quoteToken:N(await e.read("quoteToken",[p])),priceWad:String(await e.read("bondPrice",[p]))}}catch(w){return{id:p.toString(),unavailable:h.plainError(w)}}})))}return e.product==="treasury"&&(i.isMinter=await e.read("isMinter",[c]),i.isSpender=await e.read("isSpender",[c])),{chainId:y,contract:e.contract,product:e.product,blockNumber:String(e.block.number),tokens:[v,k],metrics:Object.fromEntries(o),wallet:i,units:"Raw token amounts use each token\u2019s decimals. Prices, NAV, reserve values and capacityRemaining use 18-decimal USDG WAD. Note timestamps are Unix seconds.",operations:_[e.product],caveat:"An unavailable metric is not zero. Formulaic eligibility, oracle liveness, caps and vesting are checked by the action preview. RWA entry/router calldata and initial deployment wiring remain unsupported."}}),U("netnet_financial_action",{product:W,operation:{type:"string",enum:[...new Set(Object.values(_).flat())]},amount:x(),minAmountOut:x(),maxPriceWad:x(),maxPayment:x(),marketId:{type:"integer",enum:[0,1]},recipient:{type:"string"},halted:{type:"boolean"},token:{type:"string"},noteIds:{type:"array",maxItems:50,items:x()},menu:{type:"array",maxItems:32,items:{type:"object"}}},["product","operation"],async(t,c)=>{let e=await P(t.product),r=t.operation;if(typeof r!="string"||!_[e.product].includes(r))throw new a("This operation is not supported by the selected financial product.");let u=new Set(["product","operation"]),n=[],o,i=0n,s="",l=(...d)=>d.forEach(m=>u.add(m)),p=()=>(l("amount"),A(t.amount)),w=()=>(l("minAmountOut"),A(t.minAmountOut));if(e.product==="genesis"){if(r==="purchase"&&(i=p(),o=k,n=[i],s="Founding subscription; NET is claimable only after successful finalization and vesting. A failed sale requires refund."),r==="claim"&&await e.read("claimableNetOf",[c])===0n)throw new a("No vested founding NET is claimable by this wallet.")}else if(e.product==="bond")if(r==="deposit"){if(l("marketId","maxPriceWad"),t.marketId!==0&&t.marketId!==1)throw new a("Bond marketId must be 0 (USDG) or 1 (canonical LP).");let d=BigInt(t.marketId);if(N(await e.read("quoteToken",[d]))!==(d===0n?k.address:H))throw new a("Bond quote token is not the pinned USDG or canonical LP.");i=p(),o=d===0n?k:{address:H,decimals:18,symbol:"NET/USDG LP",chainId:y};let f=A(t.maxPriceWad),b=await e.read("bondPrice",[d]);if(typeof b!="bigint"||b===0n||b>f)throw new a("Bond price exceeds maxPriceWad or is invalid.");n=[d,i,f,c],s="Payment is exchanged for a non-transferable NET note with two-day linear vesting. Redeem vested NET with the same product; payment cannot be withdrawn."}else n=[c];else if(e.product==="inverse"){if(i=p(),o=v,n=[i,w()],s="Purchased NET is burned permanently; USDG pays directly to this wallet. Capacity is denominated in USDG WAD, not raw USDG.",await e.read("active")!==!0)throw new a("NetNet buyback is inactive: oracle, finalization or capacity is unavailable.")}else if(e.product==="pteam"){if(N(await e.read("holder"))!==g(c))throw new a("This wallet is not the immutable pTEAM holder.");let d=p();if(l("maxPayment"),d>await e.read("exercisableNow"))throw new a("The NET exercise amount exceeds the vested cap.");let m=await e.read("strikeWad");if(i=(d*m/10n**BigInt(v.decimals)+10n**12n-1n)/10n**12n,i===0n||i>A(t.maxPayment))throw new a("The exercise payment exceeds maxPayment or rounds to zero.");o=k,n=[d],s=`Exercise pays ${i} USDG base units into treasury reserves and mints ${d} NET base units to the immutable holder. No withdrawal or exercise reversal exists.`}else if(e.product==="treasury"){let d=p();if(r==="mintNet"||r==="spendUsdg"){l("recipient");let m=N(t.recipient);if(await e.read(r==="mintNet"?"isMinter":"isSpender",[c])!==!0)throw new a("This wallet lacks the fixed NetNet treasury minter/spender role.");n=[m,d],s=`Protocol treasury operation sends ${d} base units to ${m}; it does not deposit into this wallet\u2019s savings.`}else n=[d],s="Permissionless protocol reserve rebalance; assets remain owned by the NetNet treasury. The deployed fraction is constrained by the immutable cap."}else if(e.product==="rwa"){if(["depositInventory","setDiscount","setInventoryMax","setHalt","setMenu"].includes(r)&&N(await e.read("manager"))!==g(c))throw new a("This wallet lacks the immutable RWA manager role.");if(r==="redeem")if(l("noteIds"),t.noteIds===void 0)n=[c];else{if(!Array.isArray(t.noteIds)||!t.noteIds.length||t.noteIds.length>50)throw new a("Provide 1..50 unique note IDs.");let m=t.noteIds.map(b=>A(b,!0));if(new Set(m.map(String)).size!==m.length)throw new a("Note IDs must be unique.");let f=await e.read("noteCount",[c]);if(m.some(b=>b>=f))throw new a("RWA note ID is out of range.");n=[c,m]}else if(r==="setHalt"){if(l("halted"),typeof t.halted!="boolean")throw new a("Provide halted as a boolean.");n=[t.halted]}else if(r==="setMenu"){if(l("menu"),!Array.isArray(t.menu)||!t.menu.length||t.menu.length>32)throw new a("Provide 1..32 explicit RWA menu entries.");let m=t.menu.map(f=>{if(!f||typeof f!="object"||Array.isArray(f)||Object.keys(f).some(L=>!["token","feed","targetWeightBps","active"].includes(L)))throw new a("Invalid RWA menu fields.");let b=f;if(typeof b.active!="boolean")throw new a("RWA active must be boolean.");return{token:N(b.token),feed:N(b.feed),targetWeightBps:A(b.targetWeightBps,!0),active:b.active}});if(new Set(m.map(f=>f.token)).size!==m.length||m.reduce((f,b)=>f+b.targetWeightBps,0n)!==10000n||m.some(f=>f.active&&(f.token===z||f.feed===z)))throw new a("RWA menu tokens must be unique, weights sum to 10000, active feeds/tokens nonzero.");n=[m],s=`Replace the complete RWA equity menu: ${JSON.stringify(T(m))}.`}else if(r==="skim")l("token"),n=[N(t.token)],s=`Sweep eligible stray assets to sleeve ${N(await e.read("sleeve"))}, not to this wallet.`;else if(r!=="pokeHwm"){let m=p();if(n=[m],r==="depositInventory"&&(o=v,i=m,s="Inventory funding is one-way. The manager cannot withdraw these NET; they are committed to bond obligations."),r==="setDiscount"&&m>await e.read("MAX_DISCOUNT_BPS")||r==="setInventoryMax"&&m>await e.read("INVENTORY_HARD_CAP"))throw new a("RWA setting exceeds its immutable maximum.")}}else e.product==="premium"?(n=[w()],s="Permissionless mint-and-sell keeper operation; all sale proceeds go to NetNet treasury. The caller receives no reward."):(n=[p(),w()],s="Convert NET already owned by the tax collector. Proceeds split to treasury and team; the caller receives no reward and supplies no NET.");if(Object.keys(t).some(d=>!u.has(d)))throw new a("Unexpected fields for this NetNet operation.");if(o&&await e.rpc.readContract({address:o.address,abi:R,functionName:"balanceOf",args:[c],blockNumber:e.block.number})<i)throw new a(`Top up ${o.symbol}: needs ${i} base units.`);let I=`NetNet ${e.product}.${r}, contract ${e.contract}, chain ${y}, values ${JSON.stringify(T(n))}. ${o?`Approve exactly ${i} ${o.symbol} base units (${o.address}, decimals ${o.decimals}). `:""}${s}`,S=[...o?[h.approval(o.address,e.contract,i.toString(),y)]:[],h.unsignedTx({to:e.contract,data:G({abi:e.abi,functionName:r,args:n}),value:"0",chainId:y,description:I})],B=await h.preview(S,c),C=0n;for(let d of B.changes){if(!/^-?\d+$/.test(d.amount))throw new a("Invalid NetNet preview amount.");if(BigInt(d.amount)<0n&&(C-=BigInt(d.amount)),BigInt(d.amount)<0n&&(!o||d.token.chainId!==y||!M(d.token.address,o.address)||d.token.decimals!==o.decimals||-BigInt(d.amount)>i))throw new a("NetNet preview spends outside the exact input budget.")}if(C>i)throw new a("NetNet preview exceeds the aggregate input budget.");return{txs:S,preview:B,summary:I}})]}};export{D as a,H as b,ae as c};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as U,c as G}from"./YDNTY67T.js";import{L as K}from"./DHUDSOGR.js";import{a as N}from"./K3RDPI5J.js";import{c as P}from"./VYAJXLND.js";import{c as R,f as L,g as H,h as W,i as z}from"./7WSHW7KW.js";import{a as F}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as I}from"./NWNYJ26T.js";import{a as _}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as S,erc20Abi as j,getAddress as T,parseAbi as k}from"viem";var w=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function q(t,s=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!s&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function le(t,s,v){return["details","analytics","manage","mint",s==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...s==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...s==="longbow"?{vault:{type:"string",enum:v.map(i=>i.vault)}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(),maxShares:u(),maxPenaltyAssets:u(),deadline:u()}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u(),maxAssets:u()}),e==="redeem"&&(m.shares=u()),e==="withdraw_assets"&&(m.amount=u()),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(),minAmountOut:u()});let J=P(t,`${s}_manage`,v[0].vault,v[0].asset),E=N(t,`${s}_analytics`,v[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:E.inputSchema;Object.assign(m,i.properties),e==="analytics"&&s==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"]}),$.push(...i.required)}return{name:`${s}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&s==="netnet"?{allOf:E.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(F(r),Object.keys(i).some(l=>!Object.hasOwn(m,l)))throw new o("Unsupported vault feature argument.");let A=s==="netnet"?v[0]:v.find(l=>typeof i.vault=="string"&&I(l.vault,i.vault));if(!A)throw new o("Choose a current vault returned by the project list tool.");let{vault:n,asset:a}=A,b={...i};if(delete b.vault,e==="details")return H(t,`${s}_details`,n,a).execute(b,r);if(e==="manage")return P(t,`${s}_manage`,n,a).execute(b,r);if(e==="analytics"){if(s==="longbow"&&i.view==="published_apy")return G(t,n,a,b);if(s==="longbow"&&i.view==="apy")return U(t,n,a,b);if(s==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await N(t,`${s}_analytics`,n).execute(b,r),asset:{...a,address:T(a.address)}}}if(e==="in_kind_exit")return K(t,n,a,i,r);let f=t.clientFor(_);if(await f.getChainId()!==_)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([f.readContract({address:n,abi:w,functionName:"asset"}),f.readContract({address:n,abi:w,functionName:"decimals"}),f.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(T(Q)!==T(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let M=e==="force_exit"?await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let l=await L(t,f,n,r,M,R(i.maxPenaltyAssets),a),C=q(i.minAmountOut),p=[l.tx],y=await t.preview(p,r);return z(y.changes,n,M,C,a),{txs:p,preview:y,summary:`${W(l.plan,a.symbol)} ${y.summary}`}}let d=e==="mint",g=e==="redeem",c=q(d||g?i.shares:i.amount),x=await f.readContract({address:n,abi:w,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[c]});if(x<=0n||d&&x>q(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let V=d?void 0:await f.readContract({address:n,abi:w,functionName:"balanceOf",args:[r]});if(!d&&(g?c:x)>V)throw new o("The wallet share balance cannot cover this exit.");let Z=d?S({abi:w,functionName:"mint",args:[c,r]}):g?S({abi:w,functionName:"redeem",args:[c,r,r]}):S({abi:w,functionName:"withdraw",args:[c,r,r]}),B=`${e} ${c} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${n}; beneficiary ${r}.`,D=[...d?[t.approval(a.address,n,x.toString(),_)]:[],t.unsignedTx({to:n,data:Z,value:"0",chainId:_,description:B})],O=await t.preview(D,r),h=(l,C)=>O.changes.filter(p=>p.token.chainId===_&&I(p.token.address,l)).reduce((p,y)=>{if(y.token.decimals!==C||!/^-?\d+$/.test(y.amount))throw new o("Invalid vault preview metadata.");return p+BigInt(y.amount)},0n);if(d?h(a.address,a.decimals)!==-x||h(n,18)!==c:g?h(n,18)!==-c||h(a.address,a.decimals)<=0n:h(a.address,a.decimals)!==c||-h(n,18)<=0n||-h(n,18)>V)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:D,preview:O,summary:`${B} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${O.summary}`}}catch(A){throw new o(t.plainError(A))}}}})}export{le as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as B}from"./P5PYFK7L.js";import{a as te,d as ne,e as oe}from"./ZQAFFWDK.js";import{d as re}from"./WP6RHXGN.js";import{b as T}from"./QHBS3PVU.js";import{a as f,b as H,c as ee}from"./43LI5NKJ.js";import{c as z}from"./OTXSKFUD.js";import{b as o,e as q}from"./IX3GZMTM.js";import{a as x,i as $,w as U,x as y,y as Z,z as J}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{decodeFunctionData as R,encodeFunctionData as L,parseAbi as se}from"viem";var we=60,G=50,Qe=200;var Ae="0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",W="0x0000000000000000000000000000000000000000",P=$[4663].routes.kyberswap.address,Q=$[4663].routes.velora.address,X=U[4663].kyberswap.toLowerCase(),ie=U[4663].velora.toLowerCase(),ge="0x0000000000000000000000000000000000000000000000000000000000000000",_=se(["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)"]),N=se(["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)"]),D=class extends r{name="NoRouteError";constructor(t="No swap route is available for this token pair and amount."){super(t)}},F=class extends r{name="ExpiredQuoteError";constructor(t="Quote has expired. Request a fresh quote."){super(t)}},ve=1e3,h=new Map;function ue(e){for(let[t,n]of h)BigInt(e)>=o(n.expiresAt)&&h.delete(t)}function K(e){return{...e,...e.sourcePoolRoute!==void 0?{sourcePoolRoute:structuredClone(e.sourcePoolRoute)}:{},...e.txs?{txs:e.txs.map(t=>({...t}))}:{}}}function ae(e){let t=K(e);return t.txs&&(t.txs.forEach(Object.freeze),Object.freeze(t.txs)),Object.freeze(t)}var Se=["router","from","to","wallet","amountIn","amountOut","minAmountOut","expiresAt","chainId","spender","value","ponsCurveToken","ponsPoolToken","blockNumber","calldataMinAmountOut","expectedSpend","expectedRefund"];function M(e,t,n=!1){for(let s of Se)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 V(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 C(e){let t=e.toLowerCase();return t===Ae.toLowerCase()||t===W.toLowerCase()}function he(e,t=G){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 be=200;function _e(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>be)throw new r("Velora returned an unsupported venue fee. Request a fresh quote.")}function de(e,t=1){return Y(t),o(e)*10000n/BigInt(1e4-t)+1n}function Oe(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 ce(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 xe(e){f(e.from),f(e.to),f(e.wallet);let t=e.callTarget??y[x].kyberswap.address,n=e.approveTarget??W;f(t),f(n);let s=o(e.amountIn),a=o(e.minAmountOut);return L({abi:_,functionName:"swap",args:[{callTarget:t,approveTarget:n,targetData:e.targetData??"0x",desc:{srcToken:e.from,dstToken:e.to,srcReceivers:C(e.from)?[]:[t],srcAmounts:C(e.from)?[]:[s],feeReceivers:[],feeAmounts:[],dstReceiver:e.wallet,amount:s,minReturnAmount:a,flags:0n,permit:"0x"},clientData:e.clientData??"0x"}]})}function Ie(e){f(e.from),f(e.to),f(e.wallet);let t=e.executor??y[x].velora.address;return f(t),L({abi:N,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??ge,beneficiary:e.wallet},e.partnerAndFee??0n,"0x",e.executorData??"0x"]})}function De(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 R({abi:_,data:e}).args[0].desc.minReturnAmount;if(t===ie)return R({abi:N,data:e}).args[1].toAmount;if(t==="0x3593564c")return ne(e).swap.amountOutMinimum;let n=R({abi:te,data:e});if(n.functionName==="buy"||n.functionName==="sell")return n.args[1];throw new r(`Unsupported swap router selector ${t}.`)}function le(e,t,n=!1){let s=o(t),a=De(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 me(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,p,A)=>{if(u.toLowerCase()!==p.toLowerCase())throw new r(`Built swap ${A} does not match the accepted quote.`)};if(l(e.to,t.router,"router"),e.chainId!==(t.chainId??x))throw new r("Built swap chain does not match the accepted quote.");let g=C(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(),c;if(i===P.toLowerCase()&&w===X){l(t.spender??t.router,P,"spender");let u=R({abi:_,data:e.data});if(L({abi:_,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("KyberSwap calldata must be canonically decodable.");let{callTarget:p,approveTarget:A,desc:m}=u.args[0];l(p,y[x].kyberswap.address,"executor"),l(A,W,"executor approval target");let b=C(n);if(m.srcReceivers.length!==m.srcAmounts.length||(b?m.srcReceivers.length!==0:m.srcReceivers.length===0||m.srcAmounts.some(v=>v<=0n)||m.srcAmounts.reduce((v,S)=>v+S,0n)!==o(d)))throw new r("KyberSwap source transfers must send the exact input to the pinned executor or verified input pool.");for(let v of m.srcReceivers)if(v.toLowerCase()!==p.toLowerCase()&&!re(n,v,e.data))throw new r(`KyberSwap source transfers: receiver ${v} is not a verified input pool or 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.");c={from:m.srcToken,to:m.dstToken,wallet:m.dstReceiver,amount:m.amount}}else if(i===Q.toLowerCase()&&w===ie){l(t.spender??t.router,Q,"spender");let u=R({abi:N,data:e.data});if(L({abi:N,...u}).toLowerCase()!==e.data.toLowerCase())throw new r("Velora calldata must be canonically decodable.");let[p,A,m,b]=u.args;if(!J.some(v=>v.toLowerCase()===p.toLowerCase()))throw new r("Built swap executor does not match the accepted quote.");if(b!=="0x")throw new r("Velora permit must match the pinned empty-permit policy.");if((t.calldataMinAmountOut!==void 0||m!==0n)&&Oe(m,t.venueFeeBps??0),t.calldataMinAmountOut!==void 0&&o(t.calldataMinAmountOut)!==de(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.");c={from:A.srcToken,to:A.destToken,wallet:A.beneficiary,amount:A.fromAmount}}else if(t.provider==="pons"&&(t.ponsPoolToken||t.ponsCurveToken))c=oe(e,{...t,from:n,to:s,wallet:a});else throw new r("Built swap selector does not match the accepted router.");if(l(c.from,n,"input token"),l(c.to,s,"output token"),l(c.wallet,a,"recipient"),c.amount!==o(d))throw new r("Built swap input amount does not match the accepted quote.");le(e.data,t.calldataMinAmountOut??t.minAmountOut,i===P.toLowerCase())}function j(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 D("Quote output amount must be positive.");let g=t.slippageBps??e.slippageBps??G,w=e.minAmountOut!==void 0?o(e.minAmountOut):o(he(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)!==de(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 O=o(t.amountIn??e.amountIn??"0"),I=o(e.expectedSpend??"0"),pe=o(e.expectedRefund??"0"),fe=o(e.calldataMinAmountOut??"0");if(O<=0n||I<=0n||I+pe!==O||fe*I/O!==w)throw new r("Pons actual minimum and refund do not match the encoded minimum.")}let i=V(t.now),c=BigInt(i+we),u=e.expiresAt!==void 0?o(e.expiresAt):c,p=(u>c?c:u).toString(),A=l.toString(),m=e.venueFeeBps??(a>0n&&l>0n?Number((l*10000n+a/2n)/a):0),b=t.provider??e.provider??(e.router.toLowerCase()===Q.toLowerCase()?"velora":"kyberswap"),v=b==="pons"&&e.feeDisclosure?e.feeDisclosure:ce({provider:b,venueFee:A,venueFeeBps:m,oakFee:"0"}),S={...e,quoteId:e.quoteId,amountOut:d.toString(),minAmountOut:w.toString(),router:e.router,expiresAt:p,provider:b,grossAmountOut:a.toString(),destAmountAfterFee:d.toString(),netAmountOut:d.toString(),venueFee:A,venueFeeBps:m,oakFee:"0",feeDisclosure:v,...t.from??e.from?{from:T(t.from??e.from)}:{},...t.to??e.to?{to:T(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??x,spender:e.spender??e.router,...t.allowance??e.allowance?{allowance:t.allowance??e.allowance}:{}};if(BigInt(i)>=o(p))throw new F;if(t.cache===!1)return S;if(ue(i),BigInt(i)>=o(p))throw new F;let k=h.get(S.quoteId);if(k){M(S,k,!0);let O=ae({...k,expiresAt:S.expiresAt});return h.set(O.quoteId,O),K(O)}for(;h.size>=ve;)h.delete(h.keys().next().value);let E=ae(S);return h.set(E.quoteId,E),K(E)}async function Ne(e,t,n={}){e={...e},f(e.from),f(e.to),f(e.wallet),e.from=T(e.from),e.to=T(e.to);let s=o(e.amountIn);if(s<=0n)throw new r("Swap amountIn must be greater than zero.");let a=e.slippageBps??G;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 D;let d={from:e.from,to:e.to,amountIn:s.toString(),slippageBps:a},l=await Promise.allSettled(t.map(async i=>{let c=await(i.quotePrices??i.quote).call(i,{...d},e.wallet);return{quote:j(c,{provider:i.name,from:e.from,to:e.to,amountIn:s.toString(),wallet:e.wallet,slippageBps:a,chainId:e.chainId??x,allowance:e.allowance,now:e.now,cache:!1}),provider:i}})),g,w=[];for(let i of l)i.status==="rejected"&&(g??=z(i.reason)),i.status==="fulfilled"&&o(i.value.quote.expiresAt)>BigInt(V(e.now))&&w.push(i.value);if(w.length===0){let i=l.some(c=>c.status==="rejected"&&c.reason instanceof Error&&c.reason.message===B)&&l.every(c=>c.status==="rejected"&&(c.reason instanceof D||c.reason instanceof Error&&c.reason.message===B));throw g??new D(i?B:void 0)}w.sort((i,c)=>{let p=o(c.quote.amountOut)-o(i.quote.amountOut)||o(c.quote.minAmountOut)-o(i.quote.minAmountOut);return p>0n?1:p<0n?-1:0});for(let{quote:i,provider:c}of w)try{if(BigInt(V(e.now))>=o(i.expiresAt))continue;if(n.deferBuild||!c.prepareQuote)return j(i,{now:e.now});let u=await c.prepareQuote(i.quoteId,e.wallet);if(u.quoteId!==i.quoteId)throw new r("Prepared quote ID does not match the selected route.");if(M(u,i,!0),!u.data)throw new r("Selected route did not return swap calldata.");let p={...i,expiresAt:u.expiresAt,data:u.data,value:u.value,allowance:u.allowance??i.allowance};return me(H({to:p.router,data:u.data,value:u.value??"0",chainId:p.chainId??x,description:"Selected swap route"}),p),j(p,{now:e.now})}catch(u){g??=z(u);continue}throw g??new D}function Me(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=V(t.now);if(ue(s),!n||BigInt(s)>=o(n.expiresAt))throw h.delete(e.quoteId),new F;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.");M(e,n),M({...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??x,i=n.spender??n.router,c=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 p=o(n.minAmountOut);if(p<=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?Ie({from:a,to:d,amountIn:u.toString(),amountOut:n.amountOut,minAmountOut:p.toString(),wallet:g}):xe({from:a,to:d,amountIn:u.toString(),minAmountOut:p.toString(),wallet:g}));le(m,n.calldataMinAmountOut??p.toString(),n.router.toLowerCase()===P.toLowerCase());let b=n.venueFee??"0",v=n.venueFeeBps??0,S=n.provider??(A?"velora":"kyberswap"),k=n.feeDisclosure??ce({provider:S,venueFee:b,venueFeeBps:v,oakFee:"0"}),E=C(a),O=t.value??e.value??n?.value??(E?u.toString():"0"),I=H({to:e.router,data:m,value:O,chainId:w,description:`Swap ${u} base units of ${a} for at least ${p} base units of ${d} via ${S} (${e.router}). ${k}`});return me(I,n),E||o(c)>=u?[I]:[ee(a,i,u.toString(),w),I]}export{we as a,G as b,Qe as c,Ae as d,W as e,_ as f,D as g,F as h,ve as i,K as j,ae as k,M as l,V as m,C as n,he as o,be as p,_e as q,de as r,Oe as s,ce as t,xe as u,Ie as v,De as w,le as x,me as y,j as z,Ne as A,Me as B};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as S,e as G,f as M,h as U,i as x,l as T,m as C,n as L,o as B,p as I,q as j,w as D,z as _}from"./N4Q6GN65.js";import{a as O,b as h}from"./X5V2Z2NM.js";import{a as N}from"./43LI5NKJ.js";import{c as F,g as A}from"./NWNYJ26T.js";import{a as p}from"./XSD5NL7J.js";import{a as $}from"./JXOEJPJ4.js";import{encodeFunctionData as q}from"viem";var z=10n**38n,W=`0x${"00".repeat(32)}`;function E(s,g){let k=s<0n,l=(k?-s:s).toString().padStart(g+1,"0"),P=l.slice(0,l.length-g),v=g?l.slice(l.length-g).replace(/0+$/,""):"";return`${k?"-":""}${P}${v?`.${v}`:""}`}var ie=s=>{let g=(e,a,i)=>({name:e,inputSchema:a,execute:async(t,n)=>{try{return N(n),L(s,t.chainId),await i(t,n)}catch(r){throw new p(s.plainError(r))}}}),k={transactionHash:{...G,description:"After local submission, repeat the same arguments with the mined hash to verify calldata, event and registry state."}},l=(e,a,i)=>s.clientFor(U(s).chainId).readContract({address:e,abi:h,functionName:a,args:i});async function P(e){let{chainId:a,registry:i}=U(s),t=await s.clientFor(a).readContract({address:i,abi:O,functionName:"ownerOf",args:[e]});return N(t),t}let v=e=>{if(typeof e!="string"||!/^[1-9][0-9]{0,18}$/.test(e)||BigInt(e)>=2n**64n)throw new p("Provide feedbackIndex as a decimal integer string of at least 1 (indexes are 1-based).");return BigInt(e)},X=g("erc8004_give_feedback",{type:"object",additionalProperties:!1,required:["agentId","value"],description:"Post public, permanent-by-hash feedback about an agent (ERC-8004 Reputation Registry giveFeedback). You cannot rate an agent you own or operate.",properties:{agentId:S,value:{type:"string",pattern:"^-?[0-9]+$",description:'Signed integer in fixed point, e.g. "87" with valueDecimals 0 is 87; "9977" with valueDecimals 2 is 99.77.'},valueDecimals:{type:"integer",minimum:0,maximum:18,default:0},tag1:{type:"string",description:"Optional filter tag such as starred, uptime, successRate, responseTime."},tag2:{type:"string"},endpoint:{type:"string",description:"Optional endpoint the feedback is about."},feedbackURI:{type:"string",description:"Optional HTTPS/IPFS URI of an off-chain feedback file."},feedbackHash:{...M,description:"keccak256 of the feedbackURI content; optional for IPFS, recommended for HTTPS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId);if(typeof e.value!="string"||!/^-?[0-9]+$/.test(e.value))throw new p("Provide value as a signed integer string.");let n=BigInt(e.value);if(n>z||n<-z)throw new p("The feedback value is out of range (\xB11e38).");let r=e.valueDecimals===void 0?0:e.valueDecimals;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>18)throw new p("valueDecimals must be an integer from 0 to 18.");let o=I(e.tag1,"tag1",128),b=I(e.tag2,"tag2",128),u=e.endpoint===void 0?"":I(e.endpoint,"endpoint",2048),f=e.feedbackURI===void 0?"":j(e.feedbackURI,"feedbackURI"),w=e.feedbackHash===void 0?W:B(e.feedbackHash,"feedbackHash"),R=q({abi:h,functionName:"giveFeedback",args:[t,n,r,o,b,u,f,w]});return _(s,a,e,{to:i,data:R,description:`Give feedback ${e.value}e-${r} to ERC-8004 agent ${t}.`,summary:`Publishes feedback ${E(n,r)} about agent ${t}${o?` (tag ${$(o)})`:""} from this wallet. Feedback is public and attributable to this wallet; it can be revoked later but never erased. Repeat with transactionHash to read back the feedback index.`,authority:async()=>{await P(t);let{registry:m,chainId:d}=U(s);if(await s.clientFor(d).readContract({address:m,abi:O,functionName:"isAuthorizedOrOwner",args:[a,t]})===!0)throw new p("The registry refuses feedback from the owner or an approved operator of the same agent.")},verify:async m=>{let d=D(m,i,h,"NewFeedback"),c=d.feedbackIndex,H=await l(i,"readFeedback",[t,a,c]);if(d.agentId!==t||!A(String(d.clientAddress),a)||d.value!==n||H[0]!==n||H[4])throw new p("The registry event or stored feedback does not match.");return{agentId:t.toString(),feedbackIndex:c.toString(),value:E(n,r),confirmed:!0}}})}),Y=g("erc8004_revoke_feedback",{type:"object",additionalProperties:!1,required:["agentId","feedbackIndex"],properties:{agentId:S,feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$",description:"1-based index from erc8004_give_feedback or erc8004_reputation."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=v(e.feedbackIndex);return _(s,a,e,{to:i,data:q({abi:h,functionName:"revokeFeedback",args:[t,n]}),description:`Revoke feedback #${n} on ERC-8004 agent ${t}.`,summary:`Marks your feedback #${n} about agent ${t} as revoked. The original entry stays on-chain, flagged revoked. Repeat with transactionHash to verify.`,authority:async()=>{let r=await l(i,"getLastIndex",[t,a]);if(n>r)throw new p(`This wallet has given only ${r} feedback entries on agent ${t}.`);if((await l(i,"readFeedback",[t,a,n]))[4])throw new p("That feedback is already revoked.")},verify:async r=>{let o=D(r,i,h,"FeedbackRevoked"),b=await l(i,"readFeedback",[t,a,n]);if(o.agentId!==t||o.feedbackIndex!==n||!A(String(o.clientAddress),a)||!b[4])throw new p("The registry event or stored feedback does not show a revocation.");return{agentId:t.toString(),feedbackIndex:n.toString(),revoked:!0}}})}),Z=g("erc8004_append_response",{type:"object",additionalProperties:!1,required:["agentId","clientAddress","feedbackIndex","responseURI"],description:"Append a public response to a feedback entry (the agent showing a refund, or anyone tagging spam).",properties:{agentId:S,clientAddress:{...F,description:"The wallet that gave the feedback."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"},responseURI:{type:"string",description:"HTTPS or IPFS URI of the response file."},responseHash:{...M,description:"keccak256 of the response content; optional for IPFS."},...k}},async(e,a)=>{let{address:i}=x(s),t=T(e.agentId),n=C(e.clientAddress,"clientAddress"),r=v(e.feedbackIndex),o=j(e.responseURI,"responseURI"),b=e.responseHash===void 0?W:B(e.responseHash,"responseHash");return _(s,a,e,{to:i,data:q({abi:h,functionName:"appendResponse",args:[t,n,r,o,b]}),description:`Append a response to feedback #${r} by ${n} on ERC-8004 agent ${t}.`,summary:`Publishes a response (${$(o)}) under feedback #${r} that ${n} gave agent ${t}, attributed to this wallet. Responses are append-only. Repeat with transactionHash to verify.`,authority:async()=>{let u=await l(i,"getLastIndex",[t,n]);if(r>u)throw new p(`${n} has given only ${u} feedback entries on agent ${t}.`)},verify:async u=>{let f=D(u,i,h,"ResponseAppended");if(f.agentId!==t||f.feedbackIndex!==r||!A(String(f.clientAddress),n)||!A(String(f.responder),a)||f.responseURI!==o)throw new p("The registry event does not match the response.");return{agentId:t.toString(),clientAddress:n,feedbackIndex:r.toString(),responder:a,confirmed:!0}}})}),J=g("erc8004_reputation",{type:"object",additionalProperties:!1,required:["agentId"],description:"Read-only: an agent's feedback summary and entries. Pass the reviewers you trust in clients; without it the summary counts every wallet, which anyone can spam.",properties:{agentId:S,clients:{type:"array",maxItems:200,items:F,description:"Reviewer wallets to count (recommended)."},tag1:{type:"string"},tag2:{type:"string"},includeRevoked:{type:"boolean",default:!1},limit:{type:"integer",minimum:1,maximum:200,default:50},clientAddress:{...F,description:"With feedbackIndex: also count responses to that one entry."},feedbackIndex:{type:"string",pattern:"^[1-9][0-9]*$"}}},async e=>{let{address:a}=x(s),i=T(e.agentId);await P(i);let t=I(e.tag1,"tag1",128),n=I(e.tag2,"tag2",128),r=typeof e.limit=="number"?Math.min(Math.max(1,Math.trunc(e.limit)),200):50,o=Array.isArray(e.clients)?e.clients.map(d=>C(d,"client")):void 0;if(o&&o.length>200)throw new p("Provide at most 200 reviewer wallets.");let b=o??await l(a,"getClients",[i]),u=b.slice(0,200),f={count:"0",value:"0",valueDecimals:0},w=[],R=0;if(u.length){let[d,c]=await Promise.all([l(a,"getSummary",[i,u,t,n]),l(a,"readAllFeedback",[i,u,t,n,e.includeRevoked===!0])]);f={count:d[0].toString(),value:E(d[1],d[2]),valueDecimals:d[2]},R=c[0].length,w=c[0].slice(0,r).map((H,y)=>({clientAddress:H,feedbackIndex:c[1][y].toString(),value:E(c[2][y],c[3][y]),valueDecimals:c[3][y],tag1:$(c[4][y]),tag2:$(c[5][y]),revoked:c[6][y]}))}let m;if(e.clientAddress!==void 0){let d=C(e.clientAddress,"clientAddress"),c=e.feedbackIndex===void 0?0n:v(e.feedbackIndex);m=(await l(a,"getResponseCount",[i,d,c,[]])).toString()}return{agentId:i.toString(),registry:a,clientsTotal:b.length,clientsUsed:u.length,filteredByClients:o!==void 0,summary:f,feedback:w,feedbackTotal:R,truncated:R>w.length||b.length>u.length,...m===void 0?{}:{responseCount:m},note:o?"Summary counts only the reviewers you named.":"Unfiltered: every reviewer wallet counts, and anyone can post feedback for free, so a high score is not evidence. Name trusted reviewers in clients for a meaningful score."}});return{tools:[X,Y,Z,J]}};export{E as a,ie as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as S}from"./43LI5NKJ.js";import{b as N}from"./IX3GZMTM.js";import{a,j as p}from"./FWD4L3CJ.js";import{a as t}from"./XSD5NL7J.js";import{encodeFunctionData as $,erc20Abi as U,getAddress as m,parseAbi as _}from"viem";var f=_(["function asset() view returns (address)","function decimals() view returns (uint8)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function M(e){if(typeof e!="string")throw new t("Amount must be a positive base-unit integer string.");let s=N(e);if(s<=0n||s>=1n<<256n)throw new t("Amount must be positive and fit uint256.");return s}function G(e){if(typeof e!="bigint"||e<0n||e>=1n<<256n)throw new t("Invalid vault amount read.");return e}function H(e,s,o){return["mint",s==="steakhouse"?"redeem":"withdraw_assets"].map(l=>{let n=l==="mint",w=l==="redeem",h=n||w?"shares":"amount",C={type:"string",pattern:"^[0-9]+$"};return{name:`${s}_${l}`,inputSchema:{type:"object",additionalProperties:!1,required:n?["shares","maxAssets"]:[h],properties:{[h]:C,...n?{maxAssets:C}:{}}},execute:async(y,r)=>{try{if(S(r),Object.keys(y).some(b=>![h,...n?["maxAssets"]:[]].includes(b)))throw new t("Unexpected vault amount argument.");let i=M(y[h]),E=n?M(y.maxAssets):void 0,u=e.clientFor(a);if(await u.getChainId()!==a)throw new t("Vault amount actions require chain 4663.");let[T,O,P]=await Promise.all([u.readContract({address:o,abi:f,functionName:"asset"}),u.readContract({address:o,abi:f,functionName:"decimals"}),u.readContract({address:m(p),abi:U,functionName:"decimals"})]);if(typeof T!="string"||m(T)!==m(p)||O!==18||P!==6)throw new t("Vault amount actions require canonical USDG and the evidenced 18-decimal shares.");let c=G(await u.readContract({address:o,abi:f,functionName:n?"previewMint":w?"previewRedeem":"previewWithdraw",args:[i]}));if(c===0n)throw new t("The vault returned a zero amount quote.");if(n&&c>E)throw new t("The mint quote exceeds maxAssets.");let D=n?void 0:G(await u.readContract({address:o,abi:U,functionName:"balanceOf",args:[r]}));if(!n&&(w?i:c)>D)throw new t("The wallet share balance cannot cover this exit.");let R=n?$({abi:f,functionName:"mint",args:[i,r]}):w?$({abi:f,functionName:"redeem",args:[i,r,r]}):$({abi:f,functionName:"withdraw",args:[i,r,r]}),I=`${l} ${i} ${h==="shares"?"18-decimal share":"6-decimal USDG"} base units from ${s}; beneficiary ${r}.`,k=[...n?[e.approval(m(p),o,c.toString(),a)]:[],e.unsignedTx({to:o,data:R,value:"0",chainId:a,description:I})],x=await e.preview(k,r),A={address:m(p),chainId:a,symbol:"USDG",decimals:6},v={address:m(o),chainId:a,symbol:`${s} shares`,decimals:18},d=b=>x.changes.filter(g=>g.token.chainId===a&&g.token.address.toLowerCase()===b.address.toLowerCase()).reduce((g,q)=>{if(q.token.decimals!==b.decimals||!/^-?\d+$/.test(q.amount))throw new t("Invalid vault preview metadata.");return g+BigInt(q.amount)},0n);if(n?d(A)!==-c||d(v)!==i:w?d(v)!==-i||d(A)<=0n:d(A)!==i||-d(v)<=0n||-d(v)>D)throw new t("The preview does not match the requested vault amount and share balance.");return{txs:k,preview:x,summary:`${I} Quoted counterpart ${c} base units. ${x.summary} Standard ERC-4626 encodes no receipt minimum. Mint approvals use the exact current quote; accrual can require a new quote. Plain exits depend on available liquidity; use a separately previewed full force exit if required.`}}catch(i){throw new t(e.plainError(i))}}}})}export{H as a};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as b,g as L,i as B,m as o,n as D,o as U}from"./KBKK7UNY.js";import{$ as _,T as f,Y as m,Z as g,_ as p,aa as d,b as e}from"./JUZ5JU6D.js";function S(n){if(n==null)return;let t=n instanceof Date?n.getTime()/1e3:typeof n=="string"?Date.parse(n)/1e3:n;return typeof t=="number"&&Number.isFinite(t)?Math.floor(t):void 0}function x(n){let t=n.nowSec??Math.floor(Date.now()/1e3),r=S(n.endDate),u=typeof n.apr=="number"&&Number.isFinite(n.apr)?n.apr:void 0,a=Number.isFinite(n.amountUsd)&&n.amountUsd>0?n.amountUsd:void 0,l={addButton:_,declineButton:d};if(u===void 0||r===void 0||r<=t||a===void 0)return{text:e(p,{}),readable:!1,notWorth:!0,defaultButton:d,...l};let i=b(n.gasUsd),c=B({amountUsd:a,ratePct:u,days:(r-t)/86400}),s=L({gross:c,costs:i.usd,amount:a}),W=[s.tooSmall?e(g,{}):"",i.estimatedHigh?e(f,{}):""].filter(Boolean).join(" ");return{text:e(m,{apr:D(u).replace(/\.00$/,""),amount_usd:o(a),gross_usd:o(c),end_date:U(r),gas_usd:o(i.usd),net_usd:o(s.netUsd),worth_clause:W}).replace(/ +\n/g,`
|
|
2
|
-
`),readable:!0,notWorth:s.tooSmall,...s.tooSmall?{defaultButton:d}:{},...l}}function N(n){return x(n).text}export{x as a,N as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as t}from"./VYAJXLND.js";import{c as o}from"./AEL62KCG.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as U}from"./7WSHW7KW.js";import{a as _}from"./43LI5NKJ.js";import{a as I}from"./66F5ZH34.js";import{g as $}from"./NWNYJ26T.js";import{a as w,i as V}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{decodeAbiParameters as N,encodeAbiParameters as K,encodeFunctionData as h,getAddress as P,keccak256 as Y,parseAbi as H,parseAbiParameters as B}from"viem";var y=P("0xCe5c1aFa115fF8b1D6913509bfc79D9AE08CC857"),q=P("0x0FBad98595b0186dA120E41f77C102beb49f803c"),D=B("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),A="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",m=H(["function vaultV2Factory() view returns (address)","function vaultData(address) view returns (bool canPullFromIdle,uint64 penalty)","function absoluteCap(address,bytes32) view returns (uint256)","function canPullFromMarket(address,bytes32) view returns (bool)","function isActiveAdapter(address,address) view returns (bool)",`function reallocate(address vault,address deallocateAdapter,${A} deallocateMarketParams,address allocateAdapter,${A} allocateMarketParams,uint128 assets,uint64 penalty)`,`function allocateFromIdle(address vault,address adapter,${A} marketParams,uint128 assets,uint64 penalty)`,`function setAbsoluteCap(address vault,address adapter,${A} marketParams,uint256 newAbsoluteCap)`,`function setCanPullFromMarket(address vault,address adapter,${A} marketParams,bool newCanPullFromMarket)`,"function setCanPullFromIdle(address vault,bool newCanPullFromIdle)","function setIsActiveAdapter(address vault,address adapter,bool newIsActiveAdapter)","function setPenalty(address vault,uint64 newPenalty)"]),E=H(["function isAllocator(address) view returns (bool)","function allocation(bytes32) view returns (uint256)"]),z=H(["function isVaultV2(address) view returns (bool)"]),v=V[w],L=[{vault:v.vaults.netnet.address,underlying:v.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:v.vaults.longbowCore.address,underlying:v.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:v.vaults.longbowFrontier.address,underlying:v.tokens.USDG.address,symbol:"USDG",decimals:6},{vault:v.vaults.longbowEth.address,underlying:v.tokens.WETH.address,symbol:"WETH",decimals:18}];function x(n,c=256){if(typeof n!="string"||!/^\d+$/.test(n)||n.length>78||BigInt(n)>=1n<<BigInt(c))throw new s("Provide uint decimal base-unit strings.");return BigInt(n)}function R(n){if(typeof n!="string"||!/^0x[0-9a-f]{64}$/i.test(n))throw new s("Provide the exact bytes32 marketId.");return n.toLowerCase()}var M=(n,c)=>n<c?n:c;async function Q(n,c){let l=L.find(u=>typeof c.vault=="string"&&$(u.vault,c.vault));if(!l)throw new s("Choose a pinned NetNet or Longbow V2 vault.");let a={address:P(l.underlying),chainId:w,symbol:l.symbol,decimals:l.decimals},o=n.clientFor(w),e=await U(o,l.vault,a),i=(u,F,W,J=[])=>o.readContract({address:u,abi:F,functionName:W,args:J,blockNumber:e.blockNumber}),t=R(c.marketId),r=e.markets.find(u=>u.id.toLowerCase()===t);if(!r)throw new s("Target market is not in this verified vault adapter inventory.");let[p,b,k,f,O]=await Promise.all([i(y,m,"vaultV2Factory"),i(q,z,"isVaultV2",[l.vault]),i(l.vault,E,"isAllocator",[y]),i(y,m,"vaultData",[l.vault]),i(y,m,"isActiveAdapter",[l.vault,r.adapter])]);if(typeof p!="string"||P(p)!==q||b!==!0||!Array.isArray(f)||f.length!==2||typeof f[0]!="boolean"||typeof f[1]!="bigint")throw new s("Invalid Public Allocator deployment or vault configuration.");let[d]=N(D,r.data);if(P(d.irm)!==P(v.morpho.adaptive_curve_irm.address))throw new s("Public allocation requires the pinned Adaptive Curve IRM.");let g=(u,F)=>Y(K(B(`string,address,${A}`),["this/marketParams",F,N(D,u)[0]])),C=g(r.data,r.adapter),[S,T]=await Promise.all([i(y,m,"absoluteCap",[l.vault,C]),i(l.vault,E,"allocation",[C])]);if(typeof S!="bigint"||typeof T!="bigint")throw new s("Invalid allocator cap read.");let G=S>T?S-T:0n,j=await Promise.all(e.markets.filter(u=>u.id.toLowerCase()!==t).map(async u=>({...u,canPull:await i(y,m,"canPullFromMarket",[l.vault,g(u.data,u.adapter)])===!0})));return{client:o,read:i,asset:a,definition:l,data:e,target:r,params:d,permission:k===!0&&O===!0,canIdle:f[0],penalty:f[1],headroom:G,sources:j}}var rt=n=>{let c=a=>Q(n,a),l=(a,o,e,i)=>{let t={vault:{type:"string",enum:L.map(r=>r.vault)},marketId:{type:"string"},...o};return{name:a,inputSchema:{type:"object",properties:t,required:["vault","marketId",...e],additionalProperties:!1},execute:async(r,p)=>{try{if(_(p),Object.keys(r).some(b=>!Object.hasOwn(t,b)))throw new s("Unsupported Public Allocator argument.");return await i(r,p)}catch(b){throw new s(n.plainError(b))}}}};return{tools:[l("morpho_allocator",{},[],async a=>{let o=await c(a);return{chainId:w,allocator:y,vault:o.definition.vault,targetMarketId:o.target.id,asset:o.asset,blockNumber:o.data.blockNumber.toString(),enabled:o.permission,penaltyWad:o.penalty.toString(),absoluteCapHeadroom:o.headroom.toString(),idleUpperBound:(o.permission&&o.canIdle?M(o.data.idle,o.headroom):0n).toString(),sources:o.sources.map(e=>({marketId:e.id,canPull:e.canPull,assetsUpperBound:(o.permission&&e.canPull?M(M(e.capacity,o.data.blueCash),o.headroom):0n).toString()})),caveat:"Upper bounds only; vault relative/absolute caps, accrual and liquidity still constrain execution. Preview an explicit source and amount with morpho_reallocate. This standalone allocation charges its disclosed penalty; a later borrow is a separate transaction and can fail or lose the added liquidity to another borrower."}}),l("morpho_reallocate",{sourceMarketId:{type:"string",description:"A returned source market ID, or omit to allocate idle assets."},assets:I(),maxPenaltyAssets:I()},["assets","maxPenaltyAssets"],async(a,o)=>{let e=x(a.assets,128),i=x(a.maxPenaltyAssets),t=await c(a);if(!t.permission||e===0n||e>t.headroom||t.penalty>10n**18n)throw new s("Public allocation is disabled or the requested amount exceeds target headroom.");let r=(e*t.penalty+10n**18n-1n)/10n**18n;if(r>i)throw new s("Allocator penalty exceeds maxPenaltyAssets.");let p;if(a.sourceMarketId===void 0){if(!t.canIdle||e>t.data.idle)throw new s("Public idle allocation is disabled or idle funds are insufficient.");p=h({abi:m,functionName:"allocateFromIdle",args:[t.definition.vault,t.target.adapter,t.params,e,t.penalty]})}else{let d=t.sources.find(C=>C.id.toLowerCase()===R(a.sourceMarketId));if(!d||!d.canPull||e>M(d.capacity,t.data.blueCash))throw new s("The source cannot publicly supply the requested liquidity.");let[g]=N(D,d.data);p=h({abi:m,functionName:"reallocate",args:[t.definition.vault,d.adapter,g,t.target.adapter,t.params,e,t.penalty]})}let b=`Move ${e} ${t.asset.symbol} base units inside ${t.definition.vault} to market ${t.target.id}; pay ${r} ${t.asset.symbol} base units as a donation penalty. This is a standalone reallocation; a subsequent borrow is separate and not guaranteed.`,k=[...r?[n.approval(t.asset.address,y,r.toString(),w)]:[],n.unsignedTx({to:y,data:p,value:"0",chainId:w,description:b})],f=await n.preview(k,o);if(f.changes.filter(d=>d.token.chainId===w&&$(d.token.address,t.asset.address)&&d.token.decimals===t.asset.decimals).reduce((d,g)=>d+BigInt(g.amount),0n)!==-r)throw new s("Allocator preview does not match the exact donation penalty.");return{txs:k,preview:f,penaltyAmount:r.toString(),summary:`${b} The calldata binds the current penalty rate. ${f.summary}`}}),l("morpho_manage_allocator",{operation:{enum:["setIsActiveAdapter","setCanPullFromMarket","setCanPullFromIdle","setAbsoluteCap","setPenalty"]},enabled:{type:"boolean"},amount:I()},["operation"],async(a,o)=>{let e=await c(a);if(await e.read(e.definition.vault,E,"isAllocator",[o])!==!0)throw new s("This wallet is not an allocator of this vault.");let i=a.enabled,t;if(a.operation==="setAbsoluteCap")t=h({abi:m,functionName:"setAbsoluteCap",args:[e.definition.vault,e.target.adapter,e.params,x(a.amount)]});else if(a.operation==="setPenalty"){let b=x(a.amount,64);if(b>10n**18n)throw new s("Public Allocator penalty must not exceed 1e18.");t=h({abi:m,functionName:"setPenalty",args:[e.definition.vault,b]})}else{if(typeof i!="boolean")throw new s("Provide enabled as a boolean.");if(a.operation==="setIsActiveAdapter")t=h({abi:m,functionName:"setIsActiveAdapter",args:[e.definition.vault,e.target.adapter,i]});else if(a.operation==="setCanPullFromMarket")t=h({abi:m,functionName:"setCanPullFromMarket",args:[e.definition.vault,e.target.adapter,e.params,i]});else if(a.operation==="setCanPullFromIdle")t=h({abi:m,functionName:"setCanPullFromIdle",args:[e.definition.vault,i]});else throw new s("Choose a supported allocator configuration operation.")}let r=`Configure Morpho Public Allocator ${String(a.operation)}: ${JSON.stringify(a)}.`,p=[n.unsignedTx({to:y,data:t,value:"0",chainId:w,description:r})];return{txs:p,preview:await n.preview(p,o),summary:r}})]}};export{y as a,q as b,m as c,Q as d,rt as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as P}from"./SMYWWIE6.js";import{a as y}from"./JKD2B6OX.js";import{b as h,c as w,d as m}from"./2MZXTOZU.js";import{j as B}from"./7KWZ5QJU.js";import{a as b}from"./43LI5NKJ.js";import{m as f,n as g}from"./NWNYJ26T.js";import{a as u}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{erc20Abi as L,formatUnits as R}from"viem";var A=70515n,U=250202n,C=568341n;function S(a,n){return{token:{...a},amount:n.toString()}}function v(a){if(a.network!==void 0&&a.network!=="mainnet")throw new o("LayerBank requires chain 4663.")}async function k(a,n,r,e){try{return f(await a.readContract({address:n.address,abi:L,functionName:"balanceOf",args:[r],blockNumber:e}),"LayerBank returned a malformed wallet balance read.")}catch(t){throw t instanceof o?t:new o("LayerBank wallet balance could not be read. Please try again.")}}async function T(a,n,r){try{let[e,t]=await Promise.all([n.getGasPrice(),B("ETH",{client:n,http:a.http,chainId:u,blockNumber:r})]),i=g(t.usdE18,"LayerBank gas reference is unavailable.",{positive:!0}),c=f(e,"LayerBank gas reference is unavailable.");if(c===0n)throw new o("LayerBank gas reference is unavailable.");let d=p=>Number(R(p*c*i/10n**18n,18)),s=d(A+U),l=d(C);if(![s,l].every(p=>Number.isFinite(p)&&p>0))throw new o("LayerBank gas reference is unavailable.");return{gasInUsd:s,gasOutUsd:l}}catch{throw new o("LayerBank gas costs could not be checked against a fresh ETH/USD reference. Please try again.")}}async function x(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),[t,i,c,d]=await Promise.all([k(r,w,n,e.blockNumber),k(r,m,n,e.blockNumber),P(a.http),T(a,r,e.blockNumber)]),s=[...c.checks,"Gas costs use measured USDG calls plus 20% headroom; entry includes approval and supply."];e.active||s.push("LayerBank reserve is inactive."),e.frozen&&s.push("LayerBank reserve is frozen for deposits."),e.paused&&s.push("LayerBank reserve is paused."),e.capRoomBase===0n&&s.push("LayerBank supply cap has no room left.");let l={rateBasePct:e.rateBasePct,...c.bonus==="unavailable"?{}:{bonus:c.bonus},cashUsdgBase:e.cashUsdgBase,capRoomBase:e.capRoomBase,open:e.active&&!e.frozen&&!e.paused&&e.capRoomBase>0n,walletUsdgBase:t,walletReceiptBase:i,...d,checks:s};return{reserve:e,reading:l}}function H(a){return async n=>{try{return(await x(a,n)).reading}catch(r){return{rateBasePct:0,cashUsdgBase:0n,capRoomBase:0n,open:!1,walletUsdgBase:0n,walletReceiptBase:0n,gasInUsd:0,gasOutUsd:0,checks:[r instanceof o?a.plainError(r):"LayerBank could not be checked right now. Please try again."]}}}}async function z(a,n){v(a),b(n);let r=a.clientFor(u),e=await y(r),t=await k(r,m,n,e.blockNumber);if(t===0n)return[];let i=a.formatAmount(t.toString(),6);return[{module:"layerbank",id:`${u}:${h}`,chainId:u,assets:[S(m,t)],description:`${i} lRobUSDG = ${i} USDG; base supply rate ${e.rateBasePct}% a year, read now.`}]}export{A as a,U as b,C as c,S as d,v as e,k as f,x as g,H as h,z as i};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as y,i as A}from"./IPN6Z4JM.js";import{b as p,e as f,g as v}from"./PIIHOXWF.js";import{c as l}from"./NWNYJ26T.js";import{a as g}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{parseAbi as I,zeroAddress as N}from"viem";var S=I(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives,uint160[] secondsPerLiquidityCumulativeX128s)"]);function j(s){return{tools:[{name:"uniswap_oracle",inputSchema:{type:"object",additionalProperties:!1,required:["token0","token1","fee","secondsAgo"],properties:{token0:l,token1:l,fee:{type:"integer",minimum:0,maximum:999999},secondsAgo:{type:"integer",minimum:1,maximum:4294967295}}},async execute(t){v(t,["token0","token1","fee","secondsAgo"]);let a=p(t.token0),c=p(t.token1),o=t.fee,e=t.secondsAgo;if(BigInt(a)>=BigInt(c))throw new r("Oracle tokens must be strictly sorted token0 < token1.");if(typeof o!="number"||!Number.isInteger(o)||o<0||o>=1e6||typeof e!="number"||!Number.isInteger(e)||e<=0||e>4294967295)throw new r("Provide integer fee pips and a positive uint32 secondsAgo.");let m=s.clientFor(g),i=await m.getBlockNumber(),u=await m.readContract({address:y.factory,abi:A,functionName:"getPool",args:[a,c,o],blockNumber:i});if(u===N)throw new r("No factory-verified v3 pool exists for this oracle.");let[[n,k],w,h]=await Promise.all([m.readContract({address:u,abi:S,functionName:"observe",args:[[e,0]],blockNumber:i}),f(s,a,i),f(s,c,i)]);if(n.length!==2||k.length!==2)throw new r("Oracle returned an unexpected observation count.");let d=n[1]-n[0],b=BigInt(e),P=d/b-(d<0n&&d%b!==0n?1n:0n);return{pool:u,token0:w,token1:h,secondsAgo:e,blockNumber:i.toString(),tickCumulatives:n.map(String),secondsPerLiquidityCumulativeX128s:k.map(String),arithmeticMeanTick:P.toString(),summary:"V3 time-weighted arithmetic mean tick, rounded toward negative infinity. Price is token1-base-units per token0-base-unit before decimal adjustment. Insufficient pool history reverts; an unavailable oracle is never reported as zero."}}}]}}export{j as a};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import{a as ae}from"./3CCBUYUM.js";import{a as bt,d as wt,e as ht}from"./CHXBOXOD.js";import{a as Ne}from"./7MR37STI.js";import{a as We,b as Be,d as pt}from"./7WSHW7KW.js";import{b as ut,c as mt,d as ft}from"./AEL62KCG.js";import{d as ct,e as te}from"./BOVMED7R.js";import{a as dt}from"./QHBS3PVU.js";import{b as lt}from"./SPJCSEKP.js";import{a as q}from"./43LI5NKJ.js";import{a as A,d as z}from"./66F5ZH34.js";import{d as De,g as E,i as Ue}from"./NWNYJ26T.js";import{b as Me}from"./IX3GZMTM.js";import{j as it}from"./ABPL3ZZI.js";import{a as p,i as V}from"./FWD4L3CJ.js";import{a as i,e as se}from"./XSD5NL7J.js";import{a as ze}from"./JXOEJPJ4.js";import{encodeFunctionData as me,erc20Abi as Ha,getAddress as Kt,parseAbi as st,zeroAddress as qa}from"viem";import{decodeAbiParameters as aa,encodeFunctionData as oa,getAddress as ie,parseAbiParameters as ra,zeroAddress as fe,zeroHash as It}from"viem";import{decodeAbiParameters as Xt,encodeFunctionData as Yt,erc20Abi as Jt,getAddress as St,parseAbi as Zt,parseAbiParameters as ea,zeroHash as kt}from"viem";var Ke=St("0xCE29862924756584BBD0D75CA1249d22007E2813"),At="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",ta="(uint256 value,uint256 nonce,uint256 deadline,uint8 v,bytes32 r,bytes32 s)",yt=Zt(["function BLUE() view returns (address)",`function vaultExitBundlesV1InKindRedemptionVaultV2(address vault,address adapter,${At}[] marketParamsList,uint256 exitAssets,${ta} sharesPermit,uint256 deadline)`]);function N(e,t=!1){if(typeof e!="string"||!/^\d{1,78}$/.test(e)||BigInt(e)>=1n<<256n||!t&&BigInt(e)===0n)throw new i("Provide a positive uint256 decimal base-unit string.");return BigInt(e)}var gt=(e,t)=>e<t?e:t;async function Za(e,t,s,r,n){q(n);let l=N(r.amount),a=N(r.maxShares),o=N(r.maxPenaltyAssets,!0),u=N(r.deadline),d=e.clientFor(p),m=await pt(d,t,s),c=(S,B,Te,ee=[])=>d.readContract({address:S,abi:B,functionName:Te,args:ee,blockNumber:m.blockNumber}),[f,b,w,h]=await Promise.all([d.getBlock({blockNumber:m.blockNumber}),c(Ke,yt,"BLUE"),c(t,Jt,"balanceOf",[n]),c(t,We,"previewRedeem",[a])]);if(typeof b!="string"||St(b)!==U)throw new i("VaultExitBundlesV1 does not report the pinned Morpho Blue.");if(u<f.timestamp||u>f.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");if(a>Be(w))throw new i("maxShares exceeds the wallet share balance.");let y=gt(m.idle,l),k=m.markets.filter(S=>S.supplied>0n&&W(S.id)),g=l-y,T=k[0]?.penalty??0n,I=g*10n**18n/(10n**18n+T);if(g>0n&&I===0n)throw new i("The penalty-adjusted in-kind amount rounds to zero.");let M=[];for(let S of k){if(I===0n)break;let B=gt(S.supplied,I);M.push({marketId:S.id,assets:B,penalty:(B*S.penalty+10n**18n-1n)/10n**18n}),I-=B}if(I>0n)throw new i("The supported adapter positions cannot cover the requested in-kind exit. Reduce the amount; unverified market positions are not transferred.");if(l+BigInt(M.length)>Be(h))throw new i("maxShares cannot cover the exit and per-market rounding buffer.");if(M.some(S=>S.assets>m.blueCash))throw new i("Morpho Blue cannot fund the largest in-kind callback. Reduce the amount.");let C=M.reduce((S,B)=>S+B.penalty,0n);if(C>o)throw new i("In-kind penalty exceeds maxPenaltyAssets.");let v=[...y?[y]:[],...M.flatMap(S=>[S.assets,S.penalty].filter(B=>B>0n))],G=(await Promise.all(v.map(S=>c(t,We,"previewWithdraw",[S])))).reduce((S,B)=>S+Be(B),0n);if(G===0n||G>a)throw new i("Separately rounded burns exceed maxShares.");let Z=M.map(S=>Xt(ea(At),m.markets.find(B=>B.id===S.marketId).data)[0]),H=m.markets[0]?.adapter;if(!H)throw new i("In-kind exit requires a verified market adapter.");let F=`In-kind exit from ${t}: spend at most ${G} share base units; receive ${y} ${s.symbol} base units and Morpho Blue supply positions ${M.map(S=>`${S.marketId}: ${S.assets} ${s.symbol} base units`).join(", ")||"none"}. Penalty ${C} ${s.symbol} base units. Deadline ${u} (Unix seconds). Supply positions remain exposed to borrower default and can only be withdrawn when market liquidity returns. This is not a cash exit. The exact share allowance bounds drift; accrual can require a fresh preview.`,P=Yt({abi:yt,functionName:"vaultExitBundlesV1InKindRedemptionVaultV2",args:[t,H,Z,l,{value:0n,nonce:0n,deadline:0n,v:0,r:kt,s:kt},u]}),D=[e.approval(t,Ke,G.toString(),p),e.unsignedTx({to:Ke,data:P,value:"0",chainId:p,description:F})],$=await e.preview(D,n),j=-$.changes.filter(S=>S.token.chainId===p&&E(S.token.address,t)).reduce((S,B)=>{if(B.token.decimals!==18||!/^-?\d+$/.test(B.amount))throw new i("Invalid in-kind share preview.");return S+BigInt(B.amount)},0n);if(j<=0n||j>G)throw new i("In-kind preview exceeds the exact share authorization or burns no shares.");return{txs:D,preview:$,summary:F,receipt:{idleAssets:y.toString(),positions:M.map(S=>({marketId:S.marketId,asset:s,assets:S.assets.toString()})),penaltyAssets:C.toString()}}}var pe=ie("0x53A1eB6589861F686af7c531211E35Aefe30210f"),xt=["supply","withdraw","supplyCollateralAndBorrow","repayAndWithdrawCollateral","migrateBorrowPosition"],Qe={kind:0,data:"0x"},Oe={nonce:0n,deadline:0n,signature:{v:0,r:It,s:It}},na=ra("(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)"),Tt=e=>({tools:[{name:"morpho_bundle",inputSchema:{type:"object",additionalProperties:!1,required:["operation","marketId","deadline"],properties:{operation:{type:"string",enum:xt},marketId:{type:"string"},destinationMarketId:{type:"string"},assets:A(),collateralAssets:A(),shares:A(),maxRepayAssets:A(),maxLtv:A(),deadline:A(),allocations:{type:"array",maxItems:4,items:{type:"object",additionalProperties:!1,required:["vault","assets","maxPenaltyAssets"],properties:{vault:{type:"string"},sourceMarketId:{type:"string"},assets:A(),maxPenaltyAssets:A()}}}}},execute:async(t,s)=>{try{q(s);let r=t.operation,n=e.clientFor(p);if(await n.getChainId()!==p||typeof r!="string"||!xt.includes(r))throw new i("Choose a supported Blue bundle on chain 4663.");let l=["operation","marketId","deadline",...r==="supply"?["assets"]:r==="withdraw"?["assets","shares","allocations"]:r==="supplyCollateralAndBorrow"?["collateralAssets","assets","maxLtv","allocations"]:r==="repayAndWithdrawCollateral"?["assets","shares","maxRepayAssets","collateralAssets","maxLtv"]:["destinationMarketId","maxLtv","allocations"]];if(Object.keys(t).some(P=>!l.includes(P)))throw new i("Unexpected argument for this Blue bundle.");let a=await n.getBlock(),o=N(t.deadline);if(o<a.timestamp||o>a.timestamp+300n)throw new i("Use an absolute Unix deadline within the next five minutes.");let[u,d]=await Promise.all([n.readContract({address:pe,abi:Ne,functionName:"BLUE",blockNumber:a.number}),n.readContract({address:pe,abi:Ne,functionName:"PUBLIC_ALLOCATOR",blockNumber:a.number})]);if(ie(u)!==U||ie(d)!==bt)throw new i("BlueBundlesV1 deployment does not match Oak\u2019s pinned Blue and Public Allocator.");let m=async P=>{if(typeof P!="string"||!W(P))throw new i("Choose a verified Morpho market with a supported exit.");let D=await n.readContract({address:U,abi:O,functionName:"idToMarketParams",args:[P],blockNumber:a.number}),$={loanToken:ie(D[0]),collateralToken:ie(D[1]),oracle:ie(D[2]),irm:ie(D[3]),lltv:D[4]};if(!E(be({...$,lltv:String($.lltv)}),P))throw new i("Blue bundle market identity mismatch.");return $},c=await m(t.marketId),f=r==="migrateBorrowPosition"?await m(t.destinationMarketId):c;if(c.loanToken!==f.loanToken||c.collateralToken!==f.collateralToken)throw new i("Migration requires the same loan and collateral tokens.");if(r==="migrateBorrowPosition"&&t.marketId===t.destinationMarketId)throw new i("Choose a different destination market.");if(r!=="supply"&&!await n.readContract({address:U,abi:O,functionName:"isAuthorized",args:[s,pe],blockNumber:a.number}))throw new i(`Authorize the pinned Blue bundle explicitly with morpho_manage setAuthorization account ${pe}, enabled true, then retry. That authority covers all Blue positions. Revoke it with enabled false after the bundle.`);let b=t.assets===void 0?0n:N(t.assets,!0),w=t.shares===void 0?0n:N(t.shares,!0),h=t.collateralAssets===void 0?0n:N(t.collateralAssets,!0),y=r==="supply"||r==="withdraw"?0n:N(t.maxLtv,!0);if(y>f.lltv)throw new i("maxLtv cannot exceed the verified destination market LLTV.");if(r==="supply"&&b===0n||r==="withdraw"&&b===0n==(w===0n)||r==="supplyCollateralAndBorrow"&&h===0n&&b===0n||r==="repayAndWithdrawCollateral"&&(b>0n&&w>0n||b===0n&&w===0n&&h===0n))throw new i("Choose a nonzero amount; assets and shares are mutually exclusive for repayment/withdrawal.");let k=t.allocations??[];if(!Array.isArray(k)||k.length>4||k.length&&r==="supplyCollateralAndBorrow"&&b===0n)throw new i("Provide at most four explicit allocations, only with a borrow or withdrawal.");let g=new Set,T=[],I=0n;for(let P of k){if(!P||typeof P!="object"||Array.isArray(P)||Object.keys(P).some(Ve=>!["vault","sourceMarketId","assets","maxPenaltyAssets"].includes(Ve)))throw new i("Unsupported bundled allocation input.");let D=P,$=await wt(e,{vault:D.vault,marketId:r==="migrateBorrowPosition"?t.destinationMarketId:t.marketId});if(g.has($.definition.vault.toLowerCase()))throw new i("Use each source vault at most once per bundle.");g.add($.definition.vault.toLowerCase());let j=N(D.assets),S=N(D.maxPenaltyAssets,!0);if(!$.permission||j>=1n<<128n||j>$.headroom||$.penalty>10n**18n||$.asset.address!==f.loanToken)throw new i("Bundled allocation is disabled, unqualified or exceeds target capacity.");let B=(j*$.penalty+10n**18n-1n)/10n**18n;if(B>S)throw new i("Bundled allocation exceeds maxPenaltyAssets.");I+=B;let Te=D.sourceMarketId===void 0,ee=Te?void 0:$.sources.find(Ve=>E(Ve.id,String(D.sourceMarketId)));if(Te?!$.canIdle||j>$.data.idle:!ee||!ee.canPull||j>ee.capacity||j>$.data.blueCash)throw new i("Bundled allocation source cannot cover the requested amount.");T.push({vault:$.definition.vault,adapter:$.target.adapter,marketParams:$.params,sourceAdapter:ee?.adapter??fe,sourceMarketParams:ee?aa(na,ee.data)[0]:$.params,assets:j,penalty:$.penalty,fromIdle:Te})}let M,C,v,x=0n;if(r==="supply")M="blueBundlesV1Supply",v=c.loanToken,x=b,C=[c,b,Qe,0n,fe,o];else if(r==="withdraw")M="blueBundlesV1Withdraw",C=[c,b,w,Oe,T,0n,fe,o];else if(r==="supplyCollateralAndBorrow"){if(M="blueBundlesV1SupplyCollateralAndBorrow",v=c.collateralToken,x=h,I>=b&&I>0n)throw new i("Allocation penalties would consume the borrow proceeds.");C=[c,h,b,y,Qe,Oe,T,0n,fe,o]}else if(r==="repayAndWithdrawCollateral"){if(M="blueBundlesV1RepayAndWithdrawCollateral",v=c.loanToken,x=N(t.maxRepayAssets,!0),b>x||w>0n&&x===0n)throw new i("Repayment requires a sufficient maxRepayAssets budget.");C=[c,b,w,x,h,y,Qe,Oe,0n,fe,o]}else M="blueBundlesV1MigrateBorrowPosition",C=[c,f,y,Oe,T,0n,fe,o];let G=`Morpho Blue atomic ${r}: ${JSON.stringify(t)}. Allocation penalties ${I} loan-token base units; zero referral fee. Max LTV ${y}; absolute deadline ${o}. Migration adds allocation penalties to destination debt; borrowing deducts them from proceeds. Exact input approval ${x}. Existing Blue bundle authorization remains until explicitly revoked with morpho_manage. No opaque callback, permit or signature is accepted.`,Z=[...v&&x?[e.approval(v,pe,x.toString(),p)]:[],e.unsignedTx({to:pe,data:oa({abi:Ne,functionName:M,args:C}),value:"0",chainId:p,description:G})],H=await e.preview(Z,s),F=new Map;for(let P of H.changes)if(BigInt(P.amount)<0n){let D=P.token.address.toLowerCase();F.set(D,(F.get(D)??0n)-BigInt(P.amount))}if([...F].some(([P,D])=>!v||P!==v.toLowerCase()||D>x))throw new i("Bundle preview spends outside the exact input budget.");return{txs:Z,preview:H,summary:G}}catch(r){throw new i(e.plainError(r))}}}]});import{concatHex as Mt,decodeAbiParameters as sa,encodeAbiParameters as $t,encodeFunctionData as Xe,erc20Abi as Pt,getAddress as K,keccak256 as Je,zeroAddress as we,zeroHash as ia}from"viem";var Y=K("0x6120765Ba5336150BbdDdD0Cd9108B5bFD369632"),la=["0x90B800999e4ACd1bD20283BD450bBd2e06D91F7C","0x708d6Bf6F847202a0755bb5636bE663B174242ea"].map(e=>K(e)),Ze=ae.find(e=>e.name==="take"),vt=[Ze.inputs[0]],da=[Ze.inputs[0].components[0]];function Ct(e){let t=Je(Mt(["0x600b380380600b5f395ff3",$t(da,[e])]));return Je(Mt(["0xff",e.midnight,ia,t]))}var le=10n**18n,Lt=(e,t)=>(e+(t-1n)/2n)/t;function Dt(e){if(e<0n)return 10n**36n/Dt(-e);let t=693147180559945309n,s=(e+322611214989459870n)/t,r=e-s*t,n=r*r/(2n*le),l=n*r/(3n*le);return le+r+n+l<<s}function ca(e){if(e<0n||e>6744n)throw new i("Midnight tick is outside 0..6744.");return Lt(Lt(10n**36n,le+Dt(4987541511039073n*(3372n-e))),10n**11n)*10n**11n}function Ge(e,t){if(typeof e!="string"||!/^0x([0-9a-f]{2})*$/i.test(e)||e.length>32770||t!==void 0&&e.length!==2+t*2)throw new i("Provide bounded canonical hex data.");return e}function Ye(e,t){if(!Array.isArray(e)||e.length!==t)throw new i("Invalid Midnight state tuple.");return e.map(s=>{if(typeof s=="number"&&Number.isSafeInteger(s)&&s>=0)return BigInt(s);if(typeof s=="bigint"&&s>=0n)return s;throw new i("Invalid Midnight integer state.")})}var ua=e=>JSON.parse(JSON.stringify(e,(t,s)=>typeof s=="bigint"?s.toString():s)),Ut=e=>{async function t(n,l){let a=Ge(n,32),o=e.clientFor(p);if(await o.getChainId()!==p)throw new i("Midnight requires chain 4663.");let u=await o.getBlock(),d=(k,g=[])=>o.readContract({address:Y,abi:ae,functionName:k,args:g,blockNumber:u.number}),m=await d("toMarket",[a]);if(m.chainId!==BigInt(p)||K(m.midnight)!==Y||!E(Ct(m),a))throw new i("Midnight market identity does not match the pinned chain and contract.");if(![V[p].tokens.USDG.address,V[p].tokens.WETH.address].some(k=>E(k,m.loanToken)))throw new i("This Midnight loan token needs a qualified transfer and exit fixture.");if(!m.collateralParams.length||m.collateralParams.length>128)throw new i("Invalid Midnight collateral inventory.");let[f,b,w,h]=await Promise.all([d("position",[a,l]),d("updatePositionView",[m,a,l]),d("marketState",[a]),d("isHealthy",[m,a,l])]),y=async k=>{let[g,T]=await Promise.all([o.readContract({address:k,abi:Pt,functionName:"decimals",blockNumber:u.number}),o.readContract({address:k,abi:Pt,functionName:"symbol",blockNumber:u.number})]);if(!Number.isInteger(g)||g>36||typeof T!="string")throw new i("Invalid Midnight token metadata.");return{address:K(k),decimals:g,symbol:T.replace(/[^a-zA-Z0-9.$_-]/g,"").slice(0,32),chainId:p}};return{id:a,rpc:o,block:u,market:m,read:d,token:y,loan:await y(m.loanToken),position:Ye(f,6),updated:Ye(b,3),state:Ye(w,13),healthy:h}}let s=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,additionalProperties:!1},execute:async(u,d)=>{try{if(q(d),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Midnight argument.");return await o(u,d)}catch(m){throw new i(e.plainError(m))}}});async function r(n,l,a){return{txs:n,preview:await e.preview(n,l),summary:a}}return{tools:[s("morpho_midnight_status",{marketId:{type:"string"}},["marketId"],async(n,l)=>{let a=await t(n.marketId,l),o=await Promise.all(a.market.collateralParams.map(async(m,c)=>({token:await a.token(m.token),lltvWad:m.lltv.toString(),oracle:m.oracle,assets:String(await a.read("collateral",[a.id,l,BigInt(c)]))}))),u=["configurator","feeSetter","feeClaimer","tickSpacingSetter"],d=await Promise.all(u.map(m=>a.read(m)));return{protocol:Object.fromEntries(u.map((m,c)=>[m,K(String(d[c]))])),continuousFeePerSecondWad:String(a.state[11]),tickSpacing:String(a.state[12]),settlementFeeCbps:a.state.slice(4,11).map(String),settlementFeeCbpWadScale:"1000000000000",chainId:p,midnight:Y,marketId:a.id,blockNumber:String(a.block.number),market:ua(a.market),loanToken:a.loan,collaterals:o,debtUnits:String(a.position[4]),creditUnits:String(a.updated[0]),pendingFeeUnits:String(a.updated[1]),withdrawableUnits:String(a.state[2]),healthy:a.healthy,maturity:String(a.market.maturity),matured:a.block.timestamp>a.market.maturity,warning:"Maturity does not guarantee lender liquidity. Borrowers become liquidatable after maturity even when collateralized. Lender credit may absorb borrower default losses."}}),s("morpho_midnight_take",{offer:{type:"string",description:"ABI-encoded Offer struct, never transaction calldata."},ratifierData:{type:"string"},units:A(),maxAssets:A(),minAssets:A()},["offer","ratifierData","units","maxAssets","minAssets"],async(n,l)=>{let a=Ge(n.offer),[o]=sa(vt,a);if(!E($t(vt,[o]),a))throw new i("Offer encoding is not canonical.");let u=await t(Ct(o.market),l),d=N(n.units),m=N(n.maxAssets,!0),c=N(n.minAssets,!0),f=Ge(n.ratifierData);if(d>=1n<<128n||E(o.maker,l)||o.callback!==we||o.callbackData!=="0x"||!la.includes(K(o.ratifier)))throw new i("Use a non-self offer with a pinned ratifier and no maker callbacks. Callback routes need a separate qualified builder.");if(u.block.timestamp<o.start||u.block.timestamp>o.expiry||o.expiry<o.start)throw new i("The Midnight offer is not currently live.");if(o.buy&&o.receiverIfMakerIsSeller!==we||!o.buy&&o.receiverIfMakerIsSeller===we)throw new i("Invalid offer seller receiver.");if(o.buy&&u.block.timestamp>u.market.maturity&&d>u.updated[0])throw new i("Post-maturity sales cannot increase this wallet\u2019s debt.");let b=await u.read("settlementFee",[u.id,u.market.maturity>u.block.timestamp?u.market.maturity-u.block.timestamp:0n]),w=ca(o.tick);if(b>w&&o.buy)throw new i("Settlement fee exceeds the offer price.");let h=o.buy?w-b:w,y=h+b,k=P=>o.buy?P/le:(P+le-1n)/le,g=k(d*y),T=k(d*h);if(o.buy?T<c||T===0n:g>m||g===0n)throw new i("Midnight proceeds/spend do not fit the requested bounds.");let I=await u.read("consumed",[o.maker,o.group]);if(o.maxAssets===0n==(o.maxUnits===0n)||I+(o.maxAssets?o.buy?g:T:d)>(o.maxAssets||o.maxUnits))throw new i("Midnight offer capacity is exhausted or invalid.");if(u.state[11]>o.continuousFeeCap||o.tick%u.state[12]!==0n)throw new i("Offer fee cap or market tick spacing no longer permits execution.");let M=await u.read("isAuthorized",[o.maker,o.ratifier]),C=[{type:"function",name:"isRatified",stateMutability:"view",inputs:[Ze.inputs[0],{type:"bytes"},{type:"address"}],outputs:[{type:"bytes32"}]}],v=await u.rpc.readContract({address:o.ratifier,abi:C,functionName:"isRatified",args:[o,f,l],blockNumber:u.block.number});if(M!==!0||v!==Je(new TextEncoder().encode("morpho.midnight.callbackSuccess")))throw new i("The maker has not authorized and ratified this exact offer.");let x=Xe({abi:ae,functionName:"take",args:[o,f,d,l,o.buy?l:we,we,"0x"]}),G=`Midnight ${o.buy?"sell credit or borrow":"buy credit or reduce debt"}: ${d} fixed debt units; ${o.buy?`receive ${T}`:`spend ${g}`} ${u.loan.symbol} base units (token ${u.loan.address}, decimals ${u.loan.decimals}). Maturity ${u.market.maturity} Unix seconds; offer expiry ${o.expiry}. A borrower can lose collateral after maturity; lender withdrawal depends on repayments and bears default losses. No lender signature or callback is created. Bounds are rechecked locally; the take calldata fixes the offer and units. Exact buyer approval caps wallet spending.`,Z=[...o.buy?[]:[e.approval(u.loan.address,Y,g.toString(),p)],e.unsignedTx({to:Y,data:x,value:"0",chainId:p,description:G})],H=await r(Z,l,G),F=H.preview.changes.filter(P=>P.token.chainId===p&&E(P.token.address,u.loan.address)).reduce((P,D)=>P+BigInt(D.amount),0n);if(o.buy?F<T:F!==-g)throw new i("Midnight preview does not match the exact quoted cash flow.");return H}),s("morpho_midnight_action",{marketId:{type:"string"},operation:{enum:["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"]},amount:A(),collateralIndex:{type:"integer",minimum:0,maximum:127}},["marketId","operation"],async(n,l)=>{let a=await t(n.marketId,l),o=n.operation;if(!["supplyCollateral","withdrawCollateral","repay","withdraw","updatePosition","claimContinuousFee"].includes(String(o)))throw new i("Choose a finite Midnight position operation.");let u,d,m=a.loan,c=0n;if(o==="updatePosition"){if(n.amount!==void 0||n.collateralIndex!==void 0)throw new i("Position update takes no amount or collateral index.");u=[a.market,l]}else if(o==="claimContinuousFee"){if(c=N(n.amount),n.collateralIndex!==void 0||K(String(await a.read("feeClaimer")))!==K(l))throw new i("This wallet lacks the Midnight fee claimer role or supplied an unused collateral index.");u=[a.market,c,l]}else{if(c=N(n.amount),c>=1n<<128n)throw new i("Midnight position amount exceeds uint128.");if(o==="supplyCollateral"||o==="withdrawCollateral"){if(!Number.isInteger(n.collateralIndex)||Number(n.collateralIndex)<0||Number(n.collateralIndex)>=a.market.collateralParams.length)throw new i("Choose a current collateral index.");let w=BigInt(String(n.collateralIndex)),h=await a.token(a.market.collateralParams[Number(w)].token);if(m=h,o==="withdrawCollateral"&&c>await a.read("collateral",[a.id,l,w]))throw new i("Insufficient Midnight collateral.");u=o==="supplyCollateral"?[a.market,w,c,l]:[a.market,w,c,l,l],o==="supplyCollateral"&&(d=h)}else{if(n.collateralIndex!==void 0)throw new i("This operation takes no collateral index.");if(o==="repay"&&c>a.position[4]||o==="withdraw"&&(c>a.updated[0]||c>a.state[2]))throw new i("Amount exceeds current debt, credit or available repayment liquidity.");u=o==="repay"?[a.market,c,l,we,"0x"]:[a.market,c,l,l],o==="repay"&&(d=a.loan)}}let f=`Midnight ${o}: ${c} ${m.symbol} base units (token ${m.address}, decimals ${m.decimals}) on ${a.id}; beneficiary ${l}; maturity ${a.market.maturity} Unix seconds. No callbacks or delegation. Withdrawal can fail if collateral health or lender liquidity changes.`,b=[...d?[e.approval(d.address,Y,c.toString(),p)]:[],e.unsignedTx({to:Y,data:Xe({abi:ae,functionName:String(o),args:u}),value:"0",chainId:p,description:f})];return r(b,l,f)}),s("morpho_midnight_manage",{operation:{type:"string",enum:["setConsumed","setIsAuthorized","setConfigurator","setFeeSetter","setFeeClaimer","setTickSpacingSetter","enableLltv","enableLiquidationCursor","setMarketTickSpacing","setMarketSettlementFee","setMarketContinuousFee","setDefaultSettlementFee","setDefaultContinuousFee","claimSettlementFee"]},values:{type:"array",maxItems:3,items:{oneOf:[{type:"string"},{type:"boolean"}]}}},["operation","values"],async(n,l)=>{let a={setConfigurator:"configurator",setFeeSetter:"configurator",setFeeClaimer:"configurator",setTickSpacingSetter:"configurator",enableLltv:"configurator",enableLiquidationCursor:"configurator",setMarketTickSpacing:"tickSpacingSetter",setMarketSettlementFee:"feeSetter",setMarketContinuousFee:"feeSetter",setDefaultSettlementFee:"feeSetter",setDefaultContinuousFee:"feeSetter",claimSettlementFee:"feeClaimer"};if(typeof n.operation!="string"||!["setConsumed","setIsAuthorized",...Object.keys(a)].includes(n.operation)||!Array.isArray(n.values))throw new i("Choose a finite Midnight management operation and ordered values.");let o=n.operation,u=ae.find(f=>f.name===o);if(n.values.length!==u.inputs.length)throw new i("Provide the exact ordered operation values.");let d=e.clientFor(p);if(await d.getChainId()!==p)throw new i("Midnight requires chain 4663.");let m=u.inputs.map((f,b)=>{let w=n.values[b];if(f.type==="bool"){if(typeof w!="boolean")throw new i("Use boolean management values.");return w}if(f.type==="address")return Ue(w,"Use explicit management addresses.",De);if(f.type==="bytes32")return Ge(w,32);if(/^uint/.test(f.type)){let h=N(w,!0);if(h>=1n<<BigInt(f.type.slice(4)))throw new i("Management integer exceeds its ABI width.");return h}throw new i("Unsupported management argument type.")});if(o==="setConsumed"||o==="setIsAuthorized"){if(!E(String(m[2]),l))throw new i("Midnight management is bound to this wallet.")}else{let f=await d.readContract({address:Y,abi:ae,functionName:a[o]});if(typeof f!="string"||K(f)!==K(l))throw new i("This wallet lacks the Midnight configuration, fee or tick role.")}let c=`Midnight ${o}, ordered values ${JSON.stringify(n.values)}. ${o==="setIsAuthorized"&&m[1]?"This grants authority over all Midnight positions, cancellations and further delegation, without an amount cap. Revoke with false when done.":""}${o==="setConsumed"?"Consumption only increases; setting uint128 maximum permanently cancels this offer group.":""}`;return r([e.unsignedTx({to:Y,data:Xe({abi:ae,functionName:o,args:m}),value:"0",chainId:p,description:c})],l,c)})]}};import{decodeAbiParameters as oe,encodeAbiParameters as ma,encodeFunctionData as R,erc20Abi as et,getAddress as L,isAddress as Re,keccak256 as fa,parseAbi as Ee,parseAbiParameters as J}from"viem";var Pe="morpho",pa="https://api.morpho.org/graphql",U=L(V[p].morpho.morpho_blue.address),ba=L(V[p].morpho.adaptive_curve_irm.address),wa=L(V[p].morpho.USDG.address),de=L(V[p].morpho.WETH.address),ha=["0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2","0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8"],ka={"oak-recorded":"Oak recorded chain observations (block 100362239).","morpho-listed":"Morpho API (POST https://api.morpho.org/graphql, markets where chainId_in [4663]) returned listed: true, fetched 2026-10-31 UTC.",longbow:"Longbow market list: Longbow MCP list_markets/get_market (https://mcp.longbow.credit/mcp, named on https://longbow.cash/mcp) and the live market list on https://longbow.cash/earn, fetched 2026-10-31 UTC; each ID re-read on chain.",netnet:"NetNet Credit: six stock-token market IDs printed at https://docs.netnet.capital/credit, plus the Loopback wsNET/USDG market returned by NetNet's Turbo router marketId() and Credit adapter marketIds(6); fetched 2026-10-31 UTC."},tt=[{marketId:"0x7c820d6a09502d63be80bb8025ec479d29d7c06e70f8df65a92aaeed23a366e2",label:"WETH/USDG 77%",source:"oak-recorded"},{marketId:"0x1fa5293f9f60059a7f6a4923022156fcdcc038bd3749be55897000c03afe92d8",label:"USDG/WETH",source:"oak-recorded"},{marketId:"0x0309c02dabf0be02682af1a2bde9a457f4df0f0b6bc889cde3f948e5315e4114",label:"spUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x10151e2ac82a820153520d9d77d56de1c84775e23b79bdc11e2e34282d9afa10",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x127353ba63e08f74d8e9ce8a1c2b41b5f89c7167135b1c09fbed34a71b4cb06b",label:"WETH/USDG 86%",source:"morpho-listed"},{marketId:"0x1a31d1c8c05a98b94777663912e4166bf50f3fcdc9c3c3d29deb55634ac58239",label:"PONS/USDG 62.5%",source:"morpho-listed"},{marketId:"0x1efd13a2d1dc66a2466e7c25820537028e604791f00454d9c686fdfbf70f404d",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x21ea2a012b888120e328775c2a7bf6fb4619cf4c4c631ad1c9b6db51f8882d5a",label:"SPCX/USDG 62.5%",source:"morpho-listed"},{marketId:"0x22e4598e5cc16cff0056e72d61c5f1f2f8bf5bbffc22da5277ab196939c8a59e",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x66306c087add8907752320b309934abcc354d21626de8115c79df49d9c214edc",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0x69400cfe81f2ae381b9a9f27076a4d637338379d999e9ffdfbde52f0876312ee",label:"META/USDG 62.5%",source:"morpho-listed"},{marketId:"0x7408b08b03e05ffd2d21c797489a0e77a28e4bb36acb4e827c69e805d06272b4",label:"GOOGL/USDG 77%",source:"morpho-listed"},{marketId:"0x7c1e38bf461da47df9805ae9b7e97a12ec023625a1f92d2a403b3b9a92260894",label:"CASHCAT/USDG 62.5%",source:"morpho-listed"},{marketId:"0x919a9b6b94dae7c86620eaf7a08e597aae8a4c3a9e9c7671771fbaf62b6b61c7",label:"syrupUSDG/USDG 91.5%",source:"morpho-listed"},{marketId:"0x93ed7865910b09f5a2e0dbfd4670c2d3bc1da9647f7c68e7975f37f497898cdb",label:"mGLO/USDG 91.5%",source:"morpho-listed"},{marketId:"0x947ae981cc823024ea00b602f6ea72d049cac05d66ef096198ceeb998651c175",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0x95312f02c1dae8407b2c80468a5657a9bd19c45ac277f1a61aa52c11444c5314",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xba01f6625137b692c5dd86afb8e654b4016d7b64e36dfca4124e84bef98bc4d2",label:"GOOGL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xc845da65a020ddca5f132efa8fea79676d8edfdea504226a4c01e7a9e34cddd6",label:"USDe/USDG 91.5%",source:"morpho-listed"},{marketId:"0xcaa167af7ba0422c76424fae56167b7db25bf19f4f435215e6dd7d06a943bdac",label:"AAPL/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe29c7d3790037800101ecbad9c45de2067698d206cbcab7c25069a9f43c9eb98",label:"TSLA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xe5a6d99c3721ef2ab00fb16f0ad226bc7c87a90394f82e27dc6bbca4b1d95c5d",label:"AI/USDG 62.5%",source:"morpho-listed"},{marketId:"0xeb1739b2a69dd22a4285d366a06698a01018b37c24d2994fefe19cc72f313613",label:"SPY/USDG 77%",source:"morpho-listed"},{marketId:"0xf5ff7d546af5e72f3912d2aa723088fd0bf66fddc158714995637714d9db6e4c",label:"NVDA/USDG 62.5%",source:"morpho-listed"},{marketId:"0xaa586d26a6fe62d9c0f0948fede6e2130500ac7a655587447e2d4a37e6330589",label:"wsNET/USDG 62.5% (NetNet Loopback)",source:"netnet"},{marketId:"0x8b16891f032a93b771347c9cb470a780e6699dd701553d3402aa3cdba6189c3e",label:"NVDA/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x9b4b47cdf7e295341c6c6cdfd3efb9805c4a5b3d580dba0c0c39d3a4232b297b",label:"SPCX/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0xdeb4782d012d5fd3b24962538c2f6559049d70bda4dabd2e4212dacb96c28d45",label:"AAPL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x7fa81b10e5d21b2e4c571f862442bc11aff2ed14f02335868d0ff933fd40d0ba",label:"GOOGL/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x2e1859aa8f143b7220088f80562c6dfe0bf8e52b87d9cedf8da8805f231994ce",label:"MSFT/USDG 62.5% (NetNet Credit)",source:"netnet"},{marketId:"0x3ebd43d91c3960a9fac32bedd5c60428e0e414de5bdd67fda770207afb0eb615",label:"COIN/USDG 38.5% (NetNet Credit)",source:"netnet"},{marketId:"0x26f3bd5919ba0e6ea6f4bca1b8bd95ce29cbe3aad4ef824fb007570eac35103b",label:"cbBTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb095654f06f4d17d4fc010c2d89a107649e3c5b58e53a3812d1736c95e63e3f8",label:"NVDAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x947c05e7c0fa3ba187d57db710d04ba8be4fef53baba0cfbe71ce61b34a1367d",label:"SPCXon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf8f0b5badf06192908bc47af32b93742d9b4fb6072d388cb183ff7849ee6534c",label:"SPYon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x26c80a00f8facc6b081989965d89cedc274b90b81be660e69245a74e5384f5de",label:"METAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xeefec6c3e5cb7df1f2366ea7cf96a583081205b9720e807d2868d9866a702229",label:"GOOGLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf511a080dcb4d0a3b9d6aebb06e24afa011cda87f9f71ada70c60f8220e94f35",label:"AAPLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xa87da1cc931faa945a41861cc9c90076772ceeae9a663836df6b265c4f30106d",label:"MSTRon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x0279ea145eff84ed2ffd3b1ed1f2aca333060d9cef6fdd48bd21073c13ec86bf",label:"CRCLon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xff2063ef18bc5f71867c56d6d3290b61f3da1d010c8a0552bdb7995cfad8cacc",label:"TSLAon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x83d542605940b5495ef38d4b62a39293766a486a24e5c67930f41acd919cf1d1",label:"QQQon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9b01d5ad5ce8e477510854132cc47853f6e82a708c9c4723887550412f4ee522",label:"GMEon/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8b2af4d69ad861a4099b995b6279aeaf6a905225a0ee889bce424c7faf19b7d9",label:"AMZN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4edbd2f2f3b33bc5f80ab588def67fab8c10945fc99f855d80ff4bef2c4aa1f0",label:"SLV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x7e6ebfdc58a893a5cddba0fba0483baf4fac2efece627ad50821dbe27d6f9738",label:"GOOGL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x30a2a5f1a098b23ed91eadc4529a8d1c967f2cdc2e40a709f3a5992004b01ac0",label:"AAPL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x14973a168cf6c6b1148309f5d567c255b292863ffe9cca59f4284e1426636f00",label:"RKLB/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf049167e6bf18a1b41b8e2acefcf7bc9b13ea013d8d65c7fbc7cbaeb3fe9b4e2",label:"NBIS/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x8114b65dfc5e64222103e5588de261eca9defd25f47ea4ae2f91d49fe4fa2993",label:"CLSK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x96d3d5f9bc842e4c8a935c5628abd02fb0e10115560c35a9add768781434f471",label:"CRWV/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x1b3555f7c1273688f01ae82da7dc8e508e6a7841ec0038dbb15767154a277b86",label:"EWY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x039503b6308d6d818d181e626d3fbc667d6e68393c3d74332a6124cd2dd6e755",label:"CASHCAT_LEGACY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x597227ca652ea5e8afb6e4801ecd766a4d6eb9b3b9fafa9127ba88a8b1f19629",label:"SPCX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x50bc39b5722fb5634c436d74c6787f3c125b879e7b73cf9e9ecc01bbb57b8e55",label:"SPY/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x315b99abb698487891243a84afd28a5ff56fe02143f203c03edd3f103936bf60",label:"QQQ/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4979137c23c8fb519cd507adc290944c3c2120e8a3191547531fced28360e9c2",label:"GME/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x6b8a1f62d88d1cd1e8de609aef07cafc8226172ba703e57c52c3730350e61df1",label:"USO/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xafc86936af4f7edf083eb2550b8c42311b83c685982742b9271b309a58268855",label:"MSFT/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf6f3dbe0a19e948147e79e66502c6b05709d8dfde977fec7db1528fc8f0ebdfa",label:"SGOV/USDG 86% (Longbow)",source:"longbow"},{marketId:"0x2ab6a14c9f68d4216dcb3b4e6ed607cf82f2e6badfa2bd5618d7f69d012d7fab",label:"USAR/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb41b34c5989420ad080e79363a9cfe3e23bec7459fcd2d88029250da370288df",label:"TSLA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x4d2075836fd32183b10e5be1b383f6430de859df6d2bd5ec5b859970c4dd14e8",label:"AMD/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x9df4f54a2e46b35bd326cec97dbabc4203fa6c64a8e4182128f277adba8fefaf",label:"MU/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xb5ba72c0d55c353fa37c0bea104eb117afb2f4934473bcb736d2218ae5686746",label:"PLTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xda5584635e8b14ea18f674dbe4243365505910fefd8e3aa1ac9bfaac0eba74e8",label:"INTC/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x74fece475178af9e06d31fb64f405046a305f8f0abc588782f596d6f261c1fbb",label:"SNDK/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xee04847a312224d551d2267bb5c2c2695777af5fd1f05347bdcca397e8f54336",label:"ORCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x508b47fb12dbb8747644d4436aae65489b5f2819936adefc8a591323f64a5b01",label:"COIN/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x243ac165f79a75a0590d2e994ffa9e260b70292fd1ca134ace95f3640895b19f",label:"TSM/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x01baec96478004fc7b74c8dfe38abef8d716fea59ffd481b6ec74db915d3bc80",label:"MSTR/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xf0959f62e748938cf260ca6fe7cb21a412e0a6643913460f4a6770c3f4b90af6",label:"CRCL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xbe881499e682850931951c998e76cfbf38c7979b1beeae7cbbb97a39b3336a07",label:"ASML/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xdd578ca54b4ef6a7827c6e9fc06905699a577f6e2f00712853d8aab13383bc38",label:"BABA/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xd8b502d5c43f6e5cfff7f938c7ef18e684f114fb5b362611981144397e5d5aef",label:"DELL/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0x003390b057d753bd839981a0d45f9a567aa0b0ed6373fd42e951eac8ee86c2ba",label:"RGTI/USDG 62.5% (Longbow)",source:"longbow"},{marketId:"0xc6e16cff2bcf185639562ab937b7a1c381522768ff16aefc85a25ff6ab1c45ea",label:"AI/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xaba3ac501ce4c6b80c08ed0dba19e1ac0de495f17af3ed692a38e92d176a6c9e",label:"PONS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8097c1d1000eb657e75265384137041ac92856c8dc0b72c99569c3681320a430",label:"DELTA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6e6762ae397a2b3f2500ea2f48f8adce0eadfbf54cbc37f6108602e907e844ad",label:"INDEX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x378713071c58206c6a826287d0051bcae113d83d6e3d3b6370b7e73128d06162",label:"STONKBROKER/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x2695be2638c98241c887e4cad4eeba0f01137205f46b9e302edab04b5fee0570",label:"AVGO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x6c12c02536aa27831f713d658b59f74e149cc62b48528cb74455e79fab32f772",label:"GLD/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x298e8ff9b31f22be90507bc61b55e66ab93e78b55a60593035e309ed93137cb8",label:"RDDT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xb33399a677e1a21152fa9969f02c57a7a342e692ec45608a3fa0d3d92519c343",label:"COST/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x3be7fe1b6b439cfeb737d9921e9b83c92095a23a4f50aeee0d6d04f44446170f",label:"DJT/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0066bc47b87597993af0bca6f526175c0abae011b764d4bf12a3def45e1f4e78",label:"NFLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8c170f5c5df593791640ac9fbac297d59d08c2e92e86f38fe52d38e929e60fa3",label:"AMC/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x0f18d4fd8d86bd4d100b867b67e1fd38c80981fcd43e442313c2d5408da9352d",label:"LLY/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x7d4313cf1b0ede39395a2c7495dc1b1b47370caf51f70571d927f22e715e5f58",label:"LULU/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xa85928d77bd25cc348e13ea6587b8b3ca3793f4af5e5db8ca07d0f20fd5cfa99",label:"IBM/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x9d61e320efb766ce5c375032b399f08afe644b095a9cb0b2d6d1f6ab68399a6f",label:"F/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x43c51f6ff44ab406ab9c97cb5512c881f4a7498209f94bbcfd874d8f97fad79d",label:"HIMS/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe6284cf12d0603aee18ff5ab412e262cf99f120e967579111d7a51f37f276f54",label:"TTWO/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0xe8d9b45cdbedc4401a3145be7726c9f72b715e03c5399c961439f11636ee9fb6",label:"MRNA/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x46eea143d473cdb8587505f8886dad452037f285f7729a7763e8c233c63b2e8e",label:"RIVN/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x8338aed363a309039b2f271a83558831e7e445f2d13c6e72c576ec0b8a969415",label:"RBLX/USDG 38.5% (Longbow)",source:"longbow"},{marketId:"0x4e92b336ecad6c842be20ae2ae27b28b3cf5ced6c5388a808167c03a8d75fdf8",label:"SPY/WETH 38.5% (Longbow)",source:"longbow"},{marketId:"0x141c2b1d2bbecf7f8a76563307d7e5bf586457e873c3d97c4bb1502e57b77952",label:"NVDA/WETH 38.5% (Longbow)",source:"longbow"}],ya=new Map(tt.map(e=>[e.marketId.toLowerCase(),e]));function W(e){return ya.get(e.toLowerCase())}function ot(e){let t=W(e);return t?{actions:"enabled",label:t.label,source:ka[t.source]}:{actions:"read-only",reason:"Not in Oak's verified Morpho market registry; Oak builds no transactions for it."}}var Bt=20,ve=120n,_e=1000000n,He=1n,he=10n**18n,ga=10n**36n,Et=(1n<<128n)-1n,Sa=(1n<<256n)-1n,X=Ee(["function idToMarketParams(bytes32 id) view returns (address loanToken, address collateralToken, address oracle, address irm, uint256 lltv)","function market(bytes32 id) view returns (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee)","function position(bytes32 id, address user) view returns (uint256 supplyShares, uint128 borrowShares, uint128 collateral)","function supplyCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, bytes data)","function withdrawCollateral((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, address onBehalf, address receiver)","function borrow((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsBorrowed, uint256 sharesBorrowed)","function repay((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsRepaid, uint256 sharesRepaid)","function supply((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, bytes data) returns (uint256 assetsSupplied, uint256 sharesSupplied)","function withdraw((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, uint256 assets, uint256 shares, address onBehalf, address receiver) returns (uint256 assetsWithdrawn, uint256 sharesWithdrawn)"]),Aa=Ee(["function price() view returns (uint256)"]),Ia=Ee(["function borrowRateView((address loanToken, address collateralToken, address oracle, address irm, uint256 lltv) marketParams, (uint128 totalSupplyAssets, uint128 totalSupplyShares, uint128 totalBorrowAssets, uint128 totalBorrowShares, uint128 lastUpdate, uint128 fee) market) view returns (uint256)"]),_t=Ee(["function deposit() payable"]);function ce(e){return{loanToken:e.loanToken,collateralToken:e.collateralToken,oracle:e.oracle,irm:e.irm,lltv:e.lltv.toString()}}function Ce(e,t){return e===0n?0n:(e+t-1n)/t}function xa(e,t,s){return e*(s+_e)/(t+He)}function Ta(e,t,s){return Ce(e*(s+_e),t+He)}function rt(e,t,s){return e*(t+He)/(s+_e)}function ne(e,t,s){return Ce(e*(t+He),s+_e)}function ke(e,t,s){return e*t/ga*s/he}function Ma(e,t,s){return t.startsWith("-")?`-${e.formatAmount(t.slice(1),s)}`:e.formatAmount(t,s)}function ye(e,t){let s=[],r={};for(let n of t.changes){let l=Ma(e,n.amount,n.token.decimals);s.push({token:n.token,amount:n.amount,formattedAmount:l}),r[n.token.address.toLowerCase()]=l}return{formattedChanges:s,formattedNetOutflows:r}}function Ht(e){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new i("Morpho marketId must be a 32-byte hex string.");return e.toLowerCase()}function qe(e){if(!e||typeof e!="object")throw new i("Morpho marketParams must be an object.");for(let a of[e.loanToken,e.collateralToken,e.oracle,e.irm])if(typeof a!="string"||!Re(a,{strict:!1}))throw new i("Morpho marketParams contains an invalid address.");let t=L(e.loanToken),s=L(e.collateralToken),r=L(e.oracle),n=L(e.irm),l=typeof e.lltv=="bigint"?e.lltv:Me(String(e.lltv));if(t===te||s===te||r===te)throw new i("Morpho marketParams loan, collateral, and oracle addresses must be non-zero.");if(l<=0n||l>=he)throw new i("Morpho marketParams LLTV must be between 0 and 1e18.");return{loanToken:t,collateralToken:s,oracle:r,irm:n,lltv:l}}function be(e){let t=qe(e),s=ma(J("address, address, address, address, uint256"),[t.loanToken,t.collateralToken,t.oracle,t.irm,t.lltv]);return fa(s)}function at(e){let t=e.toLowerCase();return t===dt.toLowerCase()||t===ct.toLowerCase()||t===te.toLowerCase()}function ge(e,t){let s=t??e.wallet;if(!s)throw new i("Provide a valid wallet address.");return q(s),L(s)}async function re(e,t,s){if(typeof e.call=="function"){let r=await e.call({to:t,data:s});if(r&&typeof r.data=="string")return r.data}if(typeof e.request=="function"){let r=await e.request({method:"eth_call",params:[{to:t,data:s},"latest"]});if(typeof r=="string")return r}throw new i(`Unable to execute eth_call on contract ${t}.`)}function qt(e){return typeof e=="string"&&/^[A-Za-z0-9$._+-]{1,32}$/.test(e)?e:"UNKNOWN"}async function Q(e,t,s=p){if(q(t),at(t))return{...ut,chainId:s};let r=L(t),n=r.toLowerCase();if(s===p){if(n===wa.toLowerCase())return mt;if(n===de.toLowerCase())return ft}let[l,a]=await Promise.all([re(e,r,R({abi:et,functionName:"symbol"})),re(e,r,R({abi:et,functionName:"decimals"}))]),[o]=oe(J("string"),l),[u]=oe(J("uint8"),a);return{address:r,symbol:qt(o),decimals:Number(u),chainId:s}}async function Ft(e,t){let s=await re(e,U,R({abi:X,functionName:"idToMarketParams",args:[t]})),[r,n,l,a,o]=oe(J("address, address, address, address, uint256"),s);return{loanToken:L(r),collateralToken:L(n),oracle:L(l),irm:L(a),lltv:o}}async function jt(e,t){let s=await re(e,U,R({abi:X,functionName:"market",args:[t]})),[r,n,l,a,o,u]=oe(J("uint128, uint128, uint128, uint128, uint128, uint128"),s);return{totalSupplyAssets:r,totalSupplyShares:n,totalBorrowAssets:l,totalBorrowShares:a,lastUpdate:o,fee:u}}async function Se(e,t,s){let r=await re(e,U,R({abi:X,functionName:"position",args:[t,L(s)]})),[n,l,a]=oe(J("uint256, uint128, uint128"),r);return{supplyShares:n,borrowShares:l,collateral:a}}async function Fe(e,t){let s=await re(e,L(t),R({abi:Aa,functionName:"price"})),[r]=oe(J("uint256"),s);return r}async function Pa(e,t,s){if(t.irm===te)return 0n;let r=await re(e,L(t.irm),R({abi:Ia,functionName:"borrowRateView",args:[t,s]})),[n]=oe(J("uint256"),r);return n}function je(e,t,s){let r=s>e.lastUpdate?s-e.lastUpdate:0n,n=t*r,l=Ce(n*n,2n*he),a=Ce(l*n,3n*he);return e.totalBorrowAssets+Ce(e.totalBorrowAssets*(n+l+a),he)}async function Le(e,t,s,r=0n){let[n,l]=await Promise.all([e.getBlock({blockTag:"latest"}),Pa(e,t,s)]),a=BigInt(Math.ceil(Date.now()/1e3)),o=(n.timestamp>a?n.timestamp:a)+r;return{totalBorrowAssets:je(s,l,o),accruedThrough:o,rate:l}}async function Vt(e,t,s){let r=await re(e,L(t),R({abi:et,functionName:"balanceOf",args:[L(s)]})),[n]=oe(J("uint256"),r);return n}async function ue(e,t,s=!1){let r=t.marketId,n=t.marketParams;if(!r&&!n)throw new i("Provide either marketId or marketParams for the Morpho Blue market.");let l=n?qe(n):void 0,a=l?be(l):void 0,o=r!==void 0?Ht(r):void 0;if(o&&a&&o!==a.toLowerCase())throw new i(`MarketParams tuple hash (${a}) does not match marketId (${o}).`);let u=(o??a).toLowerCase();if(s&&!W(u))throw new i(`Morpho actions require a known market from Oak's verified registry, which pins its oracle. Find one with morpho_status {"discover":true}; other markets are read-only.`);let[d,m]=await Promise.all([Ft(e,u),jt(e,u)]);if(d.loanToken===te||d.collateralToken===te||d.lltv===0n||m.lastUpdate===0n)throw new i(`Morpho market ${u} is not initialized on chain ${p}.`);let c=be(d);if(c.toLowerCase()!==u.toLowerCase())throw new i(`On-chain idToMarketParams tuple hash (${c}) does not match marketId (${u}).`);if(l&&!(l.loanToken.toLowerCase()===d.loanToken.toLowerCase()&&l.collateralToken.toLowerCase()===d.collateralToken.toLowerCase()&&l.oracle.toLowerCase()===d.oracle.toLowerCase()&&l.irm.toLowerCase()===d.irm.toLowerCase()&&l.lltv===d.lltv))throw new i(`Provided marketParams tuple does not match on-chain idToMarketParams for ${u}.`);return{marketId:u,marketParams:d,marketState:m}}function Ae(e){if(e.assets!==void 0&&e.amount!==void 0)throw new i("Specify either assets or amount, not both.");let t=e.assets??e.amount;if(typeof t!="string")throw new i("Provide an amount as a base-unit integer string.");let s=Me(t);if(s<=0n||s>Et)throw new i("Asset amount must be greater than zero and fit in uint128.");return s}function Ie(e,t){for(let s of["onBehalf","receiver"])if(e[s]!==void 0&&(typeof e[s]!="string"||e[s].toLowerCase()!==t.toLowerCase()))throw new i(`Morpho ${s} must be the wallet; overrides are not supported.`);if(e.data!==void 0&&e.data!=="0x")throw new i("Morpho callback data must be empty (0x).")}async function va(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=e.clientFor(p),{marketId:a,marketParams:o}=await ue(l,t,!0),u=await Q(l,o.collateralToken,p),d=o.collateralToken.toLowerCase()===de.toLowerCase(),m=typeof t.collateralToken=="string"?(q(t.collateralToken),L(t.collateralToken)):void 0,c=z("wrapNative",t.wrapNative)===!0||m!==void 0&&at(m);if(m&&!at(m)&&m.toLowerCase()!==o.collateralToken.toLowerCase())throw new i(`Collateral token ${m} does not match market collateral ${o.collateralToken}.`);if(c&&!d)throw new i("Native ETH wrapping is only supported when market collateralToken is WETH.");let f=Ae(t),b=f.toString(),w=e.formatAmount(b,u.decimals),h=[];c&&h.push(e.unsignedTx({chainId:p,to:de,data:R({abi:_t,functionName:"deposit"}),value:b,description:`Wrap ${w} ETH into WETH at ${de}.`})),h.push(e.approval(o.collateralToken,U,b,p)),h.push(e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"supplyCollateral",args:[o,f,n,"0x"]}),value:"0",description:`Supply ${w} ${u.symbol} (${b} base units) collateral to Morpho market ${a}.`}));let y=await e.preview(h,r),{formattedChanges:k,formattedNetOutflows:g}=ye(e,y);return{action:"morpho_supply_collateral",chainId:p,marketId:a,marketParams:ce(o),collateralToken:u,assets:b,formattedAssets:w,onBehalf:n,txs:h,summary:`${c?`Send ${w} ETH to wrap into WETH. `:""}Supply ${w} ${u.symbol} collateral to Morpho Blue market ${a}.`,preview:y,formattedChanges:k,formattedNetOutflows:g}}async function Ca(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=r,a=e.clientFor(p),{marketId:o,marketParams:u,marketState:d}=await ue(a,t,!0),[m,c,f,b]=await Promise.all([Q(a,u.loanToken,p),Se(a,o,n),Fe(a,u.oracle),Le(a,u,d,ve)]),w=Ae(t),h=w.toString(),y=e.formatAmount(h,m.decimals),k=d.totalSupplyAssets>d.totalBorrowAssets?d.totalSupplyAssets-d.totalBorrowAssets:0n;if(w>k)throw new i(`Insufficient market liquidity: requested ${h} base units, available ${k.toString()} base units.`);let g=ke(c.collateral,f,u.lltv),T=ne(c.borrowShares,b.totalBorrowAssets,d.totalBorrowShares);if(c.collateral===0n||T+w>g)throw new i(`Insufficient collateral or unhealthy borrow: total debt ${(T+w).toString()} exceeds max borrow ${g.toString()} base units.`);let I=Ta(w,b.totalBorrowAssets,d.totalBorrowShares),C=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"borrow",args:[u,w,0n,n,l]}),value:"0",description:`Borrow ${y} ${m.symbol} (${h} base units) from Morpho market ${o}.`})],v=await e.preview(C,r),{formattedChanges:x,formattedNetOutflows:G}=ye(e,v);return{action:"morpho_borrow",chainId:p,marketId:o,marketParams:ce(u),loanToken:m,assets:h,formattedAssets:y,borrowShares:I.toString(),onBehalf:n,receiver:l,txs:C,summary:`Borrow ${y} ${m.symbol} from Morpho Blue market ${o}.`,preview:v,formattedChanges:x,formattedNetOutflows:G}}async function La(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=e.clientFor(p);if(t.shares!==void 0){let x=Me(t.shares);if(x<=0n||x===Sa||x>Et)throw new i("Morpho Blue core does not accept maxUint256 or out-of-range share sentinels; pass exact position.borrowShares.")}if(z("repayAll",t.repayAll)===!0&&(t.shares!==void 0||t.assets!==void 0||t.amount!==void 0))throw new i("Specify repayAll alone, without shares or assets/amount.");if(t.shares!==void 0&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify either assets/amount or shares for Morpho repay, not both.");let{marketId:a,marketParams:o,marketState:u}=await ue(l,t,!0),[d,m,c]=await Promise.all([Q(l,o.loanToken,p),Se(l,a,n),Vt(l,o.loanToken,r)]);if(m.borrowShares===0n)throw new i(`Position has no active borrow debt on Morpho market ${a}.`);let f=0n,b=0n;if(z("repayAll",t.repayAll)===!0)b=m.borrowShares;else if(t.shares!==void 0){let x=Me(t.shares);if(x>m.borrowShares)throw new i(`Repay shares (${x.toString()}) exceed current position borrowShares (${m.borrowShares.toString()}).`);b=x}else f=Ae(t);let w=b>0n?await Le(l,o,u,ve):void 0,h=b>0n?ne(b,w.totalBorrowAssets,u.totalBorrowShares):f;if(c<h)throw new i(`Insufficient loan token balance for repayment: wallet holds ${c.toString()} base units, but ${h.toString()} base units are required (including accrued interest).`);let y=h.toString(),k=e.formatAmount(y,d.decimals),g=e.approval(o.loanToken,U,y,p),T=e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"repay",args:[o,f,b,n,"0x"]}),value:"0",description:b>0n?`Repay ${b.toString()} borrow shares (${k} ${d.symbol}) on Morpho market ${a}.`:`Repay ${k} ${d.symbol} (${f.toString()} base units) on Morpho market ${a}.`}),I=[g,T],M=await e.preview(I,r),{formattedChanges:C,formattedNetOutflows:v}=ye(e,M);return{action:"morpho_repay",chainId:p,marketId:a,marketParams:ce(o),loanToken:d,repayAssets:f.toString(),repayShares:b.toString(),requiredAssets:y,...w?{accruedThrough:w.accruedThrough.toString(),borrowRatePerSecond:w.rate.toString(),inclusionSeconds:ve.toString()}:{},formattedRequiredAssets:k,onBehalf:n,txs:I,summary:b>0n?`Repay ${b.toString()} borrow shares (approval up to ${k} ${d.symbol}) on Morpho Blue market ${a}. Refresh if signing/inclusion takes more than ${ve} seconds.`:`Repay ${k} ${d.symbol} on Morpho Blue market ${a}.`,preview:M,formattedChanges:C,formattedNetOutflows:v}}async function $a(e,t,s){let r=ge(t,s);Ie(t,r);let n=r,l=r,a=e.clientFor(p),{marketId:o,marketParams:u,marketState:d}=await ue(a,t,!0),[m,c,f,b]=await Promise.all([Q(a,u.collateralToken,p),Se(a,o,n),Fe(a,u.oracle),Le(a,u,d,ve)]),w=z("withdrawAll",t.withdrawAll)===!0?c.collateral:Ae(t);if(w<=0n||w>c.collateral)throw new i(`Insufficient collateral to withdraw: requested ${w.toString()} base units, position holds ${c.collateral.toString()} base units.`);if(c.borrowShares>0n){let C=c.collateral-w,v=ke(C,f,u.lltv),x=ne(c.borrowShares,b.totalBorrowAssets,d.totalBorrowShares);if(x>v)throw new i(`Unhealthy collateral withdrawal: remaining max borrow ${v.toString()} would fall below current debt ${x.toString()} base units.`)}let h=w.toString(),y=e.formatAmount(h,m.decimals),g=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"withdrawCollateral",args:[u,w,n,l]}),value:"0",description:`Withdraw ${y} ${m.symbol} (${h} base units) collateral from Morpho market ${o}.`})],T=await e.preview(g,r),{formattedChanges:I,formattedNetOutflows:M}=ye(e,T);return{action:"morpho_withdraw_collateral",chainId:p,marketId:o,marketParams:ce(u),collateralToken:m,assets:h,formattedAssets:y,onBehalf:n,receiver:l,txs:g,summary:`Withdraw ${y} ${m.symbol} collateral from Morpho Blue market ${o}.`,preview:T,formattedChanges:I,formattedNetOutflows:M}}async function Da(e,t,s){let r=ge(t,s);Ie(t,r);let n=e.clientFor(p),{marketId:l,marketParams:a,marketState:o}=await ue(n,t,!0),u=z("wrapNative",t.wrapNative)===!0;if(u&&a.loanToken.toLowerCase()!==de.toLowerCase())throw new i("Native ETH wrapping is only supported when the market loanToken is WETH.");let d=Ae(t),m=d.toString(),[c,f]=await Promise.all([Q(n,a.loanToken,p),u?Promise.resolve(d):Vt(n,a.loanToken,r)]);if(f<d)throw new i(`Insufficient ${c.symbol} balance to lend: wallet holds ${f.toString()} base units, requested ${m}.`);let b=e.formatAmount(m,c.decimals),w=[];u&&w.push(e.unsignedTx({chainId:p,to:de,data:R({abi:_t,functionName:"deposit"}),value:m,description:`Wrap ${b} ETH into WETH at ${de}.`})),w.push(e.approval(a.loanToken,U,m,p)),w.push(e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"supply",args:[a,d,0n,r,"0x"]}),value:"0",description:`Lend ${b} ${c.symbol} (${m} base units) to Morpho market ${l}.`}));let h=xa(d,o.totalSupplyAssets,o.totalSupplyShares),y=await e.preview(w,r),{formattedChanges:k,formattedNetOutflows:g}=ye(e,y);return{action:"morpho_supply",chainId:p,marketId:l,marketParams:ce(a),loanToken:c,assets:m,formattedAssets:b,supplySharesEstimated:h.toString(),onBehalf:r,oak:ot(l),txs:w,summary:`${u?`Send ${b} ETH to wrap into WETH. `:""}Lend ${b} ${c.symbol} to Morpho Blue market ${l}. It earns the market supply rate and is exposed to the market's collateral, oracle and liquidity risk.`,preview:y,formattedChanges:k,formattedNetOutflows:g}}async function Ua(e,t,s){let r=ge(t,s);Ie(t,r);let n=e.clientFor(p),l=z("withdrawAll",t.withdrawAll)===!0;if(l&&(t.assets!==void 0||t.amount!==void 0))throw new i("Specify withdrawAll alone, without assets/amount.");let{marketId:a,marketParams:o,marketState:u}=await ue(n,t,!0),[d,m]=await Promise.all([Q(n,o.loanToken,p),Se(n,a,r)]);if(m.supplyShares===0n)throw new i(`This wallet has no lent ${d.symbol} on Morpho market ${a}.`);let c=rt(m.supplyShares,u.totalSupplyAssets,u.totalSupplyShares),f=l?0n:Ae(t),b=l?m.supplyShares:0n;if(!l&&f>c)throw new i(`Withdrawal exceeds the lent balance: requested ${f.toString()} base units, position holds about ${c.toString()}. Use withdrawAll for a full exit.`);let w=u.totalSupplyAssets>u.totalBorrowAssets?u.totalSupplyAssets-u.totalBorrowAssets:0n,h=l?c:f;if(h>w)throw new i(`Insufficient market liquidity: withdrawing ${h.toString()} base units needs idle assets, but only ${w.toString()} are available until borrowers repay. Withdraw at most that amount, or retry later.`);let y=e.formatAmount(h.toString(),d.decimals),g=[e.unsignedTx({chainId:p,to:U,data:R({abi:X,functionName:"withdraw",args:[o,f,b,r,r]}),value:"0",description:l?`Withdraw all ${m.supplyShares.toString()} supply shares (about ${y} ${d.symbol}) from Morpho market ${a}.`:`Withdraw ${y} ${d.symbol} (${f.toString()} base units) of lent assets from Morpho market ${a}.`})],T=await e.preview(g,r),{formattedChanges:I,formattedNetOutflows:M}=ye(e,T);return{action:"morpho_withdraw",chainId:p,marketId:a,marketParams:ce(o),loanToken:d,withdrawAssets:f.toString(),withdrawShares:b.toString(),estimatedAssets:h.toString(),formattedAssets:y,receiver:r,txs:g,summary:l?`Withdraw all lent ${d.symbol} (about ${y}, including interest) from Morpho Blue market ${a}.`:`Withdraw ${y} lent ${d.symbol} from Morpho Blue market ${a}.`,preview:T,formattedChanges:I,formattedNetOutflows:M}}async function zt(e,t,s){let r=await e.http(pa,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({query:t,variables:s})});if(!r.ok)throw new i(`Morpho GraphQL request failed (HTTP ${r.status}).`);let n=await r.json();if(n.errors?.length)throw new i("Morpho GraphQL returned query errors.");return n.data??{}}async function Wt(e){let t=`query Markets($chainId: Int!) {
|
|
2
|
-
markets(first: 1000, where: { chainId_in: [$chainId] }) {
|
|
3
|
-
items {
|
|
4
|
-
marketId chain { id } lltv listed
|
|
5
|
-
loanAsset { address symbol decimals }
|
|
6
|
-
collateralAsset { address symbol decimals }
|
|
7
|
-
oracle { address } morphoBlue { address } irmAddress
|
|
8
|
-
state { supplyAssets borrowAssets liquidityAssets fee supplyApy borrowApy }
|
|
9
|
-
warnings { type level }
|
|
10
|
-
}
|
|
11
|
-
pageInfo { count countTotal }
|
|
12
|
-
}
|
|
13
|
-
}`;try{let r=(await zt(e,t,{chainId:p})).markets;if(!Array.isArray(r?.items)||typeof r.pageInfo?.countTotal!="number"||r.pageInfo.countTotal!==r.items.length||r.items.some(n=>!n||typeof n.marketId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n.marketId)))throw new i("Morpho GraphQL returned an incomplete or invalid market inventory.");return r.items}catch(s){throw new i(`Morpho GraphQL read failed: ${se(s)}`)}}async function Ba(e,t){return(await Wt(e)).find(r=>r.marketId.toLowerCase()===t)??null}async function Na(e,t){let r=await zt(e,`query Positions($chainId: Int!, $wallet: String!) {
|
|
14
|
-
marketPositions(first: 1000, where: { chainId_in: [$chainId], userAddress_in: [$wallet] }) {
|
|
15
|
-
items { market { marketId } }
|
|
16
|
-
pageInfo { countTotal }
|
|
17
|
-
}
|
|
18
|
-
}`,{chainId:p,wallet:t}),n=r.marketPositions?.items;if(!Array.isArray(n)||r.marketPositions?.pageInfo?.countTotal!==n.length)throw new i("Morpho GraphQL returned an incomplete wallet position list.");return n.map(l=>Ht(l.market?.marketId))}function Nt(e){let t=e;return!t||typeof t.address!="string"||!Re(t.address,{strict:!1})?null:{address:L(t.address),symbol:qt(t.symbol),decimals:typeof t.decimals=="number"?t.decimals:null}}function Ot(e){return typeof e=="string"&&Re(e,{strict:!1})?L(e):null}function Gt(e,t){if(e===void 0)return;if(typeof e!="string"||!e.trim())throw new i(`Morpho ${t} filter must be a token address or symbol.`);let s=e.trim().toLowerCase();return r=>!!r&&(String(r.address).toLowerCase()===s||typeof r.symbol=="string"&&r.symbol.toLowerCase()===s.replace(/^\$/,""))}async function Oa(e,t){if(t.marketId!==void 0||t.marketParams!==void 0||t.includeGraphql!==void 0)throw new i("Use discover without marketId, marketParams or includeGraphql.");let s=t.limit===void 0?20:Number(t.limit);if(!Number.isSafeInteger(s)||s<1||s>100)throw new i("Morpho discover limit must be an integer from 1 to 100.");let r=Gt(t.loanToken,"loanToken"),n=Gt(t.collateralToken,"collateralToken"),l=z("verifiedOnly",t.verifiedOnly)===!0,a=await Wt(e),o=a.map(d=>{let m=d.marketId.toLowerCase(),c=d.state??{},f=Nt(d.loanAsset),b=Nt(d.collateralAsset),w=Array.isArray(d.warnings)?d.warnings.map(h=>({type:String(h?.type??"").slice(0,64),level:String(h?.level??"").slice(0,16)})):[];return{marketId:m,listed:d.listed===!0,warnings:w,loanToken:f,collateralToken:b,lltv:typeof d.lltv=="string"||typeof d.lltv=="number"?String(d.lltv):null,oracle:Ot(d.oracle?.address),irm:Ot(d.irmAddress),state:{supplyAssets:c.supplyAssets===void 0?null:String(c.supplyAssets),borrowAssets:c.borrowAssets===void 0?null:String(c.borrowAssets),liquidityAssets:c.liquidityAssets===void 0?null:String(c.liquidityAssets),supplyApy:typeof c.supplyApy=="number"?c.supplyApy:null,borrowApy:typeof c.borrowApy=="number"?c.borrowApy:null},oak:ot(m)}}).filter(d=>(!l||d.oak.actions==="enabled")&&(!r||r(d.loanToken))&&(!n||n(d.collateralToken))),u=d=>{try{return BigInt(d.state.liquidityAssets??"0")}catch{return 0n}};return o.sort((d,m)=>{let c=+(m.oak.actions==="enabled")-+(d.oak.actions==="enabled");if(c)return c;let f=u(m)-u(d);return f>0n?1:f<0n?-1:0}),{chainId:p,morphoBlue:U,source:"Morpho API market inventory; token symbols, rates and liquidity are indexer data, not chain reads.",totalMatching:o.length,inventoryTotal:a.length,markets:o.slice(0,s),next:'Re-read a market with morpho_status {"marketId":"<id>"} before acting. Only oak.actions "enabled" markets accept Oak transactions.'}}async function Ga(e,t,s){let r=e.clientFor(p),n=s??t.wallet,l=n&&Re(n,{strict:!1})?L(n):void 0;if(z("discover",t.discover)===!0)return Oa(e,t);for(let d of["loanToken","collateralToken","verifiedOnly","limit"])if(t[d]!==void 0)throw new i(`Morpho ${d} is a discover filter; pass discover:true with it.`);let a=z("includeGraphql",t.includeGraphql)===!0,o=t.marketId||t.marketParams?[t]:ha.map(d=>({marketId:d})),u=await Promise.all(o.map(async d=>{let{marketId:m,marketParams:c,marketState:f}=await ue(r,d),[b,w,h,y,k,g]=await Promise.all([Q(r,c.loanToken,p),Q(r,c.collateralToken,p),Fe(r,c.oracle),Le(r,c,f),l?Se(r,m,l):Promise.resolve(void 0),a?Ba(e,m):Promise.resolve(void 0)]),T=f.totalSupplyAssets>f.totalBorrowAssets?f.totalSupplyAssets-f.totalBorrowAssets:0n,I;if(k){let M=k.borrowShares>0n?ne(k.borrowShares,y.totalBorrowAssets,f.totalBorrowShares):0n,C=k.supplyShares>0n?rt(k.supplyShares,f.totalSupplyAssets,f.totalSupplyShares):0n,v=ke(k.collateral,h,c.lltv),x=M>0n?e.formatAmount((v*he/M).toString(),18):null;I={supplyShares:k.supplyShares.toString(),supplyAssets:C.toString(),borrowShares:k.borrowShares.toString(),borrowAssets:M.toString(),collateralAssets:k.collateral.toString(),maxBorrowAssets:v.toString(),healthFactor:x}}return{marketId:m,marketParams:ce(c),loanToken:b,collateralToken:w,state:{totalSupplyAssets:f.totalSupplyAssets.toString(),totalSupplyShares:f.totalSupplyShares.toString(),totalBorrowAssets:f.totalBorrowAssets.toString(),totalBorrowShares:f.totalBorrowShares.toString(),availableLiquidity:T.toString(),lastUpdate:f.lastUpdate.toString(),fee:f.fee.toString()},oraclePrice:h.toString(),borrowRatePerSecond:y.rate.toString(),oak:ot(m),...I?{position:I}:{},...a?{graphql:g??null}:{}}}));return{chainId:p,morphoBlue:U,adaptiveCurveIrm:ba,markets:u}}async function Ra(e,t,s,r){let[n,l]=await Promise.all([Ft(t,s),jt(t,s)]),[a,o,u,d]=await Promise.all([Q(t,n.loanToken,p),Q(t,n.collateralToken,p),Fe(t,n.oracle),Le(t,n,l)]),m=[];r.collateral>0n&&m.push({token:o,amount:r.collateral.toString()});let c=r.supplyShares>0n?rt(r.supplyShares,l.totalSupplyAssets,l.totalSupplyShares):0n;c>0n&&m.push({token:a,amount:c.toString()});let f=r.borrowShares>0n?ne(r.borrowShares,d.totalBorrowAssets,l.totalBorrowShares):0n,b=ke(r.collateral,u,n.lltv),w=e.formatAmount(r.collateral.toString(),o.decimals),h=e.formatAmount(f.toString(),a.decimals);return{module:Pe,id:s,chainId:p,assets:m,description:`Morpho Blue market ${s}: collateral=${w} ${o.symbol} (${r.collateral.toString()}), debt=${h} ${a.symbol} (${f.toString()}, shares=${r.borrowShares.toString()}), maxBorrow=${b.toString()}${r.supplyShares>0n?`, lent=${e.formatAmount(c.toString(),a.decimals)} ${a.symbol} (supplyShares=${r.supplyShares.toString()})`:""}.${W(s)?"":" Read-only: not in Oak's verified market registry, so Oak cannot build exits here."}`}}async function Ea(e,t){q(t);let s=L(t),r=e.clientFor(p),n=[],l=new Set(tt.map(c=>c.marketId)),a;try{for(let c of await Na(e,s))l.add(c)}catch(c){a=se(c)}let o=[...l],u=[],d=[];if(typeof r.multicall=="function")try{let c=await r.multicall({multicallAddress:it,batchSize:0,allowFailure:!0,contracts:o.map(f=>({address:U,abi:X,functionName:"position",args:[f,s]}))});if(c.length!==o.length)throw new i("Morpho multicall returned an incomplete position list.");c.forEach((f,b)=>{let w=o[b];if(f.status!=="success"){d.push({marketId:w,reason:se(f.error)});return}let[h,y,k]=f.result;u.push({marketId:w,position:{supplyShares:h,borrowShares:y,collateral:k}})})}catch(c){d.push(...o.map(f=>({marketId:f,reason:se(c)})))}else for(let c=0;c<o.length;c+=Bt)u.push(...await Promise.all(o.slice(c,c+Bt).map(async f=>({marketId:f,position:await Se(r,f,s).catch(b=>{d.push({marketId:f,reason:se(b)})})}))));d.length&&n.push({module:Pe,id:"morpho-market-reads-incomplete",chainId:p,assets:[],incomplete:!0,description:`Morpho could not read ${d.length} of ${o.length} markets. ${[...new Set(d.map(c=>c.reason))].slice(0,3).join(" ")} Example market IDs: ${d.slice(0,3).map(c=>c.marketId).join(", ")}. Retry positions or check a known market with morpho_status {"marketId":"<id>"}; other readable markets are retained.`});let m=u.filter(c=>c.position!==void 0&&(c.position.supplyShares>0n||c.position.borrowShares>0n||c.position.collateral>0n));for(let{marketId:c,position:f}of m)try{n.push(await Ra(e,r,c,f))}catch(b){let w=W(c)!==void 0;n.push({module:Pe,id:c,chainId:p,assets:[],incomplete:!0,description:`Unreadable ${w?"verified":"unverified"} Morpho market ${c}: the wallet holds supplyShares=${f.supplyShares.toString()}, borrowShares=${f.borrowShares.toString()}, collateral=${f.collateral.toString()} base units, but its token or oracle reads failed (${se(b)}). Retry morpho_status {"marketId":"${c}"}.${w?"":" Read-only in Oak."}`})}return a!==void 0&&n.push({module:Pe,id:"morpho-discovery-unavailable",incomplete:!0,chainId:p,assets:[],description:`Incomplete: Morpho API position discovery failed (${a}). Only Oak's ${tt.length} verified markets were checked on chain; check any other market with morpho_status {"marketId":"<id>"}.`}),n}var _a=e=>({tools:[{name:"morpho_supply_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),collateralToken:{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>va(e,s,r)},{name:"morpho_withdraw_collateral",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>$a(e,s,r)},{name:"morpho_borrow",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>Ca(e,s,r)},{name:"morpho_repay",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),shares:A(),repayAll:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>La(e,s,r)},{name:"morpho_supply",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),wrapNative:{type:"boolean"},onBehalf:{type:"string"}}},execute:(s,r)=>Da(e,s,r)},{name:"morpho_withdraw",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},assets:A(),amount:A(),withdrawAll:{type:"boolean"},onBehalf:{type:"string"},receiver:{type:"string"}}},execute:(s,r)=>Ua(e,s,r)},{name:"morpho_status",inputSchema:{type:"object",properties:{marketId:{type:"string"},marketParams:{type:"object"},includeGraphql:{type:"boolean"},discover:{type:"boolean",description:"List the Morpho API market inventory with Oak action eligibility instead of reading markets on chain."},loanToken:{type:"string",description:"discover filter: loan token address or symbol."},collateralToken:{type:"string",description:"discover filter: collateral token address or symbol."},verifiedOnly:{type:"boolean",description:"discover filter: only markets Oak can act on."},limit:{type:"integer",minimum:1,maximum:100,description:"discover page size, default 20."}}},execute:(s,r)=>Ga(e,s,r)}].map(s=>{let r=new Set(Object.keys(s.inputSchema.properties));if(r.add("wallet"),s.name!=="morpho_status")for(let l of["onBehalf","receiver","data"])r.add(l);let n=new Set(["loanToken","collateralToken","oracle","irm","lltv"]);return{...s,execute:async(l,a)=>{for(let o of Object.keys(l))if(!r.has(o))throw new i(`Unknown argument ${ze(o)} for ${s.name}; remove it and retry.`);if(l.marketParams&&typeof l.marketParams=="object"){for(let o of Object.keys(l.marketParams))if(!n.has(o))throw new i(`Unknown Morpho marketParams field ${ze(o)}; remove it and retry.`)}return s.execute(l,a)}}}),positions:s=>Ea(e,s)}),Eo=e=>lt(Pe,[_a(e),ht(e),Rt(e),Ut(e),Tt(e)]);var _=V[p].morpho.morpho_blue.address,xe="(address loanToken,address collateralToken,address oracle,address irm,uint256 lltv)",O=st(["function owner() view returns (address)","function feeRecipient() view returns (address)","function isIrmEnabled(address) view returns (bool)","function isLltvEnabled(uint256) view returns (bool)","function isAuthorized(address,address) view returns (bool)","function nonce(address) view returns (uint256)",`function idToMarketParams(bytes32) view returns ${xe}`,"function market(bytes32) view returns (uint128,uint128,uint128,uint128,uint128,uint128)","function position(bytes32,address) view returns (uint256 supplyShares,uint128 borrowShares,uint128 collateral)",`function createMarket(${xe} marketParams)`,`function accrueInterest(${xe} marketParams)`,`function setFee(${xe} marketParams,uint256 newFee)`,"function setAuthorization(address authorized,bool newIsAuthorized)","function setOwner(address newOwner)","function setFeeRecipient(address newFeeRecipient)","function enableIrm(address irm)","function enableLltv(uint256 lltv)",`function liquidate(${xe} marketParams,address borrower,uint256 seizedAssets,uint256 repaidShares,bytes data) returns (uint256,uint256)`]),Fa=st(["function price() view returns (uint256)"]),ja=st([`function borrowRateView(${xe} marketParams,(uint128 totalSupplyAssets,uint128 totalSupplyShares,uint128 totalBorrowAssets,uint128 totalBorrowShares,uint128 lastUpdate,uint128 fee) market) view returns (uint256)`]),Qt=["createMarket","accrueInterest","setAuthorization","setOwner","setFeeRecipient","enableIrm","enableLltv","setFee"],Va=new Set(["setOwner","setFeeRecipient","enableIrm","enableLltv","setFee"]);function $e(e){if(typeof e!="string"||!/^\d+$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new i("Provide a uint256 decimal base-unit string.");return BigInt(e)}function nt(e){return Ue(e,"Provide an explicit account address.",De)}var Rt=e=>{async function t(){let n=e.clientFor(p);if(await n.getChainId()!==p)throw new i("Morpho protocol tools require chain 4663.");return n}async function s(n){if(typeof n!="string"||!W(n))throw new i("Choose a market in Oak\u2019s verified registry.");let l=await t(),a=await l.readContract({address:_,abi:O,functionName:"idToMarketParams",args:[n]}),o={loanToken:a[0],collateralToken:a[1],oracle:a[2],irm:a[3],lltv:a[4]};if(!E(be({...o,lltv:o.lltv.toString()}),n))throw new i("On-chain Morpho parameters do not match the selected market.");return{rpc:l,params:o,marketId:n}}let r=(n,l,a,o)=>({name:n,inputSchema:{type:"object",properties:l,required:a,additionalProperties:!1},execute:async(u,d)=>{try{if(q(d),Object.keys(u).some(m=>!Object.hasOwn(l,m)))throw new i("Unsupported Morpho protocol argument.");return await o(u,d)}catch(m){throw new i(e.plainError(m))}}});return{tools:[r("morpho_protocol",{authorized:{type:"string"}},[],async(n,l)=>{let a=await t(),[o,u,d]=await Promise.all([a.readContract({address:_,abi:O,functionName:"owner"}),a.readContract({address:_,abi:O,functionName:"feeRecipient"}),a.readContract({address:_,abi:O,functionName:"nonce",args:[l]})]),m=n.authorized===void 0?void 0:nt(n.authorized);return{chainId:p,morpho:_,owner:o,feeRecipient:u,nonce:d.toString(),...m?{authorized:m,isAuthorized:await a.readContract({address:_,abi:O,functionName:"isAuthorized",args:[l,m]})}:{}}}),r("morpho_manage",{operation:{enum:Qt},marketId:{type:"string"},marketParams:{type:"object"},account:{type:"string"},enabled:{type:"boolean"},value:A()},["operation"],async(n,l)=>{if(typeof n.operation!="string"||!Qt.includes(n.operation))throw new i("Choose a documented Morpho protocol operation.");let a=n.operation,o=await t(),u=a==="createMarket"?["operation","marketParams"]:a==="accrueInterest"?["operation","marketId"]:a==="setFee"?["operation","marketId","value"]:a==="enableLltv"?["operation","value"]:a==="setAuthorization"?["operation","account","enabled"]:["operation","account"];if(Object.keys(n).some(f=>!u.includes(f)))throw new i("Unexpected fields for this Morpho operation.");if(Va.has(a)){let f=await o.readContract({address:_,abi:O,functionName:"owner"});if(Kt(f)!==Kt(l))throw new i("This wallet does not hold the Morpho owner role.")}let d;if(a==="createMarket"){if(!n.marketParams||typeof n.marketParams!="object"||Array.isArray(n.marketParams)||Object.keys(n.marketParams).some(h=>!["loanToken","collateralToken","oracle","irm","lltv"].includes(h)))throw new i("Provide only the five documented market parameter fields.");let f=qe(n.marketParams),[b,w]=await Promise.all([o.readContract({address:_,abi:O,functionName:"isIrmEnabled",args:[f.irm]}),o.readContract({address:_,abi:O,functionName:"isLltvEnabled",args:[f.lltv]})]);if(!b||!w)throw new i("The new market\u2019s IRM and LLTV must first be enabled by the Morpho owner.");d=me({abi:O,functionName:"createMarket",args:[f]})}else if(a==="accrueInterest"||a==="setFee"){let{params:f}=await s(n.marketId);if(a==="setFee"){let b=$e(n.value);if(b>250000000000000000n)throw new i("Morpho market fee cannot exceed 25% (0.25e18).");d=me({abi:O,functionName:"setFee",args:[f,b]})}else d=me({abi:O,functionName:"accrueInterest",args:[f]})}else if(a==="enableLltv"){let f=$e(n.value);if(f>=10n**18n)throw new i("Morpho LLTV must be below 1e18.");d=me({abi:O,functionName:"enableLltv",args:[f]})}else{let f=nt(n.account);if(a==="setAuthorization"){if(typeof n.enabled!="boolean")throw new i("Provide enabled as a boolean.");d=me({abi:O,functionName:"setAuthorization",args:[f,n.enabled]})}else if(a==="setOwner"||a==="enableIrm"||a==="setFeeRecipient")d=me({abi:O,functionName:a,args:[f]});else throw new i("Unsupported Morpho operation.")}let m=`Morpho ${a}: ${JSON.stringify(n)}. ${a==="setAuthorization"&&n.enabled?"This account can manage all your Morpho positions, including borrowing and withdrawals. There is no amount cap.":""}${a==="setOwner"&&n.account===qa?"Setting the owner to zero permanently relinquishes protocol administration.":""}${a==="createMarket"?"New market creation does not add it to Oak\u2019s verified action registry.":""}`,c=[e.unsignedTx({to:_,data:d,value:"0",chainId:p,description:m})];return{txs:c,preview:await e.preview(c,l),summary:m}}),r("morpho_liquidate",{marketId:{type:"string"},borrower:{type:"string"},repaidShares:A(),maxAssets:A(),minCollateral:A()},["marketId","borrower","repaidShares","maxAssets","minCollateral"],async(n,l)=>{let{rpc:a,params:o,marketId:u}=await s(n.marketId),d=nt(n.borrower),m=$e(n.repaidShares),c=$e(n.maxAssets),f=$e(n.minCollateral),[b,w,h,y]=await Promise.all([a.readContract({address:_,abi:O,functionName:"market",args:[u]}),a.readContract({address:_,abi:O,functionName:"position",args:[u,d]}),a.readContract({address:o.oracle,abi:Fa,functionName:"price"}),a.getBlock()]);if(m===0n||m>w[1]||h===0n)throw new i("Liquidation shares must fit the current debt and the oracle must be valid.");let k={totalSupplyAssets:b[0],totalSupplyShares:b[1],totalBorrowAssets:b[2],totalBorrowShares:b[3],lastUpdate:b[4],fee:b[5]},g=await a.readContract({address:o.irm,abi:ja,functionName:"borrowRateView",args:[o,k]}),T=je(k,g,y.timestamp);if(ne(w[1],T,b[3])<=ke(w[2],h,o.lltv))throw new i("This borrower is healthy; liquidation is unavailable.");let I=ne(m,je(k,g,y.timestamp+120n),b[3]);if(I>c)throw new i("Liquidation funding exceeds maxAssets.");if(await a.readContract({address:o.loanToken,abi:Ha,functionName:"balanceOf",args:[l]})<I)throw new i("Top up the loan token before liquidating.");let C=`Liquidate ${m} debt shares of ${d} on ${u}; exact approval ${I} loan-token base units; preview minimum ${f} collateral units. No callbacks; the wallet funds repayment. Approval can leave interest-buffer dust; revoke it afterward.`,v=[e.approval(o.loanToken,_,I.toString(),p),e.unsignedTx({to:_,data:me({abi:O,functionName:"liquidate",args:[o,d,0n,m,"0x"]}),value:"0",chainId:p,description:C})],x=await e.preview(v,l),G=Z=>x.changes.filter(H=>H.token.chainId===p&&E(H.token.address,Z)).reduce((H,F)=>H+BigInt(F.amount),0n);if(-G(o.loanToken)<=0n||-G(o.loanToken)>I||G(o.collateralToken)<f||G(o.collateralToken)<=0n)throw new i("Liquidation preview does not match the funding limit and collateral minimum.");return{txs:v,preview:x,requiredAssets:I.toString(),summary:`${C} MinCollateral is a local simulation check, not an on-chain floor.`}})]}};export{O as a,Rt as b,pe as c,Tt as d,Y as e,la as f,vt as g,da as h,Ct as i,ca as j,Ut as k,Pe as l,pa as m,U as n,ba as o,wa as p,de as q,ha as r,ka as s,tt as t,W as u,ve as v,xa as w,Ta as x,rt as y,ne as z,ke as A,Ma as B,qe as C,be as D,qt as E,je as F,_a as G,Eo as H,Ke as I,yt as J,N as K,Za as L};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as j,n as z}from"./WLMWWEP7.js";import{a as U}from"./66F5ZH34.js";import{b as G,c as H,g as A}from"./NWNYJ26T.js";import{a as b}from"./FWD4L3CJ.js";import{a as u}from"./XSD5NL7J.js";import{encodeFunctionData as E,getAddress as w,hashTypedData as O,parseAbi as S,recoverTypedDataAddress as Q}from"viem";var Y={pool:w("0x281210097f0de7A8FB6F87310AF0f089c9C8DE21"),registry:w("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),usdg:w("0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"),priors:w("0xeDBf91223639800BCd5756815CAf908Df3b890bE"),stock:w("0xbEcd07EC689988e16b870C121756C4c2C8cb02B6"),backing:w("0xC999014C6218EC41f0aE412d49AE8f2aA4c539fD"),treasury:w("0xFe8fdf43c4b0443aCF8E8CD8facD62F1B770e267"),bond:w("0x346d3360B7258a18E8a2a55fe20E0F467113a53A"),autopay:w("0x72B510AF4e66e5960aB9b975e0BdCf80239e83A0"),savings:w("0xBeEff033F34C046626B8D0A041844C5d1A5409dd"),market:w("0x6a4583242B8313313E684d02aB7dc6bFf8749670"),market1:w("0xe5C8b3FacD7802099C1DfB88c0C818Cd0ebA7B19"),bidSpender:w("0x0dbd031a3e8cc91C2b0A3Bf6BD1d14c7AeD92878"),seats3:w("0x59D155C42A9263fA7596867b992bB3e84dF680a9"),seats4:w("0xb1c3a04496238D62E3c93118C297163855e22192")},c=Y,C="(uint256 agentId,uint256 sponsorId,address owner,uint256 maxPremiumBps,uint256 nonce,uint256 deadline)",X=S(["function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),V=S(["function nonces(uint256) view returns (uint256)"]),ee=S(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),ne="0x0000000000000000000000000000000000000000",$="Owner stake is collateral, not a return. A default burns 75% of owner stake (50% of other backing); pending and leaving stake remains at risk until released. New backing waits 24 hours. Exit mode 0 holds, 1 returns PRIORS, 2 requests USDG through the guarded exit queue; no immediate payout is promised.",e=(t,r,n,o,s={})=>({name:`priors_${t}`,contract:r,signature:`function ${n}`,fields:o,note:"",...s}),i=["agentId","id"],v=["amount","uint"],W=["on","bool"],_=["generation","uint32"],R=["day","uint32"],D=["layer","uint8"],a={read:!0},Z=[e("set_delegate","pool","setDelegate(uint256,address)",[i,["delegate","address"]],{owner:"agentId",note:"Owner only. Delegate controls borrowing/repayment, not transfer of identity; clear with the zero address."}),e("root_enroll","pool","enrollRoot(uint256,uint256)",[i,v],{owner:"agentId",approval:"usdg",note:"Owner only. Locks USDG pool shares behind this sponsor root; active delegated lines and fees constrain withdrawals."}),e("root_add_stake","pool","addStake(uint256,uint256)",[i,v],{approval:"usdg",note:"Anyone may add USDG; only the root owner can withdraw it. This may give funds to another owner."}),e("root_unlock","pool","unlock(uint256,uint256,address)",[i,["shares","uint"]],{owner:"agentId",args:["agentId","shares","$wallet"],note:"Owner only. Withdraw root pool shares to this wallet, subject to delegated backing and fee locks."}),e("root_retire","pool","retireRoot(uint256)",[i],{owner:"agentId",note:"Owner only; requires no remaining stake or delegated lines."}),e("root_vouch","pool","vouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Adds the exact USDG amount of undrawn backing to an existing sponsored line."}),e("root_unvouch","pool","unvouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Recalls undrawn backing; outstanding debt remains backed."}),e("root_freeze","pool","freeze(uint256,bool)",[i,["frozen","bool"]],{note:"Current sponsor owner only; freeze/unfreeze the agent line. Contract checks sponsor ownership."}),e("root_set_premium","pool","setPremium(uint256,uint256)",[i,["premiumBps","uint"]],{note:"Current sponsor owner only. Future loan premium cannot exceed the owner-consented cap."}),e("root_claim_fees","pool","claimSponsorFees(uint256,address)",[i],{owner:"agentId",args:["agentId","$wallet"],note:"Owner only; claim sponsor USDG fees to this wallet."}),e("root_set_hook","pool","setHook(uint256,address)",[i,["hook","address"]],{owner:"agentId",note:"Owner only. Changes root lending policy hook; pool enforces the delay while backing is committed."}),e("root_apply_hook","pool","applyHook(uint256)",[i],{note:"Apply a previously scheduled root hook after its on-chain delay."}),e("mark_default","pool","markDefault(uint256)",[["loanId","id"]],{note:"Irreversible: mark a past-grace unpaid loan defaulted, burn sponsor backing and mark the owner. Preview and confirm deliberately."}),e("import_history","pool","importFromV1(uint256)",[i],{note:"Import the v1 record, including defaults; this never imports unbacked capacity."}),e("fund_reserve","pool","fundReserve(uint256)",[v],{approval:"usdg",note:"Donate USDG to the pool reserve; receives no redeemable shares."}),e("root_shares","pool","rootShares(uint256) view returns (uint256)",[i],a),e("root_fee_locked","pool","feeLocked(uint256) view returns (uint256)",[i],a),e("root_fees_owed","pool","sponsorFees(uint256) view returns (uint256)",[i],a),e("root_backing","pool","backing(uint256) view returns (uint256)",[i],a),e("root_free_backing","pool","freeBacking(uint256) view returns (uint256)",[i],a),e("pool_parameters","pool","getParams() view returns ((uint256 minLoan,uint256 maxLoan,uint64 minTerm,uint64 maxTerm,uint64 grace,uint64 minScoreTerm,uint256 feeBps,uint256 sponsorFeeBps,uint256 protocolFeeBps,uint256 minStake,uint256 maxUtilizationBps,uint256 keeperBounty))",[],a),e("bond_deposit","bond","deposit(uint256)",[i],{owner:"agentId",approval:"bond",note:"Owner only. V2 treasury bond remains locked while any line or loan is open; it may replace and refund a former owner bond. Leave and release the legacy bond before Treasury V5 migration."}),e("bond_release","bond","release(uint256)",[i],{note:"Return V2 bond to its original depositor, not necessarily this wallet; contract enforces no line, no loan and age."}),e("bond_slash","bond","slash(uint256)",[i],{note:"Irreversible: send defaulted agent V2 bond to the configured beneficiary."}),e("bond_status","bond","bonds(uint256) view returns ((address depositor,uint64 at,uint256 amount))",[i],a),e("bond_releasable","bond","releasable(uint256) view returns (bool)",[i],a),e("bond_release_at","bond","unusedReleaseAt(uint256) view returns (uint256)",[i],a),e("treasury_move","treasury",`move(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","$consent","$signature"],note:"Move a former Treasury V4 line to V5, no loan open. Close old line, release legacy bond, deposit V2 bond first. V4 record and current-owner V2 bond are required."}),e("treasury_raise","treasury","raise(uint256)",[i],{note:"Raise an eligible Treasury V5 line using its current rules, score, history, age, weekly room and free backing. No unbacked credit."}),e("treasury_reclaim","treasury","reclaim(uint256)",[i],{note:"Reclaim an idle treasury line under on-chain rules; this ends borrowing access."}),e("treasury_first_line","treasury",`firstLine(uint256,uint64,bytes,${C},bytes)`,[i,["expiry","uint"],["invite","bytes"]],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","expiry","invite","$consent","$signature"],note:"Redeem an already-issued Treasury V5 invite with V5 pool consent. Requires a valid V5 inviter signature; the current owner V2 bond is needed before borrowing. V4 invites cannot be reused."}),e("treasury_raise_room","treasury","raiseRoom() view returns (uint256)",[],a),e("treasury_first_lined","treasury","firstLined(uint256) view returns (bool)",[i],a),e("treasury_eligible_raise","treasury","eligibleForRaise(uint256) view returns (bool)",[i],a),e("treasury_room","treasury","epochRoom() view returns (uint256)",[],a),e("treasury_rules","treasury","rules() view returns (uint256 reserveBps,uint256 firstLine,uint256 secondLine,uint256 epochCap,uint64 epochLength,uint64 minSeasoning,uint256 minQualified,uint256 minScore,uint64 idleAfter)",[],a),e("stock_open","stock",`open(uint256,address,uint256,${C},bytes) returns (uint256)`,[i,["token","address"],v],{owner:"agentId",consentRoot:6424n,externalConsent:!0,approval:"stock",args:["agentId","token","amount","$consent","$signature"],note:"Owner or on-chain controller with a supplied owner consent posts exact collateral. Token must be accepted and usable; live price, LTV, line cap and backing determine the line. Default seizes debt plus buffer; issuer restrictions and burns may reduce returned collateral."}),e("stock_add","stock","addCollateral(uint256,uint256)",[i,v],{approval:"stock",note:"Depositor only. Adds exact position token collateral; contract decides resulting draw room."}),e("stock_close","stock","close(uint256)",[i],{note:"Depositor or controller closes/freezes the line; collateral pays its depositor after the last loan, subject to default and issuer shortfalls."}),e("stock_expire","stock","expire(uint256)",[i],{note:"Expire idle stock line after on-chain idle rules; may close borrowing access."}),e("stock_reconcile","stock","reconcile(uint256,uint256)",[i,["maxLoans","uint"]],{note:"Reconcile the collateral debt walk against pool loans; contract ignores maxLoans in this implementation."}),e("stock_settle","stock","settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile stock collateral after a default or missed hook; may seize collateral according to the loan."}),e("stock_record_feed","stock","record(address,uint256) returns (uint80)",[["feed","address"],["maxRounds","uint"]],{note:"Advance public oracle price tape; may unblock new stock lines and default settlement."}),e("stock_reclaim","stock","reclaim(uint256)",[i],{note:"Reclaim a written-off stock position after it is no longer backed; return remains subject to vault token shortfall."}),e("stock_state","stock","getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[i],a),e("stock_borrow_room","stock","borrowRoom(uint256) view returns (uint256)",[i],a),e("stock_asset_state","stock","assets(address) view returns (address feed,uint64 maxAge,uint8 tokenDecimals,uint8 feedDecimals,bool enabled,uint16 ltvBps,uint128 lineCap)",[["token","address"]],a),e("stock_lending_status","stock","lendStatus(address) view returns (uint8)",[["token","address"]],a),e("stock_value","stock","valueOf(address,uint256) view returns (bool ok,uint256 value)",[["token","address"],v],a),e("stock_ltv","stock","ltvOf(uint256,address) view returns (uint256)",[i,["token","address"]],a),e("backing_open","backing",`open(uint256,uint256,bool,${C},bytes)`,[i,v,["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"priors",args:["agentId","amount","autoAdd","$consent","$signature"],note:$}),e("backing_open_with_usdg","backing",`openWithUsdg(uint256,uint256,uint256,uint256,uint256,bool,${C},bytes)`,[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"mixed",args:["agentId","priorsIn","usdgIn","minOut","deadline","autoAdd","$consent","$signature"],note:$}),e("backing_add","backing","back(uint256,uint256,bool)",[i,v,["autoAdd","bool"]],{approval:"priors",note:$+" Owner-only at launch; other backers require both global and individual permission."}),e("backing_add_with_usdg","backing","backWithUsdg(uint256,uint256,uint256,uint256,uint256,bool)",[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{approval:"mixed",note:$}),e("backing_leave","backing","leave(uint256,uint256,uint8)",[i,v,["exitMode","uint8"]],{note:$}),e("backing_close","backing","close(uint256,uint8)",[i,["exitMode","uint8"]],{note:$}),...["refresh","promote","expire","sync","pokeFees","recordRepay","noteDelegate"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256)`,[i],{note:"Reconcile this V5 book against current pool, owner, record, tier and backing rules; no payout is promised."})),...["setAutoAdd","setProtocolBacking","setOthersBacking"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256,bool)`,[i,W],{note:"Change this V5 book setting under the contract ownership/holder rules. Auto-add can compound rewards into stake at risk."})),e("backing_reconsent","backing",`reconsent(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8762n,args:["agentId","$consent","$signature"],note:"Owner only. Renew the pool consent for V5 backing."}),e("backing_release","backing","release(uint256,uint32,uint32,uint256,uint256)",[i,_,R,["minUsdgOut","uint"],["deadline","uint"]],{note:"Release caller day bucket after its release rule. Zero minUsdgOut returns PRIORS; positive requests a guarded sale. Stake stays burnable until release. Read generation/day from chain events."}),e("backing_release_for","backing","releaseFor(uint256,uint32,address,uint32)",[i,_,["holder","address"],R],{note:"Return eligible PRIORS to its holder under generation/day release rules, never redirect proceeds."}),e("backing_finish_close","backing","finishClose(uint256,uint32)",[i,_],{note:"Finish an eligible generation close; pays the bound owner under its release rules."}),e("backing_claim_settled","backing","claimSettled(uint256,uint32,address)",[i,_,["holder","address"]],{note:"Pay settled generation stake to the named holder, after any default burn."}),e("backing_claim_record","backing","claimSettled(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Pay settled day record to its holder after any default burn."}),e("backing_queue_exit","backing","queueExit(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Holder/keeper queues ready USDG-mode stake; minimum and queue window apply. A queue entry is not a fill or payout."}),e("backing_settle","backing","settle(uint256,uint32,uint256)",[i,_,["loanId","id"]],{note:"Reconcile V5 generation with a pool loan/default after a missed hook."}),e("backing_record_loan","backing","recordLoan(uint256)",[["loanId","id"]],{note:"Record current pool loan in V5 book."}),e("backing_record_default","backing","recordDefault(uint256)",[["loanId","id"]],{note:"Reconcile a marked pool default and its stake burn."}),e("backing_collect","backing","collect(uint256[],uint32[]) returns (uint256)",[["agentIds","ids"],["generations","gens"]],{note:"Collect caller fees for explicitly selected generations; auto-add settings may retain stake."}),e("backing_fund","backing","fund(uint256)",[v],{approval:"usdg",note:"Donate USDG to V5 root backing; donor receives no withdrawable claim."}),e("backing_book","backing","getGen(uint256,uint32) view returns ((address owner,uint64 openedAt,uint8 status,bool ownerChanged,bool optOut,bool othersOff,bool pointsVoid,bool openRoomCharged,bool closedByOwner,bool movePending,bool splitPending,uint64 movePendingAt,uint8 tier,uint8 countedAtTier,uint8 listLen,uint32 tierStep,uint64 tierSince,uint64 lastLateAt,uint64 closedMark,uint64 lastRaiseAt,uint64 promoEpoch,uint64 stakeEpoch,uint64 placeEpoch,uint160 movePendingSqrt,uint256 roomLine,uint256 openLine,uint256 promoCredit,uint256 stakeRaised,uint256 placed,uint256 index,uint256 divisor,uint256 defaultProof,uint256 cLive,uint256 cUnits,uint256[3] list,uint256[3] counted,uint256[3] pendingTok,uint256[3] leavingLive,uint256[3] tokens,uint64[3] layerEnd,uint160[3] endSqrt,uint8[3] ownerEndMode,uint32[2][3] liveDay,uint32[3] leaveHead,(uint64 epoch,uint192 points)[5] points))",[i,_],a),e("backing_generation","backing","latestGen(uint256) view returns (uint32)",[i],a),e("backing_line","backing","lineOf(uint256) view returns (uint256)",[i],a),e("backing_quote","backing","needed(uint256,uint256,bool) view returns ((uint256 minA,uint256 fullLine,uint256 capA,uint160 sqrtP,uint8 k,uint8 kCached,bool depthGuard,uint256 line,uint256 ownerA,uint256 ownBacking,uint256 roomB,uint256 lineIfAdded,uint256 weekAfter))",[i,["tokens","uint"],["asOwner","bool"]],a),e("backing_position","backing","position(uint256,uint32,uint8,address) view returns ((uint256 counted,uint256 checkpoint,uint256 a0,uint256 a1,uint32 d0,uint32 d1,bool autoAdd))",[i,_,D,["holder","address"]],a),e("backing_record","backing","record(uint256,uint32,uint8,uint32,address) view returns ((uint256 counted,uint256 uncounted,uint256 creditedTo,uint160 sqrtLeave,uint8 mode,uint64 entry))",[i,_,D,R,["holder","address"]],a),e("backing_bucket","backing","leavingBucket(uint256,uint32,uint8,uint32) view returns ((bool exists,bool retired,uint64 latestLeave,uint64 releasableAt,uint256 loanCount,uint256 counted,uint256 uncounted,uint256 retireIndex))",[i,_,D,R],a),e("backing_settings","backing","settings() view returns (bool openBacking,uint256 premiumCap,uint256 maxSwapUsdg,uint256 openRoom,uint256 raiseRoom,uint256 vouchCap,uint8 minDrawK,bool premiumCheck,uint64 pausedUntil)",[],a),e("backing_reopen_at","backing","reopenAt(uint256) view returns (uint64)",[i],a),e("backing_sync_prices","backing","sync()",[],{note:"Update global V5 price/guard observations."}),e("backing_exit_service_open","backing","exitServiceOpen() view returns (bool)",[],a),e("backing_usdg_path","backing","usdgPathOpen(uint256) view returns (bool,uint8)",[["usdgIn","uint"]],a),e("backing_entry_rule","backing","entryRule() view returns (uint8 minEntryLoans,uint32 minEntryDays)",[],a),e("backing_target_premium","backing","targetPremiumBps(uint256) view returns (uint256)",[i],a),e("backing_price_cache","backing","priceCache() view returns (uint160 sqrtMedian,uint64 obsAt,uint160 sqrtWeekLow,uint160 sqrtObservation)",[],a),e("backing_pending_bucket","backing","pendingBucket(uint256,uint32,uint8,uint32) view returns ((uint128 amount,uint64 lastDeposit,bool merged,bool dead,uint256 mergeIndex))",[i,_,D,R],a),e("backing_exit_head","backing","exitHead() view returns (uint256 entryId,address holder,uint256 rest,uint160 sqrtPLeave,uint64 joinedAt)",[],a),e("backing_exit_entry","backing","entry(uint256) view returns ((uint256 id,uint32 gen,uint8 layer,uint32 day,address holder,uint64 joinedAt,uint64 prev,uint64 next))",[["entryId","uint"]],a),e("backing_flush","backing","flush()",[],{note:"Reconcile V5 fees and backing buffers; no payout to caller is promised."}),e("backing_claimable","backing","claimable(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("autopay_hold","autopay","hold(bool)",[W],{note:"Hold/resume future autopay attempts for this wallet; allowances remain until explicitly revoked."}),e("autopay_max_cap","autopay","MAX_CAP() view returns (uint256)",[],a),e("autopay_window","autopay","WINDOW() view returns (uint64)",[],a),e("autopay_paused_until","autopay","pausedUntil() view returns (uint64)",[],a),e("autopay_plan","autopay","planOf(address,uint256) view returns (uint32 cap,address owner,bool on,bool useSavings,bool late,uint32 epoch)",[i],{...a,args:["$wallet","agentId"]}),e("autopay_check","autopay","check(uint256) view returns ((uint8 status,uint256 agentId,uint256 due,uint64 opens,uint64 closes,address wallet,uint256 fromWallet,uint256 fromWalletSavings,address owner,uint256 fromOwner,uint256 fromOwnerSavings))",[["loanId","id"]],a),e("autopay_epoch","autopay","epochOf(uint256) view returns (uint32 epoch,bool stale)",[i],a),e("autopay_held","autopay","held(address) view returns (bool)",[],{...a,args:["$wallet"]}),e("savings_deposit","savings","deposit(uint256,address) returns (uint256)",[v],{approval:"usdg",args:["amount","$wallet"],note:"Deposit own USDG into Priors default external Morpho savings vault; vault/allocator risk and withdrawal liquidity apply."}),e("savings_withdraw","savings","withdraw(uint256,address,address) returns (uint256)",[v],{args:["amount","$wallet","$wallet"],note:"Withdraw exact USDG amount from own savings. Insufficient liquidity fails the preview; no immediate exit is promised."}),e("savings_redeem","savings","redeem(uint256,address,address) returns (uint256)",[["shares","uint"]],{args:["shares","$wallet","$wallet"],note:"Redeem exact own savings shares to this wallet; liquidity and rounding apply."}),e("savings_balance","savings","balanceOf(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("savings_value","savings","previewRedeem(uint256) view returns (uint256)",[["shares","uint"]],a),...["market","market1"].flatMap((t,r)=>[e(`market_v${r===0?2:1}_listing`,t,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[i],a),e(`market_v${r===0?2:1}_record_hash`,t,"recordHash(uint256) view returns (bytes32)",[i],a),e(`market_v${r===0?2:1}_list`,t,"list(uint256,uint256,uint64)",[i,["price","uint"],["expiry","uint"]],{owner:"agentId",approval:"nft",note:"Owner sells this ERC-8004 NFT, its record and any followed treasury line. This does not transfer code, keys or servers. Approves only this NFT; confirm the sale terms and contract-enforced hold/line rules."}),e(`market_v${r===0?2:1}_cancel`,t,"cancel(uint256)",[i],{note:"Cancel the standing listing; NFT approval can remain until explicitly cleared."}),e(`market_v${r===0?2:1}_buy`,t,"buy(uint256,uint256,uint256,bytes32,bytes32)",[i,["maxPrice","uint"],["nonce","uint"],["uriHash","bytes32"],["recordHash","bytes32"]],{approval:"market",note:"Buy an ERC-8004 NFT to this wallet with exact live asking-price approval and pinned listing nonce, tokenURI and current credit record. A followed line still needs the new owner bond before borrowing. No keys/code/servers are included."})]),e("market_bid","market","bid(uint256,uint256,uint64,bytes32,uint256,uint256) returns (uint256)",[i,["price","uint"],["expiry","uint"],["uriHash","bytes32"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["agentId","price","expiry","uriHash","minRepaid","minLine"],approval:"bid",note:"Standing future purchase authority: another owner can fill this bid later without a new click. Exact reserveBudget USDG allowance is shared by all this wallet bids and replaces the old allowance. Cancel bid and clear unused budget deliberately."}),e("market_bid_any","market","bidAny(bytes32,uint256,uint256,uint64,uint256,uint256) returns (uint256)",[["root","bytes32"],["count","uint"],["price","uint"],["expiry","uint"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["root","count","price","expiry","minRepaid","minLine"],approval:"bid",note:"Standing future authority to buy count identities committed by the explicit Merkle root; shared exact reserveBudget USDG allowance. Inspect the committed ID list before authorizing. No code, keys or servers transfer."}),e("market_cancel_bid","market","cancelBid(uint256)",[["bidId","id"]],{note:"Cancel this bid; shared USDG allowance is unchanged so other bids can still fill."}),e("market_accept_bid","market","acceptBid(uint256,uint256,bytes32[],uint256)",[["bidId","id"],i,["proof","proof"],["minNet","uint"]],{owner:"agentId",approval:"nft",note:"Sell only this NFT into a currently valid bid; minNet pins seller USDG proceeds. Merkle proof and current bid rules are checked on chain during preview."}),e("market_bid_state","market","bidOf(uint256) view returns ((address maker,uint64 expiry,uint16 left,bool any,uint96 price,uint96 minLine,uint64 minRepaid,bytes32 target,bytes32 uriHash))",[["bidId","id"]],a),e("market_builder","market","builderOf(uint256) view returns ((address to,uint16 bps))",[i],a),e("market_set_builder","market","setBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{owner:"agentId",note:"Owner-only attribution before first sale; assigns future sale revenue share to to. Contract enforces enabled switch, no listing, and maximum 500 bps."}),e("market_change_builder","market","changeBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{note:"Current builder only; may lower or redirect own revenue share, never increase it."}),e("market_sale_split","market","saleSplit(uint256) view returns (uint256 fee,uint256 share,uint256 net)",[i],a),...["seats3","seats4"].flatMap((t,r)=>[e(`legacy_v${r+3}_close`,t,"close(uint256)",[i],{note:"Existing seat only. Close/freeze and return stake to original staker after final loan; default burn still applies. No new seats are opened."}),e(`legacy_v${r+3}_withdraw_offer`,t,"withdrawOffer(uint256,address)",[i],{args:["agentId","$wallet"],note:"Withdraw caller unaccepted offer; PRIORS returns to the staker."}),e(`legacy_v${r+3}_expire`,t,"expire(uint256)",[i],{note:"Expire idle seat under current contract rules."}),e(`legacy_v${r+3}_settle`,t,"settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile existing seat against pool loan/default after a missed hook."}),e(`legacy_v${r+3}_claim`,t,"claim(address) returns (uint256)",[],{args:["$wallet"],note:"Claim caller legacy seat USDG fees to this wallet."}),e(`legacy_v${r+3}_seat`,t,"getSeat(uint256) view returns ((address staker,uint64 openedAt,bool closing,uint8 status,uint128 line,uint128 burnBps,uint256 amount,uint256 feeMark,address owner))",[i],a),e(`legacy_v${r+3}_pending_fees`,t,"pendingFees(uint256) view returns (uint256)",[i],a),e(`legacy_v${r+3}_fees`,t,"feesOwed(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e(`legacy_v${r+3}_offer`,t,"offers(uint256,address) view returns (uint256)",[i],{...a,args:["agentId","$wallet"]})])];function J(t){return JSON.parse(JSON.stringify(t,(r,n)=>typeof n=="bigint"?n.toString():n))}function l(t,r,n=256){if(typeof t!="string"||!/^[0-9]+$/.test(t)||BigInt(t)>=1n<<BigInt(n))throw new u(`${r} must be a decimal base-unit string fitting uint${n}.`);return BigInt(t)}function te(t,[r,n]){let o=t[r];if(n==="address"){if(typeof o!="string"||!G.test(o))throw new u(`${r} must be a token or wallet address.`);return w(o)}if(n==="bool"){if(typeof o!="boolean")throw new u(`${r} must be true or false.`);return o}if(n==="bytes32"){if(typeof o!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o))throw new u(`${r} must be bytes32.`);return o}if(n==="proof"){if(!Array.isArray(o)||o.length>32||!o.every(d=>typeof d=="string"&&/^0x[0-9a-fA-F]{64}$/.test(d)))throw new u("proof needs at most 32 bytes32 hashes.");return o}if(n==="bytes"){if(typeof o!="string"||!/^0x(?:[0-9a-fA-F]{2})*$/.test(o)||o.length>32770)throw new u(`${r} must be bounded hexadecimal bytes.`);return o}if(n==="ids"||n==="gens"){if(!Array.isArray(o)||o.length===0||o.length>100)throw new u(`${r} needs 1 to 100 decimal strings.`);return o.map(d=>l(d,r,n==="gens"?32:256))}let s=l(o,r,n==="uint8"?8:n==="uint32"?32:256);if(n==="id"&&s===0n)throw new u(`${r} must be positive.`);if(r==="exitMode"&&s>2n)throw new u("exitMode must be 0 (hold), 1 (PRIORS), or 2 (USDG queue).");if(r==="layer"&&s>2n)throw new u("layer must be 0, 1, or 2.");return s}function P(t,r={}){return{type:"object",additionalProperties:!1,required:t.map(([n])=>n),properties:Object.fromEntries([...t.map(([n,o])=>[n,o==="bool"?{type:"boolean"}:o==="address"?H:o==="proof"?{type:"array",maxItems:32,items:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}}:o==="ids"||o==="gens"?{type:"array",maxItems:100,items:U()}:{type:"string",...o==="bytes32"?{pattern:"^0x[0-9a-fA-F]{64}$"}:o!=="bytes"?{pattern:"^[0-9]+$"}:{}}]),...Object.entries(r)])}}async function I(t,r,n,o=[]){let s=[`function ${n}`],d=S(s);return t.clientFor(b).readContract({address:r,abi:d,functionName:d[0].name,args:o})}async function B(t,r){return w(await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"ownerOf",args:[r]}))}function F(t){if(t.network==="testnet")throw new u("Priors ecosystem features are configured only on chain 4663.")}function N(t,r,n,o,s,d="0"){return{domain:z(),types:{Consent:[...j.Consent]},primaryType:"Consent",message:{agentId:t,sponsorId:r,owner:w(n),nonce:o,deadline:s,maxPremiumBps:d}}}async function M(t,r,n){if(!r||!r.request||O(r.request)!==O(n)||typeof r.signature!="string"||!/^0x(?:[a-fA-F0-9]{2}){1,4096}$/.test(r.signature))throw new u("Consent differs from this agent, sponsor, owner, premium cap, nonce or deadline.");let o=n.message.owner,s=await t.clientFor(b).getCode({address:o});if(s&&s!=="0x"){if(await t.clientFor(b).readContract({address:o,abi:ee,functionName:"isValidSignature",args:[O(n),r.signature]})!=="0x1626ba7e")throw new u("The owner contract rejected the consent signature.")}else if(!A(await Q({...n,signature:r.signature}),o))throw new u("The consent signature is not from the current agent owner.")}function ie(t,r,n,o,s,d){let g=Z.find(k=>k.name===t),p=t==="priors_sign_consent"?l(r.sponsorId,"sponsorId"):g?.consentRoot;if(!p||s.stage!=="priors_consent"||s.tool!==t||s.wallet!==w(n)||s.chainId!==b||s.agentId!==r.agentId||o.length!==1||o[0]?.kind!=="typedData")throw new u("Unexpected Priors consent continuation.");let h=l(s.nonce,"nonce").toString(),f=l(s.deadline,"deadline");if(f<=BigInt(d)||f>BigInt(d+3600))throw new u("Priors consent expired or exceeds its one-hour window.");let y=N(String(r.agentId),p.toString(),n,h,f.toString(),String(r.maxPremiumBps??"0"));if(!o[0].request||O(o[0].request)!==O(y))throw new u("Priors consent differs from the requested agent, root, owner or premium.")}async function K(t,r,n,o,s){let d=l(n.agentId,"agentId");if(!A(await B(t,d),o))throw new u("This operation requires the current identity owner wallet; a delegate cannot consent. Use the owner wallet.");let g=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),p=n.continuation,h=p?l(p.deadline,"deadline"):BigInt(Math.floor(Date.now()/1e3)+1800),f=l(n.maxPremiumBps??"0","maxPremiumBps");if(n.signature!==void 0&&!n.continuation)throw new u("A signature needs its locally confirmed Priors consent continuation.");if(f>200n)throw new u("maxPremiumBps exceeds the pool maximum of 200.");let y=N(d.toString(),s.toString(),o,g.toString(),h.toString(),f.toString());if(!p)return{steps:[{kind:"typedData",request:y}],continuation:{stage:"priors_consent",tool:r,wallet:o,chainId:b,agentId:d.toString(),nonce:g.toString(),deadline:h.toString()},summary:`Owner consent to sponsor #${s} for agent #${d}, premium cap ${f} bps; expires ${h}. No funds move from this signature. The local bridge must confirm the exact EIP-712 fields.`};if(ie(r,n,o,[{kind:"typedData",request:y}],p,Math.floor(Date.now()/1e3)),String(p.nonce)!==g.toString())throw new u("Priors consent nonce changed. Start the action again.");let k={request:y,signature:n.signature};return await M(t,k,y),{signedConsent:k}}async function oe(t,r,n,o){let s=c[r.contract],d=(p,h)=>h>0n?[t.approval(p,s,h.toString(),b)]:[];if(r.approval==="nft"){let p=l(n.agentId,"agentId"),h=await Promise.all([c.market,c.market1].map(f=>I(t,f,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[p])));for(let f of h){if(!f||typeof f!="object"||!("seller"in f)||typeof f.seller!="string")throw new u("Could not verify standing listings on both Priors markets; no NFT approval was built.");if(A(f.seller,o))throw new u("A standing listing in Priors market V1 or V2 could reactivate when NFT approval mines. Cancel it with priors_market_v1_cancel or priors_market_v2_cancel, verify both listings are cleared, then retry. No approval was built.")}return[t.approval(c.registry,s,p.toString(),b)]}if(r.approval==="market"){let p=await I(t,s,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[l(n.agentId,"agentId")]);if(p.price<=0n||p.price>l(n.maxPrice,"maxPrice")||p.nonce!==l(n.nonce,"nonce")||!A(p.uriHash,String(n.uriHash)))throw new u("Listing price, nonce or URI changed; read the listing again.");return d(c.usdg,p.price)}if(r.approval==="bid"){let p=l(n.reserveBudget,"reserveBudget");if(p>=1n<<128n||p<l(n.price,"price")*l(n.count??"1","count"))throw new u("Provide a finite exact bid reserve covering price times count.");return[t.approval(c.usdg,c.bidSpender,p.toString(),b)]}if(r.approval==="bond")return d(c.usdg,BigInt(await I(t,c.bond,"amount() view returns (uint256)")));if(r.approval==="mixed"){let p=l(n.priorsIn,"priorsIn"),h=l(n.usdgIn,"usdgIn");if(p+h===0n)throw new u("Provide a positive PRIORS or USDG input.");if(h>0n&&l(n.minOut,"minOut")===0n)throw new u("USDG conversion requires a positive minimum PRIORS output.");return[...d(c.priors,p),...d(c.usdg,h)]}if(!r.approval)return[];let g=l(n.amount,"amount");if(g===0n)throw new u("amount must be positive.");if(r.approval==="stock"){let p=r.name==="priors_stock_open"?w(String(n.token)):w((await I(t,c.stock,"getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[l(n.agentId,"agentId")])).token);if(p===ne)throw new u("No stock collateral position exists.");return d(p,g)}return d(c[r.approval],g)}function pe(t){let r=Z.map(n=>({name:n.name,inputSchema:{...P(n.fields,n.consentRoot?{maxPremiumBps:U(),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"},...n.externalConsent?{signedConsent:{type:"object",description:"Optional public owner signature from priors_sign_consent; controller may supply collateral. Never pass a key."}}:{}}:{}),description:n.note||"Read current Priors contract state. All amounts are token base-unit decimal strings."},async execute(o,s){F(t),s=w(s);let d=Object.fromEntries(n.fields.map(m=>[m[0],te(o,m)]));if(n.owner&&!(n.externalConsent&&o.signedConsent)&&!A(await B(t,d[n.owner]),s))throw new u("Owner-only feature: call from the current identity owner wallet. Nothing was signed.");if(n.contract==="savings"&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("The savings vault asset is not USDG. Nothing was signed.");if(n.contract==="autopay"&&await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2. Nothing was signed.");if(n.contract==="market"||n.contract==="market1"){if(o.expiry!==void 0){let m=l(o.expiry,"expiry",64),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+2592000n)throw new u("Market expiry must be within 30 days.")}if(o.price!==void 0&&l(o.price,"price")<5000000n)throw new u("Market price minimum is 5 USDG.");if(o.count!==void 0&&(l(o.count,"count")<1n||l(o.count,"count")>20n))throw new u("Bid count must be 1 to 20.")}if(n.name==="priors_treasury_first_line"&&l(o.expiry,"expiry",64)<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Treasury V5 invite expired.");if(o.deadline!==void 0){let m=l(o.deadline,"deadline"),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+3600n)throw new u("deadline must be in the next hour.")}if(o.agentIds&&o.agentIds.length!==o.generations.length)throw new u("agentIds and generations must have equal length.");let g;if(n.consentRoot)if(n.externalConsent&&o.signedConsent){if(g=o.signedConsent,!g.request?.message)throw new u("Provide the public signedConsent from the current identity owner.");let m=l(o.agentId,"agentId"),x=await B(t,m),T=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[m]}),q=l(g.request.message.deadline,"consent deadline");if(q<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired.");let L=l(o.maxPremiumBps??"0","maxPremiumBps");if(L>200n)throw new u("maxPremiumBps exceeds the pool cap.");await M(t,g,N(m.toString(),n.consentRoot.toString(),x,T.toString(),q.toString(),L.toString()))}else{let m=await K(t,n.name,o,s,n.consentRoot);if("steps"in m)return m;g=m.signedConsent}let p=(n.args??n.fields.map(([m])=>m)).map(m=>m==="$wallet"?s:m==="$consent"?g.request.message:m==="$signature"?g.signature:d[m]),h=S([n.signature]),f=h[0].name;if(n.read)return{chainId:b,contract:c[n.contract],units:"Base units; USDG 6 decimals, PRIORS 18 decimals; stock/savings scales come from token metadata.",value:J(await t.clientFor(b).readContract({address:c[n.contract],abi:h,functionName:f,args:p}))};let y=[...await oe(t,n,o,s),t.unsignedTx({to:c[n.contract],data:E({abi:h,functionName:f,args:p}),value:"0",chainId:b,description:`${n.name}: ${n.note}`})],k=await t.preview(y,s);return{txs:y,summary:`${n.note} Inputs (base units): ${JSON.stringify(J(d))}. ${k.summary}`}}}));return r.push({name:"priors_sign_consent",inputSchema:P([i,["sponsorId","id"],["maxPremiumBps","uint"]],{continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"}}),async execute(n,o){return F(t),K(t,"priors_sign_consent",n,w(o),l(n.sponsorId,"sponsorId"))}}),r.push({name:"priors_root_offer",inputSchema:P([["sponsorId","id"],i,v,["premiumBps","uint"]],{signedConsent:{type:"object",description:"The current agent owner output of priors_sign_consent. This is public signed authorization, never a private key."}}),async execute(n,o){F(t),o=w(o);let s=l(n.sponsorId,"sponsorId"),d=l(n.agentId,"agentId");if(!A(await B(t,s),o))throw new u("Only the sponsor root owner can send this offer.");let g=n.signedConsent;if(!g?.request?.message)throw new u("Ask the current agent owner to run priors_sign_consent from their wallet first.");let p=g.request.message,h=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),f=l(p.deadline,"consent deadline");if(f<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired; request a fresh consent.");let y=l(n.premiumBps,"premiumBps"),k=l(p.maxPremiumBps,"maxPremiumBps");if(y>k||k>200n)throw new u("premiumBps exceeds the owner consent or pool cap.");let m=N(d.toString(),s.toString(),await B(t,d),h.toString(),f.toString(),k.toString());await M(t,g,m);let x=S([`function vouchWithConsent(uint256,uint256,uint256,uint256,${C},bytes)`]),T=[t.unsignedTx({to:c.pool,data:E({abi:x,functionName:"vouchWithConsent",args:[s,d,l(n.amount,"amount"),y,m.message,g.signature]}),value:"0",chainId:b,description:"Sponsor-owned backing handoff with exact current-owner consent."})],q=await t.preview(T,o);return{txs:T,summary:`Vouch ${n.amount} USDG base units from sponsor #${s} to agent #${d}; ${y} bps premium (cap ${k}). Replaces its old sponsor only with no loan open. ${q.summary}`}}}),r.push(...re(t)),{tools:r}}function re(t){return[{name:"priors_autopay_on",inputSchema:P([i,["cap","uint"],["budget","uint"],["savingsShares","uint"],["late","bool"]]),async execute(r,n){F(t),n=w(n);let o=l(r.agentId,"agentId"),s=l(r.cap,"cap"),d=l(r.budget,"budget"),g=l(r.savingsShares,"savingsShares");if(typeof r.late!="boolean")throw new u("late must be true or false.");if(await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2.");let p=await I(t,c.autopay,"MAX_CAP() view returns (uint256)");if(s===0n||s>p||s>=1n<<32n||d<s||d===(1n<<256n)-1n||g===(1n<<256n)-1n)throw new u("Provide a positive supported per-loan cap and explicit finite budget at least cap; unlimited approvals are refused.");let h=await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"getAgentWallet",args:[o]});if(w(h)!==n)throw new u("Autopay enrollment requires the ERC-8004 declared agent wallet, not just its owner or pool delegate.");if(g>0n&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("Savings asset is not USDG.");let f=g>0n?await I(t,c.savings,"previewRedeem(uint256) view returns (uint256)",[g]):0n,y=S(["function enroll(uint256,uint256,bool,bool)"]),k=[t.approval(c.usdg,c.autopay,d.toString(),b),t.approval(c.savings,c.autopay,g.toString(),b),t.unsignedTx({to:c.autopay,data:E({abi:y,functionName:"enroll",args:[o,s,g>0n,r.late]}),value:"0",chainId:b,description:"Enroll future autopay with explicit finite USDG and savings share budgets."})],m=await t.preview(k,n);return{txs:k,summary:`Persistent future spending authorization: AutoRepay v2 can repay agent #${o} loans without a confirmation per loan, at most ${s} USDG base units per loan; exact total wallet allowance ${d} USDG base units and ${g} savings shares (currently ${f} USDG base units). These two allowances replace the budgets shared by ALL this wallet autopay plans, including setting savings allowance to zero when disabled. late=${r.late}; savings=${g>0n}. Revoke with priors_autopay_off, which also clears both allowances. ${m.summary}`}}},{name:"priors_autopay_off",inputSchema:P([i]),async execute(r,n){F(t),n=w(n);let o=S(["function revoke(uint256)"]),s=[t.unsignedTx({to:c.autopay,data:E({abi:o,functionName:"revoke",args:[l(r.agentId,"agentId")]}),value:"0",chainId:b,description:"Revoke own autopay plan."}),t.approval(c.usdg,c.autopay,"0",b),t.approval(c.savings,c.autopay,"0",b)],d=await t.preview(s,n);return{txs:s,summary:`Revoke this wallet autopay plan and zero both shared AutoRepay allowances. This also stops funding other plans using this wallet. ${d.summary}`}}}]}export{Y as a,$ as b,Z as c,J as d,l as e,N as f,ie as g,pe as h};
|