@oakagentkit/core 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dist/api/addresses.d.ts +93 -0
- package/build/dist/api/addresses.js +1 -1
- package/build/dist/api/chain.js +1 -1
- package/build/dist/api/history.js +1 -1
- package/build/dist/api/identity-link.js +1 -1
- package/build/dist/api/metadata.js +1 -1
- package/build/dist/api/modules/beefy/boosts.js +1 -1
- package/build/dist/api/modules/beefy/clm.js +1 -1
- package/build/dist/api/modules/beefy/guard.js +1 -1
- package/build/dist/api/modules/beefy/index.js +1 -1
- package/build/dist/api/modules/beefy/liquidity.js +1 -1
- package/build/dist/api/modules/beefy/management.js +1 -1
- package/build/dist/api/modules/beefy/vaults.js +1 -1
- package/build/dist/api/modules/clanker/extensions.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/clanker/manage.js +1 -1
- package/build/dist/api/modules/clanker/pool-config.js +1 -1
- package/build/dist/api/modules/clanker/protocol.js +1 -1
- package/build/dist/api/modules/clanker/state.js +1 -1
- package/build/dist/api/modules/erc8004/common.js +1 -1
- package/build/dist/api/modules/erc8004/domain.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/erc8004/management.js +1 -1
- package/build/dist/api/modules/erc8004/reputation.js +1 -1
- package/build/dist/api/modules/erc8004/services.js +1 -1
- package/build/dist/api/modules/erc8004/validation.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/backoff.d.ts +6 -0
- package/build/dist/api/modules/heyresearch/backoff.js +1 -0
- package/build/dist/api/modules/heyresearch/builder-feed.d.ts +62 -0
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -0
- package/build/dist/api/modules/heyresearch/index.d.ts +3 -0
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/proof-reads.d.ts +7 -0
- package/build/dist/api/modules/heyresearch/proof-reads.js +1 -0
- package/build/dist/api/modules/heyresearch/public-reads.d.ts +1 -0
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/heyresearch/scan.d.ts +31 -0
- package/build/dist/api/modules/heyresearch/scan.js +1 -0
- package/build/dist/api/modules/heyresearch/status-labels.d.ts +5 -0
- package/build/dist/api/modules/heyresearch/status-labels.js +1 -0
- package/build/dist/api/modules/heyresearch/token-facts.d.ts +123 -0
- package/build/dist/api/modules/heyresearch/token-facts.js +1 -0
- package/build/dist/api/modules/hoodag/chain-reads.js +1 -1
- package/build/dist/api/modules/hoodag/index.js +1 -1
- package/build/dist/api/modules/hoodag/management.js +1 -1
- package/build/dist/api/modules/hoodag/public-reads.js +1 -1
- package/build/dist/api/modules/hoodag/reconstruct.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/buyback.js +1 -1
- package/build/dist/api/modules/hoodlock/commerce.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.d.ts +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/addons.js +1 -1
- package/build/dist/api/modules/hookr/agent-gate.d.ts +63 -0
- package/build/dist/api/modules/hookr/agent-gate.js +1 -0
- package/build/dist/api/modules/hookr/contracts.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.d.ts +1 -0
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.d.ts +119 -0
- package/build/dist/api/modules/hookr/launch-options.js +1 -0
- package/build/dist/api/modules/hookr/launch-profile.d.ts +5 -0
- package/build/dist/api/modules/hookr/launch-profile.js +1 -0
- package/build/dist/api/modules/hookr/launch-receipt.d.ts +144 -0
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -0
- package/build/dist/api/modules/hookr/launch.d.ts +58 -0
- package/build/dist/api/modules/hookr/launch.js +1 -0
- package/build/dist/api/modules/hookr/liquidity.d.ts +48 -0
- package/build/dist/api/modules/hookr/liquidity.js +1 -0
- package/build/dist/api/modules/hookr/lp-positions.d.ts +2 -0
- package/build/dist/api/modules/hookr/lp-positions.js +1 -0
- package/build/dist/api/modules/hookr/lp-reads.d.ts +52 -0
- package/build/dist/api/modules/hookr/lp-reads.js +1 -0
- package/build/dist/api/modules/hookr/lp-receipt.d.ts +136 -0
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -0
- package/build/dist/api/modules/hookr/lp-state.d.ts +33 -0
- package/build/dist/api/modules/hookr/lp-state.js +1 -0
- package/build/dist/api/modules/hookr/pins.d.ts +43 -0
- package/build/dist/api/modules/hookr/pins.js +1 -0
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/read-utils.d.ts +59 -0
- package/build/dist/api/modules/hookr/read-utils.js +1 -0
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/hookr/revenue.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/kyberswap/source-pools.js +1 -1
- package/build/dist/api/modules/lighter/index.js +1 -1
- package/build/dist/api/modules/longbow/administration.js +1 -1
- package/build/dist/api/modules/longbow/analytics.js +1 -1
- package/build/dist/api/modules/longbow/fixed.js +1 -1
- package/build/dist/api/modules/longbow/index.js +1 -1
- package/build/dist/api/modules/longbow/nft.js +1 -1
- package/build/dist/api/modules/longbow/rebates.js +1 -1
- package/build/dist/api/modules/longbow/staking.js +1 -1
- package/build/dist/api/modules/meridian/index.js +1 -1
- package/build/dist/api/modules/meridian/markets.js +1 -1
- package/build/dist/api/modules/meridian/rfq.js +1 -1
- package/build/dist/api/modules/merkl/discovery.js +1 -1
- package/build/dist/api/modules/merkl/index.js +1 -1
- package/build/dist/api/modules/merkl/manage.js +1 -1
- package/build/dist/api/modules/merkl/protocol.js +1 -1
- package/build/dist/api/modules/morpho/allocator.js +1 -1
- package/build/dist/api/modules/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.js +1 -1
- package/build/dist/api/modules/morpho/midnight.js +1 -1
- package/build/dist/api/modules/morpho/protocol.js +1 -1
- package/build/dist/api/modules/morpho/vault-management.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/morpho/vault-v2.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/desk-read.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/netnet/staking.js +1 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/pons/claim.js +1 -1
- package/build/dist/api/modules/pons/index.js +1 -1
- package/build/dist/api/modules/pons/launch-status.js +1 -1
- package/build/dist/api/modules/pons/prices.js +1 -1
- package/build/dist/api/modules/pons/reads.js +1 -1
- package/build/dist/api/modules/pons/swap-terms.js +1 -1
- package/build/dist/api/modules/pons/trade.js +1 -1
- package/build/dist/api/modules/poolstrade/index.js +1 -1
- package/build/dist/api/modules/priors/coverage.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/features.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/market.js +1 -1
- package/build/dist/api/modules/priors/pt.js +1 -1
- package/build/dist/api/modules/priors/savings-exit.js +1 -1
- package/build/dist/api/modules/priors/starter-line.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/relay/bootstrap.js +1 -1
- package/build/dist/api/modules/relay/discovery.js +1 -1
- package/build/dist/api/modules/relay/inbound.js +1 -1
- package/build/dist/api/modules/relay/index.js +1 -1
- package/build/dist/api/modules/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/relay/reads.js +1 -1
- package/build/dist/api/modules/spark/actions.js +1 -1
- package/build/dist/api/modules/spark/details.js +1 -1
- package/build/dist/api/modules/spark/index.js +1 -1
- package/build/dist/api/modules/spark/management.js +1 -1
- package/build/dist/api/modules/steakhouse/analytics.js +1 -1
- package/build/dist/api/modules/steakhouse/erc4626.js +1 -1
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
- package/build/dist/api/modules/steakhouse/management.js +1 -1
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
- package/build/dist/api/modules/tickerspring/discovery.js +1 -1
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/token-jar.js +1 -1
- package/build/dist/api/modules/uniswap/trade-batch.js +1 -1
- package/build/dist/api/modules/uniswap/trade.js +1 -1
- package/build/dist/api/modules/uniswap/v2.js +1 -1
- package/build/dist/api/modules/uniswap/v3.js +1 -1
- package/build/dist/api/modules/uniswap/v4.js +1 -1
- package/build/dist/api/modules/uniswap/wrap.js +1 -1
- package/build/dist/api/modules/velora/claims.js +1 -1
- package/build/dist/api/modules/velora/delta-reads.js +1 -1
- package/build/dist/api/modules/velora/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.d.ts +5 -0
- package/build/dist/api/modules/wormhole/index.js +1 -0
- package/build/dist/api/modules/wormhole/license.d.ts +2 -0
- package/build/dist/api/modules/wormhole/license.js +1 -0
- package/build/dist/api/modules/wormhole/quotetext.d.ts +36 -0
- package/build/dist/api/modules/wormhole/quotetext.js +1 -0
- package/build/dist/api/modules/wormhole/scan-text.d.ts +40 -0
- package/build/dist/api/modules/wormhole/scan-text.js +1 -0
- package/build/dist/api/modules/wormhole/token-check.d.ts +54 -0
- package/build/dist/api/modules/wormhole/token-check.js +1 -0
- package/build/dist/api/positions.js +1 -1
- package/build/dist/api/pricenote.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/pricing.js +1 -1
- package/build/dist/api/rpc.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/signing.js +1 -1
- package/build/dist/api/simulate.js +1 -1
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/types.d.ts +7 -0
- package/build/dist/chunks/{QHHZDXRG.js → 2FSX7MMR.js} +1 -1
- package/build/dist/chunks/{RTBOMWCB.js → 2LM7U4S7.js} +1 -1
- package/build/dist/chunks/{BBVKWG65.js → 2MSQ6JII.js} +1 -1
- package/build/dist/chunks/{T6MTTMLQ.js → 2UU5TBBB.js} +1 -1
- package/build/dist/chunks/{OW7GOYKA.js → 2W46IRX6.js} +1 -1
- package/build/dist/chunks/{6LLOTPH2.js → 3EFV4FQF.js} +1 -1
- package/build/dist/chunks/{IAXKPME3.js → 3NDVXEBR.js} +1 -1
- package/build/dist/chunks/3SC5UI35.js +1 -0
- package/build/dist/chunks/{TCS3ICNE.js → 3WBDHUV2.js} +1 -1
- package/build/dist/chunks/{UPPYXY74.js → 4AKIXLXH.js} +1 -1
- package/build/dist/chunks/{ZGXNTWYG.js → 4GHVIBL5.js} +1 -1
- package/build/dist/chunks/{NHCRJC5X.js → 4KQZTPMS.js} +1 -1
- package/build/dist/chunks/{N77ANGBT.js → 4X2JOQ2L.js} +1 -1
- package/build/dist/chunks/{ZPM2MFXZ.js → 52DHGSG4.js} +1 -1
- package/build/dist/chunks/{2CS3M32D.js → 57HAXNQV.js} +1 -1
- package/build/dist/chunks/5IIR3GIN.js +1 -0
- package/build/dist/chunks/{CAU44UWP.js → 5O5ZE3ZV.js} +1 -1
- package/build/dist/chunks/5OEHZJ6X.js +1 -0
- package/build/dist/chunks/{CBA776XQ.js → 5VHH5PW3.js} +1 -1
- package/build/dist/chunks/{6HV5BR7P.js → 6AWTAE4Q.js} +1 -1
- package/build/dist/chunks/{JRVTSGAT.js → 6UPPUHCL.js} +1 -1
- package/build/dist/chunks/{MEMVFR7Z.js → 6ZYLNB2B.js} +1 -1
- package/build/dist/chunks/7XLEYOZH.js +1 -0
- package/build/dist/chunks/{Q4RZQCDS.js → AAGDMH54.js} +1 -1
- package/build/dist/chunks/ACN2BFMA.js +1 -0
- package/build/dist/chunks/{L24EOVLT.js → AJP5LDM2.js} +1 -1
- package/build/dist/chunks/{F2YH72GF.js → ALK6NKFP.js} +1 -1
- package/build/dist/chunks/{EC5W3UZD.js → AMICUXS6.js} +1 -1
- package/build/dist/chunks/{BEPSWFJX.js → ASDKY5NX.js} +1 -1
- package/build/dist/chunks/{5LQBHXFA.js → BX7XQANB.js} +1 -1
- package/build/dist/chunks/{NUTHT4FE.js → CE7D6MUS.js} +1 -1
- package/build/dist/chunks/{QNPEKNWM.js → CEIPDEXZ.js} +1 -1
- package/build/dist/chunks/{HFQS5344.js → CQCVFRQ5.js} +1 -1
- package/build/dist/chunks/{OJLMF5AR.js → CUNQ5RG5.js} +1 -1
- package/build/dist/chunks/{IWALIX7Q.js → CXLEQCP3.js} +1 -1
- package/build/dist/chunks/{VJ3W2V3B.js → CY75R4FK.js} +1 -1
- package/build/dist/chunks/{65QFM4JU.js → DCTUYDWF.js} +1 -1
- package/build/dist/chunks/{N37ZLNCT.js → DRWWPBOQ.js} +1 -1
- package/build/dist/chunks/{7B5UH2VS.js → DZGEQBO7.js} +1 -1
- package/build/dist/chunks/{RFJCG4NA.js → E7R3J4H7.js} +1 -1
- package/build/dist/chunks/{7T4BYFD4.js → EGUMOD3A.js} +1 -1
- package/build/dist/chunks/ELZNT5Q3.js +1 -0
- package/build/dist/chunks/{IUETZH6I.js → EXRKBBX2.js} +1 -1
- package/build/dist/chunks/{K7HIKXNT.js → FBSUTF3B.js} +1 -1
- package/build/dist/chunks/{LFN3OODW.js → FUXT7GRK.js} +1 -1
- package/build/dist/chunks/{7US6PD56.js → G3MHDTGT.js} +1 -1
- package/build/dist/chunks/G6HCV67X.js +1 -0
- package/build/dist/chunks/GCWA4Z3W.js +1 -0
- package/build/dist/chunks/{HNMOB76J.js → GGUEKSR4.js} +1 -1
- package/build/dist/chunks/{GZ5TW3WB.js → GIV5JMTE.js} +1 -1
- package/build/dist/chunks/{OMTCWXQR.js → GJY3P6OG.js} +1 -1
- package/build/dist/chunks/HOEQVPY7.js +1 -0
- package/build/dist/chunks/{3R3C3CU5.js → IBXYIN7Q.js} +1 -1
- package/build/dist/chunks/{SXX52Y27.js → IUE6RASI.js} +1 -1
- package/build/dist/chunks/{AYM5L6L7.js → J3GFCBZZ.js} +1 -1
- package/build/dist/chunks/{T3MGNKA6.js → JPOYTTTW.js} +1 -1
- package/build/dist/chunks/{AZGMF26W.js → JST5JGAP.js} +1 -1
- package/build/dist/chunks/{FBQWTWPT.js → JWCOXLYA.js} +1 -1
- package/build/dist/chunks/{G7UKNO2I.js → KHJFXJBU.js} +1 -1
- package/build/dist/chunks/{HQVC6X3T.js → KSZMMNXK.js} +1 -1
- package/build/dist/chunks/{O7PQDUVT.js → L3ZM77SJ.js} +1 -1
- package/build/dist/chunks/{QRUC7EFE.js → L62M7LOB.js} +1 -1
- package/build/dist/chunks/{22S4SFD5.js → L7YBCMZU.js} +1 -1
- package/build/dist/chunks/LKJBMHCE.js +1 -0
- package/build/dist/chunks/{FKAA7VUR.js → LLM5WDM3.js} +1 -1
- package/build/dist/chunks/{H6ED3RHF.js → LMVB3B6T.js} +1 -1
- package/build/dist/chunks/{UIIJWIR6.js → LQGPMOD2.js} +1 -1
- package/build/dist/chunks/{WLACEU2Y.js → LQUDJCAR.js} +1 -1
- package/build/dist/chunks/LT5P6PZW.js +1 -0
- package/build/dist/chunks/M7U3A4EH.js +3 -0
- package/build/dist/chunks/MKQVS3IO.js +1 -0
- package/build/dist/chunks/{5XFXH2JT.js → NATG6YA6.js} +1 -1
- package/build/dist/chunks/{O47JXRXN.js → NAYRD43N.js} +1 -1
- package/build/dist/chunks/{6L6DSMCU.js → NMYGNJIJ.js} +1 -1
- package/build/dist/chunks/NRBIXV7V.js +1 -0
- package/build/dist/chunks/{D6VP3N27.js → NSOEDRBU.js} +1 -1
- package/build/dist/chunks/{HL2MLC3O.js → NU4K3TEZ.js} +1 -1
- package/build/dist/chunks/NWSPC3NH.js +1 -0
- package/build/dist/chunks/O5IVZHHP.js +1 -0
- package/build/dist/chunks/{I7NUTSSX.js → OE3CLZHR.js} +1 -1
- package/build/dist/chunks/{2NA6JLEC.js → OQVZVR2S.js} +1 -1
- package/build/dist/chunks/{D3OWLDVB.js → OVK4EEOD.js} +1 -1
- package/build/dist/chunks/{Q2VMH2LB.js → PARWLWXW.js} +1 -1
- package/build/dist/chunks/{NCEJZWGX.js → PEA32CWB.js} +1 -1
- package/build/dist/chunks/{DHXVYHT4.js → PTAWEHKB.js} +1 -1
- package/build/dist/chunks/{DVKDWXEJ.js → PWBL4WKB.js} +1 -1
- package/build/dist/chunks/{PR2QED25.js → PZHR4ITH.js} +1 -1
- package/build/dist/chunks/{OG5HRQU4.js → QRDDKA4I.js} +1 -1
- package/build/dist/chunks/{YR3QJVJQ.js → QXNPPCOU.js} +1 -1
- package/build/dist/chunks/{6NR7SVRO.js → QYYFRAWY.js} +1 -1
- package/build/dist/chunks/{QR7ALOR4.js → R53P2K3C.js} +1 -1
- package/build/dist/chunks/{5RKWSFD2.js → R7FXNZRM.js} +1 -1
- package/build/dist/chunks/{CCEWSOBT.js → R7QPJQP6.js} +1 -1
- package/build/dist/chunks/{SLSPWXR6.js → R7SXC74O.js} +1 -1
- package/build/dist/chunks/{IHGVCPVA.js → RAKUK5VR.js} +1 -1
- package/build/dist/chunks/{7LDAJ6BM.js → S3HNPTXA.js} +1 -1
- package/build/dist/chunks/{WIDTTGSH.js → SJPM5ST4.js} +1 -1
- package/build/dist/chunks/{QYHJWU5T.js → SJPYXNOK.js} +1 -1
- package/build/dist/chunks/{VY3P34PY.js → SKQGLGES.js} +1 -1
- package/build/dist/chunks/{ZT67OMLW.js → SOYQOE5P.js} +1 -1
- package/build/dist/chunks/{GUBB5P6V.js → SQZRVIVF.js} +1 -1
- package/build/dist/chunks/{E24S22BZ.js → SSTROLQM.js} +1 -1
- package/build/dist/chunks/{DGGOO4RN.js → SXAIXD56.js} +1 -1
- package/build/dist/chunks/{D4WURN33.js → SXX3VTBP.js} +1 -1
- package/build/dist/chunks/{UXG67LH3.js → TCPPYBGQ.js} +1 -1
- package/build/dist/chunks/{67TJOOBI.js → TLJPVYRJ.js} +1 -1
- package/build/dist/chunks/{ULJ6E4HP.js → TMGWXDCZ.js} +1 -1
- package/build/dist/chunks/TNLHMDWL.js +1 -0
- package/build/dist/chunks/{NMFVXBTL.js → TNSKEHPC.js} +1 -1
- package/build/dist/chunks/TPDOUL4N.js +1 -0
- package/build/dist/chunks/{C2FEXLMA.js → TQL7UDFL.js} +1 -1
- package/build/dist/chunks/{QXFJZGVB.js → TWCSCRFS.js} +1 -1
- package/build/dist/chunks/{2EDXKJ3B.js → TWSTOFN3.js} +1 -1
- package/build/dist/chunks/{X6G4BD35.js → U3F6DDML.js} +1 -1
- package/build/dist/chunks/{XGUKLFBU.js → UFS2RVEZ.js} +1 -1
- package/build/dist/chunks/{RM5W63LO.js → UNZRE3YU.js} +1 -1
- package/build/dist/chunks/{GECX5U3F.js → USSOVTD5.js} +1 -1
- package/build/dist/chunks/V2OOOV6B.js +1 -0
- package/build/dist/chunks/{IRWEY7TQ.js → V5LTA42G.js} +1 -1
- package/build/dist/chunks/{TAI63P6E.js → VC2RCYQE.js} +1 -1
- package/build/dist/chunks/VCLPOU7T.js +1 -0
- package/build/dist/chunks/{BG4S6MSN.js → VFKNXQXI.js} +1 -1
- package/build/dist/chunks/{3ZVGHC6S.js → VFSRRDLY.js} +1 -1
- package/build/dist/chunks/{XW7RH7YY.js → VVEUJ36E.js} +1 -1
- package/build/dist/chunks/{5EHQM6DM.js → WQ6H62DM.js} +1 -1
- package/build/dist/chunks/{TDN3C4IG.js → WQQJ7UPJ.js} +1 -1
- package/build/dist/chunks/{F3TJCOVV.js → WTSMPDT5.js} +1 -1
- package/build/dist/chunks/{BYXBS45D.js → WVXW6VL3.js} +1 -1
- package/build/dist/chunks/WWFOYZT2.js +1 -0
- package/build/dist/chunks/WWNAGOCD.js +1 -0
- package/build/dist/chunks/X2NJSQUY.js +203 -0
- package/build/dist/chunks/{C3ZZSGSP.js → XQUPZ3GU.js} +1 -1
- package/build/dist/chunks/XQXLFF7Y.js +1 -0
- package/build/dist/chunks/XUYHMOHS.js +1 -0
- package/build/dist/chunks/XV2HQKND.js +1 -0
- package/build/dist/chunks/{QZM7CWZW.js → XVFLT275.js} +1 -1
- package/build/dist/chunks/{BV3AHLH5.js → XWEFKXKA.js} +1 -1
- package/build/dist/chunks/{NKY3DT34.js → YA5WWDEW.js} +1 -1
- package/build/dist/chunks/YHB55C5T.js +1 -0
- package/build/dist/chunks/YOENHHKI.js +1 -0
- package/build/dist/chunks/YQUKU2LS.js +1 -0
- package/build/dist/chunks/{72AWP4BM.js → YZSTP2E6.js} +1 -1
- package/build/dist/chunks/{T3NPRRTY.js → Z7RL4NGX.js} +1 -1
- package/build/dist/chunks/{YMB553OJ.js → ZT47KN7A.js} +1 -1
- package/build/dist/chunks/ZXQMF56D.js +1 -0
- package/package.json +1 -1
- package/build/dist/chunks/6SCCW74G.js +0 -1
- package/build/dist/chunks/DD7755AW.js +0 -1
- package/build/dist/chunks/EYYUWFUR.js +0 -1
- package/build/dist/chunks/JG24LNUI.js +0 -1
- package/build/dist/chunks/JRO6WTK4.js +0 -1
- package/build/dist/chunks/MNFU7PO3.js +0 -1
- package/build/dist/chunks/N3GWFLG6.js +0 -1
- package/build/dist/chunks/RRSODRGT.js +0 -1
- package/build/dist/chunks/UMK564HS.js +0 -1
- package/build/dist/chunks/XPFVT2EA.js +0 -1
- package/build/dist/chunks/XUJSQV52.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as j,n as z}from"./TCS3ICNE.js";import{a as U}from"./UWOFA6GV.js";import{b as G,c as H,g as A}from"./73N3TOJL.js";import{a as b}from"./XPFVT2EA.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as E,getAddress as w,hashTypedData as O,parseAbi as S,recoverTypedDataAddress as Q}from"viem";var Y={pool:w("0x281210097f0de7A8FB6F87310AF0f089c9C8DE21"),registry:w("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),usdg:w("0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"),priors:w("0xeDBf91223639800BCd5756815CAf908Df3b890bE"),stock:w("0xbEcd07EC689988e16b870C121756C4c2C8cb02B6"),backing:w("0xC999014C6218EC41f0aE412d49AE8f2aA4c539fD"),treasury:w("0xFe8fdf43c4b0443aCF8E8CD8facD62F1B770e267"),bond:w("0x346d3360B7258a18E8a2a55fe20E0F467113a53A"),autopay:w("0x72B510AF4e66e5960aB9b975e0BdCf80239e83A0"),savings:w("0xBeEff033F34C046626B8D0A041844C5d1A5409dd"),market:w("0x6a4583242B8313313E684d02aB7dc6bFf8749670"),market1:w("0xe5C8b3FacD7802099C1DfB88c0C818Cd0ebA7B19"),bidSpender:w("0x0dbd031a3e8cc91C2b0A3Bf6BD1d14c7AeD92878"),seats3:w("0x59D155C42A9263fA7596867b992bB3e84dF680a9"),seats4:w("0xb1c3a04496238D62E3c93118C297163855e22192")},c=Y,C="(uint256 agentId,uint256 sponsorId,address owner,uint256 maxPremiumBps,uint256 nonce,uint256 deadline)",X=S(["function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),V=S(["function nonces(uint256) view returns (uint256)"]),ee=S(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),ne="0x0000000000000000000000000000000000000000",$="Owner stake is collateral, not a return. A default burns 75% of owner stake (50% of other backing); pending and leaving stake remains at risk until released. New backing waits 24 hours. Exit mode 0 holds, 1 returns PRIORS, 2 requests USDG through the guarded exit queue; no immediate payout is promised.",e=(t,r,n,o,s={})=>({name:`priors_${t}`,contract:r,signature:`function ${n}`,fields:o,note:"",...s}),i=["agentId","id"],v=["amount","uint"],W=["on","bool"],_=["generation","uint32"],R=["day","uint32"],D=["layer","uint8"],a={read:!0},Z=[e("set_delegate","pool","setDelegate(uint256,address)",[i,["delegate","address"]],{owner:"agentId",note:"Owner only. Delegate controls borrowing/repayment, not transfer of identity; clear with the zero address."}),e("root_enroll","pool","enrollRoot(uint256,uint256)",[i,v],{owner:"agentId",approval:"usdg",note:"Owner only. Locks USDG pool shares behind this sponsor root; active delegated lines and fees constrain withdrawals."}),e("root_add_stake","pool","addStake(uint256,uint256)",[i,v],{approval:"usdg",note:"Anyone may add USDG; only the root owner can withdraw it. This may give funds to another owner."}),e("root_unlock","pool","unlock(uint256,uint256,address)",[i,["shares","uint"]],{owner:"agentId",args:["agentId","shares","$wallet"],note:"Owner only. Withdraw root pool shares to this wallet, subject to delegated backing and fee locks."}),e("root_retire","pool","retireRoot(uint256)",[i],{owner:"agentId",note:"Owner only; requires no remaining stake or delegated lines."}),e("root_vouch","pool","vouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Adds the exact USDG amount of undrawn backing to an existing sponsored line."}),e("root_unvouch","pool","unvouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Recalls undrawn backing; outstanding debt remains backed."}),e("root_freeze","pool","freeze(uint256,bool)",[i,["frozen","bool"]],{note:"Current sponsor owner only; freeze/unfreeze the agent line. Contract checks sponsor ownership."}),e("root_set_premium","pool","setPremium(uint256,uint256)",[i,["premiumBps","uint"]],{note:"Current sponsor owner only. Future loan premium cannot exceed the owner-consented cap."}),e("root_claim_fees","pool","claimSponsorFees(uint256,address)",[i],{owner:"agentId",args:["agentId","$wallet"],note:"Owner only; claim sponsor USDG fees to this wallet."}),e("root_set_hook","pool","setHook(uint256,address)",[i,["hook","address"]],{owner:"agentId",note:"Owner only. Changes root lending policy hook; pool enforces the delay while backing is committed."}),e("root_apply_hook","pool","applyHook(uint256)",[i],{note:"Apply a previously scheduled root hook after its on-chain delay."}),e("mark_default","pool","markDefault(uint256)",[["loanId","id"]],{note:"Irreversible: mark a past-grace unpaid loan defaulted, burn sponsor backing and mark the owner. Preview and confirm deliberately."}),e("import_history","pool","importFromV1(uint256)",[i],{note:"Import the v1 record, including defaults; this never imports unbacked capacity."}),e("fund_reserve","pool","fundReserve(uint256)",[v],{approval:"usdg",note:"Donate USDG to the pool reserve; receives no redeemable shares."}),e("root_shares","pool","rootShares(uint256) view returns (uint256)",[i],a),e("root_fee_locked","pool","feeLocked(uint256) view returns (uint256)",[i],a),e("root_fees_owed","pool","sponsorFees(uint256) view returns (uint256)",[i],a),e("root_backing","pool","backing(uint256) view returns (uint256)",[i],a),e("root_free_backing","pool","freeBacking(uint256) view returns (uint256)",[i],a),e("pool_parameters","pool","getParams() view returns ((uint256 minLoan,uint256 maxLoan,uint64 minTerm,uint64 maxTerm,uint64 grace,uint64 minScoreTerm,uint256 feeBps,uint256 sponsorFeeBps,uint256 protocolFeeBps,uint256 minStake,uint256 maxUtilizationBps,uint256 keeperBounty))",[],a),e("bond_deposit","bond","deposit(uint256)",[i],{owner:"agentId",approval:"bond",note:"Owner only. V2 treasury bond remains locked while any line or loan is open; it may replace and refund a former owner bond. Leave and release the legacy bond before Treasury V5 migration."}),e("bond_release","bond","release(uint256)",[i],{note:"Return V2 bond to its original depositor, not necessarily this wallet; contract enforces no line, no loan and age."}),e("bond_slash","bond","slash(uint256)",[i],{note:"Irreversible: send defaulted agent V2 bond to the configured beneficiary."}),e("bond_status","bond","bonds(uint256) view returns ((address depositor,uint64 at,uint256 amount))",[i],a),e("bond_releasable","bond","releasable(uint256) view returns (bool)",[i],a),e("bond_release_at","bond","unusedReleaseAt(uint256) view returns (uint256)",[i],a),e("treasury_move","treasury",`move(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","$consent","$signature"],note:"Move a former Treasury V4 line to V5, no loan open. Close old line, release legacy bond, deposit V2 bond first. V4 record and current-owner V2 bond are required."}),e("treasury_raise","treasury","raise(uint256)",[i],{note:"Raise an eligible Treasury V5 line using its current rules, score, history, age, weekly room and free backing. No unbacked credit."}),e("treasury_reclaim","treasury","reclaim(uint256)",[i],{note:"Reclaim an idle treasury line under on-chain rules; this ends borrowing access."}),e("treasury_first_line","treasury",`firstLine(uint256,uint64,bytes,${C},bytes)`,[i,["expiry","uint"],["invite","bytes"]],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","expiry","invite","$consent","$signature"],note:"Redeem an already-issued Treasury V5 invite with V5 pool consent. Requires a valid V5 inviter signature; the current owner V2 bond is needed before borrowing. V4 invites cannot be reused."}),e("treasury_raise_room","treasury","raiseRoom() view returns (uint256)",[],a),e("treasury_first_lined","treasury","firstLined(uint256) view returns (bool)",[i],a),e("treasury_eligible_raise","treasury","eligibleForRaise(uint256) view returns (bool)",[i],a),e("treasury_room","treasury","epochRoom() view returns (uint256)",[],a),e("treasury_rules","treasury","rules() view returns (uint256 reserveBps,uint256 firstLine,uint256 secondLine,uint256 epochCap,uint64 epochLength,uint64 minSeasoning,uint256 minQualified,uint256 minScore,uint64 idleAfter)",[],a),e("stock_open","stock",`open(uint256,address,uint256,${C},bytes) returns (uint256)`,[i,["token","address"],v],{owner:"agentId",consentRoot:6424n,externalConsent:!0,approval:"stock",args:["agentId","token","amount","$consent","$signature"],note:"Owner or on-chain controller with a supplied owner consent posts exact collateral. Token must be accepted and usable; live price, LTV, line cap and backing determine the line. Default seizes debt plus buffer; issuer restrictions and burns may reduce returned collateral."}),e("stock_add","stock","addCollateral(uint256,uint256)",[i,v],{approval:"stock",note:"Depositor only. Adds exact position token collateral; contract decides resulting draw room."}),e("stock_close","stock","close(uint256)",[i],{note:"Depositor or controller closes/freezes the line; collateral pays its depositor after the last loan, subject to default and issuer shortfalls."}),e("stock_expire","stock","expire(uint256)",[i],{note:"Expire idle stock line after on-chain idle rules; may close borrowing access."}),e("stock_reconcile","stock","reconcile(uint256,uint256)",[i,["maxLoans","uint"]],{note:"Reconcile the collateral debt walk against pool loans; contract ignores maxLoans in this implementation."}),e("stock_settle","stock","settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile stock collateral after a default or missed hook; may seize collateral according to the loan."}),e("stock_record_feed","stock","record(address,uint256) returns (uint80)",[["feed","address"],["maxRounds","uint"]],{note:"Advance public oracle price tape; may unblock new stock lines and default settlement."}),e("stock_reclaim","stock","reclaim(uint256)",[i],{note:"Reclaim a written-off stock position after it is no longer backed; return remains subject to vault token shortfall."}),e("stock_state","stock","getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[i],a),e("stock_borrow_room","stock","borrowRoom(uint256) view returns (uint256)",[i],a),e("stock_asset_state","stock","assets(address) view returns (address feed,uint64 maxAge,uint8 tokenDecimals,uint8 feedDecimals,bool enabled,uint16 ltvBps,uint128 lineCap)",[["token","address"]],a),e("stock_lending_status","stock","lendStatus(address) view returns (uint8)",[["token","address"]],a),e("stock_value","stock","valueOf(address,uint256) view returns (bool ok,uint256 value)",[["token","address"],v],a),e("stock_ltv","stock","ltvOf(uint256,address) view returns (uint256)",[i,["token","address"]],a),e("backing_open","backing",`open(uint256,uint256,bool,${C},bytes)`,[i,v,["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"priors",args:["agentId","amount","autoAdd","$consent","$signature"],note:$}),e("backing_open_with_usdg","backing",`openWithUsdg(uint256,uint256,uint256,uint256,uint256,bool,${C},bytes)`,[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"mixed",args:["agentId","priorsIn","usdgIn","minOut","deadline","autoAdd","$consent","$signature"],note:$}),e("backing_add","backing","back(uint256,uint256,bool)",[i,v,["autoAdd","bool"]],{approval:"priors",note:$+" Owner-only at launch; other backers require both global and individual permission."}),e("backing_add_with_usdg","backing","backWithUsdg(uint256,uint256,uint256,uint256,uint256,bool)",[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{approval:"mixed",note:$}),e("backing_leave","backing","leave(uint256,uint256,uint8)",[i,v,["exitMode","uint8"]],{note:$}),e("backing_close","backing","close(uint256,uint8)",[i,["exitMode","uint8"]],{note:$}),...["refresh","promote","expire","sync","pokeFees","recordRepay","noteDelegate"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256)`,[i],{note:"Reconcile this V5 book against current pool, owner, record, tier and backing rules; no payout is promised."})),...["setAutoAdd","setProtocolBacking","setOthersBacking"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256,bool)`,[i,W],{note:"Change this V5 book setting under the contract ownership/holder rules. Auto-add can compound rewards into stake at risk."})),e("backing_reconsent","backing",`reconsent(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8762n,args:["agentId","$consent","$signature"],note:"Owner only. Renew the pool consent for V5 backing."}),e("backing_release","backing","release(uint256,uint32,uint32,uint256,uint256)",[i,_,R,["minUsdgOut","uint"],["deadline","uint"]],{note:"Release caller day bucket after its release rule. Zero minUsdgOut returns PRIORS; positive requests a guarded sale. Stake stays burnable until release. Read generation/day from chain events."}),e("backing_release_for","backing","releaseFor(uint256,uint32,address,uint32)",[i,_,["holder","address"],R],{note:"Return eligible PRIORS to its holder under generation/day release rules, never redirect proceeds."}),e("backing_finish_close","backing","finishClose(uint256,uint32)",[i,_],{note:"Finish an eligible generation close; pays the bound owner under its release rules."}),e("backing_claim_settled","backing","claimSettled(uint256,uint32,address)",[i,_,["holder","address"]],{note:"Pay settled generation stake to the named holder, after any default burn."}),e("backing_claim_record","backing","claimSettled(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Pay settled day record to its holder after any default burn."}),e("backing_queue_exit","backing","queueExit(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Holder/keeper queues ready USDG-mode stake; minimum and queue window apply. A queue entry is not a fill or payout."}),e("backing_settle","backing","settle(uint256,uint32,uint256)",[i,_,["loanId","id"]],{note:"Reconcile V5 generation with a pool loan/default after a missed hook."}),e("backing_record_loan","backing","recordLoan(uint256)",[["loanId","id"]],{note:"Record current pool loan in V5 book."}),e("backing_record_default","backing","recordDefault(uint256)",[["loanId","id"]],{note:"Reconcile a marked pool default and its stake burn."}),e("backing_collect","backing","collect(uint256[],uint32[]) returns (uint256)",[["agentIds","ids"],["generations","gens"]],{note:"Collect caller fees for explicitly selected generations; auto-add settings may retain stake."}),e("backing_fund","backing","fund(uint256)",[v],{approval:"usdg",note:"Donate USDG to V5 root backing; donor receives no withdrawable claim."}),e("backing_book","backing","getGen(uint256,uint32) view returns ((address owner,uint64 openedAt,uint8 status,bool ownerChanged,bool optOut,bool othersOff,bool pointsVoid,bool openRoomCharged,bool closedByOwner,bool movePending,bool splitPending,uint64 movePendingAt,uint8 tier,uint8 countedAtTier,uint8 listLen,uint32 tierStep,uint64 tierSince,uint64 lastLateAt,uint64 closedMark,uint64 lastRaiseAt,uint64 promoEpoch,uint64 stakeEpoch,uint64 placeEpoch,uint160 movePendingSqrt,uint256 roomLine,uint256 openLine,uint256 promoCredit,uint256 stakeRaised,uint256 placed,uint256 index,uint256 divisor,uint256 defaultProof,uint256 cLive,uint256 cUnits,uint256[3] list,uint256[3] counted,uint256[3] pendingTok,uint256[3] leavingLive,uint256[3] tokens,uint64[3] layerEnd,uint160[3] endSqrt,uint8[3] ownerEndMode,uint32[2][3] liveDay,uint32[3] leaveHead,(uint64 epoch,uint192 points)[5] points))",[i,_],a),e("backing_generation","backing","latestGen(uint256) view returns (uint32)",[i],a),e("backing_line","backing","lineOf(uint256) view returns (uint256)",[i],a),e("backing_quote","backing","needed(uint256,uint256,bool) view returns ((uint256 minA,uint256 fullLine,uint256 capA,uint160 sqrtP,uint8 k,uint8 kCached,bool depthGuard,uint256 line,uint256 ownerA,uint256 ownBacking,uint256 roomB,uint256 lineIfAdded,uint256 weekAfter))",[i,["tokens","uint"],["asOwner","bool"]],a),e("backing_position","backing","position(uint256,uint32,uint8,address) view returns ((uint256 counted,uint256 checkpoint,uint256 a0,uint256 a1,uint32 d0,uint32 d1,bool autoAdd))",[i,_,D,["holder","address"]],a),e("backing_record","backing","record(uint256,uint32,uint8,uint32,address) view returns ((uint256 counted,uint256 uncounted,uint256 creditedTo,uint160 sqrtLeave,uint8 mode,uint64 entry))",[i,_,D,R,["holder","address"]],a),e("backing_bucket","backing","leavingBucket(uint256,uint32,uint8,uint32) view returns ((bool exists,bool retired,uint64 latestLeave,uint64 releasableAt,uint256 loanCount,uint256 counted,uint256 uncounted,uint256 retireIndex))",[i,_,D,R],a),e("backing_settings","backing","settings() view returns (bool openBacking,uint256 premiumCap,uint256 maxSwapUsdg,uint256 openRoom,uint256 raiseRoom,uint256 vouchCap,uint8 minDrawK,bool premiumCheck,uint64 pausedUntil)",[],a),e("backing_reopen_at","backing","reopenAt(uint256) view returns (uint64)",[i],a),e("backing_sync_prices","backing","sync()",[],{note:"Update global V5 price/guard observations."}),e("backing_exit_service_open","backing","exitServiceOpen() view returns (bool)",[],a),e("backing_usdg_path","backing","usdgPathOpen(uint256) view returns (bool,uint8)",[["usdgIn","uint"]],a),e("backing_entry_rule","backing","entryRule() view returns (uint8 minEntryLoans,uint32 minEntryDays)",[],a),e("backing_target_premium","backing","targetPremiumBps(uint256) view returns (uint256)",[i],a),e("backing_price_cache","backing","priceCache() view returns (uint160 sqrtMedian,uint64 obsAt,uint160 sqrtWeekLow,uint160 sqrtObservation)",[],a),e("backing_pending_bucket","backing","pendingBucket(uint256,uint32,uint8,uint32) view returns ((uint128 amount,uint64 lastDeposit,bool merged,bool dead,uint256 mergeIndex))",[i,_,D,R],a),e("backing_exit_head","backing","exitHead() view returns (uint256 entryId,address holder,uint256 rest,uint160 sqrtPLeave,uint64 joinedAt)",[],a),e("backing_exit_entry","backing","entry(uint256) view returns ((uint256 id,uint32 gen,uint8 layer,uint32 day,address holder,uint64 joinedAt,uint64 prev,uint64 next))",[["entryId","uint"]],a),e("backing_flush","backing","flush()",[],{note:"Reconcile V5 fees and backing buffers; no payout to caller is promised."}),e("backing_claimable","backing","claimable(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("autopay_hold","autopay","hold(bool)",[W],{note:"Hold/resume future autopay attempts for this wallet; allowances remain until explicitly revoked."}),e("autopay_max_cap","autopay","MAX_CAP() view returns (uint256)",[],a),e("autopay_window","autopay","WINDOW() view returns (uint64)",[],a),e("autopay_paused_until","autopay","pausedUntil() view returns (uint64)",[],a),e("autopay_plan","autopay","planOf(address,uint256) view returns (uint32 cap,address owner,bool on,bool useSavings,bool late,uint32 epoch)",[i],{...a,args:["$wallet","agentId"]}),e("autopay_check","autopay","check(uint256) view returns ((uint8 status,uint256 agentId,uint256 due,uint64 opens,uint64 closes,address wallet,uint256 fromWallet,uint256 fromWalletSavings,address owner,uint256 fromOwner,uint256 fromOwnerSavings))",[["loanId","id"]],a),e("autopay_epoch","autopay","epochOf(uint256) view returns (uint32 epoch,bool stale)",[i],a),e("autopay_held","autopay","held(address) view returns (bool)",[],{...a,args:["$wallet"]}),e("savings_deposit","savings","deposit(uint256,address) returns (uint256)",[v],{approval:"usdg",args:["amount","$wallet"],note:"Deposit own USDG into Priors default external Morpho savings vault; vault/allocator risk and withdrawal liquidity apply."}),e("savings_withdraw","savings","withdraw(uint256,address,address) returns (uint256)",[v],{args:["amount","$wallet","$wallet"],note:"Withdraw exact USDG amount from own savings. Insufficient liquidity fails the preview; no immediate exit is promised."}),e("savings_redeem","savings","redeem(uint256,address,address) returns (uint256)",[["shares","uint"]],{args:["shares","$wallet","$wallet"],note:"Redeem exact own savings shares to this wallet; liquidity and rounding apply."}),e("savings_balance","savings","balanceOf(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("savings_value","savings","previewRedeem(uint256) view returns (uint256)",[["shares","uint"]],a),...["market","market1"].flatMap((t,r)=>[e(`market_v${r===0?2:1}_listing`,t,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[i],a),e(`market_v${r===0?2:1}_record_hash`,t,"recordHash(uint256) view returns (bytes32)",[i],a),e(`market_v${r===0?2:1}_list`,t,"list(uint256,uint256,uint64)",[i,["price","uint"],["expiry","uint"]],{owner:"agentId",approval:"nft",note:"Owner sells this ERC-8004 NFT, its record and any followed treasury line. This does not transfer code, keys or servers. Approves only this NFT; confirm the sale terms and contract-enforced hold/line rules."}),e(`market_v${r===0?2:1}_cancel`,t,"cancel(uint256)",[i],{note:"Cancel the standing listing; NFT approval can remain until explicitly cleared."}),e(`market_v${r===0?2:1}_buy`,t,"buy(uint256,uint256,uint256,bytes32,bytes32)",[i,["maxPrice","uint"],["nonce","uint"],["uriHash","bytes32"],["recordHash","bytes32"]],{approval:"market",note:"Buy an ERC-8004 NFT to this wallet with exact live asking-price approval and pinned listing nonce, tokenURI and current credit record. A followed line still needs the new owner bond before borrowing. No keys/code/servers are included."})]),e("market_bid","market","bid(uint256,uint256,uint64,bytes32,uint256,uint256) returns (uint256)",[i,["price","uint"],["expiry","uint"],["uriHash","bytes32"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["agentId","price","expiry","uriHash","minRepaid","minLine"],approval:"bid",note:"Standing future purchase authority: another owner can fill this bid later without a new click. Exact reserveBudget USDG allowance is shared by all this wallet bids and replaces the old allowance. Cancel bid and clear unused budget deliberately."}),e("market_bid_any","market","bidAny(bytes32,uint256,uint256,uint64,uint256,uint256) returns (uint256)",[["root","bytes32"],["count","uint"],["price","uint"],["expiry","uint"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["root","count","price","expiry","minRepaid","minLine"],approval:"bid",note:"Standing future authority to buy count identities committed by the explicit Merkle root; shared exact reserveBudget USDG allowance. Inspect the committed ID list before authorizing. No code, keys or servers transfer."}),e("market_cancel_bid","market","cancelBid(uint256)",[["bidId","id"]],{note:"Cancel this bid; shared USDG allowance is unchanged so other bids can still fill."}),e("market_accept_bid","market","acceptBid(uint256,uint256,bytes32[],uint256)",[["bidId","id"],i,["proof","proof"],["minNet","uint"]],{owner:"agentId",approval:"nft",note:"Sell only this NFT into a currently valid bid; minNet pins seller USDG proceeds. Merkle proof and current bid rules are checked on chain during preview."}),e("market_bid_state","market","bidOf(uint256) view returns ((address maker,uint64 expiry,uint16 left,bool any,uint96 price,uint96 minLine,uint64 minRepaid,bytes32 target,bytes32 uriHash))",[["bidId","id"]],a),e("market_builder","market","builderOf(uint256) view returns ((address to,uint16 bps))",[i],a),e("market_set_builder","market","setBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{owner:"agentId",note:"Owner-only attribution before first sale; assigns future sale revenue share to to. Contract enforces enabled switch, no listing, and maximum 500 bps."}),e("market_change_builder","market","changeBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{note:"Current builder only; may lower or redirect own revenue share, never increase it."}),e("market_sale_split","market","saleSplit(uint256) view returns (uint256 fee,uint256 share,uint256 net)",[i],a),...["seats3","seats4"].flatMap((t,r)=>[e(`legacy_v${r+3}_close`,t,"close(uint256)",[i],{note:"Existing seat only. Close/freeze and return stake to original staker after final loan; default burn still applies. No new seats are opened."}),e(`legacy_v${r+3}_withdraw_offer`,t,"withdrawOffer(uint256,address)",[i],{args:["agentId","$wallet"],note:"Withdraw caller unaccepted offer; PRIORS returns to the staker."}),e(`legacy_v${r+3}_expire`,t,"expire(uint256)",[i],{note:"Expire idle seat under current contract rules."}),e(`legacy_v${r+3}_settle`,t,"settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile existing seat against pool loan/default after a missed hook."}),e(`legacy_v${r+3}_claim`,t,"claim(address) returns (uint256)",[],{args:["$wallet"],note:"Claim caller legacy seat USDG fees to this wallet."}),e(`legacy_v${r+3}_seat`,t,"getSeat(uint256) view returns ((address staker,uint64 openedAt,bool closing,uint8 status,uint128 line,uint128 burnBps,uint256 amount,uint256 feeMark,address owner))",[i],a),e(`legacy_v${r+3}_pending_fees`,t,"pendingFees(uint256) view returns (uint256)",[i],a),e(`legacy_v${r+3}_fees`,t,"feesOwed(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e(`legacy_v${r+3}_offer`,t,"offers(uint256,address) view returns (uint256)",[i],{...a,args:["agentId","$wallet"]})])];function J(t){return JSON.parse(JSON.stringify(t,(r,n)=>typeof n=="bigint"?n.toString():n))}function l(t,r,n=256){if(typeof t!="string"||!/^[0-9]+$/.test(t)||BigInt(t)>=1n<<BigInt(n))throw new u(`${r} must be a decimal base-unit string fitting uint${n}.`);return BigInt(t)}function te(t,[r,n]){let o=t[r];if(n==="address"){if(typeof o!="string"||!G.test(o))throw new u(`${r} must be a token or wallet address.`);return w(o)}if(n==="bool"){if(typeof o!="boolean")throw new u(`${r} must be true or false.`);return o}if(n==="bytes32"){if(typeof o!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o))throw new u(`${r} must be bytes32.`);return o}if(n==="proof"){if(!Array.isArray(o)||o.length>32||!o.every(d=>typeof d=="string"&&/^0x[0-9a-fA-F]{64}$/.test(d)))throw new u("proof needs at most 32 bytes32 hashes.");return o}if(n==="bytes"){if(typeof o!="string"||!/^0x(?:[0-9a-fA-F]{2})*$/.test(o)||o.length>32770)throw new u(`${r} must be bounded hexadecimal bytes.`);return o}if(n==="ids"||n==="gens"){if(!Array.isArray(o)||o.length===0||o.length>100)throw new u(`${r} needs 1 to 100 decimal strings.`);return o.map(d=>l(d,r,n==="gens"?32:256))}let s=l(o,r,n==="uint8"?8:n==="uint32"?32:256);if(n==="id"&&s===0n)throw new u(`${r} must be positive.`);if(r==="exitMode"&&s>2n)throw new u("exitMode must be 0 (hold), 1 (PRIORS), or 2 (USDG queue).");if(r==="layer"&&s>2n)throw new u("layer must be 0, 1, or 2.");return s}function P(t,r={}){return{type:"object",additionalProperties:!1,required:t.map(([n])=>n),properties:Object.fromEntries([...t.map(([n,o])=>[n,o==="bool"?{type:"boolean"}:o==="address"?H:o==="proof"?{type:"array",maxItems:32,items:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}}:o==="ids"||o==="gens"?{type:"array",maxItems:100,items:U()}:{type:"string",...o==="bytes32"?{pattern:"^0x[0-9a-fA-F]{64}$"}:o!=="bytes"?{pattern:"^[0-9]+$"}:{}}]),...Object.entries(r)])}}async function I(t,r,n,o=[]){let s=[`function ${n}`],d=S(s);return t.clientFor(b).readContract({address:r,abi:d,functionName:d[0].name,args:o})}async function B(t,r){return w(await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"ownerOf",args:[r]}))}function F(t){if(t.network==="testnet")throw new u("Priors ecosystem features are configured only on chain 4663.")}function N(t,r,n,o,s,d="0"){return{domain:z(),types:{Consent:[...j.Consent]},primaryType:"Consent",message:{agentId:t,sponsorId:r,owner:w(n),nonce:o,deadline:s,maxPremiumBps:d}}}async function M(t,r,n){if(!r||!r.request||O(r.request)!==O(n)||typeof r.signature!="string"||!/^0x(?:[a-fA-F0-9]{2}){1,4096}$/.test(r.signature))throw new u("Consent differs from this agent, sponsor, owner, premium cap, nonce or deadline.");let o=n.message.owner,s=await t.clientFor(b).getCode({address:o});if(s&&s!=="0x"){if(await t.clientFor(b).readContract({address:o,abi:ee,functionName:"isValidSignature",args:[O(n),r.signature]})!=="0x1626ba7e")throw new u("The owner contract rejected the consent signature.")}else if(!A(await Q({...n,signature:r.signature}),o))throw new u("The consent signature is not from the current agent owner.")}function ie(t,r,n,o,s,d){let g=Z.find(k=>k.name===t),p=t==="priors_sign_consent"?l(r.sponsorId,"sponsorId"):g?.consentRoot;if(!p||s.stage!=="priors_consent"||s.tool!==t||s.wallet!==w(n)||s.chainId!==b||s.agentId!==r.agentId||o.length!==1||o[0]?.kind!=="typedData")throw new u("Unexpected Priors consent continuation.");let h=l(s.nonce,"nonce").toString(),f=l(s.deadline,"deadline");if(f<=BigInt(d)||f>BigInt(d+3600))throw new u("Priors consent expired or exceeds its one-hour window.");let y=N(String(r.agentId),p.toString(),n,h,f.toString(),String(r.maxPremiumBps??"0"));if(!o[0].request||O(o[0].request)!==O(y))throw new u("Priors consent differs from the requested agent, root, owner or premium.")}async function K(t,r,n,o,s){let d=l(n.agentId,"agentId");if(!A(await B(t,d),o))throw new u("This operation requires the current identity owner wallet; a delegate cannot consent. Use the owner wallet.");let g=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),p=n.continuation,h=p?l(p.deadline,"deadline"):BigInt(Math.floor(Date.now()/1e3)+1800),f=l(n.maxPremiumBps??"0","maxPremiumBps");if(n.signature!==void 0&&!n.continuation)throw new u("A signature needs its locally confirmed Priors consent continuation.");if(f>200n)throw new u("maxPremiumBps exceeds the pool maximum of 200.");let y=N(d.toString(),s.toString(),o,g.toString(),h.toString(),f.toString());if(!p)return{steps:[{kind:"typedData",request:y}],continuation:{stage:"priors_consent",tool:r,wallet:o,chainId:b,agentId:d.toString(),nonce:g.toString(),deadline:h.toString()},summary:`Owner consent to sponsor #${s} for agent #${d}, premium cap ${f} bps; expires ${h}. No funds move from this signature. The local bridge must confirm the exact EIP-712 fields.`};if(ie(r,n,o,[{kind:"typedData",request:y}],p,Math.floor(Date.now()/1e3)),String(p.nonce)!==g.toString())throw new u("Priors consent nonce changed. Start the action again.");let k={request:y,signature:n.signature};return await M(t,k,y),{signedConsent:k}}async function oe(t,r,n,o){let s=c[r.contract],d=(p,h)=>h>0n?[t.approval(p,s,h.toString(),b)]:[];if(r.approval==="nft"){let p=l(n.agentId,"agentId"),h=await Promise.all([c.market,c.market1].map(f=>I(t,f,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[p])));for(let f of h){if(!f||typeof f!="object"||!("seller"in f)||typeof f.seller!="string")throw new u("Could not verify standing listings on both Priors markets; no NFT approval was built.");if(A(f.seller,o))throw new u("A standing listing in Priors market V1 or V2 could reactivate when NFT approval mines. Cancel it with priors_market_v1_cancel or priors_market_v2_cancel, verify both listings are cleared, then retry. No approval was built.")}return[t.approval(c.registry,s,p.toString(),b)]}if(r.approval==="market"){let p=await I(t,s,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[l(n.agentId,"agentId")]);if(p.price<=0n||p.price>l(n.maxPrice,"maxPrice")||p.nonce!==l(n.nonce,"nonce")||!A(p.uriHash,String(n.uriHash)))throw new u("Listing price, nonce or URI changed; read the listing again.");return d(c.usdg,p.price)}if(r.approval==="bid"){let p=l(n.reserveBudget,"reserveBudget");if(p>=1n<<128n||p<l(n.price,"price")*l(n.count??"1","count"))throw new u("Provide a finite exact bid reserve covering price times count.");return[t.approval(c.usdg,c.bidSpender,p.toString(),b)]}if(r.approval==="bond")return d(c.usdg,BigInt(await I(t,c.bond,"amount() view returns (uint256)")));if(r.approval==="mixed"){let p=l(n.priorsIn,"priorsIn"),h=l(n.usdgIn,"usdgIn");if(p+h===0n)throw new u("Provide a positive PRIORS or USDG input.");if(h>0n&&l(n.minOut,"minOut")===0n)throw new u("USDG conversion requires a positive minimum PRIORS output.");return[...d(c.priors,p),...d(c.usdg,h)]}if(!r.approval)return[];let g=l(n.amount,"amount");if(g===0n)throw new u("amount must be positive.");if(r.approval==="stock"){let p=r.name==="priors_stock_open"?w(String(n.token)):w((await I(t,c.stock,"getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[l(n.agentId,"agentId")])).token);if(p===ne)throw new u("No stock collateral position exists.");return d(p,g)}return d(c[r.approval],g)}function pe(t){let r=Z.map(n=>({name:n.name,inputSchema:{...P(n.fields,n.consentRoot?{maxPremiumBps:U(),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"},...n.externalConsent?{signedConsent:{type:"object",description:"Optional public owner signature from priors_sign_consent; controller may supply collateral. Never pass a key."}}:{}}:{}),description:n.note||"Read current Priors contract state. All amounts are token base-unit decimal strings."},async execute(o,s){F(t),s=w(s);let d=Object.fromEntries(n.fields.map(m=>[m[0],te(o,m)]));if(n.owner&&!(n.externalConsent&&o.signedConsent)&&!A(await B(t,d[n.owner]),s))throw new u("Owner-only feature: call from the current identity owner wallet. Nothing was signed.");if(n.contract==="savings"&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("The savings vault asset is not USDG. Nothing was signed.");if(n.contract==="autopay"&&await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2. Nothing was signed.");if(n.contract==="market"||n.contract==="market1"){if(o.expiry!==void 0){let m=l(o.expiry,"expiry",64),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+2592000n)throw new u("Market expiry must be within 30 days.")}if(o.price!==void 0&&l(o.price,"price")<5000000n)throw new u("Market price minimum is 5 USDG.");if(o.count!==void 0&&(l(o.count,"count")<1n||l(o.count,"count")>20n))throw new u("Bid count must be 1 to 20.")}if(n.name==="priors_treasury_first_line"&&l(o.expiry,"expiry",64)<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Treasury V5 invite expired.");if(o.deadline!==void 0){let m=l(o.deadline,"deadline"),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+3600n)throw new u("deadline must be in the next hour.")}if(o.agentIds&&o.agentIds.length!==o.generations.length)throw new u("agentIds and generations must have equal length.");let g;if(n.consentRoot)if(n.externalConsent&&o.signedConsent){if(g=o.signedConsent,!g.request?.message)throw new u("Provide the public signedConsent from the current identity owner.");let m=l(o.agentId,"agentId"),x=await B(t,m),T=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[m]}),q=l(g.request.message.deadline,"consent deadline");if(q<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired.");let L=l(o.maxPremiumBps??"0","maxPremiumBps");if(L>200n)throw new u("maxPremiumBps exceeds the pool cap.");await M(t,g,N(m.toString(),n.consentRoot.toString(),x,T.toString(),q.toString(),L.toString()))}else{let m=await K(t,n.name,o,s,n.consentRoot);if("steps"in m)return m;g=m.signedConsent}let p=(n.args??n.fields.map(([m])=>m)).map(m=>m==="$wallet"?s:m==="$consent"?g.request.message:m==="$signature"?g.signature:d[m]),h=S([n.signature]),f=h[0].name;if(n.read)return{chainId:b,contract:c[n.contract],units:"Base units; USDG 6 decimals, PRIORS 18 decimals; stock/savings scales come from token metadata.",value:J(await t.clientFor(b).readContract({address:c[n.contract],abi:h,functionName:f,args:p}))};let y=[...await oe(t,n,o,s),t.unsignedTx({to:c[n.contract],data:E({abi:h,functionName:f,args:p}),value:"0",chainId:b,description:`${n.name}: ${n.note}`})],k=await t.preview(y,s);return{txs:y,summary:`${n.note} Inputs (base units): ${JSON.stringify(J(d))}. ${k.summary}`}}}));return r.push({name:"priors_sign_consent",inputSchema:P([i,["sponsorId","id"],["maxPremiumBps","uint"]],{continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"}}),async execute(n,o){return F(t),K(t,"priors_sign_consent",n,w(o),l(n.sponsorId,"sponsorId"))}}),r.push({name:"priors_root_offer",inputSchema:P([["sponsorId","id"],i,v,["premiumBps","uint"]],{signedConsent:{type:"object",description:"The current agent owner output of priors_sign_consent. This is public signed authorization, never a private key."}}),async execute(n,o){F(t),o=w(o);let s=l(n.sponsorId,"sponsorId"),d=l(n.agentId,"agentId");if(!A(await B(t,s),o))throw new u("Only the sponsor root owner can send this offer.");let g=n.signedConsent;if(!g?.request?.message)throw new u("Ask the current agent owner to run priors_sign_consent from their wallet first.");let p=g.request.message,h=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),f=l(p.deadline,"consent deadline");if(f<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired; request a fresh consent.");let y=l(n.premiumBps,"premiumBps"),k=l(p.maxPremiumBps,"maxPremiumBps");if(y>k||k>200n)throw new u("premiumBps exceeds the owner consent or pool cap.");let m=N(d.toString(),s.toString(),await B(t,d),h.toString(),f.toString(),k.toString());await M(t,g,m);let x=S([`function vouchWithConsent(uint256,uint256,uint256,uint256,${C},bytes)`]),T=[t.unsignedTx({to:c.pool,data:E({abi:x,functionName:"vouchWithConsent",args:[s,d,l(n.amount,"amount"),y,m.message,g.signature]}),value:"0",chainId:b,description:"Sponsor-owned backing handoff with exact current-owner consent."})],q=await t.preview(T,o);return{txs:T,summary:`Vouch ${n.amount} USDG base units from sponsor #${s} to agent #${d}; ${y} bps premium (cap ${k}). Replaces its old sponsor only with no loan open. ${q.summary}`}}}),r.push(...re(t)),{tools:r}}function re(t){return[{name:"priors_autopay_on",inputSchema:P([i,["cap","uint"],["budget","uint"],["savingsShares","uint"],["late","bool"]]),async execute(r,n){F(t),n=w(n);let o=l(r.agentId,"agentId"),s=l(r.cap,"cap"),d=l(r.budget,"budget"),g=l(r.savingsShares,"savingsShares");if(typeof r.late!="boolean")throw new u("late must be true or false.");if(await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2.");let p=await I(t,c.autopay,"MAX_CAP() view returns (uint256)");if(s===0n||s>p||s>=1n<<32n||d<s||d===(1n<<256n)-1n||g===(1n<<256n)-1n)throw new u("Provide a positive supported per-loan cap and explicit finite budget at least cap; unlimited approvals are refused.");let h=await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"getAgentWallet",args:[o]});if(w(h)!==n)throw new u("Autopay enrollment requires the ERC-8004 declared agent wallet, not just its owner or pool delegate.");if(g>0n&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("Savings asset is not USDG.");let f=g>0n?await I(t,c.savings,"previewRedeem(uint256) view returns (uint256)",[g]):0n,y=S(["function enroll(uint256,uint256,bool,bool)"]),k=[t.approval(c.usdg,c.autopay,d.toString(),b),t.approval(c.savings,c.autopay,g.toString(),b),t.unsignedTx({to:c.autopay,data:E({abi:y,functionName:"enroll",args:[o,s,g>0n,r.late]}),value:"0",chainId:b,description:"Enroll future autopay with explicit finite USDG and savings share budgets."})],m=await t.preview(k,n);return{txs:k,summary:`Persistent future spending authorization: AutoRepay v2 can repay agent #${o} loans without a confirmation per loan, at most ${s} USDG base units per loan; exact total wallet allowance ${d} USDG base units and ${g} savings shares (currently ${f} USDG base units). These two allowances replace the budgets shared by ALL this wallet autopay plans, including setting savings allowance to zero when disabled. late=${r.late}; savings=${g>0n}. Revoke with priors_autopay_off, which also clears both allowances. ${m.summary}`}}},{name:"priors_autopay_off",inputSchema:P([i]),async execute(r,n){F(t),n=w(n);let o=S(["function revoke(uint256)"]),s=[t.unsignedTx({to:c.autopay,data:E({abi:o,functionName:"revoke",args:[l(r.agentId,"agentId")]}),value:"0",chainId:b,description:"Revoke own autopay plan."}),t.approval(c.usdg,c.autopay,"0",b),t.approval(c.savings,c.autopay,"0",b)],d=await t.preview(s,n);return{txs:s,summary:`Revoke this wallet autopay plan and zero both shared AutoRepay allowances. This also stops funding other plans using this wallet. ${d.summary}`}}}]}export{Y as a,$ as b,Z as c,J as d,l as e,N as f,ie as g,pe as h};
|
|
1
|
+
import{m as j,n as z}from"./3WBDHUV2.js";import{a as U}from"./UWOFA6GV.js";import{b as G,c as H,g as A}from"./73N3TOJL.js";import{a as b}from"./G6HCV67X.js";import{a as u}from"./5YS5V2LK.js";import{encodeFunctionData as E,getAddress as w,hashTypedData as O,parseAbi as S,recoverTypedDataAddress as Q}from"viem";var Y={pool:w("0x281210097f0de7A8FB6F87310AF0f089c9C8DE21"),registry:w("0x8004A169FB4a3325136EB29fA0ceB6D2e539a432"),usdg:w("0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"),priors:w("0xeDBf91223639800BCd5756815CAf908Df3b890bE"),stock:w("0xbEcd07EC689988e16b870C121756C4c2C8cb02B6"),backing:w("0xC999014C6218EC41f0aE412d49AE8f2aA4c539fD"),treasury:w("0xFe8fdf43c4b0443aCF8E8CD8facD62F1B770e267"),bond:w("0x346d3360B7258a18E8a2a55fe20E0F467113a53A"),autopay:w("0x72B510AF4e66e5960aB9b975e0BdCf80239e83A0"),savings:w("0xBeEff033F34C046626B8D0A041844C5d1A5409dd"),market:w("0x6a4583242B8313313E684d02aB7dc6bFf8749670"),market1:w("0xe5C8b3FacD7802099C1DfB88c0C818Cd0ebA7B19"),bidSpender:w("0x0dbd031a3e8cc91C2b0A3Bf6BD1d14c7AeD92878"),seats3:w("0x59D155C42A9263fA7596867b992bB3e84dF680a9"),seats4:w("0xb1c3a04496238D62E3c93118C297163855e22192")},c=Y,C="(uint256 agentId,uint256 sponsorId,address owner,uint256 maxPremiumBps,uint256 nonce,uint256 deadline)",X=S(["function ownerOf(uint256) view returns (address)","function getAgentWallet(uint256) view returns (address)"]),V=S(["function nonces(uint256) view returns (uint256)"]),ee=S(["function isValidSignature(bytes32,bytes) view returns (bytes4)"]),ne="0x0000000000000000000000000000000000000000",$="Owner stake is collateral, not a return. A default burns 75% of owner stake (50% of other backing); pending and leaving stake remains at risk until released. New backing waits 24 hours. Exit mode 0 holds, 1 returns PRIORS, 2 requests USDG through the guarded exit queue; no immediate payout is promised.",e=(t,r,n,o,s={})=>({name:`priors_${t}`,contract:r,signature:`function ${n}`,fields:o,note:"",...s}),i=["agentId","id"],v=["amount","uint"],W=["on","bool"],_=["generation","uint32"],R=["day","uint32"],D=["layer","uint8"],a={read:!0},Z=[e("set_delegate","pool","setDelegate(uint256,address)",[i,["delegate","address"]],{owner:"agentId",note:"Owner only. Delegate controls borrowing/repayment, not transfer of identity; clear with the zero address."}),e("root_enroll","pool","enrollRoot(uint256,uint256)",[i,v],{owner:"agentId",approval:"usdg",note:"Owner only. Locks USDG pool shares behind this sponsor root; active delegated lines and fees constrain withdrawals."}),e("root_add_stake","pool","addStake(uint256,uint256)",[i,v],{approval:"usdg",note:"Anyone may add USDG; only the root owner can withdraw it. This may give funds to another owner."}),e("root_unlock","pool","unlock(uint256,uint256,address)",[i,["shares","uint"]],{owner:"agentId",args:["agentId","shares","$wallet"],note:"Owner only. Withdraw root pool shares to this wallet, subject to delegated backing and fee locks."}),e("root_retire","pool","retireRoot(uint256)",[i],{owner:"agentId",note:"Owner only; requires no remaining stake or delegated lines."}),e("root_vouch","pool","vouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Adds the exact USDG amount of undrawn backing to an existing sponsored line."}),e("root_unvouch","pool","unvouch(uint256,uint256,uint256)",[["sponsorId","id"],i,v],{owner:"sponsorId",note:"Owner of sponsor only. Recalls undrawn backing; outstanding debt remains backed."}),e("root_freeze","pool","freeze(uint256,bool)",[i,["frozen","bool"]],{note:"Current sponsor owner only; freeze/unfreeze the agent line. Contract checks sponsor ownership."}),e("root_set_premium","pool","setPremium(uint256,uint256)",[i,["premiumBps","uint"]],{note:"Current sponsor owner only. Future loan premium cannot exceed the owner-consented cap."}),e("root_claim_fees","pool","claimSponsorFees(uint256,address)",[i],{owner:"agentId",args:["agentId","$wallet"],note:"Owner only; claim sponsor USDG fees to this wallet."}),e("root_set_hook","pool","setHook(uint256,address)",[i,["hook","address"]],{owner:"agentId",note:"Owner only. Changes root lending policy hook; pool enforces the delay while backing is committed."}),e("root_apply_hook","pool","applyHook(uint256)",[i],{note:"Apply a previously scheduled root hook after its on-chain delay."}),e("mark_default","pool","markDefault(uint256)",[["loanId","id"]],{note:"Irreversible: mark a past-grace unpaid loan defaulted, burn sponsor backing and mark the owner. Preview and confirm deliberately."}),e("import_history","pool","importFromV1(uint256)",[i],{note:"Import the v1 record, including defaults; this never imports unbacked capacity."}),e("fund_reserve","pool","fundReserve(uint256)",[v],{approval:"usdg",note:"Donate USDG to the pool reserve; receives no redeemable shares."}),e("root_shares","pool","rootShares(uint256) view returns (uint256)",[i],a),e("root_fee_locked","pool","feeLocked(uint256) view returns (uint256)",[i],a),e("root_fees_owed","pool","sponsorFees(uint256) view returns (uint256)",[i],a),e("root_backing","pool","backing(uint256) view returns (uint256)",[i],a),e("root_free_backing","pool","freeBacking(uint256) view returns (uint256)",[i],a),e("pool_parameters","pool","getParams() view returns ((uint256 minLoan,uint256 maxLoan,uint64 minTerm,uint64 maxTerm,uint64 grace,uint64 minScoreTerm,uint256 feeBps,uint256 sponsorFeeBps,uint256 protocolFeeBps,uint256 minStake,uint256 maxUtilizationBps,uint256 keeperBounty))",[],a),e("bond_deposit","bond","deposit(uint256)",[i],{owner:"agentId",approval:"bond",note:"Owner only. V2 treasury bond remains locked while any line or loan is open; it may replace and refund a former owner bond. Leave and release the legacy bond before Treasury V5 migration."}),e("bond_release","bond","release(uint256)",[i],{note:"Return V2 bond to its original depositor, not necessarily this wallet; contract enforces no line, no loan and age."}),e("bond_slash","bond","slash(uint256)",[i],{note:"Irreversible: send defaulted agent V2 bond to the configured beneficiary."}),e("bond_status","bond","bonds(uint256) view returns ((address depositor,uint64 at,uint256 amount))",[i],a),e("bond_releasable","bond","releasable(uint256) view returns (bool)",[i],a),e("bond_release_at","bond","unusedReleaseAt(uint256) view returns (uint256)",[i],a),e("treasury_move","treasury",`move(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","$consent","$signature"],note:"Move a former Treasury V4 line to V5, no loan open. Close old line, release legacy bond, deposit V2 bond first. V4 record and current-owner V2 bond are required."}),e("treasury_raise","treasury","raise(uint256)",[i],{note:"Raise an eligible Treasury V5 line using its current rules, score, history, age, weekly room and free backing. No unbacked credit."}),e("treasury_reclaim","treasury","reclaim(uint256)",[i],{note:"Reclaim an idle treasury line under on-chain rules; this ends borrowing access."}),e("treasury_first_line","treasury",`firstLine(uint256,uint64,bytes,${C},bytes)`,[i,["expiry","uint"],["invite","bytes"]],{owner:"agentId",consentRoot:8793n,externalConsent:!0,args:["agentId","expiry","invite","$consent","$signature"],note:"Redeem an already-issued Treasury V5 invite with V5 pool consent. Requires a valid V5 inviter signature; the current owner V2 bond is needed before borrowing. V4 invites cannot be reused."}),e("treasury_raise_room","treasury","raiseRoom() view returns (uint256)",[],a),e("treasury_first_lined","treasury","firstLined(uint256) view returns (bool)",[i],a),e("treasury_eligible_raise","treasury","eligibleForRaise(uint256) view returns (bool)",[i],a),e("treasury_room","treasury","epochRoom() view returns (uint256)",[],a),e("treasury_rules","treasury","rules() view returns (uint256 reserveBps,uint256 firstLine,uint256 secondLine,uint256 epochCap,uint64 epochLength,uint64 minSeasoning,uint256 minQualified,uint256 minScore,uint64 idleAfter)",[],a),e("stock_open","stock",`open(uint256,address,uint256,${C},bytes) returns (uint256)`,[i,["token","address"],v],{owner:"agentId",consentRoot:6424n,externalConsent:!0,approval:"stock",args:["agentId","token","amount","$consent","$signature"],note:"Owner or on-chain controller with a supplied owner consent posts exact collateral. Token must be accepted and usable; live price, LTV, line cap and backing determine the line. Default seizes debt plus buffer; issuer restrictions and burns may reduce returned collateral."}),e("stock_add","stock","addCollateral(uint256,uint256)",[i,v],{approval:"stock",note:"Depositor only. Adds exact position token collateral; contract decides resulting draw room."}),e("stock_close","stock","close(uint256)",[i],{note:"Depositor or controller closes/freezes the line; collateral pays its depositor after the last loan, subject to default and issuer shortfalls."}),e("stock_expire","stock","expire(uint256)",[i],{note:"Expire idle stock line after on-chain idle rules; may close borrowing access."}),e("stock_reconcile","stock","reconcile(uint256,uint256)",[i,["maxLoans","uint"]],{note:"Reconcile the collateral debt walk against pool loans; contract ignores maxLoans in this implementation."}),e("stock_settle","stock","settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile stock collateral after a default or missed hook; may seize collateral according to the loan."}),e("stock_record_feed","stock","record(address,uint256) returns (uint80)",[["feed","address"],["maxRounds","uint"]],{note:"Advance public oracle price tape; may unblock new stock lines and default settlement."}),e("stock_reclaim","stock","reclaim(uint256)",[i],{note:"Reclaim a written-off stock position after it is no longer backed; return remains subject to vault token shortfall."}),e("stock_state","stock","getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[i],a),e("stock_borrow_room","stock","borrowRoom(uint256) view returns (uint256)",[i],a),e("stock_asset_state","stock","assets(address) view returns (address feed,uint64 maxAge,uint8 tokenDecimals,uint8 feedDecimals,bool enabled,uint16 ltvBps,uint128 lineCap)",[["token","address"]],a),e("stock_lending_status","stock","lendStatus(address) view returns (uint8)",[["token","address"]],a),e("stock_value","stock","valueOf(address,uint256) view returns (bool ok,uint256 value)",[["token","address"],v],a),e("stock_ltv","stock","ltvOf(uint256,address) view returns (uint256)",[i,["token","address"]],a),e("backing_open","backing",`open(uint256,uint256,bool,${C},bytes)`,[i,v,["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"priors",args:["agentId","amount","autoAdd","$consent","$signature"],note:$}),e("backing_open_with_usdg","backing",`openWithUsdg(uint256,uint256,uint256,uint256,uint256,bool,${C},bytes)`,[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{owner:"agentId",consentRoot:8762n,approval:"mixed",args:["agentId","priorsIn","usdgIn","minOut","deadline","autoAdd","$consent","$signature"],note:$}),e("backing_add","backing","back(uint256,uint256,bool)",[i,v,["autoAdd","bool"]],{approval:"priors",note:$+" Owner-only at launch; other backers require both global and individual permission."}),e("backing_add_with_usdg","backing","backWithUsdg(uint256,uint256,uint256,uint256,uint256,bool)",[i,["priorsIn","uint"],["usdgIn","uint"],["minOut","uint"],["deadline","uint"],["autoAdd","bool"]],{approval:"mixed",note:$}),e("backing_leave","backing","leave(uint256,uint256,uint8)",[i,v,["exitMode","uint8"]],{note:$}),e("backing_close","backing","close(uint256,uint8)",[i,["exitMode","uint8"]],{note:$}),...["refresh","promote","expire","sync","pokeFees","recordRepay","noteDelegate"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256)`,[i],{note:"Reconcile this V5 book against current pool, owner, record, tier and backing rules; no payout is promised."})),...["setAutoAdd","setProtocolBacking","setOthersBacking"].map(t=>e(`backing_${t.replace(/[A-Z]/g,r=>`_${r.toLowerCase()}`)}`,"backing",`${t}(uint256,bool)`,[i,W],{note:"Change this V5 book setting under the contract ownership/holder rules. Auto-add can compound rewards into stake at risk."})),e("backing_reconsent","backing",`reconsent(uint256,${C},bytes)`,[i],{owner:"agentId",consentRoot:8762n,args:["agentId","$consent","$signature"],note:"Owner only. Renew the pool consent for V5 backing."}),e("backing_release","backing","release(uint256,uint32,uint32,uint256,uint256)",[i,_,R,["minUsdgOut","uint"],["deadline","uint"]],{note:"Release caller day bucket after its release rule. Zero minUsdgOut returns PRIORS; positive requests a guarded sale. Stake stays burnable until release. Read generation/day from chain events."}),e("backing_release_for","backing","releaseFor(uint256,uint32,address,uint32)",[i,_,["holder","address"],R],{note:"Return eligible PRIORS to its holder under generation/day release rules, never redirect proceeds."}),e("backing_finish_close","backing","finishClose(uint256,uint32)",[i,_],{note:"Finish an eligible generation close; pays the bound owner under its release rules."}),e("backing_claim_settled","backing","claimSettled(uint256,uint32,address)",[i,_,["holder","address"]],{note:"Pay settled generation stake to the named holder, after any default burn."}),e("backing_claim_record","backing","claimSettled(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Pay settled day record to its holder after any default burn."}),e("backing_queue_exit","backing","queueExit(uint256,uint32,address,uint8,uint32)",[i,_,["holder","address"],D,R],{note:"Holder/keeper queues ready USDG-mode stake; minimum and queue window apply. A queue entry is not a fill or payout."}),e("backing_settle","backing","settle(uint256,uint32,uint256)",[i,_,["loanId","id"]],{note:"Reconcile V5 generation with a pool loan/default after a missed hook."}),e("backing_record_loan","backing","recordLoan(uint256)",[["loanId","id"]],{note:"Record current pool loan in V5 book."}),e("backing_record_default","backing","recordDefault(uint256)",[["loanId","id"]],{note:"Reconcile a marked pool default and its stake burn."}),e("backing_collect","backing","collect(uint256[],uint32[]) returns (uint256)",[["agentIds","ids"],["generations","gens"]],{note:"Collect caller fees for explicitly selected generations; auto-add settings may retain stake."}),e("backing_fund","backing","fund(uint256)",[v],{approval:"usdg",note:"Donate USDG to V5 root backing; donor receives no withdrawable claim."}),e("backing_book","backing","getGen(uint256,uint32) view returns ((address owner,uint64 openedAt,uint8 status,bool ownerChanged,bool optOut,bool othersOff,bool pointsVoid,bool openRoomCharged,bool closedByOwner,bool movePending,bool splitPending,uint64 movePendingAt,uint8 tier,uint8 countedAtTier,uint8 listLen,uint32 tierStep,uint64 tierSince,uint64 lastLateAt,uint64 closedMark,uint64 lastRaiseAt,uint64 promoEpoch,uint64 stakeEpoch,uint64 placeEpoch,uint160 movePendingSqrt,uint256 roomLine,uint256 openLine,uint256 promoCredit,uint256 stakeRaised,uint256 placed,uint256 index,uint256 divisor,uint256 defaultProof,uint256 cLive,uint256 cUnits,uint256[3] list,uint256[3] counted,uint256[3] pendingTok,uint256[3] leavingLive,uint256[3] tokens,uint64[3] layerEnd,uint160[3] endSqrt,uint8[3] ownerEndMode,uint32[2][3] liveDay,uint32[3] leaveHead,(uint64 epoch,uint192 points)[5] points))",[i,_],a),e("backing_generation","backing","latestGen(uint256) view returns (uint32)",[i],a),e("backing_line","backing","lineOf(uint256) view returns (uint256)",[i],a),e("backing_quote","backing","needed(uint256,uint256,bool) view returns ((uint256 minA,uint256 fullLine,uint256 capA,uint160 sqrtP,uint8 k,uint8 kCached,bool depthGuard,uint256 line,uint256 ownerA,uint256 ownBacking,uint256 roomB,uint256 lineIfAdded,uint256 weekAfter))",[i,["tokens","uint"],["asOwner","bool"]],a),e("backing_position","backing","position(uint256,uint32,uint8,address) view returns ((uint256 counted,uint256 checkpoint,uint256 a0,uint256 a1,uint32 d0,uint32 d1,bool autoAdd))",[i,_,D,["holder","address"]],a),e("backing_record","backing","record(uint256,uint32,uint8,uint32,address) view returns ((uint256 counted,uint256 uncounted,uint256 creditedTo,uint160 sqrtLeave,uint8 mode,uint64 entry))",[i,_,D,R,["holder","address"]],a),e("backing_bucket","backing","leavingBucket(uint256,uint32,uint8,uint32) view returns ((bool exists,bool retired,uint64 latestLeave,uint64 releasableAt,uint256 loanCount,uint256 counted,uint256 uncounted,uint256 retireIndex))",[i,_,D,R],a),e("backing_settings","backing","settings() view returns (bool openBacking,uint256 premiumCap,uint256 maxSwapUsdg,uint256 openRoom,uint256 raiseRoom,uint256 vouchCap,uint8 minDrawK,bool premiumCheck,uint64 pausedUntil)",[],a),e("backing_reopen_at","backing","reopenAt(uint256) view returns (uint64)",[i],a),e("backing_sync_prices","backing","sync()",[],{note:"Update global V5 price/guard observations."}),e("backing_exit_service_open","backing","exitServiceOpen() view returns (bool)",[],a),e("backing_usdg_path","backing","usdgPathOpen(uint256) view returns (bool,uint8)",[["usdgIn","uint"]],a),e("backing_entry_rule","backing","entryRule() view returns (uint8 minEntryLoans,uint32 minEntryDays)",[],a),e("backing_target_premium","backing","targetPremiumBps(uint256) view returns (uint256)",[i],a),e("backing_price_cache","backing","priceCache() view returns (uint160 sqrtMedian,uint64 obsAt,uint160 sqrtWeekLow,uint160 sqrtObservation)",[],a),e("backing_pending_bucket","backing","pendingBucket(uint256,uint32,uint8,uint32) view returns ((uint128 amount,uint64 lastDeposit,bool merged,bool dead,uint256 mergeIndex))",[i,_,D,R],a),e("backing_exit_head","backing","exitHead() view returns (uint256 entryId,address holder,uint256 rest,uint160 sqrtPLeave,uint64 joinedAt)",[],a),e("backing_exit_entry","backing","entry(uint256) view returns ((uint256 id,uint32 gen,uint8 layer,uint32 day,address holder,uint64 joinedAt,uint64 prev,uint64 next))",[["entryId","uint"]],a),e("backing_flush","backing","flush()",[],{note:"Reconcile V5 fees and backing buffers; no payout to caller is promised."}),e("backing_claimable","backing","claimable(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("autopay_hold","autopay","hold(bool)",[W],{note:"Hold/resume future autopay attempts for this wallet; allowances remain until explicitly revoked."}),e("autopay_max_cap","autopay","MAX_CAP() view returns (uint256)",[],a),e("autopay_window","autopay","WINDOW() view returns (uint64)",[],a),e("autopay_paused_until","autopay","pausedUntil() view returns (uint64)",[],a),e("autopay_plan","autopay","planOf(address,uint256) view returns (uint32 cap,address owner,bool on,bool useSavings,bool late,uint32 epoch)",[i],{...a,args:["$wallet","agentId"]}),e("autopay_check","autopay","check(uint256) view returns ((uint8 status,uint256 agentId,uint256 due,uint64 opens,uint64 closes,address wallet,uint256 fromWallet,uint256 fromWalletSavings,address owner,uint256 fromOwner,uint256 fromOwnerSavings))",[["loanId","id"]],a),e("autopay_epoch","autopay","epochOf(uint256) view returns (uint32 epoch,bool stale)",[i],a),e("autopay_held","autopay","held(address) view returns (bool)",[],{...a,args:["$wallet"]}),e("savings_deposit","savings","deposit(uint256,address) returns (uint256)",[v],{approval:"usdg",args:["amount","$wallet"],note:"Deposit own USDG into Priors default external Morpho savings vault; vault/allocator risk and withdrawal liquidity apply."}),e("savings_withdraw","savings","withdraw(uint256,address,address) returns (uint256)",[v],{args:["amount","$wallet","$wallet"],note:"Withdraw exact USDG amount from own savings. Insufficient liquidity fails the preview; no immediate exit is promised."}),e("savings_redeem","savings","redeem(uint256,address,address) returns (uint256)",[["shares","uint"]],{args:["shares","$wallet","$wallet"],note:"Redeem exact own savings shares to this wallet; liquidity and rounding apply."}),e("savings_balance","savings","balanceOf(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e("savings_value","savings","previewRedeem(uint256) view returns (uint256)",[["shares","uint"]],a),...["market","market1"].flatMap((t,r)=>[e(`market_v${r===0?2:1}_listing`,t,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[i],a),e(`market_v${r===0?2:1}_record_hash`,t,"recordHash(uint256) view returns (bytes32)",[i],a),e(`market_v${r===0?2:1}_list`,t,"list(uint256,uint256,uint64)",[i,["price","uint"],["expiry","uint"]],{owner:"agentId",approval:"nft",note:"Owner sells this ERC-8004 NFT, its record and any followed treasury line. This does not transfer code, keys or servers. Approves only this NFT; confirm the sale terms and contract-enforced hold/line rules."}),e(`market_v${r===0?2:1}_cancel`,t,"cancel(uint256)",[i],{note:"Cancel the standing listing; NFT approval can remain until explicitly cleared."}),e(`market_v${r===0?2:1}_buy`,t,"buy(uint256,uint256,uint256,bytes32,bytes32)",[i,["maxPrice","uint"],["nonce","uint"],["uriHash","bytes32"],["recordHash","bytes32"]],{approval:"market",note:"Buy an ERC-8004 NFT to this wallet with exact live asking-price approval and pinned listing nonce, tokenURI and current credit record. A followed line still needs the new owner bond before borrowing. No keys/code/servers are included."})]),e("market_bid","market","bid(uint256,uint256,uint64,bytes32,uint256,uint256) returns (uint256)",[i,["price","uint"],["expiry","uint"],["uriHash","bytes32"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["agentId","price","expiry","uriHash","minRepaid","minLine"],approval:"bid",note:"Standing future purchase authority: another owner can fill this bid later without a new click. Exact reserveBudget USDG allowance is shared by all this wallet bids and replaces the old allowance. Cancel bid and clear unused budget deliberately."}),e("market_bid_any","market","bidAny(bytes32,uint256,uint256,uint64,uint256,uint256) returns (uint256)",[["root","bytes32"],["count","uint"],["price","uint"],["expiry","uint"],["minRepaid","uint"],["minLine","uint"],["reserveBudget","uint"]],{args:["root","count","price","expiry","minRepaid","minLine"],approval:"bid",note:"Standing future authority to buy count identities committed by the explicit Merkle root; shared exact reserveBudget USDG allowance. Inspect the committed ID list before authorizing. No code, keys or servers transfer."}),e("market_cancel_bid","market","cancelBid(uint256)",[["bidId","id"]],{note:"Cancel this bid; shared USDG allowance is unchanged so other bids can still fill."}),e("market_accept_bid","market","acceptBid(uint256,uint256,bytes32[],uint256)",[["bidId","id"],i,["proof","proof"],["minNet","uint"]],{owner:"agentId",approval:"nft",note:"Sell only this NFT into a currently valid bid; minNet pins seller USDG proceeds. Merkle proof and current bid rules are checked on chain during preview."}),e("market_bid_state","market","bidOf(uint256) view returns ((address maker,uint64 expiry,uint16 left,bool any,uint96 price,uint96 minLine,uint64 minRepaid,bytes32 target,bytes32 uriHash))",[["bidId","id"]],a),e("market_builder","market","builderOf(uint256) view returns ((address to,uint16 bps))",[i],a),e("market_set_builder","market","setBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{owner:"agentId",note:"Owner-only attribution before first sale; assigns future sale revenue share to to. Contract enforces enabled switch, no listing, and maximum 500 bps."}),e("market_change_builder","market","changeBuilder(uint256,address,uint256)",[i,["to","address"],["bps","uint"]],{note:"Current builder only; may lower or redirect own revenue share, never increase it."}),e("market_sale_split","market","saleSplit(uint256) view returns (uint256 fee,uint256 share,uint256 net)",[i],a),...["seats3","seats4"].flatMap((t,r)=>[e(`legacy_v${r+3}_close`,t,"close(uint256)",[i],{note:"Existing seat only. Close/freeze and return stake to original staker after final loan; default burn still applies. No new seats are opened."}),e(`legacy_v${r+3}_withdraw_offer`,t,"withdrawOffer(uint256,address)",[i],{args:["agentId","$wallet"],note:"Withdraw caller unaccepted offer; PRIORS returns to the staker."}),e(`legacy_v${r+3}_expire`,t,"expire(uint256)",[i],{note:"Expire idle seat under current contract rules."}),e(`legacy_v${r+3}_settle`,t,"settle(uint256,uint256)",[i,["loanId","id"]],{note:"Reconcile existing seat against pool loan/default after a missed hook."}),e(`legacy_v${r+3}_claim`,t,"claim(address) returns (uint256)",[],{args:["$wallet"],note:"Claim caller legacy seat USDG fees to this wallet."}),e(`legacy_v${r+3}_seat`,t,"getSeat(uint256) view returns ((address staker,uint64 openedAt,bool closing,uint8 status,uint128 line,uint128 burnBps,uint256 amount,uint256 feeMark,address owner))",[i],a),e(`legacy_v${r+3}_pending_fees`,t,"pendingFees(uint256) view returns (uint256)",[i],a),e(`legacy_v${r+3}_fees`,t,"feesOwed(address) view returns (uint256)",[],{...a,args:["$wallet"]}),e(`legacy_v${r+3}_offer`,t,"offers(uint256,address) view returns (uint256)",[i],{...a,args:["agentId","$wallet"]})])];function J(t){return JSON.parse(JSON.stringify(t,(r,n)=>typeof n=="bigint"?n.toString():n))}function l(t,r,n=256){if(typeof t!="string"||!/^[0-9]+$/.test(t)||BigInt(t)>=1n<<BigInt(n))throw new u(`${r} must be a decimal base-unit string fitting uint${n}.`);return BigInt(t)}function te(t,[r,n]){let o=t[r];if(n==="address"){if(typeof o!="string"||!G.test(o))throw new u(`${r} must be a token or wallet address.`);return w(o)}if(n==="bool"){if(typeof o!="boolean")throw new u(`${r} must be true or false.`);return o}if(n==="bytes32"){if(typeof o!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o))throw new u(`${r} must be bytes32.`);return o}if(n==="proof"){if(!Array.isArray(o)||o.length>32||!o.every(d=>typeof d=="string"&&/^0x[0-9a-fA-F]{64}$/.test(d)))throw new u("proof needs at most 32 bytes32 hashes.");return o}if(n==="bytes"){if(typeof o!="string"||!/^0x(?:[0-9a-fA-F]{2})*$/.test(o)||o.length>32770)throw new u(`${r} must be bounded hexadecimal bytes.`);return o}if(n==="ids"||n==="gens"){if(!Array.isArray(o)||o.length===0||o.length>100)throw new u(`${r} needs 1 to 100 decimal strings.`);return o.map(d=>l(d,r,n==="gens"?32:256))}let s=l(o,r,n==="uint8"?8:n==="uint32"?32:256);if(n==="id"&&s===0n)throw new u(`${r} must be positive.`);if(r==="exitMode"&&s>2n)throw new u("exitMode must be 0 (hold), 1 (PRIORS), or 2 (USDG queue).");if(r==="layer"&&s>2n)throw new u("layer must be 0, 1, or 2.");return s}function P(t,r={}){return{type:"object",additionalProperties:!1,required:t.map(([n])=>n),properties:Object.fromEntries([...t.map(([n,o])=>[n,o==="bool"?{type:"boolean"}:o==="address"?H:o==="proof"?{type:"array",maxItems:32,items:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}}:o==="ids"||o==="gens"?{type:"array",maxItems:100,items:U()}:{type:"string",...o==="bytes32"?{pattern:"^0x[0-9a-fA-F]{64}$"}:o!=="bytes"?{pattern:"^[0-9]+$"}:{}}]),...Object.entries(r)])}}async function I(t,r,n,o=[]){let s=[`function ${n}`],d=S(s);return t.clientFor(b).readContract({address:r,abi:d,functionName:d[0].name,args:o})}async function B(t,r){return w(await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"ownerOf",args:[r]}))}function F(t){if(t.network==="testnet")throw new u("Priors ecosystem features are configured only on chain 4663.")}function N(t,r,n,o,s,d="0"){return{domain:z(),types:{Consent:[...j.Consent]},primaryType:"Consent",message:{agentId:t,sponsorId:r,owner:w(n),nonce:o,deadline:s,maxPremiumBps:d}}}async function M(t,r,n){if(!r||!r.request||O(r.request)!==O(n)||typeof r.signature!="string"||!/^0x(?:[a-fA-F0-9]{2}){1,4096}$/.test(r.signature))throw new u("Consent differs from this agent, sponsor, owner, premium cap, nonce or deadline.");let o=n.message.owner,s=await t.clientFor(b).getCode({address:o});if(s&&s!=="0x"){if(await t.clientFor(b).readContract({address:o,abi:ee,functionName:"isValidSignature",args:[O(n),r.signature]})!=="0x1626ba7e")throw new u("The owner contract rejected the consent signature.")}else if(!A(await Q({...n,signature:r.signature}),o))throw new u("The consent signature is not from the current agent owner.")}function ie(t,r,n,o,s,d){let g=Z.find(k=>k.name===t),p=t==="priors_sign_consent"?l(r.sponsorId,"sponsorId"):g?.consentRoot;if(!p||s.stage!=="priors_consent"||s.tool!==t||s.wallet!==w(n)||s.chainId!==b||s.agentId!==r.agentId||o.length!==1||o[0]?.kind!=="typedData")throw new u("Unexpected Priors consent continuation.");let h=l(s.nonce,"nonce").toString(),f=l(s.deadline,"deadline");if(f<=BigInt(d)||f>BigInt(d+3600))throw new u("Priors consent expired or exceeds its one-hour window.");let y=N(String(r.agentId),p.toString(),n,h,f.toString(),String(r.maxPremiumBps??"0"));if(!o[0].request||O(o[0].request)!==O(y))throw new u("Priors consent differs from the requested agent, root, owner or premium.")}async function K(t,r,n,o,s){let d=l(n.agentId,"agentId");if(!A(await B(t,d),o))throw new u("This operation requires the current identity owner wallet; a delegate cannot consent. Use the owner wallet.");let g=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),p=n.continuation,h=p?l(p.deadline,"deadline"):BigInt(Math.floor(Date.now()/1e3)+1800),f=l(n.maxPremiumBps??"0","maxPremiumBps");if(n.signature!==void 0&&!n.continuation)throw new u("A signature needs its locally confirmed Priors consent continuation.");if(f>200n)throw new u("maxPremiumBps exceeds the pool maximum of 200.");let y=N(d.toString(),s.toString(),o,g.toString(),h.toString(),f.toString());if(!p)return{steps:[{kind:"typedData",request:y}],continuation:{stage:"priors_consent",tool:r,wallet:o,chainId:b,agentId:d.toString(),nonce:g.toString(),deadline:h.toString()},summary:`Owner consent to sponsor #${s} for agent #${d}, premium cap ${f} bps; expires ${h}. No funds move from this signature. The local bridge must confirm the exact EIP-712 fields.`};if(ie(r,n,o,[{kind:"typedData",request:y}],p,Math.floor(Date.now()/1e3)),String(p.nonce)!==g.toString())throw new u("Priors consent nonce changed. Start the action again.");let k={request:y,signature:n.signature};return await M(t,k,y),{signedConsent:k}}async function oe(t,r,n,o){let s=c[r.contract],d=(p,h)=>h>0n?[t.approval(p,s,h.toString(),b)]:[];if(r.approval==="nft"){let p=l(n.agentId,"agentId"),h=await Promise.all([c.market,c.market1].map(f=>I(t,f,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[p])));for(let f of h){if(!f||typeof f!="object"||!("seller"in f)||typeof f.seller!="string")throw new u("Could not verify standing listings on both Priors markets; no NFT approval was built.");if(A(f.seller,o))throw new u("A standing listing in Priors market V1 or V2 could reactivate when NFT approval mines. Cancel it with priors_market_v1_cancel or priors_market_v2_cancel, verify both listings are cleared, then retry. No approval was built.")}return[t.approval(c.registry,s,p.toString(),b)]}if(r.approval==="market"){let p=await I(t,s,"listingOf(uint256) view returns ((address seller,uint256 price,uint64 expiry,uint256 nonce,bytes32 uriHash,uint256 loansRepaid))",[l(n.agentId,"agentId")]);if(p.price<=0n||p.price>l(n.maxPrice,"maxPrice")||p.nonce!==l(n.nonce,"nonce")||!A(p.uriHash,String(n.uriHash)))throw new u("Listing price, nonce or URI changed; read the listing again.");return d(c.usdg,p.price)}if(r.approval==="bid"){let p=l(n.reserveBudget,"reserveBudget");if(p>=1n<<128n||p<l(n.price,"price")*l(n.count??"1","count"))throw new u("Provide a finite exact bid reserve covering price times count.");return[t.approval(c.usdg,c.bidSpender,p.toString(),b)]}if(r.approval==="bond")return d(c.usdg,BigInt(await I(t,c.bond,"amount() view returns (uint256)")));if(r.approval==="mixed"){let p=l(n.priorsIn,"priorsIn"),h=l(n.usdgIn,"usdgIn");if(p+h===0n)throw new u("Provide a positive PRIORS or USDG input.");if(h>0n&&l(n.minOut,"minOut")===0n)throw new u("USDG conversion requires a positive minimum PRIORS output.");return[...d(c.priors,p),...d(c.usdg,h)]}if(!r.approval)return[];let g=l(n.amount,"amount");if(g===0n)throw new u("amount must be positive.");if(r.approval==="stock"){let p=r.name==="priors_stock_open"?w(String(n.token)):w((await I(t,c.stock,"getPosition(uint256) view returns ((address depositor,address owner,address token,uint64 openedAt,bool closing,uint8 status,uint128 line,uint256 amount))",[l(n.agentId,"agentId")])).token);if(p===ne)throw new u("No stock collateral position exists.");return d(p,g)}return d(c[r.approval],g)}function pe(t){let r=Z.map(n=>({name:n.name,inputSchema:{...P(n.fields,n.consentRoot?{maxPremiumBps:U(),continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"},...n.externalConsent?{signedConsent:{type:"object",description:"Optional public owner signature from priors_sign_consent; controller may supply collateral. Never pass a key."}}:{}}:{}),description:n.note||"Read current Priors contract state. All amounts are token base-unit decimal strings."},async execute(o,s){F(t),s=w(s);let d=Object.fromEntries(n.fields.map(m=>[m[0],te(o,m)]));if(n.owner&&!(n.externalConsent&&o.signedConsent)&&!A(await B(t,d[n.owner]),s))throw new u("Owner-only feature: call from the current identity owner wallet. Nothing was signed.");if(n.contract==="savings"&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("The savings vault asset is not USDG. Nothing was signed.");if(n.contract==="autopay"&&await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2. Nothing was signed.");if(n.contract==="market"||n.contract==="market1"){if(o.expiry!==void 0){let m=l(o.expiry,"expiry",64),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+2592000n)throw new u("Market expiry must be within 30 days.")}if(o.price!==void 0&&l(o.price,"price")<5000000n)throw new u("Market price minimum is 5 USDG.");if(o.count!==void 0&&(l(o.count,"count")<1n||l(o.count,"count")>20n))throw new u("Bid count must be 1 to 20.")}if(n.name==="priors_treasury_first_line"&&l(o.expiry,"expiry",64)<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Treasury V5 invite expired.");if(o.deadline!==void 0){let m=l(o.deadline,"deadline"),x=BigInt(Math.floor(Date.now()/1e3));if(m<=x||m>x+3600n)throw new u("deadline must be in the next hour.")}if(o.agentIds&&o.agentIds.length!==o.generations.length)throw new u("agentIds and generations must have equal length.");let g;if(n.consentRoot)if(n.externalConsent&&o.signedConsent){if(g=o.signedConsent,!g.request?.message)throw new u("Provide the public signedConsent from the current identity owner.");let m=l(o.agentId,"agentId"),x=await B(t,m),T=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[m]}),q=l(g.request.message.deadline,"consent deadline");if(q<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired.");let L=l(o.maxPremiumBps??"0","maxPremiumBps");if(L>200n)throw new u("maxPremiumBps exceeds the pool cap.");await M(t,g,N(m.toString(),n.consentRoot.toString(),x,T.toString(),q.toString(),L.toString()))}else{let m=await K(t,n.name,o,s,n.consentRoot);if("steps"in m)return m;g=m.signedConsent}let p=(n.args??n.fields.map(([m])=>m)).map(m=>m==="$wallet"?s:m==="$consent"?g.request.message:m==="$signature"?g.signature:d[m]),h=S([n.signature]),f=h[0].name;if(n.read)return{chainId:b,contract:c[n.contract],units:"Base units; USDG 6 decimals, PRIORS 18 decimals; stock/savings scales come from token metadata.",value:J(await t.clientFor(b).readContract({address:c[n.contract],abi:h,functionName:f,args:p}))};let y=[...await oe(t,n,o,s),t.unsignedTx({to:c[n.contract],data:E({abi:h,functionName:f,args:p}),value:"0",chainId:b,description:`${n.name}: ${n.note}`})],k=await t.preview(y,s);return{txs:y,summary:`${n.note} Inputs (base units): ${JSON.stringify(J(d))}. ${k.summary}`}}}));return r.push({name:"priors_sign_consent",inputSchema:P([i,["sponsorId","id"],["maxPremiumBps","uint"]],{continuation:{type:"object"},signature:{type:"string",pattern:"^0x([a-fA-F0-9]{2})+$"}}),async execute(n,o){return F(t),K(t,"priors_sign_consent",n,w(o),l(n.sponsorId,"sponsorId"))}}),r.push({name:"priors_root_offer",inputSchema:P([["sponsorId","id"],i,v,["premiumBps","uint"]],{signedConsent:{type:"object",description:"The current agent owner output of priors_sign_consent. This is public signed authorization, never a private key."}}),async execute(n,o){F(t),o=w(o);let s=l(n.sponsorId,"sponsorId"),d=l(n.agentId,"agentId");if(!A(await B(t,s),o))throw new u("Only the sponsor root owner can send this offer.");let g=n.signedConsent;if(!g?.request?.message)throw new u("Ask the current agent owner to run priors_sign_consent from their wallet first.");let p=g.request.message,h=await t.clientFor(b).readContract({address:c.pool,abi:V,functionName:"nonces",args:[d]}),f=l(p.deadline,"consent deadline");if(f<=BigInt(Math.floor(Date.now()/1e3)))throw new u("Owner consent expired; request a fresh consent.");let y=l(n.premiumBps,"premiumBps"),k=l(p.maxPremiumBps,"maxPremiumBps");if(y>k||k>200n)throw new u("premiumBps exceeds the owner consent or pool cap.");let m=N(d.toString(),s.toString(),await B(t,d),h.toString(),f.toString(),k.toString());await M(t,g,m);let x=S([`function vouchWithConsent(uint256,uint256,uint256,uint256,${C},bytes)`]),T=[t.unsignedTx({to:c.pool,data:E({abi:x,functionName:"vouchWithConsent",args:[s,d,l(n.amount,"amount"),y,m.message,g.signature]}),value:"0",chainId:b,description:"Sponsor-owned backing handoff with exact current-owner consent."})],q=await t.preview(T,o);return{txs:T,summary:`Vouch ${n.amount} USDG base units from sponsor #${s} to agent #${d}; ${y} bps premium (cap ${k}). Replaces its old sponsor only with no loan open. ${q.summary}`}}}),r.push(...re(t)),{tools:r}}function re(t){return[{name:"priors_autopay_on",inputSchema:P([i,["cap","uint"],["budget","uint"],["savingsShares","uint"],["late","bool"]]),async execute(r,n){F(t),n=w(n);let o=l(r.agentId,"agentId"),s=l(r.cap,"cap"),d=l(r.budget,"budget"),g=l(r.savingsShares,"savingsShares");if(typeof r.late!="boolean")throw new u("late must be true or false.");if(await I(t,c.autopay,"VERSION() view returns (uint256)")!==2n)throw new u("AutoRepay VERSION is not 2.");let p=await I(t,c.autopay,"MAX_CAP() view returns (uint256)");if(s===0n||s>p||s>=1n<<32n||d<s||d===(1n<<256n)-1n||g===(1n<<256n)-1n)throw new u("Provide a positive supported per-loan cap and explicit finite budget at least cap; unlimited approvals are refused.");let h=await t.clientFor(b).readContract({address:c.registry,abi:X,functionName:"getAgentWallet",args:[o]});if(w(h)!==n)throw new u("Autopay enrollment requires the ERC-8004 declared agent wallet, not just its owner or pool delegate.");if(g>0n&&w(String(await I(t,c.savings,"asset() view returns (address)")))!==c.usdg)throw new u("Savings asset is not USDG.");let f=g>0n?await I(t,c.savings,"previewRedeem(uint256) view returns (uint256)",[g]):0n,y=S(["function enroll(uint256,uint256,bool,bool)"]),k=[t.approval(c.usdg,c.autopay,d.toString(),b),t.approval(c.savings,c.autopay,g.toString(),b),t.unsignedTx({to:c.autopay,data:E({abi:y,functionName:"enroll",args:[o,s,g>0n,r.late]}),value:"0",chainId:b,description:"Enroll future autopay with explicit finite USDG and savings share budgets."})],m=await t.preview(k,n);return{txs:k,summary:`Persistent future spending authorization: AutoRepay v2 can repay agent #${o} loans without a confirmation per loan, at most ${s} USDG base units per loan; exact total wallet allowance ${d} USDG base units and ${g} savings shares (currently ${f} USDG base units). These two allowances replace the budgets shared by ALL this wallet autopay plans, including setting savings allowance to zero when disabled. late=${r.late}; savings=${g>0n}. Revoke with priors_autopay_off, which also clears both allowances. ${m.summary}`}}},{name:"priors_autopay_off",inputSchema:P([i]),async execute(r,n){F(t),n=w(n);let o=S(["function revoke(uint256)"]),s=[t.unsignedTx({to:c.autopay,data:E({abi:o,functionName:"revoke",args:[l(r.agentId,"agentId")]}),value:"0",chainId:b,description:"Revoke own autopay plan."}),t.approval(c.usdg,c.autopay,"0",b),t.approval(c.savings,c.autopay,"0",b)],d=await t.preview(s,n);return{txs:s,summary:`Revoke this wallet autopay plan and zero both shared AutoRepay allowances. This also stops funding other plans using this wallet. ${d.summary}`}}}]}export{Y as a,$ as b,Z as c,J as d,l as e,N as f,ie as g,pe as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f,b as O,f as c,g as _,i as D}from"./
|
|
1
|
+
import{a as f,b as O,f as c,g as _,i as D}from"./WQ6H62DM.js";import{c as i,g as C}from"./73N3TOJL.js";import{a as m}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{encodeFunctionData as F,parseAbi as P}from"viem";var E=["function owner() view returns (address)","function admins(address) view returns (bool)","function allowedDepositors(address) view returns (bool)","function setAdmin(address,bool)","function setDeprecated(bool)","function setTeamFeeRecipient(address)","function claimTeamFees(address)","function setHook(address,bool)","function setLocker(address,address,bool)","function setMevModule(address,bool)","function setExtension(address,bool)","function addDepositor(address)","function storeFees(address,address,uint256)","function claim(address,address)","function withdrawETH(address)","function withdrawERC20(address,address)","function transferOwnership(address)","function renounceOwnership()"],w=P(E),g={setAdmin:{contract:"factory",fields:["target","enabled"],admin:!1},setDeprecated:{contract:"factory",fields:["enabled"],admin:!1},setTeamFeeRecipient:{contract:"factory",fields:["recipient"],admin:!1},claimTeamFees:{contract:"factory",fields:["token"],admin:!0},setHook:{contract:"factory",fields:["target","enabled"],admin:!0},setLocker:{contract:"factory",fields:["target","hook","enabled"],admin:!0},setMevModule:{contract:"factory",fields:["target","enabled"],admin:!0},setExtension:{contract:"factory",fields:["target","enabled"],admin:!0},addDepositor:{contract:"fee_locker",fields:["target"],admin:!1},withdrawETH:{contract:"locker",fields:["recipient"],admin:!1},withdrawERC20:{contract:"locker",fields:["token","recipient"],admin:!1}},R=p=>{let h=()=>p.clientFor(m),k=async(e,n,t)=>({txs:e,preview:await p.preview(e,n),summary:t}),y=(e,n,t,r)=>p.unsignedTx({to:e,chainId:m,data:F({abi:w,functionName:n,args:t}),value:"0",description:r}),$={operation:{enum:[...Object.keys(g),"transferOwnership","renounceOwnership"]},contract:{enum:["factory","locker","fee_locker"]},target:i,hook:i,token:i,recipient:i,enabled:{type:"boolean"}},b=(e,n,t,r)=>({name:`clanker_${e}`,inputSchema:{type:"object",properties:n,required:t,additionalProperties:!1},execute:async(o,s)=>{try{return D(o,Object.keys(n)),await r(o,c(s))}catch(d){throw new a(p.plainError(d))}}});return{tools:[b("protocol_admin",$,["operation"],async(e,n)=>{let t=String(e.operation),r=t==="transferOwnership"||t==="renounceOwnership";if(!r&&!Object.hasOwn(g,t))throw new a("Choose a supported Clanker protocol operation.");let o=r?void 0:g[t],s=o?.contract??e.contract;if(s!=="factory"&&s!=="locker"&&s!=="fee_locker")throw new a("Select factory, locker or fee_locker for an ownership change.");if(!r&&e.contract!==void 0&&e.contract!==s)throw new a("This operation targets a different pinned contract.");let d=o?.fields??(t==="transferOwnership"?["recipient"]:[]);for(let l of["target","hook","token","recipient","enabled"])if(e[l]!==void 0&&!d.includes(l))throw new a(`Input ${l} does not match this protocol operation.`);let u=f[s].address,A=c(await h().readContract({address:u,abi:w,functionName:"owner"}),!0);if(!C(A,n)&&(o?.admin&&await h().readContract({address:u,abi:w,functionName:"admins",args:[n]}))!==!0)throw new a("The connected wallet lacks the required Clanker protocol owner/admin role.");let T=d.map(l=>{if(l!=="enabled")return c(e[l]);if(typeof e.enabled!="boolean")throw new a("Provide enabled as boolean.");return e.enabled}),v=`Clanker protocol ${s}: ${t} ${JSON.stringify(T)}. Owner/admin operation; renouncing ownership permanently removes owner-only controls. Withdrawals transfer the entire recorded asset balance; team fees go to the configured team recipient.`;return k([y(u,t,T,v)],n,v)}),b("store_fees",{token:i,recipient:i,amount:O},["token","recipient","amount"],async(e,n)=>{let t=c(e.token),r=c(e.recipient),o=_(e.amount);if(!o)throw new a("Provide a positive fee deposit amount.");if(await h().readContract({address:f.fee_locker.address,abi:w,functionName:"allowedDepositors",args:[n]})!==!0)throw new a("This wallet is not an authorized Clanker fee depositor.");let d=`Deposit exactly ${o} base units of token ${t} into Clanker fees for ${r}. Fee-on-transfer receipts may be smaller; the recorded recipient can later claim them.`,u=[p.approval(t,f.fee_locker.address,o.toString(),m),y(f.fee_locker.address,"storeFees",[r,t,o],d)];return k(u,n,d)}),b("claim_for",{token:i,recipient:i},["token","recipient"],async(e,n)=>{let t=c(e.token),r=c(e.recipient),o=`Permissionlessly claim already-collected Clanker ${t} fees for ${r}; all receipts go to that fee owner, while ${n} pays gas.`;return k([y(f.fee_locker.address,"claim",[r,t],o)],n,o)})]}};export{R as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as E}from"./YHB55C5T.js";import{b as q,c as _,d as O,e as R}from"./PWBL4WKB.js";import{a as N}from"./VVEUJ36E.js";import{a as I}from"./6UPPUHCL.js";import{c as M}from"./AMICUXS6.js";import{b as G}from"./AXYOJBX6.js";import{a as b}from"./6IM6A5VA.js";import{a as x}from"./RETS2ZEK.js";import{a as o,d as P,i as U,j as y}from"./G6HCV67X.js";import{a as r}from"./5YS5V2LK.js";import{encodeFunctionData as g,erc20Abi as k,parseAbi as L}from"viem";var i=U[o].vaults.steakhouse.address,j=(1n<<256n)-1n,l=L(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function A(e){if(typeof e!="bigint"||e<0n||e>j)throw new r("The vault returned an invalid base-unit amount.");return e}function T(e){if(typeof e!="string")throw new r("Amount must be an integer string in base units.");let c=x(e);if(c===0n)throw new r("Amount must be positive.");if(c>j)throw new r("Amount exceeds the uint256 range.");return c}function D(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new r("Unexpected Steakhouse argument.")}var W=e=>{async function c(t){try{return await t()}catch(s){throw new r(e.plainError(s))}}async function h(){let t=e.clientFor(o);if(await t.getChainId()!==o)throw new r("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new r("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:k,functionName:"decimals"}),t.readContract({address:i,abi:k,functionName:"decimals"})]);if(a!==P||!Number.isInteger(n)||n<0||n>255)throw new r("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:o},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:o}}}async function w(t,s){return A(await t.readContract({address:i,abi:k,functionName:"balanceOf",args:[s]}))}async function C(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new r("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[_(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),E(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{D(t,!1);let{client:s,asset:a,shares:n}=await h(),u=A(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:$(!1),execute:async(t,s)=>c(async()=>{D(t,!0);let a=T(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),o),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:o,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return C(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...$(!0),properties:{...$(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$"},minAmountOut:{type:"string",pattern:"^[0-9]+$"}}},execute:async(t,s)=>c(async()=>{D(t,!0,!0);let a=t.amount==="max"?null:T(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new r("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new r("force must be a boolean.");if(t.force===!0){if(a!==null)throw new r("Force exit currently requires amount max.");let p=M(t.maxPenaltyAssets),F=T(t.minAmountOut),v=await q(e,n,i,s,d,p),S=await e.preview([v.tx],s);return R(S.changes,i,d,F),{txs:[v.tx],preview:S,summary:`${O(v.plan)} ${S.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new r("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:o,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=A(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new r("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:o,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return C([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=A(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${o}:${i.toLowerCase()}`,chainId:o,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${o}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function $(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`USDG base-unit integer string (6 decimals)${e?", or max to redeem every share":""}.`}}}}var te=e=>G("steakhouse",[W(e)]);export{W as a,te as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var u=/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} (?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d{4} \d{2}:\d{2}:\d{2} GMT$/;function l(r,e){let t=r?.trim()??"",n=Number.NaN;return/^\d{1,9}$/.test(t)?n=Number(t)*1e3:u.test(t)&&(n=Date.parse(t)-e),Number.isFinite(n)&&n>0?Math.min(n,36e5):6e4}function c(r=()=>Date.now()){let e=0,t=!1;return{blocked:()=>r()<e,limited:()=>r()<e&&t,defer(n,i=!1){let o=r(),a=o+l(n,o);(a>e||a===e&&i)&&(t=i),e=Math.max(e,a)}}}export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as Ce,d as Me,e as we,f as ie,i as be,j as Ne}from"./MEMVFR7Z.js";import{b as ne,o as ge}from"./CAU44UWP.js";import{a as O,b as pe}from"./6IM6A5VA.js";import{a as Te}from"./EG6M6SSO.js";import{a as F,c as Ue}from"./RETS2ZEK.js";import{a as k,i as _}from"./XPFVT2EA.js";import{a as c,b as te,d as U}from"./5YS5V2LK.js";import{decodeFunctionResult as he,encodeFunctionData as R,getAddress as l,parseAbi as Z,zeroAddress as C}from"viem";var re=-887272,se=887272,z=(1n<<128n)-1n,Fe="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",ze="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Ge="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,je=5,Ke=1800n,f=Object.freeze({factory:l(_[4663].uniswap.v3_factory.address),positionManager:l(_[4663].uniswap.v3_position_manager.address),swapRouter02:l(_[4663].uniswap.swap_router02.address),permit2:l(_[4663].uniswap.permit2.address),weth:l(_[4663].uniswap.WETH.address),usdg:l(_[4663].uniswap.USDG.address),ethUsdgPool:l(_[4663].oracle.ethUsdgPool.address)}),xe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),yt=Object.freeze([{fee:100,tickSpacing:1,address:l("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:f.weth,token1:f.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:l("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:f.weth,token1:f.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:l("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:f.weth,token1:f.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:l("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:f.weth,token1:f.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),x=Z(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Q=Z(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),ke=Z(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),Qe=Z(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),ye=Z(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),Ye="0xd0e30db0";function Ze(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===C||e===Fe||e==="eth"||e==="native"}function E(t,e){if(Ze(t))throw new c(`Uniswap v3 requires wrapped ERC-20 WETH (${f.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new c(`${e} must be a valid 20-byte hex address.`);return O(t),l(t)}function Je(t,e,n){let a=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new c("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(a)||!Number.isInteger(o))throw new c("Uniswap v3 tickLower and tickUpper must be integers.");if(a<re||o>se||a>se||o<re)throw new c(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(a>=o)throw new c("Uniswap v3 tickLower must be strictly less than tickUpper.");if(a%i!==0||o%i!==0)throw new c(`Uniswap v3 tickLower (${a}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:a,tickUpper:o,tickSpacing:i}}function et(t,e){let n=t.trim(),a=n.startsWith("-"),o=a||n.startsWith("+")?n.slice(1):n,i=Ue(F(o).toString(),e);return a&&i!=="0"?`-${i}`:i}function tt(t){let e=typeof t=="string"?he({abi:x,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:l(String(e[1])),token0:l(String(e[2])),token1:l(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function $e(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?l(e).toLowerCase():void 0,a=f.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==a)continue;let r=Array.isArray(i.topics)?i.topics.map(u=>String(u).toLowerCase()):[],s=r[0];if(s===ze&&r.length>=4){let d=`0x${r[2].slice(-40)}`;if(!n||d===n){let m=BigInt(r[3]).toString();m!=="0"&&o.add(m)}}else if(s===Ge&&r.length>=2&&!n){let u=BigInt(r[1]).toString();u!=="0"&&o.add(u)}}return[...o]}function ht(t){let e=n=>typeof n=="bigint"?n:F(n);return R({abi:Qe,functionName:"exactInputSingle",args:[{tokenIn:l(t.tokenIn),tokenOut:l(t.tokenOut),fee:t.fee,recipient:l(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Le=1n<<96n;function Re(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function nt(t,e,n,a){if(a<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(a<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let s=(a<<96n)*(i-t)/i/t,u=a*(t-o)/Le;return{amount0:s,amount1:u}}return{amount0:0n,amount1:a*(i-o)/Le}}async function M(t,e,n,a){let o=l(e),i,r;if(n===k&&o===f.weth?(i=18,r="WETH"):n===k&&o===f.usdg&&(i=6,r="USDG"),i===void 0){let s=await t.readContract({address:o,abi:ye,functionName:"decimals"});i=Number(s)}if(r===void 0)try{let s=await t.readContract({address:o,abi:ye,functionName:"symbol"});if(typeof s!="string"||!s.trim())throw new c("Token symbol is unavailable.");r=Ne(s.trim(),o)}catch(s){throw new c(`Could not read token metadata. ${U(s)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new c("Token decimals are invalid.");if(a!=null){let s=Number(a);if(!Number.isInteger(s)||s!==i)throw new c(`Token ${o} on chain ${n} has ${i} decimals, not ${String(a)}.`)}return{address:o,symbol:r,decimals:i,chainId:n}}async function it(t){try{if(!t.getBlock)throw new c("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new c("Invalid block timestamp.");return e.timestamp}catch(e){throw new c(`Could not read the current block timestamp. ${U(e)}`)}}function J(t,e){if(typeof t=="bigint"){if(t<0n)throw new c(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new c(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return F(t);throw new c(`${e} must be a non-negative integer.`)}async function _e(t,e){let n=await it(t);if(e==null)return n+Ke;let a=J(e,"deadline");if(a<=n)throw new c(`Uniswap v3 deadline (${a.toString()}) has expired at timestamp ${n.toString()}.`);return a}function V(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new c(`${e} must be a non-negative integer string in base units.`);return F(t)}function Ee(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new c("Slippage must be an integer from 0 to 9999 bps.");return ge("0",e),e}function ae(t,e,n,a){let o=t===void 0?F(ge(e.toString(),n)):V(t,a);if(o<=1n)throw new c(`${a} must exceed 1 base unit; the simulated amount may be too small.`);return o}function X(t,e){return pe({to:f.positionManager,data:t,value:"0",chainId:k,description:e})}async function Y(t,e,n){try{if(!t.request)throw new c("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Te.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new c("Unexpected batch simulation response.");return o[0].calls.map((i,r)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new c(`Simulation call ${r+1} failed. ${U(i.error)}`);return i.returnData})}catch(a){throw new c(`Uniswap v3 simulation failed. ${U(a)}`)}}function ce(t,e){try{return he({abi:x,functionName:t,data:e})}catch{throw new c(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Be(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new c("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new c("sqrtPriceX96 must be a non-negative integer string.");return Me(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new c("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Ce(t.initialPrice,e,n)}async function De(t,e,n,a){let o=[];for(let i of Object.keys(xe).map(Number)){if(i===a)continue;let r=l(String(await t.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[e,n,i]})));if(r===C||BigInt(await t.readContract({address:r,abi:ke,functionName:"liquidity"}))===0n)continue;let u=await t.readContract({address:r,abi:ke,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${r}`,sqrtPriceX96:BigInt(u[0])})}return o}function G(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==k)throw new c(`Uniswap v3 is only supported on Robinhood Chain (${k}).`);if(e.version!==void 0&&e.version!=="v3")throw new c(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(k);return{...n,readContract:async a=>{try{return await n.readContract(a)}catch(o){throw new c(`Could not read Uniswap v3 ${a.functionName}. ${U(o)}`,{cause:o})}}}}async function ve(t,e,n){let a;try{a=await t.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[e]})}catch(r){throw new c(`Could not verify owner of Uniswap v3 position #${e}. ${U(r)}`)}let o=l(String(a)),i=l(n);if(o!==i)throw new c(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:f.positionManager,abi:x,functionName:"positions",args:[e]});return tt(n)}function Ie(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(a=>`${et(a.amount,a.token.decimals)} ${a.token.symbol}`);return`${t} (${n.join(", ")})`}async function ot(t,e,n){O(n);let a=l(n),o=G(t,e),i=await _e(o,e.deadline),r=Ee(e),s=e.tokenId===void 0?void 0:J(e.tokenId,"tokenId"),u;if(s!==void 0){if(s<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,s,a),u=await de(o,s)}let d=u?.token0??E(e.token0,"token0"),m=u?.token1??E(e.token1,"token1");if(BigInt(d)>=BigInt(m))throw new c("Uniswap v3 requires distinct sorted token addresses.");let p=u?.fee??Number(e.fee??100),g=xe[p];if(!g)throw new c("Unsupported Uniswap v3 fee tier.");let y=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d,m,p]}))),h=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(y===C&&!h)throw new c("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(y!==C&&h)throw new c(`The Uniswap v3 pool already exists at ${y}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(s!==void 0&&h)throw new c("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new c("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||u))throw new c("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:S,tickUpper:N,tickSpacing:T}=Je(u?.tickLower??(e.fullRange===!0?Math.ceil(re/g)*g:e.tickLower),u?.tickUpper??(e.fullRange===!0?Math.floor(se/g)*g:e.tickUpper),g),w=await M(o,d,k,e.token0Decimals),b=await M(o,m,k,e.token1Decimals),P;if(y===C){let q=Be(e,w.decimals,b.decimals),L=be(q,await De(o,d,m,p),e.acceptPriceDeviation===!0,w.decimals,b.decimals);P={sqrtPriceX96:q,note:L}}let v=V(e.amount0Desired,"amount0Desired"),I=V(e.amount1Desired,"amount1Desired");if(v===0n&&I===0n)throw new c("Liquidity addition requires a positive desired amount.");let $=e.recipient===void 0?a:E(e.recipient,"recipient");if($!==a)throw new c("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==f.weth&&m!==f.weth)throw new c("Wrapping requires a positive WETH desired amount.");let H=await Promise.all([d,m].map(async q=>BigInt(await o.readContract({address:q,abi:ye,functionName:"allowance",args:[a,f.positionManager]})))),j=(q,L)=>{let fe=[];if(e.wrapNative===!0){let K=d===f.weth?q:L;K>0n&&fe.push(pe({to:f.weth,data:Ye,value:K.toString(),chainId:k,description:"Wrap ETH into WETH."}))}for(let[K,We]of[d,m].entries()){let me=K===0?q:L;me>0n&&H[K]<me&&fe.push(t.approval(We,f.positionManager,me.toString(),k))}return fe},W=s===void 0?"mint":"increaseLiquidity",B=(q,L)=>X(s===void 0?R({abi:x,functionName:"mint",args:[{token0:d,token1:m,fee:p,tickLower:S,tickUpper:N,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,recipient:$,deadline:i}]}):R({abi:x,functionName:"increaseLiquidity",args:[{tokenId:s,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,deadline:i}]}),`${W==="mint"?"Mint":"Increase"} Uniswap v3 ${w.symbol}/${b.symbol} liquidity.`),D=P&&X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[d,m,p,P.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${w.symbol}/${b.symbol} fee ${p} pool at ${ie(P.sqrtPriceX96,w.decimals,b.decimals)} ${b.symbol} per ${w.symbol}.`),Pe=D?[D]:[],Se=await Y(o,[...Pe,...j(v,I),B(0n,0n)],a),A=ce(W,Se[Se.length-1]),Ve=A[A.length-2],He=A[A.length-1];if(Ve>v||He>I)throw new c("Simulated liquidity spend exceeds the desired amounts.");let ee=[...Pe,...j(v,I)],ue=ae(e.amount0Min,A[A.length-2],r,"amount0Min"),le=ae(e.amount1Min,A[A.length-1],r,"amount1Min");if(ue>v||le>I)throw new c("Uniswap v3 minimum amount cannot exceed desired amount.");let Ae=B(ue,le);ee.push(Ae);for(let[q,L]of[d,m].entries())(q===0?v:I)>0n&&ee.push(t.approval(L,f.positionManager,"0",k));let qe=await t.preview(ee,a);return{txs:ee,preview:qe,summary:Ie(Ae.description,qe),details:{version:"v3",action:W,...s===void 0?{}:{tokenId:s.toString()},pool:y===C?null:y,fee:p,tickSpacing:T,tickLower:S,tickUpper:N,token0:w,token1:b,amount0Desired:v.toString(),amount1Desired:I.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:$,expectedAmount0:A[A.length-2].toString(),expectedAmount1:A[A.length-1].toString(),...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:ie(P.sqrtPriceX96,w.decimals,b.decimals),initialTick:we(P.sqrtPriceX96),priceCheck:P.note}:{}}}}async function rt(t,e,n){O(n);let a=l(n),o=G(t,e),i=E(e.token0,"token0"),r=E(e.token1,"token1");if(BigInt(i)>=BigInt(r))throw new c(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(r)?i:r}, token1=${BigInt(i)<BigInt(r)?r:i}; initialPrice is token1 per 1 token0 in that order.`);let s=Number(e.fee),u=xe[s];if(!u){let b=Number(await o.readContract({address:f.factory,abi:Q,functionName:"feeAmountTickSpacing",args:[s]}));if(!Number.isInteger(s)||b<=0)throw new c("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");u=b}let d=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[i,r,s]})));if(d!==C)throw new c(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let m=await M(o,i,k,e.token0Decimals),p=await M(o,r,k,e.token1Decimals),g=Be(e,m.decimals,p.decimals),y=be(g,await De(o,i,r,s),e.acceptPriceDeviation===!0,m.decimals,p.decimals),h=ie(g,m.decimals,p.decimals),S=[X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[i,r,s,g]}),`Create and initialize the Uniswap v3 ${m.symbol}/${p.symbol} fee ${s} pool at ${h} ${p.symbol} per ${m.symbol}.`)],N=await Y(o,S,a),T;try{T=l(String(he({abi:x,functionName:"createAndInitializePoolIfNecessary",data:N[0]})))}catch{throw new c("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(T===C)throw new c("Uniswap v3 pool creation simulation returned no pool.");let w=await t.preview(S,a);return{txs:S,preview:w,summary:`${S[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:T,fee:s,tickSpacing:u,token0:m,token1:p,sqrtPriceX96:g.toString(),initialPrice:h,initialTick:we(g),priceCheck:y}}}async function st(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=await M(o,r.token0,k),u=await M(o,r.token1,k),d=e.recipient===void 0?a:E(e.recipient,"recipient");if(d!==a)throw new c("Uniswap recipient must be the signing wallet.");let m=e.amount0Max===void 0?z:V(e.amount0Max,"amount0Max"),p=e.amount1Max===void 0?z:V(e.amount1Max,"amount1Max");if(m===0n&&p===0n||m>z||p>z)throw new c("Collect requires a positive amountMax within uint128.");let g=[X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:m,amount1Max:p}]}),`Collect Uniswap v3 fees from position #${i}.`)],y=ce("collect",(await Y(o,g,a))[0]),h=await t.preview(g,a);return{txs:g,preview:h,summary:Ie(g[0].description,h),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:s,token1:u,amount0Max:m.toString(),amount1Max:p.toString(),expectedAmount0:y[0].toString(),expectedAmount1:y[1].toString()}}}async function at(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=r.liquidity===0n&&e.burn===!0;if(r.liquidity<=0n&&!s)throw new c("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!s)throw new c('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let u=e.liquidity==="all"||e.liquidity===void 0?r.liquidity:V(e.liquidity,"liquidity");if(u<=0n&&!s)throw new c("Liquidity to remove must be positive.");if(u>r.liquidity)throw new c("Requested liquidity exceeds position liquidity.");let d=await _e(o,e.deadline),m=Ee(e),p=await M(o,r.token0,k),g=await M(o,r.token1,k),y=e.recipient===void 0?a:E(e.recipient,"recipient");if(y!==a)throw new c("Uniswap recipient must be the signing wallet.");let h=(B,D)=>X(R({abi:x,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:u,amount0Min:B,amount1Min:D,deadline:d}]}),`Decrease ${u} liquidity on Uniswap v3 position #${i}.`),S=s?[0n,0n]:ce("decreaseLiquidity",(await Y(o,[h(0n,0n)],a))[0]),N=(B,D)=>{if(B!==void 0&&V(B,D)!==0n)throw new c(`${D} must be zero for an empty position burn.`);return 0n},T=s?N(e.amount0Min,"amount0Min"):ae(e.amount0Min,S[0],m,"amount0Min"),w=s?N(e.amount1Min,"amount1Min"):ae(e.amount1Min,S[1],m,"amount1Min"),b=s?[]:[h(T,w)],P=b.length,v=!s||r.tokensOwed0>0n||r.tokensOwed1>0n;v&&b.push(X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:y,amount0Max:z,amount1Max:z}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let I=u===r.liquidity,$=I&&e.burn===!0;$&&b.push(X(R({abi:x,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let H=await Y(o,b,a),j=v?ce("collect",H[P]):[0n,0n],W=await t.preview(b,a);return{txs:b,preview:W,summary:Ie(`Remove Uniswap v3 liquidity from position #${i}${$?`; burns position #${i} at ${f.positionManager}`:""}`,W),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:y,token0:p,token1:g,liquidityRemoved:u.toString(),amount0Min:T.toString(),amount1Min:w.toString(),deadline:d.toString(),expectedAmount0:j[0].toString(),expectedAmount1:j[1].toString(),fullExit:I,burned:$}}}async function ct(t,e,n={}){let a=l(e),o=new Set;if(Array.isArray(n.tokenIds))for(let r of n.tokenIds){let s=J(r,"tokenId");s>0n&&o.add(s.toString())}if(Array.isArray(n.receipts))for(let r of n.receipts)for(let s of $e(r,a))o.add(s);let i=!1;try{let r=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"balanceOf",args:[a]})),s=r>64n?64n:r;for(let u=0n;u<s;u++){try{let d=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"tokenOfOwnerByIndex",args:[a,u]}));d>0n&&o.add(d.toString())}catch(d){if(!te(d,3,-32601,-32004))throw d;break}u+1n===r&&(i=!0)}r===0n&&(i=!0)}catch(r){if(!te(r,3,-32601,-32004))throw r}if(typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let r=n.toBlock??await t.getBlockNumber(),s=n.maxChunks??je,u=n.fromBlock??(r>oe*BigInt(s)?r-oe*BigInt(s)+1n:0n),d=r,m=0;for(;d>=u&&m<s;){let p=d>=oe-1n?d-(oe-1n):0n,g=p<u?u:p,y=await t.getLogs({address:f.positionManager,fromBlock:g,toBlock:d});for(let h of $e({logs:y},a))o.add(h);if(m+=1,g===0n||g<=u)break;d=g-1n}}catch(r){throw new c(`Could not discover Uniswap v3 positions from logs. ${U(r)}`)}else if(!i&&n.tokenIds===void 0&&n.receipts===void 0)throw new c("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(r=>BigInt(r)).sort((r,s)=>r<s?-1:r>s?1:0)}async function Oe(t,e,n={}){O(e);let a=l(e),o=G(t),i=await ct(o,a,n),r=[];for(let s of i){let u;try{let w=await o.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[s]});u=l(String(w))}catch(w){if(te(w,3))continue;throw new c(`Could not verify owner of position #${s}. ${U(w)}`)}if(u!==a)continue;let d;try{d=await de(o,s)}catch(w){throw new c(`Could not read position #${s}. ${U(w)}`)}if(d.liquidity===0n&&d.tokensOwed0===0n&&d.tokensOwed1===0n&&!n.includeEmpty)continue;let p=await M(o,d.token0,k),g=await M(o,d.token1,k),y=0n,h=0n;if(d.liquidity>0n)try{let w=await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d.token0,d.token1,d.fee]}),b=l(String(w));if(b===C)throw new c("Position pool was not found.");if(b!==C){let P=await o.readContract({address:b,abi:ke,functionName:"slot0"}),v=BigInt(P[0]);if(v<=0n)throw new c("Position pool has no initialized price.");let I=Re(d.tickLower),$=Re(d.tickUpper),H=nt(v,I,$,d.liquidity);y=H.amount0,h=H.amount1}}catch(w){throw new c(`Could not value Uniswap v3 position #${s}. ${U(w)}`)}let S=y+d.tokensOwed0,N=h+d.tokensOwed1,T=[{token:p,amount:S.toString()},{token:g,amount:N.toString()}];r.push({module:"uniswap",id:`uniswap:v3:${s.toString()}`,chainId:k,assets:T,description:`Uniswap v3 LP position #${s.toString()} (${p.symbol}/${g.symbol} fee ${d.fee} ticks [${d.tickLower}, ${d.tickUpper}] liquidity ${d.liquidity.toString()})`})}return r}async function dt(t,e,n){G(t,e);let a=e.wallet!==void 0?E(e.wallet,"wallet"):l(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,r=e.includeZero===!0||e.includeEmpty===!0,s=await Oe(t,a,{tokenIds:o,receipts:i,includeEmpty:r});return{positions:s,details:{version:"v3",wallet:a,count:s.length,positionManager:f.positionManager}}}function ut(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:"Desired token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units. The pool is created then liquidity is minted in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},execute:(r,s)=>ot(t,r,s)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},required:["tokenId"]},execute:(r,s)=>st(t,r,s)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(r,s)=>at(t,r,s)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet from NFT receipts and Transfer logs.",properties:{version:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect."}}},execute:(r,s)=>dt(t,r,s)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 WETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(r,s)=>rt(t,r,s)}]}var Xe=t=>({tools:ut(t),positions:e=>Oe(t,e)}),xt=Xe,vt=Xe;export{re as a,se as b,z as c,f as d,xe as e,yt as f,x as g,Q as h,ke as i,Qe as j,Je as k,et as l,tt as m,$e as n,ht as o,Be as p,ot as q,rt as r,st as s,at as t,Oe as u,dt as v,ut as w,Xe as x,xt as y,vt as z};
|
|
1
|
+
import{c as Ce,d as Me,e as we,f as ie,i as be,j as Ne}from"./6ZYLNB2B.js";import{b as ne,o as ge}from"./5O5ZE3ZV.js";import{a as O,b as pe}from"./6IM6A5VA.js";import{a as Te}from"./EG6M6SSO.js";import{a as F,c as Ue}from"./RETS2ZEK.js";import{a as k,i as _}from"./G6HCV67X.js";import{a as c,b as te,d as U}from"./5YS5V2LK.js";import{decodeFunctionResult as he,encodeFunctionData as R,getAddress as l,parseAbi as Z,zeroAddress as C}from"viem";var re=-887272,se=887272,z=(1n<<128n)-1n,Fe="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",ze="0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",Ge="0x3067048beee31b25b2f1681f88dac838c8bba36af25bfb2b7cf7473a5847e35f",oe=2000n,je=5,Ke=1800n,f=Object.freeze({factory:l(_[4663].uniswap.v3_factory.address),positionManager:l(_[4663].uniswap.v3_position_manager.address),swapRouter02:l(_[4663].uniswap.swap_router02.address),permit2:l(_[4663].uniswap.permit2.address),weth:l(_[4663].uniswap.WETH.address),usdg:l(_[4663].uniswap.USDG.address),ethUsdgPool:l(_[4663].oracle.ethUsdgPool.address)}),xe=Object.freeze({100:1,500:10,3e3:60,1e4:200}),yt=Object.freeze([{fee:100,tickSpacing:1,address:l("0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"),token0:f.weth,token1:f.usdg,recordedLiquidity:"1957537485734736219",recordedSqrtPriceX96:"3839219776288481168641554",recordedTick:-198707,feeProtocol:68},{fee:500,tickSpacing:10,address:l("0x69bfaf19c9f377bb306a89aed9f6b07e2c1a8d9a"),token0:f.weth,token1:f.usdg,recordedLiquidity:"714542894544667104",recordedSqrtPriceX96:"3839644024453020182443671",recordedTick:-198705,feeProtocol:68},{fee:3e3,tickSpacing:60,address:l("0xa9188730fe85be88ad499d7d52b099e800fb0334"),token0:f.weth,token1:f.usdg,recordedLiquidity:"310559629687003603",recordedSqrtPriceX96:"3843235825752878635548672",recordedTick:-198686,feeProtocol:102},{fee:1e4,tickSpacing:200,address:l("0x5f009e071f07e92b6c624e83f52f17bbda34680d"),token0:f.weth,token1:f.usdg,recordedLiquidity:"5822966536584155",recordedSqrtPriceX96:"3853297838190389678059735",recordedTick:-198634,feeProtocol:102}]),x=Z(["function positions(uint256 tokenId) view returns (uint96 nonce, address operator, address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint128 liquidity, uint256 feeGrowthInside0LastX128, uint256 feeGrowthInside1LastX128, uint128 tokensOwed0, uint128 tokensOwed1)","function ownerOf(uint256 tokenId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function tokenOfOwnerByIndex(address owner, uint256 index) view returns (uint256)","function mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)","function increaseLiquidity((uint256 tokenId, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint128 liquidity, uint256 amount0, uint256 amount1)","function decreaseLiquidity((uint256 tokenId, uint128 liquidity, uint256 amount0Min, uint256 amount1Min, uint256 deadline) params) payable returns (uint256 amount0, uint256 amount1)","function collect((uint256 tokenId, address recipient, uint128 amount0Max, uint128 amount1Max) params) payable returns (uint256 amount0, uint256 amount1)","function burn(uint256 tokenId) payable","function createAndInitializePoolIfNecessary(address token0, address token1, uint24 fee, uint160 sqrtPriceX96) payable returns (address pool)"]),Q=Z(["function getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool)","function feeAmountTickSpacing(uint24 fee) view returns (int24)"]),ke=Z(["function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)","function liquidity() view returns (uint128)","function tickSpacing() view returns (int24)","function fee() view returns (uint24)","function token0() view returns (address)","function token1() view returns (address)"]),Qe=Z(["function exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)"]),ye=Z(["function decimals() view returns (uint8)","function symbol() view returns (string)","function allowance(address owner, address spender) view returns (uint256)"]),Ye="0xd0e30db0";function Ze(t){if(typeof t!="string")return!1;let e=t.trim().toLowerCase();return e===C||e===Fe||e==="eth"||e==="native"}function E(t,e){if(Ze(t))throw new c(`Uniswap v3 requires wrapped ERC-20 WETH (${f.weth}) rather than native ETH in ${e}.`);if(typeof t!="string")throw new c(`${e} must be a valid 20-byte hex address.`);return O(t),l(t)}function Je(t,e,n){let a=Number(t),o=Number(e),i=Number(n);if(!Number.isInteger(i)||i<=0)throw new c("Uniswap v3 tickSpacing must be a positive integer.");if(!Number.isInteger(a)||!Number.isInteger(o))throw new c("Uniswap v3 tickLower and tickUpper must be integers.");if(a<re||o>se||a>se||o<re)throw new c(`Uniswap v3 ticks are out of bounds [${re}, ${se}].`);if(a>=o)throw new c("Uniswap v3 tickLower must be strictly less than tickUpper.");if(a%i!==0||o%i!==0)throw new c(`Uniswap v3 tickLower (${a}) and tickUpper (${o}) must be divisible by tickSpacing (${i}).`);return{tickLower:a,tickUpper:o,tickSpacing:i}}function et(t,e){let n=t.trim(),a=n.startsWith("-"),o=a||n.startsWith("+")?n.slice(1):n,i=Ue(F(o).toString(),e);return a&&i!=="0"?`-${i}`:i}function tt(t){let e=typeof t=="string"?he({abi:x,functionName:"positions",data:t}):t;return{nonce:BigInt(e[0]),operator:l(String(e[1])),token0:l(String(e[2])),token1:l(String(e[3])),fee:Number(e[4]),tickLower:Number(e[5]),tickUpper:Number(e[6]),liquidity:BigInt(e[7]),feeGrowthInside0LastX128:BigInt(e[8]),feeGrowthInside1LastX128:BigInt(e[9]),tokensOwed0:BigInt(e[10]),tokensOwed1:BigInt(e[11])}}function $e(t,e){if(!t||!Array.isArray(t.logs))return[];let n=e?l(e).toLowerCase():void 0,a=f.positionManager.toLowerCase(),o=new Set;for(let i of t.logs){if(!i||typeof i.address!="string"||i.address.toLowerCase()!==a)continue;let r=Array.isArray(i.topics)?i.topics.map(u=>String(u).toLowerCase()):[],s=r[0];if(s===ze&&r.length>=4){let d=`0x${r[2].slice(-40)}`;if(!n||d===n){let m=BigInt(r[3]).toString();m!=="0"&&o.add(m)}}else if(s===Ge&&r.length>=2&&!n){let u=BigInt(r[1]).toString();u!=="0"&&o.add(u)}}return[...o]}function ht(t){let e=n=>typeof n=="bigint"?n:F(n);return R({abi:Qe,functionName:"exactInputSingle",args:[{tokenIn:l(t.tokenIn),tokenOut:l(t.tokenOut),fee:t.fee,recipient:l(t.recipient),amountIn:e(t.amountIn),amountOutMinimum:e(t.amountOutMinimum),sqrtPriceLimitX96:t.sqrtPriceLimitX96!==void 0?e(t.sqrtPriceLimitX96):0n}]})}var Le=1n<<96n;function Re(t){let e=Math.abs(t),n=(e&1)!==0?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&2)!==0&&(n=n*0xfff97272373d413259a46990580e213an>>128n),(e&4)!==0&&(n=n*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&8)!==0&&(n=n*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&16)!==0&&(n=n*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&32)!==0&&(n=n*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&64)!==0&&(n=n*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&128)!==0&&(n=n*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&256)!==0&&(n=n*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&512)!==0&&(n=n*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&1024)!==0&&(n=n*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&2048)!==0&&(n=n*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&4096)!==0&&(n=n*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&8192)!==0&&(n=n*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&16384)!==0&&(n=n*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&32768)!==0&&(n=n*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&65536)!==0&&(n=n*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&131072)!==0&&(n=n*0x5d6af8dedb81196699c329225ee604n>>128n),(e&262144)!==0&&(n=n*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&524288)!==0&&(n=n*0x48a170391f7dc42444e8fa2n>>128n),t>0&&(n=((1n<<256n)-1n)/n),(n>>32n)+(n%(1n<<32n)===0n?0n:1n)}function nt(t,e,n,a){if(a<=0n)return{amount0:0n,amount1:0n};let[o,i]=e<n?[e,n]:[n,e];if(t<=o)return{amount0:(a<<96n)*(i-o)/i/o,amount1:0n};if(t<i){let s=(a<<96n)*(i-t)/i/t,u=a*(t-o)/Le;return{amount0:s,amount1:u}}return{amount0:0n,amount1:a*(i-o)/Le}}async function M(t,e,n,a){let o=l(e),i,r;if(n===k&&o===f.weth?(i=18,r="WETH"):n===k&&o===f.usdg&&(i=6,r="USDG"),i===void 0){let s=await t.readContract({address:o,abi:ye,functionName:"decimals"});i=Number(s)}if(r===void 0)try{let s=await t.readContract({address:o,abi:ye,functionName:"symbol"});if(typeof s!="string"||!s.trim())throw new c("Token symbol is unavailable.");r=Ne(s.trim(),o)}catch(s){throw new c(`Could not read token metadata. ${U(s)}`)}if(!Number.isInteger(i)||i<0||i>255)throw new c("Token decimals are invalid.");if(a!=null){let s=Number(a);if(!Number.isInteger(s)||s!==i)throw new c(`Token ${o} on chain ${n} has ${i} decimals, not ${String(a)}.`)}return{address:o,symbol:r,decimals:i,chainId:n}}async function it(t){try{if(!t.getBlock)throw new c("Block timestamps are unavailable.");let e=await t.getBlock();if(typeof e.timestamp!="bigint")throw new c("Invalid block timestamp.");return e.timestamp}catch(e){throw new c(`Could not read the current block timestamp. ${U(e)}`)}}function J(t,e){if(typeof t=="bigint"){if(t<0n)throw new c(`${e} must be a non-negative integer.`);return t}if(typeof t=="number"){if(!Number.isSafeInteger(t)||t<0)throw new c(`${e} must be a non-negative integer.`);return BigInt(t)}if(typeof t=="string")return F(t);throw new c(`${e} must be a non-negative integer.`)}async function _e(t,e){let n=await it(t);if(e==null)return n+Ke;let a=J(e,"deadline");if(a<=n)throw new c(`Uniswap v3 deadline (${a.toString()}) has expired at timestamp ${n.toString()}.`);return a}function V(t,e){if(typeof t!="string"||!/^\d+$/.test(t))throw new c(`${e} must be a non-negative integer string in base units.`);return F(t)}function Ee(t){let e=t.slippageBps??ne;if(typeof e!="number")throw new c("Slippage must be an integer from 0 to 9999 bps.");return ge("0",e),e}function ae(t,e,n,a){let o=t===void 0?F(ge(e.toString(),n)):V(t,a);if(o<=1n)throw new c(`${a} must exceed 1 base unit; the simulated amount may be too small.`);return o}function X(t,e){return pe({to:f.positionManager,data:t,value:"0",chainId:k,description:e})}async function Y(t,e,n){try{if(!t.request)throw new c("Sequential transaction simulation is unavailable.");let o=await t.request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:e.map(i=>({from:n,gas:`0x${Te.toString(16)}`,to:i.to,data:i.data,value:`0x${BigInt(i.value).toString(16)}`}))}],validation:!1,traceTransfers:!0},"latest"]},{retryCount:0});if(!Array.isArray(o)||o.length!==1||!Array.isArray(o[0]?.calls)||o[0].calls.length!==e.length)throw new c("Unexpected batch simulation response.");return o[0].calls.map((i,r)=>{if(i.status!=="0x1"||i.error||typeof i.returnData!="string"||!/^0x([a-fA-F0-9]{2})*$/.test(i.returnData))throw new c(`Simulation call ${r+1} failed. ${U(i.error)}`);return i.returnData})}catch(a){throw new c(`Uniswap v3 simulation failed. ${U(a)}`)}}function ce(t,e){try{return he({abi:x,functionName:t,data:e})}catch{throw new c(`Uniswap v3 ${t} simulation returned invalid amounts.`)}}function Be(t,e,n){if(t.initialPrice!==void 0&&t.sqrtPriceX96!==void 0)throw new c("Provide initialPrice or sqrtPriceX96, not both.");if(t.sqrtPriceX96!==void 0){if(typeof t.sqrtPriceX96!="string"||!/^\d+$/.test(t.sqrtPriceX96))throw new c("sqrtPriceX96 must be a non-negative integer string.");return Me(BigInt(t.sqrtPriceX96))}if(t.initialPrice===void 0)throw new c("A new pool needs initialPrice (token1 per 1 token0, human units) or sqrtPriceX96.");return Ce(t.initialPrice,e,n)}async function De(t,e,n,a){let o=[];for(let i of Object.keys(xe).map(Number)){if(i===a)continue;let r=l(String(await t.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[e,n,i]})));if(r===C||BigInt(await t.readContract({address:r,abi:ke,functionName:"liquidity"}))===0n)continue;let u=await t.readContract({address:r,abi:ke,functionName:"slot0"});o.push({label:`v3 fee ${i} pool ${r}`,sqrtPriceX96:BigInt(u[0])})}return o}function G(t,e={}){if(e.chainId!==void 0&&Number(e.chainId)!==k)throw new c(`Uniswap v3 is only supported on Robinhood Chain (${k}).`);if(e.version!==void 0&&e.version!=="v3")throw new c(`Uniswap v3 handler received unsupported version "${String(e.version)}".`);let n=t.clientFor(k);return{...n,readContract:async a=>{try{return await n.readContract(a)}catch(o){throw new c(`Could not read Uniswap v3 ${a.functionName}. ${U(o)}`,{cause:o})}}}}async function ve(t,e,n){let a;try{a=await t.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[e]})}catch(r){throw new c(`Could not verify owner of Uniswap v3 position #${e}. ${U(r)}`)}let o=l(String(a)),i=l(n);if(o!==i)throw new c(`Wallet ${i} is not the owner of Uniswap v3 position #${e.toString()} (owned by ${o}).`);return o}async function de(t,e){let n=await t.readContract({address:f.positionManager,abi:x,functionName:"positions",args:[e]});return tt(n)}function Ie(t,e){if(!Array.isArray(e.changes)||!e.changes.length)return t;let n=e.changes.map(a=>`${et(a.amount,a.token.decimals)} ${a.token.symbol}`);return`${t} (${n.join(", ")})`}async function ot(t,e,n){O(n);let a=l(n),o=G(t,e),i=await _e(o,e.deadline),r=Ee(e),s=e.tokenId===void 0?void 0:J(e.tokenId,"tokenId"),u;if(s!==void 0){if(s<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,s,a),u=await de(o,s)}let d=u?.token0??E(e.token0,"token0"),m=u?.token1??E(e.token1,"token1");if(BigInt(d)>=BigInt(m))throw new c("Uniswap v3 requires distinct sorted token addresses.");let p=u?.fee??Number(e.fee??100),g=xe[p];if(!g)throw new c("Unsupported Uniswap v3 fee tier.");let y=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d,m,p]}))),h=e.initialPrice!==void 0||e.sqrtPriceX96!==void 0;if(y===C&&!h)throw new c("No Uniswap v3 pool exists for these tokens and fee tier. To create it and add the first liquidity in one tool call with separately confirmed transactions, add initialPrice (token1 per 1 token0, human units) to this call; to create it without liquidity use uniswap_create_pool.");if(y!==C&&h)throw new c(`The Uniswap v3 pool already exists at ${y}; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);if(s!==void 0&&h)throw new c("initialPrice cannot be combined with tokenId.");if(e.fullRange!==void 0&&typeof e.fullRange!="boolean")throw new c("fullRange must be a boolean.");if(e.fullRange===!0&&(e.tickLower!==void 0||e.tickUpper!==void 0||u))throw new c("Use fullRange only for a new position, without explicit ticks. Existing position ticks cannot change.");let{tickLower:S,tickUpper:N,tickSpacing:T}=Je(u?.tickLower??(e.fullRange===!0?Math.ceil(re/g)*g:e.tickLower),u?.tickUpper??(e.fullRange===!0?Math.floor(se/g)*g:e.tickUpper),g),w=await M(o,d,k,e.token0Decimals),b=await M(o,m,k,e.token1Decimals),P;if(y===C){let q=Be(e,w.decimals,b.decimals),L=be(q,await De(o,d,m,p),e.acceptPriceDeviation===!0,w.decimals,b.decimals);P={sqrtPriceX96:q,note:L}}let v=V(e.amount0Desired,"amount0Desired"),I=V(e.amount1Desired,"amount1Desired");if(v===0n&&I===0n)throw new c("Liquidity addition requires a positive desired amount.");let $=e.recipient===void 0?a:E(e.recipient,"recipient");if($!==a)throw new c("Uniswap recipient must be the signing wallet.");if(e.wrapNative===!0&&d!==f.weth&&m!==f.weth)throw new c("Wrapping requires a positive WETH desired amount.");let H=await Promise.all([d,m].map(async q=>BigInt(await o.readContract({address:q,abi:ye,functionName:"allowance",args:[a,f.positionManager]})))),j=(q,L)=>{let fe=[];if(e.wrapNative===!0){let K=d===f.weth?q:L;K>0n&&fe.push(pe({to:f.weth,data:Ye,value:K.toString(),chainId:k,description:"Wrap ETH into WETH."}))}for(let[K,We]of[d,m].entries()){let me=K===0?q:L;me>0n&&H[K]<me&&fe.push(t.approval(We,f.positionManager,me.toString(),k))}return fe},W=s===void 0?"mint":"increaseLiquidity",B=(q,L)=>X(s===void 0?R({abi:x,functionName:"mint",args:[{token0:d,token1:m,fee:p,tickLower:S,tickUpper:N,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,recipient:$,deadline:i}]}):R({abi:x,functionName:"increaseLiquidity",args:[{tokenId:s,amount0Desired:v,amount1Desired:I,amount0Min:q,amount1Min:L,deadline:i}]}),`${W==="mint"?"Mint":"Increase"} Uniswap v3 ${w.symbol}/${b.symbol} liquidity.`),D=P&&X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[d,m,p,P.sqrtPriceX96]}),`Create and initialize the Uniswap v3 ${w.symbol}/${b.symbol} fee ${p} pool at ${ie(P.sqrtPriceX96,w.decimals,b.decimals)} ${b.symbol} per ${w.symbol}.`),Pe=D?[D]:[],Se=await Y(o,[...Pe,...j(v,I),B(0n,0n)],a),A=ce(W,Se[Se.length-1]),Ve=A[A.length-2],He=A[A.length-1];if(Ve>v||He>I)throw new c("Simulated liquidity spend exceeds the desired amounts.");let ee=[...Pe,...j(v,I)],ue=ae(e.amount0Min,A[A.length-2],r,"amount0Min"),le=ae(e.amount1Min,A[A.length-1],r,"amount1Min");if(ue>v||le>I)throw new c("Uniswap v3 minimum amount cannot exceed desired amount.");let Ae=B(ue,le);ee.push(Ae);for(let[q,L]of[d,m].entries())(q===0?v:I)>0n&&ee.push(t.approval(L,f.positionManager,"0",k));let qe=await t.preview(ee,a);return{txs:ee,preview:qe,summary:Ie(Ae.description,qe),details:{version:"v3",action:W,...s===void 0?{}:{tokenId:s.toString()},pool:y===C?null:y,fee:p,tickSpacing:T,tickLower:S,tickUpper:N,token0:w,token1:b,amount0Desired:v.toString(),amount1Desired:I.toString(),amount0Min:ue.toString(),amount1Min:le.toString(),deadline:i.toString(),recipient:$,expectedAmount0:A[A.length-2].toString(),expectedAmount1:A[A.length-1].toString(),...P?{poolCreated:!0,sqrtPriceX96:P.sqrtPriceX96.toString(),initialPrice:ie(P.sqrtPriceX96,w.decimals,b.decimals),initialTick:we(P.sqrtPriceX96),priceCheck:P.note}:{}}}}async function rt(t,e,n){O(n);let a=l(n),o=G(t,e),i=E(e.token0,"token0"),r=E(e.token1,"token1");if(BigInt(i)>=BigInt(r))throw new c(`Uniswap v3 requires sorted token addresses (token0 < token1). Use token0=${BigInt(i)<BigInt(r)?i:r}, token1=${BigInt(i)<BigInt(r)?r:i}; initialPrice is token1 per 1 token0 in that order.`);let s=Number(e.fee),u=xe[s];if(!u){let b=Number(await o.readContract({address:f.factory,abi:Q,functionName:"feeAmountTickSpacing",args:[s]}));if(!Number.isInteger(s)||b<=0)throw new c("Unsupported Uniswap v3 fee tier. Enabled tiers: 100, 500, 3000, 10000.");u=b}let d=l(String(await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[i,r,s]})));if(d!==C)throw new c(`The Uniswap v3 pool already exists at ${d}. Use uniswap_add to provide liquidity.`);let m=await M(o,i,k,e.token0Decimals),p=await M(o,r,k,e.token1Decimals),g=Be(e,m.decimals,p.decimals),y=be(g,await De(o,i,r,s),e.acceptPriceDeviation===!0,m.decimals,p.decimals),h=ie(g,m.decimals,p.decimals),S=[X(R({abi:x,functionName:"createAndInitializePoolIfNecessary",args:[i,r,s,g]}),`Create and initialize the Uniswap v3 ${m.symbol}/${p.symbol} fee ${s} pool at ${h} ${p.symbol} per ${m.symbol}.`)],N=await Y(o,S,a),T;try{T=l(String(he({abi:x,functionName:"createAndInitializePoolIfNecessary",data:N[0]})))}catch{throw new c("Uniswap v3 pool creation simulation returned an invalid pool address.")}if(T===C)throw new c("Uniswap v3 pool creation simulation returned no pool.");let w=await t.preview(S,a);return{txs:S,preview:w,summary:`${S[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add.`,details:{version:"v3",action:"createPool",pool:T,fee:s,tickSpacing:u,token0:m,token1:p,sqrtPriceX96:g.toString(),initialPrice:h,initialTick:we(g),priceCheck:y}}}async function st(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=await M(o,r.token0,k),u=await M(o,r.token1,k),d=e.recipient===void 0?a:E(e.recipient,"recipient");if(d!==a)throw new c("Uniswap recipient must be the signing wallet.");let m=e.amount0Max===void 0?z:V(e.amount0Max,"amount0Max"),p=e.amount1Max===void 0?z:V(e.amount1Max,"amount1Max");if(m===0n&&p===0n||m>z||p>z)throw new c("Collect requires a positive amountMax within uint128.");let g=[X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:d,amount0Max:m,amount1Max:p}]}),`Collect Uniswap v3 fees from position #${i}.`)],y=ce("collect",(await Y(o,g,a))[0]),h=await t.preview(g,a);return{txs:g,preview:h,summary:Ie(g[0].description,h),details:{version:"v3",action:"collect",tokenId:i.toString(),recipient:d,token0:s,token1:u,amount0Max:m.toString(),amount1Max:p.toString(),expectedAmount0:y[0].toString(),expectedAmount1:y[1].toString()}}}async function at(t,e,n){O(n);let a=l(n),o=G(t,e),i=J(e.tokenId,"tokenId");if(i<=0n)throw new c("Uniswap v3 tokenId must be a positive integer.");await ve(o,i,a);let r=await de(o,i),s=r.liquidity===0n&&e.burn===!0;if(r.liquidity<=0n&&!s)throw new c("Position has zero active liquidity to remove.");if(e.liquidity===void 0&&!s)throw new c('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let u=e.liquidity==="all"||e.liquidity===void 0?r.liquidity:V(e.liquidity,"liquidity");if(u<=0n&&!s)throw new c("Liquidity to remove must be positive.");if(u>r.liquidity)throw new c("Requested liquidity exceeds position liquidity.");let d=await _e(o,e.deadline),m=Ee(e),p=await M(o,r.token0,k),g=await M(o,r.token1,k),y=e.recipient===void 0?a:E(e.recipient,"recipient");if(y!==a)throw new c("Uniswap recipient must be the signing wallet.");let h=(B,D)=>X(R({abi:x,functionName:"decreaseLiquidity",args:[{tokenId:i,liquidity:u,amount0Min:B,amount1Min:D,deadline:d}]}),`Decrease ${u} liquidity on Uniswap v3 position #${i}.`),S=s?[0n,0n]:ce("decreaseLiquidity",(await Y(o,[h(0n,0n)],a))[0]),N=(B,D)=>{if(B!==void 0&&V(B,D)!==0n)throw new c(`${D} must be zero for an empty position burn.`);return 0n},T=s?N(e.amount0Min,"amount0Min"):ae(e.amount0Min,S[0],m,"amount0Min"),w=s?N(e.amount1Min,"amount1Min"):ae(e.amount1Min,S[1],m,"amount1Min"),b=s?[]:[h(T,w)],P=b.length,v=!s||r.tokensOwed0>0n||r.tokensOwed1>0n;v&&b.push(X(R({abi:x,functionName:"collect",args:[{tokenId:i,recipient:y,amount0Max:z,amount1Max:z}]}),`Collect principal and fees from Uniswap v3 position #${i}.`));let I=u===r.liquidity,$=I&&e.burn===!0;$&&b.push(X(R({abi:x,functionName:"burn",args:[i]}),`Burn empty Uniswap v3 position #${i}.`));let H=await Y(o,b,a),j=v?ce("collect",H[P]):[0n,0n],W=await t.preview(b,a);return{txs:b,preview:W,summary:Ie(`Remove Uniswap v3 liquidity from position #${i}${$?`; burns position #${i} at ${f.positionManager}`:""}`,W),details:{version:"v3",action:"remove",tokenId:i.toString(),recipient:y,token0:p,token1:g,liquidityRemoved:u.toString(),amount0Min:T.toString(),amount1Min:w.toString(),deadline:d.toString(),expectedAmount0:j[0].toString(),expectedAmount1:j[1].toString(),fullExit:I,burned:$}}}async function ct(t,e,n={}){let a=l(e),o=new Set;if(Array.isArray(n.tokenIds))for(let r of n.tokenIds){let s=J(r,"tokenId");s>0n&&o.add(s.toString())}if(Array.isArray(n.receipts))for(let r of n.receipts)for(let s of $e(r,a))o.add(s);let i=!1;try{let r=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"balanceOf",args:[a]})),s=r>64n?64n:r;for(let u=0n;u<s;u++){try{let d=BigInt(await t.readContract({address:f.positionManager,abi:x,functionName:"tokenOfOwnerByIndex",args:[a,u]}));d>0n&&o.add(d.toString())}catch(d){if(!te(d,3,-32601,-32004))throw d;break}u+1n===r&&(i=!0)}r===0n&&(i=!0)}catch(r){if(!te(r,3,-32601,-32004))throw r}if(typeof t.getLogs=="function"&&typeof t.getBlockNumber=="function")try{let r=n.toBlock??await t.getBlockNumber(),s=n.maxChunks??je,u=n.fromBlock??(r>oe*BigInt(s)?r-oe*BigInt(s)+1n:0n),d=r,m=0;for(;d>=u&&m<s;){let p=d>=oe-1n?d-(oe-1n):0n,g=p<u?u:p,y=await t.getLogs({address:f.positionManager,fromBlock:g,toBlock:d});for(let h of $e({logs:y},a))o.add(h);if(m+=1,g===0n||g<=u)break;d=g-1n}}catch(r){throw new c(`Could not discover Uniswap v3 positions from logs. ${U(r)}`)}else if(!i&&n.tokenIds===void 0&&n.receipts===void 0)throw new c("Uniswap v3 position discovery is unavailable; supply candidate token IDs or receipts.");return[...o].map(r=>BigInt(r)).sort((r,s)=>r<s?-1:r>s?1:0)}async function Oe(t,e,n={}){O(e);let a=l(e),o=G(t),i=await ct(o,a,n),r=[];for(let s of i){let u;try{let w=await o.readContract({address:f.positionManager,abi:x,functionName:"ownerOf",args:[s]});u=l(String(w))}catch(w){if(te(w,3))continue;throw new c(`Could not verify owner of position #${s}. ${U(w)}`)}if(u!==a)continue;let d;try{d=await de(o,s)}catch(w){throw new c(`Could not read position #${s}. ${U(w)}`)}if(d.liquidity===0n&&d.tokensOwed0===0n&&d.tokensOwed1===0n&&!n.includeEmpty)continue;let p=await M(o,d.token0,k),g=await M(o,d.token1,k),y=0n,h=0n;if(d.liquidity>0n)try{let w=await o.readContract({address:f.factory,abi:Q,functionName:"getPool",args:[d.token0,d.token1,d.fee]}),b=l(String(w));if(b===C)throw new c("Position pool was not found.");if(b!==C){let P=await o.readContract({address:b,abi:ke,functionName:"slot0"}),v=BigInt(P[0]);if(v<=0n)throw new c("Position pool has no initialized price.");let I=Re(d.tickLower),$=Re(d.tickUpper),H=nt(v,I,$,d.liquidity);y=H.amount0,h=H.amount1}}catch(w){throw new c(`Could not value Uniswap v3 position #${s}. ${U(w)}`)}let S=y+d.tokensOwed0,N=h+d.tokensOwed1,T=[{token:p,amount:S.toString()},{token:g,amount:N.toString()}];r.push({module:"uniswap",id:`uniswap:v3:${s.toString()}`,chainId:k,assets:T,description:`Uniswap v3 LP position #${s.toString()} (${p.symbol}/${g.symbol} fee ${d.fee} ticks [${d.tickLower}, ${d.tickUpper}] liquidity ${d.liquidity.toString()})`})}return r}async function dt(t,e,n){G(t,e);let a=e.wallet!==void 0?E(e.wallet,"wallet"):l(n),o=Array.isArray(e.tokenIds)?e.tokenIds:void 0,i=Array.isArray(e.receipts)?e.receipts:void 0,r=e.includeZero===!0||e.includeEmpty===!0,s=await Oe(t,a,{tokenIds:o,receipts:i,includeEmpty:r});return{positions:s,details:{version:"v3",wallet:a,count:s.length,positionManager:f.positionManager}}}function ut(t){return[{name:"uniswap_add",inputSchema:{type:"object",description:"Mint a new Uniswap v3 concentrated liquidity position or increase liquidity on an existing v3 NFT position on Robinhood Chain (4663).",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Optional existing v3 NFT tokenId for increaseLiquidity."},token0:{type:"string",description:"Sorted ERC-20 token0 address (e.g. WETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address (e.g. USDG)."},fee:{type:"integer",enum:[100,500,3e3,1e4],default:100},fullRange:{type:"boolean",description:"For a new v3 position, use the widest ticks aligned to the pool fee tier; omit explicit ticks."},tickLower:{type:"integer",description:"Lower tick boundary divisible by tickSpacing."},tickUpper:{type:"integer",description:"Upper tick boundary divisible by tickSpacing."},amount0Desired:{type:"string",description:"Desired token0 amount in decimal base units."},amount1Desired:{type:"string",description:"Desired token1 amount in decimal base units."},amount0Min:{type:"string",description:"Minimum token0 amount in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 amount in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},wrapNative:{type:"boolean",description:"Optional: wrap native ETH into WETH before minting."},initialPrice:{type:"string",description:"Only when the pool does not exist: starting price as token1 per 1 token0 in human units. The pool is created then liquidity is minted in separately confirmed transactions."},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}}},execute:(r,s)=>ot(t,r,s)},{name:"uniswap_collect",inputSchema:{type:"object",description:"Collect accrued Uniswap v3 LP fees for an owned NonfungiblePositionManager NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},recipient:{type:"string",description:"Optional fee recipient; must be the signing wallet."},amount0Max:{type:"string",description:"Max token0 to collect (defaults to uint128 max)."},amount1Max:{type:"string",description:"Max token1 to collect (defaults to uint128 max)."}},required:["tokenId"]},execute:(r,s)=>st(t,r,s)},{name:"uniswap_remove",inputSchema:{type:"object",description:"Decrease liquidity on an owned Uniswap v3 NFT position, collect principal and fees, and optionally burn the empty NFT.",properties:{version:{type:"string",enum:["v3"],default:"v3"},tokenId:{type:"string",description:"Uniswap v3 NFT tokenId."},liquidity:{type:"string",description:"Positive base-unit liquidity amount, or all for a full exit."},amount0Min:{type:"string",description:"Minimum token0 principal in decimal base units."},amount1Min:{type:"string",description:"Minimum token1 principal in decimal base units."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:ne},deadline:{type:"integer",description:"Unix timestamp deadline (> current block timestamp)."},burn:{type:"boolean",description:"Whether to burn the NFT after removing 100% of liquidity, or burn an already-empty position."}},required:["tokenId"]},execute:(r,s)=>at(t,r,s)},{name:"uniswap_list_positions",inputSchema:{type:"object",description:"List active Uniswap v3 LP positions owned by the wallet from NFT receipts and Transfer logs.",properties:{version:{type:"string",enum:["v3"],default:"v3"},wallet:{type:"string",description:"Optional wallet address override."},tokenIds:{type:"array",items:{type:"string"},description:"Optional candidate v3 NFT tokenIds to inspect."}}},execute:(r,s)=>dt(t,r,s)},{name:"uniswap_create_pool",inputSchema:{type:"object",description:"Create and initialize an empty Uniswap v3 pool on Robinhood Chain (4663). Add liquidity afterwards with uniswap_add.",properties:{version:{type:"string",enum:["v3"],default:"v3"},token0:{type:"string",description:"Sorted ERC-20 token0 address (WETH, not native ETH)."},token1:{type:"string",description:"Sorted ERC-20 token1 address."},fee:{type:"integer",enum:[100,500,3e3,1e4]},initialPrice:{type:"string",description:'Starting price as token1 per 1 token0 in human units, e.g. "3000" for 1 WETH = 3000 USDG.'},sqrtPriceX96:{type:"string",description:"Alternative to initialPrice: exact starting sqrtPriceX96."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 bps from other live pools of the pair."}},required:["token0","token1","fee"]},execute:(r,s)=>rt(t,r,s)}]}var Xe=t=>({tools:ut(t),positions:e=>Oe(t,e)}),xt=Xe,vt=Xe;export{re as a,se as b,z as c,f as d,xe as e,yt as f,x as g,Q as h,ke as i,Qe as j,Je as k,et as l,tt as m,$e as n,ht as o,Be as p,ot as q,rt as r,st as s,at as t,Oe as u,dt as v,ut as w,Xe as x,xt as y,vt as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H}from"./UWOFA6GV.js";import{c as B,f as z,g as I,k as F,n as G}from"./73N3TOJL.js";import{a as g,i as j}from"./XPFVT2EA.js";import{a}from"./5YS5V2LK.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=j[g].meridian,S=ne.PredictionMarketEscrow.address,v={address:ne.CollateralToken_USDe.address,chainId:g,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(n,y){if(n===void 0)return y;if(!Number.isSafeInteger(n)||n<1||n>E)throw new a("Provide a Meridian page limit from 1 to 25.");return n}function X(n){if(n!==void 0){if(typeof n!="string"||!n.trim()||n.length>4096)throw new a("Provide the opaque Meridian nextCursor returned by the previous page.");return n}}function Z(n,y,u,w=!1){let l=C(n),m=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!w||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>y||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof m.hasNextPage!="boolean"||u===void 0&&!m.hasNextPage&&l.totalCount>l.nodes.length||m.endCursor!==null&&(typeof m.endCursor!="string"||!m.endCursor.trim()||m.endCursor.length>4096)||m.hasNextPage&&(l.nodes.length===0||m.endCursor===null||m.endCursor===u))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:m.hasNextPage?m.endCursor:null,complete:!m.hasNextPage&&u===void 0}}function C(n){return z(n,"Meridian returned an unexpected response.")}function A(n){if(typeof n!="string"||!n.trim())throw new a("Meridian returned an invalid text field.");return n}function b(n){return F(n,"Provide a valid Meridian contract or wallet address.")}function M(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return n}function R(n){return G(n,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(n){return n===0?"0":R(n)}function D(n){if(typeof n!="bigint"||n<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(n.toString())}function ue(n,y){return n.chainId===y.chainId&&I(n.address,y.address)}function ee(n,y){let u=C(n),w=C(u.pickConfig),l=b(u.holder),m=b(w.marketAddress);if(u.chainId!==g||!I(l,y))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(m,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof w.resolved!="boolean"||w.result!==null&&typeof w.result!="string")throw new a("Meridian returned an invalid resolution.");let P=M(u.pickConfigId);if(!I(M(w.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(u.side!=="PREDICTOR"&&u.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(u.id),chainId:g,holder:l,side:u.side,balance:N(u.balance),tokenAddress:b(u.tokenAddress),pickConfigId:P,userCollateral:N(u.userCollateral),totalPayout:N(u.totalPayout),prediction:{predictionId:M(C(u.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:m,resolved:w.resolved,result:w.result}}}var le=n=>{async function y(t){try{return await t()}catch(o){throw new a(n.plainError(o))}}async function u(){let t=n.clientFor(g);if(await t.getChainId()!==g)throw new a("Meridian requires an RPC on chain 4663.");return t}async function w(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let e=await n.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new a(`Meridian returned HTTP ${e.status}. Please try again.`);let c;try{c=await e.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(c);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await w("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return Z(s.positions,o,r,!0)}async function m(t,o){let r=[],s=new Set,e=new Set,c,d,f=0;for(let p=0;p<ce;p++){let h=await l(t,E,c);if(d!==void 0&&d!==h.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=h.totalCount;for(let x of h.nodes){let i=C(x),k=A(i.id);if(e.has(k))throw new a("Meridian repeated a position during pagination; retry from the first page.");e.add(k),N(i.balance)!=="0"&&f++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(h.nextCursor===null){if(f>d||e.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(h.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(h.nextCursor),c=h.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await u();return(await Promise.all(t.map(async e=>{let[c,d,f]=await Promise.all([r.readContract({address:e.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:e.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:e.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let p={address:e.tokenAddress,chainId:g,decimals:d,symbol:A(f)},h=D(c),x=e.pickConfig.resolved?{token:{...v},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[e.pickConfigId,e.tokenAddress,BigInt(h)]}))}:null;return{module:"meridian",id:e.id,chainId:g,assets:[{token:p,amount:h}],description:`Meridian ${e.side.toLowerCase()} position; ${e.pickConfig.resolved?e.pickConfig.result??"resolved":"unresolved"}.`,holder:e.holder,side:e.side,pickConfigId:e.pickConfigId,prediction:e.prediction,pickConfig:e.pickConfig,userCollateral:{token:{...v},amount:e.userCollateral},totalPayout:{token:{...v},amount:e.totalPayout},claimable:x}}))).filter(e=>BigInt(e.assets[0].amount)>0n)}async function q(t){return P(await m(t),t)}function L(t){return n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function _(t,o,r){let s=o.changes.map(e=>{let c=e.amount.startsWith("-"),d=n.formatAmount(c?e.amount.slice(1):e.amount,e.token.decimals);return`${c?"-":"+"}${d} ${e.token.symbol} (${e.token.address}, chain ${e.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=X(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let e;if(t.search!==void 0&&(e=A(t.search).trim(),e.length>500))throw new a("Keep the Meridian market search to 500 characters.");let c=t.conditionId===void 0?void 0:M(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),f=await w("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...e===void 0?{}:{search:e},...c===void 0?{}:{conditionIds:[c]},...d===void 0?{}:{resolvers:[d]}}),p=Z(f.conditions,o,r),h=p.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let k=M(i.conditionId),T=b(i.resolver);if(c!==void 0&&!I(k,c)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:k,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:g,collateral:{...v},totalCount:p.totalCount,markets:h,limit:o,nextCursor:p.nextCursor,complete:p.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let e=await u(),c=D(await e.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(c))throw new a("The redemption amount exceeds the wallet position balance.");let d=n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),f=[d],p;try{p=await n.preview(f,o)}catch(i){if(!/\breverted\b/i.test(n.plainError(i)))throw i;let k=await m(o,r);if(k.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=k[0];if(T.pickConfig.resolved){let re=D(await e.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}f=[L(T.prediction.predictionId),d],p=await n.preview(f,o)}let h=p.changes.filter(i=>ue(i.token,v)&&i.token.decimals===v.decimals).reduce((i,k)=>i+BigInt(k.amount),0n),x=p.changes.filter(i=>i.token.chainId===g&&I(i.token.address,r)).reduce((i,k)=>i+BigInt(k.amount),0n);if(h<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return _(f,p,f.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,e){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(c,d)=>y(async()=>{if(C(c),b(d),Object.keys(c).some(f=>!Object.hasOwn(o,f))||r.some(f=>c[f]===void 0))throw new a("Provide only the required Meridian tool inputs.");return e(c,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=X(t.cursor),e=await l(o,r,s);return{positions:await P(e.nodes.map(c=>ee(c,o)),o),totalCount:e.totalCount,limit:r,nextCursor:e.nextCursor,complete:e.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=L(M(t.predictionId));await u();let s=[r];return _(s,await n.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>y(()=>q(t))}},we=le;export{le as a,we as b};
|
|
1
|
+
import{a as H}from"./UWOFA6GV.js";import{c as B,f as z,g as I,k as F,n as G}from"./73N3TOJL.js";import{a as g,i as j}from"./G6HCV67X.js";import{a}from"./5YS5V2LK.js";import{encodeFunctionData as Q,erc20Abi as O,parseAbi as oe,zeroHash as J}from"viem";var ne=j[g].meridian,S=ne.PredictionMarketEscrow.address,v={address:ne.CollateralToken_USDe.address,chainId:g,symbol:"USDe",decimals:18},se="https://api.predict.meridian.xyz/graphql",ae="query GetOpenConditions($now: Int!, $first: Int!, $after: String, $search: String, $conditionIds: [Bytes!], $resolvers: [Address!]) { conditions(first: $first, after: $after, filter: { chainId: 4663, settled: false, public: true, endTime: { gte: $now }, search: $search, conditionIds: $conditionIds, resolvers: $resolvers }) { totalCount pageInfo { hasNextPage endCursor } nodes { conditionId resolver question shortName optionName endTime estimatedPrice openInterest similarMarketVolume24h marketType } } }",de="query GetHolderPositions($holder: Address!, $first: Int!, $after: String) { positions(first: $first, after: $after, filter: { holder: $holder, chainId: 4663 }, orderBy: { field: CREATED_AT, direction: DESC }) { totalCount pageInfo { hasNextPage endCursor } nodes { id chainId holder side balance tokenAddress: token pickConfigId userCollateral totalPayout prediction { predictionId } pickConfig { pickConfigId marketAddress: escrow resolved result } } } }",U=oe(["function getClaimableAmount(bytes32 pickConfigId, address positionToken, uint256 tokenAmount) view returns (uint256)","function settle(bytes32 predictionId, bytes32 refCode)","function redeem(address positionToken, uint256 amount, bytes32 refCode) returns (uint256)"]),K={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"},V={type:"string",minLength:1,maxLength:4096,description:"Opaque nextCursor returned by the previous page."},E=25,W={type:"integer",minimum:1,maximum:E},ce=1e3;function Y(n,y){if(n===void 0)return y;if(!Number.isSafeInteger(n)||n<1||n>E)throw new a("Provide a Meridian page limit from 1 to 25.");return n}function X(n){if(n!==void 0){if(typeof n!="string"||!n.trim()||n.length>4096)throw new a("Provide the opaque Meridian nextCursor returned by the previous page.");return n}}function Z(n,y,u,w=!1){let l=C(n),m=C(l.pageInfo),P=Array.isArray(l.nodes)?l.nodes.filter(q=>!w||N(C(q).balance)!=="0").length:0;if(!Array.isArray(l.nodes)||l.nodes.length>y||!Number.isSafeInteger(l.totalCount)||l.totalCount<P||typeof m.hasNextPage!="boolean"||u===void 0&&!m.hasNextPage&&l.totalCount>l.nodes.length||m.endCursor!==null&&(typeof m.endCursor!="string"||!m.endCursor.trim()||m.endCursor.length>4096)||m.hasNextPage&&(l.nodes.length===0||m.endCursor===null||m.endCursor===u))throw new a("Meridian returned invalid pagination; retry the scan from the first page.");return{nodes:l.nodes,totalCount:l.totalCount,nextCursor:m.hasNextPage?m.endCursor:null,complete:!m.hasNextPage&&u===void 0}}function C(n){return z(n,"Meridian returned an unexpected response.")}function A(n){if(typeof n!="string"||!n.trim())throw new a("Meridian returned an invalid text field.");return n}function b(n){return F(n,"Provide a valid Meridian contract or wallet address.")}function M(n){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new a("Provide a valid Meridian prediction or pick configuration ID.");return n}function R(n){return G(n,"Meridian amount exceeds the uint256 range.",{notString:"Meridian amounts must be integer strings in base units."}).toString()}function N(n){return n===0?"0":R(n)}function D(n){if(typeof n!="bigint"||n<0n)throw new a("Meridian returned an invalid on-chain amount.");return R(n.toString())}function ue(n,y){return n.chainId===y.chainId&&I(n.address,y.address)}function ee(n,y){let u=C(n),w=C(u.pickConfig),l=b(u.holder),m=b(w.marketAddress);if(u.chainId!==g||!I(l,y))throw new a("Meridian returned a position for a different wallet or chain.");if(!I(m,S))throw new a("This Meridian position uses an unsupported escrow contract.");if(typeof w.resolved!="boolean"||w.result!==null&&typeof w.result!="string")throw new a("Meridian returned an invalid resolution.");let P=M(u.pickConfigId);if(!I(M(w.pickConfigId),P))throw new a("Meridian returned mismatched pick configuration IDs.");if(u.side!=="PREDICTOR"&&u.side!=="COUNTERPARTY")throw new a("Meridian returned an invalid position side.");return{id:A(u.id),chainId:g,holder:l,side:u.side,balance:N(u.balance),tokenAddress:b(u.tokenAddress),pickConfigId:P,userCollateral:N(u.userCollateral),totalPayout:N(u.totalPayout),prediction:{predictionId:M(C(u.prediction).predictionId)},pickConfig:{pickConfigId:P,marketAddress:m,resolved:w.resolved,result:w.result}}}var le=n=>{async function y(t){try{return await t()}catch(o){throw new a(n.plainError(o))}}async function u(){let t=n.clientFor(g);if(await t.getChainId()!==g)throw new a("Meridian requires an RPC on chain 4663.");return t}async function w(t,o,r){let s=new URL(se);s.searchParams.set("op",t),s.searchParams.set("query",o),s.searchParams.set("variables",JSON.stringify(r));let e=await n.http(s.toString(),{method:"GET",headers:{Accept:"application/json"}});if(!e.ok)throw new a(`Meridian returned HTTP ${e.status}. Please try again.`);let c;try{c=await e.json()}catch{throw new a("Meridian returned malformed JSON.")}let d=C(c);if(d.errors!==void 0&&(!Array.isArray(d.errors)||d.errors.length>0))throw new a("Meridian could not complete the GraphQL query. Please try again.");return C(d.data)}async function l(t,o=10,r){b(t);let s=await w("GetHolderPositions",de,{holder:t,first:o,...r===void 0?{}:{after:r}});return Z(s.positions,o,r,!0)}async function m(t,o){let r=[],s=new Set,e=new Set,c,d,f=0;for(let p=0;p<ce;p++){let h=await l(t,E,c);if(d!==void 0&&d!==h.totalCount)throw new a("Meridian positions changed during pagination; retry from the first page.");d=h.totalCount;for(let x of h.nodes){let i=C(x),k=A(i.id);if(e.has(k))throw new a("Meridian repeated a position during pagination; retry from the first page.");e.add(k),N(i.balance)!=="0"&&f++,(o===void 0||I(b(i.tokenAddress),o))&&r.push(ee(x,t))}if(h.nextCursor===null){if(f>d||e.size<d)throw new a("Meridian returned an incomplete positions scan; retry from the first page.");return r}if(s.has(h.nextCursor))throw new a("Meridian repeated a cursor; retry from the first page.");s.add(h.nextCursor),c=h.nextCursor}throw new a("Meridian positions scan exceeded 1000 pages. Use meridian_positions with limit and cursor to inspect pages; redeem a known settled positionToken directly.")}async function P(t,o){if(t.length===0)return[];let r=await u();return(await Promise.all(t.map(async e=>{let[c,d,f]=await Promise.all([r.readContract({address:e.tokenAddress,abi:O,functionName:"balanceOf",args:[o]}),r.readContract({address:e.tokenAddress,abi:O,functionName:"decimals"}),r.readContract({address:e.tokenAddress,abi:O,functionName:"symbol"})]);if(!Number.isInteger(d)||d<0||d>255)throw new a("Meridian returned invalid position token decimals.");let p={address:e.tokenAddress,chainId:g,decimals:d,symbol:A(f)},h=D(c),x=e.pickConfig.resolved?{token:{...v},amount:D(await r.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[e.pickConfigId,e.tokenAddress,BigInt(h)]}))}:null;return{module:"meridian",id:e.id,chainId:g,assets:[{token:p,amount:h}],description:`Meridian ${e.side.toLowerCase()} position; ${e.pickConfig.resolved?e.pickConfig.result??"resolved":"unresolved"}.`,holder:e.holder,side:e.side,pickConfigId:e.pickConfigId,prediction:e.prediction,pickConfig:e.pickConfig,userCollateral:{token:{...v},amount:e.userCollateral},totalPayout:{token:{...v},amount:e.totalPayout},claimable:x}}))).filter(e=>BigInt(e.assets[0].amount)>0n)}async function q(t){return P(await m(t),t)}function L(t){return n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"settle",args:[t,J]}),description:`Settle Meridian prediction ${t}.`})}function _(t,o,r){let s=o.changes.map(e=>{let c=e.amount.startsWith("-"),d=n.formatAmount(c?e.amount.slice(1):e.amount,e.token.decimals);return`${c?"-":"+"}${d} ${e.token.symbol} (${e.token.address}, chain ${e.token.chainId})`});return{txs:t,preview:o,summary:`${r} ${o.summary}${s.length?` Changes: ${s.join("; ")}.`:""}`}}async function te(t){let o=Y(t.limit,20),r=X(t.cursor);if(r!==void 0&&t.asOf===void 0)throw new a("Pass the previous Meridian browse asOf with cursor to keep the same time filter.");let s=t.asOf===void 0?Math.floor(Date.now()/1e3):Number(R(t.asOf));if(!Number.isSafeInteger(s)||s<0||s>2147483647)throw new a("Provide Meridian asOf as Unix seconds within the GraphQL Int range.");let e;if(t.search!==void 0&&(e=A(t.search).trim(),e.length>500))throw new a("Keep the Meridian market search to 500 characters.");let c=t.conditionId===void 0?void 0:M(t.conditionId),d=t.resolver===void 0?void 0:b(t.resolver),f=await w("GetOpenConditions",ae,{now:s,first:o,...r===void 0?{}:{after:r},...e===void 0?{}:{search:e},...c===void 0?{}:{conditionIds:[c]},...d===void 0?{}:{resolvers:[d]}}),p=Z(f.conditions,o,r),h=p.nodes.map(x=>{let i=C(x);if(!Number.isSafeInteger(i.endTime)||i.endTime<0||i.estimatedPrice!==null&&(typeof i.estimatedPrice!="number"||!Number.isFinite(i.estimatedPrice)||i.estimatedPrice<0||i.estimatedPrice>1))throw new a("Meridian returned invalid market pricing or time.");let k=M(i.conditionId),T=b(i.resolver);if(c!==void 0&&!I(k,c)||d!==void 0&&!I(T,d))throw new a("Meridian returned a different condition or resolver than requested.");return{conditionId:k,resolver:T,question:A(i.question),shortName:i.shortName===null?null:A(i.shortName),optionName:i.optionName===null?null:A(i.optionName),endTime:String(i.endTime),estimatedPrice:i.estimatedPrice===null?null:String(i.estimatedPrice),marketType:i.marketType===null?null:A(i.marketType)}});return{chainId:g,collateral:{...v},totalCount:p.totalCount,markets:h,limit:o,nextCursor:p.nextCursor,complete:p.complete,asOf:String(s)}}async function ie(t,o){let r=b(t.positionToken),s=R(t.amount);if(BigInt(s)===0n)throw new a("Provide a positive Meridian redemption amount.");let e=await u(),c=D(await e.readContract({address:r,abi:O,functionName:"balanceOf",args:[o]}));if(BigInt(s)>BigInt(c))throw new a("The redemption amount exceeds the wallet position balance.");let d=n.unsignedTx({to:S,chainId:g,value:"0",data:Q({abi:U,functionName:"redeem",args:[r,BigInt(s),J]}),description:`Redeem ${s} Meridian position base units for USDe.`}),f=[d],p;try{p=await n.preview(f,o)}catch(i){if(!/\breverted\b/i.test(n.plainError(i)))throw i;let k=await m(o,r);if(k.length!==1)throw new a("Direct Meridian redemption reverted and no unique indexed prediction was found for this token. Retry indexing or use meridian_settle with the known predictionId first.");let T=k[0];if(T.pickConfig.resolved){let re=D(await e.readContract({address:S,abi:U,functionName:"getClaimableAmount",args:[T.pickConfigId,r,BigInt(s)]}));if(BigInt(re)===0n)throw i}f=[L(T.prediction.predictionId),d],p=await n.preview(f,o)}let h=p.changes.filter(i=>ue(i.token,v)&&i.token.decimals===v.decimals).reduce((i,k)=>i+BigInt(k.amount),0n),x=p.changes.filter(i=>i.token.chainId===g&&I(i.token.address,r)).reduce((i,k)=>i+BigInt(k.amount),0n);if(h<=0n||x!==-BigInt(s))throw new a("Meridian preview did not show the requested position burn and a positive USDe payout.");return _(f,p,f.length===2?"Settle the prediction, then redeem for USDe. Unsigned transactions only.":"Redeem the position for USDe. Unsigned transaction only.")}function $(t,o,r,s,e){return{name:t,inputSchema:{type:"object",properties:o,required:r,additionalProperties:!1,description:s},execute:(c,d)=>y(async()=>{if(C(c),b(d),Object.keys(c).some(f=>!Object.hasOwn(o,f))||r.some(f=>c[f]===void 0))throw new a("Provide only the required Meridian tool inputs.");return e(c,d)})}}return{tools:[$("meridian_browse",{search:{type:"string",minLength:1,maxLength:500},cursor:V,limit:W,conditionId:K,resolver:B,asOf:H("Reuse the returned Unix seconds with cursor.")},[],"Search open Meridian conditions or look up a conditionId/resolver. Follow nextCursor with the same filters and asOf.",te),$("meridian_positions",{cursor:V,limit:W},[],"Page through indexed Meridian positions with on-chain balances and claimability. Follow nextCursor until null; indexing can lag transfers.",async(t,o)=>{let r=Y(t.limit,10),s=X(t.cursor),e=await l(o,r,s);return{positions:await P(e.nodes.map(c=>ee(c,o)),o),totalCount:e.totalCount,limit:r,nextCursor:e.nextCursor,complete:e.complete,scope:"Indexed positions with current on-chain balances. Index totalCount may exclude zero-balance rows. Indexing can lag transfers; redeem known settled tokens directly."}}),$("meridian_settle",{predictionId:K},["predictionId"],"Preview an unsigned unilateral settlement; unresolved or already settled predictions may revert.",async(t,o)=>{let r=L(M(t.predictionId));await u();let s=[r];return _(s,await n.preview(s,o),"Settle the Meridian prediction. Unsigned transaction only.")}),$("meridian_redeem",{positionToken:B,amount:H("Position token amount in base units.")},["positionToken","amount"],"Preview redemption of a known position token directly; scan all indexed pages for settlement first if required. No approval or typed signature.",ie)],positions:t=>y(()=>q(t))}},we=le;export{le as a,we as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as k}from"./UWOFA6GV.js";import{c as l}from"./73N3TOJL.js";import{a as p}from"./
|
|
1
|
+
import{a as k}from"./UWOFA6GV.js";import{c as l}from"./73N3TOJL.js";import{a as p}from"./G6HCV67X.js";import{a as s}from"./5YS5V2LK.js";import{encodeFunctionData as H,getAddress as m,parseAbi as f,zeroAddress as w}from"viem";var x=f(["function tokenizations(address token) view returns ((address creator,address forwarder,bytes32 marketFamilyId,uint64 createdAt))"]),S=f(["function tokenizations(address token) view returns ((address creator,uint8 way,address forwarder,address adapter,address door,bytes32 familyId,bytes32 marketFamilyId,uint64 unlockBlock,uint16 legBps))"]),b=f(["function name() view returns (string)","function symbol() view returns (string)","function decimals() view returns (uint8)","function balanceOf(address account) view returns (uint256)","function totalSupply() view returns (uint256)","function assetCount() view returns (uint256)","function claimable(address account,uint256 asset) view returns (uint256)","function streamSeconds() view returns (uint32)","function tipBps() view returns (uint16)","function doorCount() view returns (uint256)","function dropBox() view returns (address)","function bridge() view returns (address)","function claim(uint256 asset,address to) returns (uint256 amount)","function claimAll(address to) returns (uint256[] amounts)","function sync() returns (uint256 tip)","function syncRange(uint256 start,uint256 count) returns (uint256 tip)","function syncSome(uint256[] doorIds) returns (uint256 tip)"]),C=f(["function dropCount() view returns (uint256)","function claimable(uint256 dropId,address holder) view returns (uint256)","function claim(uint256[] dropIds,address to) returns (uint256[] amounts)"]),y=["0x522723A7a09684515881568Ab8247f3846D66F43","0xfb3c1501c727f30883cd7B36Ec380381af7412Ef"].map(m),I={token:b,drops:C};function O(n){return{type:"object",properties:Object.fromEntries(n.inputs.map(t=>[t.name,t.type==="address"?l:t.type==="uint256[]"?{type:"array",items:k(),maxItems:128}:k()])),required:n.inputs.map(t=>t.name),additionalProperties:!1}}function h(n){return Object.entries(I).flatMap(([t,o])=>o.filter(r=>r.stateMutability==="view"===n).map(r=>({target:t,fn:r})))}function v(n){return{type:"object",oneOf:h(n).map(({target:t,fn:o})=>({type:"object",properties:{token:l,target:{const:t},function:{const:o.name},params:O(o)},required:["token","target","function","params"],additionalProperties:!1}))}}function A(n,t){if(Object.keys(n).length!==4||Object.keys(n).some(e=>!["token","target","function","params"].includes(e)))throw new s("Provide token, target, function and params for the Hookr revenue operation.");let o=h(t).find(e=>e.target===n.target&&e.fn.name===n.function);if(!o||!n.params||typeof n.params!="object"||Array.isArray(n.params))throw new s("Choose a documented Hookr revenue function and parameter object.");let r;try{r=m(String(n.token))}catch{throw new s("Provide a valid Hookr revenue token address.")}let i=n.params,a=o.fn;if(Object.keys(i).length!==a.inputs.length||Object.keys(i).some(e=>!a.inputs.some(u=>u.name===e)))throw new s("Provide exactly the documented Hookr revenue parameters.");let c=e=>{if(typeof e!="string"||!/^(0|[1-9][0-9]*)$/.test(e)||e.length>78||BigInt(e)>=1n<<256n)throw new s("Revenue token indices and amounts must be decimal base-unit strings.");return BigInt(e)},d=a.inputs.map(e=>{let u=i[e.name];if(e.type==="address")try{return m(String(u))}catch{throw new s("Provide a valid Hookr revenue address.")}if(e.type==="uint256[]"){if(!Array.isArray(u)||u.length>128)throw new s("Provide at most 128 Hookr revenue indices.");return u.map(c)}return c(u)});return{token:r,fn:a,values:d,operation:o}}async function g(n,t,o){let r=n.clientFor(p),i;for(let c of y){let d=c===y[0],e=await r.readContract({address:c,abi:d?x:S,functionName:"tokenizations",args:[t]});if(!e||typeof e.creator!="string"||d&&(!("createdAt"in e)||typeof e.createdAt!="bigint"||e.createdAt<0n||e.createdAt>=1n<<64n))throw new s("Hookr token provenance is unavailable.");if(m(e.creator)!==w&&(!d||"createdAt"in e&&e.createdAt>0n)){i=c;break}}if(!i)throw new s("This token has no record on a pinned Hookr tokenizer.");let a=o?m(await r.readContract({address:t,abi:b,functionName:"dropBox"})):t;if(a===w)throw new s("Hookr revenue drop box is unavailable.");return{to:a,tokenizer:i}}async function j(n,t,o){if(n.network==="testnet")throw new s("Hookr revenue actions require mainnet, chain 4663.");let{token:r,fn:i,values:a}=A(t,!1),{to:c}=await g(n,r,t.target==="drops"),d=i.inputs.findIndex(e=>e.name==="to");if(d>=0&&[w,r,c].includes(a[d]))throw new s("Choose a valid revenue claim recipient.");return{txs:[n.unsignedTx({chainId:p,to:c,value:"0",data:H({abi:[i],functionName:i.name,args:a}),description:`Hookr revenue ${t.target}.${i.name}: ${JSON.stringify(t.params)}. No token approval or principal deposit.`})],inputs:[]}}function T(n){return[{name:"hookr_revenue_read",inputSchema:{...v(!0),description:"Read a registered Hookr revenue token or its derived drop box: balance, claimable, terms and indices. Checks tokenizer provenance on chain."},execute:async t=>{let{token:o,fn:r,values:i}=A(t,!0),{to:a,tokenizer:c}=await g(n,o,t.target==="drops"),d=await n.clientFor(p).readContract({address:a,abi:[r],functionName:r.name,args:i});return{chainId:p,token:o,tokenizer:c,contract:a,function:r.name,result:JSON.parse(JSON.stringify(d,(e,u)=>typeof u=="bigint"?u.toString():u))}}},{name:"hookr_revenue_action",inputSchema:{...v(!1),description:"Preview holder income/drop claims or permissionless sync/syncRange/syncSome on a registered Hookr revenue token. No approvals; local human confirmation required. Claims and syncs are separate actions."},execute:async(t,o)=>{let{txs:r}=await j(n,t,o),i=await n.preview(r,o);return{txs:r,preview:i,summary:`Hookr revenue ${t.function}; verify receipt and holder balances after confirmation.`}}}]}export{y as a,j as b,T as c};
|