@oakagentkit/core 0.3.6 → 0.3.7
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/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/display.js +1 -1
- package/build/dist/api/modules/chop/index.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/grove/index.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/agent-gate.js +1 -1
- package/build/dist/api/modules/hookr/blocks/pay-later.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/hook-blocks.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/pay-later-actions.js +1 -1
- package/build/dist/api/modules/hookr/pm-liquidity.js +1 -1
- package/build/dist/api/modules/hookr/relay.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/merkl/discovery.js +1 -1
- package/build/dist/api/modules/merkl/index.js +1 -1
- package/build/dist/api/modules/merkl/manage.js +1 -1
- package/build/dist/api/modules/merkl/stock-lp.d.ts +51 -0
- package/build/dist/api/modules/merkl/stock-lp.js +1 -0
- package/build/dist/api/modules/morpho/bundles.js +1 -1
- package/build/dist/api/modules/morpho/in-kind.js +1 -1
- package/build/dist/api/modules/morpho/index.js +1 -1
- package/build/dist/api/modules/morpho/local-guard.js +1 -1
- package/build/dist/api/modules/morpho/midnight.js +1 -1
- package/build/dist/api/modules/morpho/protocol.js +1 -1
- package/build/dist/api/modules/morpho/vault-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/pendle/index.js +1 -1
- package/build/dist/api/modules/pendle/reader.js +1 -1
- package/build/dist/api/modules/pendle/trade.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/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/index.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/index.js +1 -1
- package/build/dist/api/modules/wormhole/index.js +1 -1
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/tool-policy.d.ts +1 -0
- package/build/dist/api/tool-policy.js +1 -1
- package/build/dist/api/usd-estimate.js +1 -1
- package/build/dist/chunks/{GBIL2I2K.js → 2GYL3N2O.js} +1 -1
- package/build/dist/chunks/{5677LZOV.js → 2ZYFBBOE.js} +1 -1
- package/build/dist/chunks/{X53QVHBC.js → 35DTANJW.js} +1 -1
- package/build/dist/chunks/{HRGLFGFL.js → 37UBQQWL.js} +1 -1
- package/build/dist/chunks/{5DWQUEBA.js → 4JU23O3Z.js} +1 -1
- package/build/dist/chunks/{C2H3BWN5.js → 4WYTIM4T.js} +1 -1
- package/build/dist/chunks/{FGGDAAHW.js → 52AEVHKJ.js} +1 -1
- package/build/dist/chunks/{5RAZFRO4.js → 5EQTOA5F.js} +1 -1
- package/build/dist/chunks/{SRYX65GZ.js → 5VA66LFF.js} +1 -1
- package/build/dist/chunks/{IM7ZF7XZ.js → 627SGCTU.js} +1 -1
- package/build/dist/chunks/{OIGTTRN5.js → 7KK3OC7Q.js} +1 -1
- package/build/dist/chunks/{RYEQIZ2H.js → 7PBCV7VS.js} +1 -1
- package/build/dist/chunks/{P6JE2NRA.js → AOTTQPK7.js} +1 -1
- package/build/dist/chunks/{EHQRAA3R.js → B4U43D5Z.js} +1 -1
- package/build/dist/chunks/B5B7U3NZ.js +1 -0
- package/build/dist/chunks/{XWZ5SL5Q.js → CITHH7NK.js} +1 -1
- package/build/dist/chunks/{L3IAEXQR.js → CLHA557R.js} +1 -1
- package/build/dist/chunks/{CVVNAFUE.js → DUTAMN3F.js} +1 -1
- package/build/dist/chunks/{DJRS3TR5.js → EKHNXPWO.js} +1 -1
- package/build/dist/chunks/EXKV6QJD.js +1 -0
- package/build/dist/chunks/{LKRAUTYI.js → FYWK3UK6.js} +1 -1
- package/build/dist/chunks/GV6FZ6UG.js +1 -0
- package/build/dist/chunks/{TZG7HTVM.js → H5J2LFPZ.js} +1 -1
- package/build/dist/chunks/{UGFRBJDQ.js → HN5RBTNE.js} +1 -1
- package/build/dist/chunks/{3HF6WE4L.js → HTOP2OKU.js} +1 -1
- package/build/dist/chunks/ILTGXU6G.js +1 -0
- package/build/dist/chunks/{B5BU645H.js → J5624CVF.js} +1 -1
- package/build/dist/chunks/JFYC2LVI.js +1 -0
- package/build/dist/chunks/{URTQNYWU.js → JUVY6PCR.js} +1 -1
- package/build/dist/chunks/{GX2RCAHG.js → JYED2PZ3.js} +1 -1
- package/build/dist/chunks/{HNBYPHTA.js → K3HCSCXE.js} +1 -1
- package/build/dist/chunks/{K4CYAWNL.js → KAXLZJU6.js} +1 -1
- package/build/dist/chunks/{6QXTL65K.js → KW5LJGNY.js} +1 -1
- package/build/dist/chunks/{XUDQYSPU.js → LHC2YV2U.js} +1 -1
- package/build/dist/chunks/{2BKZLF5A.js → LHVGWNMW.js} +1 -1
- package/build/dist/chunks/{6Y2546JA.js → LOH6LUVT.js} +1 -1
- package/build/dist/chunks/{GTJ6LBGB.js → MFRKZOU4.js} +1 -1
- package/build/dist/chunks/{QZ6V6J6W.js → MSIT5Q3M.js} +1 -1
- package/build/dist/chunks/{G4IX4CYN.js → NCCKCGKL.js} +1 -1
- package/build/dist/chunks/{N6YNJGEF.js → NGHRUNXO.js} +1 -1
- package/build/dist/chunks/{BSV65PCA.js → NIGRNLNM.js} +1 -1
- package/build/dist/chunks/{4SXRXNHG.js → NWW6GY5E.js} +1 -1
- package/build/dist/chunks/{CR7DPGI6.js → ORKXBYVC.js} +1 -1
- package/build/dist/chunks/{IR7KDBFU.js → OUXPOFY2.js} +1 -1
- package/build/dist/chunks/{XXLQDQEX.js → OWHXYE2G.js} +1 -1
- package/build/dist/chunks/{J2J73XYU.js → PLEJPTTK.js} +1 -1
- package/build/dist/chunks/{QP2B7AYX.js → PX2G2H6G.js} +1 -1
- package/build/dist/chunks/{7X5JVF3F.js → QCPJZBEO.js} +1 -1
- package/build/dist/chunks/{7JTXYMNP.js → QGO4EKXZ.js} +1 -1
- package/build/dist/chunks/{JTWJT2O3.js → QXBQ7WPB.js} +1 -1
- package/build/dist/chunks/{DPSFR3ZS.js → R5UOFPDO.js} +1 -1
- package/build/dist/chunks/{EJIP7RBG.js → REXGROOD.js} +1 -1
- package/build/dist/chunks/{PXVF2SHU.js → RWEA4SWP.js} +1 -1
- package/build/dist/chunks/{K6GECT3F.js → RWUF6T4I.js} +1 -1
- package/build/dist/chunks/{F74ARK4H.js → SDDYM2H3.js} +1 -1
- package/build/dist/chunks/{3M7RMROZ.js → TKJ4GFUP.js} +1 -1
- package/build/dist/chunks/{DV2HVFTM.js → UCMOQAVD.js} +1 -1
- package/build/dist/chunks/{WUONMIA2.js → UL4DY6GX.js} +1 -1
- package/build/dist/chunks/{GCFHKJIO.js → UYYYSFMQ.js} +1 -1
- package/build/dist/chunks/{F36IA5RI.js → V7P4PCLL.js} +1 -1
- package/build/dist/chunks/{TWVDWNTG.js → VMSGNN3D.js} +1 -1
- package/build/dist/chunks/VQMBPY2P.js +1 -0
- package/build/dist/chunks/{K5OXLIPK.js → W3M4KAPX.js} +1 -1
- package/build/dist/chunks/{Q43WPRYU.js → W7BTXU3F.js} +1 -1
- package/build/dist/chunks/{KB2JWQZ4.js → WADRRW3E.js} +1 -1
- package/build/dist/chunks/{QAVP3CWL.js → WG7PMGTJ.js} +1 -1
- package/build/dist/chunks/{IKVRFAUP.js → WRNPYW47.js} +1 -1
- package/build/dist/chunks/{4GAU3JLN.js → XD4JA43O.js} +1 -1
- package/build/dist/chunks/{6EWSLHXL.js → Y7SKGRWC.js} +1 -1
- package/build/dist/chunks/{HEQBTHFS.js → YDJHXSS7.js} +1 -1
- package/build/dist/chunks/{TMENUIBC.js → YLU5JVRI.js} +1 -1
- package/build/dist/chunks/{IYOWMW5B.js → YR6Y6UIR.js} +1 -1
- package/build/dist/chunks/{FN6XY6ET.js → Z5WRTISY.js} +1 -1
- package/build/dist/chunks/{45QP74CE.js → ZB67QDN2.js} +1 -1
- package/build/dist/chunks/{MXI7LX2F.js → ZRG34Y7Q.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/5PNFV7HH.js +0 -1
- package/build/dist/chunks/H5KU4DUU.js +0 -1
- package/build/dist/chunks/H7ZJ7LAB.js +0 -1
- package/build/dist/chunks/M267JEDO.js +0 -1
- package/build/dist/chunks/Y5T36EEU.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as l,g as F,i as q,j as y}from"../chunks/CG7ABZXH.js";import"../chunks/FGGDAAHW.js";import"../chunks/RLX6YTNT.js";import"../chunks/O7L55XM3.js";import"../chunks/W73SLWBT.js";import"../chunks/DV2HVFTM.js";import{a as D}from"../chunks/HKHCN4A2.js";import"../chunks/UCFVPTE2.js";import"../chunks/C4XK764N.js";import"../chunks/FWOGOWUM.js";import{a as p,b}from"../chunks/3CH2IPQL.js";import"../chunks/2BKZLF5A.js";import{b as N}from"../chunks/CR7DPGI6.js";import"../chunks/4GAU3JLN.js";import"../chunks/2H2OZE6X.js";import"../chunks/BWE5PXRE.js";import{f as O,g as P,o as L}from"../chunks/OD7CY6BY.js";import{a as R,b as E}from"../chunks/UPX3OWKA.js";import{e as I}from"../chunks/O7HCEPQY.js";import{e as S}from"../chunks/46KWRAYK.js";import{a as h}from"../chunks/QBHY2QRC.js";import"../chunks/UNBRUWSV.js";import"../chunks/G2LAO23N.js";import"../chunks/2GXHYI23.js";import{e as A}from"../chunks/HRGLFGFL.js";import"../chunks/IR7KDBFU.js";import"../chunks/KHOUBQJK.js";import"../chunks/6STUQOFL.js";import"../chunks/GV6Z3MET.js";import"../chunks/4P6DRKY3.js";import"../chunks/5PNFV7HH.js";import"../chunks/HC3QFA5I.js";import"../chunks/QFUSCK5C.js";import"../chunks/VS7ZA4OF.js";import"../chunks/B75SS7H6.js";import"../chunks/TTBB6EFN.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GVCNTGLC.js";import"../chunks/KKGHXNM4.js";import"../chunks/3XY44BP5.js";import"../chunks/LD3A2KLN.js";import"../chunks/3RGED2KO.js";import"../chunks/UMY6SP7C.js";import"../chunks/CJMVRV34.js";import"../chunks/7WXAS54T.js";import"../chunks/LIUXNOLP.js";import"../chunks/B7WZJHIJ.js";import"../chunks/TNHU5UBQ.js";import"../chunks/HGSFRN57.js";import"../chunks/QFK335LC.js";import"../chunks/ICHT3H3W.js";import"../chunks/7AYP4ATZ.js";import"../chunks/PG7HZIZL.js";import"../chunks/S65KXMZ7.js";import"../chunks/CW37EGPL.js";import"../chunks/K6D6SDIG.js";import"../chunks/QA6Z2CYP.js";import"../chunks/CFPJDLTZ.js";import"../chunks/5N6YJFFA.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/EZUQMTLE.js";import"../chunks/5RXALTDT.js";import{b as s,j as f,t as c}from"../chunks/EWZFZUVF.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";import{zeroAddress as Q}from"viem";var e=(r,n)=>({...n,meaning:r}),x=f[s].meridian,V=x.CollateralToken_USDe.address,H={by:"server-continuation",reason:"Meridian Predict settles RFQ approvals over a WebSocket auction session that the Oak server holds."},M={none:"Single-use auction approval: it cannot be cancelled and lapses at its deadline.",staysExecutableUntilExpiry:!0},J={id:"meridian.rfq.mint-approval",program:"Meridian",purpose:"prediction buy approval",tools:["meridian_buy"],class:"order",encoding:"eip712",domain:{name:"PredictionMarketEscrow",version:"1",chainId:s,verifyingContract:x.PredictionMarketEscrow.address},primaryType:"MintApproval",types:{MintApproval:R},fields:{predictionHash:e("Hash of your picks, stake, the counterparty and its collateral, rebuilt locally from your request and the winning bid",{role:"derived",rebuild:"meridian.rfq.prediction-hash",yields:["counterparty"]}),signer:e("This wallet, the approving trader",{role:"signer"}),collateral:e("Your stake: the most USDe the escrow can take",{role:"amount",side:"out",token:V,arg:"stake"}),nonce:e("Escrow nonce chosen by the auction",{role:"nonce",kind:"server-observed"}),deadline:e("Approval deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:3600,revoke:M,submit:H,requireHuman:!0},Z={id:"meridian.rfq.trade-approval",program:"Meridian",purpose:"prediction sale approval",tools:["meridian_sell"],class:"order",encoding:"eip712",domain:{name:"SecondaryMarketEscrow",version:"1",chainId:s,verifyingContract:x.SecondaryMarketEscrow.address},primaryType:"TradeApproval",types:{TradeApproval:E},fields:{tradeHash:e("Hash of the position token and amount you sell, the buyer and the USDe price, rebuilt locally",{role:"derived",rebuild:"meridian.rfq.trade-hash",yields:["token-out","amount-out","token-in","amount-in","counterparty"]}),signer:e("This wallet, the seller",{role:"signer"}),nonce:e("Escrow nonce chosen by the auction",{role:"nonce",kind:"server-observed"}),deadline:e("Approval deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:3600,revoke:M,submit:H,requireHuman:!0},v=L({agentId:"1",owner:Q,nonce:"0",deadline:"0"}),$={id:"priors.consent",program:"Priors",purpose:"pool consent",tools:["priors_starter_line",...N],class:"consent",encoding:"eip712",domain:{...v.domain},primaryType:v.primaryType,types:v.types,fields:{agentId:e("Your agent ID the consent is for",{role:"observed",check:"equals the agentId argument"}),sponsorId:e("Sponsor root that may use this consent",{role:"observed",check:"treasury v4 root, or the feature root or sponsorId argument"}),owner:e("This wallet, the agent owner",{role:"account"}),maxPremiumBps:e("Largest premium the sponsor may charge, in basis points",{role:"observed",check:"equals the maxPremiumBps argument (starter line: 0)"}),nonce:e("Priors pool nonce for this agent",{role:"nonce",kind:"program-counter"}),deadline:e("Consent deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:P+300,submit:{by:"transaction"},requireHuman:!0},X={id:"priors.seat-proof",program:"Priors",purpose:"agent ownership proof",tools:["priors_starter_line"],class:"auth",encoding:"eip191-template",primaryType:"priors.seat-request",types:{},fields:{agentId:e("Your agent ID",{role:"observed",check:"equals the agentId argument"}),n:e("Invite bot nonce",{role:"nonce",kind:"server-observed"}),exp:e("Proof expiry (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:O+300,submit:{by:"server-continuation",reason:"The Priors invite bot receives the ownership proof through the Oak server session."},requireHuman:!1},Le=new Set(["factor_sign_up","factor_create_pay_link","factor_apply_to_job"]),T={by:"server-continuation",reason:"Oak hosts Factor API reads, pacing and engine posts; the module verifies the wallet signature before posting."},ee={id:"factor.agent-profile",program:"Factor",purpose:"agent profile",tools:["factor_sign_up"],class:"auth",encoding:"eip191-template",primaryType:"factor.agent-profile",types:{},fields:{address:e("This wallet, in lowercase",{role:"signer"}),name:e("Normalised agent name from your request",{role:"derived",rebuild:"factor.agent-profile.name"}),does:e("Normalised work description from your request",{role:"derived",rebuild:"factor.agent-profile.does"}),at:e("Factor state time, within 120 seconds of local creation; expiry is min(at + 600, createdAt + 600)",{role:"derived",rebuild:"factor.agent-profile.time",yields:["expiry"]})},maxLifetimeSeconds:600,requireHuman:!0,submit:T},re={id:"factor.pay-link",program:"Factor",purpose:"pay link",tools:["factor_create_pay_link"],class:"auth",encoding:"eip191-template",primaryType:"factor.pay-link",types:{},fields:{agent:e("This wallet, in lowercase",{role:"signer"}),price:e("Job price in ETH, formatted exactly from your decimal wei argument",{role:"derived",rebuild:"factor.pay-link.price"}),title:e("Normalised job title from your request",{role:"derived",rebuild:"factor.pay-link.title"}),brief:e("Hash of the normalised brief bytes, or none for an empty brief",{role:"derived",rebuild:"factor.pay-link.brief"}),due:e("Whole hours after payment from your request",{role:"derived",rebuild:"factor.pay-link.due"}),early:e("Whether up to half may be drawn before delivery, from your request",{role:"derived",rebuild:"factor.pay-link.early"}),expires:e("Link expiry clamped to at most 30 days from the local creation time",{role:"expiry"}),id:e("Fresh 16 lowercase hexadecimal link id, bound to the continuation",{role:"nonce",kind:"local-random"})},maxLifetimeSeconds:2592e3,requireHuman:!0,submit:T},ne={id:"factor.open-job-apply",program:"Factor",purpose:"open job application",tools:["factor_apply_to_job"],class:"auth",encoding:"eip191-template",primaryType:"factor.open-job-apply",types:{},fields:{open:e("Open job id from your request",{role:"derived",rebuild:"factor.open-job-apply.open"}),agent:e("This wallet, in lowercase",{role:"signer"}),pitch:e("Normalised pitch from your request, or none when empty",{role:"derived",rebuild:"factor.open-job-apply.pitch"}),at:e("Factor state time, within 120 seconds of local creation; expiry is min(at + 600, createdAt + 600)",{role:"derived",rebuild:"factor.open-job-apply.time",yields:["expiry"]})},maxLifetimeSeconds:600,requireHuman:!0,submit:T},te=[ee,re,ne],oe={AgentWalletSet:[{name:"agentId",type:"uint256"},{name:"newWallet",type:"address"},{name:"owner",type:"address"},{name:"deadline",type:"uint256"}]},ie={agentId:e("Agent whose payment wallet becomes this wallet",{role:"observed",check:"equals the agentId argument and the continuation"}),newWallet:e("This wallet, the new payment wallet",{role:"signer"}),owner:e("Current agent owner named by the registry",{role:"observed",check:"the registry checks it on chain"}),deadline:e("Proof deadline (Unix seconds)",{role:"expiry"})},U=r=>({id:r==="mainnet"?"erc8004.agent-wallet-set":"erc8004.agent-wallet-set.testnet",program:"ERC-8004",purpose:"payment-wallet proof",tools:["erc8004_set_wallet"],class:"auth",encoding:"eip712",...r==="testnet"?{network:r}:{},domain:{name:"ERC8004IdentityRegistry",version:"1",chainId:c[r].chainId,verifyingContract:c[r].identityRegistry},primaryType:"AgentWalletSet",types:oe,fields:ie,maxLifetimeSeconds:420,submit:{by:"server-continuation",reason:"The proof is an argument of the setAgentWallet transaction the Oak server builds next."},requireHuman:!1}),ae=U("mainnet"),se=U("testnet"),de={id:"hookr.relay.swap-intent",program:"Hookr",purpose:"relayed trader swap intent",tools:["hookr_relay"],class:"relayed",encoding:"eip712",domain:{name:"Permit2",chainId:s,verifyingContract:f[s].ponsTrade.permit2.address},primaryType:"HookrSwapIntent",types:{},fields:{owner:e("The trader who signed; never this wallet",{role:"counterparty"}),intent:e("The trader-signed swap terms; every calldata byte is rebuilt from them",{role:"derived",rebuild:"hookr.relay.calldata"}),signature:e("The trader Permit2 witness signature; the forwarder verifies it in a simulation from this relayer",{role:"observed",check:"forwarder execute simulation at a pinned block"})},maxLifetimeSeconds:2592e3,contractHash:{fn:"hashIntent"},nonceRead:"isNonceUsed",submit:{by:"transaction"},relayedPaths:["signature"],requireHuman:!1},pe=A,le="Meridian perps activation requires protocol-verified signing and submission vectors. TradeOrder has unsigned expiry and execution flags; delegate authority is unbounded. These candidates remain disabled.",ce={by:"server-continuation",reason:"Today the Oak server holds the perps_sign round and posts to the Meridian API; local submission is adopted with the pending patch."},W={subaccount:"primary",subaccountId:"00000000-0000-4000-8000-000000000000"},ue="0x0000000000000000000000000000000000000001";function i(r,n,t,o,G,B,K={}){let g=I(o,{...W,...G},ue,"1",1);return{id:r,program:"Meridian",purpose:n,tools:[`meridian_perps_${o}`],class:t,encoding:"eip712",domain:{...S},primaryType:g.primaryType,types:{[g.primaryType]:Object.entries(g.fields).map(([Y,z])=>({name:Y,type:z}))},fields:B,maxLifetimeSeconds:3600,submit:ce,requireHuman:t!=="auth"&&t!=="cancel",enabled:!1,disabledReason:le,...K}}var a=e("This wallet, the account owner",{role:"signer"}),u=e("Subaccount name (bytes32) from your request",{role:"derived",rebuild:"meridian.perps.subaccount"}),d=e("Nanosecond nonce from the add-on clock; Meridian accepts it within 25 minutes",{role:"nonce",kind:"local-time"}),m=e("Signing time; Meridian accepts the signature for at most one hour after it",{role:"derived",rebuild:"meridian.perps.signed-at",yields:["expiry"]}),C={revoke:{none:"One-shot request: it cannot be cancelled and lapses within one hour.",staysExecutableUntilExpiry:!0}},me=[i("meridian.perps.trade-order","perps order","order","order",{type:"LIMIT",quantity:"1",price:"1",side:0,onchainId:1,timeInForce:"GTD"},{sender:a,subaccount:u,quantity:e("Order size in D9 contract units: the most this order can trade",{role:"amount",side:"out",token:"productId",arg:"quantity"}),price:e("Limit price (D9) from your request; 0 for market orders",{role:"derived",rebuild:"meridian.perps.intent"}),reduceOnly:e("Only reduces an open position",{role:"derived",rebuild:"meridian.perps.intent"}),side:e("0 buy, 1 sell",{role:"derived",rebuild:"meridian.perps.intent"}),engineType:e("Order engine",{role:"pinned",value:0}),productId:e("Meridian product traded",{role:"token",side:"out",arg:"onchainId"}),nonce:d,signedAt:e("Signing time (the resting-order expiry is the API option expiresAt)",{role:"observed",check:"within the Meridian acceptance window"})},{maxLifetimeSeconds:2592e3,expiry:{enforcedBy:"api",path:"data.expiresAt"},revoke:{offchainSpec:"meridian.perps.cancel-order",staysExecutableUntilExpiry:!0}}),i("meridian.perps.cancel-order","perps order cancel","cancel","cancel",{all:!0},{sender:a,subaccount:u,nonce:d},{expiryBinding:"cancel-only"}),i("meridian.perps.initiate-withdraw","perps withdrawal","order","withdraw",{token:"0x0000000000000000000000000000000000000002",tokenId:W.subaccountId,amount:"1"},{account:a,subaccount:u,token:e("Token withdrawn",{role:"token",side:"out",arg:"token"}),amount:e("Amount withdrawn (D9)",{role:"amount",side:"out",token:"token",arg:"amount"}),nonce:d,signedAt:m,destinationAddress:e("This wallet, padded to 32 bytes",{role:"recipient"}),destinationEndpointId:e("Same-chain withdrawal",{role:"pinned",value:0})},C),i("meridian.perps.convert-token","perps conversion","order","convert",{fromToken:"0x0000000000000000000000000000000000000002",toToken:"0x0000000000000000000000000000000000000003",amount:"1"},{sender:a,subaccount:u,fromToken:e("Quote token converted from",{role:"token",side:"out",arg:"fromToken"}),toToken:e("Quote token converted to",{role:"token",side:"in",arg:"toToken"}),amount:e("Amount converted (D9)",{role:"amount",side:"out",token:"fromToken",arg:"amount"}),nonce:d,signedAt:m},C),i("meridian.perps.revoke-linked-signer","linked-signer revocation","cancel","signer",{mode:"revoke",signer:"0x0000000000000000000000000000000000000003"},{sender:a,signer:e("Linked signer revoked",{role:"delegate"}),subaccount:u,nonce:d,signedAt:m}),i("meridian.perps.refresh-linked-signer","linked-signer refresh","link","signer",{mode:"refresh",signer:"0x0000000000000000000000000000000000000003"},{sender:a,signer:e("Linked signer refreshed",{role:"delegate"}),nonce:d,signedAt:m},{revoke:{offchainSpec:"meridian.perps.revoke-linked-signer",staysExecutableUntilExpiry:!1}}),i("meridian.perps.extend-linked-signer","linked-signer extension","link","signer",{mode:"extend"},{sender:a,nonce:d,signedAt:m},{revoke:{offchainSpec:"meridian.perps.revoke-linked-signer",staysExecutableUntilExpiry:!1}}),i("meridian.perps.referral-auth","referral API authentication","auth","referral",{mode:"activate"},{sender:a,intent:e("Referral action: 0 activate, 1 claim, 2 read",{role:"derived",rebuild:"meridian.perps.intent"}),signedAt:e("Signed time; the local round accepts now minus 120 through now plus 10 seconds",{role:"derived",rebuild:"meridian.perps.auth-time",yields:["expiry"]})},{expiryBinding:"auth-window",authWindow:{field:"signedAt",maxAgeSeconds:120,maxFutureSeconds:10}})],ye={id:"longbow.nft.lender-offer",program:"Longbow",purpose:"existing NFT lender offer",tools:["longbow_nft_accept_offer"],class:"relayed",encoding:"eip191-packed-hash",primaryType:"longbow.nft.fixed-offer",types:{},fields:{chainId:e("Robinhood Chain, included in the packed offer hash",{role:"pinned",value:s}),contract:e("DirectLoanFixedOffer, included in the packed offer hash",{role:"pinned",value:h}),offer:e("Exact loan, payoff, NFT, currency and fee terms rebuilt by nftOfferDigest",{role:"derived",rebuild:"longbow.nft.offer-digest"}),"lenderSignature.signer":e("Existing lender who signed the offer",{role:"counterparty"}),"lenderSignature.expiry":e("Existing lender offer expiry",{role:"expiry"}),"lenderSignature.nonce":e("Lender nonce checked against the pinned loan contract",{role:"nonce",kind:"program-counter"}),"lenderSignature.signature":e("Existing lender signature, verified by recovery or pinned-block ERC-1271 before preview",{role:"observed",check:"nftOfferDigest and lender verification in the local loan builder"})},maxLifetimeSeconds:2592e3,submit:{by:"transaction"},relayedPaths:["lenderSignature.signature"],requireHuman:!1},ge={id:"raeto.topup-transfer",program:"Raeto",purpose:"credit top-up",tools:["raeto_join","raeto_topup"],class:"order",encoding:"eip712",domain:p.usdgDomain,primaryType:"TransferWithAuthorization",types:D,fields:{from:e("This wallet, paying for credit",{role:"signer"}),to:e("Raeto payment recipient pinned by the local round validator",{role:"recipient"}),value:e("Exactly the approved whole-dollar amount in USDG base units",{role:"amount",side:"out",token:p.usdg,arg:"amount_usd"}),validAfter:e("Immediately valid",{role:"pinned",value:"0"}),validBefore:e("Payment deadline in chain Unix seconds",{role:"expiry"}),nonce:e("Fresh random 32-byte nonce; authorizationState must be false",{role:"nonce",kind:"local-random"})},maxLifetimeSeconds:300,nonceRead:"authorizationState",requireHuman:!0,revoke:{none:"One-shot payment authorization lapses within five minutes. Oak never signs cancellation.",staysExecutableUntilExpiry:!0},submit:{by:"addon",host:"api.raeto.cc",path:p.topupPath}},fe={id:"raeto.agent-signin",program:"Raeto",purpose:"agent sign-in",tools:["raeto_join","raeto_topup"],class:"auth",encoding:"eip191-template",primaryType:"raeto.agent-signin",types:{},fields:{wallet:e("This wallet, signing in",{role:"signer"}),nonce:e("Single-use nonce from the exact sign-in challenge",{role:"nonce",kind:"server-observed"})},expiry:{enforcedBy:"api",path:"challenge.expiresAt"},maxLifetimeSeconds:600,requireHuman:!1,submit:{by:"addon",host:"api.raeto.cc",path:"/v1/agents/login"}};function he(r){if(!r.pinned)return[];if(!r.endpoint)throw l("Raeto pairing endpoint is not pinned");if(!r.schema?.domain||!r.schema.types||!r.schema.fields)throw l("Raeto pairing typed-data schema is not pinned");return[{id:"raeto.record-pair",program:"Raeto",purpose:"public record pairing",tools:["raeto_join","raeto_topup"],class:"auth",encoding:"eip712",primaryType:b.primaryType,domain:r.schema.domain,types:r.schema.types,fields:r.schema.fields,maxLifetimeSeconds:600,requireHuman:!0,submit:{by:"addon",host:"api.raeto.cc",path:r.endpoint}}]}var Se=[ge,fe,...he(b)],w=[J,Z,$,X,ae,se,de,ye,...me,...Se,...te],be=[S.verifyingContract,pe,h,p.usdg,p.payTo],ve=q(w,F(be));if(ve.length)throw l("invalid signature registry");var k=new Map;for(let r of w)for(let n of r.tools)k.set(n,[...k.get(n)??[],r]);var j=new Map(w.map(r=>[y(r),r]));function _(r){return k.get(r)??[]}function Ne(r,n=_(r)){return n.some(t=>t.tools.includes(r)&&t.submit.by==="addon")}function De(r){return _(r).flatMap(n=>n.class==="relayed"&&n.enabled!==!1?n.relayedPaths??[]:[])}function Fe(r,n){let t=n?.domain?.chainId===c.testnet.chainId?"testnet":"mainnet",o=j.get(y({network:t==="testnet"?"testnet":void 0,encoding:"eip712",domain:n?.domain,primaryType:n?.primaryType}));if(!o||o.enabled===!1||!o.tools.includes(r)||o.class==="relayed")throw l("Oak has no signing contract for this request");return o}function qe(r){if(!r?.domain||typeof r.primaryType!="string")return;let n=r.domain.chainId===c.testnet.chainId?"testnet":void 0,t=j.get(y({network:n,encoding:"eip712",domain:r.domain,primaryType:r.primaryType}));return t?.class==="relayed"?void 0:t}function Ce(r){let n=_(r).find(t=>t.encoding==="eip191-template"&&t.enabled!==!1);if(!n)throw l("Oak has no signing contract for this request");return n}export{ae as ERC8004_WALLET_SET,se as ERC8004_WALLET_SET_TESTNET,ne as FACTOR_APPLICATION,re as FACTOR_PAY_LINK,ee as FACTOR_PROFILE,Le as FACTOR_SIGNATURE_TOOLS,te as FACTOR_SPECS,de as HOOKR_RELAYED_INTENT,ye as LONGBOW_RELAYED_OFFER,J as MERIDIAN_MINT_APPROVAL,me as MERIDIAN_PERPS_SPECS,Z as MERIDIAN_TRADE_APPROVAL,be as MODULE_PINS,$ as PRIORS_CONSENT,X as PRIORS_SEAT_PROOF,fe as RAETO_AGENT_SIGNIN,Se as RAETO_SIGNATURE_SPECS,ge as RAETO_TOPUP_TRANSFER,w as SIGNATURE_SPECS,De as relayedSignaturePaths,Ce as specForMessage,qe as specForStruct,Fe as specForTypedData,_ as specsForTool,Ne as submitsFromAddon};
|
|
1
|
+
import{d as l,g as F,i as q,j as y}from"../chunks/CG7ABZXH.js";import{a as D}from"../chunks/HKHCN4A2.js";import"../chunks/UCFVPTE2.js";import"../chunks/C4XK764N.js";import"../chunks/FWOGOWUM.js";import{a as p,b}from"../chunks/3CH2IPQL.js";import"../chunks/52AEVHKJ.js";import"../chunks/2H2OZE6X.js";import"../chunks/RLX6YTNT.js";import"../chunks/O7L55XM3.js";import"../chunks/W73SLWBT.js";import"../chunks/UCMOQAVD.js";import"../chunks/LHVGWNMW.js";import{b as N}from"../chunks/ORKXBYVC.js";import"../chunks/XD4JA43O.js";import"../chunks/BWE5PXRE.js";import{f as O,g as P,o as L}from"../chunks/OD7CY6BY.js";import{a as R,b as E}from"../chunks/UPX3OWKA.js";import{e as I}from"../chunks/O7HCEPQY.js";import{e as S}from"../chunks/46KWRAYK.js";import{a as h}from"../chunks/QBHY2QRC.js";import"../chunks/UNBRUWSV.js";import"../chunks/G2LAO23N.js";import"../chunks/2GXHYI23.js";import{e as A}from"../chunks/37UBQQWL.js";import"../chunks/OUXPOFY2.js";import"../chunks/KHOUBQJK.js";import"../chunks/6STUQOFL.js";import"../chunks/GV6Z3MET.js";import"../chunks/4P6DRKY3.js";import"../chunks/GV6FZ6UG.js";import"../chunks/HC3QFA5I.js";import"../chunks/QFUSCK5C.js";import"../chunks/VS7ZA4OF.js";import"../chunks/B75SS7H6.js";import"../chunks/TTBB6EFN.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GVCNTGLC.js";import"../chunks/KKGHXNM4.js";import"../chunks/3XY44BP5.js";import"../chunks/LD3A2KLN.js";import"../chunks/3RGED2KO.js";import"../chunks/UMY6SP7C.js";import"../chunks/CJMVRV34.js";import"../chunks/7WXAS54T.js";import"../chunks/LIUXNOLP.js";import"../chunks/B7WZJHIJ.js";import"../chunks/TNHU5UBQ.js";import"../chunks/HGSFRN57.js";import"../chunks/QFK335LC.js";import"../chunks/ICHT3H3W.js";import"../chunks/7AYP4ATZ.js";import"../chunks/PG7HZIZL.js";import"../chunks/S65KXMZ7.js";import"../chunks/CW37EGPL.js";import"../chunks/K6D6SDIG.js";import"../chunks/QA6Z2CYP.js";import"../chunks/CFPJDLTZ.js";import"../chunks/5N6YJFFA.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/EZUQMTLE.js";import"../chunks/5RXALTDT.js";import{b as s,j as f,t as c}from"../chunks/EWZFZUVF.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";import{zeroAddress as Q}from"viem";var e=(r,n)=>({...n,meaning:r}),x=f[s].meridian,V=x.CollateralToken_USDe.address,H={by:"server-continuation",reason:"Meridian Predict settles RFQ approvals over a WebSocket auction session that the Oak server holds."},M={none:"Single-use auction approval: it cannot be cancelled and lapses at its deadline.",staysExecutableUntilExpiry:!0},J={id:"meridian.rfq.mint-approval",program:"Meridian",purpose:"prediction buy approval",tools:["meridian_buy"],class:"order",encoding:"eip712",domain:{name:"PredictionMarketEscrow",version:"1",chainId:s,verifyingContract:x.PredictionMarketEscrow.address},primaryType:"MintApproval",types:{MintApproval:R},fields:{predictionHash:e("Hash of your picks, stake, the counterparty and its collateral, rebuilt locally from your request and the winning bid",{role:"derived",rebuild:"meridian.rfq.prediction-hash",yields:["counterparty"]}),signer:e("This wallet, the approving trader",{role:"signer"}),collateral:e("Your stake: the most USDe the escrow can take",{role:"amount",side:"out",token:V,arg:"stake"}),nonce:e("Escrow nonce chosen by the auction",{role:"nonce",kind:"server-observed"}),deadline:e("Approval deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:3600,revoke:M,submit:H,requireHuman:!0},Z={id:"meridian.rfq.trade-approval",program:"Meridian",purpose:"prediction sale approval",tools:["meridian_sell"],class:"order",encoding:"eip712",domain:{name:"SecondaryMarketEscrow",version:"1",chainId:s,verifyingContract:x.SecondaryMarketEscrow.address},primaryType:"TradeApproval",types:{TradeApproval:E},fields:{tradeHash:e("Hash of the position token and amount you sell, the buyer and the USDe price, rebuilt locally",{role:"derived",rebuild:"meridian.rfq.trade-hash",yields:["token-out","amount-out","token-in","amount-in","counterparty"]}),signer:e("This wallet, the seller",{role:"signer"}),nonce:e("Escrow nonce chosen by the auction",{role:"nonce",kind:"server-observed"}),deadline:e("Approval deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:3600,revoke:M,submit:H,requireHuman:!0},v=L({agentId:"1",owner:Q,nonce:"0",deadline:"0"}),$={id:"priors.consent",program:"Priors",purpose:"pool consent",tools:["priors_starter_line",...N],class:"consent",encoding:"eip712",domain:{...v.domain},primaryType:v.primaryType,types:v.types,fields:{agentId:e("Your agent ID the consent is for",{role:"observed",check:"equals the agentId argument"}),sponsorId:e("Sponsor root that may use this consent",{role:"observed",check:"treasury v4 root, or the feature root or sponsorId argument"}),owner:e("This wallet, the agent owner",{role:"account"}),maxPremiumBps:e("Largest premium the sponsor may charge, in basis points",{role:"observed",check:"equals the maxPremiumBps argument (starter line: 0)"}),nonce:e("Priors pool nonce for this agent",{role:"nonce",kind:"program-counter"}),deadline:e("Consent deadline (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:P+300,submit:{by:"transaction"},requireHuman:!0},X={id:"priors.seat-proof",program:"Priors",purpose:"agent ownership proof",tools:["priors_starter_line"],class:"auth",encoding:"eip191-template",primaryType:"priors.seat-request",types:{},fields:{agentId:e("Your agent ID",{role:"observed",check:"equals the agentId argument"}),n:e("Invite bot nonce",{role:"nonce",kind:"server-observed"}),exp:e("Proof expiry (Unix seconds)",{role:"expiry"})},maxLifetimeSeconds:O+300,submit:{by:"server-continuation",reason:"The Priors invite bot receives the ownership proof through the Oak server session."},requireHuman:!1},Le=new Set(["factor_sign_up","factor_create_pay_link","factor_apply_to_job"]),T={by:"server-continuation",reason:"Oak hosts Factor API reads, pacing and engine posts; the module verifies the wallet signature before posting."},ee={id:"factor.agent-profile",program:"Factor",purpose:"agent profile",tools:["factor_sign_up"],class:"auth",encoding:"eip191-template",primaryType:"factor.agent-profile",types:{},fields:{address:e("This wallet, in lowercase",{role:"signer"}),name:e("Normalised agent name from your request",{role:"derived",rebuild:"factor.agent-profile.name"}),does:e("Normalised work description from your request",{role:"derived",rebuild:"factor.agent-profile.does"}),at:e("Factor state time, within 120 seconds of local creation; expiry is min(at + 600, createdAt + 600)",{role:"derived",rebuild:"factor.agent-profile.time",yields:["expiry"]})},maxLifetimeSeconds:600,requireHuman:!0,submit:T},re={id:"factor.pay-link",program:"Factor",purpose:"pay link",tools:["factor_create_pay_link"],class:"auth",encoding:"eip191-template",primaryType:"factor.pay-link",types:{},fields:{agent:e("This wallet, in lowercase",{role:"signer"}),price:e("Job price in ETH, formatted exactly from your decimal wei argument",{role:"derived",rebuild:"factor.pay-link.price"}),title:e("Normalised job title from your request",{role:"derived",rebuild:"factor.pay-link.title"}),brief:e("Hash of the normalised brief bytes, or none for an empty brief",{role:"derived",rebuild:"factor.pay-link.brief"}),due:e("Whole hours after payment from your request",{role:"derived",rebuild:"factor.pay-link.due"}),early:e("Whether up to half may be drawn before delivery, from your request",{role:"derived",rebuild:"factor.pay-link.early"}),expires:e("Link expiry clamped to at most 30 days from the local creation time",{role:"expiry"}),id:e("Fresh 16 lowercase hexadecimal link id, bound to the continuation",{role:"nonce",kind:"local-random"})},maxLifetimeSeconds:2592e3,requireHuman:!0,submit:T},ne={id:"factor.open-job-apply",program:"Factor",purpose:"open job application",tools:["factor_apply_to_job"],class:"auth",encoding:"eip191-template",primaryType:"factor.open-job-apply",types:{},fields:{open:e("Open job id from your request",{role:"derived",rebuild:"factor.open-job-apply.open"}),agent:e("This wallet, in lowercase",{role:"signer"}),pitch:e("Normalised pitch from your request, or none when empty",{role:"derived",rebuild:"factor.open-job-apply.pitch"}),at:e("Factor state time, within 120 seconds of local creation; expiry is min(at + 600, createdAt + 600)",{role:"derived",rebuild:"factor.open-job-apply.time",yields:["expiry"]})},maxLifetimeSeconds:600,requireHuman:!0,submit:T},te=[ee,re,ne],oe={AgentWalletSet:[{name:"agentId",type:"uint256"},{name:"newWallet",type:"address"},{name:"owner",type:"address"},{name:"deadline",type:"uint256"}]},ie={agentId:e("Agent whose payment wallet becomes this wallet",{role:"observed",check:"equals the agentId argument and the continuation"}),newWallet:e("This wallet, the new payment wallet",{role:"signer"}),owner:e("Current agent owner named by the registry",{role:"observed",check:"the registry checks it on chain"}),deadline:e("Proof deadline (Unix seconds)",{role:"expiry"})},U=r=>({id:r==="mainnet"?"erc8004.agent-wallet-set":"erc8004.agent-wallet-set.testnet",program:"ERC-8004",purpose:"payment-wallet proof",tools:["erc8004_set_wallet"],class:"auth",encoding:"eip712",...r==="testnet"?{network:r}:{},domain:{name:"ERC8004IdentityRegistry",version:"1",chainId:c[r].chainId,verifyingContract:c[r].identityRegistry},primaryType:"AgentWalletSet",types:oe,fields:ie,maxLifetimeSeconds:420,submit:{by:"server-continuation",reason:"The proof is an argument of the setAgentWallet transaction the Oak server builds next."},requireHuman:!1}),ae=U("mainnet"),se=U("testnet"),de={id:"hookr.relay.swap-intent",program:"Hookr",purpose:"relayed trader swap intent",tools:["hookr_relay"],class:"relayed",encoding:"eip712",domain:{name:"Permit2",chainId:s,verifyingContract:f[s].ponsTrade.permit2.address},primaryType:"HookrSwapIntent",types:{},fields:{owner:e("The trader who signed; never this wallet",{role:"counterparty"}),intent:e("The trader-signed swap terms; every calldata byte is rebuilt from them",{role:"derived",rebuild:"hookr.relay.calldata"}),signature:e("The trader Permit2 witness signature; the forwarder verifies it in a simulation from this relayer",{role:"observed",check:"forwarder execute simulation at a pinned block"})},maxLifetimeSeconds:2592e3,contractHash:{fn:"hashIntent"},nonceRead:"isNonceUsed",submit:{by:"transaction"},relayedPaths:["signature"],requireHuman:!1},pe=A,le="Meridian perps activation requires protocol-verified signing and submission vectors. TradeOrder has unsigned expiry and execution flags; delegate authority is unbounded. These candidates remain disabled.",ce={by:"server-continuation",reason:"Today the Oak server holds the perps_sign round and posts to the Meridian API; local submission is adopted with the pending patch."},W={subaccount:"primary",subaccountId:"00000000-0000-4000-8000-000000000000"},ue="0x0000000000000000000000000000000000000001";function i(r,n,t,o,G,B,K={}){let g=I(o,{...W,...G},ue,"1",1);return{id:r,program:"Meridian",purpose:n,tools:[`meridian_perps_${o}`],class:t,encoding:"eip712",domain:{...S},primaryType:g.primaryType,types:{[g.primaryType]:Object.entries(g.fields).map(([Y,z])=>({name:Y,type:z}))},fields:B,maxLifetimeSeconds:3600,submit:ce,requireHuman:t!=="auth"&&t!=="cancel",enabled:!1,disabledReason:le,...K}}var a=e("This wallet, the account owner",{role:"signer"}),u=e("Subaccount name (bytes32) from your request",{role:"derived",rebuild:"meridian.perps.subaccount"}),d=e("Nanosecond nonce from the add-on clock; Meridian accepts it within 25 minutes",{role:"nonce",kind:"local-time"}),m=e("Signing time; Meridian accepts the signature for at most one hour after it",{role:"derived",rebuild:"meridian.perps.signed-at",yields:["expiry"]}),C={revoke:{none:"One-shot request: it cannot be cancelled and lapses within one hour.",staysExecutableUntilExpiry:!0}},me=[i("meridian.perps.trade-order","perps order","order","order",{type:"LIMIT",quantity:"1",price:"1",side:0,onchainId:1,timeInForce:"GTD"},{sender:a,subaccount:u,quantity:e("Order size in D9 contract units: the most this order can trade",{role:"amount",side:"out",token:"productId",arg:"quantity"}),price:e("Limit price (D9) from your request; 0 for market orders",{role:"derived",rebuild:"meridian.perps.intent"}),reduceOnly:e("Only reduces an open position",{role:"derived",rebuild:"meridian.perps.intent"}),side:e("0 buy, 1 sell",{role:"derived",rebuild:"meridian.perps.intent"}),engineType:e("Order engine",{role:"pinned",value:0}),productId:e("Meridian product traded",{role:"token",side:"out",arg:"onchainId"}),nonce:d,signedAt:e("Signing time (the resting-order expiry is the API option expiresAt)",{role:"observed",check:"within the Meridian acceptance window"})},{maxLifetimeSeconds:2592e3,expiry:{enforcedBy:"api",path:"data.expiresAt"},revoke:{offchainSpec:"meridian.perps.cancel-order",staysExecutableUntilExpiry:!0}}),i("meridian.perps.cancel-order","perps order cancel","cancel","cancel",{all:!0},{sender:a,subaccount:u,nonce:d},{expiryBinding:"cancel-only"}),i("meridian.perps.initiate-withdraw","perps withdrawal","order","withdraw",{token:"0x0000000000000000000000000000000000000002",tokenId:W.subaccountId,amount:"1"},{account:a,subaccount:u,token:e("Token withdrawn",{role:"token",side:"out",arg:"token"}),amount:e("Amount withdrawn (D9)",{role:"amount",side:"out",token:"token",arg:"amount"}),nonce:d,signedAt:m,destinationAddress:e("This wallet, padded to 32 bytes",{role:"recipient"}),destinationEndpointId:e("Same-chain withdrawal",{role:"pinned",value:0})},C),i("meridian.perps.convert-token","perps conversion","order","convert",{fromToken:"0x0000000000000000000000000000000000000002",toToken:"0x0000000000000000000000000000000000000003",amount:"1"},{sender:a,subaccount:u,fromToken:e("Quote token converted from",{role:"token",side:"out",arg:"fromToken"}),toToken:e("Quote token converted to",{role:"token",side:"in",arg:"toToken"}),amount:e("Amount converted (D9)",{role:"amount",side:"out",token:"fromToken",arg:"amount"}),nonce:d,signedAt:m},C),i("meridian.perps.revoke-linked-signer","linked-signer revocation","cancel","signer",{mode:"revoke",signer:"0x0000000000000000000000000000000000000003"},{sender:a,signer:e("Linked signer revoked",{role:"delegate"}),subaccount:u,nonce:d,signedAt:m}),i("meridian.perps.refresh-linked-signer","linked-signer refresh","link","signer",{mode:"refresh",signer:"0x0000000000000000000000000000000000000003"},{sender:a,signer:e("Linked signer refreshed",{role:"delegate"}),nonce:d,signedAt:m},{revoke:{offchainSpec:"meridian.perps.revoke-linked-signer",staysExecutableUntilExpiry:!1}}),i("meridian.perps.extend-linked-signer","linked-signer extension","link","signer",{mode:"extend"},{sender:a,nonce:d,signedAt:m},{revoke:{offchainSpec:"meridian.perps.revoke-linked-signer",staysExecutableUntilExpiry:!1}}),i("meridian.perps.referral-auth","referral API authentication","auth","referral",{mode:"activate"},{sender:a,intent:e("Referral action: 0 activate, 1 claim, 2 read",{role:"derived",rebuild:"meridian.perps.intent"}),signedAt:e("Signed time; the local round accepts now minus 120 through now plus 10 seconds",{role:"derived",rebuild:"meridian.perps.auth-time",yields:["expiry"]})},{expiryBinding:"auth-window",authWindow:{field:"signedAt",maxAgeSeconds:120,maxFutureSeconds:10}})],ye={id:"longbow.nft.lender-offer",program:"Longbow",purpose:"existing NFT lender offer",tools:["longbow_nft_accept_offer"],class:"relayed",encoding:"eip191-packed-hash",primaryType:"longbow.nft.fixed-offer",types:{},fields:{chainId:e("Robinhood Chain, included in the packed offer hash",{role:"pinned",value:s}),contract:e("DirectLoanFixedOffer, included in the packed offer hash",{role:"pinned",value:h}),offer:e("Exact loan, payoff, NFT, currency and fee terms rebuilt by nftOfferDigest",{role:"derived",rebuild:"longbow.nft.offer-digest"}),"lenderSignature.signer":e("Existing lender who signed the offer",{role:"counterparty"}),"lenderSignature.expiry":e("Existing lender offer expiry",{role:"expiry"}),"lenderSignature.nonce":e("Lender nonce checked against the pinned loan contract",{role:"nonce",kind:"program-counter"}),"lenderSignature.signature":e("Existing lender signature, verified by recovery or pinned-block ERC-1271 before preview",{role:"observed",check:"nftOfferDigest and lender verification in the local loan builder"})},maxLifetimeSeconds:2592e3,submit:{by:"transaction"},relayedPaths:["lenderSignature.signature"],requireHuman:!1},ge={id:"raeto.topup-transfer",program:"Raeto",purpose:"credit top-up",tools:["raeto_join","raeto_topup"],class:"order",encoding:"eip712",domain:p.usdgDomain,primaryType:"TransferWithAuthorization",types:D,fields:{from:e("This wallet, paying for credit",{role:"signer"}),to:e("Raeto payment recipient pinned by the local round validator",{role:"recipient"}),value:e("Exactly the approved whole-dollar amount in USDG base units",{role:"amount",side:"out",token:p.usdg,arg:"amount_usd"}),validAfter:e("Immediately valid",{role:"pinned",value:"0"}),validBefore:e("Payment deadline in chain Unix seconds",{role:"expiry"}),nonce:e("Fresh random 32-byte nonce; authorizationState must be false",{role:"nonce",kind:"local-random"})},maxLifetimeSeconds:300,nonceRead:"authorizationState",requireHuman:!0,revoke:{none:"One-shot payment authorization lapses within five minutes. Oak never signs cancellation.",staysExecutableUntilExpiry:!0},submit:{by:"addon",host:"api.raeto.cc",path:p.topupPath}},fe={id:"raeto.agent-signin",program:"Raeto",purpose:"agent sign-in",tools:["raeto_join","raeto_topup"],class:"auth",encoding:"eip191-template",primaryType:"raeto.agent-signin",types:{},fields:{wallet:e("This wallet, signing in",{role:"signer"}),nonce:e("Single-use nonce from the exact sign-in challenge",{role:"nonce",kind:"server-observed"})},expiry:{enforcedBy:"api",path:"challenge.expiresAt"},maxLifetimeSeconds:600,requireHuman:!1,submit:{by:"addon",host:"api.raeto.cc",path:"/v1/agents/login"}};function he(r){if(!r.pinned)return[];if(!r.endpoint)throw l("Raeto pairing endpoint is not pinned");if(!r.schema?.domain||!r.schema.types||!r.schema.fields)throw l("Raeto pairing typed-data schema is not pinned");return[{id:"raeto.record-pair",program:"Raeto",purpose:"public record pairing",tools:["raeto_join","raeto_topup"],class:"auth",encoding:"eip712",primaryType:b.primaryType,domain:r.schema.domain,types:r.schema.types,fields:r.schema.fields,maxLifetimeSeconds:600,requireHuman:!0,submit:{by:"addon",host:"api.raeto.cc",path:r.endpoint}}]}var Se=[ge,fe,...he(b)],w=[J,Z,$,X,ae,se,de,ye,...me,...Se,...te],be=[S.verifyingContract,pe,h,p.usdg,p.payTo],ve=q(w,F(be));if(ve.length)throw l("invalid signature registry");var k=new Map;for(let r of w)for(let n of r.tools)k.set(n,[...k.get(n)??[],r]);var j=new Map(w.map(r=>[y(r),r]));function _(r){return k.get(r)??[]}function Ne(r,n=_(r)){return n.some(t=>t.tools.includes(r)&&t.submit.by==="addon")}function De(r){return _(r).flatMap(n=>n.class==="relayed"&&n.enabled!==!1?n.relayedPaths??[]:[])}function Fe(r,n){let t=n?.domain?.chainId===c.testnet.chainId?"testnet":"mainnet",o=j.get(y({network:t==="testnet"?"testnet":void 0,encoding:"eip712",domain:n?.domain,primaryType:n?.primaryType}));if(!o||o.enabled===!1||!o.tools.includes(r)||o.class==="relayed")throw l("Oak has no signing contract for this request");return o}function qe(r){if(!r?.domain||typeof r.primaryType!="string")return;let n=r.domain.chainId===c.testnet.chainId?"testnet":void 0,t=j.get(y({network:n,encoding:"eip712",domain:r.domain,primaryType:r.primaryType}));return t?.class==="relayed"?void 0:t}function Ce(r){let n=_(r).find(t=>t.encoding==="eip191-template"&&t.enabled!==!1);if(!n)throw l("Oak has no signing contract for this request");return n}export{ae as ERC8004_WALLET_SET,se as ERC8004_WALLET_SET_TESTNET,ne as FACTOR_APPLICATION,re as FACTOR_PAY_LINK,ee as FACTOR_PROFILE,Le as FACTOR_SIGNATURE_TOOLS,te as FACTOR_SPECS,de as HOOKR_RELAYED_INTENT,ye as LONGBOW_RELAYED_OFFER,J as MERIDIAN_MINT_APPROVAL,me as MERIDIAN_PERPS_SPECS,Z as MERIDIAN_TRADE_APPROVAL,be as MODULE_PINS,$ as PRIORS_CONSENT,X as PRIORS_SEAT_PROOF,fe as RAETO_AGENT_SIGNIN,Se as RAETO_SIGNATURE_SPECS,ge as RAETO_TOPUP_TRANSFER,w as SIGNATURE_SPECS,De as relayedSignaturePaths,Ce as specForMessage,qe as specForStruct,Fe as specForTypedData,_ as specsForTool,Ne as submitsFromAddon};
|
package/build/dist/api/tokens.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"../chunks/
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r}from"../chunks/GV6FZ6UG.js";import"../chunks/HC3QFA5I.js";import"../chunks/QFUSCK5C.js";import"../chunks/VS7ZA4OF.js";import"../chunks/B75SS7H6.js";import"../chunks/TTBB6EFN.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GVCNTGLC.js";import"../chunks/KKGHXNM4.js";import"../chunks/3XY44BP5.js";import"../chunks/LD3A2KLN.js";import"../chunks/3RGED2KO.js";import"../chunks/UMY6SP7C.js";import"../chunks/CJMVRV34.js";import"../chunks/7WXAS54T.js";import"../chunks/LIUXNOLP.js";import"../chunks/B7WZJHIJ.js";import"../chunks/TNHU5UBQ.js";import"../chunks/HGSFRN57.js";import"../chunks/QFK335LC.js";import"../chunks/ICHT3H3W.js";import"../chunks/7AYP4ATZ.js";import"../chunks/PG7HZIZL.js";import"../chunks/CFPJDLTZ.js";import"../chunks/5N6YJFFA.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/EZUQMTLE.js";import"../chunks/5RXALTDT.js";import"../chunks/EWZFZUVF.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{f as CHOP_TOKENS,l as MULTICALL3_ABI,b as NATIVE_ETH_TOKEN,a as STOCK_ASSETS_URL,e as USDE_TOKEN,c as USDG_TOKEN,d as WETH_TOKEN,i as assertOfficialStockIdentity,n as discoverReceivedTokenAddresses,k as fetchOfficialStockTokens,q as findToken,m as getBalances,j as getOfficialStockTokens,p as getReceivedTokenBalances,g as parseOfficialStockAssets,r as resolveQuoteToken,o as unreadableTokensNotice,h as verifyOfficialStockToken};
|
|
@@ -4,6 +4,7 @@ export { isRelayFundingBootstrap as isFundingBootstrap } from './modules/relay/b
|
|
|
4
4
|
export declare const COMING_SOON: ReadonlyMap<string, string>;
|
|
5
5
|
export declare const FIND_TOOL = "find_tool";
|
|
6
6
|
export declare const RUN_TOOL = "run_tool";
|
|
7
|
+
export declare const MERKL_READ_TOOLS: readonly string[];
|
|
7
8
|
export declare const UPOCH_READ_TOOLS: readonly string[];
|
|
8
9
|
export declare const LOCAL_TOOLS: readonly string[];
|
|
9
10
|
export declare const VISIBLE_TOOLS: Readonly<Record<string, readonly string[]>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i}from"../chunks/
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j}from"../chunks/B5B7U3NZ.js";import{a}from"../chunks/LFSNAQ7V.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/EWZFZUVF.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{c as COMING_SOON,d as FIND_TOOL,h as LOCAL_TOOLS,f as MERKL_READ_TOOLS,e as RUN_TOOL,g as UPOCH_READ_TOOLS,i as VISIBLE_TOOLS,a as isFundingBootstrap,b as isReadDiscovery,j as visibleTools};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunks/
|
|
1
|
+
import{a}from"../chunks/W3M4KAPX.js";import"../chunks/OUXPOFY2.js";import"../chunks/KHOUBQJK.js";import"../chunks/6STUQOFL.js";import"../chunks/GV6Z3MET.js";import"../chunks/4P6DRKY3.js";import"../chunks/GV6FZ6UG.js";import"../chunks/HC3QFA5I.js";import"../chunks/QFUSCK5C.js";import"../chunks/VS7ZA4OF.js";import"../chunks/B75SS7H6.js";import"../chunks/TTBB6EFN.js";import"../chunks/CQ5WRWV4.js";import"../chunks/IV4K7FMD.js";import"../chunks/GVCNTGLC.js";import"../chunks/KKGHXNM4.js";import"../chunks/3XY44BP5.js";import"../chunks/LD3A2KLN.js";import"../chunks/3RGED2KO.js";import"../chunks/UMY6SP7C.js";import"../chunks/CJMVRV34.js";import"../chunks/7WXAS54T.js";import"../chunks/LIUXNOLP.js";import"../chunks/B7WZJHIJ.js";import"../chunks/TNHU5UBQ.js";import"../chunks/HGSFRN57.js";import"../chunks/QFK335LC.js";import"../chunks/ICHT3H3W.js";import"../chunks/7AYP4ATZ.js";import"../chunks/PG7HZIZL.js";import"../chunks/S65KXMZ7.js";import"../chunks/CW37EGPL.js";import"../chunks/K6D6SDIG.js";import"../chunks/QA6Z2CYP.js";import"../chunks/CFPJDLTZ.js";import"../chunks/5N6YJFFA.js";import"../chunks/P4UQGWCP.js";import"../chunks/SPJCSEKP.js";import"../chunks/Z25UKUJF.js";import"../chunks/43LI5NKJ.js";import"../chunks/IOYRL6AY.js";import"../chunks/SCG5HWMN.js";import"../chunks/5TUXSOMI.js";import"../chunks/66F5ZH34.js";import"../chunks/NWNYJ26T.js";import"../chunks/IX3GZMTM.js";import"../chunks/5HCXZWUH.js";import"../chunks/EZUQMTLE.js";import"../chunks/5RXALTDT.js";import"../chunks/EWZFZUVF.js";import"../chunks/XSD5NL7J.js";import"../chunks/JXOEJPJ4.js";import"../chunks/63YRSLDK.js";export{a as estimateUsd};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as j}from"./JTWJT2O3.js";import{h as me,k as ke}from"./2GXHYI23.js";import{b as S}from"./5PNFV7HH.js";import{b as le}from"./SPJCSEKP.js";import{a as _}from"./43LI5NKJ.js";import{g as B,i as ue}from"./NWNYJ26T.js";import{b as H}from"./IX3GZMTM.js";import{b as d,j as N}from"./EWZFZUVF.js";import{a as u}from"./XSD5NL7J.js";import{a as de}from"./JXOEJPJ4.js";import{encodeFunctionData as K,erc20Abi as pe,getAddress as m,isAddress as ye,parseAbi as U,zeroAddress as fe}from"viem";var T=m(N[d].hoodlock.locker.address),F=m(N[d].hoodlock.burner.address),v=m(N[d].hoodlock.liquidityLocker.address),O=m(N[d].uniswap.v3_position_manager.address),V=m(N[d].uniswap.v4_position_manager.address),We="0x000000000000000000000000000000000000dEaD",$e=3153600000n,Le=1000000000000n,we=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),te=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),q=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),Se=U(["function approve(address to, uint256 tokenId)"]);function xe(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function ge(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${xe(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new u(`Provide a valid ${o} contract address.`);if(!ye(e,{strict:!1}))throw new u(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new u(e.plainError(t))}}function ve(e){let o=H(e);if(o<=0n)throw new u("Amount must be greater than zero.");return o}async function be(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new u("Could not read the current chain timestamp. Please try again.");return o.timestamp}function he(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new u("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Le)throw new u("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new u(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+$e;if(t>a)throw new u(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function ie(e,o,t=d){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:pe,functionName:"symbol"}),e.readContract({address:a,abi:pe,functionName:"decimals"})]);return{address:a,symbol:de(String(k)),decimals:Number(i),chainId:t}}function Ie(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>we)throw new u("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new u(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Pe(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function Ce(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?V:O,g=i===V;if(i!==O&&!g)throw new u(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new u("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new u("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new u("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new u("Provide an NFT tokenId as a decimal string.");let p=String(o.tokenId).trim(),c=H(p),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),w=e.clientFor(d),[x,I,h]=await Promise.all([be(w),w.readContract({address:v,abi:q,functionName:"fixedFee"}),w.readContract({address:v,abi:q,functionName:"collectFeeBps"})]),y,$=!0;if(g){let C=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([w.readContract({address:i,abi:C,functionName:"getPoolAndPositionInfo",args:[c]}),w.readContract({address:i,abi:C,functionName:"getPositionLiquidity",args:[c]}),w.readContract({address:i,abi:C,functionName:"ownerOf",args:[c]})]);if(m(M)!==a)throw new u("This wallet does not own that v4 position NFT.");if(J<=0n)throw new u("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===fe||await w.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new u(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=he(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>we)throw new u(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let C=H(String(o.maxFee));if(n>C)throw new u(`Live fixedFee (${n}) exceeds maxFee (${C}).`)}let f=Ie(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:K({abi:Se,functionName:"approve",args:[v,c]}),value:"0",chainId:d,description:`Approve Uniswap ${s} position NFT #${c} on ${i} for HoodLock LiquidityLocker ${v}.`}),P=e.unsignedTx({to:v,data:K({abi:q,functionName:"lock",args:[i,c,A,l,b,f]}),value:n.toString(),chainId:d,description:`Lock Uniswap ${s} NFT #${c} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,P],z=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${c} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${f}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return j(e,{txs:z.txs,summary:Q,preview:z,kind:s,contract:v,manager:i,tokenId:c.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:f,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Fe(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(d),[g,b,s]=await Promise.all([be(i),i.readContract({address:T,abi:D,functionName:"fee"}),ie(i,k,d)]),p=ve(o.amount),c=he(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new u(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let w=e.approval(s.address,T,p.toString(),d),x=e.unsignedTx({to:T,data:K({abi:D,functionName:"lock",args:[s.address,p,c]}),value:l.toString(),chainId:d,description:`Lock ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) in HoodLock Locker ${T} until ${c} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[w,x],h=await e.preview(I,a),y=ge(e,h.changes),$=`Approve and lock ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${c}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return j(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:p.toString(),unlockTime:c.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Re(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Pe(o)?Ce(e,o,t):Fe(e,o,t))}}}function Ne(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(d),[g,b,s]=await Promise.all([i.readContract({address:F,abi:te,functionName:"fee"}),i.readContract({address:F,abi:te,functionName:"DEAD"}),ie(i,k,d)]),p=ve(o.amount),c=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(c>A)throw new u(`Live burn fee (${c}) exceeds maxFee (${A}).`)}let w=e.approval(s.address,F,p.toString(),d),x=e.unsignedTx({to:F,data:K({abi:te,functionName:"burn",args:[s.address,p]}),value:c.toString(),chainId:d,description:`Send ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${F} (totalSupply is unchanged) with exact fee ${e.formatAmount(c.toString(),S.decimals)} ETH (${c} wei).`}),I=[w,x],h=await e.preview(I,a),y=ge(e,h.changes),$=`Approve and send ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${F}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(c.toString(),S.decimals)} ETH (${c} wei). Preview changes: ${y}.`;return j(e,{txs:h.txs,summary:$,preview:h,contract:F,deadAddress:l,token:s,amount:p.toString(),fee:{token:S,amount:c.toString()},totalSupplyReduced:!1},F,c)})}}}async function Ae(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(d),g=[],b=new Set,s=n=>{for(let r of n){let f=r.toString();b.has(f)||(b.add(f),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let c=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,w=async n=>{let r=n.toLowerCase(),f=l.get(r);if(f)return f;let L=n===fe?S:await ie(i,n,d);return l.set(r,L),L},x=[],I=[];for(let n of c){let r=await w(n.token),f=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:f};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:d,owner:n.owner,token:r,amount:f,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:d,assets:[R],economics:{principal:[me("locked",{token:r,amount:f,source:"hoodlock.lock.amount",dueAt:L})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`HoodLock token lock #${n.id} of ${e.formatAmount(f,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:q,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:q,functionName:"getLock",args:[n]}),[f,L,R,P,X,z,Q,C,Y,J]=r,M=m(f);if(z||!B(M,a))continue;let re=m(C),se=m(Y);if(k&&!B(re,k)&&!B(se,k))continue;let[Z,ee]=await Promise.all([w(re),w(se)]),ae=m(Q),ce=Number(R),oe=BigInt(L).toString(),ne=BigInt(J).toString();$.push({lockId:n.toString(),kind:P?"v4":"v3",contract:v,manager:P?V:O,chainId:d,owner:M,tokenId:ne,unlockTime:oe,collectFeeBps:ce,feeRecipient:ae,hookVerified:!!X,token0:Z,token1:ee,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:d,assets:[{token:{address:P?V:O,symbol:`UNI-${P?"V4":"V3"} #${ne}`,decimals:0,chainId:d},amount:"1"}],economics:{principal:[],debt:[],rewards:[],backing:[Z,ee].map(Te=>ke({token:Te,amount:null,source:"hoodlock.lpLock.underlying",unknownReason:"HoodLock does not read the locked LP's underlying amounts.",heldAs:P?V:O,dueAt:oe})),coverage:{complete:!0}},description:`HoodLock Uniswap ${P?"v4":"v3"} LP lock #${n} (NFT #${ne}, ${Z.symbol}/${ee.symbol}, feeRecipient ${ae}, collectFeeBps ${ce}) until Unix ${oe}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function He(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>Ae(e,a,k))}}}function Be(e){return async o=>(await W(e,()=>Ae(e,o))).positions}var G=e=>({tools:[Re(e),Ne(e),He(e)],positions:Be(e)}),Ge=G,Xe=G,Qe=e=>le("hoodlock",[G(e)]),Ye=G;export{T as a,F as b,v as c,O as d,V as e,We as f,$e as g,xe as h,Re as i,Ne as j,He as k,Be as l,G as m,Ge as n,Xe as o,Qe as p,Ye as q};
|
|
1
|
+
import{b as j}from"./QXBQ7WPB.js";import{h as me,k as ke}from"./2GXHYI23.js";import{b as S}from"./GV6FZ6UG.js";import{b as le}from"./SPJCSEKP.js";import{a as _}from"./43LI5NKJ.js";import{g as B,i as ue}from"./NWNYJ26T.js";import{b as H}from"./IX3GZMTM.js";import{b as d,j as N}from"./EWZFZUVF.js";import{a as u}from"./XSD5NL7J.js";import{a as de}from"./JXOEJPJ4.js";import{encodeFunctionData as K,erc20Abi as pe,getAddress as m,isAddress as ye,parseAbi as U,zeroAddress as fe}from"viem";var T=m(N[d].hoodlock.locker.address),F=m(N[d].hoodlock.burner.address),v=m(N[d].hoodlock.liquidityLocker.address),O=m(N[d].uniswap.v3_position_manager.address),V=m(N[d].uniswap.v4_position_manager.address),We="0x000000000000000000000000000000000000dEaD",$e=3153600000n,Le=1000000000000n,we=65535,D=U(["function fee() view returns (uint256)","function lock(address token, uint256 amount, uint256 unlockTime) payable returns (uint256 lockId)","function getLock(uint256 lockId) view returns (address owner, address token, uint256 amount, uint256 unlockTime, bool withdrawn)","function locksByOwner(address owner) view returns (uint256[])","function locksByToken(address token) view returns (uint256[])"]),te=U(["function fee() view returns (uint256)","function burn(address token, uint256 amount) payable returns (uint256 burnId)","function DEAD() view returns (address)","function getBurn(uint256 burnId) view returns (address burner, address token, uint256 amount, uint256 timestamp)","function totalBurnedOf(address token) view returns (uint256)"]),q=U(["function fixedFee() view returns (uint256)","function collectFeeBps() view returns (uint16)","function paused() view returns (bool)","function lock(address manager, uint256 tokenId, uint256 unlockTime, address feeRecipient, bool acceptUnverifiedHook, uint16 maxCollectFeeBps) payable returns (uint256 lockId)","function lockIdOf(address manager, uint256 tokenId) view returns (uint256)","function getLock(uint256 lockId) view returns (address owner, uint40 unlockTime, uint16 collectFeeBps, bool isV4, bool hookVerified, bool withdrawn, address feeRecipient, address token0, address token1, uint256 tokenId)","function locksOf(address owner) view returns (uint256[])"]),Se=U(["function approve(address to, uint256 tokenId)"]);function xe(e,o,t){let a=o.trim();if(a.startsWith("-")){let k=a.slice(1),i=e(k,t);return i==="0"?"0":`-${i}`}return e(a,t)}function ge(e,o){return o.length===0?"no ERC-20 transfer deltas":o.map(t=>`${xe(e.formatAmount,t.amount,t.token.decimals)} ${t.token.symbol}`).join(", ")}function E(e,o="token"){if(typeof e!="string"||!e.trim())throw new u(`Provide a valid ${o} contract address.`);if(!ye(e,{strict:!1}))throw new u(`Identify ${o} by chain and contract address, not by symbol.`);return m(e)}async function W(e,o){try{return await o()}catch(t){throw new u(e.plainError(t))}}function ve(e){let o=H(e);if(o<=0n)throw new u("Amount must be greater than zero.");return o}async function be(e){let o=await e.getBlock();if(!o||typeof o.timestamp!="bigint")throw new u("Could not read the current chain timestamp. Please try again.");return o.timestamp}function he(e,o){if(typeof e!="string"||!/^\d+$/.test(e.trim()))throw new u("unlockTime must be a non-negative integer string in Unix seconds.");let t=BigInt(e.trim());if(t>=Le)throw new u("unlockTime appears to be in milliseconds; provide Unix seconds at most 100 years (3153600000 seconds) in the future.");if(t<=o)throw new u(`unlockTime (${t}) must be in the future (greater than current timestamp ${o}).`);let a=o+$e;if(t>a)throw new u(`unlockTime (${t}) exceeds the 100-year maximum lock duration (3153600000 seconds; max ${a}).`);return t}async function ie(e,o,t=d){let a=m(o),[k,i]=await Promise.all([e.readContract({address:a,abi:pe,functionName:"symbol"}),e.readContract({address:a,abi:pe,functionName:"decimals"})]);return{address:a,symbol:de(String(k)),decimals:Number(i),chainId:t}}function Ie(e,o){if(e==null)return o;let t=typeof e=="number"?e:typeof e=="string"&&/^\d+$/.test(e.trim())?Number(e.trim()):NaN;if(!Number.isInteger(t)||t<0||t>we)throw new u("maxCollectFeeBps must be an integer between 0 and 65535.");if(t<o)throw new u(`Live collectFeeBps (${o}) exceeds maxCollectFeeBps (${t}): collect fee changed.`);return Math.min(t,o)}function Pe(e){return e.tokenId!==void 0||e.manager!==void 0||e.feeRecipient!==void 0||e.maxCollectFeeBps!==void 0||e.acceptUnverifiedHook!==void 0||e.kind==="v3"||e.kind==="lp"||e.kind==="v4"||e.version==="v3"||e.version==="v4"}async function Ce(e,o,t){_(t);let a=m(t),k=o.kind==="v4"||o.version==="v4",i=o.manager!==void 0?E(o.manager,"manager"):k?V:O,g=i===V;if(i!==O&&!g)throw new u(`Unsupported position manager ${i}; use the configured Uniswap v3 or v4 manager.`);if(k&&!g||g&&(o.kind==="v3"||o.version==="v3"))throw new u("The requested version disagrees with the position manager.");if(o.acceptUnverifiedHook!==void 0&&typeof o.acceptUnverifiedHook!="boolean")throw new u("acceptUnverifiedHook must be a boolean.");let b=o.acceptUnverifiedHook===!0;if(!g&&b)throw new u("Uniswap v3 has no hooks; omit acceptUnverifiedHook.");let s=g?"v4":"v3";if(typeof o.tokenId!="string")throw new u("Provide an NFT tokenId as a decimal string.");let p=String(o.tokenId).trim(),c=H(p),l=ue(o.feeRecipient,"Provide an explicit feeRecipient address for LP position locks."),w=e.clientFor(d),[x,I,h]=await Promise.all([be(w),w.readContract({address:v,abi:q,functionName:"fixedFee"}),w.readContract({address:v,abi:q,functionName:"collectFeeBps"})]),y,$=!0;if(g){let C=U(["function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey, uint256 info)","function getPositionLiquidity(uint256 tokenId) view returns (uint128)","function ownerOf(uint256 tokenId) view returns (address)"]),[Y,J,M]=await Promise.all([w.readContract({address:i,abi:C,functionName:"getPoolAndPositionInfo",args:[c]}),w.readContract({address:i,abi:C,functionName:"getPositionLiquidity",args:[c]}),w.readContract({address:i,abi:C,functionName:"ownerOf",args:[c]})]);if(m(M)!==a)throw new u("This wallet does not own that v4 position NFT.");if(J<=0n)throw new u("The v4 position has no liquidity to lock.");if(y=m(Y[0].hooks),$=y===fe||await w.readContract({address:v,abi:U(["function hookAllowed(address) view returns (bool)"]),functionName:"hookAllowed",args:[y]}),!$&&!b)throw new u(`Unverified v4 hook ${y}; review its risks and explicitly set acceptUnverifiedHook: true to proceed.`)}let A=he(o.unlockTime,x),n=BigInt(I),r=Number(h);if(!Number.isInteger(r)||r<0||r>we)throw new u(`Invalid on-chain collectFeeBps (${String(h)}).`);if(o.maxFee!==void 0){let C=H(String(o.maxFee));if(n>C)throw new u(`Live fixedFee (${n}) exceeds maxFee (${C}).`)}let f=Ie(o.maxCollectFeeBps,r),L=(r/100).toString(),R=e.unsignedTx({to:i,data:K({abi:Se,functionName:"approve",args:[v,c]}),value:"0",chainId:d,description:`Approve Uniswap ${s} position NFT #${c} on ${i} for HoodLock LiquidityLocker ${v}.`}),P=e.unsignedTx({to:v,data:K({abi:q,functionName:"lock",args:[i,c,A,l,b,f]}),value:n.toString(),chainId:d,description:`Lock Uniswap ${s} NFT #${c} in HoodLock LiquidityLocker (${v}) until ${A} with feeRecipient ${l}, upfront fixedFee ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei), and ongoing collect fee ${r} bps (${L}% of collected LP fees, frozen per lock).`}),X=[R,P],z=await e.preview(X,a),Q=`Approve and lock Uniswap ${s} NFT #${c} (manager ${i}) in HoodLock LiquidityLocker ${v} until Unix ${A}. Upfront fixedFee: ${e.formatAmount(n.toString(),S.decimals)} ETH (${n} wei). Ongoing LP fee share: ${r} bps (${L}% of collected LP fees, frozen per lock; maxCollectFeeBps=${f}) with feeRecipient ${l}. V4 hook: ${y??"none"}, reviewed: ${$}; acceptUnverifiedHook=${b}.`;return j(e,{txs:z.txs,summary:Q,preview:z,kind:s,contract:v,manager:i,tokenId:c.toString(),unlockTime:A.toString(),feeRecipient:l,acceptUnverifiedHook:b,collectFeeBps:r,maxCollectFeeBps:f,fixedFee:{token:S,amount:n.toString()}},v,n)}async function Fe(e,o,t){_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(d),[g,b,s]=await Promise.all([be(i),i.readContract({address:T,abi:D,functionName:"fee"}),ie(i,k,d)]),p=ve(o.amount),c=he(o.unlockTime,g),l=BigInt(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(l>A)throw new u(`Live lock fee (${l}) exceeds maxFee (${A}).`)}let w=e.approval(s.address,T,p.toString(),d),x=e.unsignedTx({to:T,data:K({abi:D,functionName:"lock",args:[s.address,p,c]}),value:l.toString(),chainId:d,description:`Lock ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) in HoodLock Locker ${T} until ${c} with exact fee ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei).`}),I=[w,x],h=await e.preview(I,a),y=ge(e,h.changes),$=`Approve and lock ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) in HoodLock Locker ${T} until Unix ${c}. Exact fee: ${e.formatAmount(l.toString(),S.decimals)} ETH (${l} wei). Preview changes: ${y}.`;return j(e,{txs:h.txs,summary:$,preview:h,kind:"token",contract:T,token:s,amount:p.toString(),unlockTime:c.toString(),fee:{token:S,amount:l.toString()}},T,l)}function Re(e){return{name:"hoodlock_lock",inputSchema:{type:"object",properties:{kind:{type:"string",enum:["token","v2","v3","v4"],description:"Lock mode: token/v2 LP via Locker, or Uniswap v3/v4 NFT via LiquidityLocker."},token:{type:"string",description:"ERC-20 token or v2 LP token contract address on chain 4663 (for token/v2 locks)."},amount:{type:"string",description:"Token amount as an integer string in base units (for token/v2 locks)."},manager:{type:"string",description:"Configured Uniswap v3 or v4 position manager; inferred from kind when omitted."},tokenId:{type:"string",description:"Uniswap NFT position tokenId as a decimal string."},feeRecipient:{type:"string",description:"Explicit recipient address for collected LP fees during a position lock."},acceptUnverifiedHook:{type:"boolean",description:"Explicit v4 unreviewed-hook consent; default false. A reviewed hook is not a safety guarantee."},maxFee:{type:"string",description:"Maximum upfront ETH fee in wei; the exact live fee is sent."},maxCollectFeeBps:{type:"number",description:"Maximum acceptable ongoing LP collect fee in bps (uint16, must be >= live collectFeeBps)."},unlockTime:{type:"string",description:"Unlock timestamp in Unix seconds (must be > now and <= now + 100 years)."}},required:["unlockTime"],additionalProperties:!1},async execute(o,t){return W(e,async()=>Pe(o)?Ce(e,o,t):Fe(e,o,t))}}}function Ne(e){return{name:"hoodlock_burn",inputSchema:{type:"object",properties:{token:{type:"string",description:"ERC-20 token contract address on chain 4663 to send to the dead address via HoodLock Burner."},amount:{type:"string",description:"Amount to burn as an integer string in base units."}},required:["token","amount"],additionalProperties:!1},async execute(o,t){return W(e,async()=>{_(t);let a=m(t),k=E(o.token,"token"),i=e.clientFor(d),[g,b,s]=await Promise.all([i.readContract({address:F,abi:te,functionName:"fee"}),i.readContract({address:F,abi:te,functionName:"DEAD"}),ie(i,k,d)]),p=ve(o.amount),c=BigInt(g),l=m(b);if(o.maxFee!==void 0){let A=H(String(o.maxFee));if(c>A)throw new u(`Live burn fee (${c}) exceeds maxFee (${A}).`)}let w=e.approval(s.address,F,p.toString(),d),x=e.unsignedTx({to:F,data:K({abi:te,functionName:"burn",args:[s.address,p]}),value:c.toString(),chainId:d,description:`Send ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${F} (totalSupply is unchanged) with exact fee ${e.formatAmount(c.toString(),S.decimals)} ETH (${c} wei).`}),I=[w,x],h=await e.preview(I,a),y=ge(e,h.changes),$=`Approve and send ${e.formatAmount(p.toString(),s.decimals)} ${s.symbol} (${p} base units of ${s.address}) to the dead address (${l}) via HoodLock Burner ${F}. Note: tokens are transferred to ${l} and totalSupply is unchanged. Exact fee: ${e.formatAmount(c.toString(),S.decimals)} ETH (${c} wei). Preview changes: ${y}.`;return j(e,{txs:h.txs,summary:$,preview:h,contract:F,deadAddress:l,token:s,amount:p.toString(),fee:{token:S,amount:c.toString()},totalSupplyReduced:!1},F,c)})}}}async function Ae(e,o,t){_(o);let a=m(o),k=t?E(t,"token"):void 0,i=e.clientFor(d),g=[],b=new Set,s=n=>{for(let r of n){let f=r.toString();b.has(f)||(b.add(f),g.push(r))}};if(k){let[n,r]=await Promise.all([i.readContract({address:T,abi:D,functionName:"locksByToken",args:[k]}),i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]})]);s(n),s(r)}else{let n=await i.readContract({address:T,abi:D,functionName:"locksByOwner",args:[a]});s(n)}let c=(await Promise.all(g.map(async n=>{let r=await i.readContract({address:T,abi:D,functionName:"getLock",args:[n]});return{id:n,owner:m(r[0]),token:m(r[1]),amount:BigInt(r[2]),unlockTime:BigInt(r[3]),withdrawn:!!r[4]}}))).filter(n=>!n.withdrawn&&n.amount>0n&&B(n.owner,a)&&(!k||B(n.token,k))),l=new Map,w=async n=>{let r=n.toLowerCase(),f=l.get(r);if(f)return f;let L=n===fe?S:await ie(i,n,d);return l.set(r,L),L},x=[],I=[];for(let n of c){let r=await w(n.token),f=n.amount.toString(),L=n.unlockTime.toString(),R={token:r,amount:f};x.push({lockId:n.id.toString(),kind:"token",contract:T,chainId:d,owner:n.owner,token:r,amount:f,asset:R,unlockTime:L,withdrawn:!1}),I.push({module:"hoodlock",id:`lock:${n.id.toString()}`,chainId:d,assets:[R],economics:{principal:[me("locked",{token:r,amount:f,source:"hoodlock.lock.amount",dueAt:L})],debt:[],rewards:[],backing:[],coverage:{complete:!0}},description:`HoodLock token lock #${n.id} of ${e.formatAmount(f,r.decimals)} ${r.symbol} (${r.address}) until Unix ${L}.`})}let h=await i.readContract({address:v,abi:q,functionName:"locksOf",args:[a]}),y=[...new Set(h.map(n=>n.toString()))].map(n=>BigInt(n)),$=[];for(let n of y){let r=await i.readContract({address:v,abi:q,functionName:"getLock",args:[n]}),[f,L,R,P,X,z,Q,C,Y,J]=r,M=m(f);if(z||!B(M,a))continue;let re=m(C),se=m(Y);if(k&&!B(re,k)&&!B(se,k))continue;let[Z,ee]=await Promise.all([w(re),w(se)]),ae=m(Q),ce=Number(R),oe=BigInt(L).toString(),ne=BigInt(J).toString();$.push({lockId:n.toString(),kind:P?"v4":"v3",contract:v,manager:P?V:O,chainId:d,owner:M,tokenId:ne,unlockTime:oe,collectFeeBps:ce,feeRecipient:ae,hookVerified:!!X,token0:Z,token1:ee,withdrawn:!1}),I.push({module:"hoodlock",id:`lp-lock:${n.toString()}`,chainId:d,assets:[{token:{address:P?V:O,symbol:`UNI-${P?"V4":"V3"} #${ne}`,decimals:0,chainId:d},amount:"1"}],economics:{principal:[],debt:[],rewards:[],backing:[Z,ee].map(Te=>ke({token:Te,amount:null,source:"hoodlock.lpLock.underlying",unknownReason:"HoodLock does not read the locked LP's underlying amounts.",heldAs:P?V:O,dueAt:oe})),coverage:{complete:!0}},description:`HoodLock Uniswap ${P?"v4":"v3"} LP lock #${n} (NFT #${ne}, ${Z.symbol}/${ee.symbol}, feeRecipient ${ae}, collectFeeBps ${ce}) until Unix ${oe}. One NFT held in LiquidityLocker custody for ${M}. Underlying token amounts are not valued.`})}let A=`Found ${x.length} active token lock(s) and ${$.length} active Uniswap v3/v4 LP lock(s) for ${a}.`;return{locks:x,lpLocks:$,positions:I,summary:A}}function He(e){return{name:"hoodlock_list_locks",inputSchema:{type:"object",properties:{owner:{type:"string",description:"Optional owner wallet address to query (defaults to the authenticated wallet)."},token:{type:"string",description:"Optional ERC-20 or LP token address to filter active locks owned by the wallet."}},additionalProperties:!1},async execute(o,t){let a=o.owner!==void 0?E(o.owner,"owner"):m(t),k=o.token!==void 0?E(o.token,"token"):void 0;return W(e,()=>Ae(e,a,k))}}}function Be(e){return async o=>(await W(e,()=>Ae(e,o))).positions}var G=e=>({tools:[Re(e),Ne(e),He(e)],positions:Be(e)}),Ge=G,Xe=G,Qe=e=>le("hoodlock",[G(e)]),Ye=G;export{T as a,F as b,v as c,O as d,V as e,We as f,$e as g,xe as h,Re as i,Ne as j,He as k,Be as l,G as m,Ge as n,Xe as o,Qe as p,Ye as q};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as tn,d as on,e as $e,f as he,i as Ee,j as rn}from"./6EWSLHXL.js";import{a as _e,b as Ue}from"./YEIM6BZQ.js";import{m as ue}from"./IR7KDBFU.js";import{b as Te,o as Me}from"./TTBB6EFN.js";import{a as de}from"./7WXAS54T.js";import{h as nn}from"./QA6Z2CYP.js";import{c as en}from"./CFPJDLTZ.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{b as y,e as Ze,j as Q,k as Ye,n as Qe}from"./EWZFZUVF.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as sn,getAddress as w,isAddress as Hn,keccak256 as Fn,pad as Vn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Bn,toHex as an}from"viem";var On=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),me=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),qt=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Oe=8388608,Fe=-887272,ve=887272,In=(1n<<48n)-1n,J=(1n<<128n)-1n,Xn=(1n<<160n)-1n,le=1n<<96n,cn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",dn=1800n,fe=50n,un=(e,n=fe)=>e*(10000n-n)/10000n,pn=(e,n,i=fe)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Rn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Xe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Cn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",zn={currency0:k,currency1:D,fee:Oe,tickSpacing:1,hooks:Re},jn=new Set([...Xe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),Wn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),Gn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Zn=z("address currency0, address currency1"),Yn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Qn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),pe=z("bytes actions, bytes[] params"),O=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Jn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),ln=z("address currency"),mn=1e6,ye=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),et=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),nt=Bn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Hn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===de.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===de.toLowerCase()}function ae(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Fn(S(Wn,[n,i,e.fee,e.tickSpacing,r]))}function qn(e){return((typeof e=="number"?e:e.fee)&Oe)!==0}function fn(e,n){return qn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ue(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ue(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=qn(e.fee);if(!s&&e.fee>mn)throw new o(`PoolKey static fee ${_e(e.fee)} exceeds the v4 maximum of ${_e(mn)}.`);if(s&&e.fee!==Oe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!jn.has(c.toLowerCase()))throw ae({currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c}).toLowerCase()===en.poolId?new o(nn):c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ae(t);if(c===Re&&d.toLowerCase()!==Cn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function tt(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function it(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function yn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Xn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>In)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:et,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function wn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function ot(e){let n=(e&0xffn)!==0n,i=wn(e>>8n&0xffffffn),r=wn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function bn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function hn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+le-1n)/le:t/le}function Ln(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:bn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:bn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:hn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:hn(n,i,e.liquidity,e.roundUp)}}function rt(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/le/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*le/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function gn(e,n=y){if(H(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return gn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return gn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:sn,functionName:"symbol"}),e.readContract({address:r,abi:sn,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:rn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function kn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function Tn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await Tn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ae(u),poolKey:u}}let s=(i??Rn).toLowerCase();if(s===Cn)return{poolId:s,poolKey:ke(zn,s)};let t=Xe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:O,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:O,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ae(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=ot(BigInt(c));return{poolKey:s,poolId:ae(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function st(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function Pn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[nt,null,Vn(r)],fromBlock:an(p),toBlock:an(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:O,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:me,abi:ye,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Ln({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(fe)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},ct={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ut={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},pt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function vn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function xn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return on(BigInt(e.sqrtPriceX96))}return tn(e.initialPrice,n,i)}async function lt(e,n,i){let r;try{r=await e.readContract({address:M,abi:O,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function An(e,n){let i=ae(n).toLowerCase(),r=new Map;for(let s of Xe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:me,abi:ye,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:me,abi:ye,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function Sn(e,n,i,r,c,s){return e.unsignedTx({to:On.toLowerCase(),data:re({abi:Jn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var mt=e=>({tools:[{name:"uniswap_add",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(cn);let m=t.slippageBps===void 0?Number(fe):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(cn);let f=BigInt(m),P=e.clientFor(y);p&&vn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await lt(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=tt(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),it(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:me,abi:ye,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=xn(t,h.decimals,g.decimals),V=Ee(q,await An(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):rt({amount0:un(A,f),amount1:un(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Ln({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:pn(ee,A,f),Y=l?I:pn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await Tn(P),X=await Ke(P,t.deadline,U.toString()),te=X<U+dn?X:U+dn,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>In)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[Sn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),q.toString(),y)),G.push(yn(ce,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ce=u.currency1.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),V.toString(),y)),G.push(yn(ce,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(Gn,[R,v,x,E,q,V,$.toLowerCase(),ie]),_n=S(Zn,[R.currency0,R.currency1]),We=S(Yn,[k,$.toLowerCase()]),Un=S(ge,[a??0n,E,q,V,ie]),Dn=a===void 0?S(pe,["0x020d14",[Le,_n,We]]):S(pe,["0x00121214",[Un,S(ln,[R.currency0]),S(ln,[R.currency1]),We]]),Nn=re({abi:O,functionName:"modifyLiquidities",args:[Dn,X]}),Kn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Nn,value:Kn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?de:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Mn=Ne(we.changes,e.formatAmount),qe=fn(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],$n=Se.length,En=a===void 0?`This deposit takes ${$n} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(fe)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:X.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:$e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${En}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Mn.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(pe,["0x0111",[g,A]]),F=re({abi:O,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ut,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,X)=>{let te=h?S(Qn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,X]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),X=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=X(b),j=X(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):kn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):kn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:pt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):st(t.wallet),m=await Pn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');vn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:me,abi:ye,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=xn(t,m.decimals,f.decimals),u=Ee(b,await An(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[Sn(e,l,p,b,m,f)],h=await e.preview(x,d),g=fn(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:$e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>Pn(e,t)}),Lt=mt;export{On as a,M as b,me as c,He as d,qt as e,se as f,D as g,k as h,Oe as i,Fe as j,ve as k,Rn as l,Ve as m,Xe as n,Re as o,Cn as p,zn as q,jn as r,H as s,ae as t,qn as u,fn as v,ke as w,tt as x,it as y,yn as z,ot as A,Ln as B,rt as C,Ne as D,gn as E,B as F,Pe as G,Pn as H,at as I,ct as J,dt as K,ut as L,pt as M,An as N,mt as O,Lt as P};
|
|
1
|
+
import{a as _e,b as Ue}from"./YEIM6BZQ.js";import{c as tn,d as on,e as $e,f as he,i as Ee,j as rn}from"./Y7SKGRWC.js";import{m as ue}from"./OUXPOFY2.js";import{b as Te,o as Me}from"./TTBB6EFN.js";import{a as de}from"./7WXAS54T.js";import{h as nn}from"./QA6Z2CYP.js";import{c as en}from"./CFPJDLTZ.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{b as y,e as Ze,j as Q,k as Ye,n as Qe}from"./EWZFZUVF.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as sn,getAddress as w,isAddress as Hn,keccak256 as Fn,pad as Vn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Bn,toHex as an}from"viem";var On=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),me=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),qt=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Oe=8388608,Fe=-887272,ve=887272,In=(1n<<48n)-1n,J=(1n<<128n)-1n,Xn=(1n<<160n)-1n,le=1n<<96n,cn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",dn=1800n,fe=50n,un=(e,n=fe)=>e*(10000n-n)/10000n,pn=(e,n,i=fe)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Rn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Xe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Cn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",zn={currency0:k,currency1:D,fee:Oe,tickSpacing:1,hooks:Re},jn=new Set([...Xe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),Wn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),Gn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Zn=z("address currency0, address currency1"),Yn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Qn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),pe=z("bytes actions, bytes[] params"),O=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Jn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),ln=z("address currency"),mn=1e6,ye=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),et=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),nt=Bn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Hn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===de.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===de.toLowerCase()}function ae(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Fn(S(Wn,[n,i,e.fee,e.tickSpacing,r]))}function qn(e){return((typeof e=="number"?e:e.fee)&Oe)!==0}function fn(e,n){return qn(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ue(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ue(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=qn(e.fee);if(!s&&e.fee>mn)throw new o(`PoolKey static fee ${_e(e.fee)} exceeds the v4 maximum of ${_e(mn)}.`);if(s&&e.fee!==Oe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!jn.has(c.toLowerCase()))throw ae({currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c}).toLowerCase()===en.poolId?new o(nn):c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ae(t);if(c===Re&&d.toLowerCase()!==Cn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function tt(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function it(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function yn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Xn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>In)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:et,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function wn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function ot(e){let n=(e&0xffn)!==0n,i=wn(e>>8n&0xffffffn),r=wn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function bn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function hn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+le-1n)/le:t/le}function Ln(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=ue(e.tickLower),i=ue(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:bn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:bn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:hn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:hn(n,i,e.liquidity,e.roundUp)}}function rt(e){let n=ue(e.tickLower),i=ue(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/le/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*le/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function gn(e,n=y){if(H(e))return{address:de,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return gn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return gn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:sn,functionName:"symbol"}),e.readContract({address:r,abi:sn,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:rn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function kn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function Tn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await Tn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ae(u),poolKey:u}}let s=(i??Rn).toLowerCase();if(s===Cn)return{poolId:s,poolKey:ke(zn,s)};let t=Xe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:O,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:O,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ae(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=ot(BigInt(c));return{poolKey:s,poolId:ae(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function st(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function Pn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[nt,null,Vn(r)],fromBlock:an(p),toBlock:an(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:O,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:me,abi:ye,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Ln({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(fe)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},ct={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ut={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},pt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function vn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function xn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return on(BigInt(e.sqrtPriceX96))}return tn(e.initialPrice,n,i)}async function lt(e,n,i){let r;try{r=await e.readContract({address:M,abi:O,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function An(e,n){let i=ae(n).toLowerCase(),r=new Map;for(let s of Xe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:me,abi:ye,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:me,abi:ye,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function Sn(e,n,i,r,c,s){return e.unsignedTx({to:On.toLowerCase(),data:re({abi:Jn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var mt=e=>({tools:[{name:"uniswap_add",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(cn);let m=t.slippageBps===void 0?Number(fe):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(cn);let f=BigInt(m),P=e.clientFor(y);p&&vn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await lt(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=tt(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),it(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:me,abi:ye,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=xn(t,h.decimals,g.decimals),V=Ee(q,await An(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):rt({amount0:un(A,f),amount1:un(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Ln({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:pn(ee,A,f),Y=l?I:pn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await Tn(P),X=await Ke(P,t.deadline,U.toString()),te=X<U+dn?X:U+dn,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>In)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[Sn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ce=u.currency0.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),q.toString(),y)),G.push(yn(ce,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ce=u.currency1.toLowerCase();G.push(e.approval(ce,He.toLowerCase(),V.toString(),y)),G.push(yn(ce,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(Gn,[R,v,x,E,q,V,$.toLowerCase(),ie]),_n=S(Zn,[R.currency0,R.currency1]),We=S(Yn,[k,$.toLowerCase()]),Un=S(ge,[a??0n,E,q,V,ie]),Dn=a===void 0?S(pe,["0x020d14",[Le,_n,We]]):S(pe,["0x00121214",[Un,S(ln,[R.currency0]),S(ln,[R.currency1]),We]]),Nn=re({abi:O,functionName:"modifyLiquidities",args:[Dn,X]}),Kn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Nn,value:Kn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?de:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Mn=Ne(we.changes,e.formatAmount),qe=fn(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],$n=Se.length,En=a===void 0?`This deposit takes ${$n} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(fe)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:X.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:$e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${En}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Mn.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(pe,["0x0111",[g,A]]),F=re({abi:O,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ut,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:O,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,X)=>{let te=h?S(Qn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,X]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:O,functionName:"modifyLiquidities",args:[S(pe,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),X=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=X(b),j=X(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):kn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):kn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:pt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):st(t.wallet),m=await Pn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');vn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:me,abi:ye,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=xn(t,m.decimals,f.decimals),u=Ee(b,await An(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[Sn(e,l,p,b,m,f)],h=await e.preview(x,d),g=fn(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:$e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>Pn(e,t)}),Lt=mt;export{On as a,M as b,me as c,He as d,qt as e,se as f,D as g,k as h,Oe as i,Fe as j,ve as k,Rn as l,Ve as m,Xe as n,Re as o,Cn as p,zn as q,jn as r,H as s,ae as t,qn as u,fn as v,ke as w,tt as x,it as y,yn as z,ot as A,Ln as B,rt as C,Ne as D,gn as E,B as F,Pe as G,Pn as H,at as I,ct as J,dt as K,ut as L,pt as M,An as N,mt as O,Lt as P};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{t as T}from"./
|
|
1
|
+
import{t as T}from"./R5UOFPDO.js";import{b as C,c as N,d as E}from"./3PU2SD3U.js";import{b as M}from"./5KKAN7XQ.js";import{b as O,la as S}from"./V5YSJKRH.js";import{a as R}from"./P4UQGWCP.js";import{c as v}from"./SCG5HWMN.js";import{e as y}from"./NWNYJ26T.js";import{b as m,j as _}from"./EWZFZUVF.js";import{a as p}from"./XSD5NL7J.js";import{getAddress as x,isAddress as k}from"viem";function P(i){if(typeof i!="string"||!i.trim()||i.length>200)throw new p("Provide nonempty filter text of at most 200 characters.");return i}function $(i,u){if(typeof i!="number"||!Number.isSafeInteger(i)||i<0||i>u)throw new p(`Choose a pagination integer from 0 to ${u}.`);return i}var w={morpho:{assess:"morpho_status",enter:"morpho_supply_collateral",exit:"morpho_withdraw_collateral"},steakhouse:{assess:"steakhouse_list",enter:"steakhouse_deposit",exit:"steakhouse_withdraw"},spark:{assess:"spark_list",enter:"spark_deposit",exit:"spark_withdraw"},netnet:{assess:"netnet_list",enter:"netnet_deposit",exit:"netnet_withdraw"},longbow:{assess:"longbow_list",enter:"longbow_deposit",exit:"longbow_withdraw"},grove:{assess:"grove_list",enter:"grove_deposit",exit:"grove_withdraw"},beefy:{assess:"beefy_list",enter:"beefy_deposit",exit:"beefy_withdraw"},uniswap:{assess:"uniswap_list_positions",enter:"uniswap_add",exit:"uniswap_remove"},layerbank:{assess:"layerbank_list",enter:"layerbank_deposit",exit:"layerbank_withdraw"}},h=_[m].vaults,L={steakhouse:[h.steakhouse.address],spark:[h.spark.address],netnet:[h.netnet.address],longbow:[h.longbowCore.address,h.longbowFrontier.address,h.longbowEth.address],grove:[h.groveAlm.address],beefy:R.vaults.map(i=>i.earnContractAddress),layerbank:[M]},U=new Set(T.map(i=>i.marketId.toLowerCase()));function q(i,u){return Object.hasOwn(L,i)&&typeof u=="string"&&k(u,{strict:!1})&&L[i].some(g=>g.toLowerCase()===u.toLowerCase())}var Z=i=>{let u=(t,n,r)=>({name:`merkl_${t}`,inputSchema:{type:"object",properties:n,additionalProperties:!1},execute:async(c,e)=>{try{let s=Object.keys(c).find(d=>!Object.hasOwn(n,d));if(s)throw new p(`Unsupported Merkl input: ${s}.`);return await r(c,e)}catch(s){throw new p(i.plainError(s))}}}),g={page:{type:"integer",minimum:0,maximum:1e4,description:"Zero-based page number."},items:{type:"integer",minimum:1,maximum:100,description:"Maximum entries per page, from 1 to 100."}},A=async(t,n)=>{let r=new URL(`https://api.merkl.xyz/v4/${t}`);for(let[c,e]of Object.entries(n))r.searchParams.set(c,e);return v(i.http,r.toString(),{method:"GET",headers:{"User-Agent":"oak-core/merkl"}},c=>Array.isArray(c)||y(c))},b=t=>{let n=$(t.items??20,100);if(!n)throw new p("Choose at least one item per page.");return{page:String($(t.page??0,1e4)),items:String(n)}};return{tools:[u("opportunities",{...g,protocol:{type:"string",description:"Protocol identifier to filter opportunities."},name:{type:"string",description:"Opportunity name search text."},explorerAddress:{type:"string",description:"Pool or market contract address to filter opportunities."}},async t=>{let n={chainId:String(m),campaigns:"true",...b(t)};if(t.protocol!==void 0&&(n.mainProtocolId=P(t.protocol)),t.name!==void 0&&(n.name=P(t.name)),t.explorerAddress!==void 0){if(typeof t.explorerAddress!="string"||!k(t.explorerAddress,{strict:!1}))throw new p("Provide a pool or market explorer address.");n.explorerAddress=x(t.explorerAddress)}let r=await A("opportunities",n);if(!Array.isArray(r)||!r.every(e=>y(e)&&typeof e.id=="string"&&Number.isSafeInteger(e.chainId)))throw new p("Merkl returned unexpected opportunities.");return{opportunities:r.filter(e=>e.chainId===m).map(e=>{let s=(y(e.protocol)?e.protocol.id:void 0)??e.mainProtocolId??e.mainProtocol,d=typeof s=="string"?s.toLowerCase():"",o;d==="morpho"&&e.action==="LEND"?e.type==="MORPHOCOLLATERAL"?[e.marketId,e.identifier,e.explorerAddress].some(I=>typeof I=="string"&&U.has(I.toLowerCase()))&&(o=w.morpho):typeof e.type=="string"&&(e.type==="ERC20LOGPROCESSOR"||e.type.includes("MORPHOVAULT"))&&typeof e.explorerAddress=="string"&&k(e.explorerAddress,{strict:!1})&&x(e.explorerAddress)===_[m].vaults.steakhouse.address&&(o=w.steakhouse):d==="uniswap"?e.type==="UNISWAP_V4"&&e.action==="POOL"&&(o=w.uniswap):q(d,e.explorerAddress)&&(e.action==="LEND"||e.action==="STAKE")&&(o=w[d]);let l=e.action==="POOL"||o?.enter==="uniswap_add",a=l?E(e.campaigns,Math.floor(Date.now()/1e3)):void 0,f=l&&a?{lpWarning:`Illustration for $100; no deposit amount has been selected.
|
|
2
2
|
${C({apr:typeof e.apr=="number"?e.apr:a.aprPct,endDate:typeof e.endTimestamp=="number"||typeof e.endTimestamp=="string"?e.endTimestamp:a.endsAt,amountUsd:100,outOfRangeIncentivized:a.outOfRangeIncentivized,feeWeightPct:a.feeWeightPct,creator:d==="uniswap"?a.creator:void 0})}`}:{};return{...e,oak:{...o?{candidateTools:o}:{},...f,destinationVerificationRequired:!0,eligibility:"Read campaign conditions; no wallet eligibility has been verified."}}}),...b(t),hasMore:r.length===Number(n.items),summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Public, untrusted campaign data includes conditions and destinations. Candidate Oak tools require a matching verified market/vault and a supported entry AND exit. APR is indicative; no rewards are promised."}}),u("campaigns",{...g,creator:{type:"string",description:"Campaign creator address to filter."},tokenSymbol:{type:"string",description:"Reward token symbol to filter campaigns."},opportunityId:{type:"string",pattern:"^\\d{1,30}$",description:"Merkl opportunity identifier as a decimal string of 1 to 30 digits."}},async t=>{if(t.opportunityId!==void 0&&(t.creator!==void 0||t.tokenSymbol!==void 0))throw new p("Use creator and tokenSymbol without opportunityId; the opportunity endpoint does not support those filters.");if(t.opportunityId!==void 0&&(typeof t.opportunityId!="string"||!/^\d{1,30}$/.test(t.opportunityId)))throw new p("Provide an opportunityId as a decimal string of 1 to 30 digits.");let n={chainId:String(m),withOpportunity:"true",...b(t)};if(t.creator!==void 0){if(typeof t.creator!="string"||!k(t.creator,{strict:!1}))throw new p("Provide a creator address.");n.creatorAddress=x(t.creator)}t.tokenSymbol!==void 0&&(n.tokenSymbol=P(t.tokenSymbol));let r=t.opportunityId===void 0?"campaigns":`opportunities/${t.opportunityId}/campaigns`,c=await A(r,t.opportunityId===void 0?n:{}),e=t.opportunityId!==void 0&&y(c)?c:void 0;if(e&&e.chainId!==m)throw new p(`Merkl opportunity must be on chain ${m}.`);let s=t.opportunityId===void 0?c:e?.campaigns;if(!Array.isArray(s)||!s.every(f=>y(f)&&(typeof f.id=="string"||typeof f.id=="number")))throw new p("Merkl returned unexpected campaigns.");let d=e?s.filter(f=>f.distributionChainId===m):s,o=Number(n.page)*Number(n.items),l=t.opportunityId===void 0?d:d.slice(o,o+Number(n.items)),a=t.opportunityId===void 0?d.length===Number(n.items):o+Number(n.items)<d.length;return{campaigns:l,...e?{opportunity:{id:e.id,name:e.name,chainId:e.chainId,protocol:y(e.protocol)?{id:e.protocol.id,name:e.protocol.name}:void 0,explorerAddress:e.explorerAddress,identifier:e.identifier}}:{},chainId:m,...b(t),hasMore:a,summary:"Powered by Merkl \u2014 https://app.merkl.xyz. Campaign rules, budgets, timing, exclusions and configuration are public API data; verify the reward distribution chain and destination before entering."}}),u("earning_status",{view:{enum:["active","breakdowns","stats","claims"],description:"active lists earning opportunities; breakdowns shows reward details; stats shows totals; claims lists claims."},...g},async(t,n)=>{if(!k(n,{strict:!1}))throw new p("Provide a valid connected wallet address.");let r=t.view??"active";if(!["active","breakdowns","stats","claims"].includes(String(r)))throw new p("Choose active, breakdowns, stats or claims.");let c=r==="claims"?"claims":r==="breakdowns"?`users/${n}/rewards/chains/${m}/breakdowns`:`users/${n}/rewards/${r==="active"?"active-opportunities":"stats"}`,{page:e,items:s}=b(t),d=r==="breakdowns"?{}:{chainId:String(m)};r==="claims"&&(d.recipient=n);let o=await A(c,d),l=Number(e)*Number(s),a=Array.isArray(o)?o:r==="breakdowns"&&y(o)&&Array.isArray(o.opportunities)?o.opportunities:void 0,f=a?Array.isArray(o)?a.slice(l,l+Number(s)):{...o,opportunities:a.slice(l,l+Number(s))}:o,D=r==="active"&&Array.isArray(a)&&a.length===0?`${O(S,{after_deposit:N()})} `:"";return{view:r,chainId:m,wallet:n,data:f,...a?{page:e,items:s,hasMore:l+Number(s)<a.length}:{},summary:`${D}Powered by Merkl \u2014 https://app.merkl.xyz. API earning attribution and history can lag onchain state; pending earnings are not claimable. Private or restricted attribution may be omitted by Merkl. Recheck merkl_rewards before a claim.`}})]}};export{Z as a};
|