@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{a as Se,j as He,l as Re,m as Te}from"./MFQTBUSD.js";import{a as ne,b as ie}from"./AODUTN65.js";import{a as xe,h as Pe}from"./QAAKUIWE.js";import{a as Ae,f as Fe,g as Ee}from"./JCS24YBB.js";import{a as we,g as be}from"./BM4KHOFB.js";import{a as ge,h as ye}from"./ZSGW2ZSO.js";import{a as ke,g as fe}from"./RKJFSDGV.js";import{a as X}from"./TZG7HTVM.js";import{a as Z,j as N,o as J}from"./5Y457HYC.js";import{a as me,b as he}from"./64LAWFBE.js";import{a as ce,b as pe}from"./G53U6Y4L.js";import{a as ue,b as le}from"./FMEO7RX7.js";import{k as ee}from"./G4IX4CYN.js";import{a as Be,c as ve}from"./IJVBCEA2.js";import{b as re,c as se}from"./HPO673QQ.js";import{a as R,b as Ce}from"./JQVTHPUO.js";import{c as te,d as v,e as oe}from"./RKS3M7L5.js";import{d as ae,e as de}from"./5VKVAUFQ.js";import{g as K}from"./3RGED2KO.js";import{a as S,e as H,f as u,i as D,j as w,k as j,m as B,o as V,p as W,r as Y}from"./UMY6SP7C.js";import{b as f,i as O,j as q,k as L}from"./CJMVRV34.js";import{a as d}from"./XSD5NL7J.js";import{decodeAbiParameters as Ue,encodeAbiParameters as Q,formatUnits as Oe,getAddress as Ge,zeroAddress as qe}from"viem";var T=[{type:"tuple",components:[{name:"guardEndBlock",type:"uint40"},{name:"maxFeePips",type:"uint24"},{name:"snipeTaxPips",type:"uint24"},{name:"snipeFloorPips",type:"uint24"},{name:"snipeDecaySeconds",type:"uint16"},{name:"dynamicFeeSens",type:"uint16"},{name:"burnBps",type:"uint16"},{name:"lpBps",type:"uint16"},{name:"potBps",type:"uint16"},{name:"royaltyBps",type:"uint16"},{name:"protocolShareBps",type:"uint16"},{name:"potEveryNBuys",type:"uint32"},{name:"maxBuyQuoteAmount",type:"uint128"},{name:"potMinBuyQuote",type:"uint128"},{name:"royaltyTo",type:"address"},{name:"integrator",type:"address"}]}],Le=Ge("0x84b1B9e5D1cAfD9543E684BB39E9cbD478189EE2"),Ke=["anti-snipe","dynamic-fees","auto-burn","lp-rewards","arb-recapture","buy-sell-block","agent-gate","market-guard","market-hours-fee","managed-fee","zap-source","zap-target","swap-reward-mint","pay-later","exit-clock","holder-pot","storm-fee","wallet-cap","swap-cut","sandwich-guard"],Ve=["anti-snipe","dynamic-fees","auto-burn","lp-rewards","buy-sell-block","exit-clock","storm-fee","wallet-cap","swap-cut","sandwich-guard","holder-pot"],De=Ve,M={"anti-snipe":["guardEndBlock","taxPips","floorPips","decaySeconds","maxBuyQuoteAmount"],"dynamic-fees":["maxFeePips","sensitivity"],"auto-burn":["burnBps"],"lp-rewards":["lpBps"],"buy-sell-block":["buyPause","sellLock"],"exit-clock":["top","floor","horizon","unit","curve"],"storm-fee":["ceiling","floor"],"wallet-cap":["cap"],"swap-cut":["buy","sell","recipient"],"sandwich-guard":["window","maximum","recipient"],"holder-pot":["buy","sell"]},Ie={"market-guard":ge.wiring+" The launch advisory slot is occupied by the agent gate.","market-hours-fee":ke.wiring+" The launch advisory slot is occupied by the agent gate.","managed-fee":we.wiring+" The launch advisory slot is occupied by the agent gate.","zap-source":Z,"zap-target":xe,"swap-reward-mint":Se,"pay-later":X,"holder-pot":Ae.refusal},We={"buy-sell-block":"buyPause 0\u2013300 and sellLock 0\u20135 are twelve-second steps after launch; at least one positive. Requires an Anti-Snipe guard covering the windows. No fee.","wallet-cap":"cap is cumulative subject base units bought per wallet during the Anti-Snipe guard; it must fit the exact decimal mantissa/exponent codec. Sales do not restore it. No fee.","exit-clock":"LP-fee destination only. top 1\u2013100 and floor below top are ten-basis-point steps. horizon is 1\u201363 hours (unit 0) or 3\u201330 days (unit 1). curve 0 linear, 1 eight-segment halving, 2 eight steps. Pinned new-token lots determine holding age.","storm-fee":"LP-fee destination, tempo zero. ceiling 1\u2013200 and floor 0\u2013ceiling are 500-pip steps (0.05%). Cannot combine with Dynamic Fees.","swap-cut":"buy and sell 0\u2013100 are 1000-pip steps (0.1%); at least one positive. recipient is the checksummed named quote-claim payee after the decoded protocol share, shared with Sandwich Guard if combined.","sandwich-guard":"window 0\u20133 means 1\u20134 execution blocks. maximum 5\u201315 is 10000-pip steps (1%). recipient is the checksummed named quote-claim payee after the decoded protocol share, shared with Swap Cut if combined."},A={"market-guard":["terms"],"market-hours-fee":["terms","owner","lastCoveredYear"],"managed-fee":["terms","keeper","owner"],"zap-source":["takePips","vault","route"],"zap-target":["feeders","routes"],"swap-reward-mint":["minter","terms"]},F={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},Ye=new Set(["feed","factory","poolManager","rules","router","root","gate","sink","quote","subject","protocolRecipient","currency0","currency1","advisory","fixedRecipient","rewardToken","creatorRecipient"]),je={guardEndBlock:"Set the parent block ending the guard.",taxPips:"Set the initial buy surcharge in pips (10000 = 1%).",floorPips:"Set the final buy surcharge in pips (10000 = 1%).",decaySeconds:"Set the surcharge decay duration in seconds.",maxBuyQuoteAmount:"Set the maximum buy amount in quote token base units, using the quote token decimals.",maxFeePips:"Set the maximum pool fee in pips (10000 = 1%).",sensitivity:"Set dynamic fee sensitivity from 1 to 10.",burnBps:"Set the burn rate in basis points (100 = 1%).",lpBps:"Set the LP fee rate in basis points (100 = 1%).",buyPause:"Set the buy pause in twelve-second steps from 0 to 300.",sellLock:"Set the sell lock in twelve-second steps from 0 to 5.",top:"Set the initial LP fee in ten-basis-point steps.",horizon:"Set the exit-clock horizon in the selected unit.",unit:"Choose 0 for hours or 1 for days.",curve:"Choose 0 for linear, 1 for segmented halving, or 2 for stepped decay.",ceiling:"Set the storm fee ceiling in 500-pip steps.",recipient:"Use the intended quote-claim payee address.",window:"Set the sandwich guard window from 0 to 3, representing 1 to 4 execution blocks.",maximum:"Set the sandwich guard maximum in 10000-pip steps.",terms:"Provide the exact configured advisory terms.",route:"Provide the exact configured vault route.",routes:"Provide the exact configured feeder vault routes.",feeders:"Provide the intended feeder vault addresses.",takePips:"Set the quote take in pips (10000 = 1%).",lastCoveredYear:"Provide the last calendar year covered by the advisory.",minDepth:"Set the minimum depth in quote token base units, using the quote token decimals.",threshold:"Provide the vault threshold in quote token base units, using the quote token decimals.",maxPerZap:"Match the vault maximum per zap in quote token base units, or 0 for no cap.",maxRewardPerSwap:"Provide the maximum reward per swap in reward token base units, using the reward token decimals.",lifetimeRewardCap:"Provide the lifetime reward cap in reward token base units, using the reward token decimals.",maxSlicePerSwap:"Provide the maximum quote slice per swap in quote token base units, using the quote token decimals.",rewardPerQuoteWad:"Provide reward token base units per 10^18 quote token base units.",endsAt:"Provide the end timestamp in Unix seconds, or 0 for no time limit."},Ze={feed:"Provide the admitted market price feed address.",bandBps:"Set the market guard band in basis points (100 = 1%).",rampBps:"Set the market guard ramp in basis points (100 = 1%).",staleness:"Set the maximum feed age in seconds.",surchargePips:"Set the maximum market guard surcharge in pips (10000 = 1%).",regularPips:"Set the regular session surcharge in pips (10000 = 1%).",preMarketPips:"Set the pre-market surcharge in pips (10000 = 1%).",afterHoursPips:"Set the after-hours surcharge in pips (10000 = 1%).",overnightPips:"Set the overnight surcharge in pips (10000 = 1%).",closedPips:"Set the closed session surcharge in pips (10000 = 1%).",openRampSeconds:"Set the opening ramp duration in seconds.",closeRampSeconds:"Set the closing ramp duration in seconds.",surcharge:"Set the default managed LP surcharge in pips (10000 = 1%).",premium0:"Set the first directional premium in pips (10000 = 1%).",premium1:"Set the second directional premium in pips (10000 = 1%).",maxStep:"Set the maximum keeper update step in pips (10000 = 1%).",minInterval:"Set the minimum keeper update interval in seconds.",maxTtl:"Set the maximum target lifetime in seconds.",factory:"Provide the factory contract address.",poolManager:"Provide the pool manager contract address.",rules:"Provide the Rules contract address.",router:"Provide the vault router address.",root:"Provide the Hookr root contract address.",gate:"Provide the target gate contract address.",sink:"Provide the intended subject token sink address.",quote:"Provide the quote token address.",subject:"Provide the subject token address.",protocolRecipient:"Provide the intended protocol recipient address.",currency0:"Provide the target pool currency0 address.",currency1:"Provide the target pool currency1 address.",advisory:"Provide the advisory contract address.",fixedRecipient:"Provide the intended fixed reward recipient address, or the zero address in trader mode.",rewardToken:"Provide the reward token address.",creatorRecipient:"Provide the intended creator recipient address.",targetId:"Provide the target pool ID as a 0x-prefixed 32-byte hex string.",poolId:"Provide the pool ID as a 0x-prefixed 32-byte hex string.",accountInitCodeHash:"Provide the account init code hash as a 0x-prefixed 32-byte hex string.",quoteIsCurrency0:"Set whether the quote token is currency0 in the target pool.",tickLower:"Provide the lower liquidity tick as a signed decimal string.",tickUpper:"Provide the upper liquidity tick as a signed decimal string.",tickSpacing:"Provide the target pool tick spacing as a signed decimal string.",fee:"Provide the target pool fee in pips (10000 = 1%).",impactBps:"Provide the vault impact limit in basis points (100 = 1%).",rewardBps:"Provide the zap caller bounty rate in basis points (100 = 1%).",protocolShareBps:"Provide the protocol share in basis points (100 = 1%).",windowBlocks:"Provide the vault impact window in blocks.",windowScope:"Match the existing vault impact-window scope as a decimal uint8 string.",buyTakePips:"Provide the buy quote take in pips (10000 = 1%).",sellTakePips:"Provide the sell quote take in pips (10000 = 1%).",mintGasLimit:"Provide the gas limit for each reward mint."},Je=(e,t)=>e==="mode"?t==="market-guard"?"Choose 1 to refuse or 2 to apply a surcharge.":t==="swap-reward-mint"?"Choose 0 for trader mode or 1 for fixed recipient mode.":"Choose 0 to send bought subject to the sink or 1 for permanent target liquidity.":e==="flags"?t==="market-guard"?"Choose 0 for subject in quote or 1 for quote in subject feed direction.":"Provide schedule flags as a decimal string (0 or 1), controlling weekday surcharges outside calendar coverage.":e==="cap"?"Set the managed LP surcharge cap in pips (10000 = 1%).":Ze[e]??je[e],z=(e,t)=>({type:"object",additionalProperties:!1,required:e,properties:Object.fromEntries(e.map(r=>[r,{...Ye.has(r)?F:["targetId","poolId","accountInitCodeHash"].includes(r)?{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}:r==="quoteIsCurrency0"?{type:"boolean"}:["tickLower","tickUpper","tickSpacing"].includes(r)?{type:"string",pattern:"^(0|-?[1-9][0-9]*)$"}:S,description:Je(r,t)}]))}),Ne=e=>je[e]??{owner:"Provide the advisory owner address.",keeper:"Provide the admitted keeper address.",vault:"Provide the source vault address.",minter:"Provide the reward minter address."}[e],Xe={"market-guard":["feed","mode","flags","bandBps","rampBps","staleness","surchargePips","minDepth"],"market-hours-fee":["regularPips","preMarketPips","afterHoursPips","overnightPips","closedPips","openRampSeconds","closeRampSeconds","flags"],"managed-fee":["cap","surcharge","premium0","premium1","maxStep","minInterval","maxTtl"],"swap-reward-mint":He},P={"swap-reward-mint":{thirdPartyPayees:{type:"array",minItems:1,maxItems:2,uniqueItems:!0,items:F,description:"List up to two distinct third-party creator or fixed reward payee addresses; omit when all payees are the launching wallet."}}};if(Object.keys(P["swap-reward-mint"]).join()!==Re.optional.join())throw new Error("swap-reward-mint optional fields differ from its validator");var et=e=>({type:"object",additionalProperties:!1,properties:{id:{const:e,description:"Select this Hook Block by its ID."},...Object.fromEntries(A[e].map(t=>[t,{...t==="terms"?z(Xe[e],e):t==="route"?z(N,"vault"):t==="routes"?{type:"array",minItems:1,maxItems:4,items:z(N,"vault")}:t==="feeders"?{type:"array",minItems:1,maxItems:4,items:F}:["owner","keeper","vault","minter","factory"].includes(t)?F:S,description:Ne(t)}])),...Object.hasOwn(P,e)?P[e]:{}},required:["id",...A[e]]}),$e=(e,t)=>({type:"object",description:We[e],additionalProperties:!1,properties:{id:{const:e,description:"Select this Hook Block by its ID."},...Object.fromEntries(t.map(r=>[r,{...r==="recipient"?{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"}:S,description:r==="cap"&&e==="wallet-cap"?"Set the cumulative wallet buy cap in subject token base units, using the subject token decimals.":r==="floor"?e==="storm-fee"?"Set the storm fee floor in 500-pip steps.":"Set the exit-clock floor in ten-basis-point steps.":r==="buy"||r==="sell"?`Set the ${r} quote charge in 1000-pip steps (0.1%) for ${e==="holder-pot"?"the holder pot":"the quote-claim payee"}.`:Ne(r)}]))},required:["id",...t]}),zt={type:"array",maxItems:20,items:{oneOf:[$e("anti-snipe",["guardEndBlock","taxPips","floorPips","decaySeconds","maxBuyQuoteAmount"]),...Object.entries(M).filter(([e])=>e!=="anti-snipe").map(([e,t])=>$e(e,t)),...v.map(et),{type:"object",additionalProperties:!1,properties:{id:{type:"string",description:"Select the Hook Block by its ID.",enum:Ke.filter(e=>!De.includes(e)&&!v.includes(e))}},required:["id"]}]},description:"Explicit Hook Blocks. Unsupported codecs are refused. Arb recapture and agent-gate use their dedicated launch fields. Empty means none beyond those fields."};function tt(e){let t=B(e);if(!Array.isArray(t.blocks)||!t.blocks.length||t.blocks.length>64)throw new d("Hookr block list is unavailable or incomplete; no empty catalog is inferred.");let r=new Set;return t.blocks.map(o=>{let s=B(o);if(typeof s.id!="string"||!/^[a-z][a-z-]{0,63}$/.test(s.id)||r.has(s.id)||typeof s.live!="boolean"||s.openToNewPools!==void 0&&typeof s.openToNewPools!="boolean")throw new d("Hookr block list is malformed or duplicated.");r.add(s.id);let a=s.live&&s.openToNewPools!==!1,n=a&&(De.includes(s.id)||v.includes(s.id));return{id:s.id,...s.address===void 0?{}:{address:D(s.address)},live:s.live,openToNewPools:a,supported:n,refusal:n?null:a?Object.hasOwn(Ie,s.id)?Ie[s.id]:`Hook Block ${s.id} needs a verified field codec and payment terms before Oak can launch it. Use its dedicated launch fields when available.`:`Hook Block ${s.id} is not open to new pools.`}})}async function _(e){return tt(await K(e,"hookr_blocks",{}))}function ot(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>20)throw new d("Choose at most twenty distinct Hook Blocks.");let t=new Set;return e.map(r=>{let o=B(r);if(typeof o.id!="string"||t.has(o.id))throw new d("Choose distinct Hook Block IDs.");if(t.add(o.id),Object.hasOwn(A,o.id)){let a=A[o.id],n=Object.hasOwn(P,o.id)?Object.keys(P[o.id]):[];return H(o,["id",...a,...n],["id",...a]),o}let s=Object.hasOwn(M,o.id)?M[o.id]:[];H(o,["id",...s],["id",...s]);for(let a of s)a==="recipient"?D(o[a]):u(o[a],["maxBuyQuoteAmount","cap"].includes(a)?128:a==="guardEndBlock"?40:24);return o})}function ze(e){if((e.length-2)/2!==512)throw new d("Hookr Rules terms must contain exactly sixteen words.");let[t]=Ue(T,e);if(Q(T,[t]).toLowerCase()!==e.toLowerCase())throw new d("Hookr Rules terms are not canonical.");return t}function rt(e,t){let r=u(t.guardEndBlock,40),o=Number(u(t.taxPips,24)),s=Number(u(t.floorPips,24)),a=Number(u(t.decaySeconds,16)),n=u(t.maxBuyQuoteAmount,128);if(!r||!o||o>597e3||!n||(a===0?s!==0:s>=o)||a>3600)throw new d("Anti-Snipe needs a future parent-block guard, positive buy cap/tax, a lower floor when decaying, and at most 3600 decay seconds.");return{...e,guardEndBlock:Number(r),snipeTaxPips:o,snipeFloorPips:s,snipeDecaySeconds:a,maxBuyQuoteAmount:n}}function st(e,t){let r=Number(u(t.maxFeePips,24)),o=Number(u(t.sensitivity,16));if(r<=3e3||r>6e5||o<1||o>10)throw new d("Dynamic fees need maxFeePips above 3000 and at most 600000, with sensitivity 1 to 10.");return{...e,maxFeePips:r,dynamicFeeSens:o}}function nt(e,t){let r=Number(u(t.burnBps,16));if(r<1||r>1e3)throw new d("Auto Burn needs burnBps between 1 and 1000.");return{...e,burnBps:r}}function it(e,t){let r=Number(u(t.lpBps,16));if(r<1||r>1e3)throw new d("LP Rewards needs lpBps between 1 and 1000.");if(e.lpBps&&e.lpBps!==r)throw new d("LP Rewards conflicts with lpRewardsBps. Choose the same rate in both fields.");return{...e,lpBps:r}}async function at(e,t,r,o,s){if(r.some(i=>v.includes(i.id)))throw new d("The agent gate and an advisory Hook Block cannot share the one advisory slot. Use an explicit open launch profile.");let a=s??(r.length?await _(e):[]),n=t,p=[...r.filter(i=>i.id==="anti-snipe"),...r.filter(i=>i.id!=="anti-snipe")];for(let i of p){let c=a.find(l=>l.id===i.id);if(!c||!c.openToNewPools)throw new d(`Hook Block ${String(i.id)} is not open to new pools.`);if(!c.supported)throw new d(c.refusal);switch(i.id){case"anti-snipe":n=rt(n,i);break;case"dynamic-fees":n=st(n,i);break;case"auto-burn":n=nt(n,i);break;case"lp-rewards":n=it(n,i);break;case"buy-sell-block":n=re(n,i);break;case"wallet-cap":n=ne(n,i);break;case"exit-clock":{let l=Object.fromEntries(Object.entries(i).filter(([m])=>m!=="id"));n=ae(n,l);break}case"storm-fee":n=ce(n,i);break;case"swap-cut":n=ue(n,i);break;case"sandwich-guard":n=me(n,i);break;case"holder-pot":n=Fe(n,i);break}}if(R(n),r.some(i=>Object.hasOwn(Me,String(i.id)))&&await gt(e,n,o),n.burnBps+n.lpBps>1e3)throw new d("Auto Burn plus LP Rewards must not exceed 1000 bps.");return ze(Q(T,[n]))}function dt(e,t=3e3,r=0n){R(e);let o=Ce(e),s=BigInt(e.protocolShareBps),a=g=>(BigInt(g)*s+99n)/100n,n=a(e.lpBps),p=a(e.burnBps),i=BigInt(e.lpBps)*100n-n,c=BigInt(e.maxFeePips-t),l=BigInt(e.snipeTaxPips),m=BigInt(t)+i+c+l+o.lp,E=n+p+c*s/10000n+l*s/10000n,x=e.lpBps!==0||e.burnBps!==0||c*s>=10000n||l*s>=10000n;return{maxLpFeePips:m,maxQuoteTakePips:(E>(x?0n:r)?E:x?0n:r)+o.quote,maxSubjectTakeBps:(BigInt(e.burnBps)*100n-p)/100n}}var b=e=>`${Oe(BigInt(e),4)}%`;function ct(e,t){return`Anti-Snipe: buys before parent block ${e.guardEndBlock} pay up to ${e.snipeTaxPips} surcharge pips (${b(e.snipeTaxPips)}), decaying to ${e.snipeFloorPips} pips (${b(e.snipeFloorPips)}) over ${e.snipeDecaySeconds} seconds; buy cap ${e.maxBuyQuoteAmount} quote base units. Hookr ${t} gets floor(charged pips * ${e.protocolShareBps}/10000) in quote; in-range LPs get the remaining LP fee. Principal locked until parent block ${e.guardEndBlock}.`}function pt(e,t){return`Dynamic fees: maximum ${e.maxFeePips} pips (${b(e.maxFeePips)}), sensitivity ${e.dynamicFeeSens}; Hookr ${t} gets floor(dynamic surcharge pips * ${e.protocolShareBps}/10000) in quote; in-range LPs get the remaining LP fee. Default tempo 30/120 seconds, carry 7500 bps, move 200 ticks; minimum dynamic liquidity is clamp(floor(launch liquidity/100), 1, 2^96-1).`}function ut(e,t){let r=(BigInt(e.burnBps)*BigInt(e.protocolShareBps)+99n)/100n;return`Auto Burn: configured ${e.burnBps} bps; subject output burn ${(BigInt(e.burnBps)*100n-r)/100n} bps after Hookr's slice. Hookr ${t} gets ${r} pips (${b(r)}) of gross buyer spend in quote; burned subject goes to 0x000000000000000000000000000000000000dEaD.`}function lt(e,t,r){let o=(BigInt(e.lpBps)*BigInt(e.protocolShareBps)+99n)/100n;return`LP Rewards: buys pay ${e.lpBps*100} gross pips (${b(e.lpBps*100)}); Hookr ${t} gets ${o} quote pips (${b(o)}), in-range LPs get ${BigInt(e.lpBps)*100n-o} LP fee pips (${b(BigInt(e.lpBps)*100n-o)}); creator royalty 0${e.integrator===Le?`; Oak ${e.integrator} gets ${r===void 0?"the share of Hookr's part that Hookr lists for it":`${Oe(r,2)}% of Hookr's part`}`:`, integrator ${e.integrator===qe?"0":e.integrator}`}.`}function Mt(e,t,r){let o=ze(e);if(R(o),o.integrator!==qe&&o.integrator!==Le||o.royaltyBps||o.potBps)throw new d("Hookr payment terms include an unsupported integrator, royalty or pot.");return[o.guardEndBlock?ct(o,t):"",o.dynamicFeeSens?pt(o,t):"",o.burnBps?ut(o,t):"",o.lpBps?lt(o,t,r):"",o.potEveryNBuys&1<<23?se(o):"",o.potEveryNBuys&1<<19?ie(o):"",o.potEveryNBuys&1<<20?de(o,t):"",o.potEveryNBuys&1<<22?pe(o,t):"",o.potEveryNBuys&1<<21?Ee(o,t):"",o.potEveryNBuys&16383&&!(o.potEveryNBuys&1<<21)?le(o,t):"",o.potEveryNBuys&1<<17?he(o,t):""].filter(Boolean)}function Qt(e){return[{name:"hookr_blocks",inputSchema:{type:"object",additionalProperties:!1,properties:{}},execute:async t=>(H(t,[]),{blocks:await _(e)})}]}var mt="0x4ff3630dd3d4ca59d00c08a7c8be527f6b90ffd700a7cc6a36a837de2ee4565e",ht="0x53a44e55150d75ad35c98d9b48c13a1ab6f4be9657d74083149e7d992e45e46f",Me={"swap-cut":"0x9394881A6Fe570adEC4480471B4D52652d263878","exit-clock":"0x2b6aB976d05Dcc7Cad53bF9324Fe892511036348","storm-fee":"0xD577087cbf9bEC0Ca0392efD8A83C3fE6A09Bd1f","wallet-cap":"0xfe5c29D2d6B7aC383A63291a771197e4D83E1d9c","buy-sell-block":"0xa64be3B5eC9B7310CBd3F77736ca5D6Fa81C5BCb","holder-pot":"0x740b2Da80eBB44613C2b44f380D55ECBECbFf11f","sandwich-guard":"0xa214e747d1a8E767F88ed2170be62E22ED79a269"};async function gt(e,t,r){let o=e.clientFor(4663),s=r??await q(o);await O(o,s.number,[f.rulesV1,f.launcherV1]);let a=[t.potEveryNBuys&16383?"swap-cut":"",...[[21,"holder-pot"],[20,"exit-clock"],[22,"storm-fee"],[19,"wallet-cap"],[23,"buy-sell-block"],[17,"sandwich-guard"]].filter(([n])=>t.potEveryNBuys&1<<Number(n)).map(([,n])=>String(n))].filter(Boolean);for(let n of a){let p=Me[n],i=B(await W(o,Y,V("registry"),"admission",[f.rulesV1,p],s.number)),c=B(i.caps);if(i.implementation!==p||w(i.kind,8)!==0n||i.codeHash!==mt||i.schemaHash!==ht||w(i.gasLimit,32)===0n||w(i.phaseMask,8)!==1n||j(i.failOpen)||j(i.feeOnly)||w(c.maxLpFeePips,24)||w(c.maxQuoteTakePips,24)||w(c.maxSubjectTakeBps,16))throw new d(`Hook Block ${n} is not admitted on the pinned core with its reviewed key terms.`)}if(t.potEveryNBuys&1<<23){let n=await ee(o,s),p=t.potMinBuyQuote>>85n&511n,i=t.potMinBuyQuote>>94n&7n;if(BigInt(t.guardEndBlock)-n-4n<(p>i?p:i))throw new d("The parent-block guard must cover the complete Buy/Sell Block windows plus four spare parent blocks.")}await L(o,s)}async function _t(e,t,r,o,s,a,n=0n,p){let i=ot(t.hookBlocks),c=oe(t.launchProfile,t.agentGate,i),l=i.filter($=>!v.includes($.id)),m=e.clientFor(4663);if((await q(m,s.number)).hash!==s.hash)throw new d("Hookr launch block changed before block validation.");await O(m,s.number,[f.rootV1,f.rulesV1,f.launcherV1]);let x=p??(i.length?await _(e):[]),g=await at(e,r,l,s,x),U=Q(T,[g]),G=dt(g,3e3,n);if(!c.advisory)return{kind:c.kind,rules:g,blockTerms:U,advisory:null,bounds:G,summaryLines:[]};let y=c.advisory,C=x.find($=>$.id===y.id);if(!C?.openToNewPools)throw new d(`Hook Block ${String(y.id)} is not open to new pools.`);let h=await yt(m,s.number,y,o);y.id==="market-guard"&&!(g.potEveryNBuys&te)&&(h.phases=3);let I="requiredCaps"in h?h.requiredCaps:h.bounds,k=await Be(m,s.number,h.descriptor,h.phases,I);if(C.address!==void 0&&C.address!==k.address)throw new d("Hookr catalog advisory address differs from the source-verified selection.");let Qe=y.id==="zap-source"?a.maxQuoteTakePips+I.maxQuoteTakePips:y.id==="swap-reward-mint"?kt(g,n)+I.maxQuoteTakePips:0n,_e=ve(G,k.caps,a,Qe);return await L(m,s),{kind:c.kind,rules:g,blockTerms:U,advisory:{...k,data:h.data,id:String(y.id),summary:h.summary},bounds:_e,summaryLines:[`No agent identity gate. ${y.id==="zap-target"?"Only the frozen feeder vaults may buy; any wallet may sell.":"Wallets need no agent identity; the selected advisory can impose its own decoded restrictions."} ${h.summary}`,`Advisory ${k.address}, phases ${k.phases}, fail closed, gas ${k.gasLimit}; full admitted reservation ${k.caps.maxLpFeePips} LP pips and ${k.caps.maxQuoteTakePips} quote pips.`]}}async function yt(e,t,r,o){let s=Object.fromEntries(Object.entries(r).filter(([n])=>n!=="id")),a;switch(r.id){case"market-guard":a=await ye(e,t,s,o);break;case"market-hours-fee":a=await fe(e,t,s);break;case"managed-fee":a=await be(e,t,s);break;case"zap-source":a=await J(e,t,s,o);break;case"zap-target":a=await Pe(e,t,s,o);break;case"swap-reward-mint":a=await Te(e,t,s,o);break;default:throw new d("Unknown Hookr advisory profile.")}return a}function kt(e,t){let r=BigInt(e.protocolShareBps),o=(BigInt(e.lpBps)*r+99n)/100n,s=(BigInt(e.lpBps)*100n-o)*BigInt(e.royaltyBps)/10000n,a=o+s+(BigInt(e.burnBps)*r+99n)/100n+BigInt(e.maxFeePips-3e3+e.snipeTaxPips)*r/10000n;return a>s+t?a:s+t}export{T as a,Le as b,Ke as c,Ve as d,A as e,zt as f,tt as g,_ as h,ot as i,ze as j,rt as k,st as l,nt as m,it as n,at as o,dt as p,ct as q,pt as r,ut as s,lt as t,Mt as u,Qt as v,_t as w,yt as x,kt as y};
|
|
1
|
+
import{a as Se,j as He,l as Re,m as Te}from"./MFQTBUSD.js";import{a as ne,b as ie}from"./AODUTN65.js";import{a as xe,h as Pe}from"./QAAKUIWE.js";import{a as Ae,f as Fe,g as Ee}from"./JCS24YBB.js";import{a as we,g as be}from"./BM4KHOFB.js";import{a as ge,h as ye}from"./ZSGW2ZSO.js";import{a as ke,g as fe}from"./RKJFSDGV.js";import{a as X}from"./H5J2LFPZ.js";import{a as Z,j as N,o as J}from"./5Y457HYC.js";import{a as me,b as he}from"./64LAWFBE.js";import{a as ce,b as pe}from"./G53U6Y4L.js";import{a as ue,b as le}from"./FMEO7RX7.js";import{k as ee}from"./NCCKCGKL.js";import{a as Be,c as ve}from"./IJVBCEA2.js";import{b as re,c as se}from"./HPO673QQ.js";import{a as R,b as Ce}from"./JQVTHPUO.js";import{c as te,d as v,e as oe}from"./RKS3M7L5.js";import{d as ae,e as de}from"./5VKVAUFQ.js";import{g as K}from"./3RGED2KO.js";import{a as S,e as H,f as u,i as D,j as w,k as j,m as B,o as V,p as W,r as Y}from"./UMY6SP7C.js";import{b as f,i as O,j as q,k as L}from"./CJMVRV34.js";import{a as d}from"./XSD5NL7J.js";import{decodeAbiParameters as Ue,encodeAbiParameters as Q,formatUnits as Oe,getAddress as Ge,zeroAddress as qe}from"viem";var T=[{type:"tuple",components:[{name:"guardEndBlock",type:"uint40"},{name:"maxFeePips",type:"uint24"},{name:"snipeTaxPips",type:"uint24"},{name:"snipeFloorPips",type:"uint24"},{name:"snipeDecaySeconds",type:"uint16"},{name:"dynamicFeeSens",type:"uint16"},{name:"burnBps",type:"uint16"},{name:"lpBps",type:"uint16"},{name:"potBps",type:"uint16"},{name:"royaltyBps",type:"uint16"},{name:"protocolShareBps",type:"uint16"},{name:"potEveryNBuys",type:"uint32"},{name:"maxBuyQuoteAmount",type:"uint128"},{name:"potMinBuyQuote",type:"uint128"},{name:"royaltyTo",type:"address"},{name:"integrator",type:"address"}]}],Le=Ge("0x84b1B9e5D1cAfD9543E684BB39E9cbD478189EE2"),Ke=["anti-snipe","dynamic-fees","auto-burn","lp-rewards","arb-recapture","buy-sell-block","agent-gate","market-guard","market-hours-fee","managed-fee","zap-source","zap-target","swap-reward-mint","pay-later","exit-clock","holder-pot","storm-fee","wallet-cap","swap-cut","sandwich-guard"],Ve=["anti-snipe","dynamic-fees","auto-burn","lp-rewards","buy-sell-block","exit-clock","storm-fee","wallet-cap","swap-cut","sandwich-guard","holder-pot"],De=Ve,M={"anti-snipe":["guardEndBlock","taxPips","floorPips","decaySeconds","maxBuyQuoteAmount"],"dynamic-fees":["maxFeePips","sensitivity"],"auto-burn":["burnBps"],"lp-rewards":["lpBps"],"buy-sell-block":["buyPause","sellLock"],"exit-clock":["top","floor","horizon","unit","curve"],"storm-fee":["ceiling","floor"],"wallet-cap":["cap"],"swap-cut":["buy","sell","recipient"],"sandwich-guard":["window","maximum","recipient"],"holder-pot":["buy","sell"]},Ie={"market-guard":ge.wiring+" The launch advisory slot is occupied by the agent gate.","market-hours-fee":ke.wiring+" The launch advisory slot is occupied by the agent gate.","managed-fee":we.wiring+" The launch advisory slot is occupied by the agent gate.","zap-source":Z,"zap-target":xe,"swap-reward-mint":Se,"pay-later":X,"holder-pot":Ae.refusal},We={"buy-sell-block":"buyPause 0\u2013300 and sellLock 0\u20135 are twelve-second steps after launch; at least one positive. Requires an Anti-Snipe guard covering the windows. No fee.","wallet-cap":"cap is cumulative subject base units bought per wallet during the Anti-Snipe guard; it must fit the exact decimal mantissa/exponent codec. Sales do not restore it. No fee.","exit-clock":"LP-fee destination only. top 1\u2013100 and floor below top are ten-basis-point steps. horizon is 1\u201363 hours (unit 0) or 3\u201330 days (unit 1). curve 0 linear, 1 eight-segment halving, 2 eight steps. Pinned new-token lots determine holding age.","storm-fee":"LP-fee destination, tempo zero. ceiling 1\u2013200 and floor 0\u2013ceiling are 500-pip steps (0.05%). Cannot combine with Dynamic Fees.","swap-cut":"buy and sell 0\u2013100 are 1000-pip steps (0.1%); at least one positive. recipient is the checksummed named quote-claim payee after the decoded protocol share, shared with Sandwich Guard if combined.","sandwich-guard":"window 0\u20133 means 1\u20134 execution blocks. maximum 5\u201315 is 10000-pip steps (1%). recipient is the checksummed named quote-claim payee after the decoded protocol share, shared with Swap Cut if combined."},A={"market-guard":["terms"],"market-hours-fee":["terms","owner","lastCoveredYear"],"managed-fee":["terms","keeper","owner"],"zap-source":["takePips","vault","route"],"zap-target":["feeders","routes"],"swap-reward-mint":["minter","terms"]},F={type:"string",pattern:"^0x[0-9a-fA-F]{40}$"},Ye=new Set(["feed","factory","poolManager","rules","router","root","gate","sink","quote","subject","protocolRecipient","currency0","currency1","advisory","fixedRecipient","rewardToken","creatorRecipient"]),je={guardEndBlock:"Set the parent block ending the guard.",taxPips:"Set the initial buy surcharge in pips (10000 = 1%).",floorPips:"Set the final buy surcharge in pips (10000 = 1%).",decaySeconds:"Set the surcharge decay duration in seconds.",maxBuyQuoteAmount:"Set the maximum buy amount in quote token base units, using the quote token decimals.",maxFeePips:"Set the maximum pool fee in pips (10000 = 1%).",sensitivity:"Set dynamic fee sensitivity from 1 to 10.",burnBps:"Set the burn rate in basis points (100 = 1%).",lpBps:"Set the LP fee rate in basis points (100 = 1%).",buyPause:"Set the buy pause in twelve-second steps from 0 to 300.",sellLock:"Set the sell lock in twelve-second steps from 0 to 5.",top:"Set the initial LP fee in ten-basis-point steps.",horizon:"Set the exit-clock horizon in the selected unit.",unit:"Choose 0 for hours or 1 for days.",curve:"Choose 0 for linear, 1 for segmented halving, or 2 for stepped decay.",ceiling:"Set the storm fee ceiling in 500-pip steps.",recipient:"Use the intended quote-claim payee address.",window:"Set the sandwich guard window from 0 to 3, representing 1 to 4 execution blocks.",maximum:"Set the sandwich guard maximum in 10000-pip steps.",terms:"Provide the exact configured advisory terms.",route:"Provide the exact configured vault route.",routes:"Provide the exact configured feeder vault routes.",feeders:"Provide the intended feeder vault addresses.",takePips:"Set the quote take in pips (10000 = 1%).",lastCoveredYear:"Provide the last calendar year covered by the advisory.",minDepth:"Set the minimum depth in quote token base units, using the quote token decimals.",threshold:"Provide the vault threshold in quote token base units, using the quote token decimals.",maxPerZap:"Match the vault maximum per zap in quote token base units, or 0 for no cap.",maxRewardPerSwap:"Provide the maximum reward per swap in reward token base units, using the reward token decimals.",lifetimeRewardCap:"Provide the lifetime reward cap in reward token base units, using the reward token decimals.",maxSlicePerSwap:"Provide the maximum quote slice per swap in quote token base units, using the quote token decimals.",rewardPerQuoteWad:"Provide reward token base units per 10^18 quote token base units.",endsAt:"Provide the end timestamp in Unix seconds, or 0 for no time limit."},Ze={feed:"Provide the admitted market price feed address.",bandBps:"Set the market guard band in basis points (100 = 1%).",rampBps:"Set the market guard ramp in basis points (100 = 1%).",staleness:"Set the maximum feed age in seconds.",surchargePips:"Set the maximum market guard surcharge in pips (10000 = 1%).",regularPips:"Set the regular session surcharge in pips (10000 = 1%).",preMarketPips:"Set the pre-market surcharge in pips (10000 = 1%).",afterHoursPips:"Set the after-hours surcharge in pips (10000 = 1%).",overnightPips:"Set the overnight surcharge in pips (10000 = 1%).",closedPips:"Set the closed session surcharge in pips (10000 = 1%).",openRampSeconds:"Set the opening ramp duration in seconds.",closeRampSeconds:"Set the closing ramp duration in seconds.",surcharge:"Set the default managed LP surcharge in pips (10000 = 1%).",premium0:"Set the first directional premium in pips (10000 = 1%).",premium1:"Set the second directional premium in pips (10000 = 1%).",maxStep:"Set the maximum keeper update step in pips (10000 = 1%).",minInterval:"Set the minimum keeper update interval in seconds.",maxTtl:"Set the maximum target lifetime in seconds.",factory:"Provide the factory contract address.",poolManager:"Provide the pool manager contract address.",rules:"Provide the Rules contract address.",router:"Provide the vault router address.",root:"Provide the Hookr root contract address.",gate:"Provide the target gate contract address.",sink:"Provide the intended subject token sink address.",quote:"Provide the quote token address.",subject:"Provide the subject token address.",protocolRecipient:"Provide the intended protocol recipient address.",currency0:"Provide the target pool currency0 address.",currency1:"Provide the target pool currency1 address.",advisory:"Provide the advisory contract address.",fixedRecipient:"Provide the intended fixed reward recipient address, or the zero address in trader mode.",rewardToken:"Provide the reward token address.",creatorRecipient:"Provide the intended creator recipient address.",targetId:"Provide the target pool ID as a 0x-prefixed 32-byte hex string.",poolId:"Provide the pool ID as a 0x-prefixed 32-byte hex string.",accountInitCodeHash:"Provide the account init code hash as a 0x-prefixed 32-byte hex string.",quoteIsCurrency0:"Set whether the quote token is currency0 in the target pool.",tickLower:"Provide the lower liquidity tick as a signed decimal string.",tickUpper:"Provide the upper liquidity tick as a signed decimal string.",tickSpacing:"Provide the target pool tick spacing as a signed decimal string.",fee:"Provide the target pool fee in pips (10000 = 1%).",impactBps:"Provide the vault impact limit in basis points (100 = 1%).",rewardBps:"Provide the zap caller bounty rate in basis points (100 = 1%).",protocolShareBps:"Provide the protocol share in basis points (100 = 1%).",windowBlocks:"Provide the vault impact window in blocks.",windowScope:"Match the existing vault impact-window scope as a decimal uint8 string.",buyTakePips:"Provide the buy quote take in pips (10000 = 1%).",sellTakePips:"Provide the sell quote take in pips (10000 = 1%).",mintGasLimit:"Provide the gas limit for each reward mint."},Je=(e,t)=>e==="mode"?t==="market-guard"?"Choose 1 to refuse or 2 to apply a surcharge.":t==="swap-reward-mint"?"Choose 0 for trader mode or 1 for fixed recipient mode.":"Choose 0 to send bought subject to the sink or 1 for permanent target liquidity.":e==="flags"?t==="market-guard"?"Choose 0 for subject in quote or 1 for quote in subject feed direction.":"Provide schedule flags as a decimal string (0 or 1), controlling weekday surcharges outside calendar coverage.":e==="cap"?"Set the managed LP surcharge cap in pips (10000 = 1%).":Ze[e]??je[e],z=(e,t)=>({type:"object",additionalProperties:!1,required:e,properties:Object.fromEntries(e.map(r=>[r,{...Ye.has(r)?F:["targetId","poolId","accountInitCodeHash"].includes(r)?{type:"string",pattern:"^0x[0-9a-fA-F]{64}$"}:r==="quoteIsCurrency0"?{type:"boolean"}:["tickLower","tickUpper","tickSpacing"].includes(r)?{type:"string",pattern:"^(0|-?[1-9][0-9]*)$"}:S,description:Je(r,t)}]))}),Ne=e=>je[e]??{owner:"Provide the advisory owner address.",keeper:"Provide the admitted keeper address.",vault:"Provide the source vault address.",minter:"Provide the reward minter address."}[e],Xe={"market-guard":["feed","mode","flags","bandBps","rampBps","staleness","surchargePips","minDepth"],"market-hours-fee":["regularPips","preMarketPips","afterHoursPips","overnightPips","closedPips","openRampSeconds","closeRampSeconds","flags"],"managed-fee":["cap","surcharge","premium0","premium1","maxStep","minInterval","maxTtl"],"swap-reward-mint":He},P={"swap-reward-mint":{thirdPartyPayees:{type:"array",minItems:1,maxItems:2,uniqueItems:!0,items:F,description:"List up to two distinct third-party creator or fixed reward payee addresses; omit when all payees are the launching wallet."}}};if(Object.keys(P["swap-reward-mint"]).join()!==Re.optional.join())throw new Error("swap-reward-mint optional fields differ from its validator");var et=e=>({type:"object",additionalProperties:!1,properties:{id:{const:e,description:"Select this Hook Block by its ID."},...Object.fromEntries(A[e].map(t=>[t,{...t==="terms"?z(Xe[e],e):t==="route"?z(N,"vault"):t==="routes"?{type:"array",minItems:1,maxItems:4,items:z(N,"vault")}:t==="feeders"?{type:"array",minItems:1,maxItems:4,items:F}:["owner","keeper","vault","minter","factory"].includes(t)?F:S,description:Ne(t)}])),...Object.hasOwn(P,e)?P[e]:{}},required:["id",...A[e]]}),$e=(e,t)=>({type:"object",description:We[e],additionalProperties:!1,properties:{id:{const:e,description:"Select this Hook Block by its ID."},...Object.fromEntries(t.map(r=>[r,{...r==="recipient"?{type:"string",pattern:"^0x[0-9a-fA-F]{40}$"}:S,description:r==="cap"&&e==="wallet-cap"?"Set the cumulative wallet buy cap in subject token base units, using the subject token decimals.":r==="floor"?e==="storm-fee"?"Set the storm fee floor in 500-pip steps.":"Set the exit-clock floor in ten-basis-point steps.":r==="buy"||r==="sell"?`Set the ${r} quote charge in 1000-pip steps (0.1%) for ${e==="holder-pot"?"the holder pot":"the quote-claim payee"}.`:Ne(r)}]))},required:["id",...t]}),zt={type:"array",maxItems:20,items:{oneOf:[$e("anti-snipe",["guardEndBlock","taxPips","floorPips","decaySeconds","maxBuyQuoteAmount"]),...Object.entries(M).filter(([e])=>e!=="anti-snipe").map(([e,t])=>$e(e,t)),...v.map(et),{type:"object",additionalProperties:!1,properties:{id:{type:"string",description:"Select the Hook Block by its ID.",enum:Ke.filter(e=>!De.includes(e)&&!v.includes(e))}},required:["id"]}]},description:"Explicit Hook Blocks. Unsupported codecs are refused. Arb recapture and agent-gate use their dedicated launch fields. Empty means none beyond those fields."};function tt(e){let t=B(e);if(!Array.isArray(t.blocks)||!t.blocks.length||t.blocks.length>64)throw new d("Hookr block list is unavailable or incomplete; no empty catalog is inferred.");let r=new Set;return t.blocks.map(o=>{let s=B(o);if(typeof s.id!="string"||!/^[a-z][a-z-]{0,63}$/.test(s.id)||r.has(s.id)||typeof s.live!="boolean"||s.openToNewPools!==void 0&&typeof s.openToNewPools!="boolean")throw new d("Hookr block list is malformed or duplicated.");r.add(s.id);let a=s.live&&s.openToNewPools!==!1,n=a&&(De.includes(s.id)||v.includes(s.id));return{id:s.id,...s.address===void 0?{}:{address:D(s.address)},live:s.live,openToNewPools:a,supported:n,refusal:n?null:a?Object.hasOwn(Ie,s.id)?Ie[s.id]:`Hook Block ${s.id} needs a verified field codec and payment terms before Oak can launch it. Use its dedicated launch fields when available.`:`Hook Block ${s.id} is not open to new pools.`}})}async function _(e){return tt(await K(e,"hookr_blocks",{}))}function ot(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>20)throw new d("Choose at most twenty distinct Hook Blocks.");let t=new Set;return e.map(r=>{let o=B(r);if(typeof o.id!="string"||t.has(o.id))throw new d("Choose distinct Hook Block IDs.");if(t.add(o.id),Object.hasOwn(A,o.id)){let a=A[o.id],n=Object.hasOwn(P,o.id)?Object.keys(P[o.id]):[];return H(o,["id",...a,...n],["id",...a]),o}let s=Object.hasOwn(M,o.id)?M[o.id]:[];H(o,["id",...s],["id",...s]);for(let a of s)a==="recipient"?D(o[a]):u(o[a],["maxBuyQuoteAmount","cap"].includes(a)?128:a==="guardEndBlock"?40:24);return o})}function ze(e){if((e.length-2)/2!==512)throw new d("Hookr Rules terms must contain exactly sixteen words.");let[t]=Ue(T,e);if(Q(T,[t]).toLowerCase()!==e.toLowerCase())throw new d("Hookr Rules terms are not canonical.");return t}function rt(e,t){let r=u(t.guardEndBlock,40),o=Number(u(t.taxPips,24)),s=Number(u(t.floorPips,24)),a=Number(u(t.decaySeconds,16)),n=u(t.maxBuyQuoteAmount,128);if(!r||!o||o>597e3||!n||(a===0?s!==0:s>=o)||a>3600)throw new d("Anti-Snipe needs a future parent-block guard, positive buy cap/tax, a lower floor when decaying, and at most 3600 decay seconds.");return{...e,guardEndBlock:Number(r),snipeTaxPips:o,snipeFloorPips:s,snipeDecaySeconds:a,maxBuyQuoteAmount:n}}function st(e,t){let r=Number(u(t.maxFeePips,24)),o=Number(u(t.sensitivity,16));if(r<=3e3||r>6e5||o<1||o>10)throw new d("Dynamic fees need maxFeePips above 3000 and at most 600000, with sensitivity 1 to 10.");return{...e,maxFeePips:r,dynamicFeeSens:o}}function nt(e,t){let r=Number(u(t.burnBps,16));if(r<1||r>1e3)throw new d("Auto Burn needs burnBps between 1 and 1000.");return{...e,burnBps:r}}function it(e,t){let r=Number(u(t.lpBps,16));if(r<1||r>1e3)throw new d("LP Rewards needs lpBps between 1 and 1000.");if(e.lpBps&&e.lpBps!==r)throw new d("LP Rewards conflicts with lpRewardsBps. Choose the same rate in both fields.");return{...e,lpBps:r}}async function at(e,t,r,o,s){if(r.some(i=>v.includes(i.id)))throw new d("The agent gate and an advisory Hook Block cannot share the one advisory slot. Use an explicit open launch profile.");let a=s??(r.length?await _(e):[]),n=t,p=[...r.filter(i=>i.id==="anti-snipe"),...r.filter(i=>i.id!=="anti-snipe")];for(let i of p){let c=a.find(l=>l.id===i.id);if(!c||!c.openToNewPools)throw new d(`Hook Block ${String(i.id)} is not open to new pools.`);if(!c.supported)throw new d(c.refusal);switch(i.id){case"anti-snipe":n=rt(n,i);break;case"dynamic-fees":n=st(n,i);break;case"auto-burn":n=nt(n,i);break;case"lp-rewards":n=it(n,i);break;case"buy-sell-block":n=re(n,i);break;case"wallet-cap":n=ne(n,i);break;case"exit-clock":{let l=Object.fromEntries(Object.entries(i).filter(([m])=>m!=="id"));n=ae(n,l);break}case"storm-fee":n=ce(n,i);break;case"swap-cut":n=ue(n,i);break;case"sandwich-guard":n=me(n,i);break;case"holder-pot":n=Fe(n,i);break}}if(R(n),r.some(i=>Object.hasOwn(Me,String(i.id)))&&await gt(e,n,o),n.burnBps+n.lpBps>1e3)throw new d("Auto Burn plus LP Rewards must not exceed 1000 bps.");return ze(Q(T,[n]))}function dt(e,t=3e3,r=0n){R(e);let o=Ce(e),s=BigInt(e.protocolShareBps),a=g=>(BigInt(g)*s+99n)/100n,n=a(e.lpBps),p=a(e.burnBps),i=BigInt(e.lpBps)*100n-n,c=BigInt(e.maxFeePips-t),l=BigInt(e.snipeTaxPips),m=BigInt(t)+i+c+l+o.lp,E=n+p+c*s/10000n+l*s/10000n,x=e.lpBps!==0||e.burnBps!==0||c*s>=10000n||l*s>=10000n;return{maxLpFeePips:m,maxQuoteTakePips:(E>(x?0n:r)?E:x?0n:r)+o.quote,maxSubjectTakeBps:(BigInt(e.burnBps)*100n-p)/100n}}var b=e=>`${Oe(BigInt(e),4)}%`;function ct(e,t){return`Anti-Snipe: buys before parent block ${e.guardEndBlock} pay up to ${e.snipeTaxPips} surcharge pips (${b(e.snipeTaxPips)}), decaying to ${e.snipeFloorPips} pips (${b(e.snipeFloorPips)}) over ${e.snipeDecaySeconds} seconds; buy cap ${e.maxBuyQuoteAmount} quote base units. Hookr ${t} gets floor(charged pips * ${e.protocolShareBps}/10000) in quote; in-range LPs get the remaining LP fee. Principal locked until parent block ${e.guardEndBlock}.`}function pt(e,t){return`Dynamic fees: maximum ${e.maxFeePips} pips (${b(e.maxFeePips)}), sensitivity ${e.dynamicFeeSens}; Hookr ${t} gets floor(dynamic surcharge pips * ${e.protocolShareBps}/10000) in quote; in-range LPs get the remaining LP fee. Default tempo 30/120 seconds, carry 7500 bps, move 200 ticks; minimum dynamic liquidity is clamp(floor(launch liquidity/100), 1, 2^96-1).`}function ut(e,t){let r=(BigInt(e.burnBps)*BigInt(e.protocolShareBps)+99n)/100n;return`Auto Burn: configured ${e.burnBps} bps; subject output burn ${(BigInt(e.burnBps)*100n-r)/100n} bps after Hookr's slice. Hookr ${t} gets ${r} pips (${b(r)}) of gross buyer spend in quote; burned subject goes to 0x000000000000000000000000000000000000dEaD.`}function lt(e,t,r){let o=(BigInt(e.lpBps)*BigInt(e.protocolShareBps)+99n)/100n;return`LP Rewards: buys pay ${e.lpBps*100} gross pips (${b(e.lpBps*100)}); Hookr ${t} gets ${o} quote pips (${b(o)}), in-range LPs get ${BigInt(e.lpBps)*100n-o} LP fee pips (${b(BigInt(e.lpBps)*100n-o)}); creator royalty 0${e.integrator===Le?`; Oak ${e.integrator} gets ${r===void 0?"the share of Hookr's part that Hookr lists for it":`${Oe(r,2)}% of Hookr's part`}`:`, integrator ${e.integrator===qe?"0":e.integrator}`}.`}function Mt(e,t,r){let o=ze(e);if(R(o),o.integrator!==qe&&o.integrator!==Le||o.royaltyBps||o.potBps)throw new d("Hookr payment terms include an unsupported integrator, royalty or pot.");return[o.guardEndBlock?ct(o,t):"",o.dynamicFeeSens?pt(o,t):"",o.burnBps?ut(o,t):"",o.lpBps?lt(o,t,r):"",o.potEveryNBuys&1<<23?se(o):"",o.potEveryNBuys&1<<19?ie(o):"",o.potEveryNBuys&1<<20?de(o,t):"",o.potEveryNBuys&1<<22?pe(o,t):"",o.potEveryNBuys&1<<21?Ee(o,t):"",o.potEveryNBuys&16383&&!(o.potEveryNBuys&1<<21)?le(o,t):"",o.potEveryNBuys&1<<17?he(o,t):""].filter(Boolean)}function Qt(e){return[{name:"hookr_blocks",inputSchema:{type:"object",additionalProperties:!1,properties:{}},execute:async t=>(H(t,[]),{blocks:await _(e)})}]}var mt="0x4ff3630dd3d4ca59d00c08a7c8be527f6b90ffd700a7cc6a36a837de2ee4565e",ht="0x53a44e55150d75ad35c98d9b48c13a1ab6f4be9657d74083149e7d992e45e46f",Me={"swap-cut":"0x9394881A6Fe570adEC4480471B4D52652d263878","exit-clock":"0x2b6aB976d05Dcc7Cad53bF9324Fe892511036348","storm-fee":"0xD577087cbf9bEC0Ca0392efD8A83C3fE6A09Bd1f","wallet-cap":"0xfe5c29D2d6B7aC383A63291a771197e4D83E1d9c","buy-sell-block":"0xa64be3B5eC9B7310CBd3F77736ca5D6Fa81C5BCb","holder-pot":"0x740b2Da80eBB44613C2b44f380D55ECBECbFf11f","sandwich-guard":"0xa214e747d1a8E767F88ed2170be62E22ED79a269"};async function gt(e,t,r){let o=e.clientFor(4663),s=r??await q(o);await O(o,s.number,[f.rulesV1,f.launcherV1]);let a=[t.potEveryNBuys&16383?"swap-cut":"",...[[21,"holder-pot"],[20,"exit-clock"],[22,"storm-fee"],[19,"wallet-cap"],[23,"buy-sell-block"],[17,"sandwich-guard"]].filter(([n])=>t.potEveryNBuys&1<<Number(n)).map(([,n])=>String(n))].filter(Boolean);for(let n of a){let p=Me[n],i=B(await W(o,Y,V("registry"),"admission",[f.rulesV1,p],s.number)),c=B(i.caps);if(i.implementation!==p||w(i.kind,8)!==0n||i.codeHash!==mt||i.schemaHash!==ht||w(i.gasLimit,32)===0n||w(i.phaseMask,8)!==1n||j(i.failOpen)||j(i.feeOnly)||w(c.maxLpFeePips,24)||w(c.maxQuoteTakePips,24)||w(c.maxSubjectTakeBps,16))throw new d(`Hook Block ${n} is not admitted on the pinned core with its reviewed key terms.`)}if(t.potEveryNBuys&1<<23){let n=await ee(o,s),p=t.potMinBuyQuote>>85n&511n,i=t.potMinBuyQuote>>94n&7n;if(BigInt(t.guardEndBlock)-n-4n<(p>i?p:i))throw new d("The parent-block guard must cover the complete Buy/Sell Block windows plus four spare parent blocks.")}await L(o,s)}async function _t(e,t,r,o,s,a,n=0n,p){let i=ot(t.hookBlocks),c=oe(t.launchProfile,t.agentGate,i),l=i.filter($=>!v.includes($.id)),m=e.clientFor(4663);if((await q(m,s.number)).hash!==s.hash)throw new d("Hookr launch block changed before block validation.");await O(m,s.number,[f.rootV1,f.rulesV1,f.launcherV1]);let x=p??(i.length?await _(e):[]),g=await at(e,r,l,s,x),U=Q(T,[g]),G=dt(g,3e3,n);if(!c.advisory)return{kind:c.kind,rules:g,blockTerms:U,advisory:null,bounds:G,summaryLines:[]};let y=c.advisory,C=x.find($=>$.id===y.id);if(!C?.openToNewPools)throw new d(`Hook Block ${String(y.id)} is not open to new pools.`);let h=await yt(m,s.number,y,o);y.id==="market-guard"&&!(g.potEveryNBuys&te)&&(h.phases=3);let I="requiredCaps"in h?h.requiredCaps:h.bounds,k=await Be(m,s.number,h.descriptor,h.phases,I);if(C.address!==void 0&&C.address!==k.address)throw new d("Hookr catalog advisory address differs from the source-verified selection.");let Qe=y.id==="zap-source"?a.maxQuoteTakePips+I.maxQuoteTakePips:y.id==="swap-reward-mint"?kt(g,n)+I.maxQuoteTakePips:0n,_e=ve(G,k.caps,a,Qe);return await L(m,s),{kind:c.kind,rules:g,blockTerms:U,advisory:{...k,data:h.data,id:String(y.id),summary:h.summary},bounds:_e,summaryLines:[`No agent identity gate. ${y.id==="zap-target"?"Only the frozen feeder vaults may buy; any wallet may sell.":"Wallets need no agent identity; the selected advisory can impose its own decoded restrictions."} ${h.summary}`,`Advisory ${k.address}, phases ${k.phases}, fail closed, gas ${k.gasLimit}; full admitted reservation ${k.caps.maxLpFeePips} LP pips and ${k.caps.maxQuoteTakePips} quote pips.`]}}async function yt(e,t,r,o){let s=Object.fromEntries(Object.entries(r).filter(([n])=>n!=="id")),a;switch(r.id){case"market-guard":a=await ye(e,t,s,o);break;case"market-hours-fee":a=await fe(e,t,s);break;case"managed-fee":a=await be(e,t,s);break;case"zap-source":a=await J(e,t,s,o);break;case"zap-target":a=await Pe(e,t,s,o);break;case"swap-reward-mint":a=await Te(e,t,s,o);break;default:throw new d("Unknown Hookr advisory profile.")}return a}function kt(e,t){let r=BigInt(e.protocolShareBps),o=(BigInt(e.lpBps)*r+99n)/100n,s=(BigInt(e.lpBps)*100n-o)*BigInt(e.royaltyBps)/10000n,a=o+s+(BigInt(e.burnBps)*r+99n)/100n+BigInt(e.maxFeePips-3e3+e.snipeTaxPips)*r/10000n;return a>s+t?a:s+t}export{T as a,Le as b,Ke as c,Ve as d,A as e,zt as f,tt as g,_ as h,ot as i,ze as j,rt as k,st as l,nt as m,it as n,at as o,dt as p,ct as q,pt as r,ut as s,lt as t,Mt as u,Qt as v,_t as w,yt as x,kt as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(r,t){return r==="hoodlock_airdrop_claim"&&!Object.hasOwn(t,"id")}var h=new Map([]),_="find_tool",l="run_tool",w=["merkl_rewards","merkl_opportunities","merkl_campaigns","merkl_earning_status","merkl_claim_config","merkl_distributor_status","merkl_stock_lp_rewards"],k=["upoch_agent","upoch_explorer"],i=["oak_setup","oak_identity_unlink","send","hoodlock_feature_buy","hoodlock_feature_claim","hoodlock_referral_register","heyresearch_token_facts","heyresearch_feed","heyresearch_follow","heyresearch_unfollow","heyresearch_position_context"],p={oak:["account","balances","find_token","price","quote","swap","positions","send","oak_setup","oak_identity_unlink"],kyberswap:[],velora:[],steakhouse:["steakhouse_deposit","steakhouse_withdraw"],spark:["spark_deposit","spark_withdraw"],layerbank:["layerbank_deposit","layerbank_withdraw"],borro:["borro_deposit","borro_withdraw"],chop:["chop_wrap","chop_unwrap"],factor:["factor_sign_up","factor_open_jobs"],raeto:["raeto_status","raeto_join","raeto_ask"],gloam:["gloam_shield","gloam_pay","gloam_claim","gloam_cash_out"],pendle:["pendle_buy","pendle_sell","pendle_redeem"],earn:["earn_options"],netnet:["netnet_deposit","netnet_withdraw"],longbow:["longbow_list","longbow_deposit","longbow_withdraw"],grove:["grove_deposit","grove_withdraw"],beefy:["beefy_list","beefy_deposit","beefy_withdraw"],pons:["pons_browse","pons_buy","pons_sell","pons_launch"],orbio:["orbio_credit_status","orbio_buy_credit"],hoodlock:["hoodlock_list_locks","hoodlock_lock","hoodlock_withdraw"],merkl:["merkl_rewards","merkl_claim"],relay:["relay_bridge_in","relay_bridge_out","relay_status"],lighter:["lighter_funding"],wormhole:[],upoch:[],erc8004:["erc8004_identity"],hoodag:["hoodag_resolve","hoodag_register"],heyresearch:["heyresearch_research_project","heyresearch_token_facts","heyresearch_feed","heyresearch_follow","heyresearch_position_context"],priors:["priors_status","priors_lend","priors_withdraw","priors_borrow","priors_repay"],morpho:["morpho_status","morpho_supply","morpho_withdraw","morpho_supply_collateral","morpho_withdraw_collateral","morpho_borrow","morpho_repay"],uniswap:["uniswap_list_positions","uniswap_add","uniswap_remove","uniswap_collect"],hookr:["hookr_orders","hookr_create","hookr_cancel"],meridian:["meridian_browse","meridian_positions","meridian_sell","meridian_redeem"],tickerspring:["tickerspring_account","tickerspring_create","tickerspring_cancel","tickerspring_claim"],clanker:["clanker_browse","clanker_launch"],poolstrade:["poolstrade_status","poolstrade_buy","poolstrade_sell","poolstrade_launch"]};function u(r,t){let a=new Set(r),s=new Set;for(let[e,n]of Object.entries(p))for(let o of n){if(s.has(o))throw new Error(`Visible tool ${o} is listed twice.`);if(e!=="oak"&&!o.startsWith(`${e}_`))throw new Error(`Visible tool ${o} is filed under ${e}.`);if(i.includes(o)||a.has(o))s.add(o);else if(t==="mainnet")throw new Error(`Visible tool ${o} is not registered.`)}for(let e of[_,l,...i,"oak_playbook"])if(a.has(e))throw new Error(`Tool name ${e} is reserved for the add-on.`);return s}export{d as a,h as b,_ as c,l as d,w as e,k as f,i as g,p as h,u as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as R}from"./
|
|
1
|
+
import{d as R}from"./WADRRW3E.js";import{a as N,f as L,g as v}from"./PX2G2H6G.js";import{I as H,K as j,L as O,b as p,d as l,z as D}from"./2ZYFBBOE.js";import{g as d}from"./NWNYJ26T.js";import{b as x}from"./EWZFZUVF.js";import{a as e}from"./XSD5NL7J.js";import{decodeAbiParameters as J,decodeFunctionData as b,encodeAbiParameters as K,encodeFunctionData as Q,erc20Abi as W,getAddress as Y,parseAbi as Z,parseAbiParameters as ee}from"viem";var U=Z(["function modifyLiquidities(bytes unlockData,uint256 deadline) payable"]),V=ee("bytes actions,bytes[] params");function de(f,$){return{tools:[{name:"uniswap_batch",inputSchema:{type:"object",additionalProperties:!1,required:["operations"],properties:{operations:{description:"One to twenty v4 liquidity operations to execute atomically; each must use a distinct position NFT.",type:"array",minItems:1,maxItems:20,items:{type:"object",additionalProperties:!1,required:["name","arguments"],properties:{name:{description:'Choose "uniswap_add" to add liquidity, "uniswap_collect" to collect fees or "uniswap_remove" to remove liquidity.',type:"string",enum:["uniswap_add","uniswap_collect","uniswap_remove"]},arguments:{description:"Arguments for the selected v4 add, collect or remove operation; explicitly select version v4.",anyOf:[H,j,O]}}}}}},async execute(a,A){if(v(a,["operations"]),!Array.isArray(a.operations)||a.operations.length<1||a.operations.length>20)throw new e("Provide 1 to 20 v4 liquidity operations.");let s="0x",c,h=[],P=0n,w=new Map,_=new Set,E=new Set;for(let t of a.operations){if(!t||typeof t!="object"||Array.isArray(t))throw new e("Each operation needs name and arguments.");let n=t;if(v(n,["name","arguments"]),!["uniswap_add","uniswap_collect","uniswap_remove"].includes(String(n.name))||!n.arguments||typeof n.arguments!="object"||Array.isArray(n.arguments))throw new e("Batch supports v4 add, collect and remove operations only.");let r=n.arguments;if(r.version!=="v4")throw new e("Every batch operation must explicitly select version v4.");if(r.initialPrice!==void 0||r.sqrtPriceX96!==void 0)throw new e("Create a pool before batching its liquidity operations.");if(r.tokenId!==void 0){let o=N(r.tokenId,"tokenId").toString();if(E.has(o))throw new e("Batch tokenIds must be distinct decimal strings.");E.add(o)}else if(n.name!=="uniswap_add")throw new e("Existing-position operations require tokenId.");let I=await $.tools.find(o=>o.name===n.name).execute(r,A),u=I.txs.at(-1);if(!u||!d(u.to,p))throw new e("Batch operation returned an unexpected destination.");P+=BigInt(u.value);for(let o of I.txs.slice(0,-1)){if(BigInt(o.value)!==0n)throw new e("Batch prerequisite cannot send native currency.");if(d(o.to,l)){let i=b({abi:R,data:o.data}),[M,G,X,z]=i.args;if(!d(G,p))throw new e("Batch Permit2 spender must be PositionManager.");let T=M.toLowerCase(),m=w.get(T),B=BigInt(z),C=(m?.amount??0n)+X;if(C>=1n<<160n)throw new e("Batch approval exceeds uint160.");w.set(T,{token:M,amount:C,expiration:m&&m.expiration<B?m.expiration:B})}else{let i=b({abi:W,data:o.data});if(i.functionName!=="approve"||!d(i.args[0],l))throw new e("Unexpected batch prerequisite.")}}let S=b({abi:U,data:u.data}),[F,y]=J(V,S.args[0]),k=F.slice(2).match(/../g)??[];if(k.length!==y.length)throw new e("Batch action/parameter count differs.");k.forEach((o,i)=>{o==="14"?_.add(y[i]):(s=`${s}${o}`,h.push(y[i]))});let q=S.args[1];c=c===void 0||q<c?q:c}for(let t of _)s=`${s}14`,h.push(t);let g=[];for(let t of w.values())g.push(f.approval(Y(t.token),l,t.amount.toString(),x),D(t.token,p,t.amount.toString(),t.expiration.toString()));return g.push(f.unsignedTx({to:p,data:Q({abi:U,functionName:"modifyLiquidities",args:[K(V,[s,h]),c]}),value:P.toString(),chainId:x,description:`Atomically modify ${a.operations.length} v4 positions; recipients are the signing wallet.`})),L(f,g,A,"Atomic v4 batch: every operation must succeed. Each position retains its own minimums; preview covers the complete action stream.")}}]}}export{U as a,V as b,de as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as W}from"./266VIESP.js";import{d as R,e as _}from"./XV6F3RET.js";import{b as z,c as I}from"./LFSJDFMY.js";import{L as E}from"./DPSFR3ZS.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{b as C,t as S}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
|
|
1
|
+
import{b as z,c as I}from"./LFSJDFMY.js";import{b as W}from"./266VIESP.js";import{d as R,e as _}from"./XV6F3RET.js";import{L as E}from"./R5UOFPDO.js";import{a as F}from"./43LI5NKJ.js";import{d as H,g as A,i as j}from"./NWNYJ26T.js";import{b as C,t as S}from"./EWZFZUVF.js";import{a as s}from"./XSD5NL7J.js";import{encodeFunctionData as M,erc20Abi as V,getAddress as Z,keccak256 as K,zeroAddress as x}from"viem";var r=R.turbo,h=R.blackjack,g=m=>j(m,"Provide an explicit card address.",H);function G(m,d){if(/^uint\d*\[\]$/.test(m.type)&&Array.isArray(d))return d.map(c=>G({...m,type:m.type.slice(0,-2)},c));if(/^uint\d*$/.test(m.type)&&(typeof d!="string"||!/^(0|[1-9]\d*)$/.test(d)))throw new s("Card integers must be canonical decimal strings, without leading zeros.");return W(m,d)}var J=["buy","cashOut","claimExpiry","refund","safeTransferFrom","safeBatchTransferFrom"],X=["liquidate","recordKnock","liquidateKnock","clearKnock","recordDrift","settle","markVoid","depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries","haltSales","resumeSales","sweepFees","skim"],Q=m=>m==="netnet_turbo_action"||m.startsWith("netnet_blackjack_")&&["netnet_blackjack_finalize","netnet_blackjack_expire","netnet_blackjack_claim"].includes(m);async function de(m,d,c,k){if(F(c),!Q(m))throw new s("No local NetNet card action builder exists.");let v=m!=="netnet_turbo_action";if(Object.keys(d).some(e=>!(v?["sessionId","seriesId"]:["operation","values","minimum","allowZeroPayout"]).includes(e)))throw new s("Unexpected card action argument.");if(v&&!z(m,d))throw new s("Recovery accepts exactly one positive decimal session or series ID.");if(await k.getChainId()!==C)throw new s("NetNet cards require chain 4663.");let w=await k.getBlock();if(w.number===null||!w.hash)throw new s("Card action block is unavailable.");let p=(e,t,i=[])=>k.readContract({address:e.address,abi:e.abi,functionName:t,args:i,blockNumber:w.number});for(let e of v?[r,h]:[r]){let t=await k.getCode({address:e.address,blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet card runtime changed or is unavailable. Requalify this deployment before signing.")}for(let e of v?Object.values(_):[_.turbo]){let t=await k.getCode({address:Z(e.address),blockNumber:w.number});if(!t||K(t)!==e.codeHash)throw new s("NetNet linked card library changed or is unavailable. Requalify before signing.")}let l={txs:[],inputs:[],cards:[],decision:"",blockNumber:w.number,blockHash:w.hash},$=(e,t,i,a,o)=>({chainId:4663,collection:r.address,operator:e,from:t,to:i,id:a,amount:o,operation:t===x?"mint":i===x?"burn":"transfer"}),T=(e,t,i,a,o=[])=>{l.txs.push({to:e,chainId:C,value:"0",data:M({abi:t,functionName:i,args:a}),description:l.decision}),l.cards.push(o)},D=(e,t)=>{if(t<=0n||t>=1n<<128n)throw new s("Card payment must be positive and below the exact-approval ceiling.");l.inputs.push({token:e,amount:t,to:r.address}),T(e,V,"approve",[r.address,t])};if(v){if(g(await p(h,"cards"))!==r.address||g(await p(h,"turbo"))!==r.address)throw new s("Blackjack card wiring changed.");let e=m==="netnet_blackjack_claim";if(Object.keys(d).some(b=>b!==(e?"seriesId":"sessionId")))throw new s("Recovery accepts only its one exact session or series ID.");let t=E(e?d.seriesId:d.sessionId),i,a,o,u="Original-series parked payout; self-claim only.";if(e){if(i=t,a=await p(h,"unclaimedChips",[t,c]),o="claimUnclaimedChips",a===0n)throw new s("This wallet has no parked chips for that series.")}else{let b=await p(h,"sessionOf",[t]);if(!b||!A(b.player,c))throw new s("Recovery is limited to this wallet\u2019s recorded blackjack session.");let y=m==="netnet_blackjack_finalize";if(o=y?"finalize":"expireSession",b.state!==(y?2:1))throw new s(y?"Session is not Closing. Use its current on-chain state to choose recovery.":"Session is not Open. A Closing session uses finalize after its challenge window.");let N=y?b.closeAt:b.deadline;if(u=y?`Challenge ends ${new Date(Number(N)*1e3).toISOString()}.`:`Session deadline ${new Date(Number(N)*1e3).toISOString()}; player-only expiry until ${new Date(Number(N+3600n)*1e3).toISOString()}.`,w.timestamp<N)throw new s(`Recovery is not due until ${N} Unix seconds.`);i=await p(h,"tableSeries"),a=b.chips}if(i<=0n||a<0n)throw new s("Blackjack recovery accounting is unavailable.");return l.decision=`${o} ${e?"series":"session"} ${t} at ${h.address}: return ${a} whole cards of collection ${r.address}, series ${i}, to ${Z(c)}. ${u} Last on-chain chips may omit off-chain winnings; cards may be worthless. A failed receiver parks the payout at ${h.address}; self-claim only. ETH gas extra.`,T(h.address,h.abi,o,[t],a===0n?[]:[$(h.address,h.address,c,i,a)]),l.recovery={...e?{}:{sessionId:t.toString()},seriesId:i.toString(),count:a.toString(),player:c,operation:o},l}let n=String(d.operation);if(n==="setApprovalForAll")throw new s(I.setApprovalForAll);if(["convertPremiums","convertSleeveFees"].includes(n))throw new s(I.conversion);if(![...J,...X].includes(n))throw new s("Choose a qualified finite TURBO operation.");if(!Array.isArray(d.values))throw new s("Provide ordered TURBO values using decimal integer strings.");let U=n==="safeTransferFrom"||n==="safeBatchTransferFrom",B=r.abi.find(e=>e.name===n),q=U?B.inputs.slice(1,-1):B.inputs;if(d.values.length!==q.length)throw new s("TURBO values do not match the exact operation inputs.");let f=q.map((e,t)=>G(e,d.values[t])),O=g(await p(r,"manager")),L=g(await p(r,"sleeve")),P=[];if(U){if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Transfer has no payout floor.");let e=g(f[0]);if(e===x||A(e,c))throw new s("Name a nonzero, non-self card recipient.");let t=await k.getCode({address:e,blockNumber:w.number});if(t&&t!=="0x")throw new s("Card transfer to a contract requires qualified credit and recovery. New blackjack seating remains disabled.");let i=n==="safeTransferFrom"?[f[1]]:f[1],a=n==="safeTransferFrom"?[f[2]]:f[2];if(!i.length||i.length>8||i.length!==a.length||new Set(i.map(String)).size!==i.length||i.some((o,u)=>o<=0n||a[u]<=0n||u>0&&o<=i[u-1]))throw new s("Use at most eight unique positive series IDs in increasing order and exact positive counts.");for(let o=0;o<i.length;o++){if(await p(r,"balanceOf",[c,i[o]])<a[o])throw new s("Card transfer exceeds this wallet\u2019s balance.");P.push($(c,c,e,i[o],a[o])),l.inputs.push({token:r.address,id:i[o],amount:a[o],to:e,exact:!0})}l.decision=`Transfer whole cards of collection ${r.address}: ${i.map((o,u)=>`series ${o} count ${a[u]}`).join(", ")} to ${e}. Basis does not travel with cards; no operator approval. No payout; transfer is irreversible. ETH gas extra.`,f=[c,...f,"0x"]}else if(["buy","cashOut","claimExpiry","refund"].includes(n)){let e=f[0],t=f[1],i=await p(r,"seriesOf",[e]);if(!i||i.asset===x||t<=0n)throw new s("Choose a known series and positive whole-card count.");let a=i.side===0?g(i.asset):S.mainnet.usdg,o=await k.readContract({address:a,abi:V,functionName:"decimals",blockNumber:w.number});if((n==="buy"||n==="cashOut")&&(i.state!==1||w.timestamp>=i.expiry))throw new s("This TURBO series is not OPEN and unexpired.");if(n==="buy"){let[u]=await p(r,"quoteBuy",[e,t]);if(!u||u>f[2])throw new s("Current card quote exceeds the explicit maximum USDG payment.");if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("Buy uses its exact count and maximum USDG price.");l.decision=`Spend at most ${f[2]} USDG base units (${S.mainnet.usdg}, decimals 6) at ${r.address}; receive ${t} whole cards, collection ${r.address}, series ${e}, into this wallet. Exact quoted approval ${u}; fees included. Strike ${i.strikeWad} WAD; expiry ${new Date(Number(i.expiry)*1e3).toISOString()}; cards can lose all value. Any residual USDG allowance requires zero cleanup. ETH gas extra.`,D(S.mainnet.usdg,u),P=[$(c,x,c,e,t)]}else{if(n==="cashOut"&&d.minimum!==void 0)throw new s("cashOut takes its one encoded minimum in values, not a second local minimum.");if(await p(r,"balanceOf",[c,e])<t)throw new s("Card burn exceeds this wallet\u2019s balance.");let u=n==="cashOut"?f[2]:E(d.minimum,!0);if(u===0n&&d.allowZeroPayout!==!0)throw new s("A zero payout floor requires allowZeroPayout:true and explicit human confirmation.");let b=0n;if(n==="cashOut"){let y=await p(r,"quoteCashOut",[e,t,c]);if(y[0]<u)throw new s("The current cash-out quote misses the payout minimum.");b=y[1]}else if(i.state!==(n==="claimExpiry"?3:4))throw new s("Expiry claims require EXPIRED; pro-rata refunds require VOID.");l.decision=`Burn ${t} whole cards of ${r.address}, series ${e}; ${n==="refund"?"series pro-rata VOID refund, not personal purchase-price repayment":n}; receive >=${u} base units of ${a} (decimals ${o}) into this wallet. ${n==="cashOut"?`Minimum encoded in calldata; current performance fee ${b}.`:"Floor is local simulation only; no on-chain minimum. Settled payout includes applicable fees."} Burned cards cannot be returned; ETH gas extra.`,P=[$(c,c,x,e,t)],l.inputs.push({token:r.address,id:e,amount:t,to:x,exact:!0}),l.receipt={token:a,minimum:u,recipient:c,enforcement:n==="cashOut"?"calldata":"simulation"}}}else{if(d.minimum!==void 0||d.allowZeroPayout!==void 0)throw new s("This TURBO operation has no caller payout floor.");if(["withdrawHouse","withdrawPutPot","createSeries","resumeSales"].includes(n)&&!A(O,c))throw new s(`This TURBO operation requires manager ${O}.`);if(n==="haltSales"&&!A(c,O)&&!A(c,g(await p(r,"halter"))))throw new s("TURBO haltSales requires the current manager or halter.");if(["depositHouse","depositPutPot","withdrawHouse","withdrawPutPot","createSeries"].includes(n)){let t=g(f[0]);if(!(await Promise.all(["asset0","asset1","asset2"].map(a=>p(r,a)))).some(a=>typeof a=="string"&&A(a,t)))throw new s("This is not a pinned TURBO reserve asset.")}l.decision=`${n} at ${r.address}; values ${JSON.stringify(f,(t,i)=>typeof i=="bigint"?String(i):i)}. Protocol capital/accounting action; manager ${O}; sleeve ${L}; no caller reward. ${n.startsWith("deposit")?"Irreversible house funding; no personal withdrawable balance.":n.startsWith("withdraw")?"Pays the current manager; operating and reservation floors still apply.":"Series state, risk or protocol fee allocation may change."} No card approval; ETH gas extra.`,(n==="depositHouse"||n==="depositPutPot")&&D(n==="depositHouse"?g(f[0]):S.mainnet.usdg,f[1])}if(l.decision.length>1024)throw new s("Card decision terms exceed the complete confirmation label capacity. Use fewer card IDs.");T(r.address,r.abi,n,f,P);for(let e of l.txs)e.description=l.decision;return l}export{J as a,X as b,Q as c,de as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as b,b as k,e as w,f as N,g as S}from"./
|
|
1
|
+
import{a as b,b as k,e as w,f as N,g as S}from"./PX2G2H6G.js";import{a as h}from"./66F5ZH34.js";import{c as g,g as E}from"./NWNYJ26T.js";import{b as d}from"./EWZFZUVF.js";import{a as r}from"./XSD5NL7J.js";import{encodeFunctionData as v,erc20Abi as O,getAddress as _,parseAbi as I,zeroAddress as T}from"viem";var x=_("0x2ac03e14cfe755426daaee0a4994184ce81482f8"),n=_("0x7a8f74c2585f84c781f951b7f2ff21337d5b630b"),o=I(["function RESOURCE() view returns (address)","function TOKEN_JAR() view returns (address)","function threshold() view returns (uint256)","function nonce() view returns (uint256)","function release(uint256 nonce,address[] assets,address recipient)"]),M={assets:{description:"One to twenty unique asset addresses to release from the Token Jar; the zero address means native ETH.",type:"array",minItems:1,maxItems:20,items:g},nonce:h("Token Jar release nonce from uniswap_token_jar, as a decimal string."),maxResourceAmount:h('Maximum amount of resource token in base units; use resource token decimals. Example: "1000000" = 1 resource token at 6 decimals.')};function D(a){return{tools:[!1,!0].map(i=>({name:i?"uniswap_token_jar_release":"uniswap_token_jar",inputSchema:{type:"object",additionalProperties:!1,required:i?["assets","nonce","maxResourceAmount"]:["assets"],properties:M},async execute(t,m){if(S(t,i?["assets","nonce","maxResourceAmount"]:["assets"]),!Array.isArray(t.assets)||t.assets.length<1||t.assets.length>20)throw new r("Provide 1 to 20 unique assets to release.");let c=t.assets.map(k);if(new Set(c).size!==c.length)throw new r("Token Jar assets must be unique.");let s=a.clientFor(d),e=await s.getBlockNumber(),[R,C,u,f]=await Promise.all([s.readContract({address:n,abi:o,functionName:"RESOURCE",blockNumber:e}),s.readContract({address:n,abi:o,functionName:"TOKEN_JAR",blockNumber:e}),s.readContract({address:n,abi:o,functionName:"threshold",blockNumber:e}),s.readContract({address:n,abi:o,functionName:"nonce",blockNumber:e})]);if(!E(String(C),x)||R===T)throw new r("Releaser deployment does not match the pinned Token Jar and ERC-20 resource.");let p=await w(a,k(R),e),J=await Promise.all(c.map(async l=>({token:await w(a,l,e),amount:(l===T?await s.getBalance({address:x,blockNumber:e}):await s.readContract({address:l,abi:O,functionName:"balanceOf",args:[x],blockNumber:e})).toString()}))),y={payment:{token:p,amount:String(u)},nonce:String(f),assets:J,blockNumber:e.toString()};if(!i)return{...y,summary:"Resource payment buys the listed jar contents; no profit is promised. Release uses a nonce to refuse competing releases."};let P=b(t.maxResourceAmount,"maxResourceAmount"),A=b(t.nonce,"nonce",256,!0);if(A!==BigInt(f)||BigInt(u)>P)throw new r("Token Jar nonce or resource cost changed. Read uniswap_token_jar and confirm fresh terms.");let j=[a.approval(p.address,n,String(u),d),a.unsignedTx({to:n,data:v({abi:o,functionName:"release",args:[A,c,m]}),value:"0",chainId:d,description:`Pay ${u} base units of ${p.address} to release Token Jar assets to ${m}, nonce ${f}.`})];return{...await N(a,j,m,"Exchange resource tokens for Token Jar assets. Check the full payment, assets and recipient in the preview; gas is additional."),...y}}}))}}export{x as a,n as b,o as c,D as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as N}from"./6HNQAYBM.js";import{a as M}from"./
|
|
1
|
+
import{a as N}from"./6HNQAYBM.js";import{a as M}from"./VQMBPY2P.js";import{b as _,c as q,d as F,e as O}from"./UYYYSFMQ.js";import{a as I}from"./QKH7ED6B.js";import{c as E}from"./IY7FWTAL.js";import{b as P}from"./SPJCSEKP.js";import{a as b}from"./43LI5NKJ.js";import{b as G}from"./IX3GZMTM.js";import{b as r,e as $,j as C,k as y}from"./EWZFZUVF.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as g,erc20Abi as D,parseAbi as W}from"viem";var i=C[r].vaults.steakhouse.address,R=(1n<<256n)-1n,l=W(["function asset() view returns (address)","function totalAssets() view returns (uint256)","function convertToAssets(uint256 shares) view returns (uint256 assets)","function previewWithdraw(uint256 assets) view returns (uint256 shares)","function deposit(uint256 assets,address receiver) returns (uint256 shares)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256 shares)","function redeem(uint256 shares,address receiver,address owner) returns (uint256 assets)"]);function S(e){if(typeof e!="bigint"||e<0n||e>R)throw new o("The vault returned an invalid base-unit amount.");return e}function k(e){if(typeof e!="string")throw new o("Amount must be an integer string in base units.");let c=G(e);if(c===0n)throw new o("Amount must be positive.");if(c>R)throw new o("Amount exceeds the uint256 range.");return c}function U(e,c,h=!1){if(!e||typeof e!="object"||Array.isArray(e)||Object.keys(e).some(w=>!c||!["amount",...h?["force","maxPenaltyAssets","minAmountOut"]:[]].includes(w)))throw new o("Unexpected Steakhouse argument.")}var L=e=>{async function c(t){try{return await t()}catch(s){throw new o(e.plainError(s))}}async function h(){let t=e.clientFor(r);if(await t.getChainId()!==r)throw new o("Steakhouse requires chain 4663.");let s=await t.readContract({address:i,abi:l,functionName:"asset"});if(typeof s!="string"||s.toLowerCase()!==y.toLowerCase())throw new o("The Steakhouse vault asset does not match USDG on chain 4663.");let[a,n]=await Promise.all([t.readContract({address:y,abi:D,functionName:"decimals"}),t.readContract({address:i,abi:D,functionName:"decimals"})]);if(a!==$||!Number.isInteger(n)||n<0||n>255)throw new o("The vault returned invalid asset or share decimals.");return{client:t,asset:{address:y,symbol:"USDG",decimals:a,chainId:r},shares:{address:i,symbol:"steakUSDG",decimals:n,chainId:r}}}async function w(t,s){return S(await t.readContract({address:i,abi:D,functionName:"balanceOf",args:[s]}))}async function x(t,s,a){let n=await e.preview(t,s);if(n.changes.length===0)throw new o("The Steakhouse simulation returned no token balance changes.");let u=n.changes.map(({token:m,amount:d})=>{let f=d.startsWith("-"),p=e.formatAmount(f?d.slice(1):d,m.decimals);return`${f?"-":""}${p} ${m.symbol} (${m.address}, chain ${m.chainId}, decimals ${m.decimals})`});return{txs:t,summary:`${a} ${n.summary} Changes: ${u.join("; ")}.`}}return{tools:[q(e,"steakhouse_details",i),I(e,"steakhouse_analytics",i),M(e,"steakhouse_manage",i),...N(e,"steakhouse",i),{name:"steakhouse_list",inputSchema:{type:"object",properties:{},additionalProperties:!1},execute:async t=>c(async()=>{U(t,!1);let{client:s,asset:a,shares:n}=await h(),u=S(await s.readContract({address:i,abi:l,functionName:"totalAssets"}));return[{name:"Steakhouse USDG",vault:n,asset:a,totalAssets:{token:a,amount:u.toString()}}]})},{name:"steakhouse_deposit",inputSchema:{...T(!1),description:"Deposit USDG in base units (1 USDG = 1000000) for vault shares. Exit with steakhouse_withdraw; check positions after confirmation."},execute:async(t,s)=>c(async()=>{U(t,!0);let a=k(t.amount);b(s);let{asset:n}=await h(),u=[e.approval(n.address,i,a.toString(),r),e.unsignedTx({to:i,data:g({abi:l,functionName:"deposit",args:[a,s]}),value:"0",chainId:r,description:`Deposit ${e.formatAmount(a.toString(),n.decimals)} USDG into Steakhouse.`})];return x(u,s,"Approve the exact USDG amount, then deposit into Steakhouse.")})},{name:"steakhouse_withdraw",inputSchema:{...T(!0),description:"Withdraw USDG in 6-decimal base units, or amount max to redeem every share for USDG. Check positions after confirmation.",properties:{...T(!0).properties,force:{type:"boolean",description:"Explicitly plan a full Morpho V2 force exit with penalty disclosure."},maxPenaltyAssets:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: most USDG, in base units (6 decimals), you accept losing to the exit penalty. Example: "1000000" = 1 USDG.'},minAmountOut:{type:"string",pattern:"^[0-9]+$",description:'Force exit only: least USDG you must receive, in base units (6 decimals). Example: "1000000" = 1 USDG.'}}},execute:async(t,s)=>c(async()=>{U(t,!0,!0);let a=t.amount==="max"?null:k(t.amount);b(s);let{client:n,asset:u,shares:m}=await h(),d=await w(n,s);if(d===0n)throw new o("The wallet has no Steakhouse shares to withdraw.");if(t.force!==void 0&&typeof t.force!="boolean")throw new o("force must be a boolean.");if(t.force===!0){if(a!==null)throw new o("Force exit currently requires amount max.");let p=E(t.maxPenaltyAssets),j=k(t.minAmountOut),v=await _(e,n,i,s,d,p),A=await e.preview([v.tx],s);return O(A.changes,i,d,j),{txs:[v.tx],preview:A,summary:`${F(v.plan)} ${A.summary}`}}if(t.maxPenaltyAssets!==void 0||t.minAmountOut!==void 0)throw new o("Penalty and output limits require force true.");let f;if(a===null)f=e.unsignedTx({to:i,data:g({abi:l,functionName:"redeem",args:[d,s,s]}),value:"0",chainId:r,description:`Redeem all ${e.formatAmount(d.toString(),m.decimals)} steakUSDG shares.`});else{let p=S(await n.readContract({address:i,abi:l,functionName:"previewWithdraw",args:[a]}));if(p===0n||p>d)throw new o("The withdrawal exceeds the available share balance or has an invalid share quote.");f=e.unsignedTx({to:i,data:g({abi:l,functionName:"withdraw",args:[a,s,s]}),value:"0",chainId:r,description:`Withdraw ${e.formatAmount(a.toString(),u.decimals)} USDG from Steakhouse.`})}return x([f],s,a===null?"Redeem the current full share balance from Steakhouse.":"Withdraw the requested USDG amount from Steakhouse.")})}],positions:t=>c(async()=>{b(t);let{client:s,asset:a,shares:n}=await h(),u=await w(s,t);if(u===0n)return[];let m=S(await s.readContract({address:i,abi:l,functionName:"convertToAssets",args:[u]}));return[{module:"steakhouse",id:`${r}:${i.toLowerCase()}`,chainId:r,assets:[{token:a,amount:m.toString()}],description:`${e.formatAmount(u.toString(),n.decimals)} steakUSDG shares (${i}, chain ${r}, decimals ${n.decimals}); USDG conversion is indicative, not guaranteed exit liquidity.`}]})}};function T(e){return{type:"object",additionalProperties:!1,required:["amount"],properties:{amount:{type:"string",pattern:e?"^(?:[0-9]+|max)$":"^[0-9]+$",description:`Amount of USDG in base units (USDG has 6 decimals)${e?", or max to redeem every share":""}. Example: "1000000" = 1 USDG.`}}}}var te=e=>P("steakhouse",[L(e)]);export{L as a,te as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as Q}from"./KYANIEPX.js";import{b as X}from"./5AO2QPWE.js";import{b as Z}from"./EYE3ZAJB.js";import{i as ee}from"./AG66NM3J.js";import{a as Y}from"./2QQ5CGQI.js";import{b as z}from"./B7HVPHSS.js";import{a as N,b as I,c as R,d as $,g as D,h as k,k as _,l as x,n as B,p as W,r as E,s as U,t as q,v as F,x as J,y as G}from"./BIFANUTV.js";import{a as y}from"./X5V2Z2NM.js";import{b as V}from"./SPJCSEKP.js";import{a as H}from"./43LI5NKJ.js";import{c as K,e as T,g as w}from"./NWNYJ26T.js";import{a as g,d as L}from"./XSD5NL7J.js";import{a as A}from"./JXOEJPJ4.js";import{Buffer as te}from"node:buffer";import{decodeEventLog as re,encodeFunctionData as O,getAddress as se,hexToString as de,parseAbiItem as ce,toEventSelector as ie}from"viem";var Ke={register:"erc8004_register"},ge="Oak now always adds the public oak.registrar marker when it registers an agent, so tag: false and --no-tag are no longer available. Remove the option and register again. To use an agent ID you already own without the marker, link it with oak setup link <agentId>.",fe="The registration went through, but Oak could not find its oak.registrar marker on Robinhood Chain. Nothing else was sent. Ask me to check the agent with erc8004_identity.",le=`One transaction registers your agent and writes the public marker oak.registrar = oak. ${N} It needs gas.`,j="https://eips.ethereum.org/EIPS/eip-8004#registration-v1",ue={type:"object",required:["type","name","description","image","services","x402Support","active","registrations"],properties:{type:{const:j,description:"ERC-8004 registration-v1 profile type URI."},name:{type:"string",minLength:1,description:"Short public name for the agent."},description:{type:"string",description:"Public text describing what the agent does; may be empty."},image:{type:"string",description:"Public HTTPS or IPFS image URI without credentials."},services:{type:"array",items:{type:"object",required:["name","endpoint"]},description:"Service endpoint objects with name and endpoint; use an empty list for none."},x402Support:{type:"boolean",description:"Whether the agent supports x402 payments."},active:{type:"boolean",description:"Whether this agent is active."},registrations:{type:"array",description:"Registry references with agentRegistry and agentId; leave empty before first registration."},tags:{type:"array",items:{type:"string"},description:"Optional public text labels for the agent."},supportedTrust:{type:"array",items:{type:"string"},description:"Optional trust mechanism labels supported by the agent."}}};function pe(e){if(typeof e!="string"||!e.trim())return!1;try{let t=new URL(e);return["https:","ipfs:"].includes(t.protocol)&&!!t.hostname&&!t.username&&!t.password}catch{return!1}}var me=e=>Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.trim()),he=e=>e.replace(/\.$/,"");function ye(e,t,a,n){let{registryId:d}=k(e);if(!T(t))throw new g("Provide a registration-v1 profile object.");if(a!==void 0&&typeof a!="boolean")throw new g("The tag option must be a boolean.");let o=[],r=(i,c)=>o.push(`${i}: ${c}`);t.type!==j&&r("type",`use "${j}"`),(typeof t.name!="string"||!t.name.trim())&&r("name",'a short name for your agent, such as "Oak Agent 1"'),typeof t.description!="string"&&r("description","a sentence about what your agent does (it may be empty text)"),pe(t.image)||r("image","an HTTPS or IPFS link to a picture, with no username or password in it"),typeof t.active!="boolean"&&r("active","true or false"),typeof t.x402Support!="boolean"&&r("x402Support","true or false"),Array.isArray(t.services)?t.services.forEach((i,c)=>{try{Z(i)}catch(p){if(!(p instanceof g))throw p;r(`services item ${c+1}`,he(p.message))}}):r("services","a list of endpoints, or [] for none");for(let i of["tags","supportedTrust"])t[i]!==void 0&&!me(t[i])&&r(i,"a list of nonempty text labels, or leave it out");if(Array.isArray(t.registrations)?t.registrations.forEach((i,c)=>{let p=`registrations item ${c+1}`;if(!T(i)||typeof i.agentRegistry!="string"||!/^eip155:[1-9][0-9]*:0x[0-9a-fA-F]{40}$/.test(i.agentRegistry))return r(p,"an agentRegistry such as eip155:4663:0x\u2026 and its agentId");let f=typeof i.agentId=="number"&&Number.isSafeInteger(i.agentId)?String(i.agentId):i.agentId,b;try{b=x(f)}catch{return r(p,'an agentId as a whole number, such as "1"')}w(i.agentRegistry,d)&&(n===void 0?r(p,"remove the entry for this registry; its ID comes from the mined Registered receipt, and erc8004_update adds it afterwards"):b!==n&&r(p,`the agentId does not match the agent being updated; use "${n}" or remove the entry`))}):r("registrations","a list, or [] before the first registration"),o.length)throw new g(`This profile needs: ${o.join("; ")}. Fix all of these and try again.`);let u=t.registrations.map(i=>({...i}));n!==void 0&&!u.some(i=>w(i.agentRegistry,d))&&u.push({agentId:n.toString(),agentRegistry:d});let s=[...new Set((t.tags??[]).filter(i=>i!==I))];a!==!1&&s.push(I);let m={...t,registrations:u,...s.length?{tags:s}:{}};s.length||delete m.tags;let l;try{if(l=JSON.stringify(m),te.byteLength(l)>65536)throw new Error;JSON.parse(l)}catch{throw new g("Profile must be JSON data no larger than 64 KiB.")}return`data:application/json;base64,${te.from(l,"utf8").toString("base64")}`}async function M(e,t){try{let{chainId:a,registry:n}=k(e),d=x(t),o=e.clientFor(a),r=await o.readContract({address:n,abi:y,functionName:"ownerOf",args:[d]}).catch(l=>{throw L(l)?new g(`Agent ${d} does not exist in this ERC-8004 registry: the owner lookup reverted. Check the agent ID.`):l});H(r);let[u,s,m]=await Promise.all([o.readContract({address:n,abi:y,functionName:"tokenURI",args:[d]}),o.readContract({address:n,abi:y,functionName:"getAgentWallet",args:[d]}),o.readContract({address:n,abi:y,functionName:"getMetadata",args:[d,I]})]);if(H(s),typeof u!="string"||typeof m!="string"||!/^0x([0-9a-fA-F]{2})*$/.test(m))throw new g("The registry returned invalid identity data.");return{agentId:d.toString(),chainId:a,registry:n,owner:r,uri:u,agentWallet:s,registrarMetadata:m,registryValidated:!1,summary:N}}catch(a){throw new g(e.plainError(a))}}async function Ve(e,t){let a=await M(e,t);return{...a,uri:A(a.uri)}}async function we(e,t,a,n,d,o){let{registry:r}=k(e),u=await F(e,t,a,d),s=o===void 0?"Registered":"URIUpdated",m=ie(o===void 0?"Registered(uint256,string,address)":"URIUpdated(uint256,string,address)"),l=u.logs.filter(v=>w(v.address,r)&&v.topics[0]===m&&!v.removed);if(l.length!==1)throw new g(`The receipt must contain one matching ${s} event.`);let i=l[0],c=re({abi:y,eventName:s,topics:i.topics,data:i.data,strict:!0}),p=c.args.agentId,f=c.eventName==="Registered"?c.args.agentURI:c.args.newURI,b=c.eventName==="Registered"?c.args.owner:c.args.updatedBy;if(o!==void 0&&p!==o||f!==n||!w(b,a))throw new g("The registry event does not match the expected agent, URI and wallet.");let h=await M(e,p.toString());if(h.uri!==n||o===void 0&&!w(h.owner,a))throw new g("The current agent owner or URI does not match the confirmed operation.");return h}function be(e,t){let{chainId:a,registry:n}=k(e);return e.unsignedTx({to:n,chainId:a,value:"0",data:O({abi:y,functionName:"setMetadata",args:[t,I,R]}),description:`Set mutable oak.registrar metadata to oak for agent ${t}.`})}async function ae(e,t,a,n){let{registry:d}=k(e),o=x(n.agentId),r=await F(e,t,a,O({abi:y,functionName:"setMetadata",args:[o,I,R]})),u=ie("MetadataSet(uint256,string,string,bytes)"),s=r.logs.filter(c=>w(c.address,d)&&c.topics[0]===u&&!c.removed);if(s.length!==1)throw new g("The receipt must contain one matching MetadataSet event.");let m=s[0],{args:l}=re({abi:y,eventName:"MetadataSet",topics:m.topics,data:m.data,strict:!0});if(l.agentId!==o||l.metadataKey!==I||l.metadataValue!==R)throw new g("The metadata event does not match this agent and registrar marker.");let i=await M(e,n.agentId);if(i.registrarMetadata!==R||i.uri!==n.uri||!w(i.owner,n.owner))throw new g("The current agent metadata, owner or URI does not match the confirmed operation.");return i}async function Ie(e,t){let{chainId:a,registry:n}=k(e),d=e.clientFor(a),o=await d.readContract({address:n,abi:y,functionName:"balanceOf",args:[t]});if(o===0n)return;if(typeof o!="bigint"||o<0n)throw new g("Registry balance is unavailable; registration was not built.");let r=await d.getBlockNumber({cacheTime:0}),u=new Set;for(;;){let s=r>9999999n?r-9999999n:0n,m=await d.getLogs({address:n,event:ce("event Transfer(address indexed from,address indexed to,uint256 indexed tokenId)"),args:{to:t},fromBlock:s,toBlock:r,strict:!0});for(let l of m){let i=l.args.tokenId.toString();if(l.removed||u.has(i))continue;u.add(i);let c=await M(e,i);if(w(c.owner,t))return c}if(s===0n)throw new g("Owned identity could not be located; registration was not built. Run oak setup link <agentId>.");r=s-1n}}function ke(e){if(e===void 0)return[];if(!Array.isArray(e)||e.length>15)throw new g("Provide at most 15 user metadata entries as { key, value } with value as 0x hex or text.");let t=new Set;return e.map(a=>{if(!T(a))throw new g("Provide each metadata entry as { key, value } or { key, text }.");let n=J(a.key);if(n===I)throw new g("The key oak.registrar is reserved for the registration marker. Remove that metadata entry.");if(t.has(n))throw new g(`Metadata key ${A(n)} is repeated.`);return t.add(n),{metadataKey:n,metadataValue:G(a)}})}function oe(e,t,a){let n=E(t);if(!n)return;let{registryId:d}=k(e);return Array.isArray(n.registrations)&&n.registrations.some(o=>T(o)&&typeof o.agentRegistry=="string"&&w(o.agentRegistry,d)&&String(o.agentId)===a.toString())}function ve(e,t,a){let n=oe(e,t.uri,BigInt(t.agentId));return n===!0?{...t,profileComplete:!0}:{...t,profileComplete:n===void 0?null:!1,nextStep:{tool:"erc8004_update",arguments:{agentId:t.agentId,profile:a??"a registration-v1 profile object"},why:"The minted profile does not list its own registry and agent ID yet (registrations is empty). erc8004_update appends it automatically. It is a normal action: it needs a verified identity link and an active subscription, so link with oak_setup first."}}}async function ne(e,t,a,n){let{chainId:d,registry:o}=k(e);H(n),B(e,a.chainId);let r=t?x(a.agentId):void 0;if(!t&&(a.tag===!1||a.noTag!==void 0||a["--no-tag"]!==void 0))throw new g(ge);if(a.tag!==void 0&&typeof a.tag!="boolean")throw new g("The tag option must be a boolean.");let s=!t&&a.profile===void 0?"":ye(e,a.profile,a.tag,r),m=t?[]:ke(a.metadata),l=a.tag!==!1;if(t&&a.metadataTransactionHash!==void 0&&(!l||a.transactionHash===void 0))throw new g("A metadata transaction hash requires tagging and the profile transaction hash.");let i=r!==void 0?O({abi:y,functionName:"setAgentURI",args:[r,s]}):O({abi:y,functionName:"register",args:[s,[...m,{metadataKey:I,metadataValue:R}]]}),c=f=>r===void 0?ve(e,f,a.profile):f;if(a.transactionHash!==void 0){let f=await we(e,a.transactionHash,n,s,i,r);if(!t){if(!w(f.registrarMetadata,R))throw new g(fe);if(a.metadataTransactionHash!==void 0)throw new g("Registration already writes oak.registrar in one transaction. Omit metadataTransactionHash.");return c({...f,status:"verified",hashes:[a.transactionHash],summary:`Verified ERC-8004 registration for agent #${f.agentId}. Transaction checked: ${a.transactionHash}. ${f.summary}${f.uri===""?" Note: the profile URI is empty; the identity is valid. Attach a profile later with erc8004_update.":""}`})}return l&&a.metadataTransactionHash!==void 0?c(await ae(e,a.metadataTransactionHash,n,f)):c(f)}if(!t){let f=await Ie(e,n);if(f){let b={...f,registrationResumed:!0},h=E(f.uri),v=Array.isArray(h?.tags)&&h.tags.includes(I);if(a.metadataTransactionHash!==void 0){if(!v)throw new g("Only a legacy Oak profile can resume its registrar metadata. Link this agent with oak setup link <agentId>.");return c({...await ae(e,a.metadataTransactionHash,n,f),registrationResumed:!0})}if(!v||f.registrarMetadata!=="0x")return c(b);let S=await U(e,[be(e,x(f.agentId))],n,`Resume registrar metadata for legacy Oak agent ${f.agentId}; no new identity will be minted. Submit locally, then repeat these arguments with metadataTransactionHash to verify the marker receipt.`);return{...b,...S}}if(a.metadataTransactionHash!==void 0)throw new g("No owned legacy Oak identity was found; no metadata transaction was built.")}r!==void 0&&await q(e,r,n);let p=[e.unsignedTx({to:o,data:i,value:"0",chainId:d,description:r===void 0?"Register an ERC-8004 agent profile.":`Update ERC-8004 agent ${r} profile.`})];return t?U(e,p,n,"Submit locally, then repeat the original arguments with transactionHash to verify the profile receipt and URI. The tag option changes the profile tag only; existing onchain metadata is unchanged."):U(e,p,n,`${le} Submit locally, then repeat the original arguments with transactionHash to verify the registration receipt, URI and marker. Update the profile registrations with the mined ID afterward.`,!1)}async function Re(e,t){let a=await M(e,t.agentId),{chainId:n,registry:d}=k(e),o=e.clientFor(n),r=BigInt(a.agentId),u=t.metadataKeys===void 0?[]:(()=>{if(!Array.isArray(t.metadataKeys)||t.metadataKeys.length>16)throw new g("Provide at most 16 metadata keys.");return t.metadataKeys.map(h=>W(h,"metadata key",128,!1))})(),s=t.operator===void 0?void 0:se(String(t.operator)),[m,l,...i]=await Promise.allSettled([o.readContract({address:d,abi:y,functionName:"getApproved",args:[r]}),s?o.readContract({address:d,abi:y,functionName:"isApprovedForAll",args:[a.owner,s]}):Promise.resolve(void 0),...u.map(h=>o.readContract({address:d,abi:y,functionName:"getMetadata",args:[r,h]}))]),c=h=>h.status==="fulfilled"?h.value:void 0,p=c(m),f=_(a.agentWallet)?"unset":w(a.agentWallet,a.owner)?"owner":"verified-other",b=oe(e,a.uri,r);return{...a,approved:typeof p=="string"&&_(p)?null:p??"unavailable",...s?{operator:s,operatorApproved:c(l)??"unavailable"}:{},walletState:f,walletNote:f==="unset"?"No verified payment wallet: it starts as the minting owner, and any NFT transfer or erc8004_unset_wallet clears it. Re-verify with erc8004_wallet_proof then erc8004_set_wallet.":f==="owner"?"The payment wallet is the current owner.":"The payment wallet was proven by a signature from that wallet and is not the owner.",profile:{selfRegistered:b??null,fetched:!1,note:b===void 0?"The URI is external or not decodable; Oak does not fetch it.":void 0},...u.length?{metadata:Object.fromEntries(u.map((h,v)=>{let S=c(i[v]),P=typeof S=="string"&&/^0x([0-9a-fA-F]{2})*$/.test(S)?S:void 0,C;if(P&&P!=="0x")try{C=A(de(P))}catch{C=void 0}return[A(h),{hex:P??"unavailable",...C?{text:C}:{}}]}))}:{}}}var Ae={type:"object",additionalProperties:!1,required:["key"],properties:{key:{type:"string",minLength:1,maxLength:128,description:"Metadata key; agentWallet and oak.registrar are reserved during registration."},value:{...D,description:"Metadata bytes as 0x-prefixed hex; provide value or text."},text:{type:"string",description:"Metadata as UTF-8 text; provide text or value."}}},Te=e=>{let t=(n,d,o)=>({name:n,inputSchema:d,execute:async(r,u)=>{try{let s=await o(r,u);return T(s)&&typeof s.uri=="string"?{...s,uri:A(s.uri)}:s}catch(s){throw new g(e.plainError(s))}}}),a=n=>({type:"object",additionalProperties:!1,required:n?["agentId","profile"]:[],properties:{profile:{...ue,description:n?"Registration-v1 profile object to publish for this agent.":"Omit for an empty URI; register(uri, metadata[]) still writes the public oak.registrar marker. Attach a profile later with erc8004_update."},tag:{type:"boolean",default:!0,description:n?"Set false to remove the profile tag. Profile updates leave existing onchain metadata unchanged.":"Accepted only as true. Oak always adds the oak.registrar marker when it registers."},transactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Verify the exact profile transaction, event and URI.":"After local submission, verify exact registration calldata, event, URI and oak.registrar marker."},metadataTransactionHash:{type:"string",pattern:"^0x[0-9a-fA-F]{64}$",description:n?"Optional legacy metadata transaction hash, supplied with transactionHash to verify a previously sent two-transaction update.":"Only for a resumed legacy Oak profile: verify its separate metadata transaction without transactionHash."},...n?{agentId:$}:{noTag:{type:"boolean",description:"Removed option: omit it and register again."},"--no-tag":{type:"boolean",description:"Removed option: omit it and register again."},metadata:{type:"array",maxItems:15,items:Ae,description:"Up to 15 user entries plus the mandatory oak.registrar marker. The keys agentWallet and oak.registrar are reserved."}}}});return{tools:[t("erc8004_register",a(!1),(n,d)=>ne(e,!1,n,d)),t("erc8004_update",a(!0),(n,d)=>ne(e,!0,n,d)),t("erc8004_identity",{type:"object",additionalProperties:!1,required:["agentId"],properties:{agentId:$,metadataKeys:{type:"array",maxItems:16,items:{type:"string",minLength:1,maxLength:128},description:"Also read these onchain metadata keys."},operator:{...K,description:"Also report whether this address is approved for all of the owner's agents."}}},n=>Re(e,n))]}},De=e=>V("erc8004",[Te(e),Q(e),X(e),Y(e),z(e),ee(e)]);export{Ke as a,Ve as b,oe as c,Te as d,De as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as g,f as T,g as k,i as E}from"./
|
|
1
|
+
import{e as g,f as T,g as k,i as E}from"./R5UOFPDO.js";import{c as _,d as S}from"./GV6FZ6UG.js";import{g as h}from"./NWNYJ26T.js";import{b as f}from"./EWZFZUVF.js";import{a as i}from"./XSD5NL7J.js";import{decodeAbiParameters as P,encodeAbiParameters as B,getAddress as d}from"viem";var D=d("0xcEF685D4796FA80F71a97e803D2c0b6719F1b4E2"),H=[{name:"items",type:"tuple[]",components:[{...k[0],name:"offer"},{name:"ratifierData",type:"bytes"}]}],G=l=>({tools:[{name:"longbow_fixed_offers",inputSchema:{type:"object",additionalProperties:!1,properties:{limit:{type:"integer",minimum:1,maximum:50,description:"Maximum number of offers to return, 1 to 50 (default 20). Newest-expiring offers come first."},marketId:{type:"string",description:"Optional Midnight market id as 0x followed by 64 hex digits (bytes32); only offers in that market are returned."}}},execute:async o=>{try{let a=o.limit??20;if(Object.keys(o).some(s=>!["limit","marketId"].includes(s))||!Number.isInteger(a)||Number(a)<1||Number(a)>50||o.marketId!==void 0&&(typeof o.marketId!="string"||!/^0x[0-9a-f]{64}$/i.test(o.marketId)))throw new i("Use limit 1..50 and an optional exact bytes32 marketId.");let p=await l.http("https://longbow.credit/api/fixed/offers",{method:"GET",redirect:"error"});if(!p.ok)throw new i(`Longbow fixed order book returned HTTP ${p.status}; offers are unavailable.`);let x=await p.text();if(x.length>2e6)throw new i("Longbow fixed order book exceeds the supported response size.");let t=JSON.parse(x);if(!t||t.chainId!==f||typeof t.mempool!="string"||d(t.mempool)!==D||!Array.isArray(t.publications)||t.publications.length>1e3||!Number.isSafeInteger(t.head)||Number(t.head)<0)throw new i("Longbow fixed indexer does not match the pinned chain, mempool or publication schema.");let c=[],u=[],y=0;for(let[s,m]of t.publications.entries())try{if(!m||typeof m!="object")throw new i("Invalid publication.");let r=m,n=r.itemsAbi;if(!Number.isSafeInteger(r.blockNumber)||Number(r.blockNumber)<0||Number(r.blockNumber)>Number(t.head))throw new i("Invalid publication block.");if(typeof n!="string"||!/^0x[0-9a-f]+$/i.test(n)||n.length>1e6||n.length<130||BigInt(`0x${n.slice(2,66)}`)!==32n||BigInt(`0x${n.slice(66,130)}`)>512n)throw new i("Invalid or oversized publication encoding.");let[w]=P(H,n);if(w.length!==r.items)throw new i("Publication count mismatch.");for(let b of w){y++;let e=b.offer;if(e.market.chainId!==BigInt(f)||d(e.market.midnight)!==g||b.ratifierData.length>32770)throw new i("Publication market or proof is unqualified.");let I=E(e.market);if(o.marketId!==void 0&&!h(I,String(o.marketId)))continue;let N=[_,S].find(O=>h(O.address,e.market.loanToken));c.push({marketId:I,offer:B(k,[e]),ratifierData:b.ratifierData,maker:d(e.maker),buy:e.buy,maturity:e.market.maturity.toString(),start:e.start.toString(),expiry:e.expiry.toString(),tick:e.tick.toString(),loanToken:N??null,directBuilderSupported:!!N&&/^0x0{40}$/i.test(e.callback)&&e.callbackData==="0x"&&T.includes(d(e.ratifier)),sourceBlock:String(r.blockNumber)})}}catch(r){u.push({publication:s,reason:l.plainError(r)})}return c.sort((s,m)=>BigInt(s.expiry)>BigInt(m.expiry)?-1:BigInt(s.expiry)<BigInt(m.expiry)?1:0),{chainId:f,midnight:g,mempool:D,indexedHead:String(t.head),decodedCount:y,matchingCount:c.length,offers:c.slice(0,Number(a)),incomplete:u.length>0||t.skipped!==0,rejected:u,warning:"Historical off-chain publications, not executable quotes. Expiry, consumption, authorization, signatures and liquidity are not verified here. Use morpho_midnight_status and preview morpho_midnight_take with the returned exact offer/proof; callback offers need a separately qualified builder. This read publishes nothing and creates no signature."}}catch(a){throw new i(l.plainError(a))}}}]});export{D as a,H as b,G as c};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as we}from"./HC3QFA5I.js";import{c as pe}from"./QFUSCK5C.js";import{a as te}from"./B75SS7H6.js";import{a as F,b as M}from"./7WXAS54T.js";import{a as ee,b as ye}from"./CFPJDLTZ.js";import{a as L}from"./5N6YJFFA.js";import{a as Te}from"./P4UQGWCP.js";import{a as x}from"./43LI5NKJ.js";import{b as he,c as be}from"./SCG5HWMN.js";import{a as me,b as J,c as q}from"./5HCXZWUH.js";import{q as fe,s as P,t as ke}from"./EZUQMTLE.js";import{b as w,c as K,d as H,e as le,j as U,k as ue,t as D}from"./EWZFZUVF.js";import{a as b}from"./XSD5NL7J.js";import{a as A,b as $,c as Q}from"./JXOEJPJ4.js";import{decodeFunctionResult as Be,encodeFunctionData as Ue,erc20Abi as ne,getAddress as T,isAddress as z,parseAbi as Y}from"viem";var X="https://api.robinhood.com/rhj/assets",Fe={address:F,symbol:"ETH",decimals:18,chainId:w},se={address:T(ue),symbol:"USDG",decimals:le,chainId:w},oe={address:T(U[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},Ie={address:T(U[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w},de=[{address:T(ee.chop),symbol:"CHOP",decimals:18,chainId:w},{address:T(ee.oakLog.address),symbol:"chOAK",decimals:18,chainId:w},{address:T(ye),symbol:"schOAK",decimals:18,chainId:w}],W=(e,n)=>de.find(s=>s.chainId===n&&s.address.toLowerCase()===e.toLowerCase());function B(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var $e="ASSET_STATUS_ACTIVE",ge="TRADING_STATUS_UNTRADABLE";function Ke(e){if(e.status!==void 0&&e.status!==$e)return`the issuer lists it as ${typeof e.status=="string"&&/^[A-Z_]{1,64}$/.test(e.status)?e.status:"not active"}`;if(!B(e.tradingCapabilities))return;let n=Object.values(e.tradingCapabilities).filter(B);return n.length>0&&n.every(s=>s.whole===ge&&s.fractional===ge)?"the issuer lists it as untradable in every session":void 0}function He(e,n,s){if(!B(e))return[];let t=e;if(typeof t.tokenSymbol!="string"||!t.tokenSymbol.trim())return[];if(!Array.isArray(t.deployments))return[];if(t.deployments.length>100)throw new b("Official stock deployment list exceeds the lookup limit.");let a=t.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(a))throw new b(`Invalid official stock ticker ${A(a)}.`);if(t.tokenDecimals!==void 0&&(typeof t.tokenDecimals!="number"||!Number.isInteger(t.tokenDecimals)||t.tokenDecimals<0||t.tokenDecimals>255))throw new b("Official stock asset has invalid token decimals.");let r=typeof t.tokenDecimals=="number"?t.tokenDecimals:18,o=Ke(t),c=[];for(let i of t.deployments){if(!B(i))continue;let d=i;if(d.chainId===n){if(typeof d.contractAddress!="string"||!z(d.contractAddress,{strict:!1}))throw new b("Official stock deployment has an invalid contract address.");c.push({address:T(d.contractAddress),symbol:a,decimals:r,chainId:n,...s.includeNames&&typeof t.tokenName=="string"&&t.tokenName.trim()?{name:t.tokenName.trim()}:{},...o?{notTradable:o}:{}})}}return c}function G(e,n=w,s={}){let t=Array.isArray(e)?e:B(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!t)throw new b("Official stock asset list response is malformed.");let a=new Map,r=new Map;if(t.length>1e4)throw new b("Official stock asset list exceeds the lookup limit.");for(let o of t){let c;try{c=He(o,n,s)}catch{continue}for(let i of c){let d=i.address.toLowerCase(),m=i.symbol.toUpperCase(),l=r.get(m);if(!s.allowAmbiguousSymbols&&l&&l!==d)throw new b(`Ambiguous official stock ticker ${A(i.symbol)} across multiple addresses.`);let u=a.get(d);if(u&&(u.symbol!==i.symbol||u.decimals!==i.decimals))throw new b(`Conflicting official stock identity at ${i.address}.`);r.set(m,d),a.set(d,u?.notTradable&&!i.notTradable?{...i,notTradable:u.notTradable}:i)}}return[...a.values()]}function We(e,n){if(typeof e.address!="string"||!z(e.address,{strict:!1}))return!1;let s=e.chainId??w,t=e.address.toLowerCase();return n.some(a=>a.chainId===s&&a.address.toLowerCase()===t&&a.symbol===e.symbol)}function j(e,n){x(e.address);let s=e.chainId??w,t=T(e.address),a=t.toLowerCase(),r=N(e.symbol),o=n.find(i=>i.chainId===s&&i.address.toLowerCase()===a),c=n.find(i=>i.chainId===s&&N(i.symbol)===r);if(o){if(e.symbol!==o.symbol)throw new b(`Token at ${t} does not match official stock ticker ${A(o.symbol)} (received ${A(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==o.decimals)throw new b(`Token ${A(o.symbol)} at ${t} does not match official decimals ${o.decimals}.`);return o}if(c)throw new b(`Token symbol ${A(e.symbol)} at ${t} does not match the official stock contract address ${c.address}.`);return{address:t,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var Ge=["AAOI","AAPL","ABCL","ADBE","AEHR","AEIS","ALAB","AMAT","AMBA","AMC","AMD","AMKR","AMZN","ANET","APLD","APP","ASML","ASTS","AUR","AVAV","AVGO","AXON","AXTI","BA","BABA","BB","BE","BMNR","BND","BULL","CBRS","CCL","CEG","CELH","CIEN","CLOV","CLS","CLSK","COHR","COIN","COST","CRCL","CRDO","CRM","CRWD","CRWV","CSCO","CTSH","CVNA","DDOG","DELL","DIS","DJT","DOCN","ELF","EWT","EWY","F","FICO","FIG","FISV","FIX","FLNC","FLY","FTNT","FUTU","GDX","GE","GEV","GLD","GLW","GLXY","GME","GOOGL","HII","HIMS","HPE","HWM","IBM","IBRX","INDA","INFQ","INOD","INTC","INTU","IONQ","IREN","JBL","JNJ","JOBY","JPM","KLAC","KSS","KTOS","LHX","LITE","LLY","LMT","LRCX","LULU","LUNR","MCD","MDB","META","MOD","MPWR","MRNA","MRVL","MSFT","MSTR","MTSI","MU","MXL","NAVN","NBIS","NET","NFLX","NNE","NOW","NU","NVDA","NVTS","OKLO","ON","ONTO","ORCL","OUST","P","PANW","PATH","PENG","PFE","PL","PLTR","POET","POWL","PR","PWR","PYPL","QBTS","QCOM","QQQ","QUBT","RBLX","RCAT","RDDT","RDW","RGTI","RIVN","RKLB","RUN","SATS","SCHD","SGOV","SHOP","SHY","SIMO","SKHY","SLS","SLV","SMCI","SMH","SMR","SNAP","SNDK","SNOW","SOFI","SOUN","SOXX","SPCX","SPMO","SPY","TE","TEAM","TEM","TER","TSEM","TSLA","TSM","TTD","TTWO","UBER","UMC","UNH","UPS","USAR","USO","V","VICR","VRT","VSAT","VST","VTI","WDAY","WDC","WULF","WYFI","XLK","XNDU","XOM","ZETA","ZM","ZS"],ae=new WeakMap,Ae=new WeakMap,Le=3e4,Se=Object.freeze([]),E;function bt(){if(!E)return Se;let e=Date.now()-E.started;return e>=0&&e<Le?E.tokens:Se}var re=new WeakMap;function V(e,n){return(re.get(e)??P)(n)}async function De(e){let n=e?.http??he(),s=e?.url??X,t=e?.chainId??w,a=q(n),r=Ae.get(a);r||(r=new me(Le),Ae.set(a,r));let{value:o,started:c}=await V(n,()=>r.read(`${t}:${s}`,async()=>{let d=await P(l=>be(a,s,{method:"GET",signal:l},u=>B(u)||Array.isArray(u))),m=G(d,t,{allowAmbiguousSymbols:!0});if(t===w&&m.length===0)throw new b("Official stock asset list has no mainnet deployments; retry when the list is available.");return d})),i=G(o,t,e);if(t===w&&s===X&&(!E||c>=E.started||Date.now()<E.started)&&(E={started:c,tokens:Object.freeze(G(o,t,{allowAmbiguousSymbols:!0}).map(d=>Object.freeze(d)))}),t===w){let d=ae.get(a);d||(d=new Set,ae.set(a,d));for(let m of i)d.add(N(m.symbol))}return i}var Ve=Y(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function Ce(e){let n=e,s=new Set;for(;n&&typeof n=="object"&&!s.has(n)&&s.size<10;){s.add(n);let t=n;if(t.name==="ContractFunctionZeroDataError"||t.name==="AbiDecodingZeroDataError")return!0;let a=`${typeof t.shortMessage=="string"?t.shortMessage:""} ${typeof t.message=="string"?t.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(a))return!0;n=t.cause}return!1}function Xe(e){return e instanceof b?/RPC endpoint|too many requests|malformed JSON/i.test(e.message):e instanceof Error?/fetch failed|network|ECONNREFUSED|ETIMEDOUT|HTTP \d{3}|rate limit|too many requests/i.test(e.message):!1}async function je(e,n,s){if(typeof e.getCode=="function")try{let t=await e.getCode({address:n});return!t||t==="0x"}catch{return Ce(s)}return Ce(s)}async function ie(e,n,s){if(n.length===0)return[];let t=await Promise.allSettled(n.map(a=>e.readContract({address:a.address,abi:ne,functionName:"balanceOf",args:[s]})));if(t.every(a=>a.status==="rejected")&&t[0]?.status==="rejected"&&Xe(t[0].reason))throw t[0].reason;return t.map(a=>{if(a.status!=="fulfilled"||a.value===void 0||a.value===null)return{ok:!1};try{let r=typeof a.value=="bigint"?a.value:BigInt(a.value);return r>=0n?{ok:!0,amount:r}:{ok:!1}}catch{return{ok:!1}}})}async function Pe(e,n,s,t){if(s.length===0)return[];let a=fe(n,e);if(!a)return ie(e,s,t);let r=s.map(c=>({target:c.address,allowFailure:!0,callData:Ue({abi:ne,functionName:"balanceOf",args:[t]})})),o;try{o=await e.readContract({address:a,abi:Ve,functionName:"aggregate3",args:[r]})}catch(c){if(await je(e,a,c))return ie(e,s,t);throw c}if(!Array.isArray(o)||o.length!==s.length)throw new b("Multicall3 aggregate3 returned an invalid result list.");return o.map(c=>{let i=c,d=Array.isArray(i)?i[0]:i?.success,m=Array.isArray(i)?i[1]:i?.returnData;if(!d||typeof m!="string"||m==="0x")return{ok:!1};try{let l=Be({abi:ne,functionName:"balanceOf",data:m}),u=typeof l=="bigint"?l:BigInt(l);return u>=0n?{ok:!0,amount:u}:{ok:!1}}catch{return{ok:!1}}})}async function yt(e,n={}){x(e);let s=T(e),t=n.chainId??w,a=n.client??ke(n.rpcUrl,t),r=[],o;if(n.stockTokens)r=[...n.stockTokens];else if(n.stockAssetsPayload!==void 0)r=G(n.stockAssetsPayload,t,{allowAmbiguousSymbols:!0});else if(n.includeStockTokens!==!1&&t!==K)try{r=await De({http:n.http,url:n.stockAssetsUrl,chainId:t,allowAmbiguousSymbols:!0})}catch(f){if(n.tokens)throw f;o="Stock token balances are unavailable right now: Oak could not read the official stock list. ETH and the other tokens shown are current. Stock tokens are missing from this list, not zero; ask for balances again shortly."}if(n.tokens)for(let f of n.tokens)j(f,r);let c=t===w?[se,oe,Ie,...n.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:T(n.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:H,chainId:t}]:[]]:t===K?[{...se,address:T(D.testnet.usdg),chainId:t},{...oe,address:T(D.testnet.weth),chainId:t},...n.oakTokenAddress?[{address:T(n.oakTokenAddress),symbol:"OAK",decimals:H,chainId:t}]:[]]:[],i=t===w&&n.includePoolTokens!==!1?[...de,...Te.vaults.flatMap(f=>[{address:T(f.tokenAddress),symbol:T(f.tokenAddress),decimals:f.tokenDecimals,chainId:t},{address:T(f.earnContractAddress),symbol:T(f.earnContractAddress),decimals:18,chainId:t}])]:[],d=new Set(i.map(f=>f.address.toLowerCase())),m=[],l=new Set;for(let f of[...c,...r,...n.tokens??[],...i]){if(f.chainId!==t||M(f.address)===F)continue;let y=W(f.address,t)??j(f,r),g=y.address.toLowerCase();l.has(g)||(l.add(g),m.push(y))}let[u,p]=await Promise.all([a.getBalance({address:s}),Pe(a,t,m,s)]),S=[],k={address:F,symbol:"ETH",decimals:18,chainId:t};(u>0n||n.includeZero)&&S.push({token:k,amount:u.toString()});for(let f=0;f<m.length;f++){let y=m[f],g=c.some(O=>v(O.address,y.address))||r.some(O=>v(O.address,y.address))||W(y.address,t)?y.symbol:A(y.symbol),C=p[f]??{ok:!1};if(!C.ok){S.push({token:{address:y.address,symbol:g,decimals:y.decimals,chainId:y.chainId},amount:"unavailable"});continue}let I=C.amount;if(I>0n&&d.has(y.address.toLowerCase())&&!W(y.address,t))try{let[O,R]=await Promise.all([L(a,t,y.address,"symbol"),L(a,t,y.address,"decimals")]);g=A(O),y.decimals=R}catch{}(I>0n||n.includeZero)&&S.push({token:{address:y.address,symbol:g,decimals:y.decimals,chainId:y.chainId},amount:I.toString()})}let h="Outside token discovery is disabled; no receipt time window was scanned, so only ETH, pinned tokens and official stock tokens are listed here.";if(n.includeReceivedTokens===!0){let f=await Ze(s,{client:a});h=f.notice;try{let y=f.addresses.filter(C=>!l.has(C.toLowerCase())),g=await Ye(s,y,{client:a,chainId:t});S.push(...g.map(({token:C,amount:I,note:O})=>({token:C,amount:I,verified:!1,note:`Received from outside Oak's lists; not verified.${O?` ${O}`:""}`}))),h+=ze(g)}catch{h+=" Discovery is incomplete: outside balances or token metadata are unavailable; known balances are retained."}}return S.length||S.push({token:k,amount:u.toString()}),S[0]={...S[0],discoveryNotice:h,...o?{stockNotice:o}:{}},S}var _=200;async function Ze(e,n){x(e);let s,t,a="the last 10,000 blocks (approximately 17 minutes at 100 ms per block; UTC boundaries unavailable)",r=()=>`Outside token discovery covers only ERC-20 receipts in ${a}; older holdings may be missing.`;try{if(t=await P(()=>n.client.getBlockNumber({cacheTime:0}),3e3),s=t>9999n?t-9999n:0n,typeof n.client.getBlock=="function")try{let l=await Promise.all([s,t].map(u=>P(()=>n.client.getBlock({blockNumber:u}),3e3)));a=`blocks ${s}\u2013${t}, from ${new Date(Number(l[0].timestamp)*1e3).toISOString()} to ${new Date(Number(l[1].timestamp)*1e3).toISOString()} (UTC)`}catch{}let o=Y(["event Transfer(address indexed from,address indexed to,uint256 value)"])[0],i=(await P(()=>n.client.getLogs({event:o,args:{to:T(e)},fromBlock:s,toBlock:t,strict:!0}),3e3)).filter(l=>!l.removed&&typeof l.args.value=="bigint"&&l.args.value>0n);i.every(l=>typeof l.blockNumber=="bigint")&&i.sort((l,u)=>l.blockNumber<u.blockNumber?-1:l.blockNumber>u.blockNumber?1:Number(l.logIndex??0)-Number(u.logIndex??0));let d=new Set;for(let l of i){let u=T(l.address);d.delete(u),d.add(u)}let m=[...d];return m.length>_?{addresses:m.slice(-_),fromBlock:s,toBlock:t,incomplete:!0,notice:`${r()} Discovery is incomplete: more than ${_} token contracts sent to this wallet in that window, so only the ${_} most recent are checked.`}:{addresses:m,fromBlock:s,toBlock:t,incomplete:!1,notice:r()}}catch{return{addresses:[],fromBlock:s,toBlock:t,incomplete:!0,notice:`${r()} Discovery is incomplete: RPC receipt reads are unavailable; known balances are retained. Retry balances when RPC logs are available.`}}}function ze(e){let n=e.filter(s=>s.unreadable).length;return n?n===1?" 1 token's symbol or decimals could not be read; its note says what is missing.":` ${n} tokens' symbols or decimals could not be read; their notes say what is missing.`:""}async function Ye(e,n,s){if(x(e),n.length>1e4)throw new b("Journal token discovery exceeds the balance lookup limit.");let t=[...new Set(n.map(o=>(x(o),T(o))))].filter(o=>M(o)!==F).map(o=>({address:o,symbol:o,decimals:0,chainId:s.chainId})),a=[];for(let o=0;o<t.length;o+=_){let c=t.slice(o,o+_);try{a.push(...await Pe(s.client,s.chainId,c,T(e)))}catch{a.push(...await ie(s.client,c,T(e)))}}let r=t.flatMap((o,c)=>{let i=a[c];return i.ok&&i.amount===0n?[]:[{token:o,amount:i.ok?i.amount.toString():"unavailable"}]});return Promise.all(r.map(async({token:o,amount:c})=>{let i=W(o.address,s.chainId);if(i)return{token:{...i},amount:c};let[d,m]=await Promise.all([L(s.client,s.chainId,o.address,"symbol").catch(()=>{}),L(s.client,s.chainId,o.address,"decimals").catch(()=>{})]);if(d!==void 0&&m!==void 0)return{token:{...o,symbol:A(d),decimals:m},amount:c};let l=[...d===void 0?["symbol"]:[],...m===void 0?["decimals"]:[]],u=l.length===2?"This token's symbol and decimals could not be read. It is shown by its contract address, and the amount is in raw base units.":d===void 0?"This token's symbol could not be read. It is shown by its contract address.":"This token's decimals could not be read. The amount is in raw base units.";return{token:{...o,symbol:d===void 0?o.address:A(d),decimals:m??0},amount:c,unreadable:l,note:u}}))}var v=(e,n)=>e.toLowerCase()===n.toLowerCase(),N=e=>Q(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,""),Oe=e=>Q(e.normalize("NFKC")).toLowerCase().match(/[\p{L}\p{N}]+/gu)?.join(" ")??"";function Ee(e){let n=e.context.network??"mainnet",{chainId:s,usdg:t,weth:a}=D[n],r=(o,c,i)=>({...o,address:M(T(o.address)),name:c,kind:i,verified:!0,source:"Oak fixed addresses",warnings:[]});return[r({...Fe,chainId:s},"Ether","native"),r({...se,address:t,chainId:s},"Global Dollar","stablecoin"),r({...oe,address:a,chainId:s},"Wrapped Ether","wrapped"),...n==="mainnet"?[r(Ie,"USDe","stablecoin")]:[],...n==="mainnet"?de.map(o=>r(o,o.symbol==="CHOP"?"Chop":o.symbol==="chOAK"?"Chop OAK log":"Chop OAK staked LP",o.symbol==="CHOP"?"erc20":"wrapped")):[],...e.oakTokenAddress?[r({address:e.oakTokenAddress,symbol:"OAK",decimals:H,chainId:s},"Oak","oak")]:[]]}async function Re(e){if(e.context.network==="testnet")return[];let n=e.officialStockTokens??await De({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return n.filter(s=>We(s,n)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:X,warnings:[],identityNote:"Official Robinhood stock token: this address matches Robinhood's published list. The name and symbol are text from that list."}))}async function ce(e,n,s=!0){let{chainId:t}=D[n.context.network??"mainnet"],a=n.context.clientFor(t);if(await a.getChainId()!==t)throw new b(`Token lookup requires Robinhood Chain ${t}.`);let[r,o,c]=await Promise.all([V(a,()=>L(a,t,e,"name",n.blockNumber)).catch(i=>{if(s)throw i;return""}),V(a,()=>L(a,t,e,"symbol",n.blockNumber)),V(a,()=>L(a,t,e,"decimals",n.blockNumber))]);if(typeof r!="string"||s&&!r.trim()||typeof o!="string"||!o.trim()||!Number.isInteger(c)||c<0||c>255)throw new b("The contract returned invalid token metadata.");return{address:T(e),name:r||o,symbol:o,decimals:c,chainId:t}}async function Ne(e,n){let s=await n.context.clientFor(w).readContract({address:U[w].clanker.factory.address,abi:Y(["function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),functionName:"tokenDeploymentInfo",args:[e]});return Array.isArray(s)&&s.length===4&&typeof s[0]=="string"&&v(s[0],e)}async function Qe(e,n){let s=n.context.clientFor(w),t=U[w].poolsTrade,a=[t.instantLaunchStrategyFeesOn.address,t.instantLaunchStrategyFeesOff.address],r=Y(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],o=await s.getBlockNumber(),c=new Set,i=0,d=0;for(let m=63127652n;m<=o;m+=10000000n){if(++i>xe)throw new b("Token origin scan limit reached.");let l=m+9999999n>o?o:m+9999999n,u=await s.getLogs({address:a,event:r,args:{token:e},fromBlock:m,toBlock:l,strict:!0});for(let p of u){if(p.removed||!a.some(k=>v(k,p.address))||!p.args.token||!v(p.args.token,e)||!p.transactionHash||c.has(p.transactionHash))continue;if(c.add(p.transactionHash),++d>20)throw new b("Token origin receipt limit reached.");let S=await s.getTransactionReceipt({hash:p.transactionHash});if(we(S).some(k=>v(k.token,e)))return T(S.from)}}}var xe=5,Je=100,qe=500,et=3e4;function Me(e){let n=Date.now()+et,s=0,t=new Map,a=o=>{let c=n-Date.now();if(c<=0)throw new b("Token lookup time budget reached; results are partial.");return P(o,Math.min(1e4,c))},r=J((o,c)=>a(async i=>{let d=await e.context.http(o,{...c,signal:i});return new Proxy(d,{get(m,l){if(l==="json")return()=>a(()=>m.json());let u=Reflect.get(m,l,m);return typeof u=="function"?u.bind(m):u}})}),e.context.http);return re.set(r,a),{...e,context:{...e.context,http:r,clientFor:o=>{if(!t.has(o)){let c=e.context.clientFor(o),i=d=>{if(++s>qe)throw new b("Token lookup RPC budget reached; results are partial.");return a(d)};t.set(o,J(new Proxy(c,{get(d,m){let l=Reflect.get(d,m);return typeof l!="function"?l:(...u)=>i(()=>l.apply(d,u))}}),c)),re.set(t.get(o),i)}return t.get(o)}}}}function Z(e){return e.source==="Oak fixed addresses"?e:e.kind==="official_stock"&&e.verified&&e.source===X?{...e,name:$(e.name)?A(e.name):e.name}:{...e,symbol:A(e.symbol),name:A(e.name)}}async function Tt(e,n){if(n=Me(n),typeof e!="string"||e.length>256||!N(e))throw new b("Provide a token name, symbol or address to find_token.");let s=N(e),t=z(e.trim(),{strict:!1})?M(T(e.trim())):void 0,{chainId:a}=D[n.context.network??"mainnet"],r=[],o=Ee(n),c=!1;try{o.push(...await Re(n))}catch{c=!0,r.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let i=k=>t?v(k.address,t):N(k.symbol).includes(s)||N(k.name).includes(s),d=o.filter(i),m=[],l=(k,h)=>[k.symbol,k.name??""].some(f=>[h.symbol,h.name].some(y=>{let g=N(f),C=N(y),I=Oe(f),O=Oe(y);return!!g&&!!C&&(g===C||(C.length>=3?g.includes(C):` ${I} `.includes(` ${O} `)))})),u=(k,h={})=>{if(m.some(g=>v(g.address,k.address)))return;let f=[`Token ${A(k.symbol)} at ${k.address} is an unverified ${h.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];($(k.symbol)||$(k.name)||o.some(g=>!v(g.address,k.address)&&l(k,g)))&&f.push(`Lookalike warning: ${A(k.symbol)} at ${k.address} resembles a verified token's name or symbol.`);let y={...k,...h,kind:h.launchpad?"launchpad":"erc20",verified:!1,source:h.launchpad?`${h.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:f};m.push(y),r.push(...f)};if(t&&!d.length){let k=await ce(t,n),h={};if(a===w){try{await Ne(t,n)&&(h.launchpad="clanker")}catch{r.push("Clanker origin lookup was unavailable for this address.")}if(h.launchpad==="clanker")try{let y=(await te(n.context,{q:t,limit:20})).tokens.find(g=>v(g.contract_address,t));y&&(h.creator=T(y.msg_sender),h.creatorSource="Clanker indexer msg_sender")}catch{r.push("Clanker creator lookup is unavailable.")}else try{let f=await pe(n.context,t);h.launchpad="pons",h.creator=T(f.creator),h.creatorSource="Pons factory deployer"}catch{r.push("Pons launch origin could not be confirmed for this address.")}if(!h.launchpad)try{let f=await Qe(t,n);f&&(h.launchpad="pools.trade",h.creator=f,h.creatorSource="Launch transaction sender; may be a relayer")}catch{c=!0,r.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}u(k,h)}else if(!t&&a===w){let k=new Set,h=new Set,f,y=0,g=0;try{do{if(++y>xe)throw new b("Token search page limit reached.");let C=await te(n.context,{q:e.trim(),limit:20,...f?{cursor:f}:{}});for(let I of C.tokens){if(++g>Je)throw new b("Token candidate limit reached.");let O=T(I.contract_address);if(!(h.has(O)||o.some(R=>v(R.address,O)))){h.add(O);try{let R=await ce(O,n);if(!i(R))continue;let _e=await Ne(O,n)?{launchpad:"clanker",creator:T(I.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};u(R,_e)}catch{c=!0,r.push(`Could not read Clanker candidate ${O}; it was omitted from these partial results.`)}}}if(C.cursor&&k.has(C.cursor))throw new b("The Clanker indexer repeated a pagination cursor.");C.cursor&&k.add(C.cursor),f=C.cursor??void 0}while(f)}catch{c=!0,r.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}r.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}a===K&&r.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let p=k=>[...new Map(k.map(h=>[h.address.toLowerCase(),h])).values()],S=p([...d,...m]);for(let k of S)if(S.some(h=>!v(h.address,k.address)&&(N(k.symbol)===N(h.symbol)||N(k.name)===N(h.name)))){let h=`Duplicate warning: several tokens share the symbol or name of ${k.address}. Choose the intended address; do not guess from the name.`;k.warnings.push(h),r.push(h)}return d.length>1&&r.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:A(e.trim()),chainId:a,partial:c,matches:p(d).map(Z),unverified:p(m).map(Z),warnings:r}}var ve=e=>`${A(e.symbol)} is not tradable right now: ${e.notTradable}. Oak will not quote it; a balance you hold still shows and can still be sent.`;async function pt(e,n){if(typeof e!="string"||!e.trim())throw new b("Provide a token address or verified symbol; use find_token to look it up.");if(!/^[A-Za-z0-9.$_-]{1,42}$/.test(e))throw new b("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,t=z(s,{strict:!1})?M(T(s)):void 0,a=Ee(n),r=t&&a.find(u=>v(u.address,t));if(r)return r;let o=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),c=!t&&a.find(u=>u.symbol.toUpperCase()===o),i=[],d=!1;try{i=await Re(n)}catch{if(c)return c;if(!t)throw new b("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");d=!0}if(t){let u=i.find(k=>v(k.address,t));if(u){if(u.notTradable)throw new b(ve(u));return n.tokenMetadata&&j(n.tokenMetadata,i),Z(u)}let p=n.tokenMetadata??await n.readMetadata?.(t);if(p&&(!v(p.address,t)||p.chainId!==D[n.context.network??"mainnet"].chainId))throw new b("Token metadata does not match the requested address and chain.");if(p&&(typeof p.symbol!="string"||!p.symbol.trim()||!Number.isInteger(p.decimals)||p.decimals<0||p.decimals>255))throw new b("The contract returned invalid token metadata.");let S=p?{...p,name:p.symbol}:await ce(t,Me(n),!1);if(d){let k=N(S.symbol),h=ae.get(q(n.context.http));if(Ge.some(f=>N(f)===k)||h?.has(k))throw new b("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return j(S,i),{...S,symbol:A(S.symbol),name:A(S.name),kind:"erc20",verified:!1,source:"On-chain metadata only",warnings:["This token address is unverified. On-chain names and symbols do not prove identity.",...d?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let m=[...a,...i].filter(u=>u.symbol.toUpperCase()===o);if(m.length!==1)throw new b(`Token symbol ${A(s)} is ${m.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let l=m[0];if(l.kind==="official_stock"&&s!==l.symbol)throw new b(`Use the exact official stock ticker ${A(l.symbol)}; case variants are refused.`);if(l.notTradable)throw new b(ve(l));return Z(l)}export{X as a,Fe as b,se as c,oe as d,Ie as e,de as f,G as g,We as h,j as i,bt as j,De as k,Ve as l,yt as m,Ze as n,ze as o,Ye as p,Tt as q,pt as r};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as Le}from"./5Y457HYC.js";import{m as le}from"./IR7KDBFU.js";import{e as Z,f as O,h as H,i as y,j as d,k as de,l as ke,m as W,o as U,p as u}from"./UMY6SP7C.js";import{b as q,i as Pe,j as ue,k as X}from"./CJMVRV34.js";import{a as c}from"./XSD5NL7J.js";import{decodeAbiParameters as Ge,decodeFunctionResult as We,encodeAbiParameters as z,encodeFunctionData as M,getAddress as D,keccak256 as N,parseAbi as _,parseAbiParameters as ze,toHex as _e,zeroAddress as x}from"viem";var mt="Pay Later requires a separate vault and family custody with beneficiary and premium terms; this launch does not create or fund that vault.",R=["premiumBps","strikeMarkupBps","tenor","priceWindowBlocks","maxBlockDepthBps","anchorDecayBlocks","topGuardBps","minOrderUnits","maxOrderUnits","maxUnitsPerBlock","maxActiveUnits","maxInventory","minPremium"],ie=[16,16,32,16,16,32,16,128,128,128,128,128,128],ye={type:"tuple",components:R.map((e,t)=>({name:e,type:`uint${ie[t]}`}))},Be=_(["function createVault(bytes32 familyId, uint8 member, (uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium) terms) returns (address vault)"]);function ee(e){let t=Z(e,R,R),r=R.map((o,i)=>O(t[o],ie[i]));if(r[0]<100n||r[0]>5000n||r[1]>5000n||r[2]<300n||r[2]>604800n||r[3]<1n||r[3]>64n||r[4]<1n||r[4]>100n||r[5]<300n||r[5]>50400n||r[6]>5000n||r[7]<1n||r[7]>r[8]||r[8]>r[9]||r[9]>r[10]||r[10]>r[11]||r[11]>10n**36n)throw new c("Pay Later terms violate the immutable economic bounds or nested inventory limits.");return Object.fromEntries(R.map((o,i)=>[o,String(r[i])]))}function $e(e){return Object.fromEntries(R.map((t,r)=>[t,ie[r]<=32?Number(e[t]):BigInt(e[t])]))}function fe(e){return z([ye],[$e(ee(e))])}function Qe(e){if(e.length!==834)throw new c("Pay Later requires exactly thirteen ABI words.");let[t]=Ge([ye],e),r=ee(Object.fromEntries(R.map(o=>[o,String(t[o])])));if(fe(r).toLowerCase()!==e.toLowerCase())throw new c("Pay Later terms are not canonical.");return r}function Ce(e,t,r){let o=H(e),i=O(t,8),n=ee(r);return M({abi:Be,functionName:"createVault",args:[o,Number(i),$e(n)]})}function Oe(e,t,r,o){let i=Qe(e);if(!/^0x[0-9a-fA-F]{40}$/.test(t)||!/^0x[0-9a-fA-F]{40}$/.test(r)||/^0x0{40}$/i.test(t)||/^0x0{40}$/i.test(r)||!Number.isInteger(o)||o<2e3||o>5e3)throw new c("Pay Later requires nonzero beneficiary and protocol recipient and a protocol share of 2000\u20135000 bps.");return`Pay Later: beneficiary ${t}, protocol recipient ${r}, protocol premium share ${o} bps. Immutable terms: ${R.map(n=>`${n} ${i[n]}`).join(", ")}. After the owner transfers the entire family and the beneficiary accepts, the vault owns the LP family through the Launcher; its LP principal cannot be removed while held by the vault. The beneficiary can start a two-step release of the family. Harvested subject-token fees become vault inventory up to maxInventory; excess subject and other-currency fees are owed to the beneficiary. The beneficiary can withdraw free inventory and earnings; reserved inventory remains in the vault to cover open orders, including after a family release. At order opening the buyer pays the quote-currency premium to the vault and its subject inventory is reserved: premium = max(ceil(strike \xD7 premiumBps / 10000), minPremium). The vault credits floor(premium \xD7 ${o} / 10000) to the protocol recipient, payable by anyone through payProtocol, and the rest to beneficiary earnings, withdrawable by the beneficiary. The buyer may exercise in a later block strictly before expiry (open timestamp plus tenor), in full or in parts, paying the cumulative pro-rata strike rounded up in quote; the vault credits the strike to beneficiary earnings and delivers the exercised subject tokens to the buyer's chosen recipient. At expiry anyone may return unexercised units to free inventory; the premium is not refunded. Token resale or profit is not guaranteed. Creation, transfer and acceptance are separate actions requiring fresh chain checks and confirmations.`}var we=_(["function transferFamily(bytes32 familyId,address newOwner,uint16 claims)","function acceptFamily(bytes32 familyId)"]),oe=_(["function acceptFamily()","function releaseFamily()","function withdrawEarnings(address currency,address to,uint256 amount)","function withdrawInventory(address to,uint128 amount)"]);function Ye(e,t,r){let o=H(e),i=y(t),n=O(r,16);if(i===x)throw new c("Pay Later vault must be nonzero.");return M({abi:we,functionName:"transferFamily",args:[o,i,Number(n)]})}function Ke(e){return M({abi:we,functionName:"transferFamily",args:[H(e),x,0]})}function Je(){return M({abi:oe,functionName:"acceptFamily"})}function Xe(){return M({abi:oe,functionName:"releaseFamily"})}function Ze(e){return M({abi:we,functionName:"acceptFamily",args:[H(e)]})}function Se(e){let t=y(e);if(t===x)throw new c("Pay Later withdrawal recipient must be nonzero.");return t}function Ne(e,t,r){return M({abi:oe,functionName:"withdrawEarnings",args:[y(e),Se(t),O(r)]})}function et(e,t){return M({abi:oe,functionName:"withdrawInventory",args:[Se(e),O(t,128)]})}var L="0xFc3e9e435C79e1712CF949C6ea921fA165cadEf3",Re="0x2f66c525278406c6261d911135b17bd618578a9bf910aff17d426e438180e050",B=_(["function launcher() view returns (address)","function registry() view returns (address)","function protocolShareBps() view returns (uint16)","function minTopGuardBps() view returns (uint16)","function minDynamicFeeSpanPips() view returns (uint24)","function bandReachBps(bytes32,uint8) view returns (uint256)","function vaultOf(bytes32,address) view returns (address)","function isVault(address) view returns (bool)"]),S=(e,t)=>String(e).toLowerCase()===String(t).toLowerCase(),ae=e=>e===x?"native ETH":e;async function je(e,t,r,o){let i=D(q.launcherV1),n=W(await u(e,i,U("launcherV1"),"position",[r,o],t)),l=W(n.key),m=y(l.currency0),f=y(l.currency1),a=y(l.hooks),P=Number(d(l.fee,24)),{tickSpacing:v}=l,{tickLower:b,tickUpper:j}=n;if(typeof v!="number"||!Number.isInteger(v)||typeof b!="number"||typeof j!="number")throw new c("Pay Later reference position is incomplete.");if(a!==D(q.rootV1))throw new c("Pay Later reference root is not the reviewed current root.");let $=N(z(ze("address,address,uint24,int24,address"),[m,f,P,v,a])),C=W(await u(e,a,U("rootV1"),"poolConfig",[$],t)),A=y(C.rules);await Pe(e,t,[i,a,A]);let g=y(await u(e,A,_(["function protocolRecipient() view returns (address)"]),"protocolRecipient",[],t));return{currency0:m,currency1:f,root:a,poolId:$,rules:A,subject:y(C.subject),quote:y(C.quote),baseLpFeePips:d(C.baseLpFeePips,24),liquidity:d(n.liquidity,128),tickLower:b,tickUpper:j,protocolRecipient:g}}async function he(e,t,r,o){let i=D(q.launcherV1);return Promise.all(Array.from({length:o},async(n,l)=>{let m=W(await u(e,i,U("launcherV1"),"position",[r,l],t)),f=W(m.key);return{member:l,currency0:y(f.currency0),currency1:y(f.currency1),liquidity:d(m.liquidity,128),tickLower:m.tickLower,tickUpper:m.tickUpper}}))}function re(e){return e.map(t=>`member ${t.member}, currencies ${t.currency0}/${t.currency1}, liquidity ${t.liquidity}, ticks ${t.tickLower}/${t.tickUpper}`).join("; ")}function pe(e,t){let r=o=>(t>>o&1)===1?"as a PoolManager claim":"as tokens";return e.map(o=>`member ${o.member}: ${ae(o.currency0)} ${r(2*o.member)}, ${ae(o.currency1)} ${r(2*o.member+1)}`).join("; ")}var xe="A PoolManager claim is a balance recorded inside the Uniswap PoolManager, not tokens in the wallet. Oak has no tool to redeem PoolManager claims.";async function tt(e,t,r,o){let i=Z(r,["familyId","member","terms","protocolRecipient","protocolShareBps"],["familyId","member","terms","protocolRecipient","protocolShareBps"]),n=y(o),l=H(i.familyId),m=Number(O(i.member,8)),f=ee(i.terms),a=y(i.protocolRecipient),P=Number(O(i.protocolShareBps,16));if(n===x||a===x||P<2e3||P>5e3)throw new c("Pay Later needs nonzero owner and protocol recipient and a protocol share of 2000\u20135000 bps.");let v=await ue(e,t),b=D(q.launcherV1),j=D(q.registry),[$,C,A,g,E,Q,I,s,p,F,se]=await Promise.all([e.getCode({address:L,blockNumber:t}),u(e,L,B,"launcher",[],t),u(e,L,B,"registry",[],t),u(e,L,B,"protocolShareBps",[],t),u(e,L,B,"minTopGuardBps",[],t),u(e,L,B,"minDynamicFeeSpanPips",[],t),u(e,L,B,"bandReachBps",[l,m],t),u(e,L,B,"vaultOf",[l,n],t),u(e,b,U("launcherV1"),"familyOwner",[l],t),u(e,b,U("launcherV1"),"pendingFamilyOwner",[l],t),u(e,b,U("launcherV1"),"memberCount",[l],t)]);if(!$||N($)!==Re||!S(C,b)||!S(A,j))throw new c("Pay Later factory runtime, launcher or registry does not match the reviewed deployment.");if(!S(p,n)||!S(s,x)||!Array.isArray(F)||!S(F[0],x))throw new c("Pay Later needs the current family owner, no existing beneficiary vault and no pending family transfer.");let Y=d(se,8);if(Y<1n||Y>8n||BigInt(m)>=Y)throw new c("Pay Later member exceeds the live family member count.");if(d(g,16)!==BigInt(P)||BigInt(f.topGuardBps)<d(E,16)||d(I)<100000n)throw new c("Pay Later protocol share, top guard floor or band reach differs from the requested listing.");let k=await je(e,t,l,m);if(k.liquidity===0n)throw new c("Pay Later reference position is incomplete or has no liquidity.");if(k.protocolRecipient!==a||BigInt(f.maxBlockDepthBps)*400n>k.baseLpFeePips)throw new c("Pay Later protocol recipient or depth share does not match the reference pool.");let K=await he(e,t,l,Number(Y)),G=Ce(l,String(m),f),w;try{let te=await e.call({account:n,to:L,data:G,blockNumber:t});if(!te.data)throw new Error("empty");w=te.data}catch{throw new c("Pay Later createVault simulation failed at the named block; listing, dynamic fee, family or custody requirements are not satisfied.")}let J=We({abi:Be,functionName:"createVault",data:w});if(J===x)throw new c("Pay Later factory predicted a zero vault.");return await X(e,v),{block:v,familyId:l,member:m,owner:n,vault:J,poolId:k.poolId,root:k.root,rules:k.rules,familyPositions:K,subject:k.subject,quote:k.quote,liquidity:k.liquidity,terms:f,protocolRecipient:a,protocolShareBps:P,minDynamicFeeSpanPips:d(Q,24),bandReachBps:d(I),summary:`${Oe(fe(f),n,a,P)} Family ${l}, member ${m}, vault ${J}. Creating the vault moves nothing. Positions that would later enter vault custody: ${re(K)}. Whether fees already accrued are paid as tokens or as PoolManager claims is chosen at the transfer step. Creation, transfer and acceptance are separate confirmations; repeat checks and simulate each immediately before signing.`}}var Ae={launcher:[3354,4191,5647,9253,9716,11135,11275,12237],poolManager:[1327,1907,2912,3967,5926,7408,9165,10771,13734,14082],root:[1139],familyId:[3315,4150,5603,8928,9654,11234,12196],member:[1212,12340],memberCount:[3267,11748],poolId:[2879,3934,5893,7375,9055,10738,13701,14049],subject:[4333,5106,7974,11416,12058,13931,14697,15021,16987],quote:[3690,6644,7850,11912,13993,14776,15260],subjectIsCurrency0:[2680,15880],beneficiary:[1772,3212,4920,5279,10829,12135],termsHash:[3016],bandLiquidity:[8995,12429,16471],bandTickLower:[5969,8866],bandTickUpper:[7077,10959],anchorCeiling:[2741,13779,14140,16409],anchorDecayBlocks:[2258,13832],topGuardBps:[3830],guardPrice:[2800,6988],protocolRecipient:[3759,11874],protocolShareBps:[6583,10900]};function nt(e,t){Le(e,17333,"0x2d650492c4352eebba37441fa43b06ca3c8c9f0aa7106c806c9f6ab44162f45b",Ae,t)}var rt=_(["function poolManager() view returns (address)","function memberCount() view returns (uint8)","function subjectIsCurrency0() view returns (bool)","function termsHash() view returns (bytes32)","function bandTickLower() view returns (int24)","function bandTickUpper() view returns (int24)","function anchorCeiling() view returns (uint256)","function anchorDecayBlocks() view returns (uint256)","function topGuardBps() view returns (uint256)","function guardPrice() view returns (uint256)","function root() view returns (address)","function poolId() view returns (bytes32)","function subject() view returns (address)","function quote() view returns (address)","function beneficiary() view returns (address)","function launcher() view returns (address)","function familyId() view returns (bytes32)","function member() view returns (uint8)","function protocolRecipient() view returns (address)","function protocolShareBps() view returns (uint256)","function bandLiquidity() view returns (uint128)","function custodyReachBps() view returns (uint256)","function terms() view returns ((uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium))"]),Ie=["poolManager","memberCount","subjectIsCurrency0","termsHash","bandTickLower","bandTickUpper","anchorCeiling","anchorDecayBlocks","topGuardBps","guardPrice","root","poolId","subject","quote","beneficiary","launcher","familyId","member","protocolRecipient","protocolShareBps","bandLiquidity","custodyReachBps","terms"],V=_(["function accountedFree() view returns (uint128)","function accountedReserved() view returns (uint128)","function owed(address) view returns (uint256)","function protocolOwed() view returns (uint256)","function nextPositionId() view returns (uint256)","function accountingInvariant() view returns (bool)"]);function at(e,t,r){if(e)return le(r);let o=le(t);return((1n<<192n)+o-1n)/o}async function qe(e,t,r,o){let i=y(o),n=H(r);if(i===x)throw new c("Pay Later custody needs the beneficiary wallet.");let l=await ue(e,t),m=D(q.launcherV1),f=U("launcherV1"),[a,P,v,b,j,$,C,A]=await Promise.all([e.getCode({address:L,blockNumber:t}),u(e,L,B,"launcher",[],t),u(e,L,B,"registry",[],t),u(e,L,B,"protocolShareBps",[],t),u(e,L,B,"vaultOf",[n,i],t),u(e,m,f,"familyOwner",[n],t),u(e,m,f,"pendingFamilyOwner",[n],t),u(e,m,f,"memberCount",[n],t)]);if(!a||N(a)!==Re||!S(P,m)||!S(v,q.registry))throw new c("Pay Later factory runtime, launcher or registry does not match the reviewed deployment.");let g=y(j);if(g===x)throw new c("This wallet has no Pay Later vault for this family; only the beneficiary that created a vault can act on it.");let[E,Q,...I]=await Promise.all([e.getCode({address:g,blockNumber:t}),u(e,L,B,"isVault",[g],t),...Ie.map(h=>u(e,g,rt,h,[],t))]);if(!E)throw new c("Pay Later vault has not been created.");let s=Object.fromEntries(Ie.map((h,T)=>[h,I[T]])),p=W(s.terms),F=ee(Object.fromEntries(R.map(h=>[h,String(p[h])]))),se=["launcher","poolManager","root","subject","quote","beneficiary","protocolRecipient"],Y=["familyId","poolId","termsHash"],k={};for(let h of Object.keys(Ae))if(se.includes(h))k[h]=z([{type:"address"}],[y(s[h])]);else if(Y.includes(h))k[h]=H(s[h]);else if(h==="subjectIsCurrency0")k[h]=z([{type:"bool"}],[de(s[h])]);else if(h==="bandTickLower"||h==="bandTickUpper"){let T=s[h];if(typeof T!="number"||!Number.isInteger(T)||T<-8388608||T>8388607)throw new c("Pay Later vault tick is invalid.");k[h]=z([{type:"int24"}],[T])}else k[h]=z([{type:"uint256"}],[d(s[h])]);if(nt(E,k),Q!==!0||y(s.beneficiary)!==i||!S(s.launcher,m)||!S(s.familyId,n))throw new c("Pay Later vault beneficiary, family or factory attestation does not match this wallet and family.");let K=Number(d(s.member,8)),G=d(A,8);if(G<1n||G>8n||BigInt(K)>=G||d(s.memberCount,8)!==G)throw new c("Pay Later vault member does not fit the live family member count.");let w=await je(e,t,n,K),[J,te,Te,He,Ue,Ve,De]=await Promise.all([u(e,g,V,"accountedFree",[],t),u(e,g,V,"accountedReserved",[],t),u(e,g,V,"owed",[w.subject],t),u(e,g,V,"owed",[w.quote],t),u(e,g,V,"protocolOwed",[],t),u(e,g,V,"nextPositionId",[],t),u(e,g,V,"accountingInvariant",[],t)]),Me=N(_e("Terms(uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium)")),Ee=N(z([{type:"bytes32"},...ye.components],[Me,...R.map((h,T)=>ie[T]<=32?Number(F[h]):BigInt(F[h]))])),ce=w.subject===w.currency0,ne=at(ce,w.tickLower,w.tickUpper),be=ne*ne/(1n<<96n)*(10000n-BigInt(F.topGuardBps))/10000n,ge=d(b,16);if(y(s.poolManager)!==D(q.poolManager)||y(s.root)!==w.root||!S(s.poolId,w.poolId)||y(s.subject)!==w.subject||y(s.quote)!==w.quote||s.subjectIsCurrency0!==ce||s.bandTickLower!==w.tickLower||s.bandTickUpper!==w.tickUpper||!S(s.termsHash,Ee)||d(s.anchorDecayBlocks)!==BigInt(F.anchorDecayBlocks)||d(s.topGuardBps)!==BigInt(F.topGuardBps)||d(s.anchorCeiling)!==ne||d(s.guardPrice)!==be||y(s.protocolRecipient)!==w.protocolRecipient||d(s.protocolShareBps)!==ge)throw new c("Pay Later vault immutables differ from the pool, band, terms or protocol recipient derived from the chain for this family.");let ve=ke(C,2);return await X(e,l),{block:l,familyId:n,owner:i,vault:g,member:K,memberCount:Number(G),poolId:w.poolId,root:w.root,rules:w.rules,subject:w.subject,quote:w.quote,subjectIsCurrency0:ce,terms:F,protocolRecipient:w.protocolRecipient,protocolShareBps:Number(ge),familyOwner:y($),pendingOwner:y(ve[0]),pendingClaims:Number(d(ve[1],16)),liquidity:w.liquidity,bandLiquidity:d(s.bandLiquidity,128),bandTickLower:w.tickLower,bandTickUpper:w.tickUpper,anchorCeiling:ne,guardPrice:be,custodyReachBps:d(s.custodyReachBps),accountedFree:d(J,128),accountedReserved:d(te,128),owedSubject:d(Te),owedQuote:d(He),protocolOwed:d(Ue),nextPositionId:d(Ve),accountingInvariant:de(De)}}var Fe=e=>`Pay Later family ${e.familyId}, reference member ${e.member}, vault ${e.vault}, beneficiary ${e.owner}.`,me={transfer:["familyId","claims"],cancel:["familyId"],accept:["familyId"],release:["familyId"],"accept-back":["familyId"],"withdraw-earnings":["familyId","currency","amount"],"withdraw-inventory":["familyId","amount"]};async function pt(e,t,r,o,i){if(i==="create"){let p=await tt(e,t,r,o);return{step:i,action:{to:L,data:Ce(p.familyId,String(p.member),p.terms)},block:p.block,familyId:p.familyId,member:p.member,vault:p.vault,beneficiary:p.owner,summary:p.summary,plan:p}}if(!Object.hasOwn(me,i))throw new c("Choose a Pay Later step: create, transfer, cancel, accept, release, accept-back, withdraw-earnings or withdraw-inventory.");let n=Z(r,me[i],me[i]),l=i==="transfer"?Number(O(n.claims,16)):0,m=i==="withdraw-earnings"?y(n.currency):x,f=i==="withdraw-earnings"?O(n.amount):i==="withdraw-inventory"?O(n.amount,128):0n,a=await qe(e,t,n.familyId,o),{familyId:P,owner:v,vault:b}=a,j=D(q.launcherV1),$=a.familyOwner===v,C=a.familyOwner===b,A=(1<<2*a.memberCount)-1,g=()=>he(e,t,P,a.memberCount),E=()=>{if(a.liquidity<a.bandLiquidity||a.custodyReachBps<100000n)throw new c("Pay Later vault custody requires the frozen band liquidity and at least 100000 bps reach.")},Q=p=>{if(f===0n||f>p)throw new c(`Pay Later ${i} amount must be above zero and at most ${p}, the amount available at the named block.`)},I,s;if(i==="transfer"){if(l>>2*a.memberCount!==0)throw new c(`Pay Later claims mask ${l} selects a member beyond the ${a.memberCount} in this family.`);if(!$||a.pendingOwner!==x)throw new c("Pay Later transfer needs this wallet to own the family with no pending transfer; cancel a pending transfer first.");E();let p=await g();I={to:j,data:Ye(P,b,String(l))},s=`Start the transfer of the entire family to the vault. Nothing moves until the separate accept step. Positions: ${re(p)}. When the vault accepts, fees already accrued are paid to this wallet, the current owner: ${pe(p,l)}. ${xe} To change this choice before acceptance, use the cancel step and start the transfer again.`}else if(i==="cancel"){if(!$)throw new c("Pay Later cancel needs this wallet to own the family.");if(a.pendingOwner===x)throw new c("Pay Later cancel found no pending family transfer to cancel.");I={to:j,data:Ke(P)},s=`Cancel the pending transfer to ${a.pendingOwner}${a.pendingOwner===b?" (the vault)":""}. The pending owner is set to the zero address, so nobody can accept it and this wallet keeps the family. A new transfer can then be started with a different choice of how accrued fees are paid.`}else if(i==="accept"){if(!$||a.pendingOwner!==b)throw new c("Pay Later accept needs this wallet to own the family and a pending transfer to the vault.");E();let p=await g();I={to:b,data:Je()},s=`Accept custody of the entire family into the vault. Positions: ${re(p)}. Fees already accrued are paid to this wallet, the previous owner, as set when the transfer was started: ${pe(p,a.pendingClaims)}. ${xe} ${Oe(fe(a.terms),v,a.protocolRecipient,a.protocolShareBps)}`}else if(i==="release"){if(!C)throw new c("Pay Later release needs the vault to own the family.");if(a.pendingOwner!==x)throw new c("Pay Later release is already pending back to the beneficiary; the next step is accept-back.");I={to:b,data:Xe()},s=`Release the family from vault custody. This starts a two-step hand-back to the beneficiary ${v} with every fee-claim bit set (mask ${A}). The vault still owns the family until the next step, accept-back, is sent by this wallet; reserved inventory stays in the vault to cover open orders (${a.accountedReserved} subject base units reserved at this block). Free inventory and earnings remain withdrawable by the beneficiary.`}else if(i==="accept-back"){if(!C||a.pendingOwner!==v||a.pendingClaims!==A)throw new c("Pay Later accept-back needs the vault to own the family and the released family pending back to this wallet with every fee-claim bit set.");let p=await g();I={to:j,data:Ze(P)},s=`Accept the released family back from the vault: this wallet becomes the owner of every family position again. Positions: ${re(p)}. Fees accrued at acceptance are paid to the previous owner, which is the vault ${b}, as PoolManager claims. They are not paid to this wallet; the vault's redeemClaims, which anyone may call, turns them into vault inventory or beneficiary earnings. Oak has no tool to redeem PoolManager claims. Reserved inventory (${a.accountedReserved} subject base units) stays in the vault to cover open orders.`}else if(i==="withdraw-earnings"){let p=m===a.subject?a.owedSubject:m===a.quote?a.owedQuote:d(await u(e,b,V,"owed",[m],t));Q(p),I={to:b,data:Ne(m,v,String(f))},s=`Withdraw ${f} base units of ${ae(m)} from the earnings the vault owes its beneficiary (${p} owed at this block) to the beneficiary wallet ${v}. No other recipient can be chosen.`}else Q(a.accountedFree),I={to:b,data:et(v,String(f))},s=`Withdraw ${f} base units of the subject token ${a.subject} from the vault's free inventory (${a.accountedFree} free at this block; ${a.accountedReserved} reserved for open orders and not withdrawable) to the beneficiary wallet ${v}. No other recipient can be chosen.`;try{await e.call({account:v,to:I.to,data:I.data,blockNumber:t})}catch{throw new c(`Pay Later ${i} simulation failed at the named block; refresh the custody conditions.`)}return await X(e,a.block),{step:i,action:I,block:a.block,familyId:P,member:a.member,vault:b,beneficiary:v,summary:`${Fe(a)} ${s}`}}function it(e){return e.familyOwner===e.vault?e.pendingOwner===e.owner?"released, pending back to beneficiary":"in custody":e.familyOwner===e.owner?e.pendingOwner===e.vault?"transfer pending to vault":"not transferred":"family held by another owner"}async function yt(e,t,r,o){let i=Z(r,["familyId"],["familyId"]),n=await qe(e,t,i.familyId,o),l=await he(e,t,n.familyId,n.memberCount);await X(e,n.block);let m=it(n),f=n.pendingOwner===x?"no transfer is pending":`on acceptance by ${n.pendingOwner}, accrued fees are paid to the current owner ${n.familyOwner}: ${pe(l,n.pendingClaims)}`,a=`${Fe(n)} Custody: ${m}. Family owner ${n.familyOwner}; pending owner ${n.pendingOwner}; ${f}. Subject ${n.subject}, quote ${ae(n.quote)}, pool ${n.poolId}. Inventory in subject base units: ${n.accountedFree} free and withdrawable, ${n.accountedReserved} reserved for open orders. Owed to the beneficiary in base units: ${n.owedSubject} subject, ${n.owedQuote} quote. Owed to the protocol recipient ${n.protocolRecipient}: ${n.protocolOwed} quote. Next position ID ${n.nextPositionId}. Band reach ${n.custodyReachBps} bps; the vault accepts custody only at 100000 or more. The vault's accounting invariant ${n.accountingInvariant?"holds":"DOES NOT hold: its balances are below what it has accounted"}. Protocol premium share ${n.protocolShareBps} bps. Immutable terms: ${R.map(P=>`${P} ${n.terms[P]}`).join(", ")}.`;return{block:{number:String(n.block.number),hash:n.block.hash,timestamp:String(n.block.timestamp)},vault:n.vault,beneficiary:n.owner,familyId:n.familyId,member:String(n.member),memberCount:String(n.memberCount),custody:m,familyOwner:n.familyOwner,pendingOwner:n.pendingOwner,pendingClaims:String(n.pendingClaims),pendingClaimsWords:f,poolId:n.poolId,root:n.root,rules:n.rules,subject:n.subject,quote:n.quote,protocolRecipient:n.protocolRecipient,protocolShareBps:String(n.protocolShareBps),accountedFree:String(n.accountedFree),accountedReserved:String(n.accountedReserved),owedSubject:String(n.owedSubject),owedQuote:String(n.owedQuote),protocolOwed:String(n.protocolOwed),nextPositionId:String(n.nextPositionId),custodyReachBps:String(n.custodyReachBps),accountingInvariant:n.accountingInvariant,bandLiquidity:String(n.bandLiquidity),liveBandLiquidity:String(n.liquidity),bandTickLower:String(n.bandTickLower),bandTickUpper:String(n.bandTickUpper),anchorCeiling:String(n.anchorCeiling),guardPrice:String(n.guardPrice),terms:n.terms,summary:a}}export{mt as a,fe as b,Qe as c,Ce as d,Oe as e,Ye as f,Ke as g,Je as h,Xe as i,Ze as j,Ne as k,et as l,L as m,Re as n,tt as o,Ae as p,nt as q,at as r,qe as s,pt as t,yt as u};
|
|
1
|
+
import{h as Le}from"./5Y457HYC.js";import{m as le}from"./OUXPOFY2.js";import{e as Z,f as O,h as H,i as y,j as d,k as de,l as ke,m as W,o as U,p as u}from"./UMY6SP7C.js";import{b as q,i as Pe,j as ue,k as X}from"./CJMVRV34.js";import{a as c}from"./XSD5NL7J.js";import{decodeAbiParameters as Ge,decodeFunctionResult as We,encodeAbiParameters as z,encodeFunctionData as M,getAddress as D,keccak256 as N,parseAbi as _,parseAbiParameters as ze,toHex as _e,zeroAddress as x}from"viem";var mt="Pay Later requires a separate vault and family custody with beneficiary and premium terms; this launch does not create or fund that vault.",R=["premiumBps","strikeMarkupBps","tenor","priceWindowBlocks","maxBlockDepthBps","anchorDecayBlocks","topGuardBps","minOrderUnits","maxOrderUnits","maxUnitsPerBlock","maxActiveUnits","maxInventory","minPremium"],ie=[16,16,32,16,16,32,16,128,128,128,128,128,128],ye={type:"tuple",components:R.map((e,t)=>({name:e,type:`uint${ie[t]}`}))},Be=_(["function createVault(bytes32 familyId, uint8 member, (uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium) terms) returns (address vault)"]);function ee(e){let t=Z(e,R,R),r=R.map((o,i)=>O(t[o],ie[i]));if(r[0]<100n||r[0]>5000n||r[1]>5000n||r[2]<300n||r[2]>604800n||r[3]<1n||r[3]>64n||r[4]<1n||r[4]>100n||r[5]<300n||r[5]>50400n||r[6]>5000n||r[7]<1n||r[7]>r[8]||r[8]>r[9]||r[9]>r[10]||r[10]>r[11]||r[11]>10n**36n)throw new c("Pay Later terms violate the immutable economic bounds or nested inventory limits.");return Object.fromEntries(R.map((o,i)=>[o,String(r[i])]))}function $e(e){return Object.fromEntries(R.map((t,r)=>[t,ie[r]<=32?Number(e[t]):BigInt(e[t])]))}function fe(e){return z([ye],[$e(ee(e))])}function Qe(e){if(e.length!==834)throw new c("Pay Later requires exactly thirteen ABI words.");let[t]=Ge([ye],e),r=ee(Object.fromEntries(R.map(o=>[o,String(t[o])])));if(fe(r).toLowerCase()!==e.toLowerCase())throw new c("Pay Later terms are not canonical.");return r}function Ce(e,t,r){let o=H(e),i=O(t,8),n=ee(r);return M({abi:Be,functionName:"createVault",args:[o,Number(i),$e(n)]})}function Oe(e,t,r,o){let i=Qe(e);if(!/^0x[0-9a-fA-F]{40}$/.test(t)||!/^0x[0-9a-fA-F]{40}$/.test(r)||/^0x0{40}$/i.test(t)||/^0x0{40}$/i.test(r)||!Number.isInteger(o)||o<2e3||o>5e3)throw new c("Pay Later requires nonzero beneficiary and protocol recipient and a protocol share of 2000\u20135000 bps.");return`Pay Later: beneficiary ${t}, protocol recipient ${r}, protocol premium share ${o} bps. Immutable terms: ${R.map(n=>`${n} ${i[n]}`).join(", ")}. After the owner transfers the entire family and the beneficiary accepts, the vault owns the LP family through the Launcher; its LP principal cannot be removed while held by the vault. The beneficiary can start a two-step release of the family. Harvested subject-token fees become vault inventory up to maxInventory; excess subject and other-currency fees are owed to the beneficiary. The beneficiary can withdraw free inventory and earnings; reserved inventory remains in the vault to cover open orders, including after a family release. At order opening the buyer pays the quote-currency premium to the vault and its subject inventory is reserved: premium = max(ceil(strike \xD7 premiumBps / 10000), minPremium). The vault credits floor(premium \xD7 ${o} / 10000) to the protocol recipient, payable by anyone through payProtocol, and the rest to beneficiary earnings, withdrawable by the beneficiary. The buyer may exercise in a later block strictly before expiry (open timestamp plus tenor), in full or in parts, paying the cumulative pro-rata strike rounded up in quote; the vault credits the strike to beneficiary earnings and delivers the exercised subject tokens to the buyer's chosen recipient. At expiry anyone may return unexercised units to free inventory; the premium is not refunded. Token resale or profit is not guaranteed. Creation, transfer and acceptance are separate actions requiring fresh chain checks and confirmations.`}var we=_(["function transferFamily(bytes32 familyId,address newOwner,uint16 claims)","function acceptFamily(bytes32 familyId)"]),oe=_(["function acceptFamily()","function releaseFamily()","function withdrawEarnings(address currency,address to,uint256 amount)","function withdrawInventory(address to,uint128 amount)"]);function Ye(e,t,r){let o=H(e),i=y(t),n=O(r,16);if(i===x)throw new c("Pay Later vault must be nonzero.");return M({abi:we,functionName:"transferFamily",args:[o,i,Number(n)]})}function Ke(e){return M({abi:we,functionName:"transferFamily",args:[H(e),x,0]})}function Je(){return M({abi:oe,functionName:"acceptFamily"})}function Xe(){return M({abi:oe,functionName:"releaseFamily"})}function Ze(e){return M({abi:we,functionName:"acceptFamily",args:[H(e)]})}function Se(e){let t=y(e);if(t===x)throw new c("Pay Later withdrawal recipient must be nonzero.");return t}function Ne(e,t,r){return M({abi:oe,functionName:"withdrawEarnings",args:[y(e),Se(t),O(r)]})}function et(e,t){return M({abi:oe,functionName:"withdrawInventory",args:[Se(e),O(t,128)]})}var L="0xFc3e9e435C79e1712CF949C6ea921fA165cadEf3",Re="0x2f66c525278406c6261d911135b17bd618578a9bf910aff17d426e438180e050",B=_(["function launcher() view returns (address)","function registry() view returns (address)","function protocolShareBps() view returns (uint16)","function minTopGuardBps() view returns (uint16)","function minDynamicFeeSpanPips() view returns (uint24)","function bandReachBps(bytes32,uint8) view returns (uint256)","function vaultOf(bytes32,address) view returns (address)","function isVault(address) view returns (bool)"]),S=(e,t)=>String(e).toLowerCase()===String(t).toLowerCase(),ae=e=>e===x?"native ETH":e;async function je(e,t,r,o){let i=D(q.launcherV1),n=W(await u(e,i,U("launcherV1"),"position",[r,o],t)),l=W(n.key),m=y(l.currency0),f=y(l.currency1),a=y(l.hooks),P=Number(d(l.fee,24)),{tickSpacing:v}=l,{tickLower:b,tickUpper:j}=n;if(typeof v!="number"||!Number.isInteger(v)||typeof b!="number"||typeof j!="number")throw new c("Pay Later reference position is incomplete.");if(a!==D(q.rootV1))throw new c("Pay Later reference root is not the reviewed current root.");let $=N(z(ze("address,address,uint24,int24,address"),[m,f,P,v,a])),C=W(await u(e,a,U("rootV1"),"poolConfig",[$],t)),A=y(C.rules);await Pe(e,t,[i,a,A]);let g=y(await u(e,A,_(["function protocolRecipient() view returns (address)"]),"protocolRecipient",[],t));return{currency0:m,currency1:f,root:a,poolId:$,rules:A,subject:y(C.subject),quote:y(C.quote),baseLpFeePips:d(C.baseLpFeePips,24),liquidity:d(n.liquidity,128),tickLower:b,tickUpper:j,protocolRecipient:g}}async function he(e,t,r,o){let i=D(q.launcherV1);return Promise.all(Array.from({length:o},async(n,l)=>{let m=W(await u(e,i,U("launcherV1"),"position",[r,l],t)),f=W(m.key);return{member:l,currency0:y(f.currency0),currency1:y(f.currency1),liquidity:d(m.liquidity,128),tickLower:m.tickLower,tickUpper:m.tickUpper}}))}function re(e){return e.map(t=>`member ${t.member}, currencies ${t.currency0}/${t.currency1}, liquidity ${t.liquidity}, ticks ${t.tickLower}/${t.tickUpper}`).join("; ")}function pe(e,t){let r=o=>(t>>o&1)===1?"as a PoolManager claim":"as tokens";return e.map(o=>`member ${o.member}: ${ae(o.currency0)} ${r(2*o.member)}, ${ae(o.currency1)} ${r(2*o.member+1)}`).join("; ")}var xe="A PoolManager claim is a balance recorded inside the Uniswap PoolManager, not tokens in the wallet. Oak has no tool to redeem PoolManager claims.";async function tt(e,t,r,o){let i=Z(r,["familyId","member","terms","protocolRecipient","protocolShareBps"],["familyId","member","terms","protocolRecipient","protocolShareBps"]),n=y(o),l=H(i.familyId),m=Number(O(i.member,8)),f=ee(i.terms),a=y(i.protocolRecipient),P=Number(O(i.protocolShareBps,16));if(n===x||a===x||P<2e3||P>5e3)throw new c("Pay Later needs nonzero owner and protocol recipient and a protocol share of 2000\u20135000 bps.");let v=await ue(e,t),b=D(q.launcherV1),j=D(q.registry),[$,C,A,g,E,Q,I,s,p,F,se]=await Promise.all([e.getCode({address:L,blockNumber:t}),u(e,L,B,"launcher",[],t),u(e,L,B,"registry",[],t),u(e,L,B,"protocolShareBps",[],t),u(e,L,B,"minTopGuardBps",[],t),u(e,L,B,"minDynamicFeeSpanPips",[],t),u(e,L,B,"bandReachBps",[l,m],t),u(e,L,B,"vaultOf",[l,n],t),u(e,b,U("launcherV1"),"familyOwner",[l],t),u(e,b,U("launcherV1"),"pendingFamilyOwner",[l],t),u(e,b,U("launcherV1"),"memberCount",[l],t)]);if(!$||N($)!==Re||!S(C,b)||!S(A,j))throw new c("Pay Later factory runtime, launcher or registry does not match the reviewed deployment.");if(!S(p,n)||!S(s,x)||!Array.isArray(F)||!S(F[0],x))throw new c("Pay Later needs the current family owner, no existing beneficiary vault and no pending family transfer.");let Y=d(se,8);if(Y<1n||Y>8n||BigInt(m)>=Y)throw new c("Pay Later member exceeds the live family member count.");if(d(g,16)!==BigInt(P)||BigInt(f.topGuardBps)<d(E,16)||d(I)<100000n)throw new c("Pay Later protocol share, top guard floor or band reach differs from the requested listing.");let k=await je(e,t,l,m);if(k.liquidity===0n)throw new c("Pay Later reference position is incomplete or has no liquidity.");if(k.protocolRecipient!==a||BigInt(f.maxBlockDepthBps)*400n>k.baseLpFeePips)throw new c("Pay Later protocol recipient or depth share does not match the reference pool.");let K=await he(e,t,l,Number(Y)),G=Ce(l,String(m),f),w;try{let te=await e.call({account:n,to:L,data:G,blockNumber:t});if(!te.data)throw new Error("empty");w=te.data}catch{throw new c("Pay Later createVault simulation failed at the named block; listing, dynamic fee, family or custody requirements are not satisfied.")}let J=We({abi:Be,functionName:"createVault",data:w});if(J===x)throw new c("Pay Later factory predicted a zero vault.");return await X(e,v),{block:v,familyId:l,member:m,owner:n,vault:J,poolId:k.poolId,root:k.root,rules:k.rules,familyPositions:K,subject:k.subject,quote:k.quote,liquidity:k.liquidity,terms:f,protocolRecipient:a,protocolShareBps:P,minDynamicFeeSpanPips:d(Q,24),bandReachBps:d(I),summary:`${Oe(fe(f),n,a,P)} Family ${l}, member ${m}, vault ${J}. Creating the vault moves nothing. Positions that would later enter vault custody: ${re(K)}. Whether fees already accrued are paid as tokens or as PoolManager claims is chosen at the transfer step. Creation, transfer and acceptance are separate confirmations; repeat checks and simulate each immediately before signing.`}}var Ae={launcher:[3354,4191,5647,9253,9716,11135,11275,12237],poolManager:[1327,1907,2912,3967,5926,7408,9165,10771,13734,14082],root:[1139],familyId:[3315,4150,5603,8928,9654,11234,12196],member:[1212,12340],memberCount:[3267,11748],poolId:[2879,3934,5893,7375,9055,10738,13701,14049],subject:[4333,5106,7974,11416,12058,13931,14697,15021,16987],quote:[3690,6644,7850,11912,13993,14776,15260],subjectIsCurrency0:[2680,15880],beneficiary:[1772,3212,4920,5279,10829,12135],termsHash:[3016],bandLiquidity:[8995,12429,16471],bandTickLower:[5969,8866],bandTickUpper:[7077,10959],anchorCeiling:[2741,13779,14140,16409],anchorDecayBlocks:[2258,13832],topGuardBps:[3830],guardPrice:[2800,6988],protocolRecipient:[3759,11874],protocolShareBps:[6583,10900]};function nt(e,t){Le(e,17333,"0x2d650492c4352eebba37441fa43b06ca3c8c9f0aa7106c806c9f6ab44162f45b",Ae,t)}var rt=_(["function poolManager() view returns (address)","function memberCount() view returns (uint8)","function subjectIsCurrency0() view returns (bool)","function termsHash() view returns (bytes32)","function bandTickLower() view returns (int24)","function bandTickUpper() view returns (int24)","function anchorCeiling() view returns (uint256)","function anchorDecayBlocks() view returns (uint256)","function topGuardBps() view returns (uint256)","function guardPrice() view returns (uint256)","function root() view returns (address)","function poolId() view returns (bytes32)","function subject() view returns (address)","function quote() view returns (address)","function beneficiary() view returns (address)","function launcher() view returns (address)","function familyId() view returns (bytes32)","function member() view returns (uint8)","function protocolRecipient() view returns (address)","function protocolShareBps() view returns (uint256)","function bandLiquidity() view returns (uint128)","function custodyReachBps() view returns (uint256)","function terms() view returns ((uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium))"]),Ie=["poolManager","memberCount","subjectIsCurrency0","termsHash","bandTickLower","bandTickUpper","anchorCeiling","anchorDecayBlocks","topGuardBps","guardPrice","root","poolId","subject","quote","beneficiary","launcher","familyId","member","protocolRecipient","protocolShareBps","bandLiquidity","custodyReachBps","terms"],V=_(["function accountedFree() view returns (uint128)","function accountedReserved() view returns (uint128)","function owed(address) view returns (uint256)","function protocolOwed() view returns (uint256)","function nextPositionId() view returns (uint256)","function accountingInvariant() view returns (bool)"]);function at(e,t,r){if(e)return le(r);let o=le(t);return((1n<<192n)+o-1n)/o}async function qe(e,t,r,o){let i=y(o),n=H(r);if(i===x)throw new c("Pay Later custody needs the beneficiary wallet.");let l=await ue(e,t),m=D(q.launcherV1),f=U("launcherV1"),[a,P,v,b,j,$,C,A]=await Promise.all([e.getCode({address:L,blockNumber:t}),u(e,L,B,"launcher",[],t),u(e,L,B,"registry",[],t),u(e,L,B,"protocolShareBps",[],t),u(e,L,B,"vaultOf",[n,i],t),u(e,m,f,"familyOwner",[n],t),u(e,m,f,"pendingFamilyOwner",[n],t),u(e,m,f,"memberCount",[n],t)]);if(!a||N(a)!==Re||!S(P,m)||!S(v,q.registry))throw new c("Pay Later factory runtime, launcher or registry does not match the reviewed deployment.");let g=y(j);if(g===x)throw new c("This wallet has no Pay Later vault for this family; only the beneficiary that created a vault can act on it.");let[E,Q,...I]=await Promise.all([e.getCode({address:g,blockNumber:t}),u(e,L,B,"isVault",[g],t),...Ie.map(h=>u(e,g,rt,h,[],t))]);if(!E)throw new c("Pay Later vault has not been created.");let s=Object.fromEntries(Ie.map((h,T)=>[h,I[T]])),p=W(s.terms),F=ee(Object.fromEntries(R.map(h=>[h,String(p[h])]))),se=["launcher","poolManager","root","subject","quote","beneficiary","protocolRecipient"],Y=["familyId","poolId","termsHash"],k={};for(let h of Object.keys(Ae))if(se.includes(h))k[h]=z([{type:"address"}],[y(s[h])]);else if(Y.includes(h))k[h]=H(s[h]);else if(h==="subjectIsCurrency0")k[h]=z([{type:"bool"}],[de(s[h])]);else if(h==="bandTickLower"||h==="bandTickUpper"){let T=s[h];if(typeof T!="number"||!Number.isInteger(T)||T<-8388608||T>8388607)throw new c("Pay Later vault tick is invalid.");k[h]=z([{type:"int24"}],[T])}else k[h]=z([{type:"uint256"}],[d(s[h])]);if(nt(E,k),Q!==!0||y(s.beneficiary)!==i||!S(s.launcher,m)||!S(s.familyId,n))throw new c("Pay Later vault beneficiary, family or factory attestation does not match this wallet and family.");let K=Number(d(s.member,8)),G=d(A,8);if(G<1n||G>8n||BigInt(K)>=G||d(s.memberCount,8)!==G)throw new c("Pay Later vault member does not fit the live family member count.");let w=await je(e,t,n,K),[J,te,Te,He,Ue,Ve,De]=await Promise.all([u(e,g,V,"accountedFree",[],t),u(e,g,V,"accountedReserved",[],t),u(e,g,V,"owed",[w.subject],t),u(e,g,V,"owed",[w.quote],t),u(e,g,V,"protocolOwed",[],t),u(e,g,V,"nextPositionId",[],t),u(e,g,V,"accountingInvariant",[],t)]),Me=N(_e("Terms(uint16 premiumBps,uint16 strikeMarkupBps,uint32 tenor,uint16 priceWindowBlocks,uint16 maxBlockDepthBps,uint32 anchorDecayBlocks,uint16 topGuardBps,uint128 minOrderUnits,uint128 maxOrderUnits,uint128 maxUnitsPerBlock,uint128 maxActiveUnits,uint128 maxInventory,uint128 minPremium)")),Ee=N(z([{type:"bytes32"},...ye.components],[Me,...R.map((h,T)=>ie[T]<=32?Number(F[h]):BigInt(F[h]))])),ce=w.subject===w.currency0,ne=at(ce,w.tickLower,w.tickUpper),be=ne*ne/(1n<<96n)*(10000n-BigInt(F.topGuardBps))/10000n,ge=d(b,16);if(y(s.poolManager)!==D(q.poolManager)||y(s.root)!==w.root||!S(s.poolId,w.poolId)||y(s.subject)!==w.subject||y(s.quote)!==w.quote||s.subjectIsCurrency0!==ce||s.bandTickLower!==w.tickLower||s.bandTickUpper!==w.tickUpper||!S(s.termsHash,Ee)||d(s.anchorDecayBlocks)!==BigInt(F.anchorDecayBlocks)||d(s.topGuardBps)!==BigInt(F.topGuardBps)||d(s.anchorCeiling)!==ne||d(s.guardPrice)!==be||y(s.protocolRecipient)!==w.protocolRecipient||d(s.protocolShareBps)!==ge)throw new c("Pay Later vault immutables differ from the pool, band, terms or protocol recipient derived from the chain for this family.");let ve=ke(C,2);return await X(e,l),{block:l,familyId:n,owner:i,vault:g,member:K,memberCount:Number(G),poolId:w.poolId,root:w.root,rules:w.rules,subject:w.subject,quote:w.quote,subjectIsCurrency0:ce,terms:F,protocolRecipient:w.protocolRecipient,protocolShareBps:Number(ge),familyOwner:y($),pendingOwner:y(ve[0]),pendingClaims:Number(d(ve[1],16)),liquidity:w.liquidity,bandLiquidity:d(s.bandLiquidity,128),bandTickLower:w.tickLower,bandTickUpper:w.tickUpper,anchorCeiling:ne,guardPrice:be,custodyReachBps:d(s.custodyReachBps),accountedFree:d(J,128),accountedReserved:d(te,128),owedSubject:d(Te),owedQuote:d(He),protocolOwed:d(Ue),nextPositionId:d(Ve),accountingInvariant:de(De)}}var Fe=e=>`Pay Later family ${e.familyId}, reference member ${e.member}, vault ${e.vault}, beneficiary ${e.owner}.`,me={transfer:["familyId","claims"],cancel:["familyId"],accept:["familyId"],release:["familyId"],"accept-back":["familyId"],"withdraw-earnings":["familyId","currency","amount"],"withdraw-inventory":["familyId","amount"]};async function pt(e,t,r,o,i){if(i==="create"){let p=await tt(e,t,r,o);return{step:i,action:{to:L,data:Ce(p.familyId,String(p.member),p.terms)},block:p.block,familyId:p.familyId,member:p.member,vault:p.vault,beneficiary:p.owner,summary:p.summary,plan:p}}if(!Object.hasOwn(me,i))throw new c("Choose a Pay Later step: create, transfer, cancel, accept, release, accept-back, withdraw-earnings or withdraw-inventory.");let n=Z(r,me[i],me[i]),l=i==="transfer"?Number(O(n.claims,16)):0,m=i==="withdraw-earnings"?y(n.currency):x,f=i==="withdraw-earnings"?O(n.amount):i==="withdraw-inventory"?O(n.amount,128):0n,a=await qe(e,t,n.familyId,o),{familyId:P,owner:v,vault:b}=a,j=D(q.launcherV1),$=a.familyOwner===v,C=a.familyOwner===b,A=(1<<2*a.memberCount)-1,g=()=>he(e,t,P,a.memberCount),E=()=>{if(a.liquidity<a.bandLiquidity||a.custodyReachBps<100000n)throw new c("Pay Later vault custody requires the frozen band liquidity and at least 100000 bps reach.")},Q=p=>{if(f===0n||f>p)throw new c(`Pay Later ${i} amount must be above zero and at most ${p}, the amount available at the named block.`)},I,s;if(i==="transfer"){if(l>>2*a.memberCount!==0)throw new c(`Pay Later claims mask ${l} selects a member beyond the ${a.memberCount} in this family.`);if(!$||a.pendingOwner!==x)throw new c("Pay Later transfer needs this wallet to own the family with no pending transfer; cancel a pending transfer first.");E();let p=await g();I={to:j,data:Ye(P,b,String(l))},s=`Start the transfer of the entire family to the vault. Nothing moves until the separate accept step. Positions: ${re(p)}. When the vault accepts, fees already accrued are paid to this wallet, the current owner: ${pe(p,l)}. ${xe} To change this choice before acceptance, use the cancel step and start the transfer again.`}else if(i==="cancel"){if(!$)throw new c("Pay Later cancel needs this wallet to own the family.");if(a.pendingOwner===x)throw new c("Pay Later cancel found no pending family transfer to cancel.");I={to:j,data:Ke(P)},s=`Cancel the pending transfer to ${a.pendingOwner}${a.pendingOwner===b?" (the vault)":""}. The pending owner is set to the zero address, so nobody can accept it and this wallet keeps the family. A new transfer can then be started with a different choice of how accrued fees are paid.`}else if(i==="accept"){if(!$||a.pendingOwner!==b)throw new c("Pay Later accept needs this wallet to own the family and a pending transfer to the vault.");E();let p=await g();I={to:b,data:Je()},s=`Accept custody of the entire family into the vault. Positions: ${re(p)}. Fees already accrued are paid to this wallet, the previous owner, as set when the transfer was started: ${pe(p,a.pendingClaims)}. ${xe} ${Oe(fe(a.terms),v,a.protocolRecipient,a.protocolShareBps)}`}else if(i==="release"){if(!C)throw new c("Pay Later release needs the vault to own the family.");if(a.pendingOwner!==x)throw new c("Pay Later release is already pending back to the beneficiary; the next step is accept-back.");I={to:b,data:Xe()},s=`Release the family from vault custody. This starts a two-step hand-back to the beneficiary ${v} with every fee-claim bit set (mask ${A}). The vault still owns the family until the next step, accept-back, is sent by this wallet; reserved inventory stays in the vault to cover open orders (${a.accountedReserved} subject base units reserved at this block). Free inventory and earnings remain withdrawable by the beneficiary.`}else if(i==="accept-back"){if(!C||a.pendingOwner!==v||a.pendingClaims!==A)throw new c("Pay Later accept-back needs the vault to own the family and the released family pending back to this wallet with every fee-claim bit set.");let p=await g();I={to:j,data:Ze(P)},s=`Accept the released family back from the vault: this wallet becomes the owner of every family position again. Positions: ${re(p)}. Fees accrued at acceptance are paid to the previous owner, which is the vault ${b}, as PoolManager claims. They are not paid to this wallet; the vault's redeemClaims, which anyone may call, turns them into vault inventory or beneficiary earnings. Oak has no tool to redeem PoolManager claims. Reserved inventory (${a.accountedReserved} subject base units) stays in the vault to cover open orders.`}else if(i==="withdraw-earnings"){let p=m===a.subject?a.owedSubject:m===a.quote?a.owedQuote:d(await u(e,b,V,"owed",[m],t));Q(p),I={to:b,data:Ne(m,v,String(f))},s=`Withdraw ${f} base units of ${ae(m)} from the earnings the vault owes its beneficiary (${p} owed at this block) to the beneficiary wallet ${v}. No other recipient can be chosen.`}else Q(a.accountedFree),I={to:b,data:et(v,String(f))},s=`Withdraw ${f} base units of the subject token ${a.subject} from the vault's free inventory (${a.accountedFree} free at this block; ${a.accountedReserved} reserved for open orders and not withdrawable) to the beneficiary wallet ${v}. No other recipient can be chosen.`;try{await e.call({account:v,to:I.to,data:I.data,blockNumber:t})}catch{throw new c(`Pay Later ${i} simulation failed at the named block; refresh the custody conditions.`)}return await X(e,a.block),{step:i,action:I,block:a.block,familyId:P,member:a.member,vault:b,beneficiary:v,summary:`${Fe(a)} ${s}`}}function it(e){return e.familyOwner===e.vault?e.pendingOwner===e.owner?"released, pending back to beneficiary":"in custody":e.familyOwner===e.owner?e.pendingOwner===e.vault?"transfer pending to vault":"not transferred":"family held by another owner"}async function yt(e,t,r,o){let i=Z(r,["familyId"],["familyId"]),n=await qe(e,t,i.familyId,o),l=await he(e,t,n.familyId,n.memberCount);await X(e,n.block);let m=it(n),f=n.pendingOwner===x?"no transfer is pending":`on acceptance by ${n.pendingOwner}, accrued fees are paid to the current owner ${n.familyOwner}: ${pe(l,n.pendingClaims)}`,a=`${Fe(n)} Custody: ${m}. Family owner ${n.familyOwner}; pending owner ${n.pendingOwner}; ${f}. Subject ${n.subject}, quote ${ae(n.quote)}, pool ${n.poolId}. Inventory in subject base units: ${n.accountedFree} free and withdrawable, ${n.accountedReserved} reserved for open orders. Owed to the beneficiary in base units: ${n.owedSubject} subject, ${n.owedQuote} quote. Owed to the protocol recipient ${n.protocolRecipient}: ${n.protocolOwed} quote. Next position ID ${n.nextPositionId}. Band reach ${n.custodyReachBps} bps; the vault accepts custody only at 100000 or more. The vault's accounting invariant ${n.accountingInvariant?"holds":"DOES NOT hold: its balances are below what it has accounted"}. Protocol premium share ${n.protocolShareBps} bps. Immutable terms: ${R.map(P=>`${P} ${n.terms[P]}`).join(", ")}.`;return{block:{number:String(n.block.number),hash:n.block.hash,timestamp:String(n.block.timestamp)},vault:n.vault,beneficiary:n.owner,familyId:n.familyId,member:String(n.member),memberCount:String(n.memberCount),custody:m,familyOwner:n.familyOwner,pendingOwner:n.pendingOwner,pendingClaims:String(n.pendingClaims),pendingClaimsWords:f,poolId:n.poolId,root:n.root,rules:n.rules,subject:n.subject,quote:n.quote,protocolRecipient:n.protocolRecipient,protocolShareBps:String(n.protocolShareBps),accountedFree:String(n.accountedFree),accountedReserved:String(n.accountedReserved),owedSubject:String(n.owedSubject),owedQuote:String(n.owedQuote),protocolOwed:String(n.protocolOwed),nextPositionId:String(n.nextPositionId),custodyReachBps:String(n.custodyReachBps),accountingInvariant:n.accountingInvariant,bandLiquidity:String(n.bandLiquidity),liveBandLiquidity:String(n.liquidity),bandTickLower:String(n.bandTickLower),bandTickUpper:String(n.bandTickUpper),anchorCeiling:String(n.anchorCeiling),guardPrice:String(n.guardPrice),terms:n.terms,summary:a}}export{mt as a,fe as b,Qe as c,Ce as d,Oe as e,Ye as f,Ke as g,Je as h,Xe as i,Ze as j,Ne as k,et as l,L as m,Re as n,tt as o,Ae as p,nt as q,at as r,qe as s,pt as t,yt as u};
|