@oakagentkit/core 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/api/amounts.d.ts +2 -0
- package/build/dist/api/amounts.js +1 -1
- package/build/dist/api/args.js +1 -1
- package/build/dist/api/gas.js +1 -1
- package/build/dist/api/grandfather.js +1 -1
- package/build/dist/api/guards.js +1 -1
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/http.js +1 -1
- package/build/dist/api/merkle.js +1 -1
- package/build/dist/api/module.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 +149 -0
- package/build/dist/api/modules/borro/abi.js +1 -0
- package/build/dist/api/modules/borro/actions.d.ts +2 -0
- package/build/dist/api/modules/borro/actions.js +1 -0
- package/build/dist/api/modules/borro/checks.d.ts +151 -0
- package/build/dist/api/modules/borro/checks.js +1 -0
- package/build/dist/api/modules/borro/copy.d.ts +174 -0
- package/build/dist/api/modules/borro/copy.js +1 -0
- package/build/dist/api/modules/borro/index.d.ts +13 -0
- package/build/dist/api/modules/borro/index.js +1 -0
- package/build/dist/api/modules/borro/liquidity.d.ts +4 -0
- package/build/dist/api/modules/borro/liquidity.js +1 -0
- package/build/dist/api/modules/borro/pins.d.ts +264 -0
- package/build/dist/api/modules/borro/pins.js +1 -0
- package/build/dist/api/modules/borro/positions.d.ts +8 -0
- package/build/dist/api/modules/borro/positions.js +1 -0
- package/build/dist/api/modules/borro/rates.d.ts +20 -0
- package/build/dist/api/modules/borro/rates.js +1 -0
- package/build/dist/api/modules/borro/reader.d.ts +36 -0
- package/build/dist/api/modules/borro/reader.js +1 -0
- package/build/dist/api/modules/borro/types.d.ts +126 -0
- package/build/dist/api/modules/borro/types.js +0 -0
- package/build/dist/api/modules/chop/abi.d.ts +527 -0
- package/build/dist/api/modules/chop/abi.js +1 -0
- package/build/dist/api/modules/chop/actions.d.ts +24 -0
- package/build/dist/api/modules/chop/actions.js +1 -0
- package/build/dist/api/modules/chop/checks.d.ts +26 -0
- package/build/dist/api/modules/chop/checks.js +1 -0
- package/build/dist/api/modules/chop/copy.d.ts +5 -0
- package/build/dist/api/modules/chop/copy.js +1 -0
- package/build/dist/api/modules/chop/guard.d.ts +13 -0
- package/build/dist/api/modules/chop/guard.js +1 -0
- package/build/dist/api/modules/chop/index.d.ts +3 -0
- package/build/dist/api/modules/chop/index.js +1 -0
- package/build/dist/api/modules/chop/pins.d.ts +53 -0
- package/build/dist/api/modules/chop/pins.js +1 -0
- package/build/dist/api/modules/chop/positions.d.ts +3 -0
- package/build/dist/api/modules/chop/positions.js +1 -0
- package/build/dist/api/modules/chop/reader.d.ts +70 -0
- package/build/dist/api/modules/chop/reader.js +1 -0
- package/build/dist/api/modules/chop/types.d.ts +32 -0
- package/build/dist/api/modules/chop/types.js +0 -0
- package/build/dist/api/modules/clanker/extensions.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/clanker/manage.js +1 -1
- package/build/dist/api/modules/clanker/pool-config.js +1 -1
- package/build/dist/api/modules/clanker/protocol.js +1 -1
- package/build/dist/api/modules/clanker/state.js +1 -1
- package/build/dist/api/modules/earn/copy.d.ts +2 -2
- package/build/dist/api/modules/earn/copy.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/earn/lp.js +1 -1
- package/build/dist/api/modules/earn/options.js +1 -1
- package/build/dist/api/modules/erc8004/common.js +1 -1
- package/build/dist/api/modules/erc8004/domain.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/erc8004/management.js +1 -1
- package/build/dist/api/modules/erc8004/reputation.js +1 -1
- package/build/dist/api/modules/erc8004/services.js +1 -1
- package/build/dist/api/modules/erc8004/validation.js +1 -1
- package/build/dist/api/modules/gloam/abi.d.ts +89 -0
- package/build/dist/api/modules/gloam/abi.js +1 -0
- package/build/dist/api/modules/gloam/actions.d.ts +5 -0
- package/build/dist/api/modules/gloam/actions.js +1 -0
- package/build/dist/api/modules/gloam/checks.d.ts +17 -0
- package/build/dist/api/modules/gloam/checks.js +1 -0
- package/build/dist/api/modules/gloam/copy.d.ts +22 -0
- package/build/dist/api/modules/gloam/copy.js +2 -0
- package/build/dist/api/modules/gloam/index.d.ts +6 -0
- package/build/dist/api/modules/gloam/index.js +1 -0
- package/build/dist/api/modules/gloam/pins.d.ts +41 -0
- package/build/dist/api/modules/gloam/pins.js +1 -0
- package/build/dist/api/modules/gloam/types.d.ts +308 -0
- package/build/dist/api/modules/gloam/types.js +1 -0
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/proof-reads.js +1 -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/token-facts.js +1 -1
- package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
- package/build/dist/api/modules/hoodag/index.js +1 -1
- package/build/dist/api/modules/hoodag/management.js +1 -1
- package/build/dist/api/modules/hoodag/public-reads.js +1 -1
- package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/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.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/hookr/revenue.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
- package/build/dist/api/modules/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-common.js +1 -1
- package/build/dist/api/modules/meridian/perps-guards.js +1 -1
- package/build/dist/api/modules/meridian/perps-intents.js +1 -1
- package/build/dist/api/modules/meridian/perps-stream.js +1 -1
- package/build/dist/api/modules/meridian/perps.d.ts +1 -0
- 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.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/netnet/staking.js +1 -1
- package/build/dist/api/modules/orbio/gateway.js +1 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/orbio/positions.js +1 -1
- package/build/dist/api/modules/pendle/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/types.d.ts +16 -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.d.ts +1 -0
- package/build/dist/api/modules/pons/launch-status.js +1 -1
- package/build/dist/api/modules/pons/prices.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/swap-terms.js +1 -1
- package/build/dist/api/modules/pons/trade.js +1 -1
- package/build/dist/api/modules/poolstrade/index.js +1 -1
- package/build/dist/api/modules/priors/coverage.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/features.js +1 -1
- package/build/dist/api/modules/priors/holdings.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/market.js +1 -1
- package/build/dist/api/modules/priors/pt.js +1 -1
- package/build/dist/api/modules/priors/savings-exit.js +1 -1
- package/build/dist/api/modules/priors/starter-line.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/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.d.ts +2 -0
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/order.js +1 -1
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- 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/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/token-jar.js +1 -1
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
- package/build/dist/api/modules/uniswap/trade.js +1 -1
- package/build/dist/api/modules/uniswap/v2.js +1 -1
- package/build/dist/api/modules/uniswap/v3.d.ts +11 -1
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.js +1 -1
- package/build/dist/api/modules/velora/claims.js +1 -1
- package/build/dist/api/modules/velora/delta-reads.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.d.ts +3 -0
- 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.d.ts +11 -0
- package/build/dist/api/modules/wormhole/swap-token-verdict.js +1 -0
- package/build/dist/api/modules/wormhole/third-party-text.d.ts +13 -0
- package/build/dist/api/modules/wormhole/third-party-text.js +1 -0
- package/build/dist/api/modules/wormhole/token-check.d.ts +2 -0
- package/build/dist/api/modules/wormhole/token-check.js +1 -1
- package/build/dist/api/modules/wormhole/x402-client.d.ts +36 -0
- package/build/dist/api/modules/wormhole/x402-client.js +1 -0
- package/build/dist/api/positions.js +1 -1
- package/build/dist/api/pricenote.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/pricing.js +1 -1
- package/build/dist/api/routes.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.d.ts +1 -0
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/tx.js +1 -1
- package/build/dist/api/types.d.ts +6 -1
- package/build/dist/api/vendor-limits.js +1 -1
- package/build/dist/chunks/{ALRRW7SF.js → 2MT3G7YZ.js} +1 -1
- package/build/dist/chunks/{WPAF55SP.js → 2THSW4QN.js} +1 -1
- package/build/dist/chunks/{MKAPRRKF.js → 2TK3ETUO.js} +1 -1
- package/build/dist/chunks/{VVA72C6O.js → 2VXLVXIB.js} +1 -1
- package/build/dist/chunks/{ZE7EU2CS.js → 35KR3VSS.js} +1 -1
- package/build/dist/chunks/{ZYH4B2GR.js → 3GQ7A3VB.js} +1 -1
- package/build/dist/chunks/3VWVW7PX.js +1 -0
- package/build/dist/chunks/{WPFAEBE7.js → 3XNZUIRU.js} +1 -1
- package/build/dist/chunks/{PBQSJSZO.js → 43LI5NKJ.js} +1 -1
- package/build/dist/chunks/{QVYCJ6WV.js → 46KWRAYK.js} +1 -1
- package/build/dist/chunks/4DP2VPXR.js +3 -0
- package/build/dist/chunks/{47YN4OUI.js → 4EN6MQEI.js} +1 -1
- package/build/dist/chunks/{UHRCM7AG.js → 4HG6FRVH.js} +1 -1
- package/build/dist/chunks/{E6UU7DL2.js → 4I3OU56B.js} +1 -1
- package/build/dist/chunks/{WIVYKLQM.js → 52ELWNXJ.js} +1 -1
- package/build/dist/chunks/{5WUKOQIJ.js → 5AXWBSPG.js} +1 -1
- package/build/dist/chunks/{D6ZJPNK7.js → 5N3O42X6.js} +1 -1
- package/build/dist/chunks/{UA4O226F.js → 5SMVQCAP.js} +1 -1
- package/build/dist/chunks/{6L5KTE6Y.js → 5SZPNZG4.js} +1 -1
- package/build/dist/chunks/{6PY3IRDS.js → 64GOINYS.js} +1 -1
- package/build/dist/chunks/{5ZLOCQA4.js → 66F5ZH34.js} +1 -1
- package/build/dist/chunks/{XDZRO5JQ.js → 6I4NTKB2.js} +1 -1
- package/build/dist/chunks/{LVLVP5KQ.js → 6JAXZNZ3.js} +1 -1
- package/build/dist/chunks/{BXHNYCH2.js → 6O3Q5B6M.js} +1 -1
- package/build/dist/chunks/{MFCPL6LF.js → 6OGDTEGH.js} +1 -1
- package/build/dist/chunks/{43CSMYDO.js → 6WD4HHID.js} +1 -1
- package/build/dist/chunks/{XJEOEMDS.js → 6WZX7C4T.js} +1 -1
- package/build/dist/chunks/6YB3VOUL.js +1 -0
- package/build/dist/chunks/77CLMPM7.js +1 -0
- package/build/dist/chunks/{EKNSLLJK.js → 7GJ6SLEV.js} +1 -1
- package/build/dist/chunks/{S2TAJHHK.js → 7KWZ5QJU.js} +1 -1
- package/build/dist/chunks/{CTMA4BTM.js → 7QIO77VE.js} +1 -1
- package/build/dist/chunks/7QZOTRSA.js +2 -0
- package/build/dist/chunks/{IKEJCBYU.js → 7WSHW7KW.js} +1 -1
- package/build/dist/chunks/{PQC5635W.js → A7I4IWUB.js} +1 -1
- package/build/dist/chunks/ACW63WIL.js +20 -0
- package/build/dist/chunks/AEL62KCG.js +1 -0
- package/build/dist/chunks/{UPMGGK34.js → AFBEZXNV.js} +1 -1
- package/build/dist/chunks/{AUOXDNUO.js → AKYF5264.js} +1 -1
- package/build/dist/chunks/{HVM2EEXB.js → ALLLYOUG.js} +1 -1
- package/build/dist/chunks/APQYLJGS.js +1 -0
- package/build/dist/chunks/AW7AXQCZ.js +1 -0
- package/build/dist/chunks/{WOEKXQAH.js → AXRL3REN.js} +1 -1
- package/build/dist/chunks/{ECWGKLBW.js → BBTPRZ6T.js} +1 -1
- package/build/dist/chunks/{ALPYEM7B.js → BND2UFVW.js} +1 -1
- package/build/dist/chunks/{GHPREYQK.js → BOVMED7R.js} +1 -1
- package/build/dist/chunks/{57JFKIMK.js → BTPXJAUX.js} +1 -1
- package/build/dist/chunks/{ZGKVXFM5.js → C7AXJHBT.js} +1 -1
- package/build/dist/chunks/{5U7TCKX2.js → CBG5HARQ.js} +1 -1
- package/build/dist/chunks/{NA7R6J5N.js → CBLMQ5UU.js} +1 -1
- package/build/dist/chunks/CDPSMI3Z.js +1 -0
- package/build/dist/chunks/{5N4A5XAW.js → CHXBOXOD.js} +1 -1
- package/build/dist/chunks/{2ZUP7ZEV.js → CQEJSCFQ.js} +1 -1
- package/build/dist/chunks/{6AAARNZ3.js → DBNTZEAJ.js} +1 -1
- package/build/dist/chunks/{IQIWASRD.js → DHUDSOGR.js} +1 -1
- package/build/dist/chunks/{L7OQUHM5.js → DJN3JAWB.js} +1 -1
- package/build/dist/chunks/{YPM2UITD.js → DL6AEWEM.js} +1 -1
- package/build/dist/chunks/{CERNEJ2F.js → DW4V5PUY.js} +1 -1
- package/build/dist/chunks/E3RACZUY.js +1 -0
- package/build/dist/chunks/{MOPETB64.js → EGYVRQUR.js} +1 -1
- package/build/dist/chunks/{IQGY5FW7.js → ER47KGRM.js} +1 -1
- package/build/dist/chunks/{ZSQOMSOC.js → FEYAY6OZ.js} +1 -1
- package/build/dist/chunks/FIO6VC2J.js +1 -0
- package/build/dist/chunks/FJ4S4GHY.js +1 -0
- package/build/dist/chunks/{RPNAFUM5.js → FUDAXV5X.js} +1 -1
- package/build/dist/chunks/{I6KUORFT.js → GG6Y4OCJ.js} +1 -1
- package/build/dist/chunks/{3AXVB23N.js → GGHBFLRC.js} +1 -1
- package/build/dist/chunks/{4ALMYJJV.js → GGSAKCND.js} +1 -1
- package/build/dist/chunks/GNC6RXLT.js +1 -0
- package/build/dist/chunks/{3ESNHZT5.js → GRQYTVNT.js} +1 -1
- package/build/dist/chunks/{WVONJOWN.js → GSBIERZD.js} +1 -1
- package/build/dist/chunks/H43RNCX2.js +1 -0
- package/build/dist/chunks/{NYNJITCM.js → H6T5FXEX.js} +1 -1
- package/build/dist/chunks/HHXBUYHO.js +1 -0
- package/build/dist/chunks/{64WKYWZV.js → HKEMQBFA.js} +1 -1
- package/build/dist/chunks/{4YFVAYKR.js → HM72DH4V.js} +1 -1
- package/build/dist/chunks/{XFKVU46U.js → HQUVB7Z5.js} +1 -1
- package/build/dist/chunks/HS4DZPYT.js +1 -0
- package/build/dist/chunks/{OTIXQZ3X.js → HU7IMNBI.js} +1 -1
- package/build/dist/chunks/{ENX72ARB.js → HWX36XJI.js} +1 -1
- package/build/dist/chunks/{QRC4ZPDA.js → I26DMNJG.js} +1 -1
- package/build/dist/chunks/I55MURSJ.js +1 -0
- package/build/dist/chunks/I6PQW2JI.js +1 -0
- package/build/dist/chunks/{S3FPF537.js → IMO3GDA5.js} +1 -1
- package/build/dist/chunks/{BQICZFLR.js → IOYRL6AY.js} +1 -1
- package/build/dist/chunks/IPN6Z4JM.js +1 -0
- package/build/dist/chunks/{MKBNLGDD.js → IPRVIKYC.js} +1 -1
- package/build/dist/chunks/{EOQYLFXA.js → IVX4R5OL.js} +1 -1
- package/build/dist/chunks/IX3GZMTM.js +1 -0
- package/build/dist/chunks/JFYBH3DX.js +1 -0
- package/build/dist/chunks/{Y7RPSDD2.js → JKD2B6OX.js} +1 -1
- package/build/dist/chunks/JQOQMFWD.js +3 -0
- package/build/dist/chunks/{PSVOVZH7.js → JUZ5JU6D.js} +5 -5
- package/build/dist/chunks/{I4TGMF2C.js → JZS3E66E.js} +1 -1
- package/build/dist/chunks/{SSIENQVU.js → K3RDPI5J.js} +1 -1
- package/build/dist/chunks/{PADWZX7J.js → K4DHHQBI.js} +1 -1
- package/build/dist/chunks/{NB3LYS3G.js → KIFZ5ZSK.js} +1 -1
- package/build/dist/chunks/KVFZKPJT.js +1 -0
- package/build/dist/chunks/{EYFBVQ46.js → L5BLHY34.js} +1 -1
- package/build/dist/chunks/{GVPX5XCL.js → LKXO2BQS.js} +1 -1
- package/build/dist/chunks/{JPNYUEQP.js → LKZX4CAA.js} +1 -1
- package/build/dist/chunks/{LROVANUR.js → LYMNHO5T.js} +1 -1
- package/build/dist/chunks/{QSN6Y2K6.js → M2UXYCKH.js} +1 -1
- package/build/dist/chunks/{BNG2IWZL.js → M37654RL.js} +1 -1
- package/build/dist/chunks/{YAJYDD6C.js → M6LC6DRE.js} +1 -1
- package/build/dist/chunks/{AG67Z3SC.js → MOE3EVAL.js} +1 -1
- package/build/dist/chunks/{DVVFT42J.js → MRMR4QHA.js} +1 -1
- package/build/dist/chunks/{WWHCEMNB.js → N4Q6GN65.js} +1 -1
- package/build/dist/chunks/{S5WICHIS.js → NAZPDRIF.js} +1 -1
- package/build/dist/chunks/{HSFOWJ3Z.js → NKZKKCK2.js} +1 -1
- package/build/dist/chunks/{BAAXGB4K.js → NOFUKKP5.js} +1 -1
- package/build/dist/chunks/{5KUWLUPM.js → NWNYJ26T.js} +1 -1
- package/build/dist/chunks/{7UOOIDR3.js → O6ROOKY2.js} +1 -1
- package/build/dist/chunks/{KBXU7U6Q.js → O7HCEPQY.js} +1 -1
- package/build/dist/chunks/{LDT3QTSY.js → OJ4WJUPP.js} +1 -1
- package/build/dist/chunks/{WD37MEMZ.js → OLSP46ZD.js} +1 -1
- package/build/dist/chunks/{TPL4U3AQ.js → OOZSE2R7.js} +1 -1
- package/build/dist/chunks/OTXSKFUD.js +1 -0
- package/build/dist/chunks/{4TQQH7N6.js → P5AJSLZ7.js} +1 -1
- package/build/dist/chunks/{BK23XJXE.js → P5PYFK7L.js} +1 -1
- package/build/dist/chunks/{A6YQ5H24.js → PACN53TR.js} +1 -1
- package/build/dist/chunks/{K72EYD6R.js → PAHXBLCS.js} +1 -1
- package/build/dist/chunks/PAY5PD4H.js +1 -0
- package/build/dist/chunks/{SGEZIYJW.js → PIIHOXWF.js} +1 -1
- package/build/dist/chunks/{SQL6HD5E.js → PK66GCDT.js} +1 -1
- package/build/dist/chunks/PNA6UIE5.js +1 -0
- package/build/dist/chunks/{6FTYNYGF.js → PSBQWDYI.js} +1 -1
- package/build/dist/chunks/{W76QC2AW.js → PV5FDT6O.js} +1 -1
- package/build/dist/chunks/{42DQTKEO.js → PXT5YTWU.js} +1 -1
- package/build/dist/chunks/{4ISR2U72.js → PZGGE5D3.js} +1 -1
- package/build/dist/chunks/{IMRXZ7JB.js → Q42YI3EP.js} +1 -1
- package/build/dist/chunks/{F3BSEE52.js → QA2RRIES.js} +1 -1
- package/build/dist/chunks/{ZBFKKUNP.js → QA3UHEO3.js} +1 -1
- package/build/dist/chunks/{PWH464CJ.js → QBIY6FQN.js} +1 -1
- package/build/dist/chunks/QFNT73OF.js +1 -0
- package/build/dist/chunks/QHBS3PVU.js +1 -0
- package/build/dist/chunks/QQECG3WP.js +1 -0
- package/build/dist/chunks/{RVO3QK2B.js → QU5XKRGK.js} +1 -1
- package/build/dist/chunks/QW2OPEYJ.js +1 -0
- package/build/dist/chunks/{G7XSFUDL.js → QYVREJYC.js} +1 -1
- package/build/dist/chunks/{KA7BPBCV.js → ROFPXEQ5.js} +1 -1
- package/build/dist/chunks/{5MQ5KSSV.js → RTAHNWHN.js} +1 -1
- package/build/dist/chunks/{MDDHG34Y.js → RTGS7RIO.js} +1 -1
- package/build/dist/chunks/{3WXK2FUA.js → RUC7KH7A.js} +1 -1
- package/build/dist/chunks/{MBTARLZQ.js → RUX3RY7Y.js} +1 -1
- package/build/dist/chunks/{3VAJW6TQ.js → RVDUSNWW.js} +1 -1
- package/build/dist/chunks/{ET23SES4.js → S5CBVFHY.js} +1 -1
- package/build/dist/chunks/{WMNRP3YH.js → SIYUNOLI.js} +1 -1
- package/build/dist/chunks/{TNKVRVTH.js → SJJR4ZBZ.js} +1 -1
- package/build/dist/chunks/{UFVPMWPJ.js → SMYWWIE6.js} +1 -1
- package/build/dist/chunks/{Z4SRGAVL.js → SPJCSEKP.js} +1 -1
- package/build/dist/chunks/{YEXUSRIZ.js → T7TFUH5K.js} +1 -1
- package/build/dist/chunks/{SKMPKAZI.js → TAEZTP4L.js} +1 -1
- package/build/dist/chunks/{E3UBHTJO.js → TEJ7W534.js} +1 -1
- package/build/dist/chunks/{AWXJV2YH.js → TFDPEAVZ.js} +1 -1
- package/build/dist/chunks/{UOGHQLQX.js → TMVO2DAK.js} +1 -1
- package/build/dist/chunks/{QJFXLYZG.js → TPBAFS7K.js} +1 -1
- package/build/dist/chunks/{MXW2TP5P.js → TVWMTMEF.js} +1 -1
- package/build/dist/chunks/{GRIGSPD4.js → TX2EOIRS.js} +1 -1
- package/build/dist/chunks/{Y7PRJOIK.js → U2RMUVVY.js} +1 -1
- package/build/dist/chunks/{VV2HEIFI.js → U5PMVP56.js} +1 -1
- package/build/dist/chunks/{TBCSZDAF.js → UD2XMNIT.js} +1 -1
- package/build/dist/chunks/{F26FK47J.js → UNJJRQIU.js} +1 -1
- package/build/dist/chunks/V5JWGWXC.js +1 -0
- package/build/dist/chunks/V74F6IDY.js +1 -0
- package/build/dist/chunks/VCOTCVKN.js +1 -0
- package/build/dist/chunks/{MYFAKCQI.js → VEQBHI6O.js} +1 -1
- package/build/dist/chunks/VHV6WQ5F.js +1 -0
- package/build/dist/chunks/{7WQEPZJY.js → VNV6ZISN.js} +1 -1
- package/build/dist/chunks/{W2OJ57ZO.js → VYAJXLND.js} +1 -1
- package/build/dist/chunks/{MDV7GECM.js → VYYSL557.js} +1 -1
- package/build/dist/chunks/WCNHZYQQ.js +1 -0
- package/build/dist/chunks/{K22EXPWN.js → WIRBCS4W.js} +1 -1
- package/build/dist/chunks/{YRXT3HTW.js → WLMWWEP7.js} +1 -1
- package/build/dist/chunks/{NDW5DAFL.js → WP6RHXGN.js} +1 -1
- package/build/dist/chunks/{PLZKXQ76.js → WTXC3XKW.js} +1 -1
- package/build/dist/chunks/{WGL46F3S.js → WU7XIAXB.js} +1 -1
- package/build/dist/chunks/{5OKJEGBH.js → WV3A3OUU.js} +1 -1
- package/build/dist/chunks/{MGPHD4VV.js → X2P55AC3.js} +1 -1
- package/build/dist/chunks/{RNC463IM.js → XBE3B6Y2.js} +1 -1
- package/build/dist/chunks/XD6X3KTC.js +1 -0
- package/build/dist/chunks/{BIRMUW7Z.js → XKSVTN5X.js} +1 -1
- package/build/dist/chunks/XL3LLGIR.js +1 -0
- package/build/dist/chunks/XQA5LCL6.js +1 -0
- package/build/dist/chunks/{SDHPFXRM.js → XSKFKBDR.js} +1 -1
- package/build/dist/chunks/{TJWVY4VO.js → YCZPSMZ5.js} +1 -1
- package/build/dist/chunks/{JZXYLHI7.js → YDNTY67T.js} +1 -1
- package/build/dist/chunks/{2DUCTO5C.js → YN56C7PN.js} +1 -1
- package/build/dist/chunks/{E6RRXNV2.js → YRNXGQJC.js} +1 -1
- package/build/dist/chunks/YWRLY5EA.js +1 -0
- package/build/dist/chunks/YWSX6IE6.js +1 -0
- package/build/dist/chunks/{DP2NIYBP.js → YXTSWRV5.js} +1 -1
- package/build/dist/chunks/{MQYOG66Q.js → Z6LZGCVW.js} +1 -1
- package/build/dist/chunks/{OFI3Y55L.js → ZQAFFWDK.js} +1 -1
- package/build/dist/chunks/{NZXQWDGF.js → ZQWZGH7V.js} +1 -1
- package/build/dist/chunks/{TBIVTEP5.js → ZSN4IRI5.js} +1 -1
- package/build/dist/chunks/{ZET37EIG.js → ZV5HIQXC.js} +1 -1
- package/build/dist/chunks/{VHLINDDS.js → ZXJ24B4L.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/24CQ2SPB.js +0 -1
- package/build/dist/chunks/2OJAOVMG.js +0 -1
- package/build/dist/chunks/65EQECL3.js +0 -1
- package/build/dist/chunks/6YYCGUCU.js +0 -1
- package/build/dist/chunks/EU3OAJU2.js +0 -1
- package/build/dist/chunks/H4NYYJ3Z.js +0 -1
- package/build/dist/chunks/HTXKERNS.js +0 -1
- package/build/dist/chunks/JG27HM4P.js +0 -1
- package/build/dist/chunks/L6D26AMO.js +0 -1
- package/build/dist/chunks/O6L4BJP4.js +0 -1
- package/build/dist/chunks/SUFA2GKR.js +0 -1
- package/build/dist/chunks/UP7FBDMJ.js +0 -1
- package/build/dist/chunks/YHRUAQQK.js +0 -1
- package/build/dist/chunks/ZCOFMGPS.js +0 -1
- package/build/dist/chunks/ZCUXM52B.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as ht}from"./G7XSFUDL.js";import{b as gt}from"./PLZKXQ76.js";import{b as bt}from"./QRC4ZPDA.js";import{c as ft}from"./EYFBVQ46.js";import{b as mt}from"./TBIVTEP5.js";import{b as pt}from"./MQYOG66Q.js";import{c as ut}from"./VHLINDDS.js";import{h as ct}from"./L7OQUHM5.js";import{a as C,b as x,c as Ie,d as me,e as Ge,g as rt,h as Ve,j as U,l as E,o as Fe,p as st,q as at,r as Me,s as dt,t as qe,u as lt}from"./YRXT3HTW.js";import{b as ot,o as it}from"./GHPREYQK.js";import{b as et}from"./Z4SRGAVL.js";import{a as z}from"./PBQSJSZO.js";import{a as tt,c as nt}from"./MYFAKCQI.js";import{a as Pe}from"./5ZLOCQA4.js";import{a as ee}from"./UP7FBDMJ.js";import{a as $,d as N,i as ce}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{a as Ee}from"./JXOEJPJ4.js";import{BaseError as Rt,ContractFunctionRevertedError as Ye,decodeEventLog as jt,decodeFunctionResult as zt,encodeFunctionData as X,erc20Abi as Jt,getAddress as B,parseAbi as ke,parseAbiItem as Xt,recoverAddress as Yt,recoverMessageAddress as Zt,recoverTypedDataAddress as Kt}from"viem";var Qt="https://priors.trade/api/check",He=604800n,wt=50n,yt=10000n,We=5000000n,$t=500000000n,je=86400n,St=2592000n,Ze=`Register one with oak_setup {"mode":"register"}, then open Priors' 5 USDG starter line with priors_starter_line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent; each transaction and signature is confirmed).`,en="0x6982e39521a070a3c40782548bfbed6dc8f566ef",tn=["0xcbb95bbf36099d34da091dc6fa6f49efa257cee3","0x284358abc07f9359f19f4b5b4ac91901be2597ba"],c={pool:B(ce[4663].priors.pool.address),lens:B(ce[4663].priors.lens.address),usdg:B(ce[4663].priors.usdg.address),registry:B(ce[4663].priors.registry.address),stockVault:B(ce[4663].priors.stockVault.address)},re={address:c.usdg,symbol:"USDG",decimals:N,chainId:$},S=ke(["function deposit(uint256 assets, address receiver, uint256 minShares) returns (uint256 minted)","function withdraw(uint256 shares_, address receiver) returns (uint256 out)","function quoteFee(uint256 agentId, uint256 principal, uint64 term) view returns (uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium)","function borrow(uint256 agentId, uint256 amount, uint64 term, address to, uint256 maxFee) returns (uint256 loanId)","function repay(uint256 loanId, uint256 expectedAgentId, uint256 maxDue)","function shares(address lender) view returns (uint256)","function convertToAssets(uint256 shares_) view returns (uint256)","function lastDepositAt(address lender) view returns (uint64)","function isController(uint256 id, address who) view returns (bool)","function delegateOf(uint256 id) view returns (address)","function getAgent(uint256 id) view returns (bool enrolled, bool isRoot, bool defaulted, bool frozen, bool importedFromV1, uint64 enrolledAt, uint64 lastBorrowAt, uint64 lastRepayAt, uint256 sponsor, uint256 delegatedIn, uint256 delegatedOut, uint256 principalOut, uint256 activeLoans, uint256 premiumBps, uint256 premiumCap, uint256 loansRepaid, uint256 volumeRepaid, uint256 feesPaid, uint256 recourseHonored, uint256 childrenDefaulted, uint256 qualifiedRepaid, uint256 dollarSecondsRepaid)","function nonces(uint256 id) view returns (uint256)","function consentDigest((uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline) c) view returns (bytes32)","function leave(uint256 agentId)","function loansOf(uint256 id) view returns (uint256[])","function getLoan(uint256 loanId) view returns (uint256 agentId, uint256 sponsorId, uint256 principal, uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium, address owner, uint64 issuedAt, uint64 dueAt, uint64 defaultableAt, uint64 minScoreTerm, uint64 closedAt, uint8 status)","event Borrowed(uint256 indexed loanId, uint256 indexed agentId, uint256 indexed sponsorId, uint256 principal, uint256 fee, uint64 dueAt, address to)"]),At=ke(["function available(uint256 agentId) view returns (uint256)","function score(uint256 id) view returns (uint256)"]),_t=ke(["function ownerOf(uint256 agentId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function getAgentWallet(uint256 agentId) view returns (address)"]),vt=ke(["function borrowRoom(uint256 agentId) view returns (uint256)","function assetList() view returns (address[])","function assets(address token) view returns (address feed, uint32 heartbeat, uint8 tokenDecimals, uint8 feedDecimals, bool enabled, uint16 ltvBps, uint256 lineCap)"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function nn(e){return e.chainId===$&&e.address.toLowerCase()===c.usdg.toLowerCase()}function on(e,i){let g=i.amount.trim(),u=g.startsWith("-"),f=u||g.startsWith("+")?g.slice(1):g,R=e.formatAmount(f,i.token.decimals),A=nn(i.token)?"USDG":i.token.address;return`${u?"-":"+"}${R} ${A}`}function te(e,i,g){if(!g.length)return i;let u=g.map(f=>on(e,f)).join(", ");return`${i} Preview changes: ${u}.`}function Pt(e,i,g,u){let f=e[i]===void 0?void 0:ee(e[i]),R=e[g]===void 0?void 0:ee(e[g]);if(f!==void 0)return f;if(R!==void 0)return R;throw new a(`Provide ${u} as an integer string in base units ("${i}" or "${g}").`)}async function De(e,i,g){try{return B(await e.clientFor($).readContract({address:c.registry,abi:_t,functionName:"ownerOf",args:[i],blockNumber:g}))}catch(u){throw u instanceof Rt&&u.walk(f=>f instanceof Ye)?new a(`ERC-8004 agent ${i} does not exist in registry ${c.registry}: it has no owner. Check the agent ID.`):new a(`Could not read the owner of ERC-8004 agent ${i} from registry ${c.registry}. Check the agent ID and retry when the registry is available.`)}}function pe(e,i){if(typeof e=="bigint"&&e>0n)return e;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if(typeof e=="string"&&/^\d+$/.test(e.trim())){let g=BigInt(e.trim());if(g>0n)return g}throw new a(`Provide a positive integer ${i}.`)}function rn(e,i){let g=i!==void 0?pe(i,"agentId"):void 0,u=[];for(let f of e)if(!(!f||typeof f.address!="string")&&f.address.toLowerCase()===c.pool.toLowerCase()&&!(!Array.isArray(f.topics)||f.topics.length===0))try{let R=jt({abi:S,eventName:"Borrowed",data:f.data,topics:f.topics});if(g!==void 0&&R.args.agentId!==g)continue;u.push(R.args.loanId)}catch{continue}return u.length===0?null:u[u.length-1].toString()}function we(e){return{enrolled:!!e[0],isRoot:!!e[1],defaulted:!!e[2],frozen:!!e[3],importedFromV1:!!e[4],enrolledAt:BigInt(e[5]),lastBorrowAt:BigInt(e[6]),lastRepayAt:BigInt(e[7]),sponsor:BigInt(e[8]),delegatedIn:BigInt(e[9]),delegatedOut:BigInt(e[10]),principalOut:BigInt(e[11]),activeLoans:BigInt(e[12]),premiumBps:BigInt(e[13]),premiumCap:BigInt(e[14]),loansRepaid:BigInt(e[15]),volumeRepaid:BigInt(e[16]),feesPaid:BigInt(e[17]),recourseHonored:BigInt(e[18]),childrenDefaulted:BigInt(e[19]),qualifiedRepaid:BigInt(e[20]),dollarSecondsRepaid:BigInt(e[21])}}function Ce(e,i){return{loanId:e,agentId:BigInt(i[0]),sponsorId:BigInt(i[1]),principal:BigInt(i[2]),fee:BigInt(i[3]),sponsorCut:BigInt(i[4]),reserveCut:BigInt(i[5]),premium:BigInt(i[6]),owner:B(String(i[7])),issuedAt:BigInt(i[8]),dueAt:BigInt(i[9]),defaultableAt:BigInt(i[10]),minScoreTerm:BigInt(i[11]),closedAt:BigInt(i[12]),status:Number(i[13])}}async function _e(e,i){let g=e.clientFor($),u=await g.getBlockNumber({cacheTime:0}),f=await g.readContract({address:c.registry,abi:_t,functionName:"balanceOf",args:[i],blockNumber:u});if(f===0n)return[];if(typeof f!="bigint"||f<0n)throw new a("Registry balance is unavailable. Retry or provide an explicit agentId.");let R=[],A=new Set,L=u;for(;;){let H=L>9999999n?L-9999999n:0n,ne=await g.getLogs({address:c.registry,event:Xt("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:i},fromBlock:H,toBlock:L,strict:!0});for(let O of ne){let J=O.args.tokenId;if(O.removed||A.has(J))continue;if(A.add(J),(await De(e,J,u)).toLowerCase()===i.toLowerCase()&&R.push(J),BigInt(R.length)===f)return R.sort((Z,se)=>Z<se?-1:Z>se?1:0)}if(H===0n)throw new a("Owned identities could not all be located. Retry or provide an explicit agentId.");L=H-1n}}async function Re(e,i,g){if(i.agentId!==void 0&&i.agentId!==null&&String(i.agentId).trim()!=="")return pe(i.agentId,"agentId");let u=await _e(e,g);if(u.length===0)throw new a(`Priors borrowing needs an ERC-8004 agent identity with a Priors credit line, and this wallet owns no identity. ${Ze}`);return u[0]}async function ze(e,i,g){let u=e.clientFor($),f=await De(e,i),[R,A]=await Promise.all([u.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[i]}),u.readContract({address:c.pool,abi:S,functionName:"isController",args:[i,g]})]),L=B(R);if(!A)throw new a(`Wallet ${g} is not an on-chain controller for ERC-8004 agent ${i} (ownerOf=${f}, delegateOf=${L}). An off-chain /api/check paymentWallet match alone does not grant CreditPoolV2 control.`);return{owner:f,delegate:L}}function sn(e,i){if(!i.enrolled||i.isRoot||i.sponsor===0n)throw new a(`ERC-8004 agent ${e} has no sponsor-backed Priors credit line on CreditPoolV2 yet (enrolled=${i.enrolled}, sponsor=${i.sponsor}, isRoot=${i.isRoot}). For an agent with no Priors record, priors_starter_line opens Priors' 5 USDG treasury line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent), then borrow.`);if(i.defaulted||i.frozen)throw new a(`ERC-8004 agent ${e} is not eligible to borrow on CreditPoolV2 (defaulted=${i.defaulted}, frozen=${i.frozen}).`);let g=i.delegatedIn>i.principalOut?i.delegatedIn-i.principalOut:0n;if(g<=0n)throw new a(`ERC-8004 agent ${e} has 0 USDG remaining credit capacity (delegatedIn=${i.delegatedIn}, principalOut=${i.principalOut}).`);return g}function an(e){let i=e.borrowReceiptLogs??(Y(e.borrowReceipt)?e.borrowReceipt.logs:void 0);if(!Array.isArray(i))return[];let g=[];for(let u of i)Y(u)&&(typeof u.address!="string"||!Array.isArray(u.topics)||typeof u.data!="string"||g.push({address:u.address,topics:u.topics,data:u.data}));return g}var Je="0x0000000000000000000000000000000000000000",ue=()=>Math.floor(Date.now()/1e3),G=e=>new Date(Number(e)*1e3).toISOString(),V=(e,i)=>e.toLowerCase()===i.toLowerCase();function ye(e){let i=(g,u)=>Array.isArray(e)?e[u]:e[g];return{depositor:B(String(i("depositor",0))),at:BigInt(i("at",1)),amount:BigInt(i("amount",2))}}async function he(e,i,g){let u=e.clientFor($),f=await u.getBlockNumber({cacheTime:0}),[R,A,L,H,ne,O,J,ge,Z,se,Te]=await Promise.all([De(e,i,f),u.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"firstLined",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"agentId",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"rules",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"epochRoom",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"bonds",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"amount",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedAfter",blockNumber:f}),u.readContract({address:c.usdg,abi:Jt,functionName:"balanceOf",args:[g],blockNumber:f})]);return{owner:R,agent:we(A),firstLined:L===!0,root:BigInt(H),firstLineAmount:BigInt(ne[1]),epochRoom:BigInt(O),bond:ye(J),bondAmount:BigInt(ge),releaseAt:BigInt(Z),unusedAfter:BigInt(se),usdg:BigInt(Te)}}function It(e,i){return e.enrolled||e.enrolledAt>0n||e.isRoot||e.defaulted||e.importedFromV1||e.loansRepaid>0n||e.sponsor!==0n||i}function Ct(e,i,g,u){let f=R=>`${e.formatAmount(R.toString(),N)} USDG`;if(i.defaulted)return"it defaulted: the pool marks it, and Priors never lends to it again";if(i.isRoot)return"it is a root: it backs other agents' lines";if(i.delegatedIn>0n){let R=i.sponsor===g?`Priors' treasury (root #${g})`:`root #${i.sponsor}`;return`it has a ${f(i.delegatedIn)} line from ${R}${i.activeLoans>0n?` with ${i.activeLoans} loan(s) open`:""}`}return`it has no line now${i.enrolledAt>0n?` (it enrolled at ${G(i.enrolledAt)})`:""}${u?`; Priors' treasury opened a line for it once, and another needs a person at ${Ge}`:""}`}async function Xe(e,i){let g;try{g=await e.http(me,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(i)})}catch(f){if(!(f instanceof tt))throw new a(`Priors' invite bot (${me}) could not be reached: ${e.plainError(f)}`);g=f.response}let u;try{u=JSON.parse(await g.text())}catch{u=void 0}if(!Y(u))throw new a(`Priors' invite bot (${me}) answered HTTP ${g.status} without a readable JSON object.`);return u}var be=e=>Ee(typeof e=="string"&&e?e:"no reason given");function dn(e,i){let g=i instanceof Rt?i.walk(L=>L instanceof Ye):void 0,u=g instanceof Ye?g.data:void 0,f=u?.args??[],R=L=>`${e.formatAmount(String(L),N)} USDG`,A=u?.errorName;switch(A){case"EpochCapReached":return`Priors' treasury has no room for a new line this week (wanted ${R(f[0])}, ${R(f[1])} left); the treasury caps new lines each week, so ask again next week.`;case"InsufficientBacking":return`Priors' treasury root lacks free backing for the line now (requested ${R(f[1])}, free ${R(f[2])}); try again later.`;case"InviteExpired":return"the invite expired; call priors_starter_line again for a new one.";case"InviteUsed":return"the invite was already used.";case"NotInvited":return`the invite's signer ${String(f[1])} is not an inviter TreasurySponsorV4 names.`;case"AlreadyLined":return"the agent is already on a treasury line.";case"OwnerDefaulted":return"a default on this wallet's Priors record stops new treasury lines.";case"BadConsent":return"the pool refused the consent (its owner, nonce or signature no longer matches); call priors_starter_line again.";case"ConsentExpired":return"the consent expired; call priors_starter_line again.";case"Paused":return"the Priors pool is paused for new risk; try again later.";case void 0:return e.plainError(i);default:return`${A}(${f.map(String).join(", ")}).`}}var ln=e=>{let i={name:"priors_lend",inputSchema:{type:"object",properties:{assets:{type:"string",pattern:"^[0-9]+$",description:'USDG deposit amount in 6-decimal base units (e.g. "1000000" for 1 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for assets: USDG base-unit integer string (e.g. "1000000" for 1 USDG).'},receiver:{type:"string",description:"Optional share receiver address (must be the signing wallet)."},minShares:{type:"string",pattern:"^[0-9]+$",description:"Minimum pool shares in base units; defaults to simulated minted shares less slippage."},slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points for the simulated share minimum (defaults to 50)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=Pt(n,"assets","amount","USDG deposit amount");if(r<=0n)throw new a("Deposit amount must be greater than zero.");let p=n.minShares===void 0?void 0:ee(n.minShares),d=e.approval(c.usdg,c.pool,r.toString(),$);if(p===void 0){let l;try{let v=await e.clientFor($).simulateCalls({account:o,calls:[{to:d.to,data:d.data},{to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,0n]})}]}),[P,_]=v.results;if(P?.status!=="success"||_?.status!=="success")throw new a("Approval or deposit simulation failed.");l=zt({abi:S,functionName:"deposit",data:_.data})}catch(v){throw new a(`Could not simulate Priors deposit shares: ${e.plainError(v)}`)}if(p=ee(it(l.toString(),n.slippageBps??ot)),p===0n)throw new a("The simulated deposit cannot provide a positive minimum share amount.")}let w=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,p]}),value:"0",chainId:$,description:`Deposit ${r} USDG base units into Priors CreditPoolV2 (${c.pool}) for ${t}.`}),b=[d,w],m=await e.preview(b,o),I=`Approve ${e.formatAmount(r.toString(),N)} USDG and deposit into Priors CreditPoolV2 (${c.pool}) for ${t} (minShares=${p}; 7-day MIN_HOLD applies a 0.5% early-exit fee on early withdrawals).`;return{txs:b,summary:te(e,I,m.changes)}}},g={name:"priors_withdraw",inputSchema:{type:"object",properties:{shares:{type:"string",pattern:"^[0-9]+$",description:"Pool share count in base units to redeem (not USDG amount; omit to redeem full wallet share balance)."},receiver:{type:"string",description:"Optional USDG receiver address (must be the signing wallet)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=e.clientFor($),p=n.shares!==void 0?ee(n.shares):await r.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]});if(p<=0n)throw new a(`Wallet ${o} has no Priors CreditPoolV2 shares to withdraw.`);let[d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[p]}),r.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),r.getBlock()]),m=w>0n&&b.timestamp<w+He,h=m?d*wt/yt:0n,I=d-h,v=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"withdraw",args:[p,t]}),value:"0",chainId:$,description:`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t}.`})],P=await e.preview(v,o),_=e.formatAmount(I.toString(),N),F=e.formatAmount(d.toString(),N),k=e.formatAmount(h.toString(),N),D=m?`inside 7-day MIN_HOLD: ${k} USDG (0.5%) early-exit fee stays in pool, net payout ${_} USDG from ${F} USDG gross`:`outside 7-day MIN_HOLD: no early-exit fee, net payout ${_} USDG`,M=`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t} (${D}).`;return{txs:v,summary:te(e,M,P.changes)}}},u={name:"priors_borrow",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID with an already-funded Priors credit line."},principal:{type:"string",pattern:"^[0-9]+$",description:'Borrow principal in 6-decimal USDG base units (min "5000000" = 5 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for principal: USDG base-unit integer string (e.g. "5000000" for 5 USDG).'},term:{type:"string",description:'Loan term in seconds (between 86400 and 2592000; defaults to "86400"). The origination fee is pro-rated by term, so a longer term costs more.'},recipient:{type:"string",description:"Optional USDG recipient address (must be the signing wallet)."},maxFee:{type:"string",description:"Optional ceiling on the origination fee, USDG base units; must equal the pool's current quote for this principal and term. Omit to use that quote. The fee is pro-rated by term, not flat: 1666 for 5 USDG over 1 day on the first live run (2026-10-31)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.recipient!==void 0&&(typeof n.recipient!="string"||n.recipient.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors recipient must be the signing wallet.");let r=await Re(e,n,o);await ze(e,r,o);let p=e.clientFor($),d=await p.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[r]}),w=we(d),b=sn(r,w),m=Pt(n,"principal","amount","USDG borrow principal");if(m<We||m>$t)throw new a(`Borrow principal must be between ${We} (5 USDG) and ${$t} (500 USDG) base units.`);if(m>b)throw new a(`Borrow principal ${m} exceeds available credit line capacity ${b} USDG base units for agent ${r}.`);let h=n.term!==void 0&&String(n.term).trim()!==""?pe(n.term,"term"):je;if(h<je||h>St)throw new a(`Loan term must be between ${je} (1 day) and ${St} (30 days) seconds.`);let I=await p.readContract({address:c.pool,abi:S,functionName:"quoteFee",args:[r,m,h]}),l=I[0],v=n.maxFee!==void 0?ee(n.maxFee):l;if(v<l)throw new a(`Provided maxFee ${v} is below the origination fee the pool quotes for this term, ${l} USDG base units.`);if(v>l)throw new a(`Provided maxFee ${v} is above the quoted origination fee ${l} USDG base units. Use the quoted fee or omit maxFee.`);let P=m+l,_=m+v,k=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"borrow",args:[r,m,h,t,v]}),value:"0",chainId:$,description:`Borrow ${m} USDG base units on Priors CreditPoolV2 for agent ${r} to ${t} (quoted fee ${l}, expected debt ${P}, maxFee ${v}, debt ceiling ${_}).`})],D=await e.preview(k,o),M=e.formatAmount(m.toString(),N),W=e.formatAmount(l.toString(),N),ae=e.formatAmount(P.toString(),N),j=e.formatAmount(v.toString(),N),$e=e.formatAmount(_.toString(),N),q=I[1]+I[3],K=I[2],de=l-q-K,oe=`Borrow ${M} USDG for ERC-8004 agent ${r} to recipient ${t} on Priors CreditPoolV2 (${c.pool}) for ${h}s: expected origination fee ${W} USDG (${l} base units; pro-rated by term, set when the loan opens, none refunded on early repayment), expected total repayment due ${ae} USDG (${P} base units); fee ceiling ${j} USDG (${v} base units), debt ceiling ${$e} USDG (${_} base units). Fee recipient on repayment: CreditPoolV2 (${c.pool}), allocating the quoted fee to sponsor ${w.sponsor} (${q} base units including premium), reserve (${K} base units), and lenders (${de} base units).`;return{txs:k,summary:te(e,oe,D.changes)}}},f={name:"priors_repay",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID that owns the active loan."},loanId:{type:"string",description:"Optional explicit per-agent loan ID (otherwise recovered from Borrowed receipt logs or loansOf(agentId))."},borrowReceiptLogs:{type:"array",description:"Optional receipt logs array from the borrow transaction to decode the exact Borrowed(loanId, agentId, ...) event."},maxDue:{type:"string",description:"Optional maximum USDG base units to repay; must equal the exact fixed principal + fee. Omit to use that debt."}}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),p;if(n.loanId!==void 0&&n.loanId!==null&&String(n.loanId).trim()!=="")p=pe(n.loanId,"loanId");else{let k=an(n);if(k.length>0){let D=rn(k,t);D!==null&&(p=BigInt(D))}}let d;if(p!==void 0){let k=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[p]}),D=Ce(p,k);if(D.agentId!==t)throw new a(`Loan ${p} belongs to agent ${D.agentId}, not agent ${t}. Recover loan IDs from the Borrowed receipt or loansOf(agentId), never global loanCount().`);if(D.status!==1)throw new a(`Loan ${p} for agent ${t} is not active (status=${D.status}).`);d=D}else{let k=await r.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[t]});if(k.length===0)throw new a(`ERC-8004 agent ${t} has no recorded loans on Priors CreditPoolV2.`);let M=(await Promise.all(k.map(async W=>{let ae=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[W]});return Ce(W,ae)}))).filter(W=>W.agentId===t&&W.status===1);if(M.length===0)throw new a(`ERC-8004 agent ${t} has no active loans to repay.`);d=M[M.length-1]}let w=d.principal+d.fee,b=n.maxDue!==void 0?ee(n.maxDue):w;if(b<w)throw new a(`Provided maxDue ${b} is below the exact fixed loan debt ${w} USDG base units (principal ${d.principal} + fixed fee ${d.fee}).`);if(b>w)throw new a(`Provided maxDue ${b} is above the exact fixed loan debt ${w} USDG base units. Use the fixed debt or omit maxDue.`);let m=e.approval(c.usdg,c.pool,w.toString(),$),h=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"repay",args:[d.loanId,t,b]}),value:"0",chainId:$,description:`Repay fixed debt ${w} USDG base units (principal ${d.principal} + fee ${d.fee}) for loan ${d.loanId} (agent ${t}).`}),I=[m,h],l=await e.preview(I,o),v=e.formatAmount(w.toString(),N),P=e.formatAmount(d.principal.toString(),N),_=e.formatAmount(d.fee.toString(),N),F=`Approve and repay ${v} USDG (${w} base units: ${P} USDG principal + ${_} USDG fixed fee) for Priors loan ${d.loanId} (agent ${t}).`;return{txs:I,summary:te(e,F,l.changes)}}},R={name:"priors_status",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Optional ERC-8004 agent ID to inspect on CreditPoolV2, PriorsLens, and StockVault."},includeApiCheck:{type:"boolean",description:"Optional flag to query https://priors.trade/api/check for supplemental off-chain metadata."}}},async execute(n,s){z(s);let o=B(s),t=e.clientFor($),[r,p,d,w]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]}),t.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),t.getBlock(),t.readContract({address:c.stockVault,abi:vt,functionName:"assetList"})]),b=r>0n?await t.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[r]}):0n,m=r>0n&&p>0n&&d.timestamp<p+He,h=m?b*wt/yt:0n,I=b-h,l=null;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")l=pe(n.agentId,"agentId");else{let q=await _e(e,o);q.length>0&&(l=q[0])}let v=null,P=!1,_=[],F=null,k=null,D=null,M=null,W=null,ae=null,j=`This wallet owns no ERC-8004 agent identity. ${Ze}`;if(l!==null){let[q,K,de,oe,Ot,Ut,Be,Ne,Le]=await Promise.all([t.readContract({address:c.lens,abi:At,functionName:"score",args:[l]}),t.readContract({address:x,abi:E,functionName:"firstLined",args:[l]}),t.readContract({address:x,abi:E,functionName:"agentId"}),t.readContract({address:x,abi:E,functionName:"rules"}),t.readContract({address:x,abi:E,functionName:"epochRoom"}),t.readContract({address:C,abi:U,functionName:"bonds",args:[l]}),t.readContract({address:C,abi:U,functionName:"amount"}),t.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[l]}),t.readContract({address:C,abi:U,functionName:"releasable",args:[l]})]),[Et,Gt,Vt,Ft,Mt,qt]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[l]}),t.readContract({address:c.lens,abi:At,functionName:"available",args:[l]}),t.readContract({address:c.stockVault,abi:vt,functionName:"borrowRoom",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"isController",args:[l,o]})]),xe=await De(e,l),Ht=B(Mt),Ke=qt,y=we(Et),Se=y.delegatedIn>y.principalOut?y.delegatedIn-y.principalOut:0n;P=y.enrolled&&!y.isRoot&&!y.defaulted&&!y.frozen&&y.sponsor>0n&&y.delegatedIn>0n,F=Vt.toString(),k=Ft.toString();let Wt=await Promise.all(Gt.map(async T=>{let le=await t.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[T]});return Ce(T,le)}));for(let T of Wt)if(T.agentId===l&&T.status===1){let le=T.principal+T.fee;_.push({loanId:T.loanId.toString(),agentId:T.agentId.toString(),sponsorId:T.sponsorId.toString(),principal:T.principal.toString(),fee:T.fee.toString(),due:le.toString(),dueAt:T.dueAt.toString(),issuedAt:T.issuedAt.toString(),owner:T.owner,token:re})}v={agentId:l.toString(),owner:xe,delegate:Ht,isAuthorizedController:Ke,enrolled:y.enrolled,isRoot:y.isRoot,defaulted:y.defaulted,frozen:y.frozen,sponsorId:y.sponsor.toString(),delegatedIn:y.delegatedIn.toString(),delegatedOut:y.delegatedOut.toString(),principalOut:y.principalOut.toString(),availableCapacity:Se.toString(),activeLoansCount:y.activeLoans.toString(),loansRepaid:y.loansRepaid.toString(),volumeRepaid:y.volumeRepaid.toString(),feesPaid:y.feesPaid.toString(),importedFromV1:y.importedFromV1,qualifiedRepaid:y.qualifiedRepaid.toString(),dollarSecondsRepaid:y.dollarSecondsRepaid.toString()};let Ae=BigInt(de),Oe=K===!0,Q=ye(Ut),ie=Q.depositor!==Je,ve=ie&&V(Q.depositor,o),Qe=It(y,Oe),Ue=V(xe,o);D={onchain:BigInt(q).toString(),scale:"0-1000",source:`CreditLensV2.score(${l}) at ${c.lens}, the score the pool computes on chain`,scoreV2:null},M={open:y.sponsor!==0n&&y.delegatedIn>0n,amount:y.delegatedIn.toString(),drawn:y.principalOut.toString(),available:Se.toString(),sponsorId:y.sponsor.toString(),backer:y.sponsor===0n?null:y.sponsor===Ae?`Priors' treasury v4 (root #${Ae})`:`root #${y.sponsor}`,token:re},W={contract:C,posted:ie,depositor:ie?Q.depositor:null,postedByWallet:ve,postedAt:ie?Q.at.toString():null,amount:(ie?Q.amount:BigInt(Be)).toString(),releasable:ie&&Le===!0,releaseAt:ie?BigInt(Ne).toString():null,rule:"Back to its depositor once the agent holds no line and has no loan open, from 4 days after it was posted (close a line first with priors_close_line); a default forfeits it to Priors' Safe."},ae={eligible:Ue&&!Qe,firstLined:Oe,lineAmount:BigInt(oe[1]).toString(),bondAmount:BigInt(Be).toString(),treasuryRoot:Ae.toString(),treasuryRoomThisWeek:BigInt(Ot).toString(),note:"Not instant: Priors' invite bot decides each invite, and the treasury caps new lines each week."};let fe=_.map(T=>({id:String(T.loanId),dueAt:BigInt(String(T.dueAt))})).sort((T,le)=>T.dueAt<le.dueAt?-1:T.dueAt>le.dueAt?1:0);y.defaulted?j=`Agent #${l} defaulted; Priors never lends to it again${ve?" and its bond is forfeited":""}.`:!Ke&&!Ue?j=`This wallet does not control agent #${l} on CreditPoolV2 (owner ${xe}); act from its owner or delegate.`:fe.length?j=`Repay loan ${fe[0].id} with priors_repay before it is due at ${G(fe[0].dueAt)}${fe.length>1?` (${fe.length} loans open)`:""}.`:P&&Se>=We?j=`Borrow with priors_borrow (5 USDG minimum, up to ${A(Se)}; the fee is pro-rated by term); Priors counts loans held 7 days or more toward the score.`:!Qe&&Ue?j=ve?`Call priors_starter_line again: the ${A(Q.amount)} bond is posted, and it goes on with the invite bot's ownership proof and the invite's redemption${Le===!0?", or priors_release_bond returns the bond":""}.`:`Call priors_starter_line: a refundable ${A(BigInt(Be))} bond, an invite from Priors' invite bot and your pool consent open a ${A(BigInt(oe[1]))} line from Priors' treasury (each transaction and signature is confirmed).`:ve?j=Le===!0?`Release the ${A(Q.amount)} invite bond with priors_release_bond.`:y.delegatedIn>0n?`The line is open with nothing to draw; to take the bond back, close it with priors_close_line, then priors_release_bond from ${G(BigInt(Ne))}.`:`The ${A(Q.amount)} invite bond comes back with priors_release_bond from ${G(BigInt(Ne))}.`:j=`Agent #${l} has a Priors record but no line to draw now; ${Ct(e,y,Ae,Oe)}.`}let $e=null;if(n.includeApiCheck){let q=l!==null?`agent=${l.toString()}`:`address=${o}`,K=await nt(e.http,`${Qt}?${q}`,{method:"GET"},Y),de=Array.isArray(K.agents)?K.agents.find(oe=>Y(oe)&&String(oe.agentId)===String(l)):void 0;D&&Y(de)&&(D.scoreV2=de.scoreV2??null),$e={...K,grantsPoolControl:!1,controlRule:"Off-chain /api/check identity or paymentWallet match never grants CreditPoolV2 control; on-chain isController(agentId, wallet) must authorize the caller; stale delegates do not qualify."}}return{chainId:$,blockNumber:d.number?.toString()??null,blockTimestamp:d.timestamp.toString(),wallet:o,token:re,contracts:c,lender:{shares:r.toString(),grossAssets:b.toString(),earlyExitFeeAssets:h.toString(),netWithdrawAssets:I.toString(),lastDepositAt:p.toString(),withinMinHoldWindow:m,minHoldSeconds:He.toString()},hasFundedLine:P,agentId:l!==null?l.toString():null,nextStep:j,score:D,line:M,bond:W,starterLine:ae,agent:v,activeLoans:_,lens:{address:c.lens,available:F,caveat:"PriorsLens.available(agentId) is a status capacity hint for already-funded lines; backer hooks may still refuse borrows."},stockVault:{address:c.stockVault,borrowRoom:k,onchainAssetCount:w.length,hostedMcpStockCount:35,extraNonStockAsset:B(en),zeroCapAssets:tn.map(q=>B(q)),caveat:"Use priors_stock_assets and priors_stock_asset_state for current collateral rules, then priors_stock_open. This summary is an observed asset-count snapshot, not a fixed allowlist; live caps, lending holds and prices control admission."},apiCheck:$e,limitations:["Borrowing and repayment require a sponsor-backed ERC-8004 credit line (enrolled && !isRoot && sponsor != 0) authorized on-chain by isController(agentId, wallet).","Priors line routes are exposed by priors_line_options and priors_capabilities: treasury starter, V5 move/raise, direct sponsor, stock and owner PRIORS backing. Ethos execution uses Priors own owner workflow because its worker supplies no unsigned final transaction.","score.onchain is the pool's on-chain score (CreditLensV2); score.scoreV2 is Priors Score v2 from /api/check, present only with includeApiCheck.","Loan debt is the principal plus the origination fee the pool quotes for the term. The fee is pro-rated by term, not flat (1666 base units for 5 USDG over 1 day, observed live 2026-10-31; priors_borrow shows the exact quote), and is fixed once the loan opens: variable interest is never invented, and early repayment refunds none of it.","Loan IDs are recovered from decoded Borrowed receipts or per-agent loansOf(agentId), never global loanCount().","Historical archive event queries and zero-position StockVault lines on public RPCs remain subject to archive retention and live backer state."]}}},A=n=>`${e.formatAmount(n.toString(),N)} USDG`;function L(n){let s=V(n.bond.depositor,n.owner)&&n.bond.amount>0n?n.bond.amount:n.bondAmount;return`Bond first: ${A(s)} is locked in Priors' InviteBond for at least ${n.unusedAfter} seconds (${Number(n.unusedAfter)/86400} days) after posting${n.releaseAt>0n?`; unusedReleaseAt is ${G(n.releaseAt)}`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments. `}function H(n,s,o){if(!V(o.owner,s))throw new a(`This wallet (${s}) does not own ERC-8004 agent ${n} (its owner is ${o.owner}). The bond, the ownership proof and the pool consent are the owner's. Nothing was signed.`);if(o.root!==Ie)throw new a(`TreasurySponsorV4 (${x}) answers root #${o.root}, not the pinned #${Ie}. Nothing was signed; update Oak.`);if(It(o.agent,o.firstLined))throw new a(`Agent #${n} already has a Priors record, so priors_starter_line posts no bond and signs nothing: ${Ct(e,o.agent,o.root,o.firstLined)}; ${o.agent.loansRepaid} loan(s) repaid. The starter line is only for an identity with no record; priors_status shows this one.`)}let ne="stays posted in InviteBond";function O(n){let s=n.agent.delegatedIn>0n?`with a line open it comes back only after priors_close_line (no loan open), then priors_release_bond from ${G(n.releaseAt)} at the earliest`:`while the agent holds no line it comes back with priors_release_bond from ${G(n.releaseAt)} (${Number(n.unusedAfter)/86400} days after it was posted)`;return`The ${A(n.bond.amount>0n?n.bond.amount:n.bondAmount)} bond ${ne} (${C}), posted from this wallet; ${s}, and priors_starter_line never posts a second bond.`}async function J(n,s,o){try{return await o()}catch(t){let r=t instanceof a?t.message:e.plainError(t);if(r.includes(ne)||n===void 0||!/^[0-9]{1,78}$/.test(n))throw t;let p;try{let d=await he(e,BigInt(n),s);p=V(d.bond.depositor,s)?O(d):""}catch{p=`If the bond transactions mined, the invite bond ${ne} (${C}) remains locked until its on-chain release conditions are met; priors_status shows the exact amount and time (its state could not be read just now).`}throw p?new a(`${r} ${p}`):t}}async function ge(n,s,o){let t=dt(await Xe(e,{agentId:n}),{agentId:n,owner:s,now:ue()});if(!t.ok&&t.refused)throw new a(`Priors' invite bot gave no ownership proof to sign for agent #${n}: ${be(t.why)}. Nothing was signed. ${o}`.trim());if(!t.ok)throw new a(`Not signed: the invite bot's answer for agent #${n} is not one Oak signs: ${t.why}. Oak signs only the bot's own start-page text, rebuilt locally for this agent and this wallet. ${o}`.trim());if(t.exp-ue()<120)throw new a(`Not signed: the invite bot's proof for agent #${n} expires in under 2 minutes; call priors_starter_line again for a new one. ${o}`.trim());return t}function Z(n,s,o,t){return{steps:[{kind:"message",message:o.message}],continuation:{stage:"proof",wallet:s,chainId:$,agentId:n,n:o.n,exp:o.exp},summary:`${L(t)}Priors starter line for ERC-8004 agent ${n}, step 2 of 3: sign Priors' invite-bot ownership proof. It is a message signature (EIP-191) only: it sends no transaction and moves no funds. The text is the bot's own form, rebuilt locally for agent #${n} and this wallet, request ${o.n}, expiring ${G(o.exp)}. Oak then sends the signature to ${me}, and the bot decides the invite. ${O(t)}`}}function se(n,s,o){if(n.chainId!==$||typeof n.wallet!="string"||!V(n.wallet,s)||typeof n.agentId!="string"||!/^[1-9][0-9]{0,29}$/.test(n.agentId))throw new a("Priors starter-line continuation does not match this wallet or chain 4663; start priors_starter_line again.");if(o.agentId!==void 0&&String(o.agentId)!==n.agentId)throw new a("Priors starter-line continuation is for another agent; start priors_starter_line again.");return BigInt(n.agentId)}async function Te(n,s){let o;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")o=pe(n.agentId,"agentId");else{let l=await _e(e,s);if(!l.length)throw new a(`Priors' starter line needs an ERC-8004 agent identity, and this wallet owns none. ${Ze}`);o=l[0]}let t=await he(e,o,s);H(o,s,t);let r=o.toString(),p=V(t.bond.depositor,s);if(!p){if(t.usdg<t.bondAmount)throw new a(`This wallet holds ${A(t.usdg)} on Robinhood Chain, and Priors' treasury invite asks a ${A(t.bondAmount)} bond first (InviteBond ${C}), posted from this wallet. Nothing was signed: add USDG, then call priors_starter_line again.`);if(t.epochRoom<t.firstLineAmount)return{summary:`${L(t)}Not submitted. Priors' treasury has ${A(t.epochRoom)} of room left this week and a first line is ${A(t.firstLineAmount)}, so priors_starter_line posted no bond and signed nothing. The treasury caps new lines each week: ask again next week.`,starterLine:{agentId:r,open:!1,reason:"room",epochRoom:t.epochRoom.toString()}};let l=await Xe(e,{check:!0,owner:s.toLowerCase()});if(l.check!==!0)throw new a("Priors' invite bot did not answer its check, so whether an invite is open cannot be told. Nothing was signed.");if(l.ok!==!0)throw new a(`Whether an automatic invite is open could not be told: Priors' invite bot says ${be(l.error)}. Nothing was signed; try again later.`);if(l.open!==!0){let v=typeof l.reason=="string"?l.reason.replace(/[^a-z-]/g,"").slice(0,24):"",P=typeof l.reopensAt=="number"&&Number.isSafeInteger(l.reopensAt)&&l.reopensAt>0?l.reopensAt:null;return{summary:`${L(t)}Not submitted. No automatic invite is open to this wallet right now, so priors_starter_line posted no bond and signed nothing. Priors' invite bot answers: closed, reason ${Ee(v||"none given")}${P?`, reopens ${G(P)}`:""}. ${lt({...l,reason:v})} Priors lists its other ways to a first line (the Ethos lane, a stock line, the owner's $PRIORS stake) at https://priors.trade/skill.md.`,starterLine:{agentId:r,open:!1,reason:v||null,reopensAt:P}}}}let d=await ge(r,s,p?O(t):"");if(p)return Z(r,s,d,t);let w=[e.approval(c.usdg,C,t.bondAmount.toString(),$),e.unsignedTx({to:C,data:X({abi:U,functionName:"deposit",args:[o]}),value:"0",chainId:$,description:`Post the ${t.bondAmount} USDG base-unit Priors invite bond for agent ${r} in InviteBond (${C}).`})],b=await e.preview(w,s),m=t.bond.depositor!==Je?` This deposit replaces the bond ${t.bond.depositor} posted for this agent; InviteBond returns that bond to it in the same transaction.`:"",h=`${L(t)}Priors starter line for ERC-8004 agent ${r}, step 1 of 3: approve exactly ${A(t.bondAmount)} to Priors' InviteBond (${C}) and post it as the agent's refundable invite bond (InviteBond.deposit).${m} Priors' invite bot says an automatic invite is open now and gave the ownership proof to sign next. Step 2 signs that proof (a message, no transaction); step 3 signs your pool consent and redeems the invite (TreasurySponsorV4.firstLine, ${x}) for a ${A(t.firstLineAmount)} line from Priors' treasury (root #${t.root}). The invite is the bot's decision, not a promise: if it refuses, or any later step fails, the bond stays posted and comes back with priors_release_bond after the on-chain lock and release conditions are met. With a line, the bond comes back only once the line is closed with no loan open (priors_close_line, then priors_release_bond); a default forfeits it to Priors' Safe.`;return{steps:w.map(l=>({kind:"tx",tx:l})),continuation:{stage:"bond",wallet:s,chainId:$,agentId:r,n:d.n,exp:d.exp},summary:te(e,h,b.changes)}}async function kt(n,s,o){let t=await he(e,n,s);H(n,s,t);let r=n.toString();if(!V(t.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet, so nothing more was signed. Check the deposit transaction, then call priors_starter_line again.`);return typeof o.n=="string"&&Ve.test(o.n)&&typeof o.exp=="number"&&Number.isSafeInteger(o.exp)&&o.exp-ue()>=300?Z(r,s,{n:o.n,exp:o.exp,message:Me(r,o.n,o.exp)},t):Z(r,s,await ge(r,s,O(t)),t)}async function Dt(n,s,o,t){let r=n.toString();if(typeof o.n!="string"||!Ve.test(o.n)||typeof o.exp!="number"||!Number.isSafeInteger(o.exp))throw new a("Invalid Priors starter-line proof continuation; start priors_starter_line again.");if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the invite bot's ownership proof.");if(o.exp<=ue())throw new a(`The invite bot's proof for agent #${r} expired before it reached the bot; nothing was sent to it. Call priors_starter_line again for a fresh proof (the bond is not posted again).`);let p=Me(r,o.n,o.exp);if(!V(await Zt({message:p,signature:t}),s))throw new a("The ownership-proof signature is not this wallet's; nothing was sent to the invite bot.");let d=await he(e,n,s);if(H(n,s,d),!V(d.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet; nothing was sent to the invite bot. Call priors_starter_line again.`);let w=await Xe(e,{n:o.n,signature:t});if(w.ok!==!0)throw new a(`Priors' invite bot gave no invite for agent #${r}: ${be(w.error)}. ${O(d)}`);if(typeof w.code!="string")throw new a(`Priors' invite bot gave no invite for agent #${r}${w.reason?`: ${be(w.reason)}`:""}${typeof w.decided=="string"?` (its decision: ${be(w.decided)})`:""}. ${O(d)}`);let b=qe(w.code,r,ue()+60);if(!b.ok)throw new a(`Priors' invite bot's code for agent #${r} is not one Oak redeems: ${b.why}. Nothing more was signed. ${O(d)}`);let m=e.clientFor($),h=await m.readContract({address:x,abi:E,functionName:"inviteDigest",args:[n,b.expiry]});if(h.toLowerCase()!==at(n,b.expiry).toLowerCase())throw new a("TreasurySponsorV4's invite digest differs from its pinned EIP-712 domain; nothing more was signed. Update Oak.");let I=await Yt({hash:h,signature:b.signature}),[l,v]=await Promise.all([m.readContract({address:x,abi:E,functionName:"inviters",args:[I]}),m.readContract({address:x,abi:E,functionName:"inviteUsed",args:[h]})]);if(l!==!0)throw new a(`Priors' invite for agent #${r} was signed by ${I}, which TreasurySponsorV4 does not name an inviter, so the treasury would refuse it. Nothing more was signed. ${O(d)}`);if(v===!0)throw new a(`Priors' invite for agent #${r} was already used. Nothing more was signed. ${O(d)}`);let[P,_]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]),F=_.timestamp+BigInt(rt),k=Fe({agentId:r,owner:s,nonce:P.toString(),deadline:F.toString()}),D=await m.readContract({address:c.pool,abi:S,functionName:"consentDigest",args:[{agentId:n,sponsorId:d.root,owner:s,maxPremiumBps:0n,nonce:P,deadline:F}]});if(D.toLowerCase()!==st(k).toLowerCase())throw new a(`The pool's consentDigest (${D}) differs from the consent Oak builds for CreditPoolV2 (${c.pool}), so the pool would refuse it. Nothing more was signed. ${O(d)}`);return{steps:[{kind:"typedData",request:k}],continuation:{stage:"consent",wallet:s,chainId:$,agentId:r,invite:w.code,request:k},summary:`Priors starter line for ERC-8004 agent ${r}, step 3 of 3: Priors' invite bot gave an invite (signed by ${I}, an inviter TreasurySponsorV4 names; it expires ${G(b.expiry)}). Sign your pool consent (EIP-712 "Priors Credit" version 2 on CreditPoolV2 ${c.pool}): it lets Priors' treasury (root #${d.root}) back a line for agent #${r} with premium 0, nonce ${P}, valid until ${G(F)}. A transaction redeeming the invite (TreasurySponsorV4.firstLine) follows for your confirmation. ${O(d)}`}}async function Tt(n,s,o,t){let r=n.toString();if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the Priors pool consent.");let p=qe(o.invite,r,ue()+60);if(!p.ok)throw new a(`The invite for agent #${r} is not one Oak redeems now: ${p.why}. Call priors_starter_line again for a new one.`);let d=Y(o.request)&&Y(o.request.message)?o.request.message:void 0;if(!d||typeof d.nonce!="string"||!/^[0-9]{1,78}$/.test(d.nonce)||typeof d.deadline!="string"||!/^[0-9]{1,20}$/.test(d.deadline))throw new a("Invalid Priors starter-line consent continuation; start priors_starter_line again.");let w=Fe({agentId:r,owner:s,nonce:d.nonce,deadline:d.deadline});if(!V(await Kt({...w,signature:t}),s))throw new a("The pool-consent signature is not this wallet's for the consent Oak built; nothing was offered.");let b=await he(e,n,s);H(n,s,b);let m=e.clientFor($),[h,I]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]);if(h.toString()!==d.nonce)throw new a(`Agent #${r}'s consent nonce moved on chain since it was signed; nothing was offered. Call priors_starter_line again.`);if(I.timestamp>=BigInt(d.deadline))throw new a(`The pool consent for agent #${r} expired at ${G(BigInt(d.deadline))}; nothing was offered. Call priors_starter_line again.`);let l={agentId:n,sponsorId:Ie,owner:s,maxPremiumBps:0n,nonce:h,deadline:BigInt(d.deadline)},v=[n,p.expiry,p.signature,l,t];try{await m.simulateContract({address:x,abi:E,functionName:"firstLine",args:v,account:s})}catch(k){throw new a(`TreasurySponsorV4.firstLine for agent #${r} would be refused: ${dn(e,k)} Nothing was offered. ${O(b)}`)}let P=e.unsignedTx({to:x,data:X({abi:E,functionName:"firstLine",args:v}),value:"0",chainId:$,description:`Redeem Priors' invite for agent ${r}: TreasurySponsorV4.firstLine opens a ${b.firstLineAmount} USDG base-unit line from root ${b.root} with the owner's consent.`}),_=await e.preview([P],s),F=`Redeem agent #${r}'s Priors invite: TreasurySponsorV4.firstLine (${x}) opens a ${A(b.firstLineAmount)} line from Priors' treasury (root #${b.root}) with your signed consent. No USDG moves in this transaction. Then priors_status shows the line and priors_borrow draws it (5 USDG minimum; the fee is pro-rated by term; Priors counts loans held 7 days or more toward the score). The ${A(b.bondAmount)} bond stays in InviteBond until the line is closed with no loan open (priors_close_line, then priors_release_bond, from ${G(b.releaseAt)} at the earliest); a default forfeits it.`;return{txs:[P],summary:te(e,F,_.changes)}}let Bt={name:"priors_starter_line",inputSchema:{description:"Bond first: the launch bond is 5 USDG, locked at least 4 days. The first result reads amount(), unusedAfter() and unusedReleaseAt(agentId) for current terms before any approval. Invites are not guaranteed; the credit score can lag. Release needs no line or open loan; default can forfeit the bond.",type:"object",additionalProperties:!1,properties:{agentId:Pe("ERC-8004 agent ID this wallet owns, with no Priors record yet (default: the first identity this wallet owns)."),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}}},async execute(n,s){z(s);let o=B(s);if(n.continuation===void 0){if(n.signature!==void 0)throw new a("A signature needs its Priors starter-line continuation; start priors_starter_line again.");return J(typeof n.agentId=="string"?n.agentId:void 0,o,()=>Te(n,o))}if(!Y(n.continuation))throw new a("Invalid Priors starter-line continuation; start priors_starter_line again.");let t=n.continuation,r=se(t,o,n),p=d=>J(r.toString(),o,d);if(t.stage==="bond"){if(n.signature!==void 0)throw new a("The bond stage takes no signature; start priors_starter_line again.");return p(()=>kt(r,o,t))}if(t.stage==="proof")return p(()=>Dt(r,o,t,n.signature));if(t.stage==="consent")return p(()=>Tt(r,o,t,n.signature));throw new a("Unknown Priors starter-line stage; start priors_starter_line again.")}},Nt={name:"priors_close_line",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose Priors line to close (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),[p,d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:x,abi:E,functionName:"agentId"})]),m=we(p);if(m.sponsor===0n)throw new a(`Agent #${t} has no Priors line to close (no sponsor on CreditPoolV2).`);if(m.activeLoans>0n)throw new a(`Agent #${t} has ${m.activeLoans} loan(s) open; repay them with priors_repay first. The pool's leave refuses while a loan is open.`);let h=ye(d),I=m.sponsor===BigInt(b),l=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"leave",args:[t]}),value:"0",chainId:$,description:`Close agent ${t}'s Priors line on CreditPoolV2 (leave): the ${m.delegatedIn} USDG base-unit line returns to root ${m.sponsor}.`}),v=await e.preview([l],o),P=V(h.depositor,o)?` Its ${A(h.amount)} invite bond can then come back with priors_release_bond from ${G(w)} (4 days after it was posted).`:"",_=`Close agent #${t}'s Priors line (CreditPoolV2.leave, ${c.pool}): the whole ${A(m.delegatedIn)} line goes back to its backer (${I?`Priors' treasury, root #${b}`:`root #${m.sponsor}`}) and the agent can no longer borrow on it. This does not reopen: ${I?`priors_starter_line opens no second treasury line for an agent with a Priors record; another needs a person at ${Ge}.`:"a new line needs a backer's new consent."}${P} No USDG moves in this transaction.`;return{txs:[l],summary:te(e,_,v.changes)}}},Lt={name:"priors_release_bond",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose InviteBond bond this wallet posted (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o),r=e.clientFor($),[p,d,w,b,m]=await Promise.all([r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"releasable",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.getBlock()]),h=ye(p);if(h.depositor===Je)throw new a(`Agent #${t} has no bond in Priors' InviteBond (${C}).`);if(!V(h.depositor,o))throw new a(`Agent #${t}'s InviteBond bond was posted by ${h.depositor}, not this wallet, and InviteBond.release pays the depositor. Oak releases only a bond this wallet posted.`);if(d!==!0){let P=we(b),_=P.defaulted?"the agent defaulted, so the bond is forfeited to Priors' Safe (InviteBond.slash)":P.activeLoans>0n?`the agent has ${P.activeLoans} loan(s) open: repay with priors_repay, close the line with priors_close_line, then release`:P.delegatedIn>0n?`the agent still holds a ${A(P.delegatedIn)} line: close it with priors_close_line (no loan may be open), then release`:m.timestamp<w?`it comes back 4 days after it was posted, from ${G(w)}`:"InviteBond does not release it yet";throw new a(`Agent #${t}'s ${A(h.amount)} invite bond cannot be released now: ${_}. Nothing was signed.`)}let I=e.unsignedTx({to:C,data:X({abi:U,functionName:"release",args:[t]}),value:"0",chainId:$,description:`Release agent ${t}'s ${h.amount} USDG base-unit Priors invite bond from InviteBond (${C}) to its depositor ${h.depositor}.`}),l=await e.preview([I],o),v=`Release agent #${t}'s ${A(h.amount)} invite bond from Priors' InviteBond (${C}): InviteBond.release returns it to its depositor, this wallet (${o}).`;return{txs:[I],summary:te(e,v,l.changes)}}};async function xt(n){z(n);let s=B(n),o=e.clientFor($),[t,r]=await Promise.all([o.readContract({address:c.pool,abi:S,functionName:"shares",args:[s]}),_e(e,s)]),p=[];if(t>0n){let d=await o.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[t]});p.push({module:"priors",id:`priors:lender:${s.toLowerCase()}`,chainId:$,assets:[{token:re,amount:d.toString()}],description:`Priors CreditPoolV2 lender position (${t} shares = ${e.formatAmount(d.toString(),N)} USDG gross).`})}for(let d of r){let w=await o.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[d]}),b=await Promise.all(w.map(async h=>{let I=await o.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[h]});return Ce(h,I)}));for(let h of b)if(h.agentId===d&&h.status===1){let I=h.principal+h.fee;p.push({module:"priors",id:`priors:loan:${h.loanId.toString()}`,chainId:$,assets:[{token:re,amount:I.toString()}],description:`Priors CreditPoolV2 active loan ${h.loanId} for agent ${d} (fixed due ${e.formatAmount(I.toString(),N)} USDG = ${h.principal} principal + ${h.fee} fee).`})}let m=ye(await o.readContract({address:C,abi:U,functionName:"bonds",args:[d]}));m.amount>0n&&V(m.depositor,s)&&p.push({module:"priors",id:`priors:bond:${d.toString()}`,chainId:$,assets:[{token:re,amount:m.amount.toString()}],description:`Priors invite bond for agent ${d} in InviteBond (${C}): ${A(m.amount)}, back with priors_release_bond once the agent holds no line and no loan, from 4 days after posting; a default forfeits it.`})}return p.push(...await gt(e,s,r,re)),p}return{tools:[i,g,u,f,R,Bt,Nt,Lt],positions:xt}},cn=e=>{let i=ln(e),g=[i,ct(e),ut(e),ft(e),mt(e),ht(e),bt(e),pt()];return{...i,tools:g.flatMap(u=>u.tools)}},Dn=e=>et("priors",[cn(e)]);export{Qt as a,He as b,wt as c,yt as d,We as e,$t as f,je as g,St as h,c as i,re as j,rn as k,cn as l,Dn as m};
|
|
1
|
+
import{b as bt}from"./I26DMNJG.js";import{c as ft}from"./L5BLHY34.js";import{b as mt}from"./ZSN4IRI5.js";import{b as ht}from"./QYVREJYC.js";import{b as pt}from"./Z6LZGCVW.js";import{c as ut}from"./ZXJ24B4L.js";import{b as gt}from"./WTXC3XKW.js";import{h as ct}from"./DJN3JAWB.js";import{a as C,b as x,c as Ie,d as me,e as Ge,g as rt,h as Ve,j as U,l as E,o as Fe,p as st,q as at,r as Me,s as dt,t as qe,u as lt}from"./WLMWWEP7.js";import{b as ot,o as it}from"./BOVMED7R.js";import{b as et}from"./SPJCSEKP.js";import{a as z}from"./43LI5NKJ.js";import{a as tt,c as nt}from"./VEQBHI6O.js";import{a as Pe}from"./66F5ZH34.js";import{b as ee}from"./IX3GZMTM.js";import{a as $,d as N,i as ce}from"./FWD4L3CJ.js";import{a}from"./XSD5NL7J.js";import{a as Ee}from"./JXOEJPJ4.js";import{BaseError as Rt,ContractFunctionRevertedError as Ye,decodeEventLog as jt,decodeFunctionResult as zt,encodeFunctionData as X,erc20Abi as Jt,getAddress as B,parseAbi as ke,parseAbiItem as Xt,recoverAddress as Yt,recoverMessageAddress as Zt,recoverTypedDataAddress as Kt}from"viem";var Qt="https://priors.trade/api/check",He=604800n,wt=50n,yt=10000n,We=5000000n,$t=500000000n,je=86400n,St=2592000n,Ze=`Register one with oak_setup {"mode":"register"}, then open Priors' 5 USDG starter line with priors_starter_line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent; each transaction and signature is confirmed).`,en="0x6982e39521a070a3c40782548bfbed6dc8f566ef",tn=["0xcbb95bbf36099d34da091dc6fa6f49efa257cee3","0x284358abc07f9359f19f4b5b4ac91901be2597ba"],c={pool:B(ce[4663].priors.pool.address),lens:B(ce[4663].priors.lens.address),usdg:B(ce[4663].priors.usdg.address),registry:B(ce[4663].priors.registry.address),stockVault:B(ce[4663].priors.stockVault.address)},re={address:c.usdg,symbol:"USDG",decimals:N,chainId:$},S=ke(["function deposit(uint256 assets, address receiver, uint256 minShares) returns (uint256 minted)","function withdraw(uint256 shares_, address receiver) returns (uint256 out)","function quoteFee(uint256 agentId, uint256 principal, uint64 term) view returns (uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium)","function borrow(uint256 agentId, uint256 amount, uint64 term, address to, uint256 maxFee) returns (uint256 loanId)","function repay(uint256 loanId, uint256 expectedAgentId, uint256 maxDue)","function shares(address lender) view returns (uint256)","function convertToAssets(uint256 shares_) view returns (uint256)","function lastDepositAt(address lender) view returns (uint64)","function isController(uint256 id, address who) view returns (bool)","function delegateOf(uint256 id) view returns (address)","function getAgent(uint256 id) view returns (bool enrolled, bool isRoot, bool defaulted, bool frozen, bool importedFromV1, uint64 enrolledAt, uint64 lastBorrowAt, uint64 lastRepayAt, uint256 sponsor, uint256 delegatedIn, uint256 delegatedOut, uint256 principalOut, uint256 activeLoans, uint256 premiumBps, uint256 premiumCap, uint256 loansRepaid, uint256 volumeRepaid, uint256 feesPaid, uint256 recourseHonored, uint256 childrenDefaulted, uint256 qualifiedRepaid, uint256 dollarSecondsRepaid)","function nonces(uint256 id) view returns (uint256)","function consentDigest((uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline) c) view returns (bytes32)","function leave(uint256 agentId)","function loansOf(uint256 id) view returns (uint256[])","function getLoan(uint256 loanId) view returns (uint256 agentId, uint256 sponsorId, uint256 principal, uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium, address owner, uint64 issuedAt, uint64 dueAt, uint64 defaultableAt, uint64 minScoreTerm, uint64 closedAt, uint8 status)","event Borrowed(uint256 indexed loanId, uint256 indexed agentId, uint256 indexed sponsorId, uint256 principal, uint256 fee, uint64 dueAt, address to)"]),At=ke(["function available(uint256 agentId) view returns (uint256)","function score(uint256 id) view returns (uint256)"]),_t=ke(["function ownerOf(uint256 agentId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function getAgentWallet(uint256 agentId) view returns (address)"]),vt=ke(["function borrowRoom(uint256 agentId) view returns (uint256)","function assetList() view returns (address[])","function assets(address token) view returns (address feed, uint32 heartbeat, uint8 tokenDecimals, uint8 feedDecimals, bool enabled, uint16 ltvBps, uint256 lineCap)"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function nn(e){return e.chainId===$&&e.address.toLowerCase()===c.usdg.toLowerCase()}function on(e,i){let g=i.amount.trim(),u=g.startsWith("-"),f=u||g.startsWith("+")?g.slice(1):g,R=e.formatAmount(f,i.token.decimals),A=nn(i.token)?"USDG":i.token.address;return`${u?"-":"+"}${R} ${A}`}function te(e,i,g){if(!g.length)return i;let u=g.map(f=>on(e,f)).join(", ");return`${i} Preview changes: ${u}.`}function Pt(e,i,g,u){let f=e[i]===void 0?void 0:ee(e[i]),R=e[g]===void 0?void 0:ee(e[g]);if(f!==void 0)return f;if(R!==void 0)return R;throw new a(`Provide ${u} as an integer string in base units ("${i}" or "${g}").`)}async function De(e,i,g){try{return B(await e.clientFor($).readContract({address:c.registry,abi:_t,functionName:"ownerOf",args:[i],blockNumber:g}))}catch(u){throw u instanceof Rt&&u.walk(f=>f instanceof Ye)?new a(`ERC-8004 agent ${i} does not exist in registry ${c.registry}: it has no owner. Check the agent ID.`):new a(`Could not read the owner of ERC-8004 agent ${i} from registry ${c.registry}. Check the agent ID and retry when the registry is available.`)}}function pe(e,i){if(typeof e=="bigint"&&e>0n)return e;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if(typeof e=="string"&&/^\d+$/.test(e.trim())){let g=BigInt(e.trim());if(g>0n)return g}throw new a(`Provide a positive integer ${i}.`)}function rn(e,i){let g=i!==void 0?pe(i,"agentId"):void 0,u=[];for(let f of e)if(!(!f||typeof f.address!="string")&&f.address.toLowerCase()===c.pool.toLowerCase()&&!(!Array.isArray(f.topics)||f.topics.length===0))try{let R=jt({abi:S,eventName:"Borrowed",data:f.data,topics:f.topics});if(g!==void 0&&R.args.agentId!==g)continue;u.push(R.args.loanId)}catch{continue}return u.length===0?null:u[u.length-1].toString()}function we(e){return{enrolled:!!e[0],isRoot:!!e[1],defaulted:!!e[2],frozen:!!e[3],importedFromV1:!!e[4],enrolledAt:BigInt(e[5]),lastBorrowAt:BigInt(e[6]),lastRepayAt:BigInt(e[7]),sponsor:BigInt(e[8]),delegatedIn:BigInt(e[9]),delegatedOut:BigInt(e[10]),principalOut:BigInt(e[11]),activeLoans:BigInt(e[12]),premiumBps:BigInt(e[13]),premiumCap:BigInt(e[14]),loansRepaid:BigInt(e[15]),volumeRepaid:BigInt(e[16]),feesPaid:BigInt(e[17]),recourseHonored:BigInt(e[18]),childrenDefaulted:BigInt(e[19]),qualifiedRepaid:BigInt(e[20]),dollarSecondsRepaid:BigInt(e[21])}}function Ce(e,i){return{loanId:e,agentId:BigInt(i[0]),sponsorId:BigInt(i[1]),principal:BigInt(i[2]),fee:BigInt(i[3]),sponsorCut:BigInt(i[4]),reserveCut:BigInt(i[5]),premium:BigInt(i[6]),owner:B(String(i[7])),issuedAt:BigInt(i[8]),dueAt:BigInt(i[9]),defaultableAt:BigInt(i[10]),minScoreTerm:BigInt(i[11]),closedAt:BigInt(i[12]),status:Number(i[13])}}async function _e(e,i){let g=e.clientFor($),u=await g.getBlockNumber({cacheTime:0}),f=await g.readContract({address:c.registry,abi:_t,functionName:"balanceOf",args:[i],blockNumber:u});if(f===0n)return[];if(typeof f!="bigint"||f<0n)throw new a("Registry balance is unavailable. Retry or provide an explicit agentId.");let R=[],A=new Set,L=u;for(;;){let H=L>9999999n?L-9999999n:0n,ne=await g.getLogs({address:c.registry,event:Xt("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:i},fromBlock:H,toBlock:L,strict:!0});for(let O of ne){let J=O.args.tokenId;if(O.removed||A.has(J))continue;if(A.add(J),(await De(e,J,u)).toLowerCase()===i.toLowerCase()&&R.push(J),BigInt(R.length)===f)return R.sort((Z,se)=>Z<se?-1:Z>se?1:0)}if(H===0n)throw new a("Owned identities could not all be located. Retry or provide an explicit agentId.");L=H-1n}}async function Re(e,i,g){if(i.agentId!==void 0&&i.agentId!==null&&String(i.agentId).trim()!=="")return pe(i.agentId,"agentId");let u=await _e(e,g);if(u.length===0)throw new a(`Priors borrowing needs an ERC-8004 agent identity with a Priors credit line, and this wallet owns no identity. ${Ze}`);return u[0]}async function ze(e,i,g){let u=e.clientFor($),f=await De(e,i),[R,A]=await Promise.all([u.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[i]}),u.readContract({address:c.pool,abi:S,functionName:"isController",args:[i,g]})]),L=B(R);if(!A)throw new a(`Wallet ${g} is not an on-chain controller for ERC-8004 agent ${i} (ownerOf=${f}, delegateOf=${L}). An off-chain /api/check paymentWallet match alone does not grant CreditPoolV2 control.`);return{owner:f,delegate:L}}function sn(e,i){if(!i.enrolled||i.isRoot||i.sponsor===0n)throw new a(`ERC-8004 agent ${e} has no sponsor-backed Priors credit line on CreditPoolV2 yet (enrolled=${i.enrolled}, sponsor=${i.sponsor}, isRoot=${i.isRoot}). For an agent with no Priors record, priors_starter_line opens Priors' 5 USDG treasury line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent), then borrow.`);if(i.defaulted||i.frozen)throw new a(`ERC-8004 agent ${e} is not eligible to borrow on CreditPoolV2 (defaulted=${i.defaulted}, frozen=${i.frozen}).`);let g=i.delegatedIn>i.principalOut?i.delegatedIn-i.principalOut:0n;if(g<=0n)throw new a(`ERC-8004 agent ${e} has 0 USDG remaining credit capacity (delegatedIn=${i.delegatedIn}, principalOut=${i.principalOut}).`);return g}function an(e){let i=e.borrowReceiptLogs??(Y(e.borrowReceipt)?e.borrowReceipt.logs:void 0);if(!Array.isArray(i))return[];let g=[];for(let u of i)Y(u)&&(typeof u.address!="string"||!Array.isArray(u.topics)||typeof u.data!="string"||g.push({address:u.address,topics:u.topics,data:u.data}));return g}var Je="0x0000000000000000000000000000000000000000",ue=()=>Math.floor(Date.now()/1e3),G=e=>new Date(Number(e)*1e3).toISOString(),V=(e,i)=>e.toLowerCase()===i.toLowerCase();function ye(e){let i=(g,u)=>Array.isArray(e)?e[u]:e[g];return{depositor:B(String(i("depositor",0))),at:BigInt(i("at",1)),amount:BigInt(i("amount",2))}}async function he(e,i,g){let u=e.clientFor($),f=await u.getBlockNumber({cacheTime:0}),[R,A,L,H,ne,O,J,ge,Z,se,Te]=await Promise.all([De(e,i,f),u.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"firstLined",args:[i],blockNumber:f}),u.readContract({address:x,abi:E,functionName:"agentId",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"rules",blockNumber:f}),u.readContract({address:x,abi:E,functionName:"epochRoom",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"bonds",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"amount",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedAfter",blockNumber:f}),u.readContract({address:c.usdg,abi:Jt,functionName:"balanceOf",args:[g],blockNumber:f})]);return{owner:R,agent:we(A),firstLined:L===!0,root:BigInt(H),firstLineAmount:BigInt(ne[1]),epochRoom:BigInt(O),bond:ye(J),bondAmount:BigInt(ge),releaseAt:BigInt(Z),unusedAfter:BigInt(se),usdg:BigInt(Te)}}function It(e,i){return e.enrolled||e.enrolledAt>0n||e.isRoot||e.defaulted||e.importedFromV1||e.loansRepaid>0n||e.sponsor!==0n||i}function Ct(e,i,g,u){let f=R=>`${e.formatAmount(R.toString(),N)} USDG`;if(i.defaulted)return"it defaulted: the pool marks it, and Priors never lends to it again";if(i.isRoot)return"it is a root: it backs other agents' lines";if(i.delegatedIn>0n){let R=i.sponsor===g?`Priors' treasury (root #${g})`:`root #${i.sponsor}`;return`it has a ${f(i.delegatedIn)} line from ${R}${i.activeLoans>0n?` with ${i.activeLoans} loan(s) open`:""}`}return`it has no line now${i.enrolledAt>0n?` (it enrolled at ${G(i.enrolledAt)})`:""}${u?`; Priors' treasury opened a line for it once, and another needs a person at ${Ge}`:""}`}async function Xe(e,i){let g;try{g=await e.http(me,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(i)})}catch(f){if(!(f instanceof tt))throw new a(`Priors' invite bot (${me}) could not be reached: ${e.plainError(f)}`);g=f.response}let u;try{u=JSON.parse(await g.text())}catch{u=void 0}if(!Y(u))throw new a(`Priors' invite bot (${me}) answered HTTP ${g.status} without a readable JSON object.`);return u}var be=e=>Ee(typeof e=="string"&&e?e:"no reason given");function dn(e,i){let g=i instanceof Rt?i.walk(L=>L instanceof Ye):void 0,u=g instanceof Ye?g.data:void 0,f=u?.args??[],R=L=>`${e.formatAmount(String(L),N)} USDG`,A=u?.errorName;switch(A){case"EpochCapReached":return`Priors' treasury has no room for a new line this week (wanted ${R(f[0])}, ${R(f[1])} left); the treasury caps new lines each week, so ask again next week.`;case"InsufficientBacking":return`Priors' treasury root lacks free backing for the line now (requested ${R(f[1])}, free ${R(f[2])}); try again later.`;case"InviteExpired":return"the invite expired; call priors_starter_line again for a new one.";case"InviteUsed":return"the invite was already used.";case"NotInvited":return`the invite's signer ${String(f[1])} is not an inviter TreasurySponsorV4 names.`;case"AlreadyLined":return"the agent is already on a treasury line.";case"OwnerDefaulted":return"a default on this wallet's Priors record stops new treasury lines.";case"BadConsent":return"the pool refused the consent (its owner, nonce or signature no longer matches); call priors_starter_line again.";case"ConsentExpired":return"the consent expired; call priors_starter_line again.";case"Paused":return"the Priors pool is paused for new risk; try again later.";case void 0:return e.plainError(i);default:return`${A}(${f.map(String).join(", ")}).`}}var ln=e=>{let i={name:"priors_lend",inputSchema:{type:"object",properties:{assets:{type:"string",pattern:"^[0-9]+$",description:'USDG deposit amount in 6-decimal base units (e.g. "1000000" for 1 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for assets: USDG base-unit integer string (e.g. "1000000" for 1 USDG).'},receiver:{type:"string",description:"Optional share receiver address (must be the signing wallet)."},minShares:{type:"string",pattern:"^[0-9]+$",description:"Minimum pool shares in base units; defaults to simulated minted shares less slippage."},slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points for the simulated share minimum (defaults to 50)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=Pt(n,"assets","amount","USDG deposit amount");if(r<=0n)throw new a("Deposit amount must be greater than zero.");let p=n.minShares===void 0?void 0:ee(n.minShares),d=e.approval(c.usdg,c.pool,r.toString(),$);if(p===void 0){let l;try{let v=await e.clientFor($).simulateCalls({account:o,calls:[{to:d.to,data:d.data},{to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,0n]})}]}),[P,_]=v.results;if(P?.status!=="success"||_?.status!=="success")throw new a("Approval or deposit simulation failed.");l=zt({abi:S,functionName:"deposit",data:_.data})}catch(v){throw new a(`Could not simulate Priors deposit shares: ${e.plainError(v)}`)}if(p=ee(it(l.toString(),n.slippageBps??ot)),p===0n)throw new a("The simulated deposit cannot provide a positive minimum share amount.")}let w=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,p]}),value:"0",chainId:$,description:`Deposit ${r} USDG base units into Priors CreditPoolV2 (${c.pool}) for ${t}.`}),b=[d,w],m=await e.preview(b,o),I=`Approve ${e.formatAmount(r.toString(),N)} USDG and deposit into Priors CreditPoolV2 (${c.pool}) for ${t} (minShares=${p}; 7-day MIN_HOLD applies a 0.5% early-exit fee on early withdrawals).`;return{txs:b,summary:te(e,I,m.changes)}}},g={name:"priors_withdraw",inputSchema:{type:"object",properties:{shares:{type:"string",pattern:"^[0-9]+$",description:"Pool share count in base units to redeem (not USDG amount; omit to redeem full wallet share balance)."},receiver:{type:"string",description:"Optional USDG receiver address (must be the signing wallet)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=e.clientFor($),p=n.shares!==void 0?ee(n.shares):await r.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]});if(p<=0n)throw new a(`Wallet ${o} has no Priors CreditPoolV2 shares to withdraw.`);let[d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[p]}),r.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),r.getBlock()]),m=w>0n&&b.timestamp<w+He,h=m?d*wt/yt:0n,I=d-h,v=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"withdraw",args:[p,t]}),value:"0",chainId:$,description:`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t}.`})],P=await e.preview(v,o),_=e.formatAmount(I.toString(),N),F=e.formatAmount(d.toString(),N),k=e.formatAmount(h.toString(),N),D=m?`inside 7-day MIN_HOLD: ${k} USDG (0.5%) early-exit fee stays in pool, net payout ${_} USDG from ${F} USDG gross`:`outside 7-day MIN_HOLD: no early-exit fee, net payout ${_} USDG`,M=`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t} (${D}).`;return{txs:v,summary:te(e,M,P.changes)}}},u={name:"priors_borrow",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID with an already-funded Priors credit line."},principal:{type:"string",pattern:"^[0-9]+$",description:'Borrow principal in 6-decimal USDG base units (min "5000000" = 5 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for principal: USDG base-unit integer string (e.g. "5000000" for 5 USDG).'},term:{type:"string",description:'Loan term in seconds (between 86400 and 2592000; defaults to "86400"). The origination fee is pro-rated by term, so a longer term costs more.'},recipient:{type:"string",description:"Optional USDG recipient address (must be the signing wallet)."},maxFee:{type:"string",description:"Optional ceiling on the origination fee, USDG base units; must equal the pool's current quote for this principal and term. Omit to use that quote. The fee is pro-rated by term, not flat: 1666 for 5 USDG over 1 day on the first live run (2026-10-31)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.recipient!==void 0&&(typeof n.recipient!="string"||n.recipient.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors recipient must be the signing wallet.");let r=await Re(e,n,o);await ze(e,r,o);let p=e.clientFor($),d=await p.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[r]}),w=we(d),b=sn(r,w),m=Pt(n,"principal","amount","USDG borrow principal");if(m<We||m>$t)throw new a(`Borrow principal must be between ${We} (5 USDG) and ${$t} (500 USDG) base units.`);if(m>b)throw new a(`Borrow principal ${m} exceeds available credit line capacity ${b} USDG base units for agent ${r}.`);let h=n.term!==void 0&&String(n.term).trim()!==""?pe(n.term,"term"):je;if(h<je||h>St)throw new a(`Loan term must be between ${je} (1 day) and ${St} (30 days) seconds.`);let I=await p.readContract({address:c.pool,abi:S,functionName:"quoteFee",args:[r,m,h]}),l=I[0],v=n.maxFee!==void 0?ee(n.maxFee):l;if(v<l)throw new a(`Provided maxFee ${v} is below the origination fee the pool quotes for this term, ${l} USDG base units.`);if(v>l)throw new a(`Provided maxFee ${v} is above the quoted origination fee ${l} USDG base units. Use the quoted fee or omit maxFee.`);let P=m+l,_=m+v,k=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"borrow",args:[r,m,h,t,v]}),value:"0",chainId:$,description:`Borrow ${m} USDG base units on Priors CreditPoolV2 for agent ${r} to ${t} (quoted fee ${l}, expected debt ${P}, maxFee ${v}, debt ceiling ${_}).`})],D=await e.preview(k,o),M=e.formatAmount(m.toString(),N),W=e.formatAmount(l.toString(),N),ae=e.formatAmount(P.toString(),N),j=e.formatAmount(v.toString(),N),$e=e.formatAmount(_.toString(),N),q=I[1]+I[3],K=I[2],de=l-q-K,oe=`Borrow ${M} USDG for ERC-8004 agent ${r} to recipient ${t} on Priors CreditPoolV2 (${c.pool}) for ${h}s: expected origination fee ${W} USDG (${l} base units; pro-rated by term, set when the loan opens, none refunded on early repayment), expected total repayment due ${ae} USDG (${P} base units); fee ceiling ${j} USDG (${v} base units), debt ceiling ${$e} USDG (${_} base units). Fee recipient on repayment: CreditPoolV2 (${c.pool}), allocating the quoted fee to sponsor ${w.sponsor} (${q} base units including premium), reserve (${K} base units), and lenders (${de} base units).`;return{txs:k,summary:te(e,oe,D.changes)}}},f={name:"priors_repay",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID that owns the active loan."},loanId:{type:"string",description:"Optional explicit per-agent loan ID (otherwise recovered from Borrowed receipt logs or loansOf(agentId))."},borrowReceiptLogs:{type:"array",description:"Optional receipt logs array from the borrow transaction to decode the exact Borrowed(loanId, agentId, ...) event."},maxDue:{type:"string",description:"Optional maximum USDG base units to repay; must equal the exact fixed principal + fee. Omit to use that debt."}}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),p;if(n.loanId!==void 0&&n.loanId!==null&&String(n.loanId).trim()!=="")p=pe(n.loanId,"loanId");else{let k=an(n);if(k.length>0){let D=rn(k,t);D!==null&&(p=BigInt(D))}}let d;if(p!==void 0){let k=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[p]}),D=Ce(p,k);if(D.agentId!==t)throw new a(`Loan ${p} belongs to agent ${D.agentId}, not agent ${t}. Recover loan IDs from the Borrowed receipt or loansOf(agentId), never global loanCount().`);if(D.status!==1)throw new a(`Loan ${p} for agent ${t} is not active (status=${D.status}).`);d=D}else{let k=await r.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[t]});if(k.length===0)throw new a(`ERC-8004 agent ${t} has no recorded loans on Priors CreditPoolV2.`);let M=(await Promise.all(k.map(async W=>{let ae=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[W]});return Ce(W,ae)}))).filter(W=>W.agentId===t&&W.status===1);if(M.length===0)throw new a(`ERC-8004 agent ${t} has no active loans to repay.`);d=M[M.length-1]}let w=d.principal+d.fee,b=n.maxDue!==void 0?ee(n.maxDue):w;if(b<w)throw new a(`Provided maxDue ${b} is below the exact fixed loan debt ${w} USDG base units (principal ${d.principal} + fixed fee ${d.fee}).`);if(b>w)throw new a(`Provided maxDue ${b} is above the exact fixed loan debt ${w} USDG base units. Use the fixed debt or omit maxDue.`);let m=e.approval(c.usdg,c.pool,w.toString(),$),h=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"repay",args:[d.loanId,t,b]}),value:"0",chainId:$,description:`Repay fixed debt ${w} USDG base units (principal ${d.principal} + fee ${d.fee}) for loan ${d.loanId} (agent ${t}).`}),I=[m,h],l=await e.preview(I,o),v=e.formatAmount(w.toString(),N),P=e.formatAmount(d.principal.toString(),N),_=e.formatAmount(d.fee.toString(),N),F=`Approve and repay ${v} USDG (${w} base units: ${P} USDG principal + ${_} USDG fixed fee) for Priors loan ${d.loanId} (agent ${t}).`;return{txs:I,summary:te(e,F,l.changes)}}},R={name:"priors_status",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Optional ERC-8004 agent ID to inspect on CreditPoolV2, PriorsLens, and StockVault."},includeApiCheck:{type:"boolean",description:"Optional flag to query https://priors.trade/api/check for supplemental off-chain metadata."}}},async execute(n,s){z(s);let o=B(s),t=e.clientFor($),[r,p,d,w]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]}),t.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),t.getBlock(),t.readContract({address:c.stockVault,abi:vt,functionName:"assetList"})]),b=r>0n?await t.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[r]}):0n,m=r>0n&&p>0n&&d.timestamp<p+He,h=m?b*wt/yt:0n,I=b-h,l=null;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")l=pe(n.agentId,"agentId");else{let q=await _e(e,o);q.length>0&&(l=q[0])}let v=null,P=!1,_=[],F=null,k=null,D=null,M=null,W=null,ae=null,j=`This wallet owns no ERC-8004 agent identity. ${Ze}`;if(l!==null){let[q,K,de,oe,Ot,Ut,Be,Ne,Le]=await Promise.all([t.readContract({address:c.lens,abi:At,functionName:"score",args:[l]}),t.readContract({address:x,abi:E,functionName:"firstLined",args:[l]}),t.readContract({address:x,abi:E,functionName:"agentId"}),t.readContract({address:x,abi:E,functionName:"rules"}),t.readContract({address:x,abi:E,functionName:"epochRoom"}),t.readContract({address:C,abi:U,functionName:"bonds",args:[l]}),t.readContract({address:C,abi:U,functionName:"amount"}),t.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[l]}),t.readContract({address:C,abi:U,functionName:"releasable",args:[l]})]),[Et,Gt,Vt,Ft,Mt,qt]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[l]}),t.readContract({address:c.lens,abi:At,functionName:"available",args:[l]}),t.readContract({address:c.stockVault,abi:vt,functionName:"borrowRoom",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"isController",args:[l,o]})]),xe=await De(e,l),Ht=B(Mt),Ke=qt,y=we(Et),Se=y.delegatedIn>y.principalOut?y.delegatedIn-y.principalOut:0n;P=y.enrolled&&!y.isRoot&&!y.defaulted&&!y.frozen&&y.sponsor>0n&&y.delegatedIn>0n,F=Vt.toString(),k=Ft.toString();let Wt=await Promise.all(Gt.map(async T=>{let le=await t.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[T]});return Ce(T,le)}));for(let T of Wt)if(T.agentId===l&&T.status===1){let le=T.principal+T.fee;_.push({loanId:T.loanId.toString(),agentId:T.agentId.toString(),sponsorId:T.sponsorId.toString(),principal:T.principal.toString(),fee:T.fee.toString(),due:le.toString(),dueAt:T.dueAt.toString(),issuedAt:T.issuedAt.toString(),owner:T.owner,token:re})}v={agentId:l.toString(),owner:xe,delegate:Ht,isAuthorizedController:Ke,enrolled:y.enrolled,isRoot:y.isRoot,defaulted:y.defaulted,frozen:y.frozen,sponsorId:y.sponsor.toString(),delegatedIn:y.delegatedIn.toString(),delegatedOut:y.delegatedOut.toString(),principalOut:y.principalOut.toString(),availableCapacity:Se.toString(),activeLoansCount:y.activeLoans.toString(),loansRepaid:y.loansRepaid.toString(),volumeRepaid:y.volumeRepaid.toString(),feesPaid:y.feesPaid.toString(),importedFromV1:y.importedFromV1,qualifiedRepaid:y.qualifiedRepaid.toString(),dollarSecondsRepaid:y.dollarSecondsRepaid.toString()};let Ae=BigInt(de),Oe=K===!0,Q=ye(Ut),ie=Q.depositor!==Je,ve=ie&&V(Q.depositor,o),Qe=It(y,Oe),Ue=V(xe,o);D={onchain:BigInt(q).toString(),scale:"0-1000",source:`CreditLensV2.score(${l}) at ${c.lens}, the score the pool computes on chain`,scoreV2:null},M={open:y.sponsor!==0n&&y.delegatedIn>0n,amount:y.delegatedIn.toString(),drawn:y.principalOut.toString(),available:Se.toString(),sponsorId:y.sponsor.toString(),backer:y.sponsor===0n?null:y.sponsor===Ae?`Priors' treasury v4 (root #${Ae})`:`root #${y.sponsor}`,token:re},W={contract:C,posted:ie,depositor:ie?Q.depositor:null,postedByWallet:ve,postedAt:ie?Q.at.toString():null,amount:(ie?Q.amount:BigInt(Be)).toString(),releasable:ie&&Le===!0,releaseAt:ie?BigInt(Ne).toString():null,rule:"Back to its depositor once the agent holds no line and has no loan open, from 4 days after it was posted (close a line first with priors_close_line); a default forfeits it to Priors' Safe."},ae={eligible:Ue&&!Qe,firstLined:Oe,lineAmount:BigInt(oe[1]).toString(),bondAmount:BigInt(Be).toString(),treasuryRoot:Ae.toString(),treasuryRoomThisWeek:BigInt(Ot).toString(),note:"Not instant: Priors' invite bot decides each invite, and the treasury caps new lines each week."};let fe=_.map(T=>({id:String(T.loanId),dueAt:BigInt(String(T.dueAt))})).sort((T,le)=>T.dueAt<le.dueAt?-1:T.dueAt>le.dueAt?1:0);y.defaulted?j=`Agent #${l} defaulted; Priors never lends to it again${ve?" and its bond is forfeited":""}.`:!Ke&&!Ue?j=`This wallet does not control agent #${l} on CreditPoolV2 (owner ${xe}); act from its owner or delegate.`:fe.length?j=`Repay loan ${fe[0].id} with priors_repay before it is due at ${G(fe[0].dueAt)}${fe.length>1?` (${fe.length} loans open)`:""}.`:P&&Se>=We?j=`Borrow with priors_borrow (5 USDG minimum, up to ${A(Se)}; the fee is pro-rated by term); Priors counts loans held 7 days or more toward the score.`:!Qe&&Ue?j=ve?`Call priors_starter_line again: the ${A(Q.amount)} bond is posted, and it goes on with the invite bot's ownership proof and the invite's redemption${Le===!0?", or priors_release_bond returns the bond":""}.`:`Call priors_starter_line: a refundable ${A(BigInt(Be))} bond, an invite from Priors' invite bot and your pool consent open a ${A(BigInt(oe[1]))} line from Priors' treasury (each transaction and signature is confirmed).`:ve?j=Le===!0?`Release the ${A(Q.amount)} invite bond with priors_release_bond.`:y.delegatedIn>0n?`The line is open with nothing to draw; to take the bond back, close it with priors_close_line, then priors_release_bond from ${G(BigInt(Ne))}.`:`The ${A(Q.amount)} invite bond comes back with priors_release_bond from ${G(BigInt(Ne))}.`:j=`Agent #${l} has a Priors record but no line to draw now; ${Ct(e,y,Ae,Oe)}.`}let $e=null;if(n.includeApiCheck){let q=l!==null?`agent=${l.toString()}`:`address=${o}`,K=await nt(e.http,`${Qt}?${q}`,{method:"GET"},Y),de=Array.isArray(K.agents)?K.agents.find(oe=>Y(oe)&&String(oe.agentId)===String(l)):void 0;D&&Y(de)&&(D.scoreV2=de.scoreV2??null),$e={...K,grantsPoolControl:!1,controlRule:"Off-chain /api/check identity or paymentWallet match never grants CreditPoolV2 control; on-chain isController(agentId, wallet) must authorize the caller; stale delegates do not qualify."}}return{chainId:$,blockNumber:d.number?.toString()??null,blockTimestamp:d.timestamp.toString(),wallet:o,token:re,contracts:c,lender:{shares:r.toString(),grossAssets:b.toString(),earlyExitFeeAssets:h.toString(),netWithdrawAssets:I.toString(),lastDepositAt:p.toString(),withinMinHoldWindow:m,minHoldSeconds:He.toString()},hasFundedLine:P,agentId:l!==null?l.toString():null,nextStep:j,score:D,line:M,bond:W,starterLine:ae,agent:v,activeLoans:_,lens:{address:c.lens,available:F,caveat:"PriorsLens.available(agentId) is a status capacity hint for already-funded lines; backer hooks may still refuse borrows."},stockVault:{address:c.stockVault,borrowRoom:k,onchainAssetCount:w.length,hostedMcpStockCount:35,extraNonStockAsset:B(en),zeroCapAssets:tn.map(q=>B(q)),caveat:"Use priors_stock_assets and priors_stock_asset_state for current collateral rules, then priors_stock_open. This summary is an observed asset-count snapshot, not a fixed allowlist; live caps, lending holds and prices control admission."},apiCheck:$e,limitations:["Borrowing and repayment require a sponsor-backed ERC-8004 credit line (enrolled && !isRoot && sponsor != 0) authorized on-chain by isController(agentId, wallet).","Priors line routes are exposed by priors_line_options and priors_capabilities: treasury starter, V5 move/raise, direct sponsor, stock and owner PRIORS backing. Ethos execution uses Priors own owner workflow because its worker supplies no unsigned final transaction.","score.onchain is the pool's on-chain score (CreditLensV2); score.scoreV2 is Priors Score v2 from /api/check, present only with includeApiCheck.","Loan debt is the principal plus the origination fee the pool quotes for the term. The fee is pro-rated by term, not flat (1666 base units for 5 USDG over 1 day, observed live 2026-10-31; priors_borrow shows the exact quote), and is fixed once the loan opens: variable interest is never invented, and early repayment refunds none of it.","Loan IDs are recovered from decoded Borrowed receipts or per-agent loansOf(agentId), never global loanCount().","Historical archive event queries and zero-position StockVault lines on public RPCs remain subject to archive retention and live backer state."]}}},A=n=>`${e.formatAmount(n.toString(),N)} USDG`;function L(n){let s=V(n.bond.depositor,n.owner)&&n.bond.amount>0n?n.bond.amount:n.bondAmount;return`Bond first: ${A(s)} is locked in Priors' InviteBond for at least ${n.unusedAfter} seconds (${Number(n.unusedAfter)/86400} days) after posting${n.releaseAt>0n?`; unusedReleaseAt is ${G(n.releaseAt)}`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments. `}function H(n,s,o){if(!V(o.owner,s))throw new a(`This wallet (${s}) does not own ERC-8004 agent ${n} (its owner is ${o.owner}). The bond, the ownership proof and the pool consent are the owner's. Nothing was signed.`);if(o.root!==Ie)throw new a(`TreasurySponsorV4 (${x}) answers root #${o.root}, not the pinned #${Ie}. Nothing was signed; update Oak.`);if(It(o.agent,o.firstLined))throw new a(`Agent #${n} already has a Priors record, so priors_starter_line posts no bond and signs nothing: ${Ct(e,o.agent,o.root,o.firstLined)}; ${o.agent.loansRepaid} loan(s) repaid. The starter line is only for an identity with no record; priors_status shows this one.`)}let ne="stays posted in InviteBond";function O(n){let s=n.agent.delegatedIn>0n?`with a line open it comes back only after priors_close_line (no loan open), then priors_release_bond from ${G(n.releaseAt)} at the earliest`:`while the agent holds no line it comes back with priors_release_bond from ${G(n.releaseAt)} (${Number(n.unusedAfter)/86400} days after it was posted)`;return`The ${A(n.bond.amount>0n?n.bond.amount:n.bondAmount)} bond ${ne} (${C}), posted from this wallet; ${s}, and priors_starter_line never posts a second bond.`}async function J(n,s,o){try{return await o()}catch(t){let r=t instanceof a?t.message:e.plainError(t);if(r.includes(ne)||n===void 0||!/^[0-9]{1,78}$/.test(n))throw t;let p;try{let d=await he(e,BigInt(n),s);p=V(d.bond.depositor,s)?O(d):""}catch{p=`If the bond transactions mined, the invite bond ${ne} (${C}) remains locked until its on-chain release conditions are met; priors_status shows the exact amount and time (its state could not be read just now).`}throw p?new a(`${r} ${p}`):t}}async function ge(n,s,o){let t=dt(await Xe(e,{agentId:n}),{agentId:n,owner:s,now:ue()});if(!t.ok&&t.refused)throw new a(`Priors' invite bot gave no ownership proof to sign for agent #${n}: ${be(t.why)}. Nothing was signed. ${o}`.trim());if(!t.ok)throw new a(`Not signed: the invite bot's answer for agent #${n} is not one Oak signs: ${t.why}. Oak signs only the bot's own start-page text, rebuilt locally for this agent and this wallet. ${o}`.trim());if(t.exp-ue()<120)throw new a(`Not signed: the invite bot's proof for agent #${n} expires in under 2 minutes; call priors_starter_line again for a new one. ${o}`.trim());return t}function Z(n,s,o,t){return{steps:[{kind:"message",message:o.message}],continuation:{stage:"proof",wallet:s,chainId:$,agentId:n,n:o.n,exp:o.exp},summary:`${L(t)}Priors starter line for ERC-8004 agent ${n}, step 2 of 3: sign Priors' invite-bot ownership proof. It is a message signature (EIP-191) only: it sends no transaction and moves no funds. The text is the bot's own form, rebuilt locally for agent #${n} and this wallet, request ${o.n}, expiring ${G(o.exp)}. Oak then sends the signature to ${me}, and the bot decides the invite. ${O(t)}`}}function se(n,s,o){if(n.chainId!==$||typeof n.wallet!="string"||!V(n.wallet,s)||typeof n.agentId!="string"||!/^[1-9][0-9]{0,29}$/.test(n.agentId))throw new a("Priors starter-line continuation does not match this wallet or chain 4663; start priors_starter_line again.");if(o.agentId!==void 0&&String(o.agentId)!==n.agentId)throw new a("Priors starter-line continuation is for another agent; start priors_starter_line again.");return BigInt(n.agentId)}async function Te(n,s){let o;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")o=pe(n.agentId,"agentId");else{let l=await _e(e,s);if(!l.length)throw new a(`Priors' starter line needs an ERC-8004 agent identity, and this wallet owns none. ${Ze}`);o=l[0]}let t=await he(e,o,s);H(o,s,t);let r=o.toString(),p=V(t.bond.depositor,s);if(!p){if(t.usdg<t.bondAmount)throw new a(`This wallet holds ${A(t.usdg)} on Robinhood Chain, and Priors' treasury invite asks a ${A(t.bondAmount)} bond first (InviteBond ${C}), posted from this wallet. Nothing was signed: add USDG, then call priors_starter_line again.`);if(t.epochRoom<t.firstLineAmount)return{summary:`${L(t)}Not submitted. Priors' treasury has ${A(t.epochRoom)} of room left this week and a first line is ${A(t.firstLineAmount)}, so priors_starter_line posted no bond and signed nothing. The treasury caps new lines each week: ask again next week.`,starterLine:{agentId:r,open:!1,reason:"room",epochRoom:t.epochRoom.toString()}};let l=await Xe(e,{check:!0,owner:s.toLowerCase()});if(l.check!==!0)throw new a("Priors' invite bot did not answer its check, so whether an invite is open cannot be told. Nothing was signed.");if(l.ok!==!0)throw new a(`Whether an automatic invite is open could not be told: Priors' invite bot says ${be(l.error)}. Nothing was signed; try again later.`);if(l.open!==!0){let v=typeof l.reason=="string"?l.reason.replace(/[^a-z-]/g,"").slice(0,24):"",P=typeof l.reopensAt=="number"&&Number.isSafeInteger(l.reopensAt)&&l.reopensAt>0?l.reopensAt:null;return{summary:`${L(t)}Not submitted. No automatic invite is open to this wallet right now, so priors_starter_line posted no bond and signed nothing. Priors' invite bot answers: closed, reason ${Ee(v||"none given")}${P?`, reopens ${G(P)}`:""}. ${lt({...l,reason:v})} Priors lists its other ways to a first line (the Ethos lane, a stock line, the owner's $PRIORS stake) at https://priors.trade/skill.md.`,starterLine:{agentId:r,open:!1,reason:v||null,reopensAt:P}}}}let d=await ge(r,s,p?O(t):"");if(p)return Z(r,s,d,t);let w=[e.approval(c.usdg,C,t.bondAmount.toString(),$),e.unsignedTx({to:C,data:X({abi:U,functionName:"deposit",args:[o]}),value:"0",chainId:$,description:`Post the ${t.bondAmount} USDG base-unit Priors invite bond for agent ${r} in InviteBond (${C}).`})],b=await e.preview(w,s),m=t.bond.depositor!==Je?` This deposit replaces the bond ${t.bond.depositor} posted for this agent; InviteBond returns that bond to it in the same transaction.`:"",h=`${L(t)}Priors starter line for ERC-8004 agent ${r}, step 1 of 3: approve exactly ${A(t.bondAmount)} to Priors' InviteBond (${C}) and post it as the agent's refundable invite bond (InviteBond.deposit).${m} Priors' invite bot says an automatic invite is open now and gave the ownership proof to sign next. Step 2 signs that proof (a message, no transaction); step 3 signs your pool consent and redeems the invite (TreasurySponsorV4.firstLine, ${x}) for a ${A(t.firstLineAmount)} line from Priors' treasury (root #${t.root}). The invite is the bot's decision, not a promise: if it refuses, or any later step fails, the bond stays posted and comes back with priors_release_bond after the on-chain lock and release conditions are met. With a line, the bond comes back only once the line is closed with no loan open (priors_close_line, then priors_release_bond); a default forfeits it to Priors' Safe.`;return{steps:w.map(l=>({kind:"tx",tx:l})),continuation:{stage:"bond",wallet:s,chainId:$,agentId:r,n:d.n,exp:d.exp},summary:te(e,h,b.changes)}}async function kt(n,s,o){let t=await he(e,n,s);H(n,s,t);let r=n.toString();if(!V(t.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet, so nothing more was signed. Check the deposit transaction, then call priors_starter_line again.`);return typeof o.n=="string"&&Ve.test(o.n)&&typeof o.exp=="number"&&Number.isSafeInteger(o.exp)&&o.exp-ue()>=300?Z(r,s,{n:o.n,exp:o.exp,message:Me(r,o.n,o.exp)},t):Z(r,s,await ge(r,s,O(t)),t)}async function Dt(n,s,o,t){let r=n.toString();if(typeof o.n!="string"||!Ve.test(o.n)||typeof o.exp!="number"||!Number.isSafeInteger(o.exp))throw new a("Invalid Priors starter-line proof continuation; start priors_starter_line again.");if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the invite bot's ownership proof.");if(o.exp<=ue())throw new a(`The invite bot's proof for agent #${r} expired before it reached the bot; nothing was sent to it. Call priors_starter_line again for a fresh proof (the bond is not posted again).`);let p=Me(r,o.n,o.exp);if(!V(await Zt({message:p,signature:t}),s))throw new a("The ownership-proof signature is not this wallet's; nothing was sent to the invite bot.");let d=await he(e,n,s);if(H(n,s,d),!V(d.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet; nothing was sent to the invite bot. Call priors_starter_line again.`);let w=await Xe(e,{n:o.n,signature:t});if(w.ok!==!0)throw new a(`Priors' invite bot gave no invite for agent #${r}: ${be(w.error)}. ${O(d)}`);if(typeof w.code!="string")throw new a(`Priors' invite bot gave no invite for agent #${r}${w.reason?`: ${be(w.reason)}`:""}${typeof w.decided=="string"?` (its decision: ${be(w.decided)})`:""}. ${O(d)}`);let b=qe(w.code,r,ue()+60);if(!b.ok)throw new a(`Priors' invite bot's code for agent #${r} is not one Oak redeems: ${b.why}. Nothing more was signed. ${O(d)}`);let m=e.clientFor($),h=await m.readContract({address:x,abi:E,functionName:"inviteDigest",args:[n,b.expiry]});if(h.toLowerCase()!==at(n,b.expiry).toLowerCase())throw new a("TreasurySponsorV4's invite digest differs from its pinned EIP-712 domain; nothing more was signed. Update Oak.");let I=await Yt({hash:h,signature:b.signature}),[l,v]=await Promise.all([m.readContract({address:x,abi:E,functionName:"inviters",args:[I]}),m.readContract({address:x,abi:E,functionName:"inviteUsed",args:[h]})]);if(l!==!0)throw new a(`Priors' invite for agent #${r} was signed by ${I}, which TreasurySponsorV4 does not name an inviter, so the treasury would refuse it. Nothing more was signed. ${O(d)}`);if(v===!0)throw new a(`Priors' invite for agent #${r} was already used. Nothing more was signed. ${O(d)}`);let[P,_]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]),F=_.timestamp+BigInt(rt),k=Fe({agentId:r,owner:s,nonce:P.toString(),deadline:F.toString()}),D=await m.readContract({address:c.pool,abi:S,functionName:"consentDigest",args:[{agentId:n,sponsorId:d.root,owner:s,maxPremiumBps:0n,nonce:P,deadline:F}]});if(D.toLowerCase()!==st(k).toLowerCase())throw new a(`The pool's consentDigest (${D}) differs from the consent Oak builds for CreditPoolV2 (${c.pool}), so the pool would refuse it. Nothing more was signed. ${O(d)}`);return{steps:[{kind:"typedData",request:k}],continuation:{stage:"consent",wallet:s,chainId:$,agentId:r,invite:w.code,request:k},summary:`Priors starter line for ERC-8004 agent ${r}, step 3 of 3: Priors' invite bot gave an invite (signed by ${I}, an inviter TreasurySponsorV4 names; it expires ${G(b.expiry)}). Sign your pool consent (EIP-712 "Priors Credit" version 2 on CreditPoolV2 ${c.pool}): it lets Priors' treasury (root #${d.root}) back a line for agent #${r} with premium 0, nonce ${P}, valid until ${G(F)}. A transaction redeeming the invite (TreasurySponsorV4.firstLine) follows for your confirmation. ${O(d)}`}}async function Tt(n,s,o,t){let r=n.toString();if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the Priors pool consent.");let p=qe(o.invite,r,ue()+60);if(!p.ok)throw new a(`The invite for agent #${r} is not one Oak redeems now: ${p.why}. Call priors_starter_line again for a new one.`);let d=Y(o.request)&&Y(o.request.message)?o.request.message:void 0;if(!d||typeof d.nonce!="string"||!/^[0-9]{1,78}$/.test(d.nonce)||typeof d.deadline!="string"||!/^[0-9]{1,20}$/.test(d.deadline))throw new a("Invalid Priors starter-line consent continuation; start priors_starter_line again.");let w=Fe({agentId:r,owner:s,nonce:d.nonce,deadline:d.deadline});if(!V(await Kt({...w,signature:t}),s))throw new a("The pool-consent signature is not this wallet's for the consent Oak built; nothing was offered.");let b=await he(e,n,s);H(n,s,b);let m=e.clientFor($),[h,I]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]);if(h.toString()!==d.nonce)throw new a(`Agent #${r}'s consent nonce moved on chain since it was signed; nothing was offered. Call priors_starter_line again.`);if(I.timestamp>=BigInt(d.deadline))throw new a(`The pool consent for agent #${r} expired at ${G(BigInt(d.deadline))}; nothing was offered. Call priors_starter_line again.`);let l={agentId:n,sponsorId:Ie,owner:s,maxPremiumBps:0n,nonce:h,deadline:BigInt(d.deadline)},v=[n,p.expiry,p.signature,l,t];try{await m.simulateContract({address:x,abi:E,functionName:"firstLine",args:v,account:s})}catch(k){throw new a(`TreasurySponsorV4.firstLine for agent #${r} would be refused: ${dn(e,k)} Nothing was offered. ${O(b)}`)}let P=e.unsignedTx({to:x,data:X({abi:E,functionName:"firstLine",args:v}),value:"0",chainId:$,description:`Redeem Priors' invite for agent ${r}: TreasurySponsorV4.firstLine opens a ${b.firstLineAmount} USDG base-unit line from root ${b.root} with the owner's consent.`}),_=await e.preview([P],s),F=`Redeem agent #${r}'s Priors invite: TreasurySponsorV4.firstLine (${x}) opens a ${A(b.firstLineAmount)} line from Priors' treasury (root #${b.root}) with your signed consent. No USDG moves in this transaction. Then priors_status shows the line and priors_borrow draws it (5 USDG minimum; the fee is pro-rated by term; Priors counts loans held 7 days or more toward the score). The ${A(b.bondAmount)} bond stays in InviteBond until the line is closed with no loan open (priors_close_line, then priors_release_bond, from ${G(b.releaseAt)} at the earliest); a default forfeits it.`;return{txs:[P],summary:te(e,F,_.changes)}}let Bt={name:"priors_starter_line",inputSchema:{description:"Bond first: the launch bond is 5 USDG, locked at least 4 days. The first result reads amount(), unusedAfter() and unusedReleaseAt(agentId) for current terms before any approval. Invites are not guaranteed; the credit score can lag. Release needs no line or open loan; default can forfeit the bond.",type:"object",additionalProperties:!1,properties:{agentId:Pe("ERC-8004 agent ID this wallet owns, with no Priors record yet (default: the first identity this wallet owns)."),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$"}}},async execute(n,s){z(s);let o=B(s);if(n.continuation===void 0){if(n.signature!==void 0)throw new a("A signature needs its Priors starter-line continuation; start priors_starter_line again.");return J(typeof n.agentId=="string"?n.agentId:void 0,o,()=>Te(n,o))}if(!Y(n.continuation))throw new a("Invalid Priors starter-line continuation; start priors_starter_line again.");let t=n.continuation,r=se(t,o,n),p=d=>J(r.toString(),o,d);if(t.stage==="bond"){if(n.signature!==void 0)throw new a("The bond stage takes no signature; start priors_starter_line again.");return p(()=>kt(r,o,t))}if(t.stage==="proof")return p(()=>Dt(r,o,t,n.signature));if(t.stage==="consent")return p(()=>Tt(r,o,t,n.signature));throw new a("Unknown Priors starter-line stage; start priors_starter_line again.")}},Nt={name:"priors_close_line",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose Priors line to close (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),[p,d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:x,abi:E,functionName:"agentId"})]),m=we(p);if(m.sponsor===0n)throw new a(`Agent #${t} has no Priors line to close (no sponsor on CreditPoolV2).`);if(m.activeLoans>0n)throw new a(`Agent #${t} has ${m.activeLoans} loan(s) open; repay them with priors_repay first. The pool's leave refuses while a loan is open.`);let h=ye(d),I=m.sponsor===BigInt(b),l=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"leave",args:[t]}),value:"0",chainId:$,description:`Close agent ${t}'s Priors line on CreditPoolV2 (leave): the ${m.delegatedIn} USDG base-unit line returns to root ${m.sponsor}.`}),v=await e.preview([l],o),P=V(h.depositor,o)?` Its ${A(h.amount)} invite bond can then come back with priors_release_bond from ${G(w)} (4 days after it was posted).`:"",_=`Close agent #${t}'s Priors line (CreditPoolV2.leave, ${c.pool}): the whole ${A(m.delegatedIn)} line goes back to its backer (${I?`Priors' treasury, root #${b}`:`root #${m.sponsor}`}) and the agent can no longer borrow on it. This does not reopen: ${I?`priors_starter_line opens no second treasury line for an agent with a Priors record; another needs a person at ${Ge}.`:"a new line needs a backer's new consent."}${P} No USDG moves in this transaction.`;return{txs:[l],summary:te(e,_,v.changes)}}},Lt={name:"priors_release_bond",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose InviteBond bond this wallet posted (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o),r=e.clientFor($),[p,d,w,b,m]=await Promise.all([r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"releasable",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.getBlock()]),h=ye(p);if(h.depositor===Je)throw new a(`Agent #${t} has no bond in Priors' InviteBond (${C}).`);if(!V(h.depositor,o))throw new a(`Agent #${t}'s InviteBond bond was posted by ${h.depositor}, not this wallet, and InviteBond.release pays the depositor. Oak releases only a bond this wallet posted.`);if(d!==!0){let P=we(b),_=P.defaulted?"the agent defaulted, so the bond is forfeited to Priors' Safe (InviteBond.slash)":P.activeLoans>0n?`the agent has ${P.activeLoans} loan(s) open: repay with priors_repay, close the line with priors_close_line, then release`:P.delegatedIn>0n?`the agent still holds a ${A(P.delegatedIn)} line: close it with priors_close_line (no loan may be open), then release`:m.timestamp<w?`it comes back 4 days after it was posted, from ${G(w)}`:"InviteBond does not release it yet";throw new a(`Agent #${t}'s ${A(h.amount)} invite bond cannot be released now: ${_}. Nothing was signed.`)}let I=e.unsignedTx({to:C,data:X({abi:U,functionName:"release",args:[t]}),value:"0",chainId:$,description:`Release agent ${t}'s ${h.amount} USDG base-unit Priors invite bond from InviteBond (${C}) to its depositor ${h.depositor}.`}),l=await e.preview([I],o),v=`Release agent #${t}'s ${A(h.amount)} invite bond from Priors' InviteBond (${C}): InviteBond.release returns it to its depositor, this wallet (${o}).`;return{txs:[I],summary:te(e,v,l.changes)}}};async function xt(n){z(n);let s=B(n),o=e.clientFor($),[t,r]=await Promise.all([o.readContract({address:c.pool,abi:S,functionName:"shares",args:[s]}),_e(e,s)]),p=[];if(t>0n){let d=await o.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[t]});p.push({module:"priors",id:`priors:lender:${s.toLowerCase()}`,chainId:$,assets:[{token:re,amount:d.toString()}],description:`Priors CreditPoolV2 lender position (${t} shares = ${e.formatAmount(d.toString(),N)} USDG gross).`})}for(let d of r){let w=await o.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[d]}),b=await Promise.all(w.map(async h=>{let I=await o.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[h]});return Ce(h,I)}));for(let h of b)if(h.agentId===d&&h.status===1){let I=h.principal+h.fee;p.push({module:"priors",id:`priors:loan:${h.loanId.toString()}`,chainId:$,assets:[{token:re,amount:I.toString()}],description:`Priors CreditPoolV2 active loan ${h.loanId} for agent ${d} (fixed due ${e.formatAmount(I.toString(),N)} USDG = ${h.principal} principal + ${h.fee} fee).`})}let m=ye(await o.readContract({address:C,abi:U,functionName:"bonds",args:[d]}));m.amount>0n&&V(m.depositor,s)&&p.push({module:"priors",id:`priors:bond:${d.toString()}`,chainId:$,assets:[{token:re,amount:m.amount.toString()}],description:`Priors invite bond for agent ${d} in InviteBond (${C}): ${A(m.amount)}, back with priors_release_bond once the agent holds no line and no loan, from 4 days after posting; a default forfeits it.`})}return p.push(...await gt(e,s,r,re)),p}return{tools:[i,g,u,f,R,Bt,Nt,Lt],positions:xt}},cn=e=>{let i=ln(e),g=[i,ct(e),ut(e),ft(e),mt(e),ht(e),bt(e),pt()];return{...i,tools:g.flatMap(u=>u.tools)}},Dn=e=>et("priors",[cn(e)]);export{Qt as a,He as b,wt as c,yt as d,We as e,$t as f,je as g,St as h,c as i,re as j,rn as k,cn as l,Dn as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as g,f as T,g as k,i as E}from"./
|
|
1
|
+
import{e as g,f as T,g as k,i as E}from"./DHUDSOGR.js";import{c as _,d as S}from"./AEL62KCG.js";import{g as h}from"./NWNYJ26T.js";import{a as l}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{decodeAbiParameters as B,encodeAbiParameters as H,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),O=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=p=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50},marketId:{type:"string"}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let f=await p.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!f.ok)throw new i(`Longbow fixed order book returned HTTP ${f.status}; offers are unavailable.`);let x=await f.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==l||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[I]=B(O,n);if(I.length!==r.items)throw new i("Publication count mismatch.");for(let b of I){y++;let e=b.offer;if(e.market.chainId!==BigInt(l)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let w=E(e.market);if(o.marketId!==void 0&&!h(w,String(o.marketId)))continue;let N=[_,S].find(P=>h(P.address,e.market.loanToken));c.push({marketId:w,offer:H(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:p.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:l,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(p.plainError(a))}}}]});export{D as a,O as b,G as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as F,c as y,d as b,f as h,g as N}from"./SK2VBNAU.js";import{g as p}from"./
|
|
1
|
+
import{a as F,c as y,d as b,f as h,g as N}from"./SK2VBNAU.js";import{g as p}from"./NWNYJ26T.js";import{a as M,i as O,j as _}from"./FWD4L3CJ.js";import{a as A}from"./XSD5NL7J.js";import{getAddress as U,isAddress as W}from"viem";var j=O[M].pendle.marketFactory.address,q=O[M].pendle.router.address,J=600,Q=/^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/,X=/^(usd.*|dai|w?eth|oak)$/i,ee=t=>X.test(t.replace(/[._-]/g,"")),te=/^PT-(.+)-\d{1,2}[A-Za-z]{3}\d{4}$/,s=t=>{throw new A(`${t} Oak won't use this market.`)},r=()=>s("Oak couldn't read this Pendle market from the chain.");function S(t){return typeof t!="number"||!Number.isInteger(t)||t<0||t>36?s("A token in this market reports unusual decimals."):t}function $(t){return!Array.isArray(t)||t.some(e=>typeof e!="string"||!W(e,{strict:!1}))?r():[...new Set(t.map(e=>U(e)))]}async function B(t,e,c={}){let g=c.now??Math.floor(Date.now()/1e3),[u,o,a,f,l,E,D,P,x,I,v]=await N(t,[{address:j,abi:F,functionName:"isValidMarket",args:[e.market]},{address:e.market,abi:y,functionName:"readTokens"},{address:e.market,abi:y,functionName:"expiry"},{address:e.market,abi:y,functionName:"isExpired"},{address:e.market,abi:y,functionName:"readState",args:[q]},{address:e.sy,abi:b,functionName:"getTokensIn"},{address:e.sy,abi:b,functionName:"getTokensOut"},{address:e.sy,abi:b,functionName:"decimals"},{address:e.sy,abi:b,functionName:"exchangeRate"},{address:e.pt,abi:h,functionName:"decimals"},{address:e.pt,abi:h,functionName:"symbol"}]);if(!u.ok)return r();if(u.value!==!0)return s("This isn't a market the Pendle factory created.");if(!o.ok||!Array.isArray(o.value)||o.value.length!==3)return r();let[z,Y,Z]=o.value;if(!p(z,e.sy)||!p(Y,e.pt)||!p(Z,e.yt))return s("The market's tokens don't match what Pendle's service listed.");if(!a.ok||typeof a.value!="bigint"||!f.ok||typeof f.value!="boolean")return r();if(a.value!==BigInt(e.expiry))return s("The market's end date doesn't match what Pendle's service listed.");let T=f.value;if(T!==g>=e.expiry&&Math.abs(g-e.expiry)>J)return s("The chain and Oak's clock disagree about whether this market has ended.");if(!l.ok||typeof l.value?.lastLnImpliedRate!="bigint"||!P.ok||!I.ok||!x.ok||typeof x.value!="bigint"||!v.ok||typeof v.value!="string"||!E.ok||!D.ok)return r();let i=$(E.value),V=$(D.value);if(i.length===0||V.length===0)return s("This market lists no token to put in or take out.");let H=S(P.value),G=S(I.value),R=i.find(n=>p(n,_)),L=await N(t,i.flatMap(n=>[{address:n,abi:h,functionName:"symbol"},{address:n,abi:h,functionName:"decimals"}])),w=new Map(i.map((n,k)=>[n,{symbol:L[k*2],decimals:L[k*2+1]}])),m;if(R)m=R;else if(i.length===1)m=i[0];else{let n=te.exec(v.value)?.[1],k=i.filter(K=>{let C=w.get(K).symbol;return C.ok&&C.value===n});k.length===1&&(m=k[0])}if(!m)return s("Oak can't tell which token this market takes as input.");let d=w.get(m);return!d.symbol.ok||typeof d.symbol.value!="string"||!d.decimals.ok?r():!Q.test(d.symbol.value)||!R&&ee(d.symbol.value)?s("The market's token name looks unusual."):{verified:{market:e.market,sy:e.sy,pt:e.pt,yt:e.yt,expiry:e.expiry,expired:T,kind:R?"stable":"stock",inputToken:m,inputSymbol:d.symbol.value,inputDecimals:S(d.decimals.value),ptDecimals:G,syDecimals:H,tokensIn:i,tokensOut:V},ptSymbol:v.value,lnImpliedRate:l.value.lastLnImpliedRate,syExchangeRate:x.value}}async function oe(t,e,c={}){return(await B(t,e,c)).verified}async function de(t,e,c={}){let g=await Promise.allSettled(e.map(a=>B(t,a,c))),u=[],o=[];return g.forEach((a,f)=>{let l=e[f];a.status==="fulfilled"?u.push({row:l,facts:a.value}):o.push(`${l.market}: ${a.reason instanceof A?a.reason.message:"Oak couldn't check this market."}`)}),{ok:u,dropped:o}}export{B as a,oe as b,de as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as g}from"./X5V2Z2NM.js";import{a as m}from"./
|
|
1
|
+
import{a as g}from"./X5V2Z2NM.js";import{a as m}from"./43LI5NKJ.js";import{a as v}from"./66F5ZH34.js";import{e as A,g as u,i as b}from"./NWNYJ26T.js";import{a as l,i as x,s as y}from"./FWD4L3CJ.js";import{a as o}from"./XSD5NL7J.js";import{b as w}from"./JXOEJPJ4.js";import{Buffer as k}from"node:buffer";import{decodeEventLog as $}from"viem";var R="Profile contents and oak.registrar are mutable, self-asserted metadata, not registry-validated claims or proof of provenance.",B="oak.registrar",D="0x6f616b",L=v("Agent ID as a decimal uint256 integer string."),j={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},q={type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"32-byte hex value."},z={type:"string",pattern:"^0x([0-9a-fA-F]{2})*$"},T="0x0000000000000000000000000000000000000000";function h(t){let e=t.network??"mainnet",{chainId:n,identityRegistry:r}=y[e],s=e==="mainnet"?x[l].identity:void 0;return{network:e,chainId:n,registry:r,registryId:`eip155:${n}:${r}`,reputation:s?.reputationRegistry.address,validation:s?.validationRegistry.address}}function K(t){let{chainId:e,reputation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 reputation registry for this network.");return{chainId:e,address:n}}function V(t){let{chainId:e,validation:n}=h(t);if(!n)throw new o("Oak has no pinned ERC-8004 validation registry for this network.");return{chainId:e,address:n}}function Z(t){return u(t,T)}function G(t){if(typeof t!="string"||!/^[0-9]+$/.test(t)||t.length>78||BigInt(t)>=2n**256n)throw new o("Provide an agent ID as a decimal uint256 integer string.");return BigInt(t)}function J(t,e){return b(t,`Provide a valid ${e} address.`)}function Q(t,e){let n=h(t).chainId;if(e!==void 0&&e!==n)throw new o(`ERC-8004 actions are supported only on chain ${n}.`)}function X(t,e){if(typeof t!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t))throw new o(`Provide ${e} as 32-byte hex.`);return t.toLowerCase()}function I(t,e,n,r=!0){if(t===void 0){if(r)return"";throw new o(`Provide ${e}.`)}if(typeof t!="string"||!r&&!t.trim()||t.length>n||w(t))throw new o(`${e} must be plain text of at most ${n} characters.`);return t}function Y(t,e){if(typeof t!="string"||!t.trim()||t.length>2048)throw new o(`Provide a valid ${e}.`);try{let n=new URL(t);if(!["https:","ipfs:"].includes(n.protocol)||!n.hostname||n.username||n.password||w(t))throw new Error}catch{throw new o(`${e} must be an HTTPS or IPFS URI without credentials.`)}return t}function tt(t){let e=/^data:application\/json;base64,([A-Za-z0-9+/=]+)$/.exec(t);if(e)try{let n=JSON.parse(k.from(e[1],"base64").toString("utf8"));return A(n)?n:void 0}catch{return}}async function C(t,e,n,r,s=!0){let i=await t.preview(e,n),a=i.changes.map(({amount:d,token:f})=>{let c=d.startsWith("-");return`${c?"-":""}${t.formatAmount(c?d.slice(1):d,f.decimals)} ${f.symbol} (${f.address}, chain ${f.chainId})`});return{txs:e,summary:`${i.summary} ${a.join("; ")} ${s?`${R} `:""}${r}`}}async function et(t,e,n,r="update this profile"){let{chainId:s,registry:i}=h(t),a=t.clientFor(s),d=await a.readContract({address:i,abi:g,functionName:"ownerOf",args:[e]});if(m(d),u(d,n))return d;let[f,c]=await Promise.all([a.readContract({address:i,abi:g,functionName:"getApproved",args:[e]}),a.readContract({address:i,abi:g,functionName:"isApprovedForAll",args:[d,n]})]);if(m(f),typeof c!="boolean")throw new o("The registry returned invalid operator approval data.");if(!u(f,n)&&!c)throw new o(`Only the agent owner or an approved operator can ${r}.`);return d}async function nt(t,e,n){let{chainId:r,registry:s}=h(t),i=t.clientFor(r),a=await i.readContract({address:s,abi:g,functionName:"ownerOf",args:[e]});if(m(a),u(a,n))return a;if(await i.readContract({address:s,abi:g,functionName:"isApprovedForAll",args:[a,n]})!==!0)throw new o("Only the agent owner or an operator approved for all of its agents can change the token approval.");return a}async function H(t,e,n,r,s){let{chainId:i,registry:a}=h(t),d=s??a;if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new o("Provide the mined transaction hash.");let f=t.clientFor(i),c=await f.getTransactionReceipt({hash:e});if(!c)throw new o("The transaction is not mined yet. Try again after confirmation.");if(c.status!=="success"||!c.to||!u(c.to,d)||!u(c.from,n)||!u(c.transactionHash,e))throw new o("The receipt is not a successful matching registry transaction.");let p=await f.getTransaction({hash:e});if(p.chainId!==i||p.value!==0n||!p.to||!u(p.to,d)||!u(p.from,n))throw new o("The transaction does not match this chain, registry and wallet.");if(!(typeof r=="function"?typeof p.input=="string"&&r(p.input):typeof p.input=="string"&&u(p.input,r)))throw new o("The mined transaction calldata does not match the exact operation Oak built.");return c}function rt(t,e,n,r){let s=t.logs.filter(i=>u(i.address,e)&&!i.removed).flatMap(i=>{try{let a=$({abi:n,topics:i.topics,data:i.data,strict:!0});return a.eventName===r?[a.args]:[]}catch{return[]}});if(s.length!==1)throw new o(`The receipt must contain one matching ${r} event.`);return s[0]}function ot(t){let e=I(t,"metadata key",128,!1);if(e==="agentWallet")throw new o("The key agentWallet is reserved: use erc8004_set_wallet / erc8004_unset_wallet, which prove control of the wallet.");return e}function it(t){if(t.value===void 0==(t.text===void 0))throw new o("Provide exactly one of value (0x hex bytes) or text (UTF-8).");let e;if(t.value!==void 0){if(typeof t.value!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(t.value))throw new o("Metadata value must be 0x-prefixed hex bytes.");e=t.value}else{if(typeof t.text!="string")throw new o("Metadata text must be a string.");e=`0x${k.from(t.text,"utf8").toString("hex")}`}if((e.length-2)/2>4096)throw new o("Metadata values are limited to 4096 bytes.");return e}async function at(t,e,n,r){let{chainId:s}=h(t);if(n.transactionHash!==void 0){let a=await H(t,n.transactionHash,e,r.matcher??r.data,r.to);return r.verify(a)}await r.authority();let i=t.unsignedTx({to:r.to,data:r.data,value:"0",chainId:s,description:r.description});return C(t,[i],e,r.summary,!1)}export{R as a,B as b,D as c,L as d,j as e,q as f,z as g,h,K as i,V as j,Z as k,G as l,J as m,Q as n,X as o,I as p,Y as q,tt as r,C as s,et as t,nt as u,H as v,rt as w,ot as x,it as y,at as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as a,e as s,f as r,i,j as f}from"./
|
|
1
|
+
import{d as a,e as s,f as r,i,j as f}from"./64GOINYS.js";import{a as p}from"./XSD5NL7J.js";import{hashStruct as g}from"viem";var w={Order:[{name:"version",type:"string"},{name:"solverChainId",type:"string"},{name:"solver",type:"address"},{name:"salt",type:"uint256"},{name:"inputs",type:"Input[]"},{name:"output",type:"Output"},{name:"fees",type:"Fee[]"}],Input:[{name:"payment",type:"InputPayment"},{name:"refunds",type:"InputRefund[]"}],InputPayment:[{name:"chainId",type:"string"},{name:"currency",type:"bytes"},{name:"amount",type:"uint256"},{name:"weight",type:"uint256"}],InputRefund:[{name:"chainId",type:"string"},{name:"recipient",type:"bytes"},{name:"currency",type:"bytes"},{name:"minimumAmount",type:"uint256"},{name:"deadline",type:"uint32"},{name:"extraData",type:"bytes"}],Output:[{name:"chainId",type:"string"},{name:"payments",type:"OutputPayment[]"},{name:"deadline",type:"uint32"},{name:"calls",type:"bytes[]"},{name:"extraData",type:"bytes"}],OutputPayment:[{name:"recipient",type:"bytes"},{name:"currency",type:"bytes"},{name:"minimumAmount",type:"uint256"},{name:"expectedAmount",type:"uint256"}],Fee:[{name:"recipientChainId",type:"string"},{name:"recipient",type:"bytes"},{name:"currencyChainId",type:"string"},{name:"currency",type:"bytes"},{name:"amount",type:"uint256"}]};function A(I,l){let t=a(I);if(t.version!=="v1")throw new p("Relay order ID cannot be verified for this order version. Request a supported v1 quote.");let u=n=>{if(typeof n!="string"||!l.includes(n))throw new p("Relay order ID cannot be verified for an unknown or non-EVM chain.");return n},c=n=>{if(typeof n!="string"||!/^0x(?:[0-9a-fA-F]{2})*$/.test(n))throw new p("Relay order ID cannot be verified with malformed bytes.");return n},d=n=>{let e=f(n);if(e>4294967295)throw new p("Relay order deadline exceeds uint32. Request a new quote.");return e};if(typeof t.salt!="string"||!/^(?:0x[0-9a-fA-F]{1,64}|0|[1-9][0-9]*)$/.test(t.salt)||BigInt(t.salt)>=1n<<256n)throw new p("Relay order ID cannot be verified with an invalid salt.");let y=a(t.output);return g({types:w,primaryType:"Order",data:{version:t.version,solverChainId:u(t.solverChainId),solver:r(t.solver),salt:BigInt(t.salt),inputs:s(t.inputs).map(n=>{let e=a(n),o=a(e.payment);return{payment:{chainId:u(o.chainId),currency:r(o.currency),amount:BigInt(i(o.amount)),weight:BigInt(i(o.weight))},refunds:s(e.refunds).map(h=>{let m=a(h);return{chainId:u(m.chainId),recipient:r(m.recipient),currency:r(m.currency),minimumAmount:BigInt(i(m.minimumAmount)),deadline:d(m.deadline),extraData:c(m.extraData)}})}}),output:{chainId:u(y.chainId),payments:s(y.payments).map(n=>{let e=a(n);return{recipient:r(e.recipient),currency:r(e.currency),minimumAmount:BigInt(i(e.minimumAmount)),expectedAmount:BigInt(i(e.expectedAmount))}}),deadline:d(y.deadline),calls:s(y.calls).map(c),extraData:c(y.extraData)},fees:s(t.fees).map(n=>{let e=a(n);return{recipientChainId:u(e.recipientChainId),recipient:r(e.recipient),currencyChainId:u(e.currencyChainId),currency:r(e.currency),amount:BigInt(i(e.amount))}})}})}export{A as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./
|
|
1
|
+
import{a as k}from"./66F5ZH34.js";import{c as l}from"./NWNYJ26T.js";import{a as p}from"./FWD4L3CJ.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as H,getAddress as m,parseAbi as f,zeroAddress as w}from"viem";var x=f(["function tokenizations(address token) view returns ((address creator,address forwarder,bytes32 marketFamilyId,uint64 createdAt))"]),S=f(["function tokenizations(address token) view returns ((address creator,uint8 way,address forwarder,address adapter,address door,bytes32 familyId,bytes32 marketFamilyId,uint64 unlockBlock,uint16 legBps))"]),b=f(["function name() view returns (string)","function symbol() view returns (string)","function decimals() view returns (uint8)","function balanceOf(address account) view returns (uint256)","function totalSupply() view returns (uint256)","function assetCount() view returns (uint256)","function claimable(address account,uint256 asset) view returns (uint256)","function streamSeconds() view returns (uint32)","function tipBps() view returns (uint16)","function doorCount() view returns (uint256)","function dropBox() view returns (address)","function bridge() view returns (address)","function claim(uint256 asset,address to) returns (uint256 amount)","function claimAll(address to) returns (uint256[] amounts)","function sync() returns (uint256 tip)","function syncRange(uint256 start,uint256 count) returns (uint256 tip)","function syncSome(uint256[] doorIds) returns (uint256 tip)"]),C=f(["function dropCount() view returns (uint256)","function claimable(uint256 dropId,address holder) view returns (uint256)","function claim(uint256[] dropIds,address to) returns (uint256[] amounts)"]),y=["0x522723A7a09684515881568Ab8247f3846D66F43","0xfb3c1501c727f30883cd7B36Ec380381af7412Ef"].map(m),I={token:b,drops:C};function O(n){return{type:"object",properties:Object.fromEntries(n.inputs.map(t=>[t.name,t.type==="address"?l:t.type==="uint256[]"?{type:"array",items:k(),maxItems:128}:k()])),required:n.inputs.map(t=>t.name),additionalProperties:!1}}function h(n){return Object.entries(I).flatMap(([t,o])=>o.filter(r=>r.stateMutability==="view"===n).map(r=>({target:t,fn:r})))}function v(n){return{type:"object",oneOf:h(n).map(({target:t,fn:o})=>({type:"object",properties:{token:l,target:{const:t},function:{const:o.name},params:O(o)},required:["token","target","function","params"],additionalProperties:!1}))}}function A(n,t){if(Object.keys(n).length!==4||Object.keys(n).some(e=>!["token","target","function","params"].includes(e)))throw new s("Provide token, target, function and params for the Hookr revenue operation.");let o=h(t).find(e=>e.target===n.target&&e.fn.name===n.function);if(!o||!n.params||typeof n.params!="object"||Array.isArray(n.params))throw new s("Choose a documented Hookr revenue function and parameter object.");let r;try{r=m(String(n.token))}catch{throw new s("Provide a valid Hookr revenue token address.")}let i=n.params,a=o.fn;if(Object.keys(i).length!==a.inputs.length||Object.keys(i).some(e=>!a.inputs.some(u=>u.name===e)))throw new s("Provide exactly the documented Hookr revenue parameters.");let c=e=>{if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new s("Revenue token indices and amounts must be decimal base-unit strings.");return BigInt(e)},d=a.inputs.map(e=>{let u=i[e.name];if(e.type==="address")try{return m(String(u))}catch{throw new s("Provide a valid Hookr revenue address.")}if(e.type==="uint256[]"){if(!Array.isArray(u)||u.length>128)throw new s("Provide at most 128 Hookr revenue indices.");return u.map(c)}return c(u)});return{token:r,fn:a,values:d,operation:o}}async function g(n,t,o){let r=n.clientFor(p),i;for(let c of y){let d=c===y[0],e=await r.readContract({address:c,abi:d?x:S,functionName:"tokenizations",args:[t]});if(!e||typeof e.creator!="string"||d&&(!("createdAt"in e)||typeof e.createdAt!="bigint"||e.createdAt<0n||e.createdAt>=1n<<64n))throw new s("Hookr token provenance is unavailable.");if(m(e.creator)!==w&&(!d||"createdAt"in e&&e.createdAt>0n)){i=c;break}}if(!i)throw new s("This token has no record on a pinned Hookr tokenizer.");let a=o?m(await r.readContract({address:t,abi:b,functionName:"dropBox"})):t;if(a===w)throw new s("Hookr revenue drop box is unavailable.");return{to:a,tokenizer:i}}async function j(n,t,o){if(n.network==="testnet")throw new s("Hookr revenue actions require mainnet, chain 4663.");let{token:r,fn:i,values:a}=A(t,!1),{to:c}=await g(n,r,t.target==="drops"),d=i.inputs.findIndex(e=>e.name==="to");if(d>=0&&[w,r,c].includes(a[d]))throw new s("Choose a valid revenue claim recipient.");return{txs:[n.unsignedTx({chainId:p,to:c,value:"0",data:H({abi:[i],functionName:i.name,args:a}),description:`Hookr revenue ${t.target}.${i.name}: ${JSON.stringify(t.params)}. No token approval or principal deposit.`})],inputs:[]}}function T(n){return[{name:"hookr_revenue_read",inputSchema:{...v(!0),description:"Read a registered Hookr revenue token or its derived drop box: balance, claimable, terms and indices. Checks tokenizer provenance on chain."},execute:async t=>{let{token:o,fn:r,values:i}=A(t,!0),{to:a,tokenizer:c}=await g(n,o,t.target==="drops"),d=await n.clientFor(p).readContract({address:a,abi:[r],functionName:r.name,args:i});return{chainId:p,token:o,tokenizer:c,contract:a,function:r.name,result:JSON.parse(JSON.stringify(d,(e,u)=>typeof u=="bigint"?u.toString():u))}}},{name:"hookr_revenue_action",inputSchema:{...v(!1),description:"Preview holder income/drop claims or permissionless sync/syncRange/syncSome on a registered Hookr revenue token. No approvals; local human confirmation required. Claims and syncs are separate actions."},execute:async(t,o)=>{let{txs:r}=await j(n,t,o),i=await n.preview(r,o);return{txs:r,preview:i,summary:`Hookr revenue ${t.function}; verify receipt and holder balances after confirmation.`}}}]}export{y as a,j as b,T as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{e as P,h as A,n as S}from"./IPN6Z4JM.js";import{a as N,b as h,f as y,g as v}from"./PIIHOXWF.js";import{N as k,b as I}from"./2THSW4QN.js";import{a as b}from"./66F5ZH34.js";import{c as w,g}from"./NWNYJ26T.js";import{a as m}from"./FWD4L3CJ.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as f,parseAbi as T,zeroAddress as _}from"viem";var i=T(["function ownerOf(uint256) view returns (address)","function getApproved(uint256) view returns (address)","function getPositionLiquidity(uint256) view returns (uint128)","function safeTransferFrom(address from,address to,uint256 tokenId)","function approve(address spender,uint256 tokenId)","function burn(uint256 tokenId)"]),q={version:{type:"string",enum:["v3","v4"]},tokenId:b(),operation:{type:"string",enum:["transfer","approve","revoke","burn"]},target:w};function D(s){return{tools:[!1,!0].map(c=>({name:c?"uniswap_position_manage":"uniswap_position_status",inputSchema:{type:"object",additionalProperties:!1,required:c?["version","tokenId","operation"]:["version","tokenId"],properties:q},async execute(e,p){if(e.version!=="v3"&&e.version!=="v4")throw new r("Specify position version v3 or v4.");let o=N(e.tokenId,"tokenId"),a=e.version==="v3"?P.positionManager:I,d=s.clientFor(m),l=await d.readContract({address:a,abi:i,functionName:"ownerOf",args:[o]});if(!c){v(e,["version","tokenId"]);let n=await d.readContract({address:a,abi:i,functionName:"getApproved",args:[o]});return{version:e.version,tokenId:o.toString(),manager:a,owner:l,approved:n}}if(!g(l,p))throw new r("Only manage a Uniswap NFT owned by the signing wallet.");let t=e.operation;v(e,["version","tokenId","operation",...["transfer","approve"].includes(String(t))?["target"]:[]]);let u;if(t==="transfer"||t==="approve"){let n=h(e.target);if(n===_)throw new r("Choose a nonzero target, or operation revoke to clear approval.");u=t==="transfer"?f({abi:i,functionName:"safeTransferFrom",args:[p,n,o]}):f({abi:i,functionName:"approve",args:[n,o]})}else if(t==="revoke")u=f({abi:i,functionName:"approve",args:[_,o]});else if(t==="burn"){if(e.version==="v4"){if(await d.readContract({address:a,abi:i,functionName:"getPositionLiquidity",args:[o]})!==0n)throw new r("Remove all liquidity before burning an empty position.");return k(s).tools.find(O=>O.name==="uniswap_remove").execute({version:"v4",tokenId:o.toString(),liquidity:"all",amount0Min:"0",amount1Min:"0"},p)}let n=S(await d.readContract({address:a,abi:A,functionName:"positions",args:[o]}));if(n.liquidity!==0n||n.tokensOwed0!==0n||n.tokensOwed1!==0n)throw new r("Remove liquidity and collect all owed tokens before burning a v3 NFT.");u=f({abi:i,functionName:"burn",args:[o]})}else throw new r("Choose transfer, approve, revoke or burn. Operator-wide approvals are not exact approvals.");return y(s,[s.unsignedTx({to:a,data:u,value:"0",chainId:m,description:`${t} Uniswap ${e.version} NFT #${o}${e.target?` with target ${e.target}`:""}.`})],p,"Position ownership or exact per-NFT approval changes. A transferred position includes its liquidity and accrued rights; burn requires an empty NFT.")}}))}}export{i as a,D as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{b as d}from"./IX3GZMTM.js";import{a as o}from"./XSD5NL7J.js";import{getAddress as w,isAddress as c,zeroAddress as g}from"viem";var u="^0x[0-9a-fA-F]{40}$",m=new RegExp(u),y={type:"string",pattern:u},R="Provide a valid contract or wallet address.";function a(n){return n!==null&&typeof n=="object"&&!Array.isArray(n)}function h(n,t){if(!a(n))throw new o(t);return n}function A(n,t){return n.toLowerCase()===t.toLowerCase()}function S(n,t){return typeof n=="string"&&typeof t=="string"&&A(n,t)}function s(n,t,r){if(typeof n!="string")throw new o(t);if(!c(n,{strict:!1}))throw new o(r);return n}function E(n,t,r=t){return w(s(n,t,r))}function D(n,t,r=t){return s(n,t,r).toLowerCase()}function T(n,t,r=t){return s(n,t,r)}function L(n,t){if(n.toLowerCase()===g)throw new o(t);return n}function B(n,t){if(typeof n!="bigint"||n<0n||n>=1n<<256n)throw new o(t);return n}function C(n,t,r={}){let{notString:i,bits:f=256,positive:p=!1}=r;if(i!==void 0&&typeof n!="string")throw new o(i);let e=d(n);if(e>=1n<<BigInt(f)||p&&e===0n)throw new o(t);return e}export{u as a,m as b,y as c,R as d,a as e,h as f,A as g,S as h,E as i,D as j,T as k,L as l,B as m,C as n};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A}from"./
|
|
1
|
+
import{a as A}from"./RTGS7RIO.js";import{a,b as g,c as b,e as w,f as x,g as h}from"./PIIHOXWF.js";import{a as r}from"./66F5ZH34.js";import{c as y}from"./NWNYJ26T.js";import{a as m}from"./FWD4L3CJ.js";import{a as i}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as B,encodePacked as T,erc20Abi as I,getAddress as q,parseAbi as C,parseAbiParameters as N,zeroAddress as R}from"viem";var O=q("0x0000ffffbe8efe702c8703ae3477ff5de3d319c0"),$=N("(address currency,address tokensRecipient,address fundsRecipient,uint64 startBlock,uint64 endBlock,uint64 claimBlock,uint256 tickSpacing,address validationHook,uint256 floorPrice,uint128 requiredCurrencyRaised,bytes auctionStepsData)"),P=C(["function create(address token,uint256 amount,bytes configData,bytes32 salt) returns (address)","function getAddress(address token,uint256 amount,bytes configData,bytes32 salt,address sender) view returns (address)"]),Q=C(["function distributeToken(address token,(address strategy,uint128 amount,bytes configData) distribution,bytes32 salt) payable"]),v={token:y,amount:r(),currency:y,startBlock:r(),endBlock:r(),claimBlock:r(),tickSpacing:r(),floorPrice:r(),requiredCurrencyRaised:r(),salt:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},steps:{type:"array",minItems:1,maxItems:100,items:{type:"object",additionalProperties:!1,required:["mps","duration"],properties:{mps:r(),duration:r()}}}};function D(e,t){let s=a(e.startBlock,"startBlock",64),o=a(e.endBlock,"endBlock",64),c=a(e.claimBlock,"claimBlock",64);if(o<=s||c<o)throw new i("Auction needs startBlock < endBlock <= claimBlock.");if(!Array.isArray(e.steps)||e.steps.length<1||e.steps.length>100)throw new i("Provide 1 to 100 issuance steps.");let u="0x",p=0n,l=0n;for(let d of e.steps){if(!d||typeof d!="object"||Array.isArray(d))throw new i("Each step requires mps and duration decimal strings.");h(d,["mps","duration"]);let n=d,k=a(n.mps,"mps",24,!0),f=a(n.duration,"duration",40);u=`${u}${T(["uint24","uint40"],[Number(k),Number(f)]).slice(2)}`,l+=k*f,p+=f}if(l!==10000000n||p!==o-s)throw new i("Issuance must total exactly 10000000 MPS and its durations must equal endBlock - startBlock.");return S($,[{currency:b(e.currency),tokensRecipient:t,fundsRecipient:t,startBlock:s,endBlock:o,claimBlock:c,tickSpacing:a(e.tickSpacing,"tickSpacing"),validationHook:R,floorPrice:a(e.floorPrice,"floorPrice"),requiredCurrencyRaised:a(e.requiredCurrencyRaised??"0","requiredCurrencyRaised",128,!0),auctionStepsData:u}])}function U(e){return{tools:[{name:"uniswap_create_auction",inputSchema:{type:"object",additionalProperties:!1,required:["token","amount","currency","startBlock","endBlock","claimBlock","tickSpacing","floorPrice","steps","salt"],properties:v},async execute(t,s){h(t,Object.keys(v));let o=g(t.token),c=a(t.amount,"amount",128);if(o===R||o===b(t.currency))throw new i("Auction sale token must be an ERC-20 distinct from its payment currency.");let u=D(t,s);if(typeof t.salt!="string"||!/^0x[0-9a-fA-F]{64}$/.test(t.salt))throw new i("Provide a 32-byte deployment salt.");let p=t.salt,l=e.clientFor(m),d=await l.getBlockNumber();if(BigInt(String(t.startBlock))<=d)throw new i("Choose a future auction startBlock with time for confirmation and approvals.");let n=await l.readContract({address:A,abi:P,functionName:"getAddress",args:[o,c,u,p,s]});if((await l.getCode({address:n})??"0x")!=="0x")throw new i("This auction already exists; choose a fresh salt or configuration.");let k=await w(e,o),f=[e.unsignedTx({to:A,data:B({abi:P,functionName:"create",args:[o,c,u,p]}),value:"0",chainId:m,description:`Create CCA ${n}; proceeds and unsold tokens go to ${s}.`}),e.unsignedTx({to:o,data:B({abi:I,functionName:"transfer",args:[n,c]}),value:"0",chainId:m,description:`Fund the factory-predicted auction ${n} with exactly ${c} base units of ${o}.`}),e.unsignedTx({to:n,data:B({abi:C(["function onTokensReceived()"]),functionName:"onTokensReceived"}),value:"0",chainId:m,description:`Activate CCA ${n} after its sale tokens arrive.`})];return{...await x(e,f,s,"Create/fund/activate a standalone CCA in three separately confirmed transactions, not an LBP-managed liquidity launch. If interrupted, inspect the predicted address and journal before recovery; do not transfer tokens twice. Raw prices are payment-base-units per sale-token-base-unit in Q96. No validation hook or off-chain signature; all proceeds and unsold tokens go to the signing wallet."),auction:n,sale:{token:k,amount:c.toString()}}}}]}}export{O as a,$ as b,P as c,Q as d,D as e,U as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as P,f as o,g as S,h as f,i as g,k as h,l as q,o as I,r as R}from"./
|
|
1
|
+
import{e as P,f as o,g as S,h as f,i as g,k as h,l as q,o as I,r as R}from"./46KWRAYK.js";import{h as O}from"./NWNYJ26T.js";import{isDeepStrictEqual as D}from"node:util";import{pad as F,zeroHash as w}from"viem";var L=["order","cancel","withdraw","convert","signer","referral"],A={nonce:"uint64",signedAt:"uint64"},M={sender:"address",subaccount:"bytes32"},_=["type","side","onchainId","quantity","price","timeInForce","postOnly","reduceOnly","close","clientOrderId","stopPrice","stopType","expiresAt","groupId","groupContingencyType"],j={order:_,cancel:["all","orderIds","clientOrderIds"],withdraw:["token","tokenId","amount"],convert:["fromToken","toToken","amount"],signer:["mode","signer"],referral:["mode","code","cursor","limit"]};function G(n){let e=n.replace(/^meridian_perps_/,"");return L.includes(e)||o("Unsupported Meridian perps action."),e}function $(n,e){let d=[...j[n],"subaccount","subaccountId","continuation","signature"];Object.keys(e).some(s=>!d.includes(s))&&o("Unsupported Meridian perps arguments; use the tool schema."),q(e.subaccount),n!=="referral"&&!(n==="signer"&&e.mode==="extend")&&h(e.subaccountId)}function v(n,e=!1){(!Array.isArray(n)||n.length<1||n.length>200)&&o("Provide between 1 and 200 unique order identifiers.");let d=n.map(s=>e?C(s):h(s));return new Set(d).size!==d.length&&o("Do not repeat Meridian order identifiers."),d}function C(n){return(typeof n!="string"||!(/^[a-z0-9]{1,32}$/i.test(n)||/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(n)))&&o("Provide an alphanumeric clientOrderId of at most 32 characters or a UUID."),n}function b(n,e){return(typeof n!="number"||!Number.isSafeInteger(n)||n<0||n>e)&&o("Provide a valid integer Meridian order option."),n}function x(n,e=!1){return n===void 0?e:(typeof n!="boolean"&&o("Provide Meridian order flags as booleans."),n)}function z(n,e,d,s,c){$(n,e),f(s,"the signing nonce",!1,64),b(c,Number.MAX_SAFE_INTEGER);let m=q(e.subaccount),t={sender:d,subaccount:m,nonce:s,signedAt:c};if(n==="order"){e.type!=="MARKET"&&e.type!=="LIMIT"&&o("Choose a MARKET or LIMIT Meridian order.");let i=f(e.quantity,"the D9 order quantity",!1,128),u=x(e.reduceOnly),a=x(e.close);(a?i!=="0"||!u:i==="0")&&o('Close orders require quantity "0" and reduceOnly true; other orders require a positive quantity.'),a&&e.type!=="MARKET"&&o("A full Meridian position close requires a MARKET order.");let T=b(e.onchainId,4294967295);T||o("Choose a nonzero Meridian product onchainId.");let k=b(e.side,1);Object.assign(t,{type:e.type,quantity:I(i),reduceOnly:u,close:a,onchainId:T,side:k,engineType:0});let E=e.type==="LIMIT"?f(e.price,"the D9 limit price",!0,128):"0";if(e.type==="LIMIT"){["GTD","IOC","FOK"].includes(String(e.timeInForce))||o("Choose GTD, IOC or FOK for a limit order.");let p=x(e.postOnly);p&&e.timeInForce!=="GTD"&&o("Post-only requires GTD."),Object.assign(t,{price:I(E),timeInForce:e.timeInForce,postOnly:p})}else["price","timeInForce","postOnly"].some(p=>e[p]!==void 0)&&o("Market orders omit price, timeInForce and postOnly.");if(e.clientOrderId!==void 0&&(t.clientOrderId=C(e.clientOrderId)),(e.stopPrice!==void 0||e.stopType!==void 0)&&(t.stopPrice=I(f(e.stopPrice,"the D9 stop price",!0,128)),t.stopType=b(e.stopType,1)),e.expiresAt!==void 0){let p=Number(f(e.expiresAt,"the order expiry",!0,64));(!Number.isSafeInteger(p)||p<=c||p>c+6652800)&&o("Order expiry must be in the next 77 days."),t.expiresAt=p}return(e.groupId!==void 0||e.groupContingencyType!==void 0)&&(t.groupId=h(e.groupId),t.groupContingencyType=b(e.groupContingencyType,1)),{path:"/v1/order",method:"POST",data:t,primaryType:"TradeOrder",fields:{...M,quantity:"uint128",price:"uint128",reduceOnly:"bool",side:"uint8",engineType:"uint8",productId:"uint32",...A},message:{sender:d,subaccount:m,quantity:i,price:E,reduceOnly:u,side:k,engineType:0,productId:T,nonce:s,signedAt:c}}}if(n==="cancel"){delete t.signedAt;let i=x(e.all);return i&&(e.orderIds!==void 0||e.clientOrderIds!==void 0)&&o("Cancel-all omits order ID arrays."),i||(e.orderIds!==void 0&&(t.orderIds=v(e.orderIds)),e.clientOrderIds!==void 0&&(t.clientOrderIds=v(e.clientOrderIds,!0)),((t.orderIds??[]).length+(t.clientOrderIds??[]).length>200||!t.orderIds&&!t.clientOrderIds)&&o("Target between 1 and 200 order IDs, or choose all.")),{path:`/v1/order/${i?"cancel-all":"cancel"}`,method:"POST",data:t,primaryType:"CancelOrder",fields:{...M,nonce:"uint64"},message:{sender:d,subaccount:m,nonce:s}}}if(n==="withdraw"){let i=g(e.token),u=f(e.amount,"the D9 withdrawal amount",!0),a=F(d);return{path:`/v1/token/${h(e.tokenId)}/withdraw`,method:"POST",data:{account:d,subaccount:m,token:i,amount:I(u),lzDestinationAddress:a,lzDestinationEid:0,nonce:s,signedAt:c},primaryType:"InitiateWithdraw",fields:{account:"address",subaccount:"bytes32",token:"address",amount:"uint256",...A,destinationAddress:"bytes32",destinationEndpointId:"uint32"},message:{account:d,subaccount:m,token:i,amount:u,nonce:s,signedAt:c,destinationAddress:a,destinationEndpointId:0}}}if(n==="convert"){let i=g(e.fromToken),u=g(e.toToken);O(i,u)&&o("Choose two different compatible quote-token pools.");let a=f(e.amount,"the D9 conversion amount",!0,128);return Object.assign(t,{fromToken:i,toToken:u,amount:I(a)}),{path:"/v1/token/convert",method:"POST",data:t,primaryType:"ConvertToken",fields:{...M,fromToken:"address",toToken:"address",amount:"uint128",...A},message:{...t,amount:a}}}if(n==="signer"){["revoke","refresh","extend"].includes(String(e.mode))||o("Choose revoke, refresh or extend. Linking a new signer requires two local signatures and is not available in Oak.");let i=e.mode,u=i==="extend"?d:g(e.signer);i==="extend"&&e.signer!==void 0&&!O(e.signer,d)&&o("Only this local signer can extend itself.");let a=i==="revoke"?"RevokeLinkedSigner":i==="refresh"?"RefreshLinkedSigner":"ExtendLinkedSigner",T={sender:d,...i!=="extend"?{signer:u}:{},...i==="revoke"?{subaccount:m}:{},nonce:s,signedAt:c},k={sender:"address",...i!=="extend"?{signer:"address"}:{},...i==="revoke"?{subaccount:"bytes32"}:{},...A};return{path:`/v1/linked-signer/${i}`,method:i==="revoke"?"DELETE":"POST",data:i==="extend"?{sender:d,nonce:s,signedAt:c}:{...t,subaccountId:h(e.subaccountId),signer:u},primaryType:a,fields:k,message:T}}let r=e.mode;["activate","claim","summary","history"].includes(String(r))||o("Choose activate, claim, summary or history for Meridian referrals."),(r==="claim"?typeof e.code!="string"||!/^[A-Z0-9]{12}$/.test(e.code):e.code!==void 0)&&o("A referral claim needs a 12-character uppercase alphanumeric code; other referral modes omit code.");let l=r==="activate"?0:r==="claim"?1:2,y={sender:d,intent:l,signedAt:c};return{path:r==="history"?"/v1/referral":`/v1/referral/${r}`,method:l===2?"GET":"POST",data:r==="claim"?{...y,code:e.code}:y,primaryType:"EIP712Auth",fields:{sender:"address",intent:"uint8",signedAt:"uint64"},message:y}}function K(n,e){return{domain:{...P},primaryType:n.primaryType,types:R(e,n.primaryType,n.fields),message:n.message}}function H(n,e,d,s,c,m,t){let r=S(c);(m||r.stage!=="perps_sign"||!O(r.wallet,d)||r.chainId!==4663||typeof r.requestId!="string"||!r.requestId||typeof r.expiresAt!="number"||r.expiresAt<=t||r.expiresAt>t+120||typeof r.signedAt!="number"||r.signedAt>t+10||r.signedAt<t-120)&&o("Meridian perps signing round is invalid or expired.");let l=z(G(n),e,d,f(r.nonce,"the nonce",!1,64),r.signedAt),y=K(l,S(r.signatureTypes));(!D(r.request,y)||!D(s,[{kind:"typedData",request:y}]))&&o("Meridian perps signing terms differ from the local request."),(!D(r.data,l.data)||r.path!==l.path||r.method!==l.method)&&o("Meridian perps API terms differ from the local request.")}var W=w;export{L as a,j as b,G as c,$ as d,z as e,K as f,H as g,W as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{f as l,h as x,i as h}from"./
|
|
1
|
+
import{f as l,h as x,i as h}from"./64GOINYS.js";import{g}from"./NWNYJ26T.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as y,erc20Abi as O,getAddress as f,parseAbi as R}from"viem";var P=[{chainId:1,vault:"0x57b68c4ea221ee8da6eb14ebdfccee5177567771",asset:"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",gateway:"0xed8a2a23bf9d6818651527daaf3bf4ffeb53945f"},{chainId:42161,vault:"0xc7273772b87860097373d91b3880fd4cc61fba2d",asset:"0x82af49447d8a07e3bd95bd0d56f35241523fbab1",gateway:"0x67defe8d90c8cd013fd527669e76e0be420f1208"}].map(t=>({chainId:t.chainId,vault:f(t.vault),asset:f(t.asset),gateway:f(t.gateway)})),T=R(["function balanceOf(address) view returns (uint256)","function asset() view returns (address)","function yieldPool() view returns (address)","function maxWithdraw(address) view returns (uint256)","function convertToAssets(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function redeem(uint256,address,address) returns (uint256)","function withdraw(uint256,address,address) returns (uint256)"]),$=R(["function redeem(address,uint256,address,uint256) returns (uint256)","function withdraw(address,uint256,address,uint256) returns (uint256)"]),I={type:"string",pattern:"^[1-9][0-9]*$"},A={type:"integer",enum:[1,42161]};function S(t){let o=P.find(i=>i.chainId===x(t));if(!o)throw new r("Relay legacy vault exits support Ethereum (1) and Arbitrum (42161).");return o}function b(t){let o=h(t);if(o==="0")throw new r("Provide a positive Relay vault amount or limit.");return o}function E(t,o){let i=S(t.chainId),s=f(l(o));if(Object.keys(t).some(c=>!["chainId","mode","amount","native","minAssetsOut","maxSharesIn"].includes(c)))throw new r("Provide only the documented Relay vault exit arguments.");if(t.mode!=="redeem"&&t.mode!=="withdraw")throw new r("Choose redeem (shares) or withdraw (WETH amount).");if(t.native!==void 0&&typeof t.native!="boolean")throw new r("Provide native as a boolean.");let e=b(t.amount),n=t.native===!0,a=t.mode==="redeem";if(!a&&!n)throw new r("Direct WETH withdrawals cannot enforce maxSharesIn on-chain. Use native withdraw or redeem a fixed number of shares.");if(t.minAssetsOut!==void 0&&(!n||!a)||t.maxSharesIn!==void 0&&a)throw new r("minAssetsOut applies only to native redeem; maxSharesIn applies only to withdraw.");let d=n&&a?b(t.minAssetsOut):void 0,u=a?e:b(t.maxSharesIn),w=(c,v,p)=>({to:c,data:v,chainId:i.chainId,value:"0",description:p}),m=[];return n?(m.push(w(i.vault,y({abi:O,functionName:"approve",args:[i.gateway,BigInt(u)]}),`Approve exactly ${u} WETH-REL share base units for the Relay native gateway.`)),m.push(w(i.gateway,y({abi:$,functionName:t.mode,args:[i.vault,BigInt(e),s,BigInt(a?d:u)]}),`Relay legacy vault ${t.mode} to native ETH for ${s}.`))):m.push(w(i.vault,y({abi:T,functionName:t.mode,args:[BigInt(e),s,s]}),`Relay legacy vault ${t.mode} to WETH for ${s}.`)),{pin:i,txs:m,wallet:s,redeem:a,native:n,amount:e,maxSharesIn:u,minAssetsOut:d}}function C(t,o,i){let s=E(o,i).txs;if(t.length!==s.length||t.some((e,n)=>e.chainId!==s[n].chainId||l(e.to)!==l(s[n].to)||e.value!=="0"||!g(e.data,s[n].data)))throw new r("Relay vault transactions differ from the requested exit.")}var H=t=>{async function o(i,s){let e=S(i),n;try{n=t.clientFor(e.chainId)}catch(c){throw/No RPC URL configured for chain/.test(t.plainError(c))?new r(`Relay legacy vault reads and exits on chain ${e.chainId} need an RPC. Ask the operator to configure OAK_RPC_URL_${e.chainId} on the server. No vault balances were checked.`):c}if(await n.getChainId()!==e.chainId)throw new r("The RPC chain does not match the Relay vault chain.");let a=(c,v,p=[])=>n.readContract({address:c,abi:T,functionName:v,args:p});if(l(await a(e.vault,"asset"))!==l(e.asset))throw new r("Relay vault asset does not match the pinned WETH.");let d=h(String(await a(e.vault,"balanceOf",[s]))),u=f(l(await a(e.vault,"yieldPool"))),w=h(String(await a(e.vault,"convertToAssets",[BigInt(d)]))),m=h(String(await a(u,"maxWithdraw",[e.vault])));return{pin:e,shares:d,assets:w,liquidAssets:m,read:a}}return{tools:[{name:"relay_vault_status",inputSchema:{type:"object",description:"Read legacy vault shares and shared liquidity. Requires server OAK_RPC_URL_1 or OAK_RPC_URL_42161 for the selected chain; no API key. New deposits are unsupported.",additionalProperties:!1,required:["chainId"],properties:{chainId:A}},execute:async(i,s)=>{if(Object.keys(i).some(u=>u!=="chainId"))throw new r("Provide only the Relay vault chainId.");let{pin:e,shares:n,assets:a,liquidAssets:d}=await o(i.chainId,s);return{chainId:e.chainId,vault:e.vault,shares:{token:{address:e.vault,chainId:e.chainId,symbol:"WETH-REL",decimals:18},amount:n},assets:{token:{address:e.asset,chainId:e.chainId,symbol:"WETH",decimals:18},amount:a},liquidAssets:d,summary:"Relay legacy vault wind-down: new deposits are unsupported. Available yield-pool liquidity is shared by all LPs and may change. Withdraw with relay_vault_withdraw; gas is paid in ETH on the vault chain."}}},{name:"relay_vault_withdraw",inputSchema:{type:"object",additionalProperties:!1,required:["chainId","mode","amount"],properties:{chainId:A,mode:{type:"string",enum:["redeem","withdraw"]},amount:I,native:{type:"boolean"},minAssetsOut:I,maxSharesIn:I}},execute:async(i,s)=>{let e=E(i,s),n=await o(i.chainId,s),a=e.redeem?e.amount:h(String(await n.read(e.pin.vault,"previewWithdraw",[BigInt(e.amount)]))),d=e.redeem?h(String(await n.read(e.pin.vault,"previewRedeem",[BigInt(e.amount)]))):e.amount;if(BigInt(a)>BigInt(n.shares)||BigInt(a)>BigInt(e.maxSharesIn))throw new r("Relay vault exit exceeds your shares or maxSharesIn.");if(BigInt(d)>BigInt(n.liquidAssets))throw new r("Relay vault liquidity is insufficient. Withdraw less or retry when liquidity returns.");if(e.minAssetsOut!==void 0&&BigInt(d)<BigInt(e.minAssetsOut))throw new r("Relay vault output is below minAssetsOut.");let u=await t.preview(e.txs,s);return{txs:e.txs,preview:u,chainId:e.pin.chainId,expectedAssets:d,expectedShares:a,summary:`Relay legacy vault exit on chain ${e.pin.chainId}: ${a} share base units for about ${d} ${e.native?"ETH":"WETH"} base units (18 decimals), to ${e.wallet}. ${e.minAssetsOut?`Gateway minimum ${e.minAssetsOut}.`:e.redeem?"Direct ERC-4626 redeem has no calldata minimum output.":`Gateway maximum input ${e.maxSharesIn} share base units.`} Review the local preview and confirm before signing. No destination bridge or future yield is promised.`}}}]}};export{P as a,E as b,C as c,H as d};
|