@oakagentkit/core 0.3.0 → 0.3.2
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/history.js +1 -1
- package/build/dist/api/modules/beefy/clm.d.ts +9 -0
- 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/borro/index.js +1 -1
- package/build/dist/api/modules/borro/positions.js +1 -1
- package/build/dist/api/modules/borro/reader.js +1 -1
- package/build/dist/api/modules/chop/actions.js +1 -1
- package/build/dist/api/modules/chop/checks.js +1 -1
- package/build/dist/api/modules/chop/copy.js +1 -1
- package/build/dist/api/modules/chop/guard.js +1 -1
- package/build/dist/api/modules/chop/index.js +1 -1
- package/build/dist/api/modules/chop/pins.d.ts +13 -0
- package/build/dist/api/modules/chop/pins.js +1 -1
- package/build/dist/api/modules/chop/positions.js +1 -1
- package/build/dist/api/modules/chop/reader.js +1 -1
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/fobo/client.d.ts +9 -0
- package/build/dist/api/modules/fobo/client.js +1 -0
- package/build/dist/api/modules/fobo/index.d.ts +16 -0
- package/build/dist/api/modules/fobo/index.js +1 -0
- package/build/dist/api/modules/fobo/intent.d.ts +243 -0
- package/build/dist/api/modules/fobo/intent.js +1 -0
- package/build/dist/api/modules/fobo/pins.d.ts +178 -0
- package/build/dist/api/modules/fobo/pins.js +1 -0
- package/build/dist/api/modules/fobo/steps.d.ts +25 -0
- package/build/dist/api/modules/fobo/steps.js +1 -0
- package/build/dist/api/modules/fobo/verify.d.ts +89 -0
- package/build/dist/api/modules/fobo/verify.js +1 -0
- package/build/dist/api/modules/gloam/copy.d.ts +1 -1
- package/build/dist/api/modules/gloam/copy.js +1 -1
- package/build/dist/api/modules/gloam/index.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-options.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/kyberswap/index.js +1 -1
- package/build/dist/api/modules/layerbank/actions.js +1 -1
- package/build/dist/api/modules/layerbank/index.js +1 -1
- package/build/dist/api/modules/layerbank/reader.js +1 -1
- package/build/dist/api/modules/longbow/administration.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/meridian/index.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/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.d.ts +2 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.d.ts +3 -2
- 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/surface.js +1 -1
- package/build/dist/api/modules/morpho/vault-tools.js +1 -1
- package/build/dist/api/modules/netnet/card-plan.js +1 -1
- package/build/dist/api/modules/netnet/card-read.js +1 -1
- package/build/dist/api/modules/netnet/card-recovery.js +1 -1
- package/build/dist/api/modules/netnet/desk-action.js +1 -1
- package/build/dist/api/modules/netnet/financial.js +1 -1
- package/build/dist/api/modules/netnet/index.js +1 -1
- package/build/dist/api/modules/orbio/index.js +1 -1
- package/build/dist/api/modules/pendle/index.js +1 -1
- package/build/dist/api/modules/pendle/reader.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/reads.js +1 -1
- package/build/dist/api/modules/pons/swap-terms.d.ts +2 -8
- 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/holdings.js +1 -1
- package/build/dist/api/modules/priors/index.js +1 -1
- package/build/dist/api/modules/priors/integration.js +1 -1
- package/build/dist/api/modules/priors/stock-swap.js +1 -1
- package/build/dist/api/modules/raeto/index.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/spark/index.js +1 -1
- package/build/dist/api/modules/steakhouse/analytics.js +1 -1
- package/build/dist/api/modules/steakhouse/index.js +1 -1
- package/build/dist/api/modules/steakhouse/local-guard.js +1 -1
- package/build/dist/api/modules/steakhouse/management.js +1 -1
- package/build/dist/api/modules/steakhouse/v2-exit.js +1 -1
- package/build/dist/api/modules/tickerspring/basket-routes.js +1 -1
- package/build/dist/api/modules/tickerspring/contract-reads.js +1 -1
- package/build/dist/api/modules/tickerspring/exit-preview.js +1 -1
- package/build/dist/api/modules/tickerspring/guards.js +1 -1
- package/build/dist/api/modules/tickerspring/index.js +1 -1
- package/build/dist/api/modules/tickerspring/journeys.js +1 -1
- package/build/dist/api/modules/tickerspring/ladder.js +1 -1
- package/build/dist/api/modules/tickerspring/maker.js +1 -1
- package/build/dist/api/modules/tickerspring/order-accounting.js +1 -1
- package/build/dist/api/modules/tickerspring/research.js +1 -1
- package/build/dist/api/modules/tickerspring/strategies.js +1 -1
- package/build/dist/api/modules/uniswap/auction-create.js +1 -1
- package/build/dist/api/modules/uniswap/auction.js +1 -1
- package/build/dist/api/modules/uniswap/batch.js +1 -1
- package/build/dist/api/modules/uniswap/common.js +1 -1
- package/build/dist/api/modules/uniswap/fees.js +1 -1
- package/build/dist/api/modules/uniswap/index.js +1 -1
- package/build/dist/api/modules/uniswap/local-guard.js +1 -1
- package/build/dist/api/modules/uniswap/oracle.js +1 -1
- package/build/dist/api/modules/uniswap/pool-math.js +1 -1
- package/build/dist/api/modules/uniswap/pools.js +1 -1
- package/build/dist/api/modules/uniswap/position.js +1 -1
- package/build/dist/api/modules/uniswap/protocol.js +1 -1
- package/build/dist/api/modules/uniswap/quote-guard.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/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.js +1 -1
- package/build/dist/api/prices.d.ts +5 -0
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/swap.d.ts +1 -0
- package/build/dist/api/swap.js +1 -1
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/universal-router.d.ts +45 -0
- package/build/dist/api/universal-router.js +1 -0
- package/build/dist/api/usd-estimate.js +1 -1
- package/build/dist/chunks/{ROQQ62LP.js → 22TU5PFT.js} +1 -1
- package/build/dist/chunks/{2WRXH6BL.js → 257N7343.js} +1 -1
- package/build/dist/chunks/{B2HSLY5F.js → 27PVS6BU.js} +1 -1
- package/build/dist/chunks/{24Q3FNGX.js → 35LXCSHY.js} +1 -1
- package/build/dist/chunks/{OYDKAIS2.js → 3BMM3V4P.js} +1 -1
- package/build/dist/chunks/{VZVW5J7J.js → 3FU6XP6S.js} +1 -1
- package/build/dist/chunks/{KH4QFN72.js → 3PHJUFU2.js} +1 -1
- package/build/dist/chunks/{TMRAF2L2.js → 3UQXTZ5R.js} +1 -1
- package/build/dist/chunks/43BG2JRB.js +1 -0
- package/build/dist/chunks/{KMSAUFYV.js → 47HSRR7G.js} +1 -1
- package/build/dist/chunks/{M7BUKZW2.js → 4RCYYN6O.js} +1 -1
- package/build/dist/chunks/4ZD5D2UP.js +1 -0
- package/build/dist/chunks/{6OCLWSMZ.js → 5CPB33XA.js} +1 -1
- package/build/dist/chunks/{X5AL3DUK.js → 6D3XNCOX.js} +1 -1
- package/build/dist/chunks/{W4RYRLL5.js → 6GWXPQZ6.js} +1 -1
- package/build/dist/chunks/{D2IYA4LP.js → 72EV7TGI.js} +1 -1
- package/build/dist/chunks/{KBU3PYP7.js → 73BZPPRS.js} +1 -1
- package/build/dist/chunks/{XV3YJ4P6.js → 7FIEBJOZ.js} +1 -1
- package/build/dist/chunks/{CI5ENLYA.js → 7FZXSYFD.js} +1 -1
- package/build/dist/chunks/{K4P5VYDP.js → 7TSIF3F4.js} +1 -1
- package/build/dist/chunks/{KZA5GYZR.js → AWV24X7F.js} +1 -1
- package/build/dist/chunks/{WOGWLFAL.js → BGVC5NI6.js} +1 -1
- package/build/dist/chunks/BJK75C7G.js +1 -0
- package/build/dist/chunks/BSX4LFYI.js +1 -0
- package/build/dist/chunks/{OTYB6BHK.js → BZPFPQ2I.js} +1 -1
- package/build/dist/chunks/{XBNZ7GTY.js → CXH46MHJ.js} +1 -1
- package/build/dist/chunks/{PQXYTOV5.js → DCGNVMKG.js} +1 -1
- package/build/dist/chunks/{OTLUQWLF.js → DLNA5272.js} +1 -1
- package/build/dist/chunks/{VMZYFO6I.js → DXAPKN7H.js} +1 -1
- package/build/dist/chunks/{NMQBOBWJ.js → EHGH646D.js} +1 -1
- package/build/dist/chunks/{PZEF5LBL.js → ETMD747Y.js} +1 -1
- package/build/dist/chunks/{GP6YO24Z.js → FSYYD3OM.js} +1 -1
- package/build/dist/chunks/{XEBMS5KU.js → GGMVT5A6.js} +1 -1
- package/build/dist/chunks/GK3D7OKG.js +1 -0
- package/build/dist/chunks/GYPMUYB5.js +1 -0
- package/build/dist/chunks/{U7UPLF4F.js → H64QC4QR.js} +1 -1
- package/build/dist/chunks/{HS5HWBMU.js → HIG7JY3J.js} +1 -1
- package/build/dist/chunks/{65356YKW.js → HPY2ONAS.js} +1 -1
- package/build/dist/chunks/{C6VJAL5B.js → HUKDISRE.js} +1 -1
- package/build/dist/chunks/{XPWGPZ2C.js → HZSYMGJ2.js} +1 -1
- package/build/dist/chunks/{QMEGAKLI.js → I3ZBOSSH.js} +1 -1
- package/build/dist/chunks/{YARZE7SJ.js → I4473OC6.js} +1 -1
- package/build/dist/chunks/{DMB64UIN.js → IJ4HZIDG.js} +1 -1
- package/build/dist/chunks/{YBLJ75U5.js → IPU656WB.js} +1 -1
- package/build/dist/chunks/{QLAOBULN.js → JTPHZCO3.js} +1 -1
- package/build/dist/chunks/{CSOO4SW7.js → K4GUZ5QS.js} +1 -1
- package/build/dist/chunks/{WBNFRPAT.js → KLEJ3W4T.js} +1 -1
- package/build/dist/chunks/{ACH4BSME.js → KOKLM63Q.js} +1 -1
- package/build/dist/chunks/{VB36EHIR.js → KVVBT43U.js} +1 -1
- package/build/dist/chunks/{6MDYKE2O.js → KXX7ZBFY.js} +1 -1
- package/build/dist/chunks/{I6PQW2JI.js → L2AE32SL.js} +1 -1
- package/build/dist/chunks/{KOTGFD2V.js → LGLWEGPY.js} +1 -1
- package/build/dist/chunks/{2HN3U6OG.js → LQSPWRHN.js} +1 -1
- package/build/dist/chunks/{C3WBHFLX.js → LTDF2LNP.js} +1 -1
- package/build/dist/chunks/{RNCMXKKS.js → M4AGEGWW.js} +1 -1
- package/build/dist/chunks/{OODSXDIH.js → MGVX5EUH.js} +1 -1
- package/build/dist/chunks/NCAV7Q4C.js +6 -0
- package/build/dist/chunks/{CZQ2CGYV.js → NUERUFH7.js} +1 -1
- package/build/dist/chunks/NV6FDIYT.js +1 -0
- package/build/dist/chunks/{A2V4NFVA.js → O3CC5SRM.js} +1 -1
- package/build/dist/chunks/{JI5DXDMY.js → ODV3XT5U.js} +1 -1
- package/build/dist/chunks/{HVFMIURK.js → OFWTO4N6.js} +1 -1
- package/build/dist/chunks/{B7BNDW35.js → OY5W7ZSL.js} +1 -1
- package/build/dist/chunks/{CD2JQ32C.js → PDGYM2WG.js} +1 -1
- package/build/dist/chunks/PHGHJ7SN.js +1 -0
- package/build/dist/chunks/{5R576SDB.js → PKYQ3XVA.js} +1 -1
- package/build/dist/chunks/{FN6GNTPR.js → PWJVC2FV.js} +1 -1
- package/build/dist/chunks/{PSGRZWES.js → QN45T4N3.js} +1 -1
- package/build/dist/chunks/{LJJYYUEG.js → QPY6UTLU.js} +1 -1
- package/build/dist/chunks/{ATEVAJ5Y.js → RA7DOR7F.js} +1 -1
- package/build/dist/chunks/{U762746N.js → RUSXMQSJ.js} +1 -1
- package/build/dist/chunks/{UPKVD7WG.js → RXP7ZUPY.js} +1 -1
- package/build/dist/chunks/{2QGLPY2D.js → SMKO7GKX.js} +1 -1
- package/build/dist/chunks/{EHK7CDTU.js → SNCV6HV7.js} +1 -1
- package/build/dist/chunks/{Q7L3BX6U.js → SO6O7JK2.js} +1 -1
- package/build/dist/chunks/{2ZQ7X223.js → SOJHYMD7.js} +1 -1
- package/build/dist/chunks/SVKG4JOY.js +3 -0
- package/build/dist/chunks/{ORG6LVKJ.js → UBI3HBXD.js} +1 -1
- package/build/dist/chunks/{NWPAQER2.js → UCHJYWGU.js} +1 -1
- package/build/dist/chunks/{N64JJN37.js → UEHN2IDF.js} +1 -1
- package/build/dist/chunks/{FTMA24EC.js → UHIJMDD2.js} +1 -1
- package/build/dist/chunks/UJQYOTO5.js +1 -0
- package/build/dist/chunks/{MMCM3GSM.js → V4UJMUIB.js} +1 -1
- package/build/dist/chunks/{ZNPVBNC5.js → VC5ZCQYZ.js} +1 -1
- package/build/dist/chunks/{FGEGJOAA.js → VDJPDIBV.js} +1 -1
- package/build/dist/chunks/{TGFQQCRY.js → VFM2BICB.js} +1 -1
- package/build/dist/chunks/{MSMHS456.js → VOJULRNU.js} +1 -1
- package/build/dist/chunks/{5W74Z4WZ.js → W3DGFMQE.js} +1 -1
- package/build/dist/chunks/{QLFPAN6S.js → W7QNSNOH.js} +1 -1
- package/build/dist/chunks/{2ZBSE2LD.js → WCI3FHWT.js} +1 -1
- package/build/dist/chunks/X5I5EJ5T.js +6 -0
- package/build/dist/chunks/{JPPQDELB.js → XKLXVTSE.js} +3 -3
- package/build/dist/chunks/{OQFNUDMQ.js → XVOW6UCI.js} +1 -1
- package/build/dist/chunks/{P6OB2AFW.js → Y7HBFQYG.js} +1 -1
- package/build/dist/chunks/{25C4DTVA.js → YAVWSW3G.js} +1 -1
- package/build/dist/chunks/{LDJI2JAL.js → YGW4ODAP.js} +1 -1
- package/build/dist/chunks/{U243AWCH.js → YW4W3LPQ.js} +1 -1
- package/build/dist/chunks/{S4UJDZGN.js → ZDCCFEVL.js} +1 -1
- package/build/dist/chunks/{D7QXZM3S.js → ZOLHVZDK.js} +1 -1
- package/build/dist/chunks/{SMSXZ3FN.js → ZSVAGOF2.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/4R3G3H42.js +0 -1
- package/build/dist/chunks/LKX5WDOQ.js +0 -1
- package/build/dist/chunks/ND32LJWI.js +0 -1
- package/build/dist/chunks/URBEK2VV.js +0 -1
- package/build/dist/chunks/UVAR6BHU.js +0 -1
- package/build/dist/chunks/V6SDKPZS.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as ht}from"./65OITTDL.js";import{b as bt}from"./OTLUQWLF.js";import{b as gt}from"./MSMHS456.js";import{b as ft}from"./B7BNDW35.js";import{c as pt}from"./ORG6LVKJ.js";import{b as wt}from"./GDOHHXNH.js";import{c as mt}from"./O4S6XAYV.js";import{h as ut}from"./VXCGMALF.js";import{a as C,b as L,c as Ie,d as me,e as Ge,g as st,h as Ve,j as U,l as E,o as Fe,p as at,q as dt,r as Me,s as lt,t as qe,u as ct}from"./4NBXBKOX.js";import{i as rt}from"./2GXHYI23.js";import{b as ot,o as it}from"./LKX5WDOQ.js";import{b as et}from"./SPJCSEKP.js";import{a as z}from"./43LI5NKJ.js";import{a as tt,c as nt}from"./SCG5HWMN.js";import{a as Pe}from"./66F5ZH34.js";import{b as ee}from"./IX3GZMTM.js";import{b as $,e as N,j as ce}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{a as Ee}from"./JXOEJPJ4.js";import{BaseError as _t,ContractFunctionRevertedError as Ye,decodeEventLog as zt,decodeFunctionResult as Jt,encodeFunctionData as X,erc20Abi as Xt,getAddress as B,parseAbi as ke,parseAbiItem as Yt,recoverAddress as Zt,recoverMessageAddress as Kt,recoverTypedDataAddress as Qt}from"viem";var en="https://priors.trade/api/check",He=604800n,yt=50n,$t=10000n,We=5000000n,St=500000000n,je=86400n,At=2592000n,Ze=`Register one with oak_setup {"mode":"register"}, then open Priors' 5 USDG starter line with priors_starter_line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent; each transaction and signature is confirmed).`,tn="0x6982e39521a070a3c40782548bfbed6dc8f566ef",nn=["0xcbb95bbf36099d34da091dc6fa6f49efa257cee3","0x284358abc07f9359f19f4b5b4ac91901be2597ba"],c={pool:B(ce[4663].priors.pool.address),lens:B(ce[4663].priors.lens.address),usdg:B(ce[4663].priors.usdg.address),registry:B(ce[4663].priors.registry.address),stockVault:B(ce[4663].priors.stockVault.address)},te={address:c.usdg,symbol:"USDG",decimals:N,chainId:$},S=ke(["function deposit(uint256 assets, address receiver, uint256 minShares) returns (uint256 minted)","function withdraw(uint256 shares_, address receiver) returns (uint256 out)","function quoteFee(uint256 agentId, uint256 principal, uint64 term) view returns (uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium)","function borrow(uint256 agentId, uint256 amount, uint64 term, address to, uint256 maxFee) returns (uint256 loanId)","function repay(uint256 loanId, uint256 expectedAgentId, uint256 maxDue)","function shares(address lender) view returns (uint256)","function convertToAssets(uint256 shares_) view returns (uint256)","function lastDepositAt(address lender) view returns (uint64)","function isController(uint256 id, address who) view returns (bool)","function delegateOf(uint256 id) view returns (address)","function getAgent(uint256 id) view returns (bool enrolled, bool isRoot, bool defaulted, bool frozen, bool importedFromV1, uint64 enrolledAt, uint64 lastBorrowAt, uint64 lastRepayAt, uint256 sponsor, uint256 delegatedIn, uint256 delegatedOut, uint256 principalOut, uint256 activeLoans, uint256 premiumBps, uint256 premiumCap, uint256 loansRepaid, uint256 volumeRepaid, uint256 feesPaid, uint256 recourseHonored, uint256 childrenDefaulted, uint256 qualifiedRepaid, uint256 dollarSecondsRepaid)","function nonces(uint256 id) view returns (uint256)","function consentDigest((uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline) c) view returns (bytes32)","function leave(uint256 agentId)","function loansOf(uint256 id) view returns (uint256[])","function getLoan(uint256 loanId) view returns (uint256 agentId, uint256 sponsorId, uint256 principal, uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium, address owner, uint64 issuedAt, uint64 dueAt, uint64 defaultableAt, uint64 minScoreTerm, uint64 closedAt, uint8 status)","event Borrowed(uint256 indexed loanId, uint256 indexed agentId, uint256 indexed sponsorId, uint256 principal, uint256 fee, uint64 dueAt, address to)"]),vt=ke(["function available(uint256 agentId) view returns (uint256)","function score(uint256 id) view returns (uint256)"]),kt=ke(["function ownerOf(uint256 agentId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function getAgentWallet(uint256 agentId) view returns (address)"]),Pt=ke(["function borrowRoom(uint256 agentId) view returns (uint256)","function assetList() view returns (address[])","function assets(address token) view returns (address feed, uint32 heartbeat, uint8 tokenDecimals, uint8 feedDecimals, bool enabled, uint16 ltvBps, uint256 lineCap)"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function on(e){return e.chainId===$&&e.address.toLowerCase()===c.usdg.toLowerCase()}function rn(e,i){let g=i.amount.trim(),u=g.startsWith("-"),f=u||g.startsWith("+")?g.slice(1):g,R=e.formatAmount(f,i.token.decimals),A=on(i.token)?"USDG":i.token.address;return`${u?"-":"+"}${R} ${A}`}function ne(e,i,g){if(!g.length)return i;let u=g.map(f=>rn(e,f)).join(", ");return`${i} Preview changes: ${u}.`}function It(e,i,g,u){let f=e[i]===void 0?void 0:ee(e[i]),R=e[g]===void 0?void 0:ee(e[g]);if(f!==void 0)return f;if(R!==void 0)return R;throw new a(`Provide ${u} as an integer string in base units ("${i}" or "${g}").`)}async function De(e,i,g){try{return B(await e.clientFor($).readContract({address:c.registry,abi:kt,functionName:"ownerOf",args:[i],blockNumber:g}))}catch(u){throw u instanceof _t&&u.walk(f=>f instanceof Ye)?new a(`ERC-8004 agent ${i} does not exist in registry ${c.registry}: it has no owner. Check the agent ID.`):new a(`Could not read the owner of ERC-8004 agent ${i} from registry ${c.registry}. Check the agent ID and retry when the registry is available.`)}}function pe(e,i){if(typeof e=="bigint"&&e>0n)return e;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if(typeof e=="string"&&/^\d+$/.test(e.trim())){let g=BigInt(e.trim());if(g>0n)return g}throw new a(`Provide a positive integer ${i}.`)}function sn(e,i){let g=i!==void 0?pe(i,"agentId"):void 0,u=[];for(let f of e)if(!(!f||typeof f.address!="string")&&f.address.toLowerCase()===c.pool.toLowerCase()&&!(!Array.isArray(f.topics)||f.topics.length===0))try{let R=zt({abi:S,eventName:"Borrowed",data:f.data,topics:f.topics});if(g!==void 0&&R.args.agentId!==g)continue;u.push(R.args.loanId)}catch{continue}return u.length===0?null:u[u.length-1].toString()}function we(e){return{enrolled:!!e[0],isRoot:!!e[1],defaulted:!!e[2],frozen:!!e[3],importedFromV1:!!e[4],enrolledAt:BigInt(e[5]),lastBorrowAt:BigInt(e[6]),lastRepayAt:BigInt(e[7]),sponsor:BigInt(e[8]),delegatedIn:BigInt(e[9]),delegatedOut:BigInt(e[10]),principalOut:BigInt(e[11]),activeLoans:BigInt(e[12]),premiumBps:BigInt(e[13]),premiumCap:BigInt(e[14]),loansRepaid:BigInt(e[15]),volumeRepaid:BigInt(e[16]),feesPaid:BigInt(e[17]),recourseHonored:BigInt(e[18]),childrenDefaulted:BigInt(e[19]),qualifiedRepaid:BigInt(e[20]),dollarSecondsRepaid:BigInt(e[21])}}function Ce(e,i){return{loanId:e,agentId:BigInt(i[0]),sponsorId:BigInt(i[1]),principal:BigInt(i[2]),fee:BigInt(i[3]),sponsorCut:BigInt(i[4]),reserveCut:BigInt(i[5]),premium:BigInt(i[6]),owner:B(String(i[7])),issuedAt:BigInt(i[8]),dueAt:BigInt(i[9]),defaultableAt:BigInt(i[10]),minScoreTerm:BigInt(i[11]),closedAt:BigInt(i[12]),status:Number(i[13])}}async function _e(e,i){let g=e.clientFor($),u=await g.getBlockNumber({cacheTime:0}),f=await g.readContract({address:c.registry,abi:kt,functionName:"balanceOf",args:[i],blockNumber:u});if(f===0n)return[];if(typeof f!="bigint"||f<0n)throw new a("Registry balance is unavailable. Retry or provide an explicit agentId.");let R=[],A=new Set,x=u;for(;;){let H=x>9999999n?x-9999999n:0n,oe=await g.getLogs({address:c.registry,event:Yt("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:i},fromBlock:H,toBlock:x,strict:!0});for(let O of oe){let J=O.args.tokenId;if(O.removed||A.has(J))continue;if(A.add(J),(await De(e,J,u)).toLowerCase()===i.toLowerCase()&&R.push(J),BigInt(R.length)===f)return R.sort((Z,se)=>Z<se?-1:Z>se?1:0)}if(H===0n)throw new a("Owned identities could not all be located. Retry or provide an explicit agentId.");x=H-1n}}async function Re(e,i,g){if(i.agentId!==void 0&&i.agentId!==null&&String(i.agentId).trim()!=="")return pe(i.agentId,"agentId");let u=await _e(e,g);if(u.length===0)throw new a(`Priors borrowing needs an ERC-8004 agent identity with a Priors credit line, and this wallet owns no identity. ${Ze}`);return u[0]}async function ze(e,i,g){let u=e.clientFor($),f=await De(e,i),[R,A]=await Promise.all([u.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[i]}),u.readContract({address:c.pool,abi:S,functionName:"isController",args:[i,g]})]),x=B(R);if(!A)throw new a(`Wallet ${g} is not an on-chain controller for ERC-8004 agent ${i} (ownerOf=${f}, delegateOf=${x}). An off-chain /api/check paymentWallet match alone does not grant CreditPoolV2 control.`);return{owner:f,delegate:x}}function an(e,i){if(!i.enrolled||i.isRoot||i.sponsor===0n)throw new a(`ERC-8004 agent ${e} has no sponsor-backed Priors credit line on CreditPoolV2 yet (enrolled=${i.enrolled}, sponsor=${i.sponsor}, isRoot=${i.isRoot}). For an agent with no Priors record, priors_starter_line opens Priors' 5 USDG treasury line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent), then borrow.`);if(i.defaulted||i.frozen)throw new a(`ERC-8004 agent ${e} is not eligible to borrow on CreditPoolV2 (defaulted=${i.defaulted}, frozen=${i.frozen}).`);let g=i.delegatedIn>i.principalOut?i.delegatedIn-i.principalOut:0n;if(g<=0n)throw new a(`ERC-8004 agent ${e} has 0 USDG remaining credit capacity (delegatedIn=${i.delegatedIn}, principalOut=${i.principalOut}).`);return g}function dn(e){let i=e.borrowReceiptLogs??(Y(e.borrowReceipt)?e.borrowReceipt.logs:void 0);if(!Array.isArray(i))return[];let g=[];for(let u of i)Y(u)&&(typeof u.address!="string"||!Array.isArray(u.topics)||typeof u.data!="string"||g.push({address:u.address,topics:u.topics,data:u.data}));return g}var Je="0x0000000000000000000000000000000000000000",ue=()=>Math.floor(Date.now()/1e3),G=e=>new Date(Number(e)*1e3).toISOString(),V=(e,i)=>e.toLowerCase()===i.toLowerCase();function ye(e){let i=(g,u)=>Array.isArray(e)?e[u]:e[g];return{depositor:B(String(i("depositor",0))),at:BigInt(i("at",1)),amount:BigInt(i("amount",2))}}async function he(e,i,g){let u=e.clientFor($),f=await u.getBlockNumber({cacheTime:0}),[R,A,x,H,oe,O,J,ge,Z,se,Te]=await Promise.all([De(e,i,f),u.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[i],blockNumber:f}),u.readContract({address:L,abi:E,functionName:"firstLined",args:[i],blockNumber:f}),u.readContract({address:L,abi:E,functionName:"agentId",blockNumber:f}),u.readContract({address:L,abi:E,functionName:"rules",blockNumber:f}),u.readContract({address:L,abi:E,functionName:"epochRoom",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"bonds",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"amount",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedAfter",blockNumber:f}),u.readContract({address:c.usdg,abi:Xt,functionName:"balanceOf",args:[g],blockNumber:f})]);return{owner:R,agent:we(A),firstLined:x===!0,root:BigInt(H),firstLineAmount:BigInt(oe[1]),epochRoom:BigInt(O),bond:ye(J),bondAmount:BigInt(ge),releaseAt:BigInt(Z),unusedAfter:BigInt(se),usdg:BigInt(Te)}}function Ct(e,i){return e.enrolled||e.enrolledAt>0n||e.isRoot||e.defaulted||e.importedFromV1||e.loansRepaid>0n||e.sponsor!==0n||i}function Rt(e,i,g,u){let f=R=>`${e.formatAmount(R.toString(),N)} USDG`;if(i.defaulted)return"it defaulted: the pool marks it, and Priors never lends to it again";if(i.isRoot)return"it is a root: it backs other agents' lines";if(i.delegatedIn>0n){let R=i.sponsor===g?`Priors' treasury (root #${g})`:`root #${i.sponsor}`;return`it has a ${f(i.delegatedIn)} line from ${R}${i.activeLoans>0n?` with ${i.activeLoans} loan(s) open`:""}`}return`it has no line now${i.enrolledAt>0n?` (it enrolled at ${G(i.enrolledAt)})`:""}${u?`; Priors' treasury opened a line for it once, and another needs a person at ${Ge}`:""}`}async function Xe(e,i){let g;try{g=await e.http(me,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(i)})}catch(f){if(!(f instanceof tt))throw new a(`Priors' invite bot (${me}) could not be reached: ${e.plainError(f)}`);g=f.response}let u;try{u=JSON.parse(await g.text())}catch{u=void 0}if(!Y(u))throw new a(`Priors' invite bot (${me}) answered HTTP ${g.status} without a readable JSON object.`);return u}var be=e=>Ee(typeof e=="string"&&e?e:"no reason given");function ln(e,i){let g=i instanceof _t?i.walk(x=>x instanceof Ye):void 0,u=g instanceof Ye?g.data:void 0,f=u?.args??[],R=x=>`${e.formatAmount(String(x),N)} USDG`,A=u?.errorName;switch(A){case"EpochCapReached":return`Priors' treasury has no room for a new line this week (wanted ${R(f[0])}, ${R(f[1])} left); the treasury caps new lines each week, so ask again next week.`;case"InsufficientBacking":return`Priors' treasury root lacks free backing for the line now (requested ${R(f[1])}, free ${R(f[2])}); try again later.`;case"InviteExpired":return"the invite expired; call priors_starter_line again for a new one.";case"InviteUsed":return"the invite was already used.";case"NotInvited":return`the invite's signer ${String(f[1])} is not an inviter TreasurySponsorV4 names.`;case"AlreadyLined":return"the agent is already on a treasury line.";case"OwnerDefaulted":return"a default on this wallet's Priors record stops new treasury lines.";case"BadConsent":return"the pool refused the consent (its owner, nonce or signature no longer matches); call priors_starter_line again.";case"ConsentExpired":return"the consent expired; call priors_starter_line again.";case"Paused":return"the Priors pool is paused for new risk; try again later.";case void 0:return e.plainError(i);default:return`${A}(${f.map(String).join(", ")}).`}}var cn=e=>{let i={name:"priors_lend",inputSchema:{type:"object",properties:{assets:{type:"string",pattern:"^[0-9]+$",description:'USDG deposit amount in 6-decimal base units (e.g. "1000000" for 1 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for assets: USDG amount in base units (6 decimals). Example: "1000000" = 1 USDG.'},receiver:{type:"string",description:"Optional share receiver address (must be the signing wallet)."},minShares:{type:"string",pattern:"^[0-9]+$",description:"Minimum pool shares in base units; defaults to simulated minted shares less slippage."},slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points for the simulated share minimum (defaults to 50)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=It(n,"assets","amount","USDG deposit amount");if(r<=0n)throw new a("Deposit amount must be greater than zero.");let p=n.minShares===void 0?void 0:ee(n.minShares),d=e.approval(c.usdg,c.pool,r.toString(),$);if(p===void 0){let l;try{let v=await e.clientFor($).simulateCalls({account:o,calls:[{to:d.to,data:d.data},{to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,0n]})}]}),[I,_]=v.results;if(I?.status!=="success"||_?.status!=="success")throw new a("Approval or deposit simulation failed.");l=Jt({abi:S,functionName:"deposit",data:_.data})}catch(v){throw new a(`Could not simulate Priors deposit shares: ${e.plainError(v)}`)}if(p=ee(it(l.toString(),n.slippageBps??ot)),p===0n)throw new a("The simulated deposit cannot provide a positive minimum share amount.")}let w=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,p]}),value:"0",chainId:$,description:`Deposit ${r} USDG base units into Priors CreditPoolV2 (${c.pool}) for ${t}.`}),b=[d,w],m=await e.preview(b,o),P=`Approve ${e.formatAmount(r.toString(),N)} USDG and deposit into Priors CreditPoolV2 (${c.pool}) for ${t} (minShares=${p}; 7-day MIN_HOLD applies a 0.5% early-exit fee on early withdrawals).`;return{txs:b,summary:ne(e,P,m.changes)}}},g={name:"priors_withdraw",inputSchema:{type:"object",properties:{shares:{type:"string",pattern:"^[0-9]+$",description:"Pool share count in base units to redeem (not USDG amount; omit to redeem full wallet share balance)."},receiver:{type:"string",description:"Optional USDG receiver address (must be the signing wallet)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=e.clientFor($),p=n.shares!==void 0?ee(n.shares):await r.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]});if(p<=0n)throw new a(`Wallet ${o} has no Priors CreditPoolV2 shares to withdraw.`);let[d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[p]}),r.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),r.getBlock()]),m=w>0n&&b.timestamp<w+He,h=m?d*yt/$t:0n,P=d-h,v=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"withdraw",args:[p,t]}),value:"0",chainId:$,description:`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t}.`})],I=await e.preview(v,o),_=e.formatAmount(P.toString(),N),F=e.formatAmount(d.toString(),N),k=e.formatAmount(h.toString(),N),D=m?`inside 7-day MIN_HOLD: ${k} USDG (0.5%) early-exit fee stays in pool, net payout ${_} USDG from ${F} USDG gross`:`outside 7-day MIN_HOLD: no early-exit fee, net payout ${_} USDG`,M=`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t} (${D}).`;return{txs:v,summary:ne(e,M,I.changes)}}},u={name:"priors_borrow",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID with an already-funded Priors credit line."},principal:{type:"string",pattern:"^[0-9]+$",description:'Borrow principal in 6-decimal USDG base units (min "5000000" = 5 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for principal: USDG amount in base units (6 decimals). Example: "5000000" = 5 USDG.'},term:{type:"string",description:'Loan term in seconds (between 86400 and 2592000; defaults to "86400"). The origination fee is pro-rated by term, so a longer term costs more.'},recipient:{type:"string",description:"Optional USDG recipient address (must be the signing wallet)."},maxFee:{type:"string",description:"Optional fee ceiling in USDG base units (6 decimals); must equal the pool quote for this principal and term. Omit to use it. The fee is pro-rated by term, not flat: 1666 for 5 USDG over 1 day."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.recipient!==void 0&&(typeof n.recipient!="string"||n.recipient.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors recipient must be the signing wallet.");let r=await Re(e,n,o);await ze(e,r,o);let p=e.clientFor($),d=await p.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[r]}),w=we(d),b=an(r,w),m=It(n,"principal","amount","USDG borrow principal");if(m<We||m>St)throw new a(`Borrow principal must be between ${We} (5 USDG) and ${St} (500 USDG) base units.`);if(m>b)throw new a(`Borrow principal ${m} exceeds available credit line capacity ${b} USDG base units for agent ${r}.`);let h=n.term!==void 0&&String(n.term).trim()!==""?pe(n.term,"term"):je;if(h<je||h>At)throw new a(`Loan term must be between ${je} (1 day) and ${At} (30 days) seconds.`);let P=await p.readContract({address:c.pool,abi:S,functionName:"quoteFee",args:[r,m,h]}),l=P[0],v=n.maxFee!==void 0?ee(n.maxFee):l;if(v<l)throw new a(`Provided maxFee ${v} is below the origination fee the pool quotes for this term, ${l} USDG base units.`);if(v>l)throw new a(`Provided maxFee ${v} is above the quoted origination fee ${l} USDG base units. Use the quoted fee or omit maxFee.`);let I=m+l,_=m+v,k=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"borrow",args:[r,m,h,t,v]}),value:"0",chainId:$,description:`Borrow ${m} USDG base units on Priors CreditPoolV2 for agent ${r} to ${t} (quoted fee ${l}, expected debt ${I}, maxFee ${v}, debt ceiling ${_}).`})],D=await e.preview(k,o),M=e.formatAmount(m.toString(),N),W=e.formatAmount(l.toString(),N),ae=e.formatAmount(I.toString(),N),j=e.formatAmount(v.toString(),N),$e=e.formatAmount(_.toString(),N),q=P[1]+P[3],K=P[2],de=l-q-K,ie=`Borrow ${M} USDG for ERC-8004 agent ${r} to recipient ${t} on Priors CreditPoolV2 (${c.pool}) for ${h}s: expected origination fee ${W} USDG (${l} base units; pro-rated by term, set when the loan opens, none refunded on early repayment), expected total repayment due ${ae} USDG (${I} base units); fee ceiling ${j} USDG (${v} base units), debt ceiling ${$e} USDG (${_} base units). Fee recipient on repayment: CreditPoolV2 (${c.pool}), allocating the quoted fee to sponsor ${w.sponsor} (${q} base units including premium), reserve (${K} base units), and lenders (${de} base units).`;return{txs:k,summary:ne(e,ie,D.changes)}}},f={name:"priors_repay",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID that owns the active loan."},loanId:{type:"string",description:"Optional explicit per-agent loan ID (otherwise recovered from Borrowed receipt logs or loansOf(agentId))."},borrowReceiptLogs:{type:"array",description:"Optional receipt logs array from the borrow transaction to decode the exact Borrowed(loanId, agentId, ...) event."},maxDue:{type:"string",description:"Optional maximum USDG base units to repay; must equal the exact fixed principal + fee. Omit to use that debt."}}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),p;if(n.loanId!==void 0&&n.loanId!==null&&String(n.loanId).trim()!=="")p=pe(n.loanId,"loanId");else{let k=dn(n);if(k.length>0){let D=sn(k,t);D!==null&&(p=BigInt(D))}}let d;if(p!==void 0){let k=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[p]}),D=Ce(p,k);if(D.agentId!==t)throw new a(`Loan ${p} belongs to agent ${D.agentId}, not agent ${t}. Recover loan IDs from the Borrowed receipt or loansOf(agentId), never global loanCount().`);if(D.status!==1)throw new a(`Loan ${p} for agent ${t} is not active (status=${D.status}).`);d=D}else{let k=await r.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[t]});if(k.length===0)throw new a(`ERC-8004 agent ${t} has no recorded loans on Priors CreditPoolV2.`);let M=(await Promise.all(k.map(async W=>{let ae=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[W]});return Ce(W,ae)}))).filter(W=>W.agentId===t&&W.status===1);if(M.length===0)throw new a(`ERC-8004 agent ${t} has no active loans to repay.`);d=M[M.length-1]}let w=d.principal+d.fee,b=n.maxDue!==void 0?ee(n.maxDue):w;if(b<w)throw new a(`Provided maxDue ${b} is below the exact fixed loan debt ${w} USDG base units (principal ${d.principal} + fixed fee ${d.fee}).`);if(b>w)throw new a(`Provided maxDue ${b} is above the exact fixed loan debt ${w} USDG base units. Use the fixed debt or omit maxDue.`);let m=e.approval(c.usdg,c.pool,w.toString(),$),h=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"repay",args:[d.loanId,t,b]}),value:"0",chainId:$,description:`Repay fixed debt ${w} USDG base units (principal ${d.principal} + fee ${d.fee}) for loan ${d.loanId} (agent ${t}).`}),P=[m,h],l=await e.preview(P,o),v=e.formatAmount(w.toString(),N),I=e.formatAmount(d.principal.toString(),N),_=e.formatAmount(d.fee.toString(),N),F=`Approve and repay ${v} USDG (${w} base units: ${I} USDG principal + ${_} USDG fixed fee) for Priors loan ${d.loanId} (agent ${t}).`;return{txs:P,summary:ne(e,F,l.changes)}}},R={name:"priors_status",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Optional ERC-8004 agent ID to inspect on CreditPoolV2, PriorsLens, and StockVault."},includeApiCheck:{type:"boolean",description:"Optional flag to query https://priors.trade/api/check for supplemental off-chain metadata."}}},async execute(n,s){z(s);let o=B(s),t=e.clientFor($),[r,p,d,w]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]}),t.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),t.getBlock(),t.readContract({address:c.stockVault,abi:Pt,functionName:"assetList"})]),b=r>0n?await t.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[r]}):0n,m=r>0n&&p>0n&&d.timestamp<p+He,h=m?b*yt/$t:0n,P=b-h,l=null;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")l=pe(n.agentId,"agentId");else{let q=await _e(e,o);q.length>0&&(l=q[0])}let v=null,I=!1,_=[],F=null,k=null,D=null,M=null,W=null,ae=null,j=`This wallet owns no ERC-8004 agent identity. ${Ze}`;if(l!==null){let[q,K,de,ie,Ut,Et,Be,Ne,xe]=await Promise.all([t.readContract({address:c.lens,abi:vt,functionName:"score",args:[l]}),t.readContract({address:L,abi:E,functionName:"firstLined",args:[l]}),t.readContract({address:L,abi:E,functionName:"agentId"}),t.readContract({address:L,abi:E,functionName:"rules"}),t.readContract({address:L,abi:E,functionName:"epochRoom"}),t.readContract({address:C,abi:U,functionName:"bonds",args:[l]}),t.readContract({address:C,abi:U,functionName:"amount"}),t.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[l]}),t.readContract({address:C,abi:U,functionName:"releasable",args:[l]})]),[Gt,Vt,Ft,Mt,qt,Ht]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[l]}),t.readContract({address:c.lens,abi:vt,functionName:"available",args:[l]}),t.readContract({address:c.stockVault,abi:Pt,functionName:"borrowRoom",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"isController",args:[l,o]})]),Le=await De(e,l),Wt=B(qt),Ke=Ht,y=we(Gt),Se=y.delegatedIn>y.principalOut?y.delegatedIn-y.principalOut:0n;I=y.enrolled&&!y.isRoot&&!y.defaulted&&!y.frozen&&y.sponsor>0n&&y.delegatedIn>0n,F=Ft.toString(),k=Mt.toString();let jt=await Promise.all(Vt.map(async T=>{let le=await t.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[T]});return Ce(T,le)}));for(let T of jt)if(T.agentId===l&&T.status===1){let le=T.principal+T.fee;_.push({loanId:T.loanId.toString(),agentId:T.agentId.toString(),sponsorId:T.sponsorId.toString(),principal:T.principal.toString(),fee:T.fee.toString(),due:le.toString(),dueAt:T.dueAt.toString(),issuedAt:T.issuedAt.toString(),owner:T.owner,token:te})}v={agentId:l.toString(),owner:Le,delegate:Wt,isAuthorizedController:Ke,enrolled:y.enrolled,isRoot:y.isRoot,defaulted:y.defaulted,frozen:y.frozen,sponsorId:y.sponsor.toString(),delegatedIn:y.delegatedIn.toString(),delegatedOut:y.delegatedOut.toString(),principalOut:y.principalOut.toString(),availableCapacity:Se.toString(),activeLoansCount:y.activeLoans.toString(),loansRepaid:y.loansRepaid.toString(),volumeRepaid:y.volumeRepaid.toString(),feesPaid:y.feesPaid.toString(),importedFromV1:y.importedFromV1,qualifiedRepaid:y.qualifiedRepaid.toString(),dollarSecondsRepaid:y.dollarSecondsRepaid.toString()};let Ae=BigInt(de),Oe=K===!0,Q=ye(Et),re=Q.depositor!==Je,ve=re&&V(Q.depositor,o),Qe=Ct(y,Oe),Ue=V(Le,o);D={onchain:BigInt(q).toString(),scale:"0-1000",source:`CreditLensV2.score(${l}) at ${c.lens}, the score the pool computes on chain`,scoreV2:null},M={open:y.sponsor!==0n&&y.delegatedIn>0n,amount:y.delegatedIn.toString(),drawn:y.principalOut.toString(),available:Se.toString(),sponsorId:y.sponsor.toString(),backer:y.sponsor===0n?null:y.sponsor===Ae?`Priors' treasury v4 (root #${Ae})`:`root #${y.sponsor}`,token:te},W={contract:C,posted:re,depositor:re?Q.depositor:null,postedByWallet:ve,postedAt:re?Q.at.toString():null,amount:(re?Q.amount:BigInt(Be)).toString(),releasable:re&&xe===!0,releaseAt:re?BigInt(Ne).toString():null,rule:"Back to its depositor once the agent holds no line and has no loan open, from 4 days after it was posted (close a line first with priors_close_line); a default forfeits it to Priors' Safe."},ae={eligible:Ue&&!Qe,firstLined:Oe,lineAmount:BigInt(ie[1]).toString(),bondAmount:BigInt(Be).toString(),treasuryRoot:Ae.toString(),treasuryRoomThisWeek:BigInt(Ut).toString(),note:"Not instant: Priors' invite bot decides each invite, and the treasury caps new lines each week."};let fe=_.map(T=>({id:String(T.loanId),dueAt:BigInt(String(T.dueAt))})).sort((T,le)=>T.dueAt<le.dueAt?-1:T.dueAt>le.dueAt?1:0);y.defaulted?j=`Agent #${l} defaulted; Priors never lends to it again${ve?" and its bond is forfeited":""}.`:!Ke&&!Ue?j=`This wallet does not control agent #${l} on CreditPoolV2 (owner ${Le}); act from its owner or delegate.`:fe.length?j=`Repay loan ${fe[0].id} with priors_repay before it is due at ${G(fe[0].dueAt)}${fe.length>1?` (${fe.length} loans open)`:""}.`:I&&Se>=We?j=`Borrow with priors_borrow (5 USDG minimum, up to ${A(Se)}; the fee is pro-rated by term); Priors counts loans held 7 days or more toward the score.`:!Qe&&Ue?j=ve?`Call priors_starter_line again: the ${A(Q.amount)} bond is posted, and it goes on with the invite bot's ownership proof and the invite's redemption${xe===!0?", or priors_release_bond returns the bond":""}.`:`Call priors_starter_line: a refundable ${A(BigInt(Be))} bond, an invite from Priors' invite bot and your pool consent open a ${A(BigInt(ie[1]))} line from Priors' treasury (each transaction and signature is confirmed).`:ve?j=xe===!0?`Release the ${A(Q.amount)} invite bond with priors_release_bond.`:y.delegatedIn>0n?`The line is open with nothing to draw; to take the bond back, close it with priors_close_line, then priors_release_bond from ${G(BigInt(Ne))}.`:`The ${A(Q.amount)} invite bond comes back with priors_release_bond from ${G(BigInt(Ne))}.`:j=`Agent #${l} has a Priors record but no line to draw now; ${Rt(e,y,Ae,Oe)}.`}let $e=null;if(n.includeApiCheck){let q=l!==null?`agent=${l.toString()}`:`address=${o}`,K=await nt(e.http,`${en}?${q}`,{method:"GET"},Y),de=Array.isArray(K.agents)?K.agents.find(ie=>Y(ie)&&String(ie.agentId)===String(l)):void 0;D&&Y(de)&&(D.scoreV2=de.scoreV2??null),$e={...K,grantsPoolControl:!1,controlRule:"Off-chain /api/check identity or paymentWallet match never grants CreditPoolV2 control; on-chain isController(agentId, wallet) must authorize the caller; stale delegates do not qualify."}}return{chainId:$,blockNumber:d.number?.toString()??null,blockTimestamp:d.timestamp.toString(),wallet:o,token:te,contracts:c,lender:{shares:r.toString(),grossAssets:b.toString(),earlyExitFeeAssets:h.toString(),netWithdrawAssets:P.toString(),lastDepositAt:p.toString(),withinMinHoldWindow:m,minHoldSeconds:He.toString()},hasFundedLine:I,agentId:l!==null?l.toString():null,nextStep:j,score:D,line:M,bond:W,starterLine:ae,agent:v,activeLoans:_,lens:{address:c.lens,available:F,caveat:"PriorsLens.available(agentId) is a status capacity hint for already-funded lines; backer hooks may still refuse borrows."},stockVault:{address:c.stockVault,borrowRoom:k,onchainAssetCount:w.length,hostedMcpStockCount:35,extraNonStockAsset:B(tn),zeroCapAssets:nn.map(q=>B(q)),caveat:"Use priors_stock_assets and priors_stock_asset_state for current collateral rules, then priors_stock_open. This summary is an observed asset-count snapshot, not a fixed allowlist; live caps, lending holds and prices control admission."},apiCheck:$e,limitations:["Borrowing and repayment require a sponsor-backed ERC-8004 credit line (enrolled && !isRoot && sponsor != 0) authorized on-chain by isController(agentId, wallet).","Priors line routes are exposed by priors_line_options and priors_capabilities: treasury starter, V5 move/raise, direct sponsor, stock and owner PRIORS backing. Ethos execution uses Priors own owner workflow because its worker supplies no unsigned final transaction.","score.onchain is the pool's on-chain score (CreditLensV2); score.scoreV2 is Priors Score v2 from /api/check, present only with includeApiCheck.","Loan debt is the principal plus the origination fee the pool quotes for the term. The fee is pro-rated by term, not flat (1666 base units for 5 USDG over 1 day, observed live 2026-10-31; priors_borrow shows the exact quote), and is fixed once the loan opens: variable interest is never invented, and early repayment refunds none of it.","Loan IDs are recovered from decoded Borrowed receipts or per-agent loansOf(agentId), never global loanCount().","Historical archive event queries and zero-position StockVault lines on public RPCs remain subject to archive retention and live backer state."]}}},A=n=>`${e.formatAmount(n.toString(),N)} USDG`;function x(n){let s=V(n.bond.depositor,n.owner)&&n.bond.amount>0n?n.bond.amount:n.bondAmount;return`Bond first: ${A(s)} is locked in Priors' InviteBond for at least ${n.unusedAfter} seconds (${Number(n.unusedAfter)/86400} days) after posting${n.releaseAt>0n?`; unusedReleaseAt is ${G(n.releaseAt)}`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments. `}function H(n,s,o){if(!V(o.owner,s))throw new a(`This wallet (${s}) does not own ERC-8004 agent ${n} (its owner is ${o.owner}). The bond, the ownership proof and the pool consent are the owner's. Nothing was signed.`);if(o.root!==Ie)throw new a(`TreasurySponsorV4 (${L}) answers root #${o.root}, not the pinned #${Ie}. Nothing was signed; update Oak.`);if(Ct(o.agent,o.firstLined))throw new a(`Agent #${n} already has a Priors record, so priors_starter_line posts no bond and signs nothing: ${Rt(e,o.agent,o.root,o.firstLined)}; ${o.agent.loansRepaid} loan(s) repaid. The starter line is only for an identity with no record; priors_status shows this one.`)}let oe="stays posted in InviteBond";function O(n){let s=n.agent.delegatedIn>0n?`with a line open it comes back only after priors_close_line (no loan open), then priors_release_bond from ${G(n.releaseAt)} at the earliest`:`while the agent holds no line it comes back with priors_release_bond from ${G(n.releaseAt)} (${Number(n.unusedAfter)/86400} days after it was posted)`;return`The ${A(n.bond.amount>0n?n.bond.amount:n.bondAmount)} bond ${oe} (${C}), posted from this wallet; ${s}, and priors_starter_line never posts a second bond.`}async function J(n,s,o){try{return await o()}catch(t){let r=t instanceof a?t.message:e.plainError(t);if(r.includes(oe)||n===void 0||!/^[0-9]{1,78}$/.test(n))throw t;let p;try{let d=await he(e,BigInt(n),s);p=V(d.bond.depositor,s)?O(d):""}catch{p=`If the bond transactions mined, the invite bond ${oe} (${C}) remains locked until its on-chain release conditions are met; priors_status shows the exact amount and time (its state could not be read just now).`}throw p?new a(`${r} ${p}`):t}}async function ge(n,s,o){let t=lt(await Xe(e,{agentId:n}),{agentId:n,owner:s,now:ue()});if(!t.ok&&t.refused)throw new a(`Priors' invite bot gave no ownership proof to sign for agent #${n}: ${be(t.why)}. Nothing was signed. ${o}`.trim());if(!t.ok)throw new a(`Not signed: the invite bot's answer for agent #${n} is not one Oak signs: ${t.why}. Oak signs only the bot's own start-page text, rebuilt locally for this agent and this wallet. ${o}`.trim());if(t.exp-ue()<120)throw new a(`Not signed: the invite bot's proof for agent #${n} expires in under 2 minutes; call priors_starter_line again for a new one. ${o}`.trim());return t}function Z(n,s,o,t){return{steps:[{kind:"message",message:o.message}],continuation:{stage:"proof",wallet:s,chainId:$,agentId:n,n:o.n,exp:o.exp},summary:`${x(t)}Priors starter line for ERC-8004 agent ${n}, step 2 of 3: sign Priors' invite-bot ownership proof. It is a message signature (EIP-191) only: it sends no transaction and moves no funds. The text is the bot's own form, rebuilt locally for agent #${n} and this wallet, request ${o.n}, expiring ${G(o.exp)}. Oak then sends the signature to ${me}, and the bot decides the invite. ${O(t)}`}}function se(n,s,o){if(n.chainId!==$||typeof n.wallet!="string"||!V(n.wallet,s)||typeof n.agentId!="string"||!/^[1-9][0-9]{0,29}$/.test(n.agentId))throw new a("Priors starter-line continuation does not match this wallet or chain 4663; start priors_starter_line again.");if(o.agentId!==void 0&&String(o.agentId)!==n.agentId)throw new a("Priors starter-line continuation is for another agent; start priors_starter_line again.");return BigInt(n.agentId)}async function Te(n,s){let o;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")o=pe(n.agentId,"agentId");else{let l=await _e(e,s);if(!l.length)throw new a(`Priors' starter line needs an ERC-8004 agent identity, and this wallet owns none. ${Ze}`);o=l[0]}let t=await he(e,o,s);H(o,s,t);let r=o.toString(),p=V(t.bond.depositor,s);if(!p){if(t.usdg<t.bondAmount)throw new a(`This wallet holds ${A(t.usdg)} on Robinhood Chain, and Priors' treasury invite asks a ${A(t.bondAmount)} bond first (InviteBond ${C}), posted from this wallet. Nothing was signed: add USDG, then call priors_starter_line again.`);if(t.epochRoom<t.firstLineAmount)return{summary:`${x(t)}Not submitted. Priors' treasury has ${A(t.epochRoom)} of room left this week and a first line is ${A(t.firstLineAmount)}, so priors_starter_line posted no bond and signed nothing. The treasury caps new lines each week: ask again next week.`,starterLine:{agentId:r,open:!1,reason:"room",epochRoom:t.epochRoom.toString()}};let l=await Xe(e,{check:!0,owner:s.toLowerCase()});if(l.check!==!0)throw new a("Priors' invite bot did not answer its check, so whether an invite is open cannot be told. Nothing was signed.");if(l.ok!==!0)throw new a(`Whether an automatic invite is open could not be told: Priors' invite bot says ${be(l.error)}. Nothing was signed; try again later.`);if(l.open!==!0){let v=typeof l.reason=="string"?l.reason.replace(/[^a-z-]/g,"").slice(0,24):"",I=typeof l.reopensAt=="number"&&Number.isSafeInteger(l.reopensAt)&&l.reopensAt>0?l.reopensAt:null;return{summary:`${x(t)}Not submitted. No automatic invite is open to this wallet right now, so priors_starter_line posted no bond and signed nothing. Priors' invite bot answers: closed, reason ${Ee(v||"none given")}${I?`, reopens ${G(I)}`:""}. ${ct({...l,reason:v})} Priors lists its other ways to a first line (the Ethos lane, a stock line, the owner's $PRIORS stake) at https://priors.trade/skill.md.`,starterLine:{agentId:r,open:!1,reason:v||null,reopensAt:I}}}}let d=await ge(r,s,p?O(t):"");if(p)return Z(r,s,d,t);let w=[e.approval(c.usdg,C,t.bondAmount.toString(),$),e.unsignedTx({to:C,data:X({abi:U,functionName:"deposit",args:[o]}),value:"0",chainId:$,description:`Post the ${t.bondAmount} USDG base-unit Priors invite bond for agent ${r} in InviteBond (${C}).`})],b=await e.preview(w,s),m=t.bond.depositor!==Je?` This deposit replaces the bond ${t.bond.depositor} posted for this agent; InviteBond returns that bond to it in the same transaction.`:"",h=`${x(t)}Priors starter line for ERC-8004 agent ${r}, step 1 of 3: approve exactly ${A(t.bondAmount)} to Priors' InviteBond (${C}) and post it as the agent's refundable invite bond (InviteBond.deposit).${m} Priors' invite bot says an automatic invite is open now and gave the ownership proof to sign next. Step 2 signs that proof (a message, no transaction); step 3 signs your pool consent and redeems the invite (TreasurySponsorV4.firstLine, ${L}) for a ${A(t.firstLineAmount)} line from Priors' treasury (root #${t.root}). The invite is the bot's decision, not a promise: if it refuses, or any later step fails, the bond stays posted and comes back with priors_release_bond after the on-chain lock and release conditions are met. With a line, the bond comes back only once the line is closed with no loan open (priors_close_line, then priors_release_bond); a default forfeits it to Priors' Safe.`;return{steps:w.map(l=>({kind:"tx",tx:l})),continuation:{stage:"bond",wallet:s,chainId:$,agentId:r,n:d.n,exp:d.exp},summary:ne(e,h,b.changes)}}async function Dt(n,s,o){let t=await he(e,n,s);H(n,s,t);let r=n.toString();if(!V(t.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet, so nothing more was signed. Check the deposit transaction, then call priors_starter_line again.`);return typeof o.n=="string"&&Ve.test(o.n)&&typeof o.exp=="number"&&Number.isSafeInteger(o.exp)&&o.exp-ue()>=300?Z(r,s,{n:o.n,exp:o.exp,message:Me(r,o.n,o.exp)},t):Z(r,s,await ge(r,s,O(t)),t)}async function Tt(n,s,o,t){let r=n.toString();if(typeof o.n!="string"||!Ve.test(o.n)||typeof o.exp!="number"||!Number.isSafeInteger(o.exp))throw new a("Invalid Priors starter-line proof continuation; start priors_starter_line again.");if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the invite bot's ownership proof.");if(o.exp<=ue())throw new a(`The invite bot's proof for agent #${r} expired before it reached the bot; nothing was sent to it. Call priors_starter_line again for a fresh proof (the bond is not posted again).`);let p=Me(r,o.n,o.exp);if(!V(await Kt({message:p,signature:t}),s))throw new a("The ownership-proof signature is not this wallet's; nothing was sent to the invite bot.");let d=await he(e,n,s);if(H(n,s,d),!V(d.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet; nothing was sent to the invite bot. Call priors_starter_line again.`);let w=await Xe(e,{n:o.n,signature:t});if(w.ok!==!0)throw new a(`Priors' invite bot gave no invite for agent #${r}: ${be(w.error)}. ${O(d)}`);if(typeof w.code!="string")throw new a(`Priors' invite bot gave no invite for agent #${r}${w.reason?`: ${be(w.reason)}`:""}${typeof w.decided=="string"?` (its decision: ${be(w.decided)})`:""}. ${O(d)}`);let b=qe(w.code,r,ue()+60);if(!b.ok)throw new a(`Priors' invite bot's code for agent #${r} is not one Oak redeems: ${b.why}. Nothing more was signed. ${O(d)}`);let m=e.clientFor($),h=await m.readContract({address:L,abi:E,functionName:"inviteDigest",args:[n,b.expiry]});if(h.toLowerCase()!==dt(n,b.expiry).toLowerCase())throw new a("TreasurySponsorV4's invite digest differs from its pinned EIP-712 domain; nothing more was signed. Update Oak.");let P=await Zt({hash:h,signature:b.signature}),[l,v]=await Promise.all([m.readContract({address:L,abi:E,functionName:"inviters",args:[P]}),m.readContract({address:L,abi:E,functionName:"inviteUsed",args:[h]})]);if(l!==!0)throw new a(`Priors' invite for agent #${r} was signed by ${P}, which TreasurySponsorV4 does not name an inviter, so the treasury would refuse it. Nothing more was signed. ${O(d)}`);if(v===!0)throw new a(`Priors' invite for agent #${r} was already used. Nothing more was signed. ${O(d)}`);let[I,_]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]),F=_.timestamp+BigInt(st),k=Fe({agentId:r,owner:s,nonce:I.toString(),deadline:F.toString()}),D=await m.readContract({address:c.pool,abi:S,functionName:"consentDigest",args:[{agentId:n,sponsorId:d.root,owner:s,maxPremiumBps:0n,nonce:I,deadline:F}]});if(D.toLowerCase()!==at(k).toLowerCase())throw new a(`The pool's consentDigest (${D}) differs from the consent Oak builds for CreditPoolV2 (${c.pool}), so the pool would refuse it. Nothing more was signed. ${O(d)}`);return{steps:[{kind:"typedData",request:k}],continuation:{stage:"consent",wallet:s,chainId:$,agentId:r,invite:w.code,request:k},summary:`Priors starter line for ERC-8004 agent ${r}, step 3 of 3: Priors' invite bot gave an invite (signed by ${P}, an inviter TreasurySponsorV4 names; it expires ${G(b.expiry)}). Sign your pool consent (EIP-712 "Priors Credit" version 2 on CreditPoolV2 ${c.pool}): it lets Priors' treasury (root #${d.root}) back a line for agent #${r} with premium 0, nonce ${I}, valid until ${G(F)}. A transaction redeeming the invite (TreasurySponsorV4.firstLine) follows for your confirmation. ${O(d)}`}}async function Bt(n,s,o,t){let r=n.toString();if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the Priors pool consent.");let p=qe(o.invite,r,ue()+60);if(!p.ok)throw new a(`The invite for agent #${r} is not one Oak redeems now: ${p.why}. Call priors_starter_line again for a new one.`);let d=Y(o.request)&&Y(o.request.message)?o.request.message:void 0;if(!d||typeof d.nonce!="string"||!/^[0-9]{1,78}$/.test(d.nonce)||typeof d.deadline!="string"||!/^[0-9]{1,20}$/.test(d.deadline))throw new a("Invalid Priors starter-line consent continuation; start priors_starter_line again.");let w=Fe({agentId:r,owner:s,nonce:d.nonce,deadline:d.deadline});if(!V(await Qt({...w,signature:t}),s))throw new a("The pool-consent signature is not this wallet's for the consent Oak built; nothing was offered.");let b=await he(e,n,s);H(n,s,b);let m=e.clientFor($),[h,P]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]);if(h.toString()!==d.nonce)throw new a(`Agent #${r}'s consent nonce moved on chain since it was signed; nothing was offered. Call priors_starter_line again.`);if(P.timestamp>=BigInt(d.deadline))throw new a(`The pool consent for agent #${r} expired at ${G(BigInt(d.deadline))}; nothing was offered. Call priors_starter_line again.`);let l={agentId:n,sponsorId:Ie,owner:s,maxPremiumBps:0n,nonce:h,deadline:BigInt(d.deadline)},v=[n,p.expiry,p.signature,l,t];try{await m.simulateContract({address:L,abi:E,functionName:"firstLine",args:v,account:s})}catch(k){throw new a(`TreasurySponsorV4.firstLine for agent #${r} would be refused: ${ln(e,k)} Nothing was offered. ${O(b)}`)}let I=e.unsignedTx({to:L,data:X({abi:E,functionName:"firstLine",args:v}),value:"0",chainId:$,description:`Redeem Priors' invite for agent ${r}: TreasurySponsorV4.firstLine opens a ${b.firstLineAmount} USDG base-unit line from root ${b.root} with the owner's consent.`}),_=await e.preview([I],s),F=`Redeem agent #${r}'s Priors invite: TreasurySponsorV4.firstLine (${L}) opens a ${A(b.firstLineAmount)} line from Priors' treasury (root #${b.root}) with your signed consent. No USDG moves in this transaction. Then priors_status shows the line and priors_borrow draws it (5 USDG minimum; the fee is pro-rated by term; Priors counts loans held 7 days or more toward the score). The ${A(b.bondAmount)} bond stays in InviteBond until the line is closed with no loan open (priors_close_line, then priors_release_bond, from ${G(b.releaseAt)} at the earliest); a default forfeits it.`;return{txs:[I],summary:ne(e,F,_.changes)}}let Nt={name:"priors_starter_line",inputSchema:{description:"Bond first: the launch bond is 5 USDG, locked at least 4 days. The first result reads amount(), unusedAfter() and unusedReleaseAt(agentId) for current terms before any approval. Invites are not guaranteed; the credit score can lag. Release needs no line or open loan; default can forfeit the bond.",type:"object",additionalProperties:!1,properties:{agentId:Pe("ERC-8004 agent ID this wallet owns, with no Priors record yet (default: the first identity this wallet owns)."),continuation:{type:"object",description:"Opaque state from the previous starter-line step; pass it back unchanged. Omit on the first call; never build it by hand."},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Local signature for the confirmed starter-line step, as 0x hex; the bridge supplies it. Never a key."}}},async execute(n,s){z(s);let o=B(s);if(n.continuation===void 0){if(n.signature!==void 0)throw new a("A signature needs its Priors starter-line continuation; start priors_starter_line again.");return J(typeof n.agentId=="string"?n.agentId:void 0,o,()=>Te(n,o))}if(!Y(n.continuation))throw new a("Invalid Priors starter-line continuation; start priors_starter_line again.");let t=n.continuation,r=se(t,o,n),p=d=>J(r.toString(),o,d);if(t.stage==="bond"){if(n.signature!==void 0)throw new a("The bond stage takes no signature; start priors_starter_line again.");return p(()=>Dt(r,o,t))}if(t.stage==="proof")return p(()=>Tt(r,o,t,n.signature));if(t.stage==="consent")return p(()=>Bt(r,o,t,n.signature));throw new a("Unknown Priors starter-line stage; start priors_starter_line again.")}},xt={name:"priors_close_line",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose Priors line to close (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),[p,d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:L,abi:E,functionName:"agentId"})]),m=we(p);if(m.sponsor===0n)throw new a(`Agent #${t} has no Priors line to close (no sponsor on CreditPoolV2).`);if(m.activeLoans>0n)throw new a(`Agent #${t} has ${m.activeLoans} loan(s) open; repay them with priors_repay first. The pool's leave refuses while a loan is open.`);let h=ye(d),P=m.sponsor===BigInt(b),l=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"leave",args:[t]}),value:"0",chainId:$,description:`Close agent ${t}'s Priors line on CreditPoolV2 (leave): the ${m.delegatedIn} USDG base-unit line returns to root ${m.sponsor}.`}),v=await e.preview([l],o),I=V(h.depositor,o)?` Its ${A(h.amount)} invite bond can then come back with priors_release_bond from ${G(w)} (4 days after it was posted).`:"",_=`Close agent #${t}'s Priors line (CreditPoolV2.leave, ${c.pool}): the whole ${A(m.delegatedIn)} line goes back to its backer (${P?`Priors' treasury, root #${b}`:`root #${m.sponsor}`}) and the agent can no longer borrow on it. This does not reopen: ${P?`priors_starter_line opens no second treasury line for an agent with a Priors record; another needs a person at ${Ge}.`:"a new line needs a backer's new consent."}${I} No USDG moves in this transaction.`;return{txs:[l],summary:ne(e,_,v.changes)}}},Lt={name:"priors_release_bond",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose InviteBond bond this wallet posted (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o),r=e.clientFor($),[p,d,w,b,m]=await Promise.all([r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"releasable",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.getBlock()]),h=ye(p);if(h.depositor===Je)throw new a(`Agent #${t} has no bond in Priors' InviteBond (${C}).`);if(!V(h.depositor,o))throw new a(`Agent #${t}'s InviteBond bond was posted by ${h.depositor}, not this wallet, and InviteBond.release pays the depositor. Oak releases only a bond this wallet posted.`);if(d!==!0){let I=we(b),_=I.defaulted?"the agent defaulted, so the bond is forfeited to Priors' Safe (InviteBond.slash)":I.activeLoans>0n?`the agent has ${I.activeLoans} loan(s) open: repay with priors_repay, close the line with priors_close_line, then release`:I.delegatedIn>0n?`the agent still holds a ${A(I.delegatedIn)} line: close it with priors_close_line (no loan may be open), then release`:m.timestamp<w?`it comes back 4 days after it was posted, from ${G(w)}`:"InviteBond does not release it yet";throw new a(`Agent #${t}'s ${A(h.amount)} invite bond cannot be released now: ${_}. Nothing was signed.`)}let P=e.unsignedTx({to:C,data:X({abi:U,functionName:"release",args:[t]}),value:"0",chainId:$,description:`Release agent ${t}'s ${h.amount} USDG base-unit Priors invite bond from InviteBond (${C}) to its depositor ${h.depositor}.`}),l=await e.preview([P],o),v=`Release agent #${t}'s ${A(h.amount)} invite bond from Priors' InviteBond (${C}): InviteBond.release returns it to its depositor, this wallet (${o}).`;return{txs:[P],summary:ne(e,v,l.changes)}}};async function Ot(n){z(n);let s=B(n),o=e.clientFor($),[t,r]=await Promise.all([o.readContract({address:c.pool,abi:S,functionName:"shares",args:[s]}),_e(e,s)]),p=[];if(t>0n){let d=await o.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[t]});p.push({module:"priors",id:`priors:lender:${s.toLowerCase()}`,chainId:$,assets:[{token:te,amount:d.toString()}],description:`Priors CreditPoolV2 lender position (${t} shares = ${e.formatAmount(d.toString(),N)} USDG gross).`})}for(let d of r){let w=await o.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[d]}),b=await Promise.all(w.map(async h=>{let P=await o.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[h]});return Ce(h,P)}));for(let h of b)if(h.agentId===d&&h.status===1){let P=h.principal+h.fee;p.push({module:"priors",id:`priors:loan:${h.loanId.toString()}`,chainId:$,assets:[],liabilities:[{token:te,amount:P.toString()}],economics:{principal:[],debt:[rt({token:te,amount:P.toString(),source:"priors.loan.fixedDue",dueAt:h.dueAt.toString()})],rewards:[],backing:[],coverage:{complete:!0}},description:`Priors CreditPoolV2 active loan ${h.loanId} for agent ${d} (fixed due ${e.formatAmount(P.toString(),N)} USDG = ${h.principal} principal + ${h.fee} fee).`})}let m=ye(await o.readContract({address:C,abi:U,functionName:"bonds",args:[d]}));m.amount>0n&&V(m.depositor,s)&&p.push({module:"priors",id:`priors:bond:${d.toString()}`,chainId:$,assets:[{token:te,amount:m.amount.toString()}],description:`Priors invite bond for agent ${d} in InviteBond (${C}): ${A(m.amount)}, back with priors_release_bond once the agent holds no line and no loan, from 4 days after posting; a default forfeits it.`})}return p.push(...await ft(e,s,r,te)),p}return{tools:[i,g,u,f,R,Nt,xt,Lt],positions:Ot}},un=e=>{let i=cn(e),g=[i,ut(e),pt(e),mt(e),ht(e),bt(e),wt(e),gt()];return{...i,tools:g.flatMap(u=>u.tools)}},Bn=e=>et("priors",[un(e)]);export{en as a,He as b,yt as c,$t as d,We as e,St as f,je as g,At as h,c as i,te as j,sn as k,un as l,Bn as m};
|
|
1
|
+
import{b as bt}from"./DLNA5272.js";import{b as ft}from"./OY5W7ZSL.js";import{b as wt}from"./GDOHHXNH.js";import{c as mt}from"./O4S6XAYV.js";import{b as ht}from"./65OITTDL.js";import{b as gt}from"./VOJULRNU.js";import{c as pt}from"./UBI3HBXD.js";import{h as ut}from"./VXCGMALF.js";import{a as C,b as L,c as Ie,d as me,e as Ge,g as st,h as Ve,j as U,l as E,o as Fe,p as at,q as dt,r as Me,s as lt,t as qe,u as ct}from"./4NBXBKOX.js";import{i as rt}from"./2GXHYI23.js";import{b as ot,o as it}from"./GYPMUYB5.js";import{b as et}from"./SPJCSEKP.js";import{a as z}from"./43LI5NKJ.js";import{a as tt,c as nt}from"./SCG5HWMN.js";import{a as Pe}from"./66F5ZH34.js";import{b as ee}from"./IX3GZMTM.js";import{b as $,e as N,j as ce}from"./TI727O2H.js";import{a}from"./XSD5NL7J.js";import{a as Ee}from"./JXOEJPJ4.js";import{BaseError as _t,ContractFunctionRevertedError as Ye,decodeEventLog as zt,decodeFunctionResult as Jt,encodeFunctionData as X,erc20Abi as Xt,getAddress as B,parseAbi as ke,parseAbiItem as Yt,recoverAddress as Zt,recoverMessageAddress as Kt,recoverTypedDataAddress as Qt}from"viem";var en="https://priors.trade/api/check",He=604800n,yt=50n,$t=10000n,We=5000000n,St=500000000n,je=86400n,At=2592000n,Ze=`Register one with oak_setup {"mode":"register"}, then open Priors' 5 USDG starter line with priors_starter_line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent; each transaction and signature is confirmed).`,tn="0x6982e39521a070a3c40782548bfbed6dc8f566ef",nn=["0xcbb95bbf36099d34da091dc6fa6f49efa257cee3","0x284358abc07f9359f19f4b5b4ac91901be2597ba"],c={pool:B(ce[4663].priors.pool.address),lens:B(ce[4663].priors.lens.address),usdg:B(ce[4663].priors.usdg.address),registry:B(ce[4663].priors.registry.address),stockVault:B(ce[4663].priors.stockVault.address)},te={address:c.usdg,symbol:"USDG",decimals:N,chainId:$},S=ke(["function deposit(uint256 assets, address receiver, uint256 minShares) returns (uint256 minted)","function withdraw(uint256 shares_, address receiver) returns (uint256 out)","function quoteFee(uint256 agentId, uint256 principal, uint64 term) view returns (uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium)","function borrow(uint256 agentId, uint256 amount, uint64 term, address to, uint256 maxFee) returns (uint256 loanId)","function repay(uint256 loanId, uint256 expectedAgentId, uint256 maxDue)","function shares(address lender) view returns (uint256)","function convertToAssets(uint256 shares_) view returns (uint256)","function lastDepositAt(address lender) view returns (uint64)","function isController(uint256 id, address who) view returns (bool)","function delegateOf(uint256 id) view returns (address)","function getAgent(uint256 id) view returns (bool enrolled, bool isRoot, bool defaulted, bool frozen, bool importedFromV1, uint64 enrolledAt, uint64 lastBorrowAt, uint64 lastRepayAt, uint256 sponsor, uint256 delegatedIn, uint256 delegatedOut, uint256 principalOut, uint256 activeLoans, uint256 premiumBps, uint256 premiumCap, uint256 loansRepaid, uint256 volumeRepaid, uint256 feesPaid, uint256 recourseHonored, uint256 childrenDefaulted, uint256 qualifiedRepaid, uint256 dollarSecondsRepaid)","function nonces(uint256 id) view returns (uint256)","function consentDigest((uint256 agentId, uint256 sponsorId, address owner, uint256 maxPremiumBps, uint256 nonce, uint256 deadline) c) view returns (bytes32)","function leave(uint256 agentId)","function loansOf(uint256 id) view returns (uint256[])","function getLoan(uint256 loanId) view returns (uint256 agentId, uint256 sponsorId, uint256 principal, uint256 fee, uint256 sponsorCut, uint256 reserveCut, uint256 premium, address owner, uint64 issuedAt, uint64 dueAt, uint64 defaultableAt, uint64 minScoreTerm, uint64 closedAt, uint8 status)","event Borrowed(uint256 indexed loanId, uint256 indexed agentId, uint256 indexed sponsorId, uint256 principal, uint256 fee, uint64 dueAt, address to)"]),vt=ke(["function available(uint256 agentId) view returns (uint256)","function score(uint256 id) view returns (uint256)"]),kt=ke(["function ownerOf(uint256 agentId) view returns (address)","function balanceOf(address owner) view returns (uint256)","function getAgentWallet(uint256 agentId) view returns (address)"]),Pt=ke(["function borrowRoom(uint256 agentId) view returns (uint256)","function assetList() view returns (address[])","function assets(address token) view returns (address feed, uint32 heartbeat, uint8 tokenDecimals, uint8 feedDecimals, bool enabled, uint16 ltvBps, uint256 lineCap)"]);function Y(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function on(e){return e.chainId===$&&e.address.toLowerCase()===c.usdg.toLowerCase()}function rn(e,i){let g=i.amount.trim(),u=g.startsWith("-"),f=u||g.startsWith("+")?g.slice(1):g,R=e.formatAmount(f,i.token.decimals),A=on(i.token)?"USDG":i.token.address;return`${u?"-":"+"}${R} ${A}`}function ne(e,i,g){if(!g.length)return i;let u=g.map(f=>rn(e,f)).join(", ");return`${i} Preview changes: ${u}.`}function It(e,i,g,u){let f=e[i]===void 0?void 0:ee(e[i]),R=e[g]===void 0?void 0:ee(e[g]);if(f!==void 0)return f;if(R!==void 0)return R;throw new a(`Provide ${u} as an integer string in base units ("${i}" or "${g}").`)}async function De(e,i,g){try{return B(await e.clientFor($).readContract({address:c.registry,abi:kt,functionName:"ownerOf",args:[i],blockNumber:g}))}catch(u){throw u instanceof _t&&u.walk(f=>f instanceof Ye)?new a(`ERC-8004 agent ${i} does not exist in registry ${c.registry}: it has no owner. Check the agent ID.`):new a(`Could not read the owner of ERC-8004 agent ${i} from registry ${c.registry}. Check the agent ID and retry when the registry is available.`)}}function pe(e,i){if(typeof e=="bigint"&&e>0n)return e;if(typeof e=="number"&&Number.isSafeInteger(e)&&e>0)return BigInt(e);if(typeof e=="string"&&/^\d+$/.test(e.trim())){let g=BigInt(e.trim());if(g>0n)return g}throw new a(`Provide a positive integer ${i}.`)}function sn(e,i){let g=i!==void 0?pe(i,"agentId"):void 0,u=[];for(let f of e)if(!(!f||typeof f.address!="string")&&f.address.toLowerCase()===c.pool.toLowerCase()&&!(!Array.isArray(f.topics)||f.topics.length===0))try{let R=zt({abi:S,eventName:"Borrowed",data:f.data,topics:f.topics});if(g!==void 0&&R.args.agentId!==g)continue;u.push(R.args.loanId)}catch{continue}return u.length===0?null:u[u.length-1].toString()}function we(e){return{enrolled:!!e[0],isRoot:!!e[1],defaulted:!!e[2],frozen:!!e[3],importedFromV1:!!e[4],enrolledAt:BigInt(e[5]),lastBorrowAt:BigInt(e[6]),lastRepayAt:BigInt(e[7]),sponsor:BigInt(e[8]),delegatedIn:BigInt(e[9]),delegatedOut:BigInt(e[10]),principalOut:BigInt(e[11]),activeLoans:BigInt(e[12]),premiumBps:BigInt(e[13]),premiumCap:BigInt(e[14]),loansRepaid:BigInt(e[15]),volumeRepaid:BigInt(e[16]),feesPaid:BigInt(e[17]),recourseHonored:BigInt(e[18]),childrenDefaulted:BigInt(e[19]),qualifiedRepaid:BigInt(e[20]),dollarSecondsRepaid:BigInt(e[21])}}function Ce(e,i){return{loanId:e,agentId:BigInt(i[0]),sponsorId:BigInt(i[1]),principal:BigInt(i[2]),fee:BigInt(i[3]),sponsorCut:BigInt(i[4]),reserveCut:BigInt(i[5]),premium:BigInt(i[6]),owner:B(String(i[7])),issuedAt:BigInt(i[8]),dueAt:BigInt(i[9]),defaultableAt:BigInt(i[10]),minScoreTerm:BigInt(i[11]),closedAt:BigInt(i[12]),status:Number(i[13])}}async function _e(e,i){let g=e.clientFor($),u=await g.getBlockNumber({cacheTime:0}),f=await g.readContract({address:c.registry,abi:kt,functionName:"balanceOf",args:[i],blockNumber:u});if(f===0n)return[];if(typeof f!="bigint"||f<0n)throw new a("Registry balance is unavailable. Retry or provide an explicit agentId.");let R=[],A=new Set,x=u;for(;;){let H=x>9999999n?x-9999999n:0n,oe=await g.getLogs({address:c.registry,event:Yt("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:i},fromBlock:H,toBlock:x,strict:!0});for(let O of oe){let J=O.args.tokenId;if(O.removed||A.has(J))continue;if(A.add(J),(await De(e,J,u)).toLowerCase()===i.toLowerCase()&&R.push(J),BigInt(R.length)===f)return R.sort((Z,se)=>Z<se?-1:Z>se?1:0)}if(H===0n)throw new a("Owned identities could not all be located. Retry or provide an explicit agentId.");x=H-1n}}async function Re(e,i,g){if(i.agentId!==void 0&&i.agentId!==null&&String(i.agentId).trim()!=="")return pe(i.agentId,"agentId");let u=await _e(e,g);if(u.length===0)throw new a(`Priors borrowing needs an ERC-8004 agent identity with a Priors credit line, and this wallet owns no identity. ${Ze}`);return u[0]}async function ze(e,i,g){let u=e.clientFor($),f=await De(e,i),[R,A]=await Promise.all([u.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[i]}),u.readContract({address:c.pool,abi:S,functionName:"isController",args:[i,g]})]),x=B(R);if(!A)throw new a(`Wallet ${g} is not an on-chain controller for ERC-8004 agent ${i} (ownerOf=${f}, delegateOf=${x}). An off-chain /api/check paymentWallet match alone does not grant CreditPoolV2 control.`);return{owner:f,delegate:x}}function an(e,i){if(!i.enrolled||i.isRoot||i.sponsor===0n)throw new a(`ERC-8004 agent ${e} has no sponsor-backed Priors credit line on CreditPoolV2 yet (enrolled=${i.enrolled}, sponsor=${i.sponsor}, isRoot=${i.isRoot}). For an agent with no Priors record, priors_starter_line opens Priors' 5 USDG treasury line (a refundable 5 USDG bond, an invite from Priors' invite bot, your pool consent), then borrow.`);if(i.defaulted||i.frozen)throw new a(`ERC-8004 agent ${e} is not eligible to borrow on CreditPoolV2 (defaulted=${i.defaulted}, frozen=${i.frozen}).`);let g=i.delegatedIn>i.principalOut?i.delegatedIn-i.principalOut:0n;if(g<=0n)throw new a(`ERC-8004 agent ${e} has 0 USDG remaining credit capacity (delegatedIn=${i.delegatedIn}, principalOut=${i.principalOut}).`);return g}function dn(e){let i=e.borrowReceiptLogs??(Y(e.borrowReceipt)?e.borrowReceipt.logs:void 0);if(!Array.isArray(i))return[];let g=[];for(let u of i)Y(u)&&(typeof u.address!="string"||!Array.isArray(u.topics)||typeof u.data!="string"||g.push({address:u.address,topics:u.topics,data:u.data}));return g}var Je="0x0000000000000000000000000000000000000000",ue=()=>Math.floor(Date.now()/1e3),G=e=>new Date(Number(e)*1e3).toISOString(),V=(e,i)=>e.toLowerCase()===i.toLowerCase();function ye(e){let i=(g,u)=>Array.isArray(e)?e[u]:e[g];return{depositor:B(String(i("depositor",0))),at:BigInt(i("at",1)),amount:BigInt(i("amount",2))}}async function he(e,i,g){let u=e.clientFor($),f=await u.getBlockNumber({cacheTime:0}),[R,A,x,H,oe,O,J,ge,Z,se,Te]=await Promise.all([De(e,i,f),u.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[i],blockNumber:f}),u.readContract({address:L,abi:E,functionName:"firstLined",args:[i],blockNumber:f}),u.readContract({address:L,abi:E,functionName:"agentId",blockNumber:f}),u.readContract({address:L,abi:E,functionName:"rules",blockNumber:f}),u.readContract({address:L,abi:E,functionName:"epochRoom",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"bonds",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"amount",blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[i],blockNumber:f}),u.readContract({address:C,abi:U,functionName:"unusedAfter",blockNumber:f}),u.readContract({address:c.usdg,abi:Xt,functionName:"balanceOf",args:[g],blockNumber:f})]);return{owner:R,agent:we(A),firstLined:x===!0,root:BigInt(H),firstLineAmount:BigInt(oe[1]),epochRoom:BigInt(O),bond:ye(J),bondAmount:BigInt(ge),releaseAt:BigInt(Z),unusedAfter:BigInt(se),usdg:BigInt(Te)}}function Ct(e,i){return e.enrolled||e.enrolledAt>0n||e.isRoot||e.defaulted||e.importedFromV1||e.loansRepaid>0n||e.sponsor!==0n||i}function Rt(e,i,g,u){let f=R=>`${e.formatAmount(R.toString(),N)} USDG`;if(i.defaulted)return"it defaulted: the pool marks it, and Priors never lends to it again";if(i.isRoot)return"it is a root: it backs other agents' lines";if(i.delegatedIn>0n){let R=i.sponsor===g?`Priors' treasury (root #${g})`:`root #${i.sponsor}`;return`it has a ${f(i.delegatedIn)} line from ${R}${i.activeLoans>0n?` with ${i.activeLoans} loan(s) open`:""}`}return`it has no line now${i.enrolledAt>0n?` (it enrolled at ${G(i.enrolledAt)})`:""}${u?`; Priors' treasury opened a line for it once, and another needs a person at ${Ge}`:""}`}async function Xe(e,i){let g;try{g=await e.http(me,{method:"POST",headers:{"content-type":"application/json",accept:"application/json"},body:JSON.stringify(i)})}catch(f){if(!(f instanceof tt))throw new a(`Priors' invite bot (${me}) could not be reached: ${e.plainError(f)}`);g=f.response}let u;try{u=JSON.parse(await g.text())}catch{u=void 0}if(!Y(u))throw new a(`Priors' invite bot (${me}) answered HTTP ${g.status} without a readable JSON object.`);return u}var be=e=>Ee(typeof e=="string"&&e?e:"no reason given");function ln(e,i){let g=i instanceof _t?i.walk(x=>x instanceof Ye):void 0,u=g instanceof Ye?g.data:void 0,f=u?.args??[],R=x=>`${e.formatAmount(String(x),N)} USDG`,A=u?.errorName;switch(A){case"EpochCapReached":return`Priors' treasury has no room for a new line this week (wanted ${R(f[0])}, ${R(f[1])} left); the treasury caps new lines each week, so ask again next week.`;case"InsufficientBacking":return`Priors' treasury root lacks free backing for the line now (requested ${R(f[1])}, free ${R(f[2])}); try again later.`;case"InviteExpired":return"the invite expired; call priors_starter_line again for a new one.";case"InviteUsed":return"the invite was already used.";case"NotInvited":return`the invite's signer ${String(f[1])} is not an inviter TreasurySponsorV4 names.`;case"AlreadyLined":return"the agent is already on a treasury line.";case"OwnerDefaulted":return"a default on this wallet's Priors record stops new treasury lines.";case"BadConsent":return"the pool refused the consent (its owner, nonce or signature no longer matches); call priors_starter_line again.";case"ConsentExpired":return"the consent expired; call priors_starter_line again.";case"Paused":return"the Priors pool is paused for new risk; try again later.";case void 0:return e.plainError(i);default:return`${A}(${f.map(String).join(", ")}).`}}var cn=e=>{let i={name:"priors_lend",inputSchema:{type:"object",properties:{assets:{type:"string",pattern:"^[0-9]+$",description:'USDG deposit amount in 6-decimal base units (e.g. "1000000" for 1 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for assets: USDG amount in base units (6 decimals). Example: "1000000" = 1 USDG.'},receiver:{type:"string",description:"Optional share receiver address (must be the signing wallet)."},minShares:{type:"string",pattern:"^[0-9]+$",description:"Minimum pool shares in base units; defaults to simulated minted shares less slippage."},slippageBps:{type:"integer",minimum:0,maximum:9999,description:"Slippage in basis points for the simulated share minimum (defaults to 50)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=It(n,"assets","amount","USDG deposit amount");if(r<=0n)throw new a("Deposit amount must be greater than zero.");let p=n.minShares===void 0?void 0:ee(n.minShares),d=e.approval(c.usdg,c.pool,r.toString(),$);if(p===void 0){let l;try{let v=await e.clientFor($).simulateCalls({account:o,calls:[{to:d.to,data:d.data},{to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,0n]})}]}),[I,_]=v.results;if(I?.status!=="success"||_?.status!=="success")throw new a("Approval or deposit simulation failed.");l=Jt({abi:S,functionName:"deposit",data:_.data})}catch(v){throw new a(`Could not simulate Priors deposit shares: ${e.plainError(v)}`)}if(p=ee(it(l.toString(),n.slippageBps??ot)),p===0n)throw new a("The simulated deposit cannot provide a positive minimum share amount.")}let w=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"deposit",args:[r,t,p]}),value:"0",chainId:$,description:`Deposit ${r} USDG base units into Priors CreditPoolV2 (${c.pool}) for ${t}.`}),b=[d,w],m=await e.preview(b,o),P=`Approve ${e.formatAmount(r.toString(),N)} USDG and deposit into Priors CreditPoolV2 (${c.pool}) for ${t} (minShares=${p}; 7-day MIN_HOLD applies a 0.5% early-exit fee on early withdrawals).`;return{txs:b,summary:ne(e,P,m.changes)}}},g={name:"priors_withdraw",inputSchema:{type:"object",properties:{shares:{type:"string",pattern:"^[0-9]+$",description:"Pool share count in base units to redeem (not USDG amount; omit to redeem full wallet share balance)."},receiver:{type:"string",description:"Optional USDG receiver address (must be the signing wallet)."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.receiver!==void 0&&(typeof n.receiver!="string"||n.receiver.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors receiver must be the signing wallet.");let r=e.clientFor($),p=n.shares!==void 0?ee(n.shares):await r.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]});if(p<=0n)throw new a(`Wallet ${o} has no Priors CreditPoolV2 shares to withdraw.`);let[d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[p]}),r.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),r.getBlock()]),m=w>0n&&b.timestamp<w+He,h=m?d*yt/$t:0n,P=d-h,v=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"withdraw",args:[p,t]}),value:"0",chainId:$,description:`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t}.`})],I=await e.preview(v,o),_=e.formatAmount(P.toString(),N),F=e.formatAmount(d.toString(),N),k=e.formatAmount(h.toString(),N),D=m?`inside 7-day MIN_HOLD: ${k} USDG (0.5%) early-exit fee stays in pool, net payout ${_} USDG from ${F} USDG gross`:`outside 7-day MIN_HOLD: no early-exit fee, net payout ${_} USDG`,M=`Withdraw ${p} shares from Priors CreditPoolV2 (${c.pool}) to ${t} (${D}).`;return{txs:v,summary:ne(e,M,I.changes)}}},u={name:"priors_borrow",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID with an already-funded Priors credit line."},principal:{type:"string",pattern:"^[0-9]+$",description:'Borrow principal in 6-decimal USDG base units (min "5000000" = 5 USDG).'},amount:{type:"string",pattern:"^[0-9]+$",description:'Alias for principal: USDG amount in base units (6 decimals). Example: "5000000" = 5 USDG.'},term:{type:"string",description:'Loan term in seconds (between 86400 and 2592000; defaults to "86400"). The origination fee is pro-rated by term, so a longer term costs more.'},recipient:{type:"string",description:"Optional USDG recipient address (must be the signing wallet)."},maxFee:{type:"string",description:"Optional fee ceiling in USDG base units (6 decimals); must equal the pool quote for this principal and term. Omit to use it. The fee is pro-rated by term, not flat: 1666 for 5 USDG over 1 day."}}},async execute(n,s){z(s);let o=B(s),t=o;if(n.recipient!==void 0&&(typeof n.recipient!="string"||n.recipient.trim().toLowerCase()!==o.toLowerCase()))throw new a("Priors recipient must be the signing wallet.");let r=await Re(e,n,o);await ze(e,r,o);let p=e.clientFor($),d=await p.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[r]}),w=we(d),b=an(r,w),m=It(n,"principal","amount","USDG borrow principal");if(m<We||m>St)throw new a(`Borrow principal must be between ${We} (5 USDG) and ${St} (500 USDG) base units.`);if(m>b)throw new a(`Borrow principal ${m} exceeds available credit line capacity ${b} USDG base units for agent ${r}.`);let h=n.term!==void 0&&String(n.term).trim()!==""?pe(n.term,"term"):je;if(h<je||h>At)throw new a(`Loan term must be between ${je} (1 day) and ${At} (30 days) seconds.`);let P=await p.readContract({address:c.pool,abi:S,functionName:"quoteFee",args:[r,m,h]}),l=P[0],v=n.maxFee!==void 0?ee(n.maxFee):l;if(v<l)throw new a(`Provided maxFee ${v} is below the origination fee the pool quotes for this term, ${l} USDG base units.`);if(v>l)throw new a(`Provided maxFee ${v} is above the quoted origination fee ${l} USDG base units. Use the quoted fee or omit maxFee.`);let I=m+l,_=m+v,k=[e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"borrow",args:[r,m,h,t,v]}),value:"0",chainId:$,description:`Borrow ${m} USDG base units on Priors CreditPoolV2 for agent ${r} to ${t} (quoted fee ${l}, expected debt ${I}, maxFee ${v}, debt ceiling ${_}).`})],D=await e.preview(k,o),M=e.formatAmount(m.toString(),N),W=e.formatAmount(l.toString(),N),ae=e.formatAmount(I.toString(),N),j=e.formatAmount(v.toString(),N),$e=e.formatAmount(_.toString(),N),q=P[1]+P[3],K=P[2],de=l-q-K,ie=`Borrow ${M} USDG for ERC-8004 agent ${r} to recipient ${t} on Priors CreditPoolV2 (${c.pool}) for ${h}s: expected origination fee ${W} USDG (${l} base units; pro-rated by term, set when the loan opens, none refunded on early repayment), expected total repayment due ${ae} USDG (${I} base units); fee ceiling ${j} USDG (${v} base units), debt ceiling ${$e} USDG (${_} base units). Fee recipient on repayment: CreditPoolV2 (${c.pool}), allocating the quoted fee to sponsor ${w.sponsor} (${q} base units including premium), reserve (${K} base units), and lenders (${de} base units).`;return{txs:k,summary:ne(e,ie,D.changes)}}},f={name:"priors_repay",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"ERC-8004 agent token ID that owns the active loan."},loanId:{type:"string",description:"Optional explicit per-agent loan ID (otherwise recovered from Borrowed receipt logs or loansOf(agentId))."},borrowReceiptLogs:{type:"array",description:"Optional receipt logs array from the borrow transaction to decode the exact Borrowed(loanId, agentId, ...) event."},maxDue:{type:"string",description:"Optional maximum USDG base units to repay; must equal the exact fixed principal + fee. Omit to use that debt."}}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),p;if(n.loanId!==void 0&&n.loanId!==null&&String(n.loanId).trim()!=="")p=pe(n.loanId,"loanId");else{let k=dn(n);if(k.length>0){let D=sn(k,t);D!==null&&(p=BigInt(D))}}let d;if(p!==void 0){let k=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[p]}),D=Ce(p,k);if(D.agentId!==t)throw new a(`Loan ${p} belongs to agent ${D.agentId}, not agent ${t}. Recover loan IDs from the Borrowed receipt or loansOf(agentId), never global loanCount().`);if(D.status!==1)throw new a(`Loan ${p} for agent ${t} is not active (status=${D.status}).`);d=D}else{let k=await r.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[t]});if(k.length===0)throw new a(`ERC-8004 agent ${t} has no recorded loans on Priors CreditPoolV2.`);let M=(await Promise.all(k.map(async W=>{let ae=await r.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[W]});return Ce(W,ae)}))).filter(W=>W.agentId===t&&W.status===1);if(M.length===0)throw new a(`ERC-8004 agent ${t} has no active loans to repay.`);d=M[M.length-1]}let w=d.principal+d.fee,b=n.maxDue!==void 0?ee(n.maxDue):w;if(b<w)throw new a(`Provided maxDue ${b} is below the exact fixed loan debt ${w} USDG base units (principal ${d.principal} + fixed fee ${d.fee}).`);if(b>w)throw new a(`Provided maxDue ${b} is above the exact fixed loan debt ${w} USDG base units. Use the fixed debt or omit maxDue.`);let m=e.approval(c.usdg,c.pool,w.toString(),$),h=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"repay",args:[d.loanId,t,b]}),value:"0",chainId:$,description:`Repay fixed debt ${w} USDG base units (principal ${d.principal} + fee ${d.fee}) for loan ${d.loanId} (agent ${t}).`}),P=[m,h],l=await e.preview(P,o),v=e.formatAmount(w.toString(),N),I=e.formatAmount(d.principal.toString(),N),_=e.formatAmount(d.fee.toString(),N),F=`Approve and repay ${v} USDG (${w} base units: ${I} USDG principal + ${_} USDG fixed fee) for Priors loan ${d.loanId} (agent ${t}).`;return{txs:P,summary:ne(e,F,l.changes)}}},R={name:"priors_status",inputSchema:{type:"object",properties:{agentId:{type:"string",description:"Optional ERC-8004 agent ID to inspect on CreditPoolV2, PriorsLens, and StockVault."},includeApiCheck:{type:"boolean",description:"Optional flag to query https://priors.trade/api/check for supplemental off-chain metadata."}}},async execute(n,s){z(s);let o=B(s),t=e.clientFor($),[r,p,d,w]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"shares",args:[o]}),t.readContract({address:c.pool,abi:S,functionName:"lastDepositAt",args:[o]}),t.getBlock(),t.readContract({address:c.stockVault,abi:Pt,functionName:"assetList"})]),b=r>0n?await t.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[r]}):0n,m=r>0n&&p>0n&&d.timestamp<p+He,h=m?b*yt/$t:0n,P=b-h,l=null;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")l=pe(n.agentId,"agentId");else{let q=await _e(e,o);q.length>0&&(l=q[0])}let v=null,I=!1,_=[],F=null,k=null,D=null,M=null,W=null,ae=null,j=`This wallet owns no ERC-8004 agent identity. ${Ze}`;if(l!==null){let[q,K,de,ie,Ut,Et,Be,Ne,xe]=await Promise.all([t.readContract({address:c.lens,abi:vt,functionName:"score",args:[l]}),t.readContract({address:L,abi:E,functionName:"firstLined",args:[l]}),t.readContract({address:L,abi:E,functionName:"agentId"}),t.readContract({address:L,abi:E,functionName:"rules"}),t.readContract({address:L,abi:E,functionName:"epochRoom"}),t.readContract({address:C,abi:U,functionName:"bonds",args:[l]}),t.readContract({address:C,abi:U,functionName:"amount"}),t.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[l]}),t.readContract({address:C,abi:U,functionName:"releasable",args:[l]})]),[Gt,Vt,Ft,Mt,qt,Ht]=await Promise.all([t.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[l]}),t.readContract({address:c.lens,abi:vt,functionName:"available",args:[l]}),t.readContract({address:c.stockVault,abi:Pt,functionName:"borrowRoom",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"delegateOf",args:[l]}),t.readContract({address:c.pool,abi:S,functionName:"isController",args:[l,o]})]),Le=await De(e,l),Wt=B(qt),Ke=Ht,y=we(Gt),Se=y.delegatedIn>y.principalOut?y.delegatedIn-y.principalOut:0n;I=y.enrolled&&!y.isRoot&&!y.defaulted&&!y.frozen&&y.sponsor>0n&&y.delegatedIn>0n,F=Ft.toString(),k=Mt.toString();let jt=await Promise.all(Vt.map(async T=>{let le=await t.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[T]});return Ce(T,le)}));for(let T of jt)if(T.agentId===l&&T.status===1){let le=T.principal+T.fee;_.push({loanId:T.loanId.toString(),agentId:T.agentId.toString(),sponsorId:T.sponsorId.toString(),principal:T.principal.toString(),fee:T.fee.toString(),due:le.toString(),dueAt:T.dueAt.toString(),issuedAt:T.issuedAt.toString(),owner:T.owner,token:te})}v={agentId:l.toString(),owner:Le,delegate:Wt,isAuthorizedController:Ke,enrolled:y.enrolled,isRoot:y.isRoot,defaulted:y.defaulted,frozen:y.frozen,sponsorId:y.sponsor.toString(),delegatedIn:y.delegatedIn.toString(),delegatedOut:y.delegatedOut.toString(),principalOut:y.principalOut.toString(),availableCapacity:Se.toString(),activeLoansCount:y.activeLoans.toString(),loansRepaid:y.loansRepaid.toString(),volumeRepaid:y.volumeRepaid.toString(),feesPaid:y.feesPaid.toString(),importedFromV1:y.importedFromV1,qualifiedRepaid:y.qualifiedRepaid.toString(),dollarSecondsRepaid:y.dollarSecondsRepaid.toString()};let Ae=BigInt(de),Oe=K===!0,Q=ye(Et),re=Q.depositor!==Je,ve=re&&V(Q.depositor,o),Qe=Ct(y,Oe),Ue=V(Le,o);D={onchain:BigInt(q).toString(),scale:"0-1000",source:`CreditLensV2.score(${l}) at ${c.lens}, the score the pool computes on chain`,scoreV2:null},M={open:y.sponsor!==0n&&y.delegatedIn>0n,amount:y.delegatedIn.toString(),drawn:y.principalOut.toString(),available:Se.toString(),sponsorId:y.sponsor.toString(),backer:y.sponsor===0n?null:y.sponsor===Ae?`Priors' treasury v4 (root #${Ae})`:`root #${y.sponsor}`,token:te},W={contract:C,posted:re,depositor:re?Q.depositor:null,postedByWallet:ve,postedAt:re?Q.at.toString():null,amount:(re?Q.amount:BigInt(Be)).toString(),releasable:re&&xe===!0,releaseAt:re?BigInt(Ne).toString():null,rule:"Back to its depositor once the agent holds no line and has no loan open, from 4 days after it was posted (close a line first with priors_close_line); a default forfeits it to Priors' Safe."},ae={eligible:Ue&&!Qe,firstLined:Oe,lineAmount:BigInt(ie[1]).toString(),bondAmount:BigInt(Be).toString(),treasuryRoot:Ae.toString(),treasuryRoomThisWeek:BigInt(Ut).toString(),note:"Not instant: Priors' invite bot decides each invite, and the treasury caps new lines each week."};let fe=_.map(T=>({id:String(T.loanId),dueAt:BigInt(String(T.dueAt))})).sort((T,le)=>T.dueAt<le.dueAt?-1:T.dueAt>le.dueAt?1:0);y.defaulted?j=`Agent #${l} defaulted; Priors never lends to it again${ve?" and its bond is forfeited":""}.`:!Ke&&!Ue?j=`This wallet does not control agent #${l} on CreditPoolV2 (owner ${Le}); act from its owner or delegate.`:fe.length?j=`Repay loan ${fe[0].id} with priors_repay before it is due at ${G(fe[0].dueAt)}${fe.length>1?` (${fe.length} loans open)`:""}.`:I&&Se>=We?j=`Borrow with priors_borrow (5 USDG minimum, up to ${A(Se)}; the fee is pro-rated by term); Priors counts loans held 7 days or more toward the score.`:!Qe&&Ue?j=ve?`Call priors_starter_line again: the ${A(Q.amount)} bond is posted, and it goes on with the invite bot's ownership proof and the invite's redemption${xe===!0?", or priors_release_bond returns the bond":""}.`:`Call priors_starter_line: a refundable ${A(BigInt(Be))} bond, an invite from Priors' invite bot and your pool consent open a ${A(BigInt(ie[1]))} line from Priors' treasury (each transaction and signature is confirmed).`:ve?j=xe===!0?`Release the ${A(Q.amount)} invite bond with priors_release_bond.`:y.delegatedIn>0n?`The line is open with nothing to draw; to take the bond back, close it with priors_close_line, then priors_release_bond from ${G(BigInt(Ne))}.`:`The ${A(Q.amount)} invite bond comes back with priors_release_bond from ${G(BigInt(Ne))}.`:j=`Agent #${l} has a Priors record but no line to draw now; ${Rt(e,y,Ae,Oe)}.`}let $e=null;if(n.includeApiCheck){let q=l!==null?`agent=${l.toString()}`:`address=${o}`,K=await nt(e.http,`${en}?${q}`,{method:"GET"},Y),de=Array.isArray(K.agents)?K.agents.find(ie=>Y(ie)&&String(ie.agentId)===String(l)):void 0;D&&Y(de)&&(D.scoreV2=de.scoreV2??null),$e={...K,grantsPoolControl:!1,controlRule:"Off-chain /api/check identity or paymentWallet match never grants CreditPoolV2 control; on-chain isController(agentId, wallet) must authorize the caller; stale delegates do not qualify."}}return{chainId:$,blockNumber:d.number?.toString()??null,blockTimestamp:d.timestamp.toString(),wallet:o,token:te,contracts:c,lender:{shares:r.toString(),grossAssets:b.toString(),earlyExitFeeAssets:h.toString(),netWithdrawAssets:P.toString(),lastDepositAt:p.toString(),withinMinHoldWindow:m,minHoldSeconds:He.toString()},hasFundedLine:I,agentId:l!==null?l.toString():null,nextStep:j,score:D,line:M,bond:W,starterLine:ae,agent:v,activeLoans:_,lens:{address:c.lens,available:F,caveat:"PriorsLens.available(agentId) is a status capacity hint for already-funded lines; backer hooks may still refuse borrows."},stockVault:{address:c.stockVault,borrowRoom:k,onchainAssetCount:w.length,hostedMcpStockCount:35,extraNonStockAsset:B(tn),zeroCapAssets:nn.map(q=>B(q)),caveat:"Use priors_stock_assets and priors_stock_asset_state for current collateral rules, then priors_stock_open. This summary is an observed asset-count snapshot, not a fixed allowlist; live caps, lending holds and prices control admission."},apiCheck:$e,limitations:["Borrowing and repayment require a sponsor-backed ERC-8004 credit line (enrolled && !isRoot && sponsor != 0) authorized on-chain by isController(agentId, wallet).","Priors line routes are exposed by priors_line_options and priors_capabilities: treasury starter, V5 move/raise, direct sponsor, stock and owner PRIORS backing. Ethos execution uses Priors own owner workflow because its worker supplies no unsigned final transaction.","score.onchain is the pool's on-chain score (CreditLensV2); score.scoreV2 is Priors Score v2 from /api/check, present only with includeApiCheck.","Loan debt is the principal plus the origination fee the pool quotes for the term. The fee is pro-rated by term, not flat (1666 base units for 5 USDG over 1 day, observed live 2026-10-31; priors_borrow shows the exact quote), and is fixed once the loan opens: variable interest is never invented, and early repayment refunds none of it.","Loan IDs are recovered from decoded Borrowed receipts or per-agent loansOf(agentId), never global loanCount().","Historical archive event queries and zero-position StockVault lines on public RPCs remain subject to archive retention and live backer state."]}}},A=n=>`${e.formatAmount(n.toString(),N)} USDG`;function x(n){let s=V(n.bond.depositor,n.owner)&&n.bond.amount>0n?n.bond.amount:n.bondAmount;return`Bond first: ${A(s)} is locked in Priors' InviteBond for at least ${n.unusedAfter} seconds (${Number(n.unusedAfter)/86400} days) after posting${n.releaseAt>0n?`; unusedReleaseAt is ${G(n.releaseAt)}`:"; the exact release time is read after posting"}. Release requires no line and no open loan; default can forfeit the bond. Invites are not guaranteed. The credit score can lag qualifying repayments. `}function H(n,s,o){if(!V(o.owner,s))throw new a(`This wallet (${s}) does not own ERC-8004 agent ${n} (its owner is ${o.owner}). The bond, the ownership proof and the pool consent are the owner's. Nothing was signed.`);if(o.root!==Ie)throw new a(`TreasurySponsorV4 (${L}) answers root #${o.root}, not the pinned #${Ie}. Nothing was signed; update Oak.`);if(Ct(o.agent,o.firstLined))throw new a(`Agent #${n} already has a Priors record, so priors_starter_line posts no bond and signs nothing: ${Rt(e,o.agent,o.root,o.firstLined)}; ${o.agent.loansRepaid} loan(s) repaid. The starter line is only for an identity with no record; priors_status shows this one.`)}let oe="stays posted in InviteBond";function O(n){let s=n.agent.delegatedIn>0n?`with a line open it comes back only after priors_close_line (no loan open), then priors_release_bond from ${G(n.releaseAt)} at the earliest`:`while the agent holds no line it comes back with priors_release_bond from ${G(n.releaseAt)} (${Number(n.unusedAfter)/86400} days after it was posted)`;return`The ${A(n.bond.amount>0n?n.bond.amount:n.bondAmount)} bond ${oe} (${C}), posted from this wallet; ${s}, and priors_starter_line never posts a second bond.`}async function J(n,s,o){try{return await o()}catch(t){let r=t instanceof a?t.message:e.plainError(t);if(r.includes(oe)||n===void 0||!/^[0-9]{1,78}$/.test(n))throw t;let p;try{let d=await he(e,BigInt(n),s);p=V(d.bond.depositor,s)?O(d):""}catch{p=`If the bond transactions mined, the invite bond ${oe} (${C}) remains locked until its on-chain release conditions are met; priors_status shows the exact amount and time (its state could not be read just now).`}throw p?new a(`${r} ${p}`):t}}async function ge(n,s,o){let t=lt(await Xe(e,{agentId:n}),{agentId:n,owner:s,now:ue()});if(!t.ok&&t.refused)throw new a(`Priors' invite bot gave no ownership proof to sign for agent #${n}: ${be(t.why)}. Nothing was signed. ${o}`.trim());if(!t.ok)throw new a(`Not signed: the invite bot's answer for agent #${n} is not one Oak signs: ${t.why}. Oak signs only the bot's own start-page text, rebuilt locally for this agent and this wallet. ${o}`.trim());if(t.exp-ue()<120)throw new a(`Not signed: the invite bot's proof for agent #${n} expires in under 2 minutes; call priors_starter_line again for a new one. ${o}`.trim());return t}function Z(n,s,o,t){return{steps:[{kind:"message",message:o.message}],continuation:{stage:"proof",wallet:s,chainId:$,agentId:n,n:o.n,exp:o.exp},summary:`${x(t)}Priors starter line for ERC-8004 agent ${n}, step 2 of 3: sign Priors' invite-bot ownership proof. It is a message signature (EIP-191) only: it sends no transaction and moves no funds. The text is the bot's own form, rebuilt locally for agent #${n} and this wallet, request ${o.n}, expiring ${G(o.exp)}. Oak then sends the signature to ${me}, and the bot decides the invite. ${O(t)}`}}function se(n,s,o){if(n.chainId!==$||typeof n.wallet!="string"||!V(n.wallet,s)||typeof n.agentId!="string"||!/^[1-9][0-9]{0,29}$/.test(n.agentId))throw new a("Priors starter-line continuation does not match this wallet or chain 4663; start priors_starter_line again.");if(o.agentId!==void 0&&String(o.agentId)!==n.agentId)throw new a("Priors starter-line continuation is for another agent; start priors_starter_line again.");return BigInt(n.agentId)}async function Te(n,s){let o;if(n.agentId!==void 0&&n.agentId!==null&&String(n.agentId).trim()!=="")o=pe(n.agentId,"agentId");else{let l=await _e(e,s);if(!l.length)throw new a(`Priors' starter line needs an ERC-8004 agent identity, and this wallet owns none. ${Ze}`);o=l[0]}let t=await he(e,o,s);H(o,s,t);let r=o.toString(),p=V(t.bond.depositor,s);if(!p){if(t.usdg<t.bondAmount)throw new a(`This wallet holds ${A(t.usdg)} on Robinhood Chain, and Priors' treasury invite asks a ${A(t.bondAmount)} bond first (InviteBond ${C}), posted from this wallet. Nothing was signed: add USDG, then call priors_starter_line again.`);if(t.epochRoom<t.firstLineAmount)return{summary:`${x(t)}Not submitted. Priors' treasury has ${A(t.epochRoom)} of room left this week and a first line is ${A(t.firstLineAmount)}, so priors_starter_line posted no bond and signed nothing. The treasury caps new lines each week: ask again next week.`,starterLine:{agentId:r,open:!1,reason:"room",epochRoom:t.epochRoom.toString()}};let l=await Xe(e,{check:!0,owner:s.toLowerCase()});if(l.check!==!0)throw new a("Priors' invite bot did not answer its check, so whether an invite is open cannot be told. Nothing was signed.");if(l.ok!==!0)throw new a(`Whether an automatic invite is open could not be told: Priors' invite bot says ${be(l.error)}. Nothing was signed; try again later.`);if(l.open!==!0){let v=typeof l.reason=="string"?l.reason.replace(/[^a-z-]/g,"").slice(0,24):"",I=typeof l.reopensAt=="number"&&Number.isSafeInteger(l.reopensAt)&&l.reopensAt>0?l.reopensAt:null;return{summary:`${x(t)}Not submitted. No automatic invite is open to this wallet right now, so priors_starter_line posted no bond and signed nothing. Priors' invite bot answers: closed, reason ${Ee(v||"none given")}${I?`, reopens ${G(I)}`:""}. ${ct({...l,reason:v})} Priors lists its other ways to a first line (the Ethos lane, a stock line, the owner's $PRIORS stake) at https://priors.trade/skill.md.`,starterLine:{agentId:r,open:!1,reason:v||null,reopensAt:I}}}}let d=await ge(r,s,p?O(t):"");if(p)return Z(r,s,d,t);let w=[e.approval(c.usdg,C,t.bondAmount.toString(),$),e.unsignedTx({to:C,data:X({abi:U,functionName:"deposit",args:[o]}),value:"0",chainId:$,description:`Post the ${t.bondAmount} USDG base-unit Priors invite bond for agent ${r} in InviteBond (${C}).`})],b=await e.preview(w,s),m=t.bond.depositor!==Je?` This deposit replaces the bond ${t.bond.depositor} posted for this agent; InviteBond returns that bond to it in the same transaction.`:"",h=`${x(t)}Priors starter line for ERC-8004 agent ${r}, step 1 of 3: approve exactly ${A(t.bondAmount)} to Priors' InviteBond (${C}) and post it as the agent's refundable invite bond (InviteBond.deposit).${m} Priors' invite bot says an automatic invite is open now and gave the ownership proof to sign next. Step 2 signs that proof (a message, no transaction); step 3 signs your pool consent and redeems the invite (TreasurySponsorV4.firstLine, ${L}) for a ${A(t.firstLineAmount)} line from Priors' treasury (root #${t.root}). The invite is the bot's decision, not a promise: if it refuses, or any later step fails, the bond stays posted and comes back with priors_release_bond after the on-chain lock and release conditions are met. With a line, the bond comes back only once the line is closed with no loan open (priors_close_line, then priors_release_bond); a default forfeits it to Priors' Safe.`;return{steps:w.map(l=>({kind:"tx",tx:l})),continuation:{stage:"bond",wallet:s,chainId:$,agentId:r,n:d.n,exp:d.exp},summary:ne(e,h,b.changes)}}async function Dt(n,s,o){let t=await he(e,n,s);H(n,s,t);let r=n.toString();if(!V(t.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet, so nothing more was signed. Check the deposit transaction, then call priors_starter_line again.`);return typeof o.n=="string"&&Ve.test(o.n)&&typeof o.exp=="number"&&Number.isSafeInteger(o.exp)&&o.exp-ue()>=300?Z(r,s,{n:o.n,exp:o.exp,message:Me(r,o.n,o.exp)},t):Z(r,s,await ge(r,s,O(t)),t)}async function Tt(n,s,o,t){let r=n.toString();if(typeof o.n!="string"||!Ve.test(o.n)||typeof o.exp!="number"||!Number.isSafeInteger(o.exp))throw new a("Invalid Priors starter-line proof continuation; start priors_starter_line again.");if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the invite bot's ownership proof.");if(o.exp<=ue())throw new a(`The invite bot's proof for agent #${r} expired before it reached the bot; nothing was sent to it. Call priors_starter_line again for a fresh proof (the bond is not posted again).`);let p=Me(r,o.n,o.exp);if(!V(await Kt({message:p,signature:t}),s))throw new a("The ownership-proof signature is not this wallet's; nothing was sent to the invite bot.");let d=await he(e,n,s);if(H(n,s,d),!V(d.bond.depositor,s))throw new a(`The invite bond for agent #${r} is not on chain from this wallet; nothing was sent to the invite bot. Call priors_starter_line again.`);let w=await Xe(e,{n:o.n,signature:t});if(w.ok!==!0)throw new a(`Priors' invite bot gave no invite for agent #${r}: ${be(w.error)}. ${O(d)}`);if(typeof w.code!="string")throw new a(`Priors' invite bot gave no invite for agent #${r}${w.reason?`: ${be(w.reason)}`:""}${typeof w.decided=="string"?` (its decision: ${be(w.decided)})`:""}. ${O(d)}`);let b=qe(w.code,r,ue()+60);if(!b.ok)throw new a(`Priors' invite bot's code for agent #${r} is not one Oak redeems: ${b.why}. Nothing more was signed. ${O(d)}`);let m=e.clientFor($),h=await m.readContract({address:L,abi:E,functionName:"inviteDigest",args:[n,b.expiry]});if(h.toLowerCase()!==dt(n,b.expiry).toLowerCase())throw new a("TreasurySponsorV4's invite digest differs from its pinned EIP-712 domain; nothing more was signed. Update Oak.");let P=await Zt({hash:h,signature:b.signature}),[l,v]=await Promise.all([m.readContract({address:L,abi:E,functionName:"inviters",args:[P]}),m.readContract({address:L,abi:E,functionName:"inviteUsed",args:[h]})]);if(l!==!0)throw new a(`Priors' invite for agent #${r} was signed by ${P}, which TreasurySponsorV4 does not name an inviter, so the treasury would refuse it. Nothing more was signed. ${O(d)}`);if(v===!0)throw new a(`Priors' invite for agent #${r} was already used. Nothing more was signed. ${O(d)}`);let[I,_]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]),F=_.timestamp+BigInt(st),k=Fe({agentId:r,owner:s,nonce:I.toString(),deadline:F.toString()}),D=await m.readContract({address:c.pool,abi:S,functionName:"consentDigest",args:[{agentId:n,sponsorId:d.root,owner:s,maxPremiumBps:0n,nonce:I,deadline:F}]});if(D.toLowerCase()!==at(k).toLowerCase())throw new a(`The pool's consentDigest (${D}) differs from the consent Oak builds for CreditPoolV2 (${c.pool}), so the pool would refuse it. Nothing more was signed. ${O(d)}`);return{steps:[{kind:"typedData",request:k}],continuation:{stage:"consent",wallet:s,chainId:$,agentId:r,invite:w.code,request:k},summary:`Priors starter line for ERC-8004 agent ${r}, step 3 of 3: Priors' invite bot gave an invite (signed by ${P}, an inviter TreasurySponsorV4 names; it expires ${G(b.expiry)}). Sign your pool consent (EIP-712 "Priors Credit" version 2 on CreditPoolV2 ${c.pool}): it lets Priors' treasury (root #${d.root}) back a line for agent #${r} with premium 0, nonce ${I}, valid until ${G(F)}. A transaction redeeming the invite (TreasurySponsorV4.firstLine) follows for your confirmation. ${O(d)}`}}async function Bt(n,s,o,t){let r=n.toString();if(typeof t!="string"||!/^0x[0-9a-fA-F]{130}$/.test(t))throw new a("Provide this wallet's signature of the Priors pool consent.");let p=qe(o.invite,r,ue()+60);if(!p.ok)throw new a(`The invite for agent #${r} is not one Oak redeems now: ${p.why}. Call priors_starter_line again for a new one.`);let d=Y(o.request)&&Y(o.request.message)?o.request.message:void 0;if(!d||typeof d.nonce!="string"||!/^[0-9]{1,78}$/.test(d.nonce)||typeof d.deadline!="string"||!/^[0-9]{1,20}$/.test(d.deadline))throw new a("Invalid Priors starter-line consent continuation; start priors_starter_line again.");let w=Fe({agentId:r,owner:s,nonce:d.nonce,deadline:d.deadline});if(!V(await Qt({...w,signature:t}),s))throw new a("The pool-consent signature is not this wallet's for the consent Oak built; nothing was offered.");let b=await he(e,n,s);H(n,s,b);let m=e.clientFor($),[h,P]=await Promise.all([m.readContract({address:c.pool,abi:S,functionName:"nonces",args:[n]}),m.getBlock()]);if(h.toString()!==d.nonce)throw new a(`Agent #${r}'s consent nonce moved on chain since it was signed; nothing was offered. Call priors_starter_line again.`);if(P.timestamp>=BigInt(d.deadline))throw new a(`The pool consent for agent #${r} expired at ${G(BigInt(d.deadline))}; nothing was offered. Call priors_starter_line again.`);let l={agentId:n,sponsorId:Ie,owner:s,maxPremiumBps:0n,nonce:h,deadline:BigInt(d.deadline)},v=[n,p.expiry,p.signature,l,t];try{await m.simulateContract({address:L,abi:E,functionName:"firstLine",args:v,account:s})}catch(k){throw new a(`TreasurySponsorV4.firstLine for agent #${r} would be refused: ${ln(e,k)} Nothing was offered. ${O(b)}`)}let I=e.unsignedTx({to:L,data:X({abi:E,functionName:"firstLine",args:v}),value:"0",chainId:$,description:`Redeem Priors' invite for agent ${r}: TreasurySponsorV4.firstLine opens a ${b.firstLineAmount} USDG base-unit line from root ${b.root} with the owner's consent.`}),_=await e.preview([I],s),F=`Redeem agent #${r}'s Priors invite: TreasurySponsorV4.firstLine (${L}) opens a ${A(b.firstLineAmount)} line from Priors' treasury (root #${b.root}) with your signed consent. No USDG moves in this transaction. Then priors_status shows the line and priors_borrow draws it (5 USDG minimum; the fee is pro-rated by term; Priors counts loans held 7 days or more toward the score). The ${A(b.bondAmount)} bond stays in InviteBond until the line is closed with no loan open (priors_close_line, then priors_release_bond, from ${G(b.releaseAt)} at the earliest); a default forfeits it.`;return{txs:[I],summary:ne(e,F,_.changes)}}let Nt={name:"priors_starter_line",inputSchema:{description:"Bond first: the launch bond is 5 USDG, locked at least 4 days. The first result reads amount(), unusedAfter() and unusedReleaseAt(agentId) for current terms before any approval. Invites are not guaranteed; the credit score can lag. Release needs no line or open loan; default can forfeit the bond.",type:"object",additionalProperties:!1,properties:{agentId:Pe("ERC-8004 agent ID this wallet owns, with no Priors record yet (default: the first identity this wallet owns)."),continuation:{type:"object",description:"Opaque state from the previous starter-line step; pass it back unchanged. Omit on the first call; never build it by hand."},signature:{type:"string",pattern:"^0x([0-9a-fA-F]{2})+$",description:"Local signature for the confirmed starter-line step, as 0x hex; the bridge supplies it. Never a key."}}},async execute(n,s){z(s);let o=B(s);if(n.continuation===void 0){if(n.signature!==void 0)throw new a("A signature needs its Priors starter-line continuation; start priors_starter_line again.");return J(typeof n.agentId=="string"?n.agentId:void 0,o,()=>Te(n,o))}if(!Y(n.continuation))throw new a("Invalid Priors starter-line continuation; start priors_starter_line again.");let t=n.continuation,r=se(t,o,n),p=d=>J(r.toString(),o,d);if(t.stage==="bond"){if(n.signature!==void 0)throw new a("The bond stage takes no signature; start priors_starter_line again.");return p(()=>Dt(r,o,t))}if(t.stage==="proof")return p(()=>Tt(r,o,t,n.signature));if(t.stage==="consent")return p(()=>Bt(r,o,t,n.signature));throw new a("Unknown Priors starter-line stage; start priors_starter_line again.")}},xt={name:"priors_close_line",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose Priors line to close (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o);await ze(e,t,o);let r=e.clientFor($),[p,d,w,b]=await Promise.all([r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:L,abi:E,functionName:"agentId"})]),m=we(p);if(m.sponsor===0n)throw new a(`Agent #${t} has no Priors line to close (no sponsor on CreditPoolV2).`);if(m.activeLoans>0n)throw new a(`Agent #${t} has ${m.activeLoans} loan(s) open; repay them with priors_repay first. The pool's leave refuses while a loan is open.`);let h=ye(d),P=m.sponsor===BigInt(b),l=e.unsignedTx({to:c.pool,data:X({abi:S,functionName:"leave",args:[t]}),value:"0",chainId:$,description:`Close agent ${t}'s Priors line on CreditPoolV2 (leave): the ${m.delegatedIn} USDG base-unit line returns to root ${m.sponsor}.`}),v=await e.preview([l],o),I=V(h.depositor,o)?` Its ${A(h.amount)} invite bond can then come back with priors_release_bond from ${G(w)} (4 days after it was posted).`:"",_=`Close agent #${t}'s Priors line (CreditPoolV2.leave, ${c.pool}): the whole ${A(m.delegatedIn)} line goes back to its backer (${P?`Priors' treasury, root #${b}`:`root #${m.sponsor}`}) and the agent can no longer borrow on it. This does not reopen: ${P?`priors_starter_line opens no second treasury line for an agent with a Priors record; another needs a person at ${Ge}.`:"a new line needs a backer's new consent."}${I} No USDG moves in this transaction.`;return{txs:[l],summary:ne(e,_,v.changes)}}},Lt={name:"priors_release_bond",inputSchema:{type:"object",properties:{agentId:Pe("ERC-8004 agent ID whose InviteBond bond this wallet posted (default: the first identity this wallet owns).")}},async execute(n,s){z(s);let o=B(s),t=await Re(e,n,o),r=e.clientFor($),[p,d,w,b,m]=await Promise.all([r.readContract({address:C,abi:U,functionName:"bonds",args:[t]}),r.readContract({address:C,abi:U,functionName:"releasable",args:[t]}),r.readContract({address:C,abi:U,functionName:"unusedReleaseAt",args:[t]}),r.readContract({address:c.pool,abi:S,functionName:"getAgent",args:[t]}),r.getBlock()]),h=ye(p);if(h.depositor===Je)throw new a(`Agent #${t} has no bond in Priors' InviteBond (${C}).`);if(!V(h.depositor,o))throw new a(`Agent #${t}'s InviteBond bond was posted by ${h.depositor}, not this wallet, and InviteBond.release pays the depositor. Oak releases only a bond this wallet posted.`);if(d!==!0){let I=we(b),_=I.defaulted?"the agent defaulted, so the bond is forfeited to Priors' Safe (InviteBond.slash)":I.activeLoans>0n?`the agent has ${I.activeLoans} loan(s) open: repay with priors_repay, close the line with priors_close_line, then release`:I.delegatedIn>0n?`the agent still holds a ${A(I.delegatedIn)} line: close it with priors_close_line (no loan may be open), then release`:m.timestamp<w?`it comes back 4 days after it was posted, from ${G(w)}`:"InviteBond does not release it yet";throw new a(`Agent #${t}'s ${A(h.amount)} invite bond cannot be released now: ${_}. Nothing was signed.`)}let P=e.unsignedTx({to:C,data:X({abi:U,functionName:"release",args:[t]}),value:"0",chainId:$,description:`Release agent ${t}'s ${h.amount} USDG base-unit Priors invite bond from InviteBond (${C}) to its depositor ${h.depositor}.`}),l=await e.preview([P],o),v=`Release agent #${t}'s ${A(h.amount)} invite bond from Priors' InviteBond (${C}): InviteBond.release returns it to its depositor, this wallet (${o}).`;return{txs:[P],summary:ne(e,v,l.changes)}}};async function Ot(n){z(n);let s=B(n),o=e.clientFor($),[t,r]=await Promise.all([o.readContract({address:c.pool,abi:S,functionName:"shares",args:[s]}),_e(e,s)]),p=[];if(t>0n){let d=await o.readContract({address:c.pool,abi:S,functionName:"convertToAssets",args:[t]});p.push({module:"priors",id:`priors:lender:${s.toLowerCase()}`,chainId:$,assets:[{token:te,amount:d.toString()}],description:`Priors CreditPoolV2 lender position (${t} shares = ${e.formatAmount(d.toString(),N)} USDG gross).`})}for(let d of r){let w=await o.readContract({address:c.pool,abi:S,functionName:"loansOf",args:[d]}),b=await Promise.all(w.map(async h=>{let P=await o.readContract({address:c.pool,abi:S,functionName:"getLoan",args:[h]});return Ce(h,P)}));for(let h of b)if(h.agentId===d&&h.status===1){let P=h.principal+h.fee;p.push({module:"priors",id:`priors:loan:${h.loanId.toString()}`,chainId:$,assets:[],liabilities:[{token:te,amount:P.toString()}],economics:{principal:[],debt:[rt({token:te,amount:P.toString(),source:"priors.loan.fixedDue",dueAt:h.dueAt.toString()})],rewards:[],backing:[],coverage:{complete:!0}},description:`Priors CreditPoolV2 active loan ${h.loanId} for agent ${d} (fixed due ${e.formatAmount(P.toString(),N)} USDG = ${h.principal} principal + ${h.fee} fee).`})}let m=ye(await o.readContract({address:C,abi:U,functionName:"bonds",args:[d]}));m.amount>0n&&V(m.depositor,s)&&p.push({module:"priors",id:`priors:bond:${d.toString()}`,chainId:$,assets:[{token:te,amount:m.amount.toString()}],description:`Priors invite bond for agent ${d} in InviteBond (${C}): ${A(m.amount)}, back with priors_release_bond once the agent holds no line and no loan, from 4 days after posting; a default forfeits it.`})}return p.push(...await ft(e,s,r,te)),p}return{tools:[i,g,u,f,R,Nt,xt,Lt],positions:Ot}},un=e=>{let i=cn(e),g=[i,ut(e),pt(e),mt(e),ht(e),bt(e),wt(e),gt()];return{...i,tools:g.flatMap(u=>u.tools)}},Bn=e=>et("priors",[un(e)]);export{en as a,He as b,yt as c,$t as d,We as e,St as f,je as g,At as h,c as i,te as j,sn as k,un as l,Bn as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as n,f as a,i as s,j as l,k as u}from"./X24YTJST.js";import{c as e}from"./
|
|
1
|
+
import{d as n,f as a,i as s,j as l,k as u}from"./X24YTJST.js";import{c as e}from"./W7QNSNOH.js";var m="In-kind exits are a separate unsupported flow.";function b(t,i){return n(t,i,e)}function V(t,i,o,r,x,p){return a(t,i,o,r,x,p,e)}function A(t,i,o){return s(t,i,o,e,m)}function P(t){return l(t,e.symbol)}function S(t,i,o,r){u(t,i,o,r,e)}export{b as a,V as b,A as c,P as d,S as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as x}from"./G2LAO23N.js";import{c as O,d as z,e as g}from"./HS5HWBMU.js";import{a as m}from"./66F5ZH34.js";import{c as u,f as B,g as p,i as D}from"./NWNYJ26T.js";import{b as H}from"./TI727O2H.js";import{a as i}from"./XSD5NL7J.js";import{decodeEventLog as W,encodeFunctionData as Q,getAddress as V,hashStruct as Y,isHex as J,parseAbi as Z,zeroAddress as k}from"viem";var ee="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",I=Z(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",ee,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),te={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},ne=V("0x000000000022D473030F116dDEE9F6B43aC78BA3"),P={key:{type:"object",description:"Uniswap v4 PoolKey of the pool to swap in.",properties:{currency0:{...u,description:"Lower-sorted pool token address; the zero address is native ETH, which cannot be the relay input."},currency1:{...u,description:"Higher-sorted pool token address; must be greater than currency0."},fee:{type:"integer",description:x.pips()},tickSpacing:{type:"integer",description:"Pool tick spacing, a positive integer."},hooks:{...u,description:"Address of the pool hook contract."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean",description:"True swaps currency0 for currency1 (input is currency0); false swaps currency1 for currency0."},amountSpecified:{type:"string",pattern:"^-?[0-9]+$",description:'Signed amount in base units: negative = exact input of the input token, positive = exact output of the output token. Example: "-1000000" = 1 USDG in, if USDG (6 decimals) is the input.'},amountBound:{...m(),description:"Slippage bound in base units: minimum output token if amountSpecified is negative, maximum input token if positive. Must be nonzero; read that token's decimals."},sqrtPriceLimitX96:{...m(),description:"Swap price limit as a Q64.96 sqrt price, decimal string."},recipient:{...u,description:x.recipient("account that receives the swap output")},relayer:{...u,description:"Address of the relayer allowed to submit this intent (must be the submitting wallet), or the zero address for an open relay with no fee."},relayerFee:{...m(),description:"Fee paid to the relayer in base units of the fee token (the input token if charged on input, else the output token); read its decimals. Must be 0 for an open relay."},engagement:{...u,description:"Address of the Hookr engagement contract for campaign credit, or the zero address when campaigns is empty."},campaigns:{type:"array",items:m(),maxItems:8,description:"Up to eight campaign IDs (decimal strings) to credit; empty when engagement is the zero address."},nonce:{...m(),description:"Unique Permit2-style intent nonce of the trader, a decimal string; each nonce can execute once."},deadline:{...m(),description:"Intent expiry as a Unix seconds timestamp; the relay fails after this time."}},F={owner:{...u,description:x.recipient("trader who signed the intent and supplies the input funds")},signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$",description:"The trader's Permit2 witness signature over the intent, as 0x-prefixed hex."},intent:{type:"object",description:"The complete trader-signed Hookr swap intent.",properties:P,required:Object.keys(P),additionalProperties:!1}};function N(n){return B(n,"Provide a complete trader-signed Hookr intent.")}function l(n,o=256,e=!1){if(typeof n!="string"||!/^-?\d+$/.test(n)||n.length>79)throw new i("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let t=BigInt(n);if(e?t<=-(1n<<BigInt(o-1))||t>=1n<<BigInt(o-1):t<0n||t>=1n<<BigInt(o))throw new i("Hookr intent integer is outside its ABI range.");return t}function y(n){return D(n,"Provide valid Hookr intent addresses.")}function q(n,o){if(Object.keys(n).some(s=>!Object.hasOwn(F,s)))throw new i("Provide only owner, intent and the trader signature for Hookr relay.");let e=N(n.intent);if(Object.keys(e).some(s=>!Object.hasOwn(P,s)))throw new i("Hookr intent contains an undocumented field.");let t=N(e.key);if(Object.keys(t).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof t.fee!="number"||!Number.isInteger(t.fee)||t.fee<0||t.fee>16777215||typeof t.tickSpacing!="number"||!Number.isInteger(t.tickSpacing)||t.tickSpacing<=0||t.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new i("Provide a valid canonical v4 pool key and direction.");let a={currency0:y(t.currency0),currency1:y(t.currency1),fee:t.fee,tickSpacing:t.tickSpacing,hooks:y(t.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new i("Hookr pool currencies must sort strictly by address.");let r=y(n.owner);if(r===k||p(r,o))throw new i("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new i("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:l(e.amountSpecified,128,!0),amountBound:l(e.amountBound,128),sqrtPriceLimitX96:l(e.sqrtPriceLimitX96,160),recipient:y(e.recipient),relayer:y(e.relayer),relayerFee:l(e.relayerFee),engagement:y(e.engagement),campaigns:e.campaigns.map(s=>l(s)),nonce:l(e.nonce),deadline:l(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new i("Hookr intent input/output amounts and bound must be nonzero.");if([k,g,O].some(s=>p(s,c.recipient)))throw new i("Hookr intent recipient is reserved.");if(c.relayer!==k&&!p(c.relayer,o)||c.relayer===k&&c.relayerFee!==0n)throw new i("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===k!=(c.campaigns.length===0))throw new i("Hookr engagement and campaigns must be supplied together.");let f=c.zeroForOne?a.currency0:a.currency1;if(f===k)throw new i("Hookr Permit2 relay cannot pull native ETH input.");if(typeof n.signature!="string"||!J(n.signature,{strict:!0})||n.signature.length<4||n.signature.length%2!==0||n.signature.length>16386)throw new i("Provide the trader-signed Permit2 witness signature, never a private key.");let S=n.signature,w=Y({data:c,primaryType:"HookrSwapIntent",types:te});return{owner:r,intent:c,signature:S,input:f,intentHash:w}}function U(n,o){let{owner:e,intent:t,signature:a}=q(n,o);return{chainId:H,to:g,value:"0",data:Q({abi:I,functionName:"execute",args:[t,e,a]}),description:`Relay Hookr trader ${e} to recipient ${t.recipient}; relayer fee ${t.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function ue(n,o,e){let t=U(o,e);if(n.length!==1||n[0].chainId!==t.chainId||!p(n[0].to,t.to)||n[0].value!=="0"||!p(n[0].data,t.data))throw new i("Hookr relay calldata differs from the locally requested signed intent.")}function pe(n){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:F,required:Object.keys(F),additionalProperties:!1},execute:async(o,e)=>{let t=q(o,e),{owner:a,intent:r,signature:c,input:f,intentHash:S}=t,w=n.clientFor(H),s=await w.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>r.deadline)throw new i("Hookr signed intent expired or the chain timestamp is unavailable.");let h=(X,G=[])=>w.readContract({address:g,abi:I,functionName:X,args:G,blockNumber:s.number}),[j,d,_,K,$,L]=await Promise.all([h("hashIntent",[r]),h("pullOf",[r]),h("isNonceUsed",[a,r.nonce]),h("router"),h("registry"),h("permit2")]);if(j!==S||_!==!1||K!==O||$!==z||L!==ne)throw new i("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(d)||d.length!==3||typeof d[0]!="string"||!p(d[0],f)||typeof d[1]!="bigint"||typeof d[2]!="boolean")throw new i("Hookr Permit2 pull could not be verified.");let b=d[2],A=r.amountSpecified<0n?-r.amountSpecified:r.amountBound;if(d[1]!==A+(b?r.relayerFee:0n)||r.amountSpecified>0n&&!b&&r.relayerFee>r.amountSpecified)throw new i("Hookr Permit2 pull or output-side fee differs from the signed terms.");let C=await w.simulateContract({address:g,abi:I,functionName:"execute",args:[r,a,c],account:e,blockNumber:s.number}),[R,T]=C.result,E=r.amountSpecified<0n?r.amountBound:r.amountSpecified-(b?0n:r.relayerFee);if(R>A||T<E)throw new i("Hookr relay simulation did not satisfy the signed input/output bounds.");let v=[n.unsignedTx(U(o,e))],M=await n.preview(v,e);return{txs:v,preview:M,summary:v[0].description,intentHash:S,owner:a,recipient:r.recipient,relayer:e,inputToken:f,maximumPull:d[1].toString(),feeToken:b?f:r.zeroForOne?r.key.currency1:r.key.currency0,relayerFee:r.relayerFee.toString(),feeFromInput:b,minimumOutput:E.toString(),simulatedAmountIn:R.toString(),simulatedAmountOut:T.toString(),note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hash of the mined relay transaction: 32 bytes, 0x followed by 64 hex digits."}},required:["transactionHash"],additionalProperties:!1},execute:async o=>{if(Object.keys(o).some(a=>a!=="transactionHash")||typeof o.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o.transactionHash))throw new i("Provide a Hookr relay transactionHash.");let e=await n.clientFor(H).getTransactionReceipt({hash:o.transactionHash});if(e.status!=="success")throw new i("Hookr relay reverted. No fee is proven paid.");let t=e.logs.filter(a=>p(a.address,g)).flatMap(a=>{try{let r=W({abi:I,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...r.args,amountIn:r.args.amountIn.toString(),amountOut:r.args.amountOut.toString(),relayerFee:r.args.relayerFee.toString()}]}catch{return[]}});if(!t.length)throw new i("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:H,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:t,note:"Event evidence at this mined block; check balances and finality."}}}]}export{I as a,q as b,U as c,ue as d,pe as e};
|
|
1
|
+
import{a as x}from"./G2LAO23N.js";import{c as O,d as z,e as g}from"./HIG7JY3J.js";import{a as m}from"./66F5ZH34.js";import{c as u,f as B,g as p,i as D}from"./NWNYJ26T.js";import{b as H}from"./TI727O2H.js";import{a as i}from"./XSD5NL7J.js";import{decodeEventLog as W,encodeFunctionData as Q,getAddress as V,hashStruct as Y,isHex as J,parseAbi as Z,zeroAddress as k}from"viem";var ee="struct HookrSwapIntent { PoolKey key; bool zeroForOne; int128 amountSpecified; uint128 amountBound; uint160 sqrtPriceLimitX96; address recipient; address relayer; uint256 relayerFee; address engagement; uint256[] campaigns; uint256 nonce; uint256 deadline; }",I=Z(["struct PoolKey { address currency0; address currency1; uint24 fee; int24 tickSpacing; address hooks; }",ee,"function execute(HookrSwapIntent intent, address owner, bytes signature) returns (uint256 amountIn, uint256 amountOut)","function hashIntent(HookrSwapIntent intent) pure returns (bytes32)","function pullOf(HookrSwapIntent intent) view returns (address token, uint256 amount, bool feeFromInput)","function isNonceUsed(address owner, uint256 intentNonce) view returns (bool)","function router() view returns (address)","function registry() view returns (address)","function permit2() view returns (address)","event IntentExecuted(bytes32 indexed intentHash,address indexed owner,address indexed relayer,bytes32 poolId,uint256 amountIn,uint256 amountOut,uint256 relayerFee,bool feeFromInput)"]),te={PoolKey:[{name:"currency0",type:"address"},{name:"currency1",type:"address"},{name:"fee",type:"uint24"},{name:"tickSpacing",type:"int24"},{name:"hooks",type:"address"}],HookrSwapIntent:[{name:"key",type:"PoolKey"},{name:"zeroForOne",type:"bool"},{name:"amountSpecified",type:"int128"},{name:"amountBound",type:"uint128"},{name:"sqrtPriceLimitX96",type:"uint160"},{name:"recipient",type:"address"},{name:"relayer",type:"address"},{name:"relayerFee",type:"uint256"},{name:"engagement",type:"address"},{name:"campaigns",type:"uint256[]"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]},ne=V("0x000000000022D473030F116dDEE9F6B43aC78BA3"),P={key:{type:"object",description:"Uniswap v4 PoolKey of the pool to swap in.",properties:{currency0:{...u,description:"Lower-sorted pool token address; the zero address is native ETH, which cannot be the relay input."},currency1:{...u,description:"Higher-sorted pool token address; must be greater than currency0."},fee:{type:"integer",description:x.pips()},tickSpacing:{type:"integer",description:"Pool tick spacing, a positive integer."},hooks:{...u,description:"Address of the pool hook contract."}},required:["currency0","currency1","fee","tickSpacing","hooks"],additionalProperties:!1},zeroForOne:{type:"boolean",description:"True swaps currency0 for currency1 (input is currency0); false swaps currency1 for currency0."},amountSpecified:{type:"string",pattern:"^-?[0-9]+$",description:'Signed amount in base units: negative = exact input of the input token, positive = exact output of the output token. Example: "-1000000" = 1 USDG in, if USDG (6 decimals) is the input.'},amountBound:{...m(),description:"Slippage bound in base units: minimum output token if amountSpecified is negative, maximum input token if positive. Must be nonzero; read that token's decimals."},sqrtPriceLimitX96:{...m(),description:"Swap price limit as a Q64.96 sqrt price, decimal string."},recipient:{...u,description:x.recipient("account that receives the swap output")},relayer:{...u,description:"Address of the relayer allowed to submit this intent (must be the submitting wallet), or the zero address for an open relay with no fee."},relayerFee:{...m(),description:"Fee paid to the relayer in base units of the fee token (the input token if charged on input, else the output token); read its decimals. Must be 0 for an open relay."},engagement:{...u,description:"Address of the Hookr engagement contract for campaign credit, or the zero address when campaigns is empty."},campaigns:{type:"array",items:m(),maxItems:8,description:"Up to eight campaign IDs (decimal strings) to credit; empty when engagement is the zero address."},nonce:{...m(),description:"Unique Permit2-style intent nonce of the trader, a decimal string; each nonce can execute once."},deadline:{...m(),description:"Intent expiry as a Unix seconds timestamp; the relay fails after this time."}},F={owner:{...u,description:x.recipient("trader who signed the intent and supplies the input funds")},signature:{type:"string",pattern:"^0x[0-9a-fA-F]+$",description:"The trader's Permit2 witness signature over the intent, as 0x-prefixed hex."},intent:{type:"object",description:"The complete trader-signed Hookr swap intent.",properties:P,required:Object.keys(P),additionalProperties:!1}};function N(n){return B(n,"Provide a complete trader-signed Hookr intent.")}function l(n,o=256,e=!1){if(typeof n!="string"||!/^-?\d+$/.test(n)||n.length>79)throw new i("Hookr intent amounts, nonce and deadline must be decimal base-unit strings.");let t=BigInt(n);if(e?t<=-(1n<<BigInt(o-1))||t>=1n<<BigInt(o-1):t<0n||t>=1n<<BigInt(o))throw new i("Hookr intent integer is outside its ABI range.");return t}function y(n){return D(n,"Provide valid Hookr intent addresses.")}function q(n,o){if(Object.keys(n).some(s=>!Object.hasOwn(F,s)))throw new i("Provide only owner, intent and the trader signature for Hookr relay.");let e=N(n.intent);if(Object.keys(e).some(s=>!Object.hasOwn(P,s)))throw new i("Hookr intent contains an undocumented field.");let t=N(e.key);if(Object.keys(t).some(s=>!["currency0","currency1","fee","tickSpacing","hooks"].includes(s))||typeof t.fee!="number"||!Number.isInteger(t.fee)||t.fee<0||t.fee>16777215||typeof t.tickSpacing!="number"||!Number.isInteger(t.tickSpacing)||t.tickSpacing<=0||t.tickSpacing>8388607||typeof e.zeroForOne!="boolean")throw new i("Provide a valid canonical v4 pool key and direction.");let a={currency0:y(t.currency0),currency1:y(t.currency1),fee:t.fee,tickSpacing:t.tickSpacing,hooks:y(t.hooks)};if(BigInt(a.currency0)>=BigInt(a.currency1))throw new i("Hookr pool currencies must sort strictly by address.");let r=y(n.owner);if(r===k||p(r,o))throw new i("Hookr relay requires another trader as owner; the relayer funds gas only.");if(!Array.isArray(e.campaigns)||e.campaigns.length>8)throw new i("Provide at most eight Hookr campaign IDs.");let c={key:a,zeroForOne:e.zeroForOne,amountSpecified:l(e.amountSpecified,128,!0),amountBound:l(e.amountBound,128),sqrtPriceLimitX96:l(e.sqrtPriceLimitX96,160),recipient:y(e.recipient),relayer:y(e.relayer),relayerFee:l(e.relayerFee),engagement:y(e.engagement),campaigns:e.campaigns.map(s=>l(s)),nonce:l(e.nonce),deadline:l(e.deadline)};if(c.amountSpecified===0n||c.amountBound===0n)throw new i("Hookr intent input/output amounts and bound must be nonzero.");if([k,g,O].some(s=>p(s,c.recipient)))throw new i("Hookr intent recipient is reserved.");if(c.relayer!==k&&!p(c.relayer,o)||c.relayer===k&&c.relayerFee!==0n)throw new i("Hookr intent names a different relayer or an open relay with a fee.");if(c.engagement===k!=(c.campaigns.length===0))throw new i("Hookr engagement and campaigns must be supplied together.");let f=c.zeroForOne?a.currency0:a.currency1;if(f===k)throw new i("Hookr Permit2 relay cannot pull native ETH input.");if(typeof n.signature!="string"||!J(n.signature,{strict:!0})||n.signature.length<4||n.signature.length%2!==0||n.signature.length>16386)throw new i("Provide the trader-signed Permit2 witness signature, never a private key.");let S=n.signature,w=Y({data:c,primaryType:"HookrSwapIntent",types:te});return{owner:r,intent:c,signature:S,input:f,intentHash:w}}function U(n,o){let{owner:e,intent:t,signature:a}=q(n,o);return{chainId:H,to:g,value:"0",data:Q({abi:I,functionName:"execute",args:[t,e,a]}),description:`Relay Hookr trader ${e} to recipient ${t.recipient}; relayer fee ${t.relayerFee} in pool quote currency. Relayer pays gas; owner supplies Permit2 funds.`}}function ue(n,o,e){let t=U(o,e);if(n.length!==1||n[0].chainId!==t.chainId||!p(n[0].to,t.to)||n[0].value!=="0"||!p(n[0].data,t.data))throw new i("Hookr relay calldata differs from the locally requested signed intent.")}function pe(n){return[{name:"hookr_relay",inputSchema:{type:"object",description:"Preview a trader-signed Permit2 swap for local human-confirmed submission. Relayer pays gas; the trader supplies input. No signature is created by this tool.",properties:F,required:Object.keys(F),additionalProperties:!1},execute:async(o,e)=>{let t=q(o,e),{owner:a,intent:r,signature:c,input:f,intentHash:S}=t,w=n.clientFor(H),s=await w.getBlock();if(typeof s.number!="bigint"||typeof s.timestamp!="bigint"||s.timestamp<=0n||s.timestamp>r.deadline)throw new i("Hookr signed intent expired or the chain timestamp is unavailable.");let h=(X,G=[])=>w.readContract({address:g,abi:I,functionName:X,args:G,blockNumber:s.number}),[j,d,_,K,$,L]=await Promise.all([h("hashIntent",[r]),h("pullOf",[r]),h("isNonceUsed",[a,r.nonce]),h("router"),h("registry"),h("permit2")]);if(j!==S||_!==!1||K!==O||$!==z||L!==ne)throw new i("Hookr intent hash, nonce or forwarder deployment is invalid. Ask the trader for a fresh signed intent.");if(!Array.isArray(d)||d.length!==3||typeof d[0]!="string"||!p(d[0],f)||typeof d[1]!="bigint"||typeof d[2]!="boolean")throw new i("Hookr Permit2 pull could not be verified.");let b=d[2],A=r.amountSpecified<0n?-r.amountSpecified:r.amountBound;if(d[1]!==A+(b?r.relayerFee:0n)||r.amountSpecified>0n&&!b&&r.relayerFee>r.amountSpecified)throw new i("Hookr Permit2 pull or output-side fee differs from the signed terms.");let C=await w.simulateContract({address:g,abi:I,functionName:"execute",args:[r,a,c],account:e,blockNumber:s.number}),[R,T]=C.result,E=r.amountSpecified<0n?r.amountBound:r.amountSpecified-(b?0n:r.relayerFee);if(R>A||T<E)throw new i("Hookr relay simulation did not satisfy the signed input/output bounds.");let v=[n.unsignedTx(U(o,e))],M=await n.preview(v,e);return{txs:v,preview:M,summary:v[0].description,intentHash:S,owner:a,recipient:r.recipient,relayer:e,inputToken:f,maximumPull:d[1].toString(),feeToken:b?f:r.zeroForOne?r.key.currency1:r.key.currency0,relayerFee:r.relayerFee.toString(),feeFromInput:b,minimumOutput:E.toString(),simulatedAmountIn:R.toString(),simulatedAmountOut:T.toString(),note:"Verify IntentExecuted in the receipt and your fee balance after submission."}}},{name:"hookr_relay_receipt",inputSchema:{type:"object",description:"Read the executed intent and fee from a mined Hookr relay receipt.",properties:{transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:"Hash of the mined relay transaction: 32 bytes, 0x followed by 64 hex digits."}},required:["transactionHash"],additionalProperties:!1},execute:async o=>{if(Object.keys(o).some(a=>a!=="transactionHash")||typeof o.transactionHash!="string"||!/^0x[0-9a-fA-F]{64}$/.test(o.transactionHash))throw new i("Provide a Hookr relay transactionHash.");let e=await n.clientFor(H).getTransactionReceipt({hash:o.transactionHash});if(e.status!=="success")throw new i("Hookr relay reverted. No fee is proven paid.");let t=e.logs.filter(a=>p(a.address,g)).flatMap(a=>{try{let r=W({abi:I,eventName:"IntentExecuted",topics:a.topics,data:a.data});return[{...r.args,amountIn:r.args.amountIn.toString(),amountOut:r.args.amountOut.toString(),relayerFee:r.args.relayerFee.toString()}]}catch{return[]}});if(!t.length)throw new i("Receipt contains no verified Hookr IntentExecuted event.");return{chainId:H,transactionHash:e.transactionHash,blockNumber:e.blockNumber.toString(),intents:t,note:"Event evidence at this mined block; check balances and finality."}}}]}export{I as a,q as b,U as c,ue as d,pe as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as o,d as r,e as i}from"./
|
|
1
|
+
import{a,b as o,d as r,e as i}from"./XVOW6UCI.js";import{c as s}from"./VXCGMALF.js";import{b as t}from"./TI727O2H.js";var n=[{feature:"Ethos claim",source:"https://go.priors.trade/start-ethos.js",missing:"Public claim endpoint signs/sends the sponsor transaction remotely. No unsigned final transaction with a local preview/confirmation handoff is published. Use the owner Go Start workflow; Oak offers status and route discovery."},{feature:"x402 pay_url, paid reports, hire payments and pay_gateway",source:"https://github.com/priors-agents/priors/tree/02230282d8888e00794207ed271ee01b4ce30309/packages/x402",missing:"These hand EIP-3009 payment authorization to an external merchant/facilitator. The recipient settles remotely; no Oak-local unsigned transaction handoff is exposed. Oak discovery is supported; external payment-signature validation, recipient/invoice binding and preview semantics require a shared add-on protocol, beyond this module write scope. Gateway source also says its live 402 surface was not measured."},{feature:"Go Google/Privy account, gas sponsorship, recovery and agent001 approvals",source:"https://go.priors.trade/account",missing:"Authenticated smart-account/session and sponsored-operation APIs are not publicly specified as an unsigned plain-wallet contract. Owner uses Priors UI. Underlying pool, stock, savings and backing contracts are supported here."},{feature:"Publish merchant listings, job offers/results, board requests and signed public offers",source:"https://priors.trade/agent",missing:"Hosted MCP supplies discovery and signed board reads. A versioned authenticated mutation/withdrawal contract is not pinned from the inspected public SDK. Existing owner consent plus direct sponsor offer is supported on chain; creating external listings/messages remains an owner workflow."},{feature:"Create the X proof post",source:"https://go.priors.trade/xlink-core.js",missing:"Requires the human account owner to publish on X. Oak can set or clear the canonical proof URL as public ERC-8004 metadata, but does not publish posts or claim metadata alone verifies X ownership."}];function l(){return{tools:[{name:"priors_capabilities",inputSchema:{type:"object",properties:{},additionalProperties:!1},async execute(){return{chainId:t,sourceCommit:"02230282d8888e00794207ed271ee01b4ce30309",reads:[...a],actions:[...r],localOwnerSignatures:[...o],core:[...i],ownerOnly:s.filter(e=>e.owner).map(e=>e.name),blocked:n.map(e=>({...e,status:"BLOCKED"})),integration:"The shared bridge/server diffs must be integrated for open reads, local signing continuations, exact calldata reconstruction, action destinations and human confirmation. New core builders fail closed in older add-ons; a core-only install does not establish end-to-end feature availability.",safety:"Every local action previews its exact unsigned transaction bundle. Approvals equal inputs or explicit finite future budgets; never unlimited. Persistent autopay and bids authorize later third-party execution within the stated budget. Token backing is collateral and provides no promised returns."}}}]}}export{n as a,l as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as pe,c as me}from"./4PLLS6CT.js";import{a as ue}from"./SPJCSEKP.js";import{a as be}from"./43LI5NKJ.js";import{c as le}from"./SCG5HWMN.js";import{a as O}from"./66F5ZH34.js";import{c as Y,d as oe,g as I,i as fe,m as se,n as re}from"./NWNYJ26T.js";import{b as M,j as de,k as ce}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{decodeFunctionData as J,encodeFunctionData as T,erc20Abi as te,getAddress as he,keccak256 as Ce,parseAbi as P}from"viem";var q={chainId:4663,observedAt:"2026-11-04T21:56:26.556Z",block:"106231118",routeBlock:"106231118",sources:["https://rpc.mainnet.chain.robinhood.com","https://raw.githubusercontent.com/beefyfinance/cowcentrated-subgraph/main/abis/beefy/clm/ClmManager.json","https://raw.githubusercontent.com/beefyfinance/beefy-v2/main/src/features/data/apis/beefy/beefy-clm-pool.ts"],markets:{v3:{router:"0xCaf681a66D020601342297493863E78C959E5cb2",quoter:"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",factory:"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA"},cl:{router:"0xC062b870E813fcA720f1e002c234369Ab3aB9415",quoter:"0x03983AB2C057a2eac211ff01738a1e49ff325B49",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3"}},vaults:[{id:"up33-cow-robinhood-cashcat-weth-vault",vault:"0x25012D654bF9107B6E0Af0248656fEf0b718dBd3",manager:"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x020bfC650A365f8BB26819deAAbF3E21291018b4","0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"],strategy:"0xd7F3bCDAfCFf0018953BB6944Db2683Ff2e42b07",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x4E8649Be40aE67EBbcff99C291B92eE03015917b",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-usdg-net-vault",vault:"0x25B418FcFe8543c25AD9d78246839E5Cf3a3b50D",manager:"0x5A725556514222d0cc81501A9294a3135b7C41C4",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168","0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"],strategy:"0x89207bED2935C64d6cb105E9C85E0E2ED99DD8f2",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},{id:"up33-cow-robinhood-weth-stonkbroker-vault",vault:"0x544c7Ef9265dc08d93B5394116E68aE7D9e60730",manager:"0x5794bB61E83397049c40D87BbF3d44AF583A27Ce",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0xe934e36A439C94017B64a3FecE66AF12099aBF50"],strategy:"0x54Bd0805f549708144C811c14DdEeC0714CA5e0c",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-weth-up-vault",vault:"0x56EA4b4AFAFbb87CFD8Fd8a0266a2F86561677b8",manager:"0x36759534741E28Eb052238738963D684bFe719E4",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x57C0E45cB534413D1C20A4240955d6bB250BB4F1"],strategy:"0x8337c691C3afA52ccE418178e52ed472F034Cb8b",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x23D641FeCcD207E8794c593e8240444A0674C4Ba",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-weth-frong-vault",vault:"0x75588e48f7b4Ed9365d78C6cD509f3C7B804Ca47",manager:"0x9818f01EDCcc3d8EB86B859931C3B877cf44A108",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x6245e67affA44a23077f0Ea7f981a8DC743a0c47"],strategy:"0xdB739d906CD5101b65E089a284ec13a3ab21F603",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x9334BbCBE77C0883d704f71Db35CCF636639334c",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-usdg-intc-vault",vault:"0x8353c496114CF66D10545fdc2B4e6dFBafd37e3b",manager:"0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168","0xc72b96e0E48ecd4DC75E1e45396e26300BC39681"],strategy:"0xbaEE86C9D7dE9dc192f17dFA62833B601Dc64D23",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:60,bridge:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},{id:"up33-cow-robinhood-weth-tendies-vault",vault:"0x97DCDc29a3B3e2F556564279f7D09eE40eB74E45",manager:"0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x45242320DBB855EeA8Fd36804C6487E10E97FCF9"],strategy:"0x9a02CaA8a2e63659f8A419a29a3B48baD86d3c7a",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0xD53a623c17A5853838FA140cE5706eA008565dA8",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"}],routes:[{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x020bfC650A365f8BB26819deAAbF3E21291018b4",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c8020bfc650a365f8bb26819deaabf3e21291018b4",pools:["0x4E8649Be40aE67EBbcff99C291B92eE03015917b"]},{from:"0x020bfC650A365f8BB26819deAAbF3E21291018b4",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x020bfc650a365f8bb26819deaabf3e21291018b40000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x4E8649Be40aE67EBbcff99C291B92eE03015917b"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf",kind:"cl",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d1680000c8ca9c78dd337a67f6e0077f65f5e9218719d30edf",pools:["0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673"]},{from:"0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"cl",path:"0xca9c78dd337a67f6e0077f65f5e9218719d30edf0000c85fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0xe934e36A439C94017B64a3FecE66AF12099aBF50",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c8e934e36a439c94017b64a3fece66af12099abf50",pools:["0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c"]},{from:"0xe934e36A439C94017B64a3FecE66AF12099aBF50",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0xe934e36a439c94017b64a3fece66af12099abf500000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x57C0E45cB534413D1C20A4240955d6bB250BB4F1",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c857c0e45cb534413d1c20a4240955d6bb250bb4f1",pools:["0x23D641FeCcD207E8794c593e8240444A0674C4Ba"]},{from:"0x57C0E45cB534413D1C20A4240955d6bB250BB4F1",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x57c0e45cb534413d1c20a4240955d6bb250bb4f10000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x23D641FeCcD207E8794c593e8240444A0674C4Ba"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x6245e67affA44a23077f0Ea7f981a8DC743a0c47",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c86245e67affa44a23077f0ea7f981a8dc743a0c47",pools:["0x9334BbCBE77C0883d704f71Db35CCF636639334c"]},{from:"0x6245e67affA44a23077f0Ea7f981a8DC743a0c47",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x6245e67affa44a23077f0ea7f981a8dc743a0c470000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x9334BbCBE77C0883d704f71Db35CCF636639334c"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",kind:"cl",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d16800003cc72b96e0e48ecd4dc75e1e45396e26300bc39681",pools:["0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67"]},{from:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"cl",path:"0xc72b96e0e48ecd4dc75e1e45396e26300bc3968100003c5fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x45242320DBB855EeA8Fd36804C6487E10E97FCF9",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c845242320dbb855eea8fd36804c6487e10e97fcf9",pools:["0xD53a623c17A5853838FA140cE5706eA008565dA8"]},{from:"0x45242320DBB855EeA8Fd36804C6487E10E97FCF9",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x45242320dbb855eea8fd36804c6487e10e97fcf90000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0xD53a623c17A5853838FA140cE5706eA008565dA8"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"v3",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d1680000640bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"v3",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000645fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"]}],codeHashes:{"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C":"0x6f2a1713cbceba31cc630dddda1ef99cd35086c96005f3c9ea015f9a8e53e613","0xd7F3bCDAfCFf0018953BB6944Db2683Ff2e42b07":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xfD7EE9D17BD6941bF8e612281ec23E857134BB92":"0x9cc155dd143657bba37e6a51fa28e78158e3f47454acdcebedc0512e3803d0fc","0xF5331Dc29A1FDe4b22d7F168661584B057228683":"0x9f1e0f8e488165740c5ab91a3da1bea1a75eeef607ea37b32296ad465971344c","0x4E8649Be40aE67EBbcff99C291B92eE03015917b":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3":"0x4350c8fcdf90361969542249d76c25d6afbd31f10bebf0134bfe21beba1e8f4c","0x5A725556514222d0cc81501A9294a3135b7C41C4":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x89207bED2935C64d6cb105E9C85E0E2ED99DD8f2":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x5794bB61E83397049c40D87BbF3d44AF583A27Ce":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x54Bd0805f549708144C811c14DdEeC0714CA5e0c":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x36759534741E28Eb052238738963D684bFe719E4":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x8337c691C3afA52ccE418178e52ed472F034Cb8b":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x23D641FeCcD207E8794c593e8240444A0674C4Ba":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x9818f01EDCcc3d8EB86B859931C3B877cf44A108":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xdB739d906CD5101b65E089a284ec13a3ab21F603":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x9334BbCBE77C0883d704f71Db35CCF636639334c":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xbaEE86C9D7dE9dc192f17dFA62833B601Dc64D23":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x9a02CaA8a2e63659f8A419a29a3B48baD86d3c7a":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xD53a623c17A5853838FA140cE5706eA008565dA8":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0xCaf681a66D020601342297493863E78C959E5cb2":"0x6f36c378e272c6324c48f045182bcb54bd8ad654cf9ebd42e8893d52c4cb25dc","0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7":"0x3db0868d945e9304c9bc6a8b2181948109ea617647142f3c4083e14393496a28","0x1f7d7550B1b028f7571E69A784071F0205FD2EfA":"0xec72b1abd1f2faee020cfea9c646bd8994f9fb389054f6e574f103a895091739","0xC062b870E813fcA720f1e002c234369Ab3aB9415":"0x11ea7d3599ef56eda32c0ce7ca26e9aae71bec13bfcbd3ad0e83826c1a2defe4","0x03983AB2C057a2eac211ff01738a1e49ff325B49":"0x1ed81396c831d69a6c59384019850c21ac672d24ae83b4b26304a7384e1e4096","0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca":"0x3298b5dd4e6f115074c526a55ad05a36fd73a0034ac22ec6cbaab32cc9c1e8d2","0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73":"0x5706be52f64875fee65a2cec0d80e47a23d8793cbe85d214b48445e2d05f5353","0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3":"0xa2cf7f366f3d8d11e611acecf7916a27308ba041bf1e161bddbd4ecbb9402b6a","0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6":"0xd6f09e63327b36d3c498f8de8768bd3e4336894cd00ddb36aa9e0a1e4a4c911e"},delegates:{"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x4E8649Be40aE67EBbcff99C291B92eE03015917b":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x5A725556514222d0cc81501A9294a3135b7C41C4":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x5794bB61E83397049c40D87BbF3d44AF583A27Ce":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x36759534741E28Eb052238738963D684bFe719E4":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x23D641FeCcD207E8794c593e8240444A0674C4Ba":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x9818f01EDCcc3d8EB86B859931C3B877cf44A108":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x9334BbCBE77C0883d704f71Db35CCF636639334c":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0xD53a623c17A5853838FA140cE5706eA008565dA8":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3"},qualificationHistory:[{observedAt:"2026-10-31",block:"102927065",routeBlock:"102928782",implementation:"0xF5331Dc29A1FDe4b22d7F168661584B057228683",implementationHash:"0x9f1e0f8e488165740c5ab91a3da1bea1a75eeef607ea37b32296ad465971344c"}],blockHash:"0xcb0e2862c6e22ca5854fb9264995749e497eb26f05a3370202db69909b891c47"};var De=q.vaults,we=["beefy_clm_swap","beefy_clm_deposit","beefy_clm_withdraw"],X=P(["function wants() view returns(address,address)","function strategy() view returns(address)","function want() view returns(address)","function implementation() view returns(address)","function pool() view returns(address)","function vault() view returns(address)","function price() view returns(uint256)","function paused() view returns(bool)","function isCalm() view returns(bool)","function actionableAt() view returns(uint256)","function token0() view returns(address)","function token1() view returns(address)","function factory() view returns(address)","function tickSpacing() view returns(int24)","function balances() view returns(uint256,uint256)","function previewDeposit(uint256,uint256) view returns(uint256 shares,uint256 amount0,uint256 amount1,uint256 fee0,uint256 fee1)","function previewWithdraw(uint256) view returns(uint256,uint256)","function deposit(uint256 amount0,uint256 amount1,uint256 minShares)","function withdraw(uint256 shares,uint256 minAmount0,uint256 minAmount1)"]),ie=P(["function exactInput((bytes path,address recipient,uint256 deadline,uint256 amountIn,uint256 amountOutMinimum)) payable returns(uint256)"]),W=P(["function exactInput((bytes path,address recipient,uint256 amountIn,uint256 amountOutMinimum)) payable returns(uint256)","function multicall(uint256 deadline,bytes[] data) payable returns(bytes[])"]),ge=P(["function quoteExactInput(bytes path,uint256 amountIn) returns(uint256,uint160[],uint32[],uint256)"]),Fe={cl:P(["function getPool(address,address,int24) view returns(address)"]),v3:P(["function getPool(address,address,uint24) view returns(address)"])},ye=P(["function deposit() payable"]),Z={vault:{...Y,description:"Address of the Beefy CLM vault contract (from beefy_list)."},chainId:{const:M,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},slippageBps:{type:"integer",minimum:0,maximum:500,description:"Maximum slippage in basis points (50 = 0.5%), 0 to 500. Default 50."}},Be=10n**36n,z=he(de[M].uniswap.WETH.address),ke="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",ve=Object.fromEntries(Object.entries(q.codeHashes).map(([d,r])=>[d.toLowerCase(),r])),Ae=Object.fromEntries(Object.entries(q.delegates).map(([d,r])=>[d.toLowerCase(),r]));function f(d){return fe(d,"Provide a token or vault address.",oe)}function g(d){return se(d,"Invalid Beefy CLM integer.")}function G(d,r=!1){return re(d,"Provide a positive amount that fits uint256.",{notString:"Provide a decimal base-unit integer string.",positive:!r})}function K(d){let r=d??50;if(typeof r!="number"||!Number.isInteger(r)||r<0||r>500)throw new o("Use integer slippageBps from 0 to 500.");return BigInt(r)}function Q(d,r){let m=d*(10000n-r)/10000n;if(m<=0n)throw new o("This CLM amount is too small for a positive output minimum.");return m}function ne(d,r){if(!Array.isArray(d)||d.length!==r)throw new o("Invalid Beefy CLM quote.");return d.map(g)}function Me(d){let r=f(d),m=De.find(b=>I(b.vault,r));if(!m)throw new o("This vault has no qualified Beefy CLM route. Use beefy_withdraw to return existing vault shares to their want; redeem that want through the project app if Oak has no qualified redemption route.");return m}function Se(d,r,m,b,h){if(d<=0n||m<=0n||b<0n||h<0n)throw new o("The CLM price or budget is invalid.");let E=r?d*m/Be:d;if(E===0n)throw new o("The CLM budget is too small at the current pool price.");let e=b*m/Be,t=h>e?h-e:e-h,a=E<t?E:t,s=(E-a)/2n,i=d*(h>e?a+s:s)/E;return[i,d-i]}var Ee=d=>{async function r(e){try{return await e()}catch(t){throw new o(d.plainError(t))}}function m(e,t){if(e.chainId!==void 0&&e.chainId!==M)throw new o("Beefy CLM requires chain 4663.");for(let a of Object.keys(e))if(!["vault","chainId",...t].includes(a))throw new o(`Unsupported Beefy CLM input: ${a}.`);return Me(e.vault)}async function b(e,t){be(t);let a=d.clientFor(M);if(await a.getChainId()!==M)throw new o("The Beefy CLM endpoint must report chain 4663.");let s=g(await a.getBlockNumber()),i=await a.getBlock({blockNumber:s}),n=(B,p,A=[])=>a.readContract({address:f(B),abi:X,functionName:p,args:A,blockNumber:s}),c=new Set;async function l(B){let p=B.toLowerCase();if(c.has(p))return;let A=ve[p];if(!A)throw new o("Unqualified Beefy CLM dependency; no transaction was built.");let D=await a.getCode({address:f(B),blockNumber:s});if(!D||Ce(D)!==A)throw new o("A Beefy CLM contract or delegated implementation no longer matches its pinned code.");c.add(p),Ae[p]&&await l(Ae[p])}await me(a,f(e.vault),s);for(let B of[e.manager,e.strategy,e.beacon,e.implementation,e.pool,e.factory])await l(B);let[F,u,y,x,C,v,w,S,R,ee]=await Promise.all([n(e.vault,"want"),n(e.manager,"wants"),n(e.manager,"strategy"),n(e.beacon,"implementation"),n(e.strategy,"pool"),n(e.strategy,"vault"),n(e.pool,"token0"),n(e.pool,"token1"),n(e.pool,"factory"),n(e.pool,"tickSpacing")]);if(f(F)!==e.manager||!Array.isArray(u)||u.length!==2||u.some((B,p)=>f(B)!==e.wants[p])||f(y)!==e.strategy||f(x)!==e.implementation||f(C)!==e.pool||f(v)!==e.manager||f(w)!==e.wants[0]||f(S)!==e.wants[1]||f(R)!==e.factory||ee!==e.tickSpacing)throw new o("The Beefy CLM want, tokens, strategy, beacon or pool differs from its qualified deployment.");let V=async B=>g(await a.readContract({address:f(B),abi:te,functionName:"balanceOf",args:[t],blockNumber:s}));async function ae(B){let p=f(B),[A,D]=await Promise.all([a.readContract({address:p,abi:te,functionName:"symbol",blockNumber:s}),a.readContract({address:p,abi:te,functionName:"decimals",blockNumber:s})]);if(typeof A!="string"||!A.trim()||!Number.isInteger(D)||D<0||D>255)throw new o("Invalid CLM token metadata.");return{address:p,symbol:A,decimals:D,chainId:M}}async function H(){let p=(await le(d.http,"https://api.beefy.finance/vaults",{},k=>Array.isArray(k)&&k.every($=>$!==null&&typeof $=="object"))).filter(k=>k.chain==="robinhood"&&typeof k.earnContractAddress=="string"&&I(k.earnContractAddress,e.vault)),A=p[0],D=pe(f(e.vault));if(p.length!==1||!A||A.id!==D.id||A.type!=="standard"||f(A.tokenAddress)!==e.manager||A.tokenDecimals!==18)throw new o("The Beefy API and qualified CLM vault disagree.");if(A.status!=="active")throw new o(`Beefy marks this vault ${String(A.status)}; deposits are unavailable. Exit with beefy_withdraw, redeem the returned CLM shares with beefy_clm_withdraw, then swap the received tokens to USDG with beefy_clm_swap.`);let L=f(await n(e.vault,"strategy")),_=await Promise.all([n(L,"paused"),n(e.strategy,"paused")]);if(_.some(k=>typeof k!="boolean"))throw new o("Invalid Beefy strategy pause flag.");if(_.some(Boolean))throw new o("The Beefy strategy is paused; deposits are unavailable. Exit with beefy_withdraw, redeem CLM shares with beefy_clm_withdraw, then convert the tokens to USDG with beefy_clm_swap.");if(await n(e.manager,"isCalm")!==!0)throw new o("The CLM pool is not calm; wait and request a fresh deposit preview.")}async function N(B,p){let A=new Set([...e.wants,f(ce),z]);if(!A.has(B)||!A.has(p)||B===p)throw new o("Use this CLM pair or the USDG/WETH conversion route, with different input and output tokens.");let D=q.routes.find(U=>U.from===B&&U.to===p&&(U.pools[0]===e.pool||U.kind==="v3"));if(!D)throw new o("No qualified direct CLM route for this token pair. Convert through the CLM bridge token in separately mined steps.");let L=q.markets[D.kind];for(let U of[L.router,L.quoter,L.factory,...D.pools])await l(U);let _=D.path;if(_.length!==88||f(_.slice(0,42))!==B||f(`0x${_.slice(-40)}`)!==p)throw new o("Invalid qualified CLM swap path.");let k=Number.parseInt(_.slice(42,48),16),$=await a.readContract({address:f(L.factory),abi:Fe[D.kind],functionName:"getPool",args:[B,p,k],blockNumber:s});if(f($)!==D.pools[0])throw new o("The swap factory no longer selects the qualified CLM pool.");if(f(await n(L.quoter,"factory"))!==L.factory)throw new o("The CLM quoter factory differs from its pin.");return D}async function j(B,p,A){let D=await N(B,p),L=q.markets[D.kind],_=await a.simulateContract({address:f(L.quoter),abi:ge,functionName:"quoteExactInput",args:[D.path,A],account:t,blockNumber:s}),k=g(_.result[0]);if(k===0n)throw new o("No positive quote for this CLM swap.");return{selected:D,market:L,out:k}}return{client:a,blockNumber:s,deadline:i.timestamp+600n,read:n,balance:V,token:ae,code:l,entryAvailable:H,quote:j}}function h(e,t,a,s="0"){return d.unsignedTx({to:f(e),data:t,description:a,value:s,chainId:M})}async function E(e,t,a){let s=await d.preview(e,t);return{txs:e,preview:s,summary:`${a} Re-read actual balances after every mined step. Calls are separate transactions; earlier steps can remain mined if a later step fails. Confirm the local preview. Gas is additional.`}}return{tools:[{name:"beefy_lp",inputSchema:{type:"object",properties:{...Z,amount:{...O(),description:"Optional entry budget in the CLM bridge token base units (USDG or WETH)."}},required:["vault"],additionalProperties:!1},execute:(e,t)=>r(async()=>{let a=m(e,["amount","slippageBps"]),s=K(e.slippageBps),i=await b(a,t),[n,c,l,F,u,y,x,C]=await Promise.all([i.token(a.wants[0]),i.token(a.wants[1]),i.token(a.manager),i.balance(a.wants[0]),i.balance(a.wants[1]),i.balance(a.manager),i.read(a.manager,"balances"),i.read(a.strategy,"price")]),v;if(e.amount!==void 0){await i.entryAvailable();let w=G(e.amount),[S,R]=ne(x,2),ee=Se(w,a.bridge===n.address,g(C),S,R),V=[];for(let[ae,H]of[n,c].entries()){let N=ee[ae],j=N===0n||H.address===a.bridge?N:(await i.quote(f(a.bridge),H.address,N)).out;V.push({token:H,bridgeAmount:N.toString(),expectedAmount:j.toString(),minimumAmount:j===0n?"0":Q(j,s).toString(),swapRequired:N>0n&&H.address!==a.bridge})}v={bridge:await i.token(a.bridge),budget:w.toString(),inputs:V,source:"strategy.price() and CLM balances(); imbalance first, then split remaining value equally. Re-quote after mining swaps."}}return{chainId:M,vault:a.vault,manager:a.manager,bridge:await i.token(a.bridge),constituents:[{token:n,balance:F.toString()},{token:c,balance:u.toString()}],shares:{token:l,amount:y.toString()},entryPlan:v,block:i.blockNumber.toString(),summary:"Convert USDG or ETH to the bridge token with beefy_clm_swap. Use entryPlan to acquire the current deposit ratio, including a one-sided ratio when appropriate. Deposit actual balances with beefy_clm_deposit, then deposit mined CLM shares with beefy_deposit. Exit with beefy_withdraw, beefy_clm_withdraw, then beefy_clm_swap through the bridge token to USDG."}})},{name:"beefy_clm_swap",inputSchema:{type:"object",properties:{...Z,from:{...Y,description:"Address of the token to sell: native ETH placeholder, or a CLM constituent or bridge token (USDG or WETH)."},to:{...Y,description:"Address of the token to receive, different from the input token: a CLM constituent or the bridge token."},amount:O('Amount of the input token in base units of that token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals; "1000000000000000000" = 1 WETH.')},required:["vault","from","to","amount"],additionalProperties:!1},execute:(e,t)=>r(async()=>{let a=m(e,["from","to","amount","slippageBps"]),s=K(e.slippageBps),i=f(e.from),n=f(e.to),c=G(e.amount),l=i.toLowerCase()===ke,F=l?z:i,u=await b(a,t);if((l?await u.client.getBalance({address:t,blockNumber:u.blockNumber}):await u.balance(i))<c)throw new o("Insufficient CLM swap balance; keep ETH for gas.");let y=[];l&&(await u.code(z),y.push(h(z,T({abi:ye,functionName:"deposit"}),"Wrap exactly the requested ETH for the CLM workflow.",c.toString())));let x=c,C=c;if(F!==n){let w=await u.quote(F,n,c);x=w.out,C=Q(x,s),y.push(d.approval(F,f(w.market.router),c.toString(),M));let S={path:w.selected.path,recipient:t,amountIn:c,amountOutMinimum:C},R=w.selected.kind==="cl"?T({abi:ie,functionName:"exactInput",args:[{...S,deadline:u.deadline}]}):T({abi:W,functionName:"multicall",args:[u.deadline,[T({abi:W,functionName:"exactInput",args:[S]})]]});y.push(h(w.market.router,R,`Swap exact input with at least ${C} output base units to the calling wallet.`))}else if(!l)throw new o("The CLM swap requires different input and output tokens.");let v=await u.token(n);return{...await E(y,t,"Swap qualified CLM constituents. Venue fees are included in the quote."),output:{token:v,amount:x.toString()},minimumOutput:{token:v,amount:C.toString()},deadline:u.deadline.toString()}})},{name:"beefy_clm_deposit",inputSchema:{type:"object",properties:{...Z,amount0:O(`Amount of the CLM vault's first token (token0) to deposit, in base units of that token (read its decimals). May be "0" if amount1 is positive.`),amount1:O(`Amount of the CLM vault's second token (token1) to deposit, in base units of that token (read its decimals). May be "0" if amount0 is positive.`)},required:["vault","amount0","amount1"],additionalProperties:!1},execute:(e,t)=>r(async()=>{let a=m(e,["amount0","amount1","slippageBps"]),s=K(e.slippageBps),i=G(e.amount0,!0),n=G(e.amount1,!0);if(i===0n&&n===0n)throw new o("At least one CLM deposit amount must be positive.");let c=await b(a,t);if(await c.entryAvailable(),await c.balance(a.wants[0])<i||await c.balance(a.wants[1])<n)throw new o("Acquire the CLM constituents first and retry with their mined balances.");let[l,F,u,y,x]=ne(await c.read(a.manager,"previewDeposit",[i,n]),5);if(F>i||u>n||F+u===0n||y>F||x>u)throw new o("The CLM returned invalid deposit amounts or fees.");let C=Q(l,s),v=[];for(let[w,S]of[i,n].entries())S>0n&&v.push(d.approval(f(a.wants[w]),f(a.manager),S.toString(),M));v.push(h(a.manager,T({abi:X,functionName:"deposit",args:[i,n,C]}),`Mint at least ${C} CLM share base units to the calling wallet.`));for(let[w,S]of[i,n].entries())S>0n&&v.push(d.approval(f(a.wants[w]),f(a.manager),"0",M));return{...await E(v,t,"Mint CLM want shares with a positive share minimum and exact input approvals. Final revocations clear any unused allowance. Deposit the actual shares received into beefy_deposit separately."),output:{token:await c.token(a.manager),amount:l.toString()},minimumShares:C.toString(),usedAmounts:[F.toString(),u.toString()],fees:[y.toString(),x.toString()]}})},{name:"beefy_clm_withdraw",inputSchema:{type:"object",properties:{...Z,shares:{description:'CLM shares to redeem for the pair tokens, in base units of the CLM share token (read its decimals). "all" redeems your full CLM share balance.',anyOf:[O(),{const:"all"}]}},required:["vault","shares"],additionalProperties:!1},execute:(e,t)=>r(async()=>{let a=m(e,["shares","slippageBps"]),s=K(e.slippageBps),i=e.shares==="all"?void 0:G(e.shares),n=await b(a,t),c=await n.balance(a.manager),l=i??c;if(l===0n||l>c)throw new o("Withdraw vault shares first, then provide a positive CLM share amount no greater than your mined balance.");let u=ne(await n.read(a.manager,"previewWithdraw",[l]),2).map(x=>x===0n?0n:Q(x,s));if(u.every(x=>x===0n))throw new o("No positive CLM withdrawal output is available.");let y=[h(a.manager,T({abi:X,functionName:"withdraw",args:[l,u[0],u[1]]}),"Redeem CLM shares and return the pair tokens to the calling wallet.")];return{...await E(y,t,"Redeem CLM shares. Convert actual returned tokens, including leftover deposit dust, through the bridge token to USDG with beefy_clm_swap after mining. Strategy pause or API status does not prevent requesting this preview."),minimumOutputs:await Promise.all(u.map(async(x,C)=>({token:await n.token(a.wants[C]),amount:x.toString()})))}})}]}};async function je(d,r,m,b){if(!we.includes(d))throw new o("Unknown Beefy CLM action.");let h=async()=>{throw new o("Beefy CLM reconstruction uses only qualified on-chain routes.")},E=ue({clientFor:()=>b,http:fetch,quoteSwap:h,buildSwap:h,preview:async t=>({txs:t,changes:[],summary:"Locally reconstructed CLM intent; local preview still required."})});return(await Ee(E).tools.find(t=>t.name===d).execute(r,m)).txs}function Ge(d,r,m){let b=()=>{throw new o("Beefy CLM calldata differs from locally reconstructed intent; nothing was signed.")};function h(E,e,t){if(E===e)return;let a=J({abi:t,data:E}),s=J({abi:t,data:e});(a.functionName!==s.functionName||!a.args||!s.args)&&b();let i=[...a.args],n=[...s.args];if(I(T({abi:t,functionName:a.functionName,args:i}),E)||b(),a.functionName==="deposit"||a.functionName==="withdraw")for(let c of a.functionName==="deposit"?[2]:[1,2])g(i[c])<g(n[c])&&b(),i[c]=n[c];else if(a.functionName==="multicall"){let c=g(i[0]);(c<=m||c>g(n[0]))&&b(),(!Array.isArray(i[1])||!Array.isArray(n[1])||i[1].length!==1||n[1].length!==1)&&b(),h(i[1][0],n[1][0],W),i[0]=n[0],i[1]=n[1]}else if(a.functionName==="exactInput"){let c={...i[0]},l=n[0];g(c.amountOutMinimum)<g(l.amountOutMinimum)&&b(),c.amountOutMinimum=l.amountOutMinimum,"deadline"in c&&((g(c.deadline)<=m||g(c.deadline)>g(l.deadline))&&b(),c.deadline=l.deadline),i[0]=c}else b();I(T({abi:t,functionName:a.functionName,args:i}),e)||b()}(!r.length||d.length!==r.length)&&b();for(let[E,e]of d.entries()){let t=r[E];(e.chainId!==t.chainId||!I(e.to,t.to)||e.value!==t.value)&&b();try{if(I(t.to,q.markets.cl.router))J({abi:ie,data:t.data}).args[0].deadline<=m&&b();else if(I(t.to,q.markets.v3.router)){let a=J({abi:W,data:t.data});(a.functionName!=="multicall"||a.args[0]<=m)&&b()}}catch{b()}if(!I(e.data,t.data))try{let a=De.find(s=>I(s.manager,t.to));h(e.data,t.data,a?X:I(t.to,q.markets.cl.router)?ie:W)}catch{b()}}}var We=d=>({tools:Ee(d).tools.slice(1)});export{De as a,we as b,X as c,ie as d,W as e,Me as f,Se as g,Ee as h,je as i,Ge as j,We as k};
|
|
1
|
+
import{b as Be,c as Ae}from"./4PLLS6CT.js";import{a as pe}from"./SPJCSEKP.js";import{a as le}from"./43LI5NKJ.js";import{c as me}from"./SCG5HWMN.js";import{a as O}from"./66F5ZH34.js";import{c as Y,d as fe,g as I,i as re,m as be,n as ue}from"./NWNYJ26T.js";import{b as v,j as ce,k as se}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{decodeFunctionData as J,encodeFunctionData as q,erc20Abi as te,getAddress as Ce,keccak256 as we,parseAbi as P}from"viem";var _={chainId:4663,observedAt:"2026-11-04T21:56:26.556Z",block:"106231118",routeBlock:"106231118",sources:["https://rpc.mainnet.chain.robinhood.com","https://raw.githubusercontent.com/beefyfinance/cowcentrated-subgraph/main/abis/beefy/clm/ClmManager.json","https://raw.githubusercontent.com/beefyfinance/beefy-v2/main/src/features/data/apis/beefy/beefy-clm-pool.ts"],markets:{v3:{router:"0xCaf681a66D020601342297493863E78C959E5cb2",quoter:"0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7",factory:"0x1f7d7550B1b028f7571E69A784071F0205FD2EfA"},cl:{router:"0xC062b870E813fcA720f1e002c234369Ab3aB9415",quoter:"0x03983AB2C057a2eac211ff01738a1e49ff325B49",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3"}},vaults:[{id:"up33-cow-robinhood-cashcat-weth-vault",vault:"0x25012D654bF9107B6E0Af0248656fEf0b718dBd3",manager:"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x020bfC650A365f8BB26819deAAbF3E21291018b4","0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"],strategy:"0xd7F3bCDAfCFf0018953BB6944Db2683Ff2e42b07",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x4E8649Be40aE67EBbcff99C291B92eE03015917b",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-usdg-net-vault",vault:"0x25B418FcFe8543c25AD9d78246839E5Cf3a3b50D",manager:"0x5A725556514222d0cc81501A9294a3135b7C41C4",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168","0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf"],strategy:"0x89207bED2935C64d6cb105E9C85E0E2ED99DD8f2",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},{id:"up33-cow-robinhood-weth-stonkbroker-vault",vault:"0x544c7Ef9265dc08d93B5394116E68aE7D9e60730",manager:"0x5794bB61E83397049c40D87BbF3d44AF583A27Ce",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0xe934e36A439C94017B64a3FecE66AF12099aBF50"],strategy:"0x54Bd0805f549708144C811c14DdEeC0714CA5e0c",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-weth-up-vault",vault:"0x56EA4b4AFAFbb87CFD8Fd8a0266a2F86561677b8",manager:"0x36759534741E28Eb052238738963D684bFe719E4",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x57C0E45cB534413D1C20A4240955d6bB250BB4F1"],strategy:"0x8337c691C3afA52ccE418178e52ed472F034Cb8b",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x23D641FeCcD207E8794c593e8240444A0674C4Ba",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-weth-frong-vault",vault:"0x75588e48f7b4Ed9365d78C6cD509f3C7B804Ca47",manager:"0x9818f01EDCcc3d8EB86B859931C3B877cf44A108",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x6245e67affA44a23077f0Ea7f981a8DC743a0c47"],strategy:"0xdB739d906CD5101b65E089a284ec13a3ab21F603",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x9334BbCBE77C0883d704f71Db35CCF636639334c",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"},{id:"up33-cow-robinhood-usdg-intc-vault",vault:"0x8353c496114CF66D10545fdc2B4e6dFBafd37e3b",manager:"0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168","0xc72b96e0E48ecd4DC75E1e45396e26300BC39681"],strategy:"0xbaEE86C9D7dE9dc192f17dFA62833B601Dc64D23",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:60,bridge:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"},{id:"up33-cow-robinhood-weth-tendies-vault",vault:"0x97DCDc29a3B3e2F556564279f7D09eE40eB74E45",manager:"0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d",managerImpl:"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C",wants:["0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73","0x45242320DBB855EeA8Fd36804C6487E10E97FCF9"],strategy:"0x9a02CaA8a2e63659f8A419a29a3B48baD86d3c7a",beacon:"0xfD7EE9D17BD6941bF8e612281ec23E857134BB92",implementation:"0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6",pool:"0xD53a623c17A5853838FA140cE5706eA008565dA8",factory:"0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3",tickSpacing:200,bridge:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73"}],routes:[{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x020bfC650A365f8BB26819deAAbF3E21291018b4",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c8020bfc650a365f8bb26819deaabf3e21291018b4",pools:["0x4E8649Be40aE67EBbcff99C291B92eE03015917b"]},{from:"0x020bfC650A365f8BB26819deAAbF3E21291018b4",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x020bfc650a365f8bb26819deaabf3e21291018b40000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x4E8649Be40aE67EBbcff99C291B92eE03015917b"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf",kind:"cl",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d1680000c8ca9c78dd337a67f6e0077f65f5e9218719d30edf",pools:["0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673"]},{from:"0xCA9c78Dd337A67F6e0077F65F5E9218719d30eDf",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"cl",path:"0xca9c78dd337a67f6e0077f65f5e9218719d30edf0000c85fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0xe934e36A439C94017B64a3FecE66AF12099aBF50",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c8e934e36a439c94017b64a3fece66af12099abf50",pools:["0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c"]},{from:"0xe934e36A439C94017B64a3FecE66AF12099aBF50",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0xe934e36a439c94017b64a3fece66af12099abf500000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x57C0E45cB534413D1C20A4240955d6bB250BB4F1",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c857c0e45cb534413d1c20a4240955d6bb250bb4f1",pools:["0x23D641FeCcD207E8794c593e8240444A0674C4Ba"]},{from:"0x57C0E45cB534413D1C20A4240955d6bB250BB4F1",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x57c0e45cb534413d1c20a4240955d6bb250bb4f10000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x23D641FeCcD207E8794c593e8240444A0674C4Ba"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x6245e67affA44a23077f0Ea7f981a8DC743a0c47",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c86245e67affa44a23077f0ea7f981a8dc743a0c47",pools:["0x9334BbCBE77C0883d704f71Db35CCF636639334c"]},{from:"0x6245e67affA44a23077f0Ea7f981a8DC743a0c47",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x6245e67affa44a23077f0ea7f981a8dc743a0c470000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x9334BbCBE77C0883d704f71Db35CCF636639334c"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",kind:"cl",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d16800003cc72b96e0e48ecd4dc75e1e45396e26300bc39681",pools:["0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67"]},{from:"0xc72b96e0E48ecd4DC75E1e45396e26300BC39681",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"cl",path:"0xc72b96e0e48ecd4dc75e1e45396e26300bc3968100003c5fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x45242320DBB855EeA8Fd36804C6487E10E97FCF9",kind:"cl",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000c845242320dbb855eea8fd36804c6487e10e97fcf9",pools:["0xD53a623c17A5853838FA140cE5706eA008565dA8"]},{from:"0x45242320DBB855EeA8Fd36804C6487E10E97FCF9",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"cl",path:"0x45242320dbb855eea8fd36804c6487e10e97fcf90000c80bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0xD53a623c17A5853838FA140cE5706eA008565dA8"]},{from:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",to:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",kind:"v3",path:"0x5fc5360d0400a0fd4f2af552add042d716f1d1680000640bd7d308f8e1639fab988df18a8011f41eacad73",pools:["0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"]},{from:"0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73",to:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168",kind:"v3",path:"0x0bd7d308f8e1639fab988df18a8011f41eacad730000645fc5360d0400a0fd4f2af552add042d716f1d168",pools:["0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca"]}],codeHashes:{"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C":"0x6f2a1713cbceba31cc630dddda1ef99cd35086c96005f3c9ea015f9a8e53e613","0xd7F3bCDAfCFf0018953BB6944Db2683Ff2e42b07":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xfD7EE9D17BD6941bF8e612281ec23E857134BB92":"0x9cc155dd143657bba37e6a51fa28e78158e3f47454acdcebedc0512e3803d0fc","0xF5331Dc29A1FDe4b22d7F168661584B057228683":"0x9f1e0f8e488165740c5ab91a3da1bea1a75eeef607ea37b32296ad465971344c","0x4E8649Be40aE67EBbcff99C291B92eE03015917b":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x1ac9dB4a2608ba45D6127B1737949b51Bb54B7F3":"0x4350c8fcdf90361969542249d76c25d6afbd31f10bebf0134bfe21beba1e8f4c","0x5A725556514222d0cc81501A9294a3135b7C41C4":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x89207bED2935C64d6cb105E9C85E0E2ED99DD8f2":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x5794bB61E83397049c40D87BbF3d44AF583A27Ce":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x54Bd0805f549708144C811c14DdEeC0714CA5e0c":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x36759534741E28Eb052238738963D684bFe719E4":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x8337c691C3afA52ccE418178e52ed472F034Cb8b":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x23D641FeCcD207E8794c593e8240444A0674C4Ba":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x9818f01EDCcc3d8EB86B859931C3B877cf44A108":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xdB739d906CD5101b65E089a284ec13a3ab21F603":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x9334BbCBE77C0883d704f71Db35CCF636639334c":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0xbaEE86C9D7dE9dc192f17dFA62833B601Dc64D23":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d":"0xa5fcbfc6347a83acdfbc561e9c0a59b1bbb321da361c3463b73b5c173a68291b","0x9a02CaA8a2e63659f8A419a29a3B48baD86d3c7a":"0x48fed026ddb394d366df6328a1bb802687a479cd28e30ee41d38b8567fb90202","0xD53a623c17A5853838FA140cE5706eA008565dA8":"0xda57657ec68ddfb0987ba1352a44cefe40433e55585f3e4555b8ced4bbeb540d","0xCaf681a66D020601342297493863E78C959E5cb2":"0x6f36c378e272c6324c48f045182bcb54bd8ad654cf9ebd42e8893d52c4cb25dc","0x33e885eD0Ec9bF04EcfB19341582aADCb4c8A9E7":"0x3db0868d945e9304c9bc6a8b2181948109ea617647142f3c4083e14393496a28","0x1f7d7550B1b028f7571E69A784071F0205FD2EfA":"0xec72b1abd1f2faee020cfea9c646bd8994f9fb389054f6e574f103a895091739","0xC062b870E813fcA720f1e002c234369Ab3aB9415":"0x11ea7d3599ef56eda32c0ce7ca26e9aae71bec13bfcbd3ad0e83826c1a2defe4","0x03983AB2C057a2eac211ff01738a1e49ff325B49":"0x1ed81396c831d69a6c59384019850c21ac672d24ae83b4b26304a7384e1e4096","0x52e65B17fB6E5BA00Ed806f37Afcd2DaA50271Ca":"0x3298b5dd4e6f115074c526a55ad05a36fd73a0034ac22ec6cbaab32cc9c1e8d2","0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73":"0x5706be52f64875fee65a2cec0d80e47a23d8793cbe85d214b48445e2d05f5353","0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3":"0xa2cf7f366f3d8d11e611acecf7916a27308ba041bf1e161bddbd4ecbb9402b6a","0x01b0d3d2d54e0B63a8a97E108bE72C819Dc5a0E6":"0xd6f09e63327b36d3c498f8de8768bd3e4336894cd00ddb36aa9e0a1e4a4c911e"},delegates:{"0x137731B8B2D7Cd24aB4A4A9061f2D7b4Fd1aBFEE":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x4E8649Be40aE67EBbcff99C291B92eE03015917b":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x5A725556514222d0cc81501A9294a3135b7C41C4":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x99e70A5b06215e5D2F3BeC773b4f59c008fc1673":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x5794bB61E83397049c40D87BbF3d44AF583A27Ce":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0xB11ba9a4d345434c25d625C076f23Ad14abC6B3c":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x36759534741E28Eb052238738963D684bFe719E4":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x23D641FeCcD207E8794c593e8240444A0674C4Ba":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x9818f01EDCcc3d8EB86B859931C3B877cf44A108":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x9334BbCBE77C0883d704f71Db35CCF636639334c":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x599ac767099bB6f01712867BfA1Fc1Aa27DEFD37":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0x6290Be6e6913708866E6f17eaf3F4FCC7d3fdF67":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3","0x9619bFB1f2D97E2B23F23310205e4c2089c1A45d":"0xfD4017Ad7c1092aaFEbC82621B4DeE59f178D74C","0xD53a623c17A5853838FA140cE5706eA008565dA8":"0x11725976BF1F38c4aB78d1F480bc5883d70D9dc3"},qualificationHistory:[{observedAt:"2026-10-31",block:"102927065",routeBlock:"102928782",implementation:"0xF5331Dc29A1FDe4b22d7F168661584B057228683",implementationHash:"0x9f1e0f8e488165740c5ab91a3da1bea1a75eeef607ea37b32296ad465971344c"}],blockHash:"0xcb0e2862c6e22ca5854fb9264995749e497eb26f05a3370202db69909b891c47"};var oe=_.vaults,ge=["beefy_clm_swap","beefy_clm_deposit","beefy_clm_withdraw"],X=P(["function wants() view returns(address,address)","function strategy() view returns(address)","function want() view returns(address)","function implementation() view returns(address)","function pool() view returns(address)","function vault() view returns(address)","function price() view returns(uint256)","function paused() view returns(bool)","function isCalm() view returns(bool)","function actionableAt() view returns(uint256)","function token0() view returns(address)","function token1() view returns(address)","function factory() view returns(address)","function tickSpacing() view returns(int24)","function balances() view returns(uint256,uint256)","function previewDeposit(uint256,uint256) view returns(uint256 shares,uint256 amount0,uint256 amount1,uint256 fee0,uint256 fee1)","function previewWithdraw(uint256) view returns(uint256,uint256)","function deposit(uint256 amount0,uint256 amount1,uint256 minShares)","function withdraw(uint256 shares,uint256 minAmount0,uint256 minAmount1)"]),ie=P(["function exactInput((bytes path,address recipient,uint256 deadline,uint256 amountIn,uint256 amountOutMinimum)) payable returns(uint256)"]),W=P(["function exactInput((bytes path,address recipient,uint256 amountIn,uint256 amountOutMinimum)) payable returns(uint256)","function multicall(uint256 deadline,bytes[] data) payable returns(bytes[])"]),Fe=P(["function quoteExactInput(bytes path,uint256 amountIn) returns(uint256,uint160[],uint32[],uint256)"]),ye={cl:P(["function getPool(address,address,int24) view returns(address)"]),v3:P(["function getPool(address,address,uint24) view returns(address)"])},ke=P(["function deposit() payable"]),Z={vault:{...Y,description:"Address of the Beefy CLM vault contract (from beefy_list)."},chainId:{const:v,description:"Chain id; only 4663 (Robinhood Chain mainnet) is supported. Optional."},slippageBps:{type:"integer",minimum:0,maximum:500,description:"Maximum slippage in basis points (50 = 0.5%), 0 to 500. Default 50."}},De=10n**36n,z=Ce(ce[v].uniswap.WETH.address),ve="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",de=Object.fromEntries(Object.entries(_.codeHashes).map(([i,s])=>[i.toLowerCase(),s])),je=oe.map(i=>{let s=i.manager.toLowerCase(),l=i.managerImpl.toLowerCase(),r=de[s],E=de[l];if(!r||!E)throw new Error("Beefy CLM manager delegation is missing a pinned runtime hash.");return{chainId:v,entry:s,entryCodeHash:r,proxy:s,proxyCodeHash:r,implementation:l,codeHash:E}}),Ee=Object.fromEntries(Object.entries(_.delegates).map(([i,s])=>[i.toLowerCase(),s]));function f(i){return re(i,"Provide a token or vault address.",fe)}function g(i){return be(i,"Invalid Beefy CLM integer.")}function G(i,s=!1){return ue(i,"Provide a positive amount that fits uint256.",{notString:"Provide a decimal base-unit integer string.",positive:!s})}function K(i){let s=i??50;if(typeof s!="number"||!Number.isInteger(s)||s<0||s>500)throw new c("Use integer slippageBps from 0 to 500.");return BigInt(s)}function Q(i,s){let l=i*(10000n-s)/10000n;if(l<=0n)throw new c("This CLM amount is too small for a positive output minimum.");return l}function ne(i,s){if(!Array.isArray(i)||i.length!==s)throw new c("Invalid Beefy CLM quote.");return i.map(g)}function Me(i){let s=f(i),l=oe.find(r=>I(r.vault,s));if(!l)throw new c("This vault has no qualified Beefy CLM route. Use beefy_withdraw to return existing vault shares to their want; redeem that want through the project app if Oak has no qualified redemption route.");return l}function Se(i,s,l,r,E){if(i<=0n||l<=0n||r<0n||E<0n)throw new c("The CLM price or budget is invalid.");let x=s?i*l/De:i;if(x===0n)throw new c("The CLM budget is too small at the current pool price.");let e=r*l/De,t=E>e?E-e:e-E,a=x<t?x:t,b=(x-a)/2n,d=i*(E>e?a+b:b)/x;return[d,i-d]}var xe=i=>{async function s(e){try{return await e()}catch(t){throw new c(i.plainError(t))}}function l(e,t){if(e.chainId!==void 0&&e.chainId!==v)throw new c("Beefy CLM requires chain 4663.");for(let a of Object.keys(e))if(!["vault","chainId",...t].includes(a))throw new c(`Unsupported Beefy CLM input: ${a}.`);return Me(e.vault)}async function r(e,t){le(t);let a=i.clientFor(v);if(await a.getChainId()!==v)throw new c("The Beefy CLM endpoint must report chain 4663.");let b=g(await a.getBlockNumber()),d=await a.getBlock({blockNumber:b}),n=(B,m,A=[])=>a.readContract({address:f(B),abi:X,functionName:m,args:A,blockNumber:b}),o=new Set;async function p(B){let m=B.toLowerCase();if(o.has(m))return;let A=de[m];if(!A)throw new c("Unqualified Beefy CLM dependency; no transaction was built.");let D=await a.getCode({address:f(B),blockNumber:b});if(!D||we(D)!==A)throw new c("A Beefy CLM contract or delegated implementation no longer matches its pinned code.");o.add(m),Ee[m]&&await p(Ee[m])}await Ae(a,f(e.vault),b);for(let B of[e.manager,e.strategy,e.beacon,e.implementation,e.pool,e.factory])await p(B);let[F,u,y,h,C,M,w,S,R,ee]=await Promise.all([n(e.vault,"want"),n(e.manager,"wants"),n(e.manager,"strategy"),n(e.beacon,"implementation"),n(e.strategy,"pool"),n(e.strategy,"vault"),n(e.pool,"token0"),n(e.pool,"token1"),n(e.pool,"factory"),n(e.pool,"tickSpacing")]);if(f(F)!==e.manager||!Array.isArray(u)||u.length!==2||u.some((B,m)=>f(B)!==e.wants[m])||f(y)!==e.strategy||f(h)!==e.implementation||f(C)!==e.pool||f(M)!==e.manager||f(w)!==e.wants[0]||f(S)!==e.wants[1]||f(R)!==e.factory||ee!==e.tickSpacing)throw new c("The Beefy CLM want, tokens, strategy, beacon or pool differs from its qualified deployment.");let V=async B=>g(await a.readContract({address:f(B),abi:te,functionName:"balanceOf",args:[t],blockNumber:b}));async function ae(B){let m=f(B),[A,D]=await Promise.all([a.readContract({address:m,abi:te,functionName:"symbol",blockNumber:b}),a.readContract({address:m,abi:te,functionName:"decimals",blockNumber:b})]);if(typeof A!="string"||!A.trim()||!Number.isInteger(D)||D<0||D>255)throw new c("Invalid CLM token metadata.");return{address:m,symbol:A,decimals:D,chainId:v}}async function H(){let m=(await me(i.http,"https://api.beefy.finance/vaults",{},k=>Array.isArray(k)&&k.every($=>$!==null&&typeof $=="object"))).filter(k=>k.chain==="robinhood"&&typeof k.earnContractAddress=="string"&&I(k.earnContractAddress,e.vault)),A=m[0],D=Be(f(e.vault));if(m.length!==1||!A||A.id!==D.id||A.type!=="standard"||f(A.tokenAddress)!==e.manager||A.tokenDecimals!==18)throw new c("The Beefy API and qualified CLM vault disagree.");if(A.status!=="active")throw new c(`Beefy marks this vault ${String(A.status)}; deposits are unavailable. Exit with beefy_withdraw, redeem the returned CLM shares with beefy_clm_withdraw, then swap the received tokens to USDG with beefy_clm_swap.`);let L=f(await n(e.vault,"strategy")),T=await Promise.all([n(L,"paused"),n(e.strategy,"paused")]);if(T.some(k=>typeof k!="boolean"))throw new c("Invalid Beefy strategy pause flag.");if(T.some(Boolean))throw new c("The Beefy strategy is paused; deposits are unavailable. Exit with beefy_withdraw, redeem CLM shares with beefy_clm_withdraw, then convert the tokens to USDG with beefy_clm_swap.");if(await n(e.manager,"isCalm")!==!0)throw new c("The CLM pool is not calm; wait and request a fresh deposit preview.")}async function N(B,m){let A=new Set([...e.wants,f(se),z]);if(!A.has(B)||!A.has(m)||B===m)throw new c("Use this CLM pair or the USDG/WETH conversion route, with different input and output tokens.");let D=_.routes.find(U=>U.from===B&&U.to===m&&(U.pools[0]===e.pool||U.kind==="v3"));if(!D)throw new c("No qualified direct CLM route for this token pair. Convert through the CLM bridge token in separately mined steps.");let L=_.markets[D.kind];for(let U of[L.router,L.quoter,L.factory,...D.pools])await p(U);let T=D.path;if(T.length!==88||f(T.slice(0,42))!==B||f(`0x${T.slice(-40)}`)!==m)throw new c("Invalid qualified CLM swap path.");let k=Number.parseInt(T.slice(42,48),16),$=await a.readContract({address:f(L.factory),abi:ye[D.kind],functionName:"getPool",args:[B,m,k],blockNumber:b});if(f($)!==D.pools[0])throw new c("The swap factory no longer selects the qualified CLM pool.");if(f(await n(L.quoter,"factory"))!==L.factory)throw new c("The CLM quoter factory differs from its pin.");return D}async function j(B,m,A){let D=await N(B,m),L=_.markets[D.kind],T=await a.simulateContract({address:f(L.quoter),abi:Fe,functionName:"quoteExactInput",args:[D.path,A],account:t,blockNumber:b}),k=g(T.result[0]);if(k===0n)throw new c("No positive quote for this CLM swap.");return{selected:D,market:L,out:k}}return{client:a,blockNumber:b,deadline:d.timestamp+600n,read:n,balance:V,token:ae,code:p,entryAvailable:H,quote:j}}function E(e,t,a,b="0"){return i.unsignedTx({to:f(e),data:t,description:a,value:b,chainId:v})}async function x(e,t,a){let b=await i.preview(e,t);return{txs:e,preview:b,summary:`${a} Re-read actual balances after every mined step. Calls are separate transactions; earlier steps can remain mined if a later step fails. Confirm the local preview. Gas is additional.`}}return{tools:[{name:"beefy_lp",inputSchema:{type:"object",properties:{...Z,amount:{...O(),description:"Optional entry budget in the CLM bridge token base units (USDG or WETH)."}},required:["vault"],additionalProperties:!1},execute:(e,t)=>s(async()=>{let a=l(e,["amount","slippageBps"]),b=K(e.slippageBps),d=await r(a,t),[n,o,p,F,u,y,h,C]=await Promise.all([d.token(a.wants[0]),d.token(a.wants[1]),d.token(a.manager),d.balance(a.wants[0]),d.balance(a.wants[1]),d.balance(a.manager),d.read(a.manager,"balances"),d.read(a.strategy,"price")]),M;if(e.amount!==void 0){await d.entryAvailable();let w=G(e.amount),[S,R]=ne(h,2),ee=Se(w,a.bridge===n.address,g(C),S,R),V=[];for(let[ae,H]of[n,o].entries()){let N=ee[ae],j=N===0n||H.address===a.bridge?N:(await d.quote(f(a.bridge),H.address,N)).out;V.push({token:H,bridgeAmount:N.toString(),expectedAmount:j.toString(),minimumAmount:j===0n?"0":Q(j,b).toString(),swapRequired:N>0n&&H.address!==a.bridge})}M={bridge:await d.token(a.bridge),budget:w.toString(),inputs:V,source:"strategy.price() and CLM balances(); imbalance first, then split remaining value equally. Re-quote after mining swaps."}}return{chainId:v,vault:a.vault,manager:a.manager,bridge:await d.token(a.bridge),constituents:[{token:n,balance:F.toString()},{token:o,balance:u.toString()}],shares:{token:p,amount:y.toString()},entryPlan:M,block:d.blockNumber.toString(),summary:"Convert USDG or ETH to the bridge token with beefy_clm_swap. Use entryPlan to acquire the current deposit ratio, including a one-sided ratio when appropriate. Deposit actual balances with beefy_clm_deposit, then deposit mined CLM shares with beefy_deposit. Exit with beefy_withdraw, beefy_clm_withdraw, then beefy_clm_swap through the bridge token to USDG."}})},{name:"beefy_clm_swap",inputSchema:{type:"object",properties:{...Z,from:{...Y,description:"Address of the token to sell: native ETH placeholder, or a CLM constituent or bridge token (USDG or WETH)."},to:{...Y,description:"Address of the token to receive, different from the input token: a CLM constituent or the bridge token."},amount:O('Amount of the input token in base units of that token (read its decimals). Example: "1000000" = 1 USDG at 6 decimals; "1000000000000000000" = 1 WETH.')},required:["vault","from","to","amount"],additionalProperties:!1},execute:(e,t)=>s(async()=>{let a=l(e,["from","to","amount","slippageBps"]),b=K(e.slippageBps),d=f(e.from),n=f(e.to),o=G(e.amount),p=d.toLowerCase()===ve,F=p?z:d,u=await r(a,t);if((p?await u.client.getBalance({address:t,blockNumber:u.blockNumber}):await u.balance(d))<o)throw new c("Insufficient CLM swap balance; keep ETH for gas.");let y=[];p&&(await u.code(z),y.push(E(z,q({abi:ke,functionName:"deposit"}),"Wrap exactly the requested ETH for the CLM workflow.",o.toString())));let h=o,C=o;if(F!==n){let w=await u.quote(F,n,o);h=w.out,C=Q(h,b),y.push(i.approval(F,f(w.market.router),o.toString(),v));let S={path:w.selected.path,recipient:t,amountIn:o,amountOutMinimum:C},R=w.selected.kind==="cl"?q({abi:ie,functionName:"exactInput",args:[{...S,deadline:u.deadline}]}):q({abi:W,functionName:"multicall",args:[u.deadline,[q({abi:W,functionName:"exactInput",args:[S]})]]});y.push(E(w.market.router,R,`Swap exact input with at least ${C} output base units to the calling wallet.`))}else if(!p)throw new c("The CLM swap requires different input and output tokens.");let M=await u.token(n);return{...await x(y,t,"Swap qualified CLM constituents. Venue fees are included in the quote."),output:{token:M,amount:h.toString()},minimumOutput:{token:M,amount:C.toString()},deadline:u.deadline.toString()}})},{name:"beefy_clm_deposit",inputSchema:{type:"object",properties:{...Z,amount0:O(`Amount of the CLM vault's first token (token0) to deposit, in base units of that token (read its decimals). May be "0" if amount1 is positive.`),amount1:O(`Amount of the CLM vault's second token (token1) to deposit, in base units of that token (read its decimals). May be "0" if amount0 is positive.`)},required:["vault","amount0","amount1"],additionalProperties:!1},execute:(e,t)=>s(async()=>{let a=l(e,["amount0","amount1","slippageBps"]),b=K(e.slippageBps),d=G(e.amount0,!0),n=G(e.amount1,!0);if(d===0n&&n===0n)throw new c("At least one CLM deposit amount must be positive.");let o=await r(a,t);if(await o.entryAvailable(),await o.balance(a.wants[0])<d||await o.balance(a.wants[1])<n)throw new c("Acquire the CLM constituents first and retry with their mined balances.");let[p,F,u,y,h]=ne(await o.read(a.manager,"previewDeposit",[d,n]),5);if(F>d||u>n||F+u===0n||y>F||h>u)throw new c("The CLM returned invalid deposit amounts or fees.");let C=Q(p,b),M=[];for(let[w,S]of[d,n].entries())S>0n&&M.push(i.approval(f(a.wants[w]),f(a.manager),S.toString(),v));M.push(E(a.manager,q({abi:X,functionName:"deposit",args:[d,n,C]}),`Mint at least ${C} CLM share base units to the calling wallet.`));for(let[w,S]of[d,n].entries())S>0n&&M.push(i.approval(f(a.wants[w]),f(a.manager),"0",v));return{...await x(M,t,"Mint CLM want shares with a positive share minimum and exact input approvals. Final revocations clear any unused allowance. Deposit the actual shares received into beefy_deposit separately."),output:{token:await o.token(a.manager),amount:p.toString()},minimumShares:C.toString(),usedAmounts:[F.toString(),u.toString()],fees:[y.toString(),h.toString()]}})},{name:"beefy_clm_withdraw",inputSchema:{type:"object",properties:{...Z,shares:{description:'CLM shares to redeem for the pair tokens, in base units of the CLM share token (read its decimals). "all" redeems your full CLM share balance.',anyOf:[O(),{const:"all"}]}},required:["vault","shares"],additionalProperties:!1},execute:(e,t)=>s(async()=>{let a=l(e,["shares","slippageBps"]),b=K(e.slippageBps),d=e.shares==="all"?void 0:G(e.shares),n=await r(a,t),o=await n.balance(a.manager),p=d??o;if(p===0n||p>o)throw new c("Withdraw vault shares first, then provide a positive CLM share amount no greater than your mined balance.");let u=ne(await n.read(a.manager,"previewWithdraw",[p]),2).map(h=>h===0n?0n:Q(h,b));if(u.every(h=>h===0n))throw new c("No positive CLM withdrawal output is available.");let y=[E(a.manager,q({abi:X,functionName:"withdraw",args:[p,u[0],u[1]]}),"Redeem CLM shares and return the pair tokens to the calling wallet.")];return{...await x(y,t,"Redeem CLM shares. Convert actual returned tokens, including leftover deposit dust, through the bridge token to USDG with beefy_clm_swap after mining. Strategy pause or API status does not prevent requesting this preview."),minimumOutputs:await Promise.all(u.map(async(h,C)=>({token:await n.token(a.wants[C]),amount:h.toString()})))}})}]}};async function Ge(i,s,l,r){if(!ge.includes(i))throw new c("Unknown Beefy CLM action.");let E=async()=>{throw new c("Beefy CLM reconstruction uses only qualified on-chain routes.")},x=pe({clientFor:()=>r,http:fetch,quoteSwap:E,buildSwap:E,preview:async t=>({txs:t,changes:[],summary:"Locally reconstructed CLM intent; local preview still required."})});return(await xe(x).tools.find(t=>t.name===i).execute(s,l)).txs}function We(i,s,l){let r=()=>{throw new c("Beefy CLM calldata differs from locally reconstructed intent; nothing was signed.")};function E(x,e,t){if(x===e)return;let a=J({abi:t,data:x}),b=J({abi:t,data:e});(a.functionName!==b.functionName||!a.args||!b.args)&&r();let d=[...a.args],n=[...b.args];if(I(q({abi:t,functionName:a.functionName,args:d}),x)||r(),a.functionName==="deposit"||a.functionName==="withdraw")for(let o of a.functionName==="deposit"?[2]:[1,2])g(d[o])<g(n[o])&&r(),d[o]=n[o];else if(a.functionName==="multicall"){let o=g(d[0]);(o<=l||o>g(n[0]))&&r(),(!Array.isArray(d[1])||!Array.isArray(n[1])||d[1].length!==1||n[1].length!==1)&&r(),E(d[1][0],n[1][0],W),d[0]=n[0],d[1]=n[1]}else if(a.functionName==="exactInput"){let o={...d[0]},p=n[0];g(o.amountOutMinimum)<g(p.amountOutMinimum)&&r(),o.amountOutMinimum=p.amountOutMinimum,"deadline"in o&&((g(o.deadline)<=l||g(o.deadline)>g(p.deadline))&&r(),o.deadline=p.deadline),d[0]=o}else r();I(q({abi:t,functionName:a.functionName,args:d}),e)||r()}(!s.length||i.length!==s.length)&&r();for(let[x,e]of i.entries()){let t=s[x];(e.chainId!==t.chainId||!I(e.to,t.to)||e.value!==t.value)&&r();try{if(I(t.to,_.markets.cl.router))J({abi:ie,data:t.data}).args[0].deadline<=l&&r();else if(I(t.to,_.markets.v3.router)){let a=J({abi:W,data:t.data});(a.functionName!=="multicall"||a.args[0]<=l)&&r()}}catch{r()}if(!I(e.data,t.data))try{let a=oe.find(b=>I(b.manager,t.to));E(e.data,t.data,a?X:I(t.to,_.markets.cl.router)?ie:W)}catch{r()}}}var Ve=i=>({tools:xe(i).tools.slice(1)});export{oe as a,ge as b,X as c,ie as d,W as e,je as f,Me as g,Se as h,xe as i,Ge as j,We as k,Ve as l};
|