@oakagentkit/core 0.3.4 → 0.3.5
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/actions.d.ts +13 -1
- package/build/dist/api/modules/chop/actions.js +1 -1
- package/build/dist/api/modules/chop/checks.js +1 -1
- package/build/dist/api/modules/chop/copy.d.ts +1 -0
- package/build/dist/api/modules/chop/copy.js +1 -1
- package/build/dist/api/modules/chop/display.d.ts +36 -0
- package/build/dist/api/modules/chop/display.js +1 -0
- package/build/dist/api/modules/chop/guard.js +1 -1
- package/build/dist/api/modules/chop/index.js +1 -1
- package/build/dist/api/modules/chop/pins.d.ts +1 -0
- package/build/dist/api/modules/chop/pins.js +1 -1
- package/build/dist/api/modules/chop/positions.js +1 -1
- package/build/dist/api/modules/chop/reader.d.ts +6 -1
- package/build/dist/api/modules/chop/reader.js +1 -1
- package/build/dist/api/modules/chop/types.d.ts +7 -0
- package/build/dist/api/modules/chop/unfarm.d.ts +16 -0
- package/build/dist/api/modules/chop/unfarm.js +1 -0
- package/build/dist/api/modules/clanker/index.js +1 -1
- package/build/dist/api/modules/earn/index.js +1 -1
- package/build/dist/api/modules/erc8004/index.js +1 -1
- package/build/dist/api/modules/factor/actions.js +1 -1
- package/build/dist/api/modules/factor/api.js +1 -1
- package/build/dist/api/modules/factor/checks.js +1 -1
- package/build/dist/api/modules/factor/copy.d.ts +11 -11
- package/build/dist/api/modules/factor/copy.js +1 -1
- package/build/dist/api/modules/factor/guard.js +1 -1
- package/build/dist/api/modules/factor/index.js +1 -1
- package/build/dist/api/modules/factor/reader.js +1 -1
- package/build/dist/api/modules/fobo/client.js +1 -1
- package/build/dist/api/modules/fobo/index.js +1 -1
- package/build/dist/api/modules/gloam/index.js +1 -1
- package/build/dist/api/modules/grove/index.js +1 -1
- package/build/dist/api/modules/heyresearch/builder-feed.js +1 -1
- package/build/dist/api/modules/heyresearch/index.js +1 -1
- package/build/dist/api/modules/heyresearch/public-reads.js +1 -1
- package/build/dist/api/modules/heyresearch/scan.js +1 -1
- package/build/dist/api/modules/heyresearch/token-facts.js +1 -1
- package/build/dist/api/modules/hoodlock/airdrop.js +1 -1
- package/build/dist/api/modules/hoodlock/fee.js +1 -1
- package/build/dist/api/modules/hoodlock/guard.js +1 -1
- package/build/dist/api/modules/hoodlock/index.js +1 -1
- package/build/dist/api/modules/hoodlock/lifecycle.js +1 -1
- package/build/dist/api/modules/hoodlock/locks-burn.js +1 -1
- package/build/dist/api/modules/hoodlock/public.js +1 -1
- package/build/dist/api/modules/hookr/actions.js +1 -1
- package/build/dist/api/modules/hookr/create-cancel.js +1 -1
- package/build/dist/api/modules/hookr/discovery.js +1 -1
- package/build/dist/api/modules/hookr/fill-bounty.js +1 -1
- package/build/dist/api/modules/hookr/index.js +1 -1
- package/build/dist/api/modules/hookr/launch-receipt.js +1 -1
- package/build/dist/api/modules/hookr/launch.js +1 -1
- package/build/dist/api/modules/hookr/liquidity.js +1 -1
- package/build/dist/api/modules/hookr/lp-positions.js +1 -1
- package/build/dist/api/modules/hookr/lp-reads.js +1 -1
- package/build/dist/api/modules/hookr/lp-receipt.js +1 -1
- package/build/dist/api/modules/hookr/lp-state.js +1 -1
- package/build/dist/api/modules/hookr/public-reads.js +1 -1
- package/build/dist/api/modules/hookr/relay.js +1 -1
- package/build/dist/api/modules/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/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/pons/index.js +1 -1
- package/build/dist/api/modules/priors/coverage.js +1 -1
- package/build/dist/api/modules/priors/discovery.js +1 -1
- package/build/dist/api/modules/priors/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/relay/outbound-status.js +1 -1
- package/build/dist/api/modules/spark/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/upoch/index.js +1 -1
- package/build/dist/api/modules/upoch/reads.js +1 -1
- package/build/dist/api/modules/wormhole/index.js +1 -1
- package/build/dist/api/prices.d.ts +5 -0
- package/build/dist/api/prices.js +1 -1
- package/build/dist/api/send.js +1 -1
- package/build/dist/api/signing-registry.js +1 -1
- package/build/dist/api/tokens.d.ts +1 -0
- package/build/dist/api/tokens.js +1 -1
- package/build/dist/api/usd-estimate.d.ts +2 -0
- package/build/dist/api/usd-estimate.js +1 -1
- package/build/dist/chunks/{UBVE2U6X.js → 2FOI2625.js} +1 -1
- package/build/dist/chunks/{5OTQCE2E.js → 2I7XHRTI.js} +1 -1
- package/build/dist/chunks/{SGHSCK22.js → 2PS4GCOZ.js} +1 -1
- package/build/dist/chunks/3BQ5XHDJ.js +1 -0
- package/build/dist/chunks/{PRBIC3UK.js → 3YH5B5NQ.js} +1 -1
- package/build/dist/chunks/{RUSXMQSJ.js → 4HQEJHCD.js} +1 -1
- package/build/dist/chunks/{ZFRTBBIW.js → 4IOHSX3Z.js} +1 -1
- package/build/dist/chunks/5H7NVE6O.js +1 -0
- package/build/dist/chunks/{JJGZ7W3V.js → 6AS3TGOX.js} +1 -1
- package/build/dist/chunks/{RK3PPFRX.js → 6CKCZJ3F.js} +1 -1
- package/build/dist/chunks/{HU2JXDLH.js → 6LVHN33V.js} +1 -1
- package/build/dist/chunks/7OOCAZBE.js +1 -0
- package/build/dist/chunks/{O3XWE4FO.js → 7TRO6MBQ.js} +1 -1
- package/build/dist/chunks/{WX7OYCNS.js → A4FLWHLP.js} +1 -1
- package/build/dist/chunks/{FP7DHVK2.js → A4K5GXVO.js} +1 -1
- package/build/dist/chunks/{AOX6DKYU.js → AL6UXNGH.js} +1 -1
- package/build/dist/chunks/{FQTO7VJG.js → C57DITTF.js} +1 -1
- package/build/dist/chunks/{ZTX4WT62.js → CFPJDLTZ.js} +1 -1
- package/build/dist/chunks/{SRHVSNPX.js → CNDIAF3P.js} +1 -1
- package/build/dist/chunks/{LEHBRAZX.js → CW37EGPL.js} +1 -1
- package/build/dist/chunks/{PQG3ULRT.js → DBOGRUPS.js} +1 -1
- package/build/dist/chunks/{T3QEN3S6.js → E47UYYK4.js} +1 -1
- package/build/dist/chunks/EPOIAXCV.js +3 -0
- package/build/dist/chunks/{DWQJ7NSX.js → FCVH4FYH.js} +1 -1
- package/build/dist/chunks/{V6EVQWAL.js → FHB7QYJO.js} +1 -1
- package/build/dist/chunks/FRT6AC6M.js +1 -0
- package/build/dist/chunks/{Z5YI6KLN.js → FRVCSDKU.js} +1 -1
- package/build/dist/chunks/{EIE2U4OX.js → G5AMH4IP.js} +1 -1
- package/build/dist/chunks/{EQEMI54U.js → GDUKZYE2.js} +1 -1
- package/build/dist/chunks/{GNOHIL4Q.js → GKUPC4DO.js} +1 -1
- package/build/dist/chunks/{K7HTDKAT.js → GMMTHTCP.js} +1 -1
- package/build/dist/chunks/{XHFAF5PZ.js → HDBZZOHJ.js} +1 -1
- package/build/dist/chunks/{Q4HSQL65.js → HPS4KOU4.js} +1 -1
- package/build/dist/chunks/IZP3EKKS.js +1 -0
- package/build/dist/chunks/{P6MPKIU2.js → J7OZLXSG.js} +1 -1
- package/build/dist/chunks/{PXUML7HJ.js → JDHPMS7X.js} +1 -1
- package/build/dist/chunks/{MOZBDCVV.js → JJSCDDQO.js} +1 -1
- package/build/dist/chunks/{EFESPGA2.js → KCZUJ57H.js} +1 -1
- package/build/dist/chunks/{2ILYVUFA.js → KKTOBXIT.js} +1 -1
- package/build/dist/chunks/{L6CVMDWQ.js → KO7ANIKY.js} +1 -1
- package/build/dist/chunks/{2T6O77QZ.js → LKUZAJPZ.js} +1 -1
- package/build/dist/chunks/{5GQJVKVY.js → LZM3DO5Q.js} +1 -1
- package/build/dist/chunks/M6JNGU4E.js +1 -0
- package/build/dist/chunks/{MEB727X5.js → M7OVMIIE.js} +1 -1
- package/build/dist/chunks/{RKM62HC5.js → MJGEGNDU.js} +1 -1
- package/build/dist/chunks/{SYERFEJ4.js → MQXSCNUL.js} +1 -1
- package/build/dist/chunks/N624NR7Y.js +1 -0
- package/build/dist/chunks/{X3YEDVRN.js → N65J3L2H.js} +1 -1
- package/build/dist/chunks/{2TX7HP6M.js → N742W5KX.js} +1 -1
- package/build/dist/chunks/{365B4YEV.js → NIWAVMDR.js} +1 -1
- package/build/dist/chunks/O2QBSINK.js +1 -0
- package/build/dist/chunks/{FA3GBXQP.js → O4P5IQCP.js} +1 -1
- package/build/dist/chunks/{HUKDISRE.js → OB3YMTDI.js} +1 -1
- package/build/dist/chunks/{WXZ4LAKO.js → PV7FEVBD.js} +1 -1
- package/build/dist/chunks/{4M6XBG6X.js → Q3Q3YHEX.js} +1 -1
- package/build/dist/chunks/QA6Z2CYP.js +2 -0
- package/build/dist/chunks/{BDLV42SD.js → QBNASL3T.js} +1 -1
- package/build/dist/chunks/{AHUCYDBC.js → QKIQ7ZKD.js} +1 -1
- package/build/dist/chunks/{7FYM7FJA.js → QMIH6HXH.js} +1 -1
- package/build/dist/chunks/{2QP6WGKZ.js → QQD4PV64.js} +1 -1
- package/build/dist/chunks/{KNBNKG7P.js → R66NSNNQ.js} +1 -1
- package/build/dist/chunks/{VQJXQLFW.js → RP5VCG54.js} +1 -1
- package/build/dist/chunks/{OKXKDDBX.js → RUHNLNVX.js} +1 -1
- package/build/dist/chunks/{VKNKVUAA.js → S37D7HOK.js} +1 -1
- package/build/dist/chunks/S47M3IPR.js +1 -0
- package/build/dist/chunks/S65KXMZ7.js +3 -0
- package/build/dist/chunks/{NYHKIXJR.js → SX5YNFHG.js} +1 -1
- package/build/dist/chunks/{MHONMLF6.js → TGXEKBLV.js} +1 -1
- package/build/dist/chunks/{VHK5AYC2.js → TJU644I7.js} +1 -1
- package/build/dist/chunks/{O56EZB5Y.js → TOIKOIY6.js} +1 -1
- package/build/dist/chunks/{YR44GQG4.js → TZ7S5KRB.js} +1 -1
- package/build/dist/chunks/UEOS6SHR.js +1 -0
- package/build/dist/chunks/{USZCTSPI.js → USGMGKAG.js} +1 -1
- package/build/dist/chunks/{W5FM2OVB.js → UUF4Z6K6.js} +1 -1
- package/build/dist/chunks/{PMFR47H3.js → VREGY7E6.js} +1 -1
- package/build/dist/chunks/{2YYKQGJZ.js → W7BFM6CK.js} +1 -1
- package/build/dist/chunks/{3D7FXI6G.js → WQ2XTDHO.js} +1 -1
- package/build/dist/chunks/WRA3ZC6W.js +1 -0
- package/build/dist/chunks/{K3TZYPSV.js → XADHV2DT.js} +1 -1
- package/build/dist/chunks/{LVFI74ST.js → XNJ6NDQQ.js} +1 -1
- package/build/dist/chunks/{DD47RZFU.js → XTXXWRN2.js} +1 -1
- package/build/dist/chunks/{CZ66MYKR.js → XWC6IC5E.js} +1 -1
- package/build/dist/chunks/{DMB64UIN.js → YWVPK3DV.js} +1 -1
- package/build/dist/chunks/{WNWRF4HE.js → YZHJ4BAP.js} +1 -1
- package/build/dist/chunks/{4PB6MSGZ.js → ZKBOPZH5.js} +1 -1
- package/build/dist/chunks/{5ZVIAGLX.js → ZQPC54J5.js} +1 -1
- package/build/dist/chunks/{HDBDBKEA.js → ZVY7GGSP.js} +1 -1
- package/build/dist/chunks/{LQSPWRHN.js → ZX43P4BK.js} +1 -1
- package/build/dist/chunks/{PQOWIRKQ.js → ZXFJKW6H.js} +1 -1
- package/build/dist/chunks/{N6PHSHBE.js → ZXRIJG6H.js} +1 -1
- package/package.json +1 -1
- package/build/dist/chunks/3AOTYJPX.js +0 -1
- package/build/dist/chunks/4E7FJQLL.js +0 -1
- package/build/dist/chunks/4J245N3F.js +0 -1
- package/build/dist/chunks/BA66J5YQ.js +0 -1
- package/build/dist/chunks/BIY2F6MO.js +0 -1
- package/build/dist/chunks/DGCJZ3HO.js +0 -1
- package/build/dist/chunks/DHX3Q5RV.js +0 -2
- package/build/dist/chunks/EFUACKDK.js +0 -1
- package/build/dist/chunks/JW7GLNLB.js +0 -3
- package/build/dist/chunks/MIKQWF6Q.js +0 -3
- package/build/dist/chunks/P7C3TYI4.js +0 -1
- package/build/dist/chunks/ZNX3YVF2.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as H}from"./HOEQVPY7.js";import{f as h}from"./GQ3XZFRL.js";import{a as E}from"./SCG5HWMN.js";import{a as m}from"./XSD5NL7J.js";var O="https://heyresearch.xyz/api/v1/scan",T=2500,D=6e4,S=64,L=32768,x=/^0x[0-9a-fA-F]{40}$/,$=/[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/u;function R(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var f=class extends m{};function j(e,t){return e===401||e===403?new f(`HEY Research Lab refused access (HTTP ${e}). Ask the Oak operator to check HEY access and allowance.`):(e===400||e===422)&&(/^\/api\/v1\/(?:scan|builder)\?/.test(t)||t.startsWith("/api/agent/research_project?address="))?new f(`HEY Research Lab rejected this token identity on chain 4663 (HTTP ${e}). Check the token contract address.`):new f(`HEY Research Lab rejected the request (HTTP ${e}). Check the project, token address and selectors.`)}var z=/\.(?:localhost|local|localdomain|internal|intranet|lan|home|corp|private|home\.arpa)$/;function P(e){let t=e.toLowerCase().replace(/\.$/,"");return!t||t.startsWith("[")||/^[\d.]+$/.test(t)||!t.includes(".")||t==="localhost"||z.test(t)?!1:/^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/.test(t)&&/[a-z]/.test(t.slice(t.lastIndexOf(".")+1))}function A(e,t=!1){if(typeof e!="string"||e.length>2048||/[\s<>\\]/.test(e)||$.test(e))return!1;try{let r=new URL(e);return r.protocol==="https:"&&!r.username&&!r.password&&(t?r.origin==="https://heyresearch.xyz"&&r.pathname.startsWith("/project/"):P(r.hostname))}catch{return!1}}function I(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number.isFinite(Date.parse(e))&&new Date(e).toISOString().slice(0,10)===e&&e<=new Date(Date.now()+864e5).toISOString().slice(0,10)}function Y(e){if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/.test(e))return!1;let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,19)===e.slice(0,19)&&t<=Date.now()+3e5}function v(e,t,r){if(t!==4663||!x.test(r)||!R(e)||e.chainId!==t||typeof e.contractAddress!="string"||e.contractAddress.toLowerCase()!==r.toLowerCase())return;let a={chainId:4663,contractAddress:e.contractAddress};if(e.found===!1)return Object.freeze({found:!1,...a});if(e.found!==!0||!h(e.status_label,80)||!h(e.status_help,300)||typeof e.verified_builder!="boolean"||typeof e.activity_applies_to_token!="boolean"||typeof e.token_verification!="string"||!/^[A-Z][A-Z_]{0,63}$/.test(e.token_verification)||!A(e.project_link,!0)||!R(e.activity))return;let s=e.activity.last_ship,o=e.activity.last_ship_url;if(s!=null&&!I(s)||o!=null&&!A(o))return;let i=e.as_of;if(!(i!==void 0&&!Y(i))&&s!=null==(o!=null))return Object.freeze({found:!0,...a,status_label:e.status_label,status_help:e.status_help,verified_builder:e.verified_builder,token_verification:e.token_verification,activity_applies_to_token:e.activity_applies_to_token,project_link:e.project_link,...i===void 0?{}:{as_of:i},activity:Object.freeze({last_ship:s??null,last_ship_url:o??null})})}async function N(e,t){if(!e.ok||!e.body)throw new Error("HEY unavailable");let r=e.body.getReader(),a=()=>{r.cancel().catch(()=>{})};t.addEventListener("abort",a,{once:!0}),t.aborted&&a();let s=new TextDecoder("utf-8",{fatal:!0}),o="",i=0;try{for(;;){let{done:c,value:d}=await r.read();if(c)break;if(i+=d.byteLength,i>L)throw new Error("HEY response too large");o+=s.decode(d,{stream:!0})}return JSON.parse(o+s.decode())}finally{t.removeEventListener("abort",a),a()}}function U(e,t=fetch){if(!/^[0-9A-Za-z.+-]{1,64}$/.test(e))throw new Error("Invalid integration version");let r=new Map,a=new Map,s=H();return async(o,i)=>{if(o!==4663||!x.test(i)||/^0x(?:0{40}|e{40})$/i.test(i))return{status:"unavailable"};if(s.blocked())return{status:"unavailable"};let c=`${o}:${i.toLowerCase()}`,d=r.get(c);if(d&&d.expires>Date.now())return d.result;r.delete(c);let _=a.get(c);if(_)return _;if(a.size>=S)return{status:"unavailable"};let b=(async()=>{let p=new AbortController,w;try{let u=new Promise((l,n)=>{w=setTimeout(()=>{s.defer(null),p.abort(),n(new Error("HEY deadline"))},T)}),C=(async()=>{let l=new URL(O);l.searchParams.set("chain",String(o)),l.searchParams.set("token",i);let n;try{n=await t(l,{method:"GET",headers:{"x-hey-integration":`oak-agent-kit/${e}`},signal:p.signal,credentials:"omit",redirect:"error",referrerPolicy:"no-referrer"})}catch(y){if(y instanceof E)n=y.response;else throw s.defer(null),y}if(n.status===429||n.status>=500)throw s.defer(n.headers.get("retry-after")),n.body?.cancel().catch(()=>{}),new Error("HEY unavailable");if(n.status>=400&&n.status<500)throw n.body?.cancel().catch(()=>{}),j(n.status,"/api/v1/scan?");let k=v(await N(n,p.signal),o,i);if(!k)throw new Error("Invalid HEY response");return Object.freeze({status:"ok",card:k})})(),g=await Promise.race([C,u]);for(let[l,n]of r)n.expires<=Date.now()&&r.delete(l);return r.size>=S&&r.delete(r.keys().next().value),r.set(c,{expires:Date.now()+D,result:g}),g}catch(u){if(u instanceof f)throw u;return{status:"unavailable"}}finally{clearTimeout(w)}})();a.set(c,b);try{return await b}finally{a.delete(c)}}}export{j as a,v as b,U as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as g,j as k}from"./
|
|
1
|
+
import{i as g,j as k}from"./HDBZZOHJ.js";import{d as p,f}from"./O4P5IQCP.js";import{q as m}from"./PV7FEVBD.js";import{c as u,f as h}from"./MI5HZDMH.js";import{a as d}from"./SPJCSEKP.js";import{g as l}from"./NWNYJ26T.js";import{a as i}from"./XSD5NL7J.js";var w=["hoodlock_lock","hoodlock_burn","hoodlock_airdrop_create","hoodlock_airdrop_claim",...p,...u];async function H(e,r,t,s){if(!w.includes(e))throw new i("Unknown HoodLock action; nothing was signed.");let o=async()=>{throw new i("HoodLock does not require a swap for this action.")},n=d({clientFor:()=>s,http:fetch,preview:async a=>({txs:a,changes:[],summary:"Locally reconstructed HoodLock intent."}),quoteSwap:o,buildSwap:o}),c=await[g(n),k(n),...m(n).tools,...f(n).tools,...h(n).tools].find(a=>a.name===e).execute(r,t);if(!Array.isArray(c.txs)||c.txs.length===0)throw new i("HoodLock action has no transactions; use the read route.");return c.txs.map(a=>({...a}))}function I(e,r){if(!r.length||e.length!==r.length||e.some((t,s)=>{let o=r[s];return t.chainId!==o.chainId||!l(t.to,o.to)||!l(t.data,o.data)||t.value!==o.value}))throw new i("HoodLock transaction differs from the locally reconstructed request; nothing was signed.")}export{w as a,H as b,I as c};
|
|
@@ -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"./MQXSCNUL.js";import{c as _,d as S}from"./N624NR7Y.js";import{g as h}from"./NWNYJ26T.js";import{b as f}from"./TI727O2H.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as p,c as s}from"./
|
|
1
|
+
import{a as p,c as s}from"./EPOIAXCV.js";import{a}from"./SPJCSEKP.js";import{b as i}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";async function u(e,n,t){if(!Object.prototype.hasOwnProperty.call(p,e.name))throw new o("Local Chop guard cannot rebuild this action; nothing was signed.");if(e.chainId!==void 0&&e.chainId!==i)throw new o("Local Chop guard requires chain 4663; nothing was signed.");let r=async()=>{throw new o("Local Chop guard does not use HTTP, swaps or a preview service.")},d=a({clientFor:c=>{if(c!==i)throw new o("Local Chop guard requires chain 4663; nothing was signed.");return t.client},http:r,quoteSwap:r,buildSwap:r,preview:r});return(await s(d,e.name,e.args,n)).built}function g(e){return(n,t)=>u(n,t,e)}export{u as a,g as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as q,o as U}from"./GYPMUYB5.js";import{a as le}from"./ELHRXA5U.js";import{a as pe,b as fe}from"./DGDMRATN.js";import{a as ye}from"./4Z3IGMU6.js";import{a as J,b as ue,c as me}from"./C76D54YG.js";import{e as F,h as L,m as ce}from"./TXGZ6NWN.js";import{b as ae}from"./SPJCSEKP.js";import{a as E}from"./IOYRL6AY.js";import{c as de}from"./SCG5HWMN.js";import{c as O,e as A,g as w,k as ie,l as oe,m as re,n as se}from"./NWNYJ26T.js";import{b as h,j as te}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ce,encodeAbiParameters as j,encodeFunctionData as D,erc20Abi as V,isAddress as Ie,parseAbi as xe,parseAbiParameters as W,toHex as z,zeroAddress as Z}from"viem";var x=te[h].clanker,he=xe(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=xe(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),P={address:x.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},ve="https://www.clanker.world/api/tokens",be={type:"string",pattern:"^\\d+$"},ge={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function C(e){return oe(ie(e,F),F)}function ke(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r(`Provide an explicit bytes32 ${t}.`);return e}function I(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new r(`Provide ${t} as text.`);return e}function G(e,t=256){return se(e,`Amount exceeds the uint${t} range.`,{bits:t})}function K(e){return re(e,"The contract returned an invalid amount.").toString()}function B(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new r(`Unsupported Clanker input: ${s}.`)}function we(e,t){return t.changes.map(({token:s,amount:u})=>{let g=u.startsWith("-");return`${g?"-":"+"}${e.formatAmount(g?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function Se(e){return A(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>A(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Ie(t[s],{strict:!1})))}function Q(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>Q(s,t+1)):A(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,Q(u,t+1)])):null}function _e(e){return{...Q(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!A(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new r("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){B(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new r("Choose an indexer limit from 1 to 20.");let u=new URL(ve);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",I(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",I(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",C(t.deployer));let g=await de(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Se);return{tokens:g.data.filter(v=>v.chain_id===h&&w(v.factory_address,x.factory.address)),total:g.total,cursor:g.cursor||null,tokensDeployed:g.tokensDeployed}}var Oe=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(i){throw new r(e.plainError(i))}},u=(n,i,a,c="0")=>e.unsignedTx({to:n,data:i,value:c,chainId:h,description:a}),g=async(n,i)=>K(await t().readContract({address:x.fee_locker.address,abi:T,functionName:"availableFees",args:[n,i]})),v=async n=>{if(w(n,P.address))return P;let[i,a]=await Promise.all([t().readContract({address:n,abi:V,functionName:"symbol"}),t().readContract({address:n,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(a)||a<0||a>255)throw new r("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:i,decimals:a}},X=async n=>{n.cursor!==void 0&&$e(n.cursor);let i=await Ne(e,n);return{...i,tokens:i.tokens.map(_e)}},Ae=async(n,i)=>{if(B(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new r("Clanker launches use vanity false and an explicit salt.");let a=I(n.name,"token name",!0),c=I(n.symbol,"token symbol",!0),b=ke(n.salt,"salt"),y=G(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new r("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let o=n.minAmountOut===void 0?void 0:G(n.minAmountOut,128);if(o!==void 0&&o<=1n)throw new r("Initial-buy minimum must exceed one base unit.");if(!y&&o!==void 0)throw new r("A minimum requires a positive initial buy.");let m=ue(n,i);L(n.feeBps??100,0,1e3);let p=fe(n);if(y&&!w(p.poolConfig.pairedToken,P.address))throw new r("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new r("Provide one to seven reward allocations.");let k=d.map(f=>{if(!A(f))throw new r("Provide reward allocations as objects.");return B(f,["admin","recipient","bps","feePreference"]),{admin:C(f.admin),recipient:C(f.recipient),bps:L(f.bps,1,1e4),feePreference:L(f.feePreference??0,0,2)}});if(k.reduce((f,S)=>f+S.bps,0)!==1e4)throw new r("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:i,name:a,symbol:c,salt:b,image:I(n.image,"image"),metadata:I(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):I(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:p.poolConfig,lockerConfig:{locker:x.locker.address,rewardAdmins:k.map(f=>f.admin),rewardRecipients:k.map(f=>f.recipient),rewardBps:k.map(f=>f.bps),tickLower:p.tickLower,tickUpper:p.tickUpper,positionBps:p.positionBps,lockerData:j(W("(uint8[])"),[[k.map(f=>f.feePreference)]])},mevModuleConfig:{mevModule:x.mev_module.address,mevModuleData:j(W("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Pe=await t().simulateContract({address:x.factory.address,abi:he,functionName:"deployToken",args:[_],account:i,value:0n,gas:E}),M=C(Pe.result),Y=f=>{let S=[...m,...y?[{extension:x.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(W("(address,address,uint24,int24,address),uint128,address"),[[Z,Z,0,0,Z],f,i])}]:[]];return u(x.factory.address,D({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:S}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&o===void 0){let S=(await e.preview([Y(0n)],i)).changes.filter($=>$.token.chainId===h&&w($.token.address,M)&&$.token.decimals===18).reduce(($,ne)=>$+(/^-?\d+$/.test(ne.amount)?BigInt(ne.amount):(()=>{throw new r("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new r("Initial-buy simulation returned no token output.");if(o=G(U(S.toString(),l),128),o<=1n)throw new r("Initial-buy output is too small for a protected minimum.")}let ee=[Y(o??0n)],H=await e.preview(ee,i);return{txs:ee,preview:H,predictedToken:M,token:{address:M,chainId:h,symbol:c,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${c} at ${M} (CREATE2 address predicted from simulation); vanity false; salt ${b}. Supply 100000000000000000000000000000 base units (18 decimals). ${p.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(p)}. Reward allocations: ${JSON.stringify(k)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${we(e,H)}`}},Te=async(n,i)=>{if(B(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new r("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new r("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new r("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new r("A pool ID requires its Clanker token.");let a=[P],c=[];if(n.token!==void 0){let o=C(n.token);if(w(o,P.address))throw new r("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await ce(e,o),{poolId:p,hook:d,locker:k}=m;if(n.poolId!==void 0&&!w(ke(n.poolId,"pool ID for fee collection"),p))throw new r("The supplied pool ID does not match the onchain Clanker pool.");w(m.pairedToken,P.address)||a.splice(0,1,await v(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[p]});if(typeof _!="boolean")throw new r("The hook returned an invalid MEV guard state.");_&&c.push(u(d,D({abi:T,functionName:"mevModuleOperational",args:[p]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(k,D({abi:T,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}a.push(await v(o))}let b;if(c.length){if(await t().getChainId()!==h)throw new r("Fee simulation endpoint is on the wrong chain.");let o=[...c.map(d=>({from:i,gas:z(E),to:d.to,data:d.data,value:z(BigInt(d.value))})),...a.map(d=>({from:i,gas:z(E),to:x.fee_locker.address,data:D({abi:T,functionName:"availableFees",args:[i,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!A(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==o.length)throw new r("The endpoint returned an unexpected fee simulation response.");let p=m[0].calls;if(!p.every(d=>A(d)&&d.status==="0x1"&&!d.error))throw new r("Clanker fee collection simulation failed.");b=p.slice(c.length).map(d=>{if(!A(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new r("The endpoint returned an invalid fee balance.");return K(Ce({abi:T,functionName:"availableFees",data:d.returnData}))})}else b=await Promise.all(a.map(o=>g(i,o.address)));let y=a.flatMap((o,m)=>BigInt(b[m])>0n?[{token:o,amount:b[m]}]:[]);if(!y.length)throw new r("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of y)c.push(u(x.fee_locker.address,D({abi:T,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let l=await e.preview(c,i);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${we(e,l)}`}},R=(n,i,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:i,required:a,additionalProperties:!1},execute:(b,y)=>s(async()=>c(b,C(y)))});return{tools:[R("launch",{name:{type:"string",description:"Token name, shown publicly."},symbol:{type:"string",description:"Token ticker symbol, shown publicly."},salt:{...ge,description:"Deployment salt as 0x followed by 64 hex digits; it fixes the predicted token address."},image:{type:"string",description:"Image URL for the token. Public."},metadata:{type:"string",description:"Token metadata as a JSON string (description, social links). Public."},context:{type:"string",description:"Launch context as a JSON string. Defaults to Oak on Robinhood."},vanity:{const:!1,description:"Vanity address mining is not supported; leave false or omit."},initialBuy:{...be,description:"Native ETH base units, 18 decimals."},minAmountOut:{...be,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q,description:"Slippage in basis points (50 = 0.5%) applied to the initial buy when minAmountOut is omitted."},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100,description:"Static LP fee in basis points (100 = 1%). Not allowed together with pool.dynamicFee."},pool:{...pe,description:"Optional pool setup: paired token, starting tick, tick spacing, liquidity positions and dynamic fee. Defaults to a WETH pool."},rewards:{type:"array",minItems:1,maxItems:7,description:"How LP fees are split, 1 to 7 rows with bps totaling 10000. Default: all to the launching wallet.",items:{type:"object",properties:{admin:{...O,description:"Address that can later change this row."},recipient:{...O,description:"Address that receives this row's share of LP fees."},bps:{type:"integer",minimum:1,maximum:1e4,description:"This row's share of LP fees in basis points (5000 = 50%)."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in: 0 = both tokens (default), 1 = paired token, 2 = launched token."}},required:["admin","recipient","bps"],additionalProperties:!1}},vault:{...J.vault,description:"Optional vault extension: lock part of the supply, then vest it to an admin."},airdrop:{...J.airdrop,description:"Optional airdrop extension: reserve part of the supply for a Merkle-tree airdrop."}},["name","symbol","salt"],async(n,i)=>{let a=await Ae(n,i);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...O,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...ge,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string",description:"Optional search text matched against token name or symbol."},limit:{type:"integer",minimum:1,maximum:20,description:"Maximum tokens to return, 1 to 20 (default 10)."},cursor:{type:"string",description:"Opaque pagination cursor returned by a previous clanker_browse call."},deployer:{...O,description:"Optional address of the deploying wallet to filter tokens by."}},[],X)],positions:n=>s(async()=>{C(n);let i=new Map,a=new Set,c;do{let l=await X({deployer:n,limit:20,...c?{cursor:c}:{}});for(let o of l.tokens)w(o.msg_sender,n)&&i.set(o.contract_address.toLowerCase(),o);if(l.cursor&&a.has(l.cursor))throw new r("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let b=[],y=[P];for(let[l,o]of i){let m=await v(o.contract_address),p={...m,symbol:N(m.symbol)},d=K(await t().readContract({address:p.address,abi:V,functionName:"balanceOf",args:[n]}));b.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:p,amount:d}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),y.some(k=>w(k.address,p.address))||y.push(p)}for(let l of y){let o=await g(n,l.address);BigInt(o)>0n&&b.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return b})}},ze=e=>ae("clanker",[Oe(e),le(e),me(e),ye(e)]);export{Ne as a,Oe as b,ze as c};
|
|
1
|
+
import{b as q,o as U}from"./GYPMUYB5.js";import{a as J,b as ue,c as me}from"./C76D54YG.js";import{a as le}from"./ELHRXA5U.js";import{a as pe,b as fe}from"./DGDMRATN.js";import{a as ye}from"./4Z3IGMU6.js";import{e as F,h as L,m as ce}from"./TXGZ6NWN.js";import{b as ae}from"./SPJCSEKP.js";import{a as E}from"./IOYRL6AY.js";import{c as de}from"./SCG5HWMN.js";import{c as O,e as A,g as w,k as ie,l as oe,m as re,n as se}from"./NWNYJ26T.js";import{b as h,j as te}from"./TI727O2H.js";import{a as r}from"./XSD5NL7J.js";import{a as N}from"./JXOEJPJ4.js";import{decodeFunctionResult as Ce,encodeAbiParameters as j,encodeFunctionData as D,erc20Abi as V,isAddress as Ie,parseAbi as xe,parseAbiParameters as W,toHex as z,zeroAddress as Z}from"viem";var x=te[h].clanker,he=xe(["function deployToken(((address tokenAdmin,string name,string symbol,bytes32 salt,string image,string metadata,string context,uint256 originatingChainId) tokenConfig,(address hook,address pairedToken,int24 tickIfToken0IsClanker,int24 tickSpacing,bytes poolData) poolConfig,(address locker,address[] rewardAdmins,address[] rewardRecipients,uint16[] rewardBps,int24[] tickLower,int24[] tickUpper,uint16[] positionBps,bytes lockerData) lockerConfig,(address mevModule,bytes mevModuleData) mevModuleConfig,(address extension,uint256 msgValue,uint16 extensionBps,bytes extensionData)[] extensionConfigs) config) payable returns (address)","function tokenDeploymentInfo(address) view returns ((address,address,address,address[]))"]),T=xe(["function availableFees(address,address) view returns (uint256)","function claim(address,address)","function collectRewards(address)","function mevModuleEnabled(bytes32) view returns (bool)","function mevModuleOperational(bytes32) returns (bool)"]),P={address:x.paired_weth.address,symbol:"WETH",decimals:18,chainId:h},ve="https://www.clanker.world/api/tokens",be={type:"string",pattern:"^\\d+$"},ge={type:"string",pattern:"^0x[0-9a-fA-F]{64}$"};function C(e){return oe(ie(e,F),F)}function ke(e,t){if(typeof e!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e))throw new r(`Provide an explicit bytes32 ${t}.`);return e}function I(e,t,s=!1){if(e===void 0&&!s)return"";if(typeof e!="string"||s&&!e.trim())throw new r(`Provide ${t} as text.`);return e}function G(e,t=256){return se(e,`Amount exceeds the uint${t} range.`,{bits:t})}function K(e){return re(e,"The contract returned an invalid amount.").toString()}function B(e,t){let s=Object.keys(e).find(u=>!t.includes(u));if(s)throw new r(`Unsupported Clanker input: ${s}.`)}function we(e,t){return t.changes.map(({token:s,amount:u})=>{let g=u.startsWith("-");return`${g?"-":"+"}${e.formatAmount(g?u.slice(1):u,s.decimals)} ${s.symbol} (${s.address}, chain ${s.chainId})`}).join("; ")}function Se(e){return A(e)&&Array.isArray(e.data)&&Number.isSafeInteger(e.total)&&Number(e.total)>=0&&Number.isSafeInteger(e.tokensDeployed)&&Number(e.tokensDeployed)>=0&&(e.cursor===null||e.cursor===void 0||typeof e.cursor=="string")&&e.data.every(t=>A(t)&&typeof t.name=="string"&&typeof t.symbol=="string"&&Number.isSafeInteger(t.chain_id)&&["contract_address","admin","msg_sender","factory_address"].every(s=>typeof t[s]=="string"&&Ie(t[s],{strict:!1})))}function Q(e,t=0){return typeof e=="string"?N(e):e===null||typeof e=="boolean"?e:typeof e=="number"?Number.isFinite(e)?e:null:t>=4?null:Array.isArray(e)?e.slice(0,20).map(s=>Q(s,t+1)):A(e)?Object.fromEntries(Object.entries(e).filter(([s])=>/^[A-Za-z0-9_]{1,40}$/.test(s)).slice(0,40).map(([s,u])=>[s,Q(u,t+1)])):null}function _e(e){return{...Q(e),contract_address:e.contract_address,admin:e.admin,msg_sender:e.msg_sender,chain_id:e.chain_id,factory_address:e.factory_address,name:N(e.name),symbol:N(e.symbol)}}function $e(e){try{if(typeof e!="string"||!/^[A-Za-z0-9_-]{1,256}={0,2}$/.test(e))throw new Error;let t=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(!A(t)||typeof t.id!="string"||!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z?$/.test(t.id)||!Number.isFinite(Date.parse(t.id)))throw new Error;return e}catch{throw new r("Use the cursor returned by the previous clanker_browse page.")}}async function Ne(e,t={}){B(t,["q","limit","cursor","deployer"]);let s=t.limit??10;if(typeof s!="number"||!Number.isInteger(s)||s<1||s>20)throw new r("Choose an indexer limit from 1 to 20.");let u=new URL(ve);u.searchParams.set("chainId",String(h)),u.searchParams.set("limit",String(s)),t.q!==void 0&&u.searchParams.set("q",I(t.q,"search")),t.cursor!==void 0&&u.searchParams.set("cursor",I(t.cursor,"cursor",!0)),t.deployer!==void 0&&u.searchParams.set("msgSender",C(t.deployer));let g=await de(e.http,u.toString(),{headers:{"User-Agent":"Oak-Clanker/1.0"}},Se);return{tokens:g.data.filter(v=>v.chain_id===h&&w(v.factory_address,x.factory.address)),total:g.total,cursor:g.cursor||null,tokensDeployed:g.tokensDeployed}}var Oe=e=>{let t=()=>e.clientFor(h),s=async n=>{try{return await n()}catch(i){throw new r(e.plainError(i))}},u=(n,i,a,c="0")=>e.unsignedTx({to:n,data:i,value:c,chainId:h,description:a}),g=async(n,i)=>K(await t().readContract({address:x.fee_locker.address,abi:T,functionName:"availableFees",args:[n,i]})),v=async n=>{if(w(n,P.address))return P;let[i,a]=await Promise.all([t().readContract({address:n,abi:V,functionName:"symbol"}),t().readContract({address:n,abi:V,functionName:"decimals"})]);if(typeof i!="string"||!i.trim()||!Number.isInteger(a)||a<0||a>255)throw new r("The contract returned invalid token metadata.");return{address:n,chainId:h,symbol:i,decimals:a}},X=async n=>{n.cursor!==void 0&&$e(n.cursor);let i=await Ne(e,n);return{...i,tokens:i.tokens.map(_e)}},Ae=async(n,i)=>{if(B(n,["name","symbol","salt","image","metadata","context","vanity","initialBuy","minAmountOut","slippageBps","rewards","vault","airdrop","feeBps","pool"]),n.vanity!==void 0&&n.vanity!==!1)throw new r("Clanker launches use vanity false and an explicit salt.");let a=I(n.name,"token name",!0),c=I(n.symbol,"token symbol",!0),b=ke(n.salt,"salt"),y=G(n.initialBuy??"0"),l=n.slippageBps??q;if(typeof l!="number")throw new r("Slippage must be an integer from 0 to 9999 bps.");U("0",l);let o=n.minAmountOut===void 0?void 0:G(n.minAmountOut,128);if(o!==void 0&&o<=1n)throw new r("Initial-buy minimum must exceed one base unit.");if(!y&&o!==void 0)throw new r("A minimum requires a positive initial buy.");let m=ue(n,i);L(n.feeBps??100,0,1e3);let p=fe(n);if(y&&!w(p.poolConfig.pairedToken,P.address))throw new r("An initial ETH buy currently requires a WETH-paired pool. Launch without an initial buy and obtain a protected swap quote separately.");let d=n.rewards??[{admin:i,recipient:i,bps:1e4,feePreference:0}];if(!Array.isArray(d)||!d.length||d.length>7)throw new r("Provide one to seven reward allocations.");let k=d.map(f=>{if(!A(f))throw new r("Provide reward allocations as objects.");return B(f,["admin","recipient","bps","feePreference"]),{admin:C(f.admin),recipient:C(f.recipient),bps:L(f.bps,1,1e4),feePreference:L(f.feePreference??0,0,2)}});if(k.reduce((f,S)=>f+S.bps,0)!==1e4)throw new r("Reward allocations must total 10000 bps.");let _={tokenConfig:{tokenAdmin:i,name:a,symbol:c,salt:b,image:I(n.image,"image"),metadata:I(n.metadata,"metadata"),context:n.context===void 0?JSON.stringify({interface:"Oak",platform:"robinhood"}):I(n.context,"context"),originatingChainId:BigInt(h)},poolConfig:p.poolConfig,lockerConfig:{locker:x.locker.address,rewardAdmins:k.map(f=>f.admin),rewardRecipients:k.map(f=>f.recipient),rewardBps:k.map(f=>f.bps),tickLower:p.tickLower,tickUpper:p.tickUpper,positionBps:p.positionBps,lockerData:j(W("(uint8[])"),[[k.map(f=>f.feePreference)]])},mevModuleConfig:{mevModule:x.mev_module.address,mevModuleData:j(W("(uint24,uint24,uint256)"),[[666777,41673,15n]])},extensionConfigs:m},Pe=await t().simulateContract({address:x.factory.address,abi:he,functionName:"deployToken",args:[_],account:i,value:0n,gas:E}),M=C(Pe.result),Y=f=>{let S=[...m,...y?[{extension:x.devbuy.address,msgValue:y,extensionBps:0,extensionData:j(W("(address,address,uint24,int24,address),uint128,address"),[[Z,Z,0,0,Z],f,i])}]:[]];return u(x.factory.address,D({abi:he,functionName:"deployToken",args:[{..._,extensionConfigs:S}]}),`Launch ${a} (${c}); initial buy ${y} native ETH base units.`,y.toString())};if(y&&o===void 0){let S=(await e.preview([Y(0n)],i)).changes.filter($=>$.token.chainId===h&&w($.token.address,M)&&$.token.decimals===18).reduce(($,ne)=>$+(/^-?\d+$/.test(ne.amount)?BigInt(ne.amount):(()=>{throw new r("Invalid initial-buy simulation amount.")})()),0n);if(S<=0n)throw new r("Initial-buy simulation returned no token output.");if(o=G(U(S.toString(),l),128),o<=1n)throw new r("Initial-buy output is too small for a protected minimum.")}let ee=[Y(o??0n)],H=await e.preview(ee,i);return{txs:ee,preview:H,predictedToken:M,token:{address:M,chainId:h,symbol:c,decimals:18},...o!==void 0?{minAmountOut:o.toString()}:{},summary:`Launch ${c} at ${M} (CREATE2 address predicted from simulation); vanity false; salt ${b}. Supply 100000000000000000000000000000 base units (18 decimals). ${p.feeSummary}; protocol adds 20% of LP fees. Pool and LP allocations: ${JSON.stringify(p)}. Reward allocations: ${JSON.stringify(k)}. Extensions: ${JSON.stringify({vault:n.vault,airdrop:n.airdrop})}. Sniper fees 666777 to 41673 over 15 seconds. ${H.summary} ${we(e,H)}`}},Te=async(n,i)=>{if(B(n,["token","poolId","collect"]),n.collect!==void 0&&typeof n.collect!="boolean")throw new r("collect must be boolean.");if(n.collect===!1&&n.poolId!==void 0)throw new r("poolId requires collection.");if(n.collect===!0&&n.token===void 0)throw new r("Collection requires a Clanker token.");if(n.poolId!==void 0&&n.token===void 0)throw new r("A pool ID requires its Clanker token.");let a=[P],c=[];if(n.token!==void 0){let o=C(n.token);if(w(o,P.address))throw new r("Provide the launched Clanker token, not WETH.");if(n.collect!==!1){let m=await ce(e,o),{poolId:p,hook:d,locker:k}=m;if(n.poolId!==void 0&&!w(ke(n.poolId,"pool ID for fee collection"),p))throw new r("The supplied pool ID does not match the onchain Clanker pool.");w(m.pairedToken,P.address)||a.splice(0,1,await v(m.pairedToken));let _=await t().readContract({address:d,abi:T,functionName:"mevModuleEnabled",args:[p]});if(typeof _!="boolean")throw new r("The hook returned an invalid MEV guard state.");_&&c.push(u(d,D({abi:T,functionName:"mevModuleOperational",args:[p]}),"Update the Clanker pool MEV guard before collection.")),c.push(u(k,D({abi:T,functionName:"collectRewards",args:[o]}),"Collect pending LP fees into the fee locker."))}a.push(await v(o))}let b;if(c.length){if(await t().getChainId()!==h)throw new r("Fee simulation endpoint is on the wrong chain.");let o=[...c.map(d=>({from:i,gas:z(E),to:d.to,data:d.data,value:z(BigInt(d.value))})),...a.map(d=>({from:i,gas:z(E),to:x.fee_locker.address,data:D({abi:T,functionName:"availableFees",args:[i,d.address]}),value:"0x0"}))],m=await t().request({method:"eth_simulateV1",params:[{blockStateCalls:[{calls:o}],validation:!1,traceTransfers:!1},"latest"]},{retryCount:0});if(!Array.isArray(m)||m.length!==1||!A(m[0])||!Array.isArray(m[0].calls)||m[0].calls.length!==o.length)throw new r("The endpoint returned an unexpected fee simulation response.");let p=m[0].calls;if(!p.every(d=>A(d)&&d.status==="0x1"&&!d.error))throw new r("Clanker fee collection simulation failed.");b=p.slice(c.length).map(d=>{if(!A(d)||typeof d.returnData!="string"||!/^0x[0-9a-fA-F]{64}$/.test(d.returnData))throw new r("The endpoint returned an invalid fee balance.");return K(Ce({abi:T,functionName:"availableFees",data:d.returnData}))})}else b=await Promise.all(a.map(o=>g(i,o.address)));let y=a.flatMap((o,m)=>BigInt(b[m])>0n?[{token:o,amount:b[m]}]:[]);if(!y.length)throw new r("No claimable fees for this wallet; pending LP fees may require the MEV window to end.");for(let{token:o}of y)c.push(u(x.fee_locker.address,D({abi:T,functionName:"claim",args:[i,o.address]}),`Claim ${o.symbol} fees to ${i}.`));let l=await e.preview(c,i);return{txs:c,preview:l,fees:y,summary:`Claim fees to ${i}. WETH fees aggregate across all Clanker launches for this recipient. ${l.summary} ${we(e,l)}`}},R=(n,i,a,c)=>({name:`clanker_${n}`,inputSchema:{type:"object",properties:i,required:a,additionalProperties:!1},execute:(b,y)=>s(async()=>c(b,C(y)))});return{tools:[R("launch",{name:{type:"string",description:"Token name, shown publicly."},symbol:{type:"string",description:"Token ticker symbol, shown publicly."},salt:{...ge,description:"Deployment salt as 0x followed by 64 hex digits; it fixes the predicted token address."},image:{type:"string",description:"Image URL for the token. Public."},metadata:{type:"string",description:"Token metadata as a JSON string (description, social links). Public."},context:{type:"string",description:"Launch context as a JSON string. Defaults to Oak on Robinhood."},vanity:{const:!1,description:"Vanity address mining is not supported; leave false or omit."},initialBuy:{...be,description:"Native ETH base units, 18 decimals."},minAmountOut:{...be,description:"Minimum new token base units, 18 decimals; derived from simulation when omitted."},slippageBps:{type:"integer",minimum:0,maximum:9999,default:q,description:"Slippage in basis points (50 = 0.5%) applied to the initial buy when minAmountOut is omitted."},feeBps:{type:"integer",minimum:0,maximum:1e3,default:100,description:"Static LP fee in basis points (100 = 1%). Not allowed together with pool.dynamicFee."},pool:{...pe,description:"Optional pool setup: paired token, starting tick, tick spacing, liquidity positions and dynamic fee. Defaults to a WETH pool."},rewards:{type:"array",minItems:1,maxItems:7,description:"How LP fees are split, 1 to 7 rows with bps totaling 10000. Default: all to the launching wallet.",items:{type:"object",properties:{admin:{...O,description:"Address that can later change this row."},recipient:{...O,description:"Address that receives this row's share of LP fees."},bps:{type:"integer",minimum:1,maximum:1e4,description:"This row's share of LP fees in basis points (5000 = 50%)."},feePreference:{type:"integer",minimum:0,maximum:2,description:"Which token this row is paid in: 0 = both tokens (default), 1 = paired token, 2 = launched token."}},required:["admin","recipient","bps"],additionalProperties:!1}},vault:{...J.vault,description:"Optional vault extension: lock part of the supply, then vest it to an admin."},airdrop:{...J.airdrop,description:"Optional airdrop extension: reserve part of the supply for a Merkle-tree airdrop."}},["name","symbol","salt"],async(n,i)=>{let a=await Ae(n,i);return{...a,summary:`${a.summary} After the launch is mined, use clanker_status to inspect ${a.predictedToken} and clanker_claim to collect creator fees.`}}),R("claim",{token:{...O,description:"Launched token; derives its onchain pool and collects pending LP fees before claiming."},poolId:{...ge,description:"Optional assertion against the derived pool ID."},collect:{type:"boolean",default:!0,description:"Set false to claim only already-collected fees."}},[],Te),R("browse",{q:{type:"string",description:"Optional search text matched against token name or symbol."},limit:{type:"integer",minimum:1,maximum:20,description:"Maximum tokens to return, 1 to 20 (default 10)."},cursor:{type:"string",description:"Opaque pagination cursor returned by a previous clanker_browse call."},deployer:{...O,description:"Optional address of the deploying wallet to filter tokens by."}},[],X)],positions:n=>s(async()=>{C(n);let i=new Map,a=new Set,c;do{let l=await X({deployer:n,limit:20,...c?{cursor:c}:{}});for(let o of l.tokens)w(o.msg_sender,n)&&i.set(o.contract_address.toLowerCase(),o);if(l.cursor&&a.has(l.cursor))throw new r("The Clanker indexer repeated a pagination cursor.");l.cursor&&a.add(l.cursor),c=l.cursor??void 0}while(c);let b=[],y=[P];for(let[l,o]of i){let m=await v(o.contract_address),p={...m,symbol:N(m.symbol)},d=K(await t().readContract({address:p.address,abi:V,functionName:"balanceOf",args:[n]}));b.push({module:"clanker",id:`launch:${l}`,chainId:h,assets:[{token:p,amount:d}],description:`Indexed launch ${o.name}; wallet token balance, not locked LP principal.`}),y.some(k=>w(k.address,p.address))||y.push(p)}for(let l of y){let o=await g(n,l.address);BigInt(o)>0n&&b.push({module:"clanker",id:`fees:${l.address.toLowerCase()}`,chainId:h,assets:[{token:l,amount:o}],description:"Collected fees across launches for this recipient. Pending LP fees excluded; token-side discovery covers indexed launches by this wallet."})}return b})}},ze=e=>ae("clanker",[Oe(e),le(e),me(e),ye(e)]);export{Ne as a,Oe as b,ze as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as W,c as K}from"./A3BJSQ23.js";import{M as z}from"./
|
|
1
|
+
import{b as W,c as K}from"./A3BJSQ23.js";import{M as z}from"./MQXSCNUL.js";import{a as D}from"./IPU656WB.js";import{c as C}from"./LCH6F5HT.js";import{c as B,f as R,i as F,j as L,k as H}from"./X24YTJST.js";import{a as V}from"./43LI5NKJ.js";import{a as u}from"./66F5ZH34.js";import{g as O}from"./NWNYJ26T.js";import{b as A}from"./TI727O2H.js";import{a as o}from"./XSD5NL7J.js";import{encodeFunctionData as I,erc20Abi as j,getAddress as P,parseAbi as k}from"viem";var f=k(["function asset() view returns (address)","function decimals() view returns (uint8)","function balanceOf(address) view returns (uint256)","function previewMint(uint256) view returns (uint256)","function previewRedeem(uint256) view returns (uint256)","function previewWithdraw(uint256) view returns (uint256)","function mint(uint256 shares,address receiver) returns (uint256)","function redeem(uint256 shares,address receiver,address owner) returns (uint256)","function withdraw(uint256 assets,address receiver,address owner) returns (uint256)"]);function U(t,n=!1){if(typeof t!="string"||!/^\d+$/.test(t)||t.length>78||BigInt(t)>=1n<<256n||!n&&BigInt(t)===0n)throw new o("Provide a positive uint256 decimal base-unit string.");return BigInt(t)}function ce(t,n,y){return["details","analytics","manage","mint",n==="netnet"?"redeem":"withdraw_assets","force_exit","in_kind_exit"].map(e=>{let $=[...n==="longbow"?["vault"]:[],...e==="mint"?["shares","maxAssets"]:e==="redeem"?["shares"]:e==="withdraw_assets"?["amount"]:e==="force_exit"?["maxPenaltyAssets","minAmountOut"]:[]],m={...n==="longbow"?{vault:{type:"string",enum:y.map(i=>i.vault),description:"Pinned vault address on chain 4663; use longbow_list to compare vault names."}}:{}};e==="in_kind_exit"&&(Object.assign(m,{amount:u(`Assets to receive, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`),maxShares:u('Most vault shares you will burn, in share base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),deadline:u("Absolute Unix seconds deadline, no more than five minutes ahead. Example: 1800000000.")}),$.push("amount","maxShares","maxPenaltyAssets","deadline")),e==="mint"&&Object.assign(m,{shares:u('Vault shares to mint, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.'),maxAssets:u(`Most of the vault's asset you will pay, in base units (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)}),e==="redeem"&&(m.shares=u('Vault shares to redeem, in base units (shares have 18 decimals). Example: "1000000000000000000" = 1 share.')),e==="withdraw_assets"&&(m.amount=u(`Assets to withdraw, in base units of the vault's asset (read its decimals; USDG has 6). Example: "1000000" = 1 USDG.`)),e==="force_exit"&&Object.assign(m,{maxPenaltyAssets:u(`Highest exit penalty you accept, in base units of the vault's asset (read its decimals). Example: "10000" = 0.01 USDG for a 6-decimal asset.`),minAmountOut:u(`Least of the vault's asset you must receive, in base units (read its decimals). Example: "1000000" = 1 USDG.`)});let J=C(t,`${n}_manage`,y[0].vault,y[0].asset),N=D(t,`${n}_analytics`,y[0].vault);if(e==="manage"||e==="analytics"){let i=e==="manage"?J.inputSchema:N.inputSchema;Object.assign(m,i.properties),e==="analytics"&&n==="longbow"&&(m.view={type:"string",enum:["apy","published_apy"],description:"Report: apy (realized yield from share price) or published_apy (yield published by the project)."}),$.push(...i.required)}return{name:`${n}_${e}`,inputSchema:{type:"object",properties:m,required:$,additionalProperties:!1,...e==="analytics"&&n==="netnet"?{allOf:N.inputSchema.allOf}:{}},execute:async(i,r)=>{try{if(V(r),Object.keys(i).some(c=>!Object.hasOwn(m,c)))throw new o("Unsupported vault feature argument.");let _=n==="netnet"?y[0]:y.find(c=>typeof i.vault=="string"&&O(c.vault,i.vault));if(!_)throw new o("Choose a current vault returned by the project list tool.");let{vault:s,asset:a}=_,b={...i};if(delete b.vault,e==="details")return F(t,`${n}_details`,s,a).execute(b,r);if(e==="manage")return C(t,`${n}_manage`,s,a).execute(b,r);if(e==="analytics"){if(n==="longbow"&&i.view==="published_apy")return K(t,s,a,b);if(n==="longbow"&&i.view==="apy")return W(t,s,a,b);if(n==="longbow")throw new o("Choose apy or published_apy; the Longbow vault is not indexed by Morpho for other analytics views.");return{...await D(t,`${n}_analytics`,s).execute(b,r),asset:{...a,address:P(a.address)}}}if(e==="in_kind_exit")return z(t,s,a,i,r);let h=t.clientFor(A);if(await h.getChainId()!==A)throw new o("Vault actions require chain 4663.");let[Q,X,Y]=await Promise.all([h.readContract({address:s,abi:f,functionName:"asset"}),h.readContract({address:s,abi:f,functionName:"decimals"}),h.readContract({address:a.address,abi:j,functionName:"decimals"})]);if(P(Q)!==P(a.address)||X!==18||Y!==a.decimals)throw new o("Vault metadata does not match the pinned asset and shares.");let T=e==="force_exit"?await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]}):void 0;if(e==="force_exit"){let c=await R(t,h,s,r,T,B(i.maxPenaltyAssets),a),E=U(i.minAmountOut),w=[c.tx],v=await t.preview(w,r);return H(v.changes,s,T,E,a),{txs:w,preview:v,summary:`${L(c.plan,a.symbol)} ${v.summary}`}}let d=e==="mint",g=e==="redeem",l=U(d||g?i.shares:i.amount),x=await h.readContract({address:s,abi:f,functionName:d?"previewMint":g?"previewRedeem":"previewWithdraw",args:[l]});if(x<=0n||d&&x>U(i.maxAssets))throw new o("Vault quote is zero or exceeds maxAssets.");let q=d?void 0:await h.readContract({address:s,abi:f,functionName:"balanceOf",args:[r]});if(!d&&(g?l:x)>q)throw new o("The wallet share balance cannot cover this exit.");let Z=d?I({abi:f,functionName:"mint",args:[l,r]}):g?I({abi:f,functionName:"redeem",args:[l,r,r]}):I({abi:f,functionName:"withdraw",args:[l,r,r]}),G=`${e} ${l} ${d||g?"18-decimal share":`${a.decimals}-decimal ${a.symbol}`} base units on ${s}; beneficiary ${r}.`,M=[...d?[t.approval(a.address,s,x.toString(),A)]:[],t.unsignedTx({to:s,data:Z,value:"0",chainId:A,description:G})],S=await t.preview(M,r),p=(c,E)=>S.changes.filter(w=>w.token.chainId===A&&O(w.token.address,c)).reduce((w,v)=>{if(v.token.decimals!==E||!/^-?\d+$/.test(v.amount))throw new o("Invalid vault preview metadata.");return w+BigInt(v.amount)},0n);if(d?p(a.address,a.decimals)!==-x||p(s,18)!==l:g?p(s,18)!==-l||p(a.address,a.decimals)<=0n:p(a.address,a.decimals)!==l||-p(s,18)<=0n||-p(s,18)>q)throw new o("Vault preview does not match the requested amount and beneficiary.");return{txs:M,preview:S,summary:`${G} Counterpart quote ${x} base units. Mint approval is exact; accrual may require a fresh quote. Standard ERC-4626 calls encode no minimum receipt. ${S.summary}`}}catch(_){throw new o(t.plainError(_))}}}})}export{ce as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as p}from"./
|
|
1
|
+
import{j as p}from"./3BQ5XHDJ.js";import{a as d}from"./Z7FGEWO2.js";import{a as f}from"./43LI5NKJ.js";import{d as a,i as c}from"./NWNYJ26T.js";import{b as m}from"./IX3GZMTM.js";import{b as i}from"./TI727O2H.js";import{a as s}from"./XSD5NL7J.js";import{erc20Abi as u,zeroAddress as b}from"viem";function T(r,n,e=256,t=!1){if(typeof r!="string"||!/^[0-9]+$/.test(r))throw new s(`${n} must be a decimal base-unit string.`);let o=m(r);if(!t&&o===0n||o>=1n<<BigInt(e))throw new s(`${n} must be ${t?"a":"a positive"} uint${e}.`);return o}function g(r){return c(r,"Provide a token or contract address.",a)}function E(r){return typeof r=="string"&&["eth",d.toLowerCase()].includes(r.toLowerCase())?b:g(r)}function D(r){let n=r??50;if(typeof n!="number"||!Number.isInteger(n)||n<0||n>=1e4)throw new s("Slippage must be an integer from 0 to 9999 bps.");return n}async function N(r,n,e){if(n===b)return{address:d,symbol:"ETH",decimals:18,chainId:i};let t=r.clientFor(i),[o,w]=await Promise.all([t.readContract({address:n,abi:u,functionName:"symbol",blockNumber:e}),t.readContract({address:n,abi:u,functionName:"decimals",blockNumber:e})]);return{address:n,symbol:p(o,n),decimals:w,chainId:i}}async function S(r,n,e,t){return f(e),{txs:n,preview:await r.preview(n,e),summary:t}}function $(r,n){if(Object.keys(r).some(e=>!n.includes(e)))throw new s(`Provide only ${n.join(", ")}.`)}export{T as a,g as b,E as c,D as d,N as e,S as f,$ as g};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as K,e as _,h as W,m as G,n as j}from"./BA66J5YQ.js";import{a as p,d as $}from"./JFC2QCMW.js";import{a as D}from"./Y2QADJOB.js";import{b as C}from"./ZTX4WT62.js";import{b as T,j as x}from"./TI727O2H.js";import{formatUnits as ne,getAddress as ie,parseAbi as Q}from"viem";var m=10n**18n,U=1n<<192n,J=Q(["function slot0() view returns (uint160,int24,uint16,uint16,uint16,uint8,bool)","function liquidity() view returns (uint128)","function getSlot0(bytes32) view returns (uint160,int24,uint24,uint24)","function getLiquidity(bytes32) view returns (uint128)"]),re=Q(["function getLaunchedToken(address) view returns ((address token,address curve,address deployer,address creatorFeeRecipient,address pairToken,uint256 graduationThreshold,uint24 poolFee,int24 tickSpacing,uint16 creatorTaxBps,bool buybackEnabled,uint8 phase,uint256 sweptQuote,uint256 sweptTokens,uint256 sweptAt,bool exists))"]),s=a=>({usdEstimate:null,estimateLabel:"price unavailable",estimateReason:a}),h=a=>`${a.chainId}:${a.address.toLowerCase()}`;async function le(a,S,g={}){let b=Number.isFinite(g.budgetMs)?Math.min(3e3,Math.max(0,g.budgetMs)):3e3,k=`Oak stopped pricing after ${b===3e3?"3 seconds":`${b} milliseconds`}`,w=new Map,y=[...new Map(S.map(e=>[h(e.token),e.token])).values()],u=!1,v=0,E=[];async function P(e){if(u)throw new Error(k);if(v>=6?await new Promise(t=>E.push(t)):v++,u)throw new Error(k);try{return await e()}finally{let t=E.shift();t?t():v--}}let I=new Map,R=new Map,F=new Map,q;function f(e){let t=I.get(e);if(!t){let n=a.clientFor(e);t=new Proxy(n,{get(r,i,c){let d=Reflect.get(r,i,c);return i==="readContract"?(...o)=>P(async()=>Reflect.apply(d,r,o)):d}}),I.set(e,t)}return t}function A(e){let t=R.get(e);return t||(t=P(()=>f(e).getBlockNumber({cacheTime:0})),R.set(e,t)),t}function O(e,t){return q??=G(e,void 0,t).then(n=>{let r=BigInt(n);if(r<=0n)throw new Error("ETH average unavailable");return r}),q}function V(e,t){let n=`${e}:${t}`,r=F.get(n);return r||(r=P(()=>f(e).getBlock({blockNumber:t})).then(i=>{if(!(i.number!==t||typeof i.timestamp!="bigint"||i.timestamp<=0n))return i.timestamp.toString()}).catch(()=>{}),F.set(n,r)),r}async function z(e,t){let n=f(e.chainId),r=await A(e.chainId),i=await $(e,n,r);if(!i)return s("Oak has no pinned pool with sufficient in-range depth for this token");let c=BigInt(e.address)<BigInt(p.usdg);return{numerator:c?i.sqrt**2n:U,denominator:(c?U:i.sqrt**2n)*10n**6n,source:`current price in the Uniswap USDG/${t.symbol} pool; on-chain trading can differ from the stock market`,block:r}}async function X(e){if(_(e))return{numerator:1n,denominator:10n**6n,source:"USDG counted at $1.00"};if(e.chainId!==T)return s("Oak has no source for this token");if(g.chopShareTokens?.some(o=>o.toLowerCase()===e.address.toLowerCase()))return s("chop_logs shows this log's backing");let t=e.symbol;if(t.startsWith("untrusted "))try{let o=JSON.parse(t.slice(10));typeof o=="string"&&(t=o)}catch{}if(K(e))try{let o=f(e.chainId),l=await A(e.chainId),N=ie(C.stateView),B=C.poolId,[ee,te]=await Promise.all([o.readContract({address:N,abi:J,functionName:"getSlot0",args:[B],blockNumber:l}),o.readContract({address:N,abi:J,functionName:"getLiquidity",args:[B],blockNumber:l})]),H=ee[0];return H<=0n||te<=0n?s("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool. A quote is a sale for this amount only; Oak never uses it to value a balance."):{numerator:await O(o,l)*U,denominator:m*H**2n*10n**BigInt(e.decimals),source:"current price in the Uniswap v4 WETH/CHOP pool",block:l}}catch{return s("Oak could not verify the pinned Uniswap v4 WETH/CHOP pool for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.")}if(t==="CHOP")return s("Oak has no pinned market for CHOP. A quote is a sale for this amount only; Oak never uses it to value a balance.");let n=p.tokens.find(o=>o.token.toLowerCase()===e.address.toLowerCase());if(n)return z(e,n);if(Object.hasOwn(p.notOffered,t))return s("Oak has no pinned market for this token");let r=f(e.chainId),i=await A(e.chainId);if(W(e))return{numerator:await O(r,i),denominator:m*m,source:"30-minute average of the Uniswap ETH/USDG pool",block:i};let c=(a.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS)?.toLowerCase()===e.address.toLowerCase();if(c)try{let o=a.resolvePrice?await a.resolvePrice(e,i):await j(e,{client:r,blockNumber:i,oakTokenAddress:e.address,officialStockTokens:[]}),l=BigInt(o.usdE18);if(l<=0n)throw new Error("OAK price unavailable");return{numerator:l,denominator:m*10n**BigInt(e.decimals),source:"OAK price",block:i}}catch{}if(c&&(await r.readContract({address:x[T].pons.factory.address,abi:re,functionName:"getLaunchedToken",args:[e.address],blockNumber:i})).phase!==2)return s("Oak has no graduated Pons pool price for OAK");let d=await D(e,r,i);return d.numerator<=0n||d.denominator<=0n?s("Oak has no source for this token"):{numerator:await O(r,i)*d.numerator,denominator:m*d.denominator*10n**BigInt(e.decimals),source:c?"OAK's current Pons pool price; fewer than enough trades in 30 minutes for a price":"current Pons pool price",block:i}}let L=0;async function Y(){for(;!u&&L<y.length;){let e=y[L++],t;try{if(!Number.isInteger(e.decimals)||e.decimals<0||e.decimals>255)throw new Error("Invalid decimals");if(t=await X(e),u||w.set(h(e),t),"numerator"in t&&t.block!==void 0){let n=await V(e.chainId,t.block);u||(t.observedAt=n)}}catch{t=s("Oak has no source for this token")}u||w.set(h(e),t)}}let M,Z=new Promise(e=>{M=setTimeout(()=>{u=!0;for(let t of E.splice(0))t();e()},b)});try{await Promise.race([Promise.all(Array.from({length:Math.min(6,y.length)},Y)),Z])}finally{clearTimeout(M),u=!0}return S.map(e=>{let t;try{if(!/^\d+$/.test(e.amount)||!Number.isInteger(e.token.decimals)||e.token.decimals<0||e.token.decimals>255)throw new Error("Invalid amount");t="humanAmount"in e&&typeof e.humanAmount=="string"?e.humanAmount:ne(BigInt(e.amount),e.token.decimals);let n=w.get(h(e.token));if(n&&"numerator"in n){let i=(BigInt(e.amount)*n.numerator*100n*2n+n.denominator)/(n.denominator*2n);return{...e,humanAmount:t,usdEstimate:`${i/100n}.${(i%100n).toString().padStart(2,"0")}`,estimateLabel:"estimate, not a quote",estimateSource:n.source,unitUsdE18:(n.numerator*10n**BigInt(e.token.decimals)*m/n.denominator).toString(),...n.observedAt===void 0?{}:{observedAt:n.observedAt},...n.block===void 0?{}:{estimateAsOf:n.block.toString()}}}return{...e,humanAmount:t,...n??s(k)}}catch{return{...e,...t===void 0?{}:{humanAmount:t},...s("Oak cannot format this token amount")}}})}export{le as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as $e,b as Ee}from"./YEIM6BZQ.js";import{c as en,d as nn,e as _e,f as he,i as Ue,j as tn}from"./P7C3TYI4.js";import{l as de}from"./BA66J5YQ.js";import{b as Te,o as Me}from"./GYPMUYB5.js";import{a as ce}from"./Z7FGEWO2.js";import{a as T,b as Je}from"./43LI5NKJ.js";import{a as L}from"./66F5ZH34.js";import{b as K}from"./IX3GZMTM.js";import{b as y,e as Ze,j as Q,k as Ye,n as Qe}from"./TI727O2H.js";import{a as o,b as Ge,e as oe}from"./XSD5NL7J.js";import{encodeAbiParameters as S,encodeFunctionData as re,erc20Abi as on,getAddress as w,isAddress as Nn,keccak256 as Kn,pad as Hn,parseAbi as Ae,parseAbiParameters as z,toEventSelector as Fn,toHex as rn}from"viem";var Vn=w(Q[4663].uniswap.v4_pool_manager.address),M=w(Q[4663].uniswap.v4_position_manager.address),le=w(Q[4663].uniswap.v4_state_view.address),He=w(Q[4663].uniswap.permit2.address),At=w(Q[4663].ponsTrade.universal_router.address),se=w(Q[4663].uniswap.WETH.address),D=w(Ye),k="0x0000000000000000000000000000000000000000",Xe=8388608,Fe=-887272,ve=887272,An=(1n<<48n)-1n,J=(1n<<128n)-1n,Bn=(1n<<160n)-1n,pe=1n<<96n,sn="V4 deposits use limits, not minimums: set amount0Max and amount1Max, and for more room for price movement set slippageBps (at most 500 = 5%).",an=1800n,me=50n,cn=(e,n=me)=>e*(10000n-n)/10000n,dn=(e,n,i=me)=>{let r=(e*(10000n+i)+9999n)/10000n;return r<n?r:n},Xn="0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",Ve=class extends o{name="PonsHookRefusal";token;constructor(n){let i=n===void 0?void 0:w(n),r=i?`To buy, use pons_buy {"token":"${i}","amountIn":"<ETH in wei>"}. To sell, use pons_sell {"token":"${i}","amountIn":"<token base units>"}.`:"For this custom pair, check the launch token and pairToken with pons_status, then use pons_buy or pons_sell with those addresses and amounts in the input token's base units.";super(`Oak's Uniswap tools don't quote this pool. Its hook is Pons's own trading hook, so Oak trades it only through Pons. ${r} Pons shows the exact fees before you approve.`),this.token=i}},Oe=[{poolId:"0xbac3aa3b91584a53a579b3c999a56756e954e59247e497bad1d25a4334bde551",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0x06a889870c8f83640d6816319f72e2aa579b6080")},liquidity:"5532026605872066941",sqrtPriceX96:"3839897026469220985301794",tick:-198703,protocolFee:0,lpFee:0},{poolId:"0x387bf619da4d3fb62bb276482693dba1b9b3520f573cabdfe033384a24125982",key:{currency0:k,currency1:D,fee:500,tickSpacing:10,hooks:k},liquidity:"225820987949255613",sqrtPriceX96:"3840577772610961024680304",tick:-198700,protocolFee:512125,lpFee:500},{poolId:"0x54f7883914619af9105355bf83ed678bcf9f63560218ac61c9963b9503d0ba32",key:{currency0:k,currency1:D,fee:460,tickSpacing:9,hooks:k},liquidity:"85654324417347171",sqrtPriceX96:"3840419018843648722761192",tick:-198701,protocolFee:479349,lpFee:460},{poolId:"0xc7b615a3721594f73664eb3f62d8290d0fcc8d9d1156aed1ddecbd7f32efd9f5",key:{currency0:k,currency1:D,fee:8388608,tickSpacing:10,hooks:w("0xcb787a5cdea8b3715d984d82f1203fd7bfebe0c4")},liquidity:"50517446454827887",sqrtPriceX96:"3840495145865430860317598",tick:-198700,protocolFee:0,lpFee:0},{poolId:"0x24107d152f14a76d292123265ae3f3c71f863fc2f4ef7ba49d64e78d28ea379e",key:{currency0:k,currency1:D,fee:100,tickSpacing:1,hooks:k},liquidity:"36478878201789434",sqrtPriceX96:"3840363370720475418748563",tick:-198701,protocolFee:102425,lpFee:100},{poolId:"0x84bd4e2d8be11aeb0afc1195b38f587b61e90068548f1063fdbe448fb8cad0b6",key:{currency0:se,currency1:D,fee:200,tickSpacing:4,hooks:k},liquidity:"5980655057479791",sqrtPriceX96:"3839891926195366283625355",tick:-198703,protocolFee:213044,lpFee:200},{poolId:"0x3b0cbf0603ecc67b5fc9bb4fbb6ac9e08d3b2f406b63d1662a36063a7fe5e866",key:{currency0:k,currency1:D,fee:87,tickSpacing:1,hooks:k},liquidity:"5486760264498148",sqrtPriceX96:"3840563617639470134132117",tick:-198700,protocolFee:90134,lpFee:87}],Re=w("0x987e330f00b79864a07fe81dfac344d0078abcc0"),Sn="0xa791e5169faf703c0b63fd9552c33ec1128a773a00f5dc33a640da62a022cd35",On={currency0:k,currency1:D,fee:Xe,tickSpacing:1,hooks:Re},Rn=new Set([...Oe.map(e=>e.key.hooks.toLowerCase()),Re.toLowerCase()]),zn=z("address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks"),jn=z("(address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, int24 tickLower, int24 tickUpper, uint256 liquidity, uint128 amount0Max, uint128 amount1Max, address owner, bytes hookData"),Wn=z("address currency0, address currency1"),Gn=z("address currency, address recipient"),ge=z("uint256 tokenId, uint256 liquidity, uint128 amount0Min, uint128 amount1Min, bytes hookData"),Zn=z("uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes hookData"),De=z("address currency0, address currency1, address recipient"),ue=z("bytes actions, bytes[] params"),X=Ae(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable","function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)","function getPositionLiquidity(uint256 tokenId) view returns (uint128 liquidity)","function getPoolAndPositionInfo(uint256 tokenId) view returns ((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) poolKey, uint256 info)","function positionInfo(uint256 tokenId) view returns (uint256 info)","function ownerOf(uint256 tokenId) view returns (address owner)","function nextTokenId() view returns (uint256 tokenId)"]),Yn=Ae(["function initialize((address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks) key, uint160 sqrtPriceX96) returns (int24 tick)"]),un=z("address currency"),pn=1e6,fe=Ae(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Qn=Ae(["function approve(address token, address spender, uint160 amount, uint48 expiration)"]),Jn=Fn("Transfer(address,address,uint256)");function xe(e){if(typeof e!="string"||!Nn(e,{strict:!1}))throw new o("Provide a valid v4 currency address.");let n=e.toLowerCase();return n===k||n===ce.toLowerCase()?k:w(e)}function H(e){let n=e.toLowerCase();return n===k||n===ce.toLowerCase()}function ye(e){let n=xe(e.currency0),i=xe(e.currency1);T(e.hooks);let r=w(e.hooks);return Kn(S(zn,[n,i,e.fee,e.tickSpacing,r]))}function In(e){return((typeof e=="number"?e:e.fee)&Xe)!==0}function ln(e,n){return In(e)?{dynamicFee:!0,storedLpFee:n,swapsAreFree:!1,feeNote:Ee(e,n)}:{dynamicFee:!1,storedLpFee:n,swapsAreFree:n===0,feeNote:Ee(e,n)}}function ke(e,n){if(!e||typeof e!="object")throw new o("Provide a valid v4 PoolKey.");let i=xe(e.currency0),r=xe(e.currency1);if(BigInt(i)>=BigInt(r))throw new o("PoolKey currencies must be strictly sorted (currency0 < currency1).");if(!Number.isInteger(e.tickSpacing)||e.tickSpacing<=0||e.tickSpacing>32767)throw new o("PoolKey tickSpacing must be a positive integer.");if(!Number.isInteger(e.fee)||e.fee<0||e.fee>16777215)throw new o("PoolKey fee must be a valid uint24.");T(e.hooks);let c=w(e.hooks),s=In(e.fee);if(!s&&e.fee>pn)throw new o(`PoolKey static fee ${$e(e.fee)} exceeds the v4 maximum of ${$e(pn)}.`);if(s&&e.fee!==Xe)throw new o("Dynamic-fee PoolKey must use exact fee flag 0x800000 (8388608).");if(s&&c.toLowerCase()===k)throw new o("Dynamic-fee PoolKey requires a non-zero hook address.");if(!Rn.has(c.toLowerCase()))throw c.toLowerCase()===Qe.toLowerCase()?new Ve(i===k?r:void 0):new o(`Unsupported v4 hook ${c}: Oak does not assure arbitrary v4 hooks outside measured PoolKeys.`);let t={currency0:i,currency1:r,fee:e.fee,tickSpacing:e.tickSpacing,hooks:c},d=ye(t);if(c===Re&&d.toLowerCase()!==Sn)throw new o("Only the documented VolatilePair ETH/USDG PoolKey is supported. Pool creation requires the Uniswap Labs role.");if(n!==void 0){if(typeof n!="string"||!/^0x[0-9a-fA-F]{64}$/.test(n))throw new o("Provide a 32-byte hex poolId.");if(d.toLowerCase()!==n.toLowerCase())throw new o(`PoolKey hash (${d}) does not match expected poolId (${n}).`)}return t}function et(e){if(!Number.isInteger(e)||e<=0||e>ve)throw new o("tickSpacing must be a positive integer.");let n=Math.trunc(Fe/e)*e,i=Math.trunc(ve/e)*e;return{tickLower:n===0?0:n,tickUpper:i===0?0:i}}function nt(e,n,i){if(!Number.isInteger(i)||i<=0)throw new o("tickSpacing must be a positive integer.");if(!Number.isInteger(e)||!Number.isInteger(n))throw new o("tickLower and tickUpper must be integers.");if(e<Fe||n>ve)throw new o(`Ticks [${e}, ${n}] are outside Uniswap bounds [${Fe}, ${ve}].`);if(e>=n)throw new o("tickLower must be strictly less than tickUpper.");if(e%i!==0||n%i!==0)throw new o(`Ticks [${e}, ${n}] must be divisible by tickSpacing ${i}.`)}function mn(e,n,i,r,c=y){if(T(e),T(n),H(e))throw new o("Native ETH does not use Permit2 approval.");let s=K(i);if(s<=0n||s>Bn)throw new o("Permit2 approval amount must be a positive integer within uint160.");let t=K(String(r));if(t<=0n||t>An)throw new o("Permit2 expiration must be a positive timestamp within uint48.");let d=re({abi:Qn,functionName:"approve",args:[e,n,s,Number(t)]});return Je({to:He,data:d,value:"0",chainId:c,description:`Approve Permit2 allowance of ${s} base units of ${e} for ${n} until ${t}.`})}function fn(e){let n=Number(e&0xffffffn);return(n&8388608)!==0?n-16777216:n}function tt(e){let n=(e&0xffn)!==0n,i=fn(e>>8n&0xffffffn),r=fn(e>>32n&0xffffffn);return{poolIdBytes25:`0x${(e>>56n&(1n<<200n)-1n).toString(16).padStart(50,"0")}`,tickLower:i,tickUpper:r,hasSubscriber:n}}function yn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e];if(c<=0n||s<=0n)return 0n;let t=(i<<96n)*(s-c),d=s*c;return r?(t+d-1n)/d:t/d}function wn(e,n,i,r=!1){let[c,s]=e<=n?[e,n]:[n,e],t=i*(s-c);return r?(t+pe-1n)/pe:t/pe}function Cn(e){if(e.liquidity<=0n)return{amount0:0n,amount1:0n};let n=de(e.tickLower),i=de(e.tickUpper);return e.sqrtPriceX96<=n?{amount0:yn(n,i,e.liquidity,e.roundUp),amount1:0n}:e.sqrtPriceX96<i?{amount0:yn(e.sqrtPriceX96,i,e.liquidity,e.roundUp),amount1:wn(n,e.sqrtPriceX96,e.liquidity,e.roundUp)}:{amount0:0n,amount1:wn(n,i,e.liquidity,e.roundUp)}}function it(e){let n=de(e.tickLower),i=de(e.tickUpper),r=(s,t,d)=>t<=s||d<=0n?0n:d*s*t/pe/(t-s),c=(s,t,d)=>t<=s||d<=0n?0n:d*pe/(t-s);if(e.sqrtPriceX96<=n)return r(n,i,e.amount0);if(e.sqrtPriceX96<i){let s=r(e.sqrtPriceX96,i,e.amount0),t=c(n,e.sqrtPriceX96,e.amount1);return s<t?s:t}return c(n,i,e.amount1)}function Ne(e,n){return e.map(i=>{let r=i.amount.trim(),c=r.startsWith("-"),s=c||r.startsWith("+")?r.slice(1):r,t=n(s,i.token.decimals);return`${c?"-":""}${t} ${i.token.symbol}`})}function bn(e,n=y){if(H(e))return{address:ce,symbol:"ETH",decimals:18,chainId:n};let i=w(e);return i.toLowerCase()===D.toLowerCase()?{address:D,symbol:"USDG",decimals:Ze,chainId:n}:i.toLowerCase()===se.toLowerCase()?{address:se,symbol:"WETH",decimals:18,chainId:n}:{address:i,symbol:i.slice(0,10),decimals:18,chainId:n}}async function B(e,n,i=y){if(H(n))return bn(n,i);let r=w(n);if(r.toLowerCase()===D.toLowerCase()||r.toLowerCase()===se.toLowerCase())return bn(r,i);let[c,s]=await Promise.all([e.readContract({address:r,abi:on,functionName:"symbol"}),e.readContract({address:r,abi:on,functionName:"decimals"})]);if(!Number.isInteger(Number(s))||Number(s)<0||Number(s)>77)throw new o(`Token ${r} reports invalid decimals.`);return{address:r,symbol:tn(c,r),decimals:Number(s),chainId:i}}function Z(e,n){if(typeof e!="string"||!/^\d+$/.test(e))throw new o(`${n} must be a non-negative integer string in base units.`);return K(e)}function hn(e,n,i,r){let c=e===void 0?K(Me(n.toString(),i)):Z(e,r);if(c<=1n||c>J)throw new o(`${r} must exceed 1 base unit and fit in uint128; the simulated amount may be too small.`);return c}async function qn(e,n){if(typeof n=="number"&&Number.isFinite(n)&&n>0)return BigInt(Math.floor(n>1e11?n/1e3:n));if(typeof n=="string"&&/^\d+$/.test(n.trim()))return BigInt(n.trim());try{let i=await e.request({method:"eth_getBlockByNumber",params:["latest",!1]});if(i&&typeof i.timestamp=="string")return BigInt(i.timestamp)}catch{}return BigInt(Math.floor(Date.now()/1e3))}async function Ke(e,n,i){let r=await qn(e,i);if(n==null)return r+1800n;let c=K(String(n));if(c<=r)throw new o(`Transaction deadline ${c} has expired (current timestamp ${r}).`);return c}async function Be(e,n){let i=typeof n.poolId=="string"?n.poolId.trim():void 0,r=n.poolKey&&typeof n.poolKey=="object"&&!Array.isArray(n.poolKey)?n.poolKey:void 0,c=r?{currency0:String(r.currency0??k),currency1:String(r.currency1??D),fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:String(r.hooks??k)}:n.currency0!==void 0&&n.currency1!==void 0&&n.fee!==void 0&&n.tickSpacing!==void 0?{currency0:String(n.currency0),currency1:String(n.currency1),fee:Number(n.fee),tickSpacing:Number(n.tickSpacing),hooks:String(n.hooks??k)}:void 0;if(c){if(H(c.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");let u=ke(c,i);return{poolId:ye(u),poolKey:u}}let s=(i??Xn).toLowerCase();if(s===Sn)return{poolId:s,poolKey:ke(On,s)};let t=Oe.find(u=>u.poolId.toLowerCase()===s);if(t){if(H(t.key.currency0)&&typeof n.token0=="string"&&n.token0.toLowerCase()===se.toLowerCase())throw new o("Native ETH currency0 differs from WETH; do not supply WETH for a native-ETH v4 pool.");return{poolId:t.poolId,poolKey:t.key}}let d=s.slice(0,52),a=await e.readContract({address:M,abi:X,functionName:"poolKeys",args:[d]}),[p,l,m,f,P]=a;if(p.toLowerCase()===k&&l.toLowerCase()===k&&Number(f)===0)throw new o(`Unknown or uninitialized v4 poolId ${s}.`);let b=ke({currency0:p,currency1:l,fee:Number(m),tickSpacing:Number(f),hooks:P},s);return{poolId:s,poolKey:b}}async function Pe(e,n,i){try{let[r,c]=await e.readContract({address:M,abi:X,functionName:"getPoolAndPositionInfo",args:[n]}),s=ke({currency0:r.currency0,currency1:r.currency1,fee:Number(r.fee),tickSpacing:Number(r.tickSpacing),hooks:r.hooks});if((i.poolKey||i.poolId)&&(await Be(e,i)).poolId.toLowerCase()!==ye(s).toLowerCase())throw new o("The supplied PoolKey does not match this v4 position.");let t=tt(BigInt(c));return{poolKey:s,poolId:ye(s),tickLower:t.tickLower,tickUpper:t.tickUpper}}catch(r){throw new o(`Could not read v4 position #${n}. ${oe(r)}`)}}function ot(e){if(typeof e!="string")throw new o("wallet must be a valid 20-byte hex address.");return T(e),w(e)}async function gn(e,n,i={}){T(n);let r=w(n),c=e.clientFor(y),s=new Set;if(i.tokenIds)for(let d of i.tokenIds)s.add(K(String(d)).toString());if(!i.tokenIds?.length)try{let d=await c.getBlockNumber(),a=10000000n;for(let p=0n;p<=d;p+=a){let l=p+a-1n<d?p+a-1n:d,m=await c.request({method:"eth_getLogs",params:[{address:M.toLowerCase(),topics:[Jn,null,Hn(r)],fromBlock:rn(p),toBlock:rn(l)}]});if(!Array.isArray(m))throw new o("Invalid v4 position log response.");for(let f of m){if(!Array.isArray(f.topics)||f.topics.length!==4||!/^0x[0-9a-fA-F]{64}$/.test(f.topics[3]??""))throw new o("Invalid v4 position transfer log.");s.add(BigInt(f.topics[3]).toString())}}}catch(d){if(!i.tokenIds)throw new o(`Could not discover v4 positions. ${oe(d)}`)}let t=[];for(let d of s){let a=BigInt(d);try{let p;try{p=await c.readContract({address:M,abi:X,functionName:"ownerOf",args:[a]})}catch(F){if(Ge(F,3))continue;throw F}if(p.toLowerCase()!==r.toLowerCase())continue;let l=await c.readContract({address:M,abi:X,functionName:"getPositionLiquidity",args:[a]}),m=BigInt(l);if(m===0n&&!i.includeZero)continue;let{poolKey:f,poolId:P,tickLower:b,tickUpper:u}=await Pe(c,a,{}),v=await c.readContract({address:le,abi:fe,functionName:"getSlot0",args:[P]}),x=BigInt(v[0]),{amount0:h,amount1:g}=Cn({liquidity:m,tickLower:b,tickUpper:u,sqrtPriceX96:x}),[A,I]=await Promise.all([B(c,f.currency0,y),B(c,f.currency1,y)]);t.push({module:"uniswap",id:`uniswap:v4:${a.toString()}`,chainId:y,assets:[{token:A,amount:h.toString()},{token:I,amount:g.toString()}],description:`Uniswap v4 LP position #${a.toString()} (${A.symbol}/${I.symbol}, liquidity=${m.toString()}, ticks=[${b},${u}], poolId=${P})`})}catch(p){throw new o(`Could not read v4 position #${a}. ${oe(p)}`)}}return t}var rt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolId:{type:"string",description:"32-byte Uniswap v4 poolId hex string."},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"},tickLower:{description:"Lower tick boundary, divisible by the pool tick spacing.",type:"number"},tickUpper:{description:"Upper tick boundary, divisible by the pool tick spacing.",type:"number"},fullRange:{description:"Use the widest tick range aligned to the pool tick spacing; omit explicit ticks.",type:"boolean"},liquidity:L('Position liquidity in protocol base units. Example: "1000" = 1000 liquidity units.'),amount0Max:L('Maximum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Max:L('Maximum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),permit2Expiration:{description:'Permit2 allowance expiry in Unix seconds, as a decimal string. Example: "1800000000".',type:"string"},exactCaps:{description:"Use both caller caps exactly for a new v4 mint; omit tokenId, initialPrice and sqrtPriceX96.",type:"boolean"},slippageBps:{description:"Mint cap headroom in basis points (50 = 0.5%), up to 500 (5%); unavailable when increasing an existing NFT.",type:"integer",minimum:0,maximum:500,default:Number(me)},hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"},tokenId:L('Existing v4 position NFT identifier to increase, as a decimal string; keeps its tick range. Omit to mint a new position. Example: "1".'),initialPrice:{type:"string",description:"Starting price as token1 per one token0 in human units; used only for a new pool. Pool creation and the first liquidity add require separate confirmations."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},st={type:"object",description:"Create and initialize an empty Uniswap v4 pool (permissionless PoolManager.initialize). Add liquidity afterwards with uniswap_add.",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object",properties:{currency0:{description:"Lower sorted currency address; the zero address means native ETH.",type:"string"},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%).",type:"number"},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{description:"Hook contract address; the zero address means no hook.",type:"string"}}},currency0:{type:"string",description:"Lower sorted currency; the zero address is native ETH."},currency1:{description:"Higher sorted currency address.",type:"string"},fee:{type:"number",description:"Pool fee in pips, hundredths of a basis point (3000 = 0.3%; 950000 = 95%)."},tickSpacing:{description:"Spacing between usable pool ticks, as an integer.",type:"number"},hooks:{type:"string",description:"Hook address; only hooks Oak has measured are accepted. Defaults to none."},initialPrice:{type:"string",description:"Starting pool price as token1 per one token0 in human units. Add liquidity separately after initialization."},sqrtPriceX96:{type:"string",description:"Alternative starting price: square root of the token1/token0 base-unit price ratio, multiplied by 2^96, as a decimal string."},acceptPriceDeviation:{type:"boolean",description:"Allow a starting price more than 500 basis points (5%) from other live pools of the pair."}}},at={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},ct={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenId:L('Identifier of the position NFT, as a decimal string. Example: "1".'),liquidity:{type:"string",pattern:"^(?:[0-9]+|all)$",description:'Liquidity in protocol base units, or "all" for a full exit where supported; not a token amount. Example: "1000" = 1000 liquidity units.'},slippageBps:{description:"Slippage tolerance in basis points (50 = 0.5%).",type:"integer",minimum:0,maximum:9999,default:Te},fullExit:{description:"Remove all position liquidity and collect the proceeds.",type:"boolean"},burn:{description:"Burn the position NFT after all liquidity and owed tokens have been removed.",type:"boolean"},amount0Min:L('Minimum amount of currency0 in base units; use currency0 decimals. Example: "1000000" = 1 currency0 at 6 decimals.'),amount1Min:L('Minimum amount of currency1 in base units; use currency1 decimals. Example: "1000000" = 1 currency1 at 6 decimals.'),poolId:{description:"Identifier of the v4 pool, as a 32-byte hex string.",type:"string"},poolKey:{description:"V4 pool key: sorted currencies, fee in pips, tick spacing and hook address.",type:"object"},recipient:{description:"Recipient address; must be the signing wallet.",type:"string"},deadline:L("Transaction deadline in Unix seconds, after the current block timestamp. Example: 1800000000."),hookData:{description:"Hex-encoded hook call data; only data supported by the measured hook is accepted.",type:"string"}},required:["tokenId"]},dt={type:"object",properties:{version:{description:"Uniswap v4 PoolManager version.",type:"string",enum:["v4"]},tokenIds:{description:'Position NFT identifiers as decimal strings. Example: ["1", "2"].',type:"array",items:L()},includeZero:{description:"Include positions whose current liquidity is zero.",type:"boolean"}}};function kn(e){let n=e.poolKey&&typeof e.poolKey=="object"&&!Array.isArray(e.poolKey)?e.poolKey:e;for(let i of["currency0","currency1","fee","tickSpacing"])if(n[i]===void 0)throw new o(`Creating a pool needs the full poolKey (currency0, currency1, fee, tickSpacing, hooks); ${i} is missing. A poolId alone cannot describe a pool that does not exist yet.`)}function Pn(e,n,i){if(e.initialPrice!==void 0&&e.sqrtPriceX96!==void 0)throw new o("Provide initialPrice or sqrtPriceX96, not both.");if(e.sqrtPriceX96!==void 0){if(typeof e.sqrtPriceX96!="string"||!/^\d+$/.test(e.sqrtPriceX96))throw new o("sqrtPriceX96 must be a non-negative integer string.");return nn(BigInt(e.sqrtPriceX96))}return en(e.initialPrice,n,i)}async function ut(e,n,i){let r;try{r=await e.readContract({address:M,abi:X,functionName:"ownerOf",args:[n]})}catch(c){throw new o(`Could not verify owner of Uniswap v4 position #${n}. ${oe(c)}`)}if(w(r)!==w(i))throw new o(`Wallet ${w(i)} is not the owner of Uniswap v4 position #${n} (owned by ${w(r)}).`)}async function vn(e,n){let i=ye(n).toLowerCase(),r=new Map;for(let s of Oe)s.key.currency0.toLowerCase()===n.currency0.toLowerCase()&&s.key.currency1.toLowerCase()===n.currency1.toLowerCase()&&r.set(s.poolId.toLowerCase(),s.key);let c=[];for(let[s,t]of r){if(s===i||BigInt(await e.readContract({address:le,abi:fe,functionName:"getLiquidity",args:[s]}))===0n)continue;let a=await e.readContract({address:le,abi:fe,functionName:"getSlot0",args:[s]});BigInt(a[0])>0n&&c.push({label:`v4 fee ${t.fee} spacing ${t.tickSpacing} pool ${s}`,sqrtPriceX96:BigInt(a[0])})}return c}function xn(e,n,i,r,c,s){return e.unsignedTx({to:Vn.toLowerCase(),data:re({abi:Yn,functionName:"initialize",args:[{currency0:n.currency0.toLowerCase(),currency1:n.currency1.toLowerCase(),fee:n.fee,tickSpacing:n.tickSpacing,hooks:n.hooks.toLowerCase()},r]}),value:"0",chainId:y,description:`Create and initialize Uniswap v4 pool ${i} (${c.symbol}/${s.symbol}, fee ${n.fee}, tickSpacing ${n.tickSpacing}) at ${he(r,c.decimals,s.decimals)} ${s.symbol} per ${c.symbol}.`})}var pt=e=>({tools:[{name:"uniswap_add",inputSchema:rt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=t.tokenId===void 0?void 0:K(String(t.tokenId));if(a!==void 0&&a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=t.initialPrice!==void 0||t.sqrtPriceX96!==void 0;if(t.exactCaps!==void 0&&typeof t.exactCaps!="boolean")throw new o("exactCaps must be a boolean.");let l=t.exactCaps===!0;if(l&&(a!==void 0||p||t.amount0Max===void 0||t.amount1Max===void 0))throw new o("exactCaps is for v4 mints only: provide both amount0Max and amount1Max, without tokenId, initialPrice or sqrtPriceX96.");if(a!==void 0&&p)throw new o("initialPrice cannot be combined with tokenId.");if(a!==void 0&&(t.amount0Min!==void 0||t.amount1Min!==void 0||t.slippageBps!==void 0))throw new o("V4 mint encodes fixed liquidity and amount0Max/amount1Max; amount minima and slippageBps are not supported for minting.");if(t.amount0Min!==void 0||t.amount1Min!==void 0)throw new o(sn);let m=t.slippageBps===void 0?Number(me):t.slippageBps;if(typeof m!="number"||!Number.isInteger(m)||m<0||m>500)throw new o(sn);let f=BigInt(m),P=e.clientFor(y);p&&kn(t);let b,u,v,x;if(a!==void 0){if(t.tickLower!==void 0||t.tickUpper!==void 0||t.fullRange!==void 0)throw new o("An existing v4 position keeps its tick range; omit tickLower, tickUpper and fullRange when increasing.");await ut(P,a,d),{poolId:b,poolKey:u,tickLower:v,tickUpper:x}=await Pe(P,a,t)}else{({poolId:b,poolKey:u}=await Be(P,t));let q=et(u.tickSpacing);v=t.fullRange===!0&&t.tickLower===void 0?q.tickLower:Number(t.tickLower),x=t.fullRange===!0&&t.tickUpper===void 0?q.tickUpper:Number(t.tickUpper),nt(v,x,u.tickSpacing)}let[h,g]=await Promise.all([B(P,u.currency0,y),B(P,u.currency1,y)]),A=Z(t.amount0Max??t.amount0Desired,"amount0Max"),I=Z(t.amount1Max??t.amount1Desired,"amount1Max");if(A<=0n&&I<=0n||A>J||I>J)throw new o("Provide positive amount0Max/amount1Max within uint128.");let F=await P.readContract({address:le,abi:fe,functionName:"getSlot0",args:[b]}),_=BigInt(F[0]),j=Number(F[3]),C;if(p){if(_>0n)throw new o(`Pool ${b} already exists; remove initialPrice/sqrtPriceX96 to add liquidity at its current price.`);let q=Pn(t,h.decimals,g.decimals),V=Ue(q,await vn(P,u),t.acceptPriceDeviation===!0,h.decimals,g.decimals);C={sqrtPriceX96:q,note:V},_=q}else if(_<=0n)throw new o(`Pool ${b} is not initialized on StateView. To create it and add the first liquidity in one tool call with separately confirmed transactions, pass the full poolKey plus initialPrice (token1 per 1 token0, human units); to create it without liquidity use uniswap_create_pool.`);let E=t.liquidity!==void 0&&!l?Z(t.liquidity,"liquidity"):it({amount0:cn(A,f),amount1:cn(I,f),tickLower:v,tickUpper:x,sqrtPriceX96:_});if(E<=0n||E>J)throw new o("Position liquidity must be a positive integer within uint128.");let{amount0:ee,amount1:ne}=Cn({liquidity:E,tickLower:v,tickUpper:x,sqrtPriceX96:_,roundUp:!0});if(ee>A||ne>I)throw new o("Liquidity requires more tokens than amount0Max or amount1Max.");let W=l?A:dn(ee,A,f),Y=l?I:dn(ne,I,f),$=t.recipient!==void 0?String(t.recipient):d;if(T($),w($)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let U=await qn(P),O=await Ke(P,t.deadline,U.toString()),te=O<U+an?O:U+an,N=t.permit2Expiration===void 0?te:K(String(t.permit2Expiration));if(N<=U||N>te||N>An)throw new o("Permit2 expiration must be in the next 30 minutes and no later than the transaction deadline.");let ie=typeof t.hookData=="string"?t.hookData:"0x",Se=((q,V)=>{let G=C?[xn(e,u,b,C.sqrtPriceX96,h,g)]:[];if(!H(u.currency0)&&q>0n){let ae=u.currency0.toLowerCase();G.push(e.approval(ae,He.toLowerCase(),q.toString(),y)),G.push(mn(ae,M.toLowerCase(),q.toString(),N.toString(),y))}if(!H(u.currency1)&&V>0n){let ae=u.currency1.toLowerCase();G.push(e.approval(ae,He.toLowerCase(),V.toString(),y)),G.push(mn(ae,M.toLowerCase(),V.toString(),N.toString(),y))}let R={currency0:u.currency0.toLowerCase(),currency1:u.currency1.toLowerCase(),fee:u.fee,tickSpacing:u.tickSpacing,hooks:u.hooks.toLowerCase()},Le=S(jn,[R,v,x,E,q,V,$.toLowerCase(),ie]),$n=S(Wn,[R.currency0,R.currency1]),We=S(Gn,[k,$.toLowerCase()]),En=S(ge,[a??0n,E,q,V,ie]),_n=a===void 0?S(ue,["0x020d14",[Le,$n,We]]):S(ue,["0x00121214",[En,S(un,[R.currency0]),S(un,[R.currency1]),We]]),Un=re({abi:X,functionName:"modifyLiquidities",args:[_n,O]}),Dn=H(u.currency0)?q.toString():"0";return G.push(e.unsignedTx({to:M.toLowerCase(),data:Un,value:Dn,chainId:y,description:a!==void 0?`Increase Uniswap v4 position #${a} on pool ${b} (liquidity +${E}).`:`Mint Uniswap v4 position on pool ${b} (ticks [${v}, ${x}], liquidity ${E}).`})),G})(W,Y),we=await e.preview(Se,d),ze=(q,V)=>{let G=H(V)?ce:V.toLowerCase();return-q.changes.filter(R=>R.token.address.toLowerCase()===G).reduce((R,Le)=>R+BigInt(Le.amount),0n)},Ie=ze(we,u.currency0),Ce=ze(we,u.currency1);if(Ie<0n||Ce<0n||Ie>W||Ce>Y||Ie===0n&&Ce===0n&&a===void 0)throw new o("Invalid simulated v4 mint spend. Refresh the liquidity preview.");let Ln=Ne(we.changes,e.formatAmount),qe=ln(u,j),je=[...!H(u.currency0)&&W>0n?[h.symbol]:[],...!H(u.currency1)&&Y>0n?[g.symbol]:[]],Tn=Se.length,Mn=a===void 0?`This deposit takes ${Tn} approvals in a row: ${je.length?`let Permit2 use your ${je.join(" and ")}, let the Uniswap position manager use it through Permit2, then the deposit`:"the deposit"}. `:"",be=m>Number(me)?`You chose ${m/100}% room for price movement. Oak will approve up to ${e.formatAmount(W.toString(),h.decimals)} ${h.symbol} and ${e.formatAmount(Y.toString(),g.decimals)} ${g.symbol}, more than the expected ${e.formatAmount(ee.toString(),h.decimals)} and ${e.formatAmount(ne.toString(),g.decimals)}. Anything not used stays in your wallet, and any leftover permission is cancelled after the deposit.`:void 0;return{txs:Se,preview:we,poolId:b,poolKey:u,tickLower:v,tickUpper:x,liquidity:E.toString(),amount0Max:{token:h,amount:A.toString()},amount1Max:{token:g,amount:I.toString()},dynamicFee:qe.dynamicFee,swapsAreFree:qe.swapsAreFree,...a===void 0?{mintTerms:{amount0Max:W.toString(),amount1Max:Y.toString(),deadline:O.toString(),permit2Expiration:N.toString(),slippageBps:m.toString(),liquidity:E.toString()}}:{},...be?{warnings:[be]}:{},action:a!==void 0?"increase":C?"createAndMint":"mint",...a!==void 0?{tokenId:a.toString()}:{},...C?{poolCreated:!0,sqrtPriceX96:C.sqrtPriceX96.toString(),initialPrice:he(C.sqrtPriceX96,h.decimals,g.decimals),initialTick:_e(C.sqrtPriceX96),priceCheck:C.note}:{},summary:`${Mn}${a!==void 0?`Increase Uniswap v4 position #${a}`:C?"Create Uniswap v4 pool and add first liquidity":"Add Uniswap v4 liquidity"} (${E} L, ticks [${v}, ${x}]) on pool ${b}. Preview deltas: ${Ln.join(", ")||"none"}. A partial spend can leave ERC-20 and Permit2 allowances equal to grant minus spent, bounded by your caps. Use oak_cleanup_allowances to revoke remaining allowances. ${qe.feeNote}${be?` ${be}`:""}${C?` ${C.note}`:""}`}}},{name:"uniswap_collect",inputSchema:at,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),f=t.amount0Min!==void 0?Z(t.amount0Min,"amount0Min"):0n,P=t.amount1Min!==void 0?Z(t.amount1Min,"amount1Min"):0n;if(f>J||P>J)throw new o("amount0Min and amount1Min must fit in uint128.");let b=typeof t.hookData=="string"?t.hookData:"0x",{poolKey:u,poolId:v}=await Pe(p,a,t),[x,h]=await Promise.all([B(p,u.currency0,y),B(p,u.currency1,y)]),g=S(ge,[a,0n,f,P,b]),A=S(De,[u.currency0.toLowerCase(),u.currency1.toLowerCase(),l.toLowerCase()]),I=S(ue,["0x0111",[g,A]]),F=re({abi:X,functionName:"modifyLiquidities",args:[I,m]}),_=[e.unsignedTx({to:M.toLowerCase(),data:F,value:"0",chainId:y,description:`Collect Uniswap v4 fees from position #${a} to ${l}.`})],j=await e.preview(_,d),C=Ne(j.changes,e.formatAmount);return{txs:_,preview:j,tokenId:a.toString(),poolId:v,recipient:l,currencies:[x,h],summary:`Collect Uniswap v4 fees for position #${a} (actions 0x0111). Preview deltas: ${C.join(", ")||"0"}.`}}},{name:"uniswap_remove",inputSchema:ct,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=K(String(t.tokenId??""));if(a<=0n)throw new o("Provide a positive v4 position tokenId.");let p=e.clientFor(y),l=t.recipient!==void 0?String(t.recipient):d;if(T(l),w(l)!==w(d))throw new o("Uniswap recipient must be the signing wallet.");let m=await Ke(p,t.deadline,t.now),{poolKey:f,poolId:P}=await Pe(p,a,t),[b,u]=await Promise.all([B(p,f.currency0,y),B(p,f.currency1,y)]),v=t.slippageBps??Te;if(typeof v!="number")throw new o("Slippage must be an integer from 0 to 9999 bps.");Me("0",v);let x=typeof t.hookData=="string"?t.hookData:"0x",h=t.fullExit===!0||t.burn===!0||t.liquidity==="all";if(!h&&t.liquidity===void 0)throw new o('Provide a liquidity amount or explicitly choose liquidity "all" for a full exit.');let g=t.liquidity===void 0||t.liquidity==="all"?void 0:Z(t.liquidity,"liquidity");if(g!==void 0&&(g<0n||g===0n&&!h||g>J))throw new o("Provide positive liquidity within uint128 for v4 removal.");let A;try{A=BigInt(await p.readContract({address:M,abi:X,functionName:"getPositionLiquidity",args:[a]}))}catch($){throw new o(`Could not read v4 position liquidity. ${oe($)}`)}if(A<0n||A===0n&&!h||g!==void 0&&g>A)throw new o("Removal requires a nonempty position and cannot exceed its liquidity.");if(h&&g!==void 0&&g!==A)throw new o("A full burn must match the position liquidity; omit the amount when explicitly choosing all.");let I=h?"0x0311":"0x0111",F=($,U,O)=>{let te=h?S(Zn,[a,$,U,x]):S(ge,[a,g,$,U,x]),N=S(De,[f.currency0,f.currency1,O]);return e.unsignedTx({to:M.toLowerCase(),data:re({abi:X,functionName:"modifyLiquidities",args:[S(ue,[I,[te,N]]),m]}),value:"0",chainId:y,description:`${h?"Burn and exit":"Decrease"} Uniswap v4 position #${a} (${I}).`})},_=0n,j=0n;if(A>0n&&(t.amount0Min===void 0||t.amount1Min===void 0)){let $=e.unsignedTx({to:M.toLowerCase(),data:re({abi:X,functionName:"modifyLiquidities",args:[S(ue,["0x0111",[S(ge,[a,0n,0n,0n,x]),S(De,[f.currency0,f.currency1,M])]]),m]}),value:"0",chainId:y,description:"Simulation only: separate fees from removal principal."}),U=await e.preview([$,F(2n,2n,d)],d),O=te=>U.changes.reduce((N,ie)=>ie.token.chainId===y&&ie.token.address.toLowerCase()===te.address.toLowerCase()?N+BigInt(ie.amount):N,0n);if(_=O(b),j=O(u),_<0n||j<0n)throw new o("Removal simulation did not return the expected currencies.")}let C=($,U)=>{if($!==void 0&&Z($,U)!==0n)throw new o(`${U} must be zero for an empty position burn.`);return 0n},E=A===0n?C(t.amount0Min,"amount0Min"):hn(t.amount0Min,_,v,"amount0Min"),ee=A===0n?C(t.amount1Min,"amount1Min"):hn(t.amount1Min,j,v,"amount1Min"),ne=[F(E,ee,l)],W=await e.preview(ne,d),Y=Ne(W.changes,e.formatAmount);return{txs:ne,preview:W,action:I,tokenId:a.toString(),poolId:P,amount0Min:{token:b,amount:E.toString()},amount1Min:{token:u,amount:ee.toString()},summary:`${h?"Full exit":"Partial remove"} Uniswap v4 position #${a} (${I})${h?`; burns position #${a} at ${M}`:""}. Preview deltas: ${Y.join(", ")||"none"}.`}}},{name:"uniswap_list_positions",inputSchema:dt,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');let a=Array.isArray(t.tokenIds)?t.tokenIds:void 0,p=t.includeZero===!0,l=t.wallet===void 0?w(d):ot(t.wallet),m=await gn(e,l,{tokenIds:a,includeZero:p});return{version:"v4",positions:m,summary:`Found ${m.length} active Uniswap v4 position(s) for ${l}.`}}},{name:"uniswap_create_pool",inputSchema:st,async execute(t,d){if(T(d),t.version!==void 0&&t.version!=="v4")throw new o('Uniswap v4 part only handles version "v4".');kn(t);let a=e.clientFor(y),{poolId:p,poolKey:l}=await Be(a,t),[m,f]=await Promise.all([B(a,l.currency0,y),B(a,l.currency1,y)]),P=await a.readContract({address:le,abi:fe,functionName:"getSlot0",args:[p]});if(BigInt(P[0])>0n)throw new o(`Uniswap v4 pool ${p} already exists. Use uniswap_add to provide liquidity.`);let b=Pn(t,m.decimals,f.decimals),u=Ue(b,await vn(a,l),t.acceptPriceDeviation===!0,m.decimals,f.decimals),v=he(b,m.decimals,f.decimals),x=[xn(e,l,p,b,m,f)],h=await e.preview(x,d),g=ln(l,l.fee);return{txs:x,preview:h,poolId:p,poolKey:l,sqrtPriceX96:b.toString(),initialPrice:v,initialTick:_e(b),priceCheck:u,action:"createPool",summary:`${x[0].description} The pool starts empty: nothing trades until liquidity is added with uniswap_add. ${g.feeNote} ${u}`}}}],positions:t=>gn(e,t)}),St=pt;export{Vn as a,M as b,le as c,He as d,At as e,se as f,D as g,k as h,Xe as i,Fe as j,ve as k,Xn as l,Ve as m,Oe as n,Re as o,Sn as p,On as q,Rn as r,H as s,ye as t,In as u,ln as v,ke as w,et as x,nt as y,mn as z,tt as A,Cn as B,it as C,Ne as D,bn as E,B as F,Pe as G,gn as H,rt as I,st as J,at as K,ct as L,dt as M,vn as N,pt as O,St as P};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as me}from"./3PHJUFU2.js";import{a as fe}from"./DCGNVMKG.js";import{a as Y}from"./LQSPWRHN.js";import{a as _,b as E}from"./Z7FGEWO2.js";import{a as I}from"./VVAM3EAK.js";import{a as ue}from"./P4UQGWCP.js";import{a as R}from"./43LI5NKJ.js";import{b as de,c as le}from"./SCG5HWMN.js";import{a as re,b as Z,c as z}from"./5HCXZWUH.js";import{q as ie,s as P,t as ce}from"./MQ5F2VOK.js";import{b as w,c as U,d as F,e as oe,j as M,k as ae,t as D}from"./TI727O2H.js";import{a as h}from"./XSD5NL7J.js";import{a as T,b as X,c as j}from"./JXOEJPJ4.js";import{decodeFunctionResult as De,encodeFunctionData as Pe,erc20Abi as Q,getAddress as p,isAddress as G,parseAbi as V}from"viem";var J="https://api.robinhood.com/rhj/assets",xe={address:_,symbol:"ETH",decimals:18,chainId:w},q={address:p(ae),symbol:"USDG",decimals:oe,chainId:w},ee={address:p(M[4663].tokens.WETH.address),symbol:"WETH",decimals:18,chainId:w},ge={address:p(M[4663].meridian.CollateralToken_USDe.address),symbol:"USDe",decimals:18,chainId:w};function $(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function K(e,n=w,s={}){let t=Array.isArray(e)?e:$(e)&&Array.isArray(e.assets)?e.assets:void 0;if(!t)throw new h("Official stock asset list response is malformed.");let o=new Map,c=new Map;if(t.length>1e4)throw new h("Official stock asset list exceeds the lookup limit.");for(let a of t){if(!$(a))continue;let r=a;if(typeof r.tokenSymbol!="string"||!r.tokenSymbol.trim()||!Array.isArray(r.deployments))continue;if(r.deployments.length>100)throw new h("Official stock deployment list exceeds the lookup limit.");let d=r.tokenSymbol;if(!/^[A-Za-z0-9.$_-]{1,32}$/.test(d))throw new h(`Invalid official stock ticker ${T(d)}.`);if(r.tokenDecimals!==void 0&&(typeof r.tokenDecimals!="number"||!Number.isInteger(r.tokenDecimals)||r.tokenDecimals<0||r.tokenDecimals>255))throw new h("Official stock asset has invalid token decimals.");let l=typeof r.tokenDecimals=="number"&&Number.isInteger(r.tokenDecimals)&&r.tokenDecimals>=0&&r.tokenDecimals<=255?r.tokenDecimals:18;for(let k of r.deployments){if(!$(k))continue;let y=k;if(y.chainId!==n)continue;if(typeof y.contractAddress!="string"||!G(y.contractAddress,{strict:!1}))throw new h("Official stock deployment has an invalid contract address.");let b=p(y.contractAddress),m=b.toLowerCase(),S=d.toUpperCase(),u=c.get(S);if(!s.allowAmbiguousSymbols&&u&&u!==m)throw new h(`Ambiguous official stock ticker ${T(d)} across multiple addresses.`);let i=o.get(m);if(i&&(i.symbol!==d||i.decimals!==l))throw new h(`Conflicting official stock identity at ${b}.`);c.set(S,m),o.set(m,{address:b,symbol:d,decimals:l,chainId:n,...s.includeNames&&typeof r.tokenName=="string"&&r.tokenName.trim()?{name:r.tokenName.trim()}:{}})}}return[...o.values()]}function Re(e,n){if(typeof e.address!="string"||!G(e.address,{strict:!1}))return!1;let s=e.chainId??w,t=e.address.toLowerCase();return n.some(o=>o.chainId===s&&o.address.toLowerCase()===t&&o.symbol===e.symbol)}function W(e,n){R(e.address);let s=e.chainId??w,t=p(e.address),o=t.toLowerCase(),c=O(e.symbol),a=n.find(d=>d.chainId===s&&d.address.toLowerCase()===o),r=n.find(d=>d.chainId===s&&O(d.symbol)===c);if(a){if(e.symbol!==a.symbol)throw new h(`Token at ${t} does not match official stock ticker ${T(a.symbol)} (received ${T(e.symbol)}).`);if(e.decimals!==void 0&&e.decimals!==a.decimals)throw new h(`Token ${T(a.symbol)} at ${t} does not match official decimals ${a.decimals}.`);return a}if(r)throw new h(`Token symbol ${T(e.symbol)} at ${t} does not match the official stock contract address ${r.address}.`);return{address:t,symbol:e.symbol.trim(),decimals:e.decimals??18,chainId:s}}var Ee=["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"],te=new WeakMap,ke=new WeakMap,Ae=3e4,he=Object.freeze([]),x;function ot(){if(!x)return he;let e=Date.now()-x.started;return e>=0&&e<Ae?x.tokens:he}var ne=new WeakMap;function H(e,n){return(ne.get(e)??P)(n)}async function Se(e){let n=e?.http??de(),s=e?.url??J,t=e?.chainId??w,o=z(n),c=ke.get(o);c||(c=new re(Ae),ke.set(o,c));let{value:a,started:r}=await H(n,()=>c.read(`${t}:${s}`,async()=>{let l=await P(y=>le(o,s,{method:"GET",signal:y},b=>$(b)||Array.isArray(b))),k=K(l,t,{allowAmbiguousSymbols:!0});if(t===w&&k.length===0)throw new h("Official stock asset list has no mainnet deployments; retry when the list is available.");return l})),d=K(a,t,e);if(t===w&&s===J&&(!x||r>=x.started||Date.now()<x.started)&&(x={started:r,tokens:Object.freeze(K(a,t,{allowAmbiguousSymbols:!0}).map(l=>Object.freeze(l)))}),t===w){let l=te.get(o);l||(l=new Set,te.set(o,l));for(let k of d)l.add(O(k.symbol))}return d}var Me=V(["function aggregate3((address target, bool allowFailure, bytes callData)[] calls) payable returns ((bool success, bytes returnData)[] returnData)"]);function ye(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 o=`${typeof t.shortMessage=="string"?t.shortMessage:""} ${typeof t.message=="string"?t.message:""}`;if(/returned no data \("0x"\)|Cannot decode zero data/i.test(o))return!0;n=t.cause}return!1}function _e(e){return e instanceof h?/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 Be(e,n,s){if(typeof e.getCode=="function")try{let t=await e.getCode({address:n});return!t||t==="0x"}catch{return ye(s)}return ye(s)}async function be(e,n,s){if(n.length===0)return[];let t=await Promise.allSettled(n.map(o=>e.readContract({address:o.address,abi:Q,functionName:"balanceOf",args:[s]})));if(t.every(o=>o.status==="rejected")&&t[0]?.status==="rejected"&&_e(t[0].reason))throw t[0].reason;return t.map(o=>{if(o.status!=="fulfilled"||o.value===void 0||o.value===null)return{ok:!1};try{let c=typeof o.value=="bigint"?o.value:BigInt(o.value);return c>=0n?{ok:!0,amount:c}:{ok:!1}}catch{return{ok:!1}}})}async function Ce(e,n,s,t){if(s.length===0)return[];let o=ie(n,e);if(!o)return be(e,s,t);let c=s.map(r=>({target:r.address,allowFailure:!0,callData:Pe({abi:Q,functionName:"balanceOf",args:[t]})})),a;try{a=await e.readContract({address:o,abi:Me,functionName:"aggregate3",args:[c]})}catch(r){if(await Be(e,o,r))return be(e,s,t);throw r}if(!Array.isArray(a)||a.length!==s.length)throw new h("Multicall3 aggregate3 returned an invalid result list.");return a.map(r=>{let d=r,l=Array.isArray(d)?d[0]:d?.success,k=Array.isArray(d)?d[1]:d?.returnData;if(!l||typeof k!="string"||k==="0x")return{ok:!1};try{let y=De({abi:Q,functionName:"balanceOf",data:k}),b=typeof y=="bigint"?y:BigInt(y);return b>=0n?{ok:!0,amount:b}:{ok:!1}}catch{return{ok:!1}}})}async function at(e,n={}){R(e);let s=p(e),t=n.chainId??w,o=n.client??ce(n.rpcUrl,t),c=[];if(n.stockTokens?c=[...n.stockTokens]:n.stockAssetsPayload!==void 0?c=K(n.stockAssetsPayload,t):n.includeStockTokens!==!1&&t!==U&&(c=await Se({http:n.http,url:n.stockAssetsUrl,chainId:t})),n.tokens)for(let i of n.tokens)W(i,c);let a=t===w?[q,ee,ge,...n.oakTokenAddress||process.env.OAK_TOKEN_ADDRESS?[{address:p(n.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS),symbol:"OAK",decimals:F,chainId:t}]:[]]:t===U?[{...q,address:p(D.testnet.usdg),chainId:t},{...ee,address:p(D.testnet.weth),chainId:t},...n.oakTokenAddress?[{address:p(n.oakTokenAddress),symbol:"OAK",decimals:F,chainId:t}]:[]]:[],r=t===w&&n.includePoolTokens!==!1?ue.vaults.flatMap(i=>[{address:p(i.tokenAddress),symbol:p(i.tokenAddress),decimals:i.tokenDecimals,chainId:t},{address:p(i.earnContractAddress),symbol:p(i.earnContractAddress),decimals:18,chainId:t}]):[],d=new Set(r.map(i=>i.address.toLowerCase())),l=[],k=new Set;for(let i of[...a,...c,...n.tokens??[],...r]){if(i.chainId!==t||E(i.address)===_)continue;let f=W(i,c),A=f.address.toLowerCase();k.has(A)||(k.add(A),l.push(f))}let[y,b]=await Promise.all([o.getBalance({address:s}),Ce(o,t,l,s)]),m=[],S={address:_,symbol:"ETH",decimals:18,chainId:t};(y>0n||n.includeZero)&&m.push({token:S,amount:y.toString()});for(let i=0;i<l.length;i++){let f=l[i],A=a.some(L=>v(L.address,f.address))||c.some(L=>v(L.address,f.address))?f.symbol:T(f.symbol),g=b[i]??{ok:!1};if(!g.ok){m.push({token:{address:f.address,symbol:A,decimals:f.decimals,chainId:f.chainId},amount:"unavailable"});continue}let C=g.amount;if(C>0n&&d.has(f.address.toLowerCase()))try{let[L,N]=await Promise.all([I(o,t,f.address,"symbol"),I(o,t,f.address,"decimals")]);A=T(L),f.decimals=N}catch{}(C>0n||n.includeZero)&&m.push({token:{address:f.address,symbol:A,decimals:f.decimals,chainId:f.chainId},amount:C.toString()})}let u="Outside token discovery is disabled; no receipt time window was scanned. The local journal can include older receipts.";if(n.includeReceivedTokens===!0){let i=await Ue(s,{client:o});if(u=i.notice,!i.incomplete)try{let f=i.addresses.filter(g=>!k.has(g.toLowerCase())),A=await Fe(s,f,{client:o,chainId:t});m.push(...A.map(g=>({...g,verified:!1,note:"Received from outside Oak's lists; not verified."})))}catch{u+=" Discovery is incomplete: outside balances or token metadata are unavailable; known balances are retained."}}return m.length||m.push({token:S,amount:y.toString()}),m[0]={...m[0],discoveryNotice:u},m}async function Ue(e,n){R(e);let s,t,o="the last 10,000 blocks (approximately 17 minutes at 100 ms per block; UTC boundaries unavailable)",c=()=>`Outside token discovery covers only ERC-20 receipts in ${o}; older holdings may be missing. The local journal can include older receipts.`;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(k=>P(()=>n.client.getBlock({blockNumber:k}),3e3)));o=`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 a=V(["event Transfer(address indexed from,address indexed to,uint256 value)"])[0],r=await P(()=>n.client.getLogs({event:a,args:{to:p(e)},fromBlock:s,toBlock:t,strict:!0}),3e3),d=[...new Set(r.filter(l=>!l.removed&&typeof l.args.value=="bigint"&&l.args.value>0n).map(l=>p(l.address)))];return d.length>200?{addresses:[],fromBlock:s,toBlock:t,incomplete:!0,notice:`${c()} Discovery is incomplete: the 200-contract limit was exceeded; known balances are retained.`}:{addresses:d,fromBlock:s,toBlock:t,incomplete:!1,notice:c()}}catch{return{addresses:[],fromBlock:s,toBlock:t,incomplete:!0,notice:`${c()} Discovery is incomplete: RPC receipt reads are unavailable; known balances are retained. Retry balances when RPC logs are available.`}}}async function Fe(e,n,s){if(R(e),n.length>1e4)throw new h("Journal token discovery exceeds the balance lookup limit.");let t=[...new Set(n.map(a=>(R(a),p(a))))].filter(a=>E(a)!==_).map(a=>({address:a,symbol:a,decimals:0,chainId:s.chainId})),o=await Ce(s.client,s.chainId,t,p(e)),c=t.flatMap((a,r)=>{let d=o[r];return d.ok&&d.amount===0n?[]:[{token:a,amount:d.ok?d.amount.toString():"unavailable"}]});return Promise.all(c.map(async({token:a,amount:r})=>{let[d,l]=await Promise.all([I(s.client,s.chainId,a.address,"symbol"),I(s.client,s.chainId,a.address,"decimals").catch(()=>{throw new h(`Token decimals are unavailable for journal-received token ${a.address}; retry balances when RPC metadata is available.`)})]);return{token:{...a,symbol:T(d),decimals:l},amount:r}}))}var v=(e,n)=>e.toLowerCase()===n.toLowerCase(),O=e=>j(e.normalize("NFKC")).toLowerCase().replace(/[^\p{L}\p{N}]/gu,""),pe=e=>j(e.normalize("NFKC")).toLowerCase().match(/[\p{L}\p{N}]+/gu)?.join(" ")??"";function Oe(e){let n=e.context.network??"mainnet",{chainId:s,usdg:t,weth:o}=D[n],c=(a,r,d)=>({...a,address:E(p(a.address)),name:r,kind:d,verified:!0,source:"Oak fixed addresses",warnings:[]});return[c({...xe,chainId:s},"Ether","native"),c({...q,address:t,chainId:s},"Global Dollar","stablecoin"),c({...ee,address:o,chainId:s},"Wrapped Ether","wrapped"),...n==="mainnet"?[c(ge,"USDe","stablecoin")]:[],...e.oakTokenAddress?[c({address:e.oakTokenAddress,symbol:"OAK",decimals:F,chainId:s},"Oak","oak")]:[]]}async function ve(e){if(e.context.network==="testnet")return[];let n=e.officialStockTokens??await Se({http:e.context.http,includeNames:!0,allowAmbiguousSymbols:!0});return n.filter(s=>Re(s,n)).map(s=>({...s,name:s.name??s.symbol,kind:"official_stock",verified:!0,source:J,warnings:[],identityNote:"Official Robinhood stock token: this address matches Robinhood's published list. The quoted name is text from that list."}))}async function se(e,n,s=!0){let{chainId:t}=D[n.context.network??"mainnet"],o=n.context.clientFor(t);if(await o.getChainId()!==t)throw new h(`Token lookup requires Robinhood Chain ${t}.`);let[c,a,r]=await Promise.all([H(o,()=>I(o,t,e,"name",n.blockNumber)).catch(d=>{if(s)throw d;return""}),H(o,()=>I(o,t,e,"symbol",n.blockNumber)),H(o,()=>I(o,t,e,"decimals",n.blockNumber))]);if(typeof c!="string"||s&&!c.trim()||typeof a!="string"||!a.trim()||!Number.isInteger(r)||r<0||r>255)throw new h("The contract returned invalid token metadata.");return{address:p(e),name:c||a,symbol:a,decimals:r,chainId:t}}async function Te(e,n){let s=await n.context.clientFor(w).readContract({address:M[w].clanker.factory.address,abi:V(["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 $e(e,n){let s=n.context.clientFor(w),t=M[w].poolsTrade,o=[t.instantLaunchStrategyFeesOn.address,t.instantLaunchStrategyFeesOff.address],c=V(["event TokenLaunched(bytes32 indexed poolId,address indexed token,address indexed feeSplitter,(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey)"])[0],a=await s.getBlockNumber(),r=new Set,d=0,l=0;for(let k=63127652n;k<=a;k+=10000000n){if(++d>Le)throw new h("Token origin scan limit reached.");let y=k+9999999n>a?a:k+9999999n,b=await s.getLogs({address:o,event:c,args:{token:e},fromBlock:k,toBlock:y,strict:!0});for(let m of b){if(m.removed||!o.some(u=>v(u,m.address))||!m.args.token||!v(m.args.token,e)||!m.transactionHash||r.has(m.transactionHash))continue;if(r.add(m.transactionHash),++l>20)throw new h("Token origin receipt limit reached.");let S=await s.getTransactionReceipt({hash:m.transactionHash});if(fe(S).some(u=>v(u.token,e)))return p(S.from)}}}var Le=5,Ke=100,He=500,We=3e4;function Ne(e){let n=Date.now()+We,s=0,t=new Map,o=a=>{let r=n-Date.now();if(r<=0)throw new h("Token lookup time budget reached; results are partial.");return P(a,Math.min(1e4,r))},c=Z((a,r)=>o(async d=>{let l=await e.context.http(a,{...r,signal:d});return new Proxy(l,{get(k,y){if(y==="json")return()=>o(()=>k.json());let b=Reflect.get(k,y,k);return typeof b=="function"?b.bind(k):b}})}),e.context.http);return ne.set(c,o),{...e,context:{...e.context,http:c,clientFor:a=>{if(!t.has(a)){let r=e.context.clientFor(a),d=l=>{if(++s>He)throw new h("Token lookup RPC budget reached; results are partial.");return o(l)};t.set(a,Z(new Proxy(r,{get(l,k){let y=Reflect.get(l,k);return typeof y!="function"?y:(...b)=>d(()=>y.apply(l,b))}}),r)),ne.set(t.get(a),d)}return t.get(a)}}}}function we(e){return e.source==="Oak fixed addresses"?e:{...e,symbol:T(e.symbol),name:T(e.name)}}async function rt(e,n){if(n=Ne(n),typeof e!="string"||e.length>256||!O(e))throw new h("Provide a token name, symbol or address to find_token.");let s=O(e),t=G(e.trim(),{strict:!1})?E(p(e.trim())):void 0,{chainId:o}=D[n.context.network??"mainnet"],c=[],a=Oe(n),r=!1;try{a.push(...await ve(n))}catch{r=!0,c.push("The official stock list is unavailable; results are partial and stock identities and lookalikes could not be checked.")}let d=u=>t?v(u.address,t):O(u.symbol).includes(s)||O(u.name).includes(s),l=a.filter(d),k=[],y=(u,i)=>[u.symbol,u.name??""].some(f=>[i.symbol,i.name].some(A=>{let g=O(f),C=O(A),L=pe(f),N=pe(A);return!!g&&!!C&&(g===C||(C.length>=3?g.includes(C):` ${L} `.includes(` ${N} `)))})),b=(u,i={})=>{if(k.some(g=>v(g.address,u.address)))return;let f=[`Token ${T(u.symbol)} at ${u.address} is an unverified ${i.launchpad?"launchpad token":"token"}. Use its address, not its name or symbol.`];(X(u.symbol)||X(u.name)||a.some(g=>!v(g.address,u.address)&&y(u,g)))&&f.push(`Lookalike warning: ${T(u.symbol)} at ${u.address} resembles a verified token's name or symbol.`);let A={...u,...i,kind:i.launchpad?"launchpad":"erc20",verified:!1,source:i.launchpad?`${i.launchpad} origin and on-chain metadata; not a verified token`:"On-chain metadata only",warnings:f};k.push(A),c.push(...f)};if(t&&!l.length){let u=await se(t,n),i={};if(o===w){try{await Te(t,n)&&(i.launchpad="clanker")}catch{c.push("Clanker origin lookup was unavailable for this address.")}if(i.launchpad==="clanker")try{let A=(await Y(n.context,{q:t,limit:20})).tokens.find(g=>v(g.contract_address,t));A&&(i.creator=p(A.msg_sender),i.creatorSource="Clanker indexer msg_sender")}catch{c.push("Clanker creator lookup is unavailable.")}else try{let f=await me(n.context,t);i.launchpad="pons",i.creator=p(f.creator),i.creatorSource="Pons factory deployer"}catch{c.push("Pons launch origin could not be confirmed for this address.")}if(!i.launchpad)try{let f=await $e(t,n);f&&(i.launchpad="pools.trade",i.creator=f,i.creatorSource="Launch transaction sender; may be a relayer")}catch{r=!0,c.push("pools.trade launch receipt lookup is unavailable; origin results are partial.")}}b(u,i)}else if(!t&&o===w){let u=new Set,i=new Set,f,A=0,g=0;try{do{if(++A>Le)throw new h("Token search page limit reached.");let C=await Y(n.context,{q:e.trim(),limit:20,...f?{cursor:f}:{}});for(let L of C.tokens){if(++g>Ke)throw new h("Token candidate limit reached.");let N=p(L.contract_address);if(!(i.has(N)||a.some(B=>v(B.address,N)))){i.add(N);try{let B=await se(N,n);if(!d(B))continue;let Ie=await Te(N,n)?{launchpad:"clanker",creator:p(L.msg_sender),creatorSource:"Clanker indexer msg_sender"}:{};b(B,Ie)}catch{r=!0,c.push(`Could not read Clanker candidate ${N}; it was omitted from these partial results.`)}}}if(C.cursor&&u.has(C.cursor))throw new h("The Clanker indexer repeated a pagination cursor.");C.cursor&&u.add(C.cursor),f=C.cursor??void 0}while(f)}catch{r=!0,c.push("Clanker name search is unavailable, incomplete or reached its scan limit; results are partial.")}c.push("Pons and pools.trade require a token address; name search does not cover those launchpads.")}o===U&&c.push("Testnet lookup covers pinned tokens and explicit token addresses; stock and launchpad discovery are unavailable.");let m=u=>[...new Map(u.map(i=>[i.address.toLowerCase(),i])).values()],S=m([...l,...k]);for(let u of S)if(S.some(i=>!v(i.address,u.address)&&(O(u.symbol)===O(i.symbol)||O(u.name)===O(i.name)))){let i=`Duplicate warning: several tokens share the symbol or name of ${u.address}. Choose the intended address; do not guess from the name.`;u.warnings.push(i),c.push(i)}return l.length>1&&c.push("Several verified tokens match this search, including possible substring matches. Choose an exact address; the search does not select a quote token."),{query:T(e.trim()),chainId:o,partial:r,matches:m(l).map(we),unverified:m(k).map(we),warnings:c}}async function it(e,n){if(typeof e!="string"||!e.trim())throw new h("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 h("Use an exact ASCII verified symbol or token address; use find_token to look it up.");let s=e,t=G(s,{strict:!1})?E(p(s)):void 0,o=Oe(n),c=t&&o.find(b=>v(b.address,t));if(c)return c;let a=s.toUpperCase()==="$OAK"?"OAK":s.toUpperCase(),r=!t&&o.find(b=>b.symbol.toUpperCase()===a),d=[],l=!1;try{d=await ve(n)}catch{if(r)return r;if(!t)throw new h("The official stock list is unavailable; stock symbols cannot be checked. Use find_token and try again when the list is reachable.");l=!0}if(t){let b=d.find(u=>v(u.address,t));if(b)return n.tokenMetadata&&W(n.tokenMetadata,d),{...b,name:T(b.name)};let m=n.tokenMetadata??await n.readMetadata?.(t);if(m&&(!v(m.address,t)||m.chainId!==D[n.context.network??"mainnet"].chainId))throw new h("Token metadata does not match the requested address and chain.");if(m&&(typeof m.symbol!="string"||!m.symbol.trim()||!Number.isInteger(m.decimals)||m.decimals<0||m.decimals>255))throw new h("The contract returned invalid token metadata.");let S=m?{...m,name:m.symbol}:await se(t,Ne(n),!1);if(l){let u=O(S.symbol),i=te.get(z(n.context.http));if(Ee.some(f=>O(f)===u)||i?.has(u))throw new h("The official stock list is unavailable; this address claims a stock ticker that cannot be checked. Try again when the list is reachable.")}return W(S,d),{...S,symbol:T(S.symbol),name:T(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.",...l?["The official stock list is unavailable; stock identity could not be verified."]:[]]}}let k=[...o,...d].filter(b=>b.symbol.toUpperCase()===a);if(k.length!==1)throw new h(`Token symbol ${T(s)} is ${k.length?"ambiguous":"unverified"}; use find_token and choose an explicit address.`);let y=k[0];if(y.kind==="official_stock"&&s!==y.symbol)throw new h(`Use the exact official stock ticker ${T(y.symbol)}; case variants are refused.`);return y.source==="Oak fixed addresses"?y:{...y,name:T(y.name)}}export{J as a,xe as b,q as c,ee as d,ge as e,K as f,Re as g,W as h,ot as i,Se as j,Me as k,at as l,Ue as m,Fe as n,rt as o,it as p};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{m as z}from"./WSILNJS2.js";import{a as U,e as j,h as Q,i as Y,k as J}from"./KHOUBQJK.js";import{c as A,e as $}from"./JFC2QCMW.js";import{a as V}from"./Y2QADJOB.js";import{b as Z,e as O,p as ee}from"./4J245N3F.js";import{a as y,b as P}from"./Z7FGEWO2.js";import{a as h}from"./LIUXNOLP.js";import{a as X,b as N}from"./ZTX4WT62.js";import{a as v}from"./VVAM3EAK.js";import{a as B}from"./SPJCSEKP.js";import{b as F}from"./SCG5HWMN.js";import{b as E}from"./IX3GZMTM.js";import{t as T}from"./MQ5F2VOK.js";import{b as m,c as l,d as G,e as D,j as g,k as q,l as W,q as K}from"./TI727O2H.js";import{a as c}from"./XSD5NL7J.js";import{a as k,b as R}from"./JXOEJPJ4.js";import{getAddress as f,isAddress as ne,parseAbi as se}from"viem";var te=[{inputs:[],name:"available",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ethUsdE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"liquidityUsdgE6",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"phase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"priceSigner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"signer",type:"address"}],name:"setPriceSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"spotOakPerEthE18",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"supplyNet",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"syncPhase",outputs:[{internalType:"uint8",name:"",type:"uint8"}],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"wallet",type:"address"},{internalType:"uint256",name:"oakPerEthE18",type:"uint256"},{internalType:"uint64",name:"timestamp",type:"uint64"},{internalType:"bytes32",name:"nonce",type:"bytes32"}],internalType:"struct PriceNote",name:"n",type:"tuple"},{internalType:"bytes",name:"sig",type:"bytes"},{internalType:"address",name:"boundWallet",type:"address"}],name:"verifyNote",outputs:[{internalType:"uint256",name:"oakPerEthE18",type:"uint256"}],stateMutability:"view",type:"function"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"signer",type:"address"}],name:"PriceSignerSet",type:"event"},{inputs:[],name:"NotReady",type:"error"},{inputs:[],name:"NoteBadSignature",type:"error"},{inputs:[],name:"NoteExpired",type:"error"},{inputs:[],name:"NoteNotYetValid",type:"error"},{inputs:[{internalType:"uint256",name:"spot",type:"uint256"},{internalType:"uint256",name:"note",type:"uint256"}],name:"NoteOutsideGuard",type:"error"},{inputs:[],name:"NoteWrongWallet",type:"error"},{inputs:[{internalType:"address",name:"source",type:"address"}],name:"OracleUnreadable",type:"error"}];function Be(n){return"source"in n&&n.source==="pool-spot-estimate"?void 0:n}var M=300,ye="1000000000000000000",oe=f(g[m].tokens.USDG.address),de=f(g[l].deployments.test_USDG.address),_=f(g[m].tokens.WETH.address),I=f(g[l].deployments.test_WETH.address),L=f(X.chop);function ce(n){return n.chainId===m&&n.address.toLowerCase()===L.toLowerCase()}function ue(n){let e=n.address.toLowerCase();return n.chainId===m?e===oe.toLowerCase():n.chainId===l?e===de.toLowerCase():!1}function me(n){return n.chainId!==m&&n.chainId!==l?!1:P(n.address)===y}function le(n){let e=n.address.toLowerCase();return n.chainId===m?e===_.toLowerCase():n.chainId===l?e===I.toLowerCase():!1}function we(n){return me(n)||le(n)}var fe=-887272,be=887272,ge=(1n<<256n)-1n,Ee=se(["function observe(uint32[] secondsAgos) view returns (int56[] tickCumulatives, uint160[] secondsPerLiquidityCumulativeX128s)","function slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint8 feeProtocol, bool unlocked)"]),re=se(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Te=1n<<192n;async function Se(n,e){let t=f(N.stateView),s=N.poolId,[a,i]=await Promise.all([n.readContract({address:t,abi:re,functionName:"getSlot0",args:[s],blockNumber:e}),n.readContract({address:t,abi:re,functionName:"getLiquidity",args:[s],blockNumber:e})]),o=a[0],r=Number(a[1]);if(o<=0n||i<=0n||!Number.isInteger(r)||r<fe||r>be)throw new c("The pinned Uniswap v4 WETH/CHOP pool has no active liquidity, and the only other route is a near-empty pool.");return{numerator:Te,denominator:o*o}}function H(n,e){if(typeof n=="bigint")return n;if(typeof n=="number"){if(!Number.isSafeInteger(n))throw new c(`Invalid ${e} timestamp.`);return BigInt(n)}if(typeof n=="string"&&/^-?\d+$/.test(n.trim()))return BigInt(n.trim());throw new c(`Invalid ${e} timestamp.`)}function Fe(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){try{return p(n,e,t),!0}catch{return!1}}function p(n,e=BigInt(Math.floor(Date.now()/1e3)),t=M){if(!Number.isInteger(t)||t<0)throw new c("Maximum price age must be a non-negative integer.");let s=H(n,"price"),a=H(e,"current");if(s<=0n)throw new c("Price timestamp must be positive.");if(s>a)throw new c("Price timestamp is in the future.");let i=a-s;if(i>BigInt(t))throw new c(`Price is stale: age ${i}s exceeds ${t}s.`);return s.toString()}function he(n){if(!Number.isInteger(n)||n<fe||n>be)throw new c(`Tick ${n} is outside valid Uniswap bounds.`);let e=BigInt(n<0?-n:n),t=(e&0x1n)!==0n?0xfffcb933bd6fad37aa2d162d1a594001n:0x100000000000000000000000000000000n;return(e&0x2n)!==0n&&(t=t*0xfff97272373d413259a46990580e213an>>128n),(e&0x4n)!==0n&&(t=t*0xfff2e50f5f656932ef12357cf3c7fdccn>>128n),(e&0x8n)!==0n&&(t=t*0xffe5caca7e10e4e61c3624eaa0941cd0n>>128n),(e&0x10n)!==0n&&(t=t*0xffcb9843d60f6159c9db58835c926644n>>128n),(e&0x20n)!==0n&&(t=t*0xff973b41fa98c081472e6896dfb254c0n>>128n),(e&0x40n)!==0n&&(t=t*0xff2ea16466c96a3843ec78b326b52861n>>128n),(e&0x80n)!==0n&&(t=t*0xfe5dee046a99a2a811c461f1969c3053n>>128n),(e&0x100n)!==0n&&(t=t*0xfcbe86c7900a88aedcffc83b479aa3a4n>>128n),(e&0x200n)!==0n&&(t=t*0xf987a7253ac413176f2b074cf7815e54n>>128n),(e&0x400n)!==0n&&(t=t*0xf3392b0822b70005940c7a398e4b70f3n>>128n),(e&0x800n)!==0n&&(t=t*0xe7159475a2c29b7443b29c7fa6e889d9n>>128n),(e&0x1000n)!==0n&&(t=t*0xd097f3bdfd2022b8845ad8f792aa5825n>>128n),(e&0x2000n)!==0n&&(t=t*0xa9f746462d870fdf8a65dc1f90e061e5n>>128n),(e&0x4000n)!==0n&&(t=t*0x70d869a156d2a1b890bb3df62baf32f7n>>128n),(e&0x8000n)!==0n&&(t=t*0x31be135f97d08fd981231505542fcfa6n>>128n),(e&0x10000n)!==0n&&(t=t*0x9aa508b5b7a84e1c677de54f3e99bc9n>>128n),(e&0x20000n)!==0n&&(t=t*0x5d6af8dedb81196699c329225ee604n>>128n),(e&0x40000n)!==0n&&(t=t*0x2216e584f5fa1ea926041bedfe98n>>128n),(e&0x80000n)!==0n&&(t=t*0x48a170391f7dc42444e8fa2n>>128n),n>0&&(t=ge/t),(t>>32n)+(t%(1n<<32n)===0n?0n:1n)}async function ie(n,e,t,s){let a=async()=>{throw new c("Price identity resolution is read-only.")},i=B({network:e===l?"testnet":"mainnet",clientFor:r=>t.client??T(t.rpcUrl,r),http:t.http??F(),preview:a,quoteSwap:a,buildSwap:a}),o=await ee(n,{context:i,oakTokenAddress:t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS,officialStockTokens:t.officialStockTokens,tokenMetadata:s,blockNumber:t.blockNumber,readMetadata:async r=>{let d=t.client??T(t.rpcUrl,e),[u,b]=await Promise.all([v(d,e,r,"symbol",t.blockNumber),v(d,e,r,"decimals",t.blockNumber)]);return{address:r,symbol:u,decimals:b,chainId:e}}});return{address:o.address,symbol:o.kind==="erc20"&&s?s.symbol:o.symbol,decimals:o.decimals,chainId:o.chainId}}async function Pe(n,e,t){if(typeof n=="object"&&n!==null){let r=n.chainId??e,d=P(n.address)===y?y:f(n.address),u={address:d,symbol:n.symbol,decimals:n.decimals,chainId:r};return ue(u)?{address:d,symbol:"USDG",decimals:D,chainId:r}:me(u)?{address:y,symbol:"ETH",decimals:18,chainId:r}:le(u)?{address:d,symbol:"WETH",decimals:18,chainId:r}:ce(u)?{address:d,symbol:"CHOP",decimals:18,chainId:r}:ie(u.address,r,t,u)}let s=n.trim(),a=s.toUpperCase(),i=s.toLowerCase();if(a==="ETH"||ne(s,{strict:!1})&&P(s)===y)return{...Z,chainId:e};if(a==="WETH"||e===m&&i===_.toLowerCase()||e===l&&i===I.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical WETH address configured for chain ${e}.`);return{address:e===l?I:_,symbol:"WETH",decimals:18,chainId:e}}if(a==="USDG"||e===m&&i===q.toLowerCase()||e===l&&i===W.toLowerCase()){if(e!==m&&e!==l)throw new c(`No canonical USDG address configured for chain ${e}.`);return{address:e===l?de:oe,symbol:"USDG",decimals:D,chainId:e}}if(e===m&&(a==="USDE"||i===O.address.toLowerCase()))return{...O,chainId:e};if(e===m&&(a==="CHOP"||i===L.toLowerCase()))return{address:L,symbol:"CHOP",decimals:18,chainId:e};let o=t.oakTokenAddress??process.env.OAK_TOKEN_ADDRESS;if(a==="OAK"||o&&s.toLowerCase()===o.toLowerCase()){if(!o&&!ne(s,{strict:!1}))throw new c("OAK token address is required to price OAK.");return{address:f(o??s),symbol:"OAK",decimals:G,chainId:e}}return ie(n,e,t)}async function x(n,e,t){if(e)return(await n.readContract({address:e,abi:te,functionName:"ethUsdE18",blockNumber:t})).toString();let a=(await n.readContract({address:f(K),abi:Ee,functionName:"observe",args:[[U,0]],blockNumber:t}))[0];if(!a||a.length<2)throw new c("ETH/USDG pool observation returned insufficient tick cumulatives.");let i=Q(a[0],a[1],U),o=he(i);return Y(o)}async function S(n,e,t,s){if(n.timestamp!==void 0)return p(n.timestamp,t(),s);if(e&&typeof e.getBlock=="function"){let i=await h(e,n.blockNumber);return p(i.timestamp,t(),s)}let a=t();return p(a,a,s)}function ae(n){if(n.startsWith("untrusted "))try{let e=JSON.parse(n.slice(10));if(typeof e=="string"&&k(e)===n)return n}catch{}return k(n)}async function Xe(n,e={}){let t=e.chainId??m,s=e.maxAgeSeconds??M,a=()=>e.now!==void 0?H(e.now,"current"):BigInt(Math.floor(Date.now()/1e3)),i=await Pe(n,t,e);if((R(i.symbol)||i.symbol.length>256)&&(i.symbol=ae(i.symbol)),e.trades){let r=await S(e,e.client,a,s),d=J(e.trades,{now:a(),windowStart:e.windowStart,windowEnd:e.windowEnd});if(e.spotOakPerEthE18!==void 0&&!z(d,e.spotOakPerEthE18))throw new c("30-minute average is outside the 50% spot guard band.");let u=e.ethUsdE18!==void 0?e.ethUsdE18.toString():await x(e.client??T(e.rpcUrl,t),e.oracleAddress);return{token:i,usdE18:j(u,d),timestamp:r}}if(e.usdE18!==void 0){let r=await S(e,e.client,a,s),d=E(e.usdE18.toString());if(d<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:d.toString(),timestamp:r}}if(e.resolver){let r=await e.resolver(i),d=p(r.timestamp,a(),s),u=E(r.usdE18);if(u<=0n)throw new c("USD price must be positive.");return{token:i,usdE18:u.toString(),timestamp:d,...r.source==="pool-spot-estimate"?{source:r.source,sourceLabel:A}:{}}}let o=e.client??T(e.rpcUrl,t);if(ue(i)){let r=await S(e,o,a,s);return{token:i,usdE18:ye,timestamp:r}}if(we(i)){let r=await S(e,o,a,s),d=await x(o,e.oracleAddress,e.blockNumber);return{token:i,usdE18:d,timestamp:r}}if(ce(i)){let r=e.timestamp===void 0&&o&&typeof o.getBlock=="function"?await h(o,e.blockNumber):void 0,d=r?p(r.timestamp,a(),s):await S(e,o,a,s);if(r&&r.number===null)throw new c("CHOP reference requires a mined block.");let u=r?.number??e.blockNumber,[b,C]=await Promise.all([Se(o,u),e.ethUsdE18!==void 0?Promise.resolve(e.ethUsdE18.toString()):x(o,e.oracleAddress,u)]),w=E(C)*b.numerator/b.denominator;if(w<=0n)throw new c("CHOP USD reference price must be positive.");return{token:i,usdE18:w.toString(),timestamp:d}}if(i.chainId===m)try{let r=await h(o,e.blockNumber),d=p(r.timestamp,a(),s);if(r.number===null)throw new c("Pons reference requires a mined block.");let u=await $(i,o,r.number);if(u!==void 0&&u>0n)return{token:i,usdE18:u.toString(),timestamp:d,source:"pool-spot-estimate",sourceLabel:A};let[b,C]=await Promise.all([V(i,o,r.number),x(o,e.oracleAddress,r.number)]),w=E(C)*b.numerator/b.denominator;if(w<=0n)throw new c("Pons USD reference price must be positive.");return{token:i,usdE18:w.toString(),timestamp:d}}catch{}throw new c(`Oak has no fresh on-chain trade price for ${ae(i.symbol)}, so it shows no price. balances and positions show a labeled estimate where one exists; an estimate is not a quote.`)}export{Be as a,M as b,ye as c,ce as d,ue as e,me as f,le as g,we as h,Se as i,Fe as j,p as k,he as l,x as m,Xe as n};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as T,f as re,g as B,i as ae,j as O}from"./PXUML7HJ.js";import{F as I,a as ee,b as oe,c as _,f as L,h as S,m as te,n as y,r as z,s as se,t as ne,v as ie}from"./4E7FJQLL.js";import{a as U}from"./YEIM6BZQ.js";import{f as W,g as Q}from"./P7C3TYI4.js";import{a as K}from"./Z7FGEWO2.js";import{a as J}from"./43LI5NKJ.js";import{g as E}from"./NWNYJ26T.js";import{b as k,n as Z}from"./TI727O2H.js";import{a as b,b as F,e as Y}from"./XSD5NL7J.js";import{decodeAbiParameters as we,getAddress as v,pad as de,parseAbi as fe,parseAbiParameters as Pe,toEventSelector as be,toHex as ce,zeroAddress as pe}from"viem";var ke=be("Initialize(bytes32,address,address,uint24,int24,address,uint160,int24)"),ye=Pe("uint24 fee, int24 tickSpacing, address hooks, uint160 sqrtPriceX96, int24 tick"),Ae=10000000n,Ie=10000n,me=25,X=200,R=16,ve=3e3,Ce=500,Se=500n,q=100,$=fe(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96, int24 tick, uint24 protocolFee, uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),_e=fe(["function poolKeys(bytes25 poolId) view returns (address currency0, address currency1, uint24 fee, int24 tickSpacing, address hooks)"]);function Le(o){let e=o.trim().toLowerCase();return e==="eth"||e==="native"||e===pe||e===K.toLowerCase()}function le(o,e){if(o!=null){if(typeof o!="string")throw new b(`${e} must be a token address, or "eth" for native ETH.`);return Le(o)?{eth:!0}:(J(o),{eth:!1,address:v(o)})}}var he=(o,e)=>BigInt(o)<BigInt(e)?-1:BigInt(o)>BigInt(e)?1:0;function x(o){return{address:o.address,symbol:o.symbol,decimals:o.decimals}}async function ge(o,e,r,i,a){let[t,s,f]=await Promise.all([o.readContract({address:e,abi:O,functionName:"slot0"}),o.readContract({address:e,abi:O,functionName:"liquidity"}),o.readContract({address:e,abi:O,functionName:"tickSpacing"})]),n=BigInt(t[0]);return{version:"v3",id:e,feePercent:U(a),highFee:a>=5e4,token0:x(r),token1:x(i),fee:a,tickSpacing:Number(f),initialized:n>0n,liquidity:BigInt(s).toString(),sqrtPriceX96:n.toString(),tick:Number(t[1]),price:n>0n?W(n,r.decimals,i.decimals):"0",addSupported:!0}}async function H(o,e,r){let i=r??ne(e),[a,t]=await Promise.all([I(o,e.currency0,k),I(o,e.currency1,k)]),[s,f]=await Promise.all([o.readContract({address:_,abi:$,functionName:"getSlot0",args:[i]}),o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[i]})]),n=BigInt(s[0]),w=ie(e,Number(s[3]));return{version:"v4",id:i,feePercent:U((e.fee&8388608)!==0?Number(s[3]):e.fee),highFee:((e.fee&8388608)!==0?Number(s[3]):e.fee)>=5e4,token0:x(a),token1:x(t),fee:e.fee,tickSpacing:e.tickSpacing,hooks:v(e.hooks),initialized:n>0n,liquidity:BigInt(f).toString(),sqrtPriceX96:n.toString(),tick:Number(s[1]),price:n>0n?W(n,a.decimals,t.decimals):"0",addSupported:z.has(e.hooks.toLowerCase()),feeNote:w.feeNote,...z.has(e.hooks.toLowerCase())?{}:{note:e.hooks.toLowerCase()===Z.toLowerCase()?new te(se(e.currency0)?e.currency1:void 0).message:`Hook ${v(e.hooks)} is not one Oak has measured, so uniswap_add will refuse this pool.`}}}async function Ne(o,e,r,i){let a=await o.getBlockNumber(),t=[],s=new Set,f=!1,n=Ae;for(let d=a;;){let u=d+1n>n?d-n+1n:0n,l;try{l=await o.request({method:"eth_getLogs",params:[{address:ee.toLowerCase(),topics:[ke,null,e?de(e):null,r?de(r):null],fromBlock:ce(u),toBlock:ce(d)}]})}catch(p){if(F(p,-32601)||n<=Ie)throw p;n/=2n;continue}if(!Array.isArray(l))throw new b("Invalid v4 Initialize log response.");let P=[];for(let p of l){if(!Array.isArray(p.topics)||p.topics.length!==4||typeof p.data!="string")throw new b("Invalid v4 Initialize log.");let[A,C,N]=we(ye,p.data),D={currency0:v(`0x${p.topics[2].slice(-40)}`),currency1:v(`0x${p.topics[3].slice(-40)}`),fee:Number(A),tickSpacing:Number(C),hooks:v(N)};P.push({key:D,id:p.topics[1]}),s.add(p.topics[1].toLowerCase())}if(t.push(P),u===0n)break;if(s.size>=i){f=!0;break}d=u-1n}let w=new Map;for(let d of t.reverse())for(let u of d)w.set(u.id.toLowerCase(),u);return{pools:[...w.values()],cut:f}}async function Ee(o,e,r){let i=e.eth?T.weth:e.address,a=r.eth?T.weth:r.address;if(i===a)return[];let[t,s]=he(i,a)<0?[i,a]:[a,i],[f,n]=await Promise.all([I(o,t,k),I(o,s,k)]),w=[];for(let d of Object.keys(re).map(Number)){let u=v(String(await o.readContract({address:T.factory,abi:ae,functionName:"getPool",args:[t,s,d]})));u!==pe&&w.push(await ge(o,u,f,n,d))}return w}function ue(o){return o?o.eth?[S,L]:o.address===L?[L,S]:[o.address]:null}async function Te(o,e){let r=new Map;if(e.length===0)return r;if(typeof o.multicall=="function"&&o.chain?.contracts?.multicall3)try{return(await o.multicall({allowFailure:!0,contracts:e.map(a=>({address:_,abi:$,functionName:"getLiquidity",args:[a]}))})).forEach((a,t)=>r.set(e[t].toLowerCase(),a.status==="success"?BigInt(a.result):0n)),r}catch{}for(let i=0;i<e.length;i+=R)(await Promise.allSettled(e.slice(i,i+R).map(async t=>BigInt(await o.readContract({address:_,abi:$,functionName:"getLiquidity",args:[t]}))))).forEach((t,s)=>r.set(e[i+s].toLowerCase(),t.status==="fulfilled"?t.value:0n));return r}async function Be(o,e,r,i){let a=ue(e),t=ue(r),s=new Map,f=(c,h)=>{if(c&&h){if(c===h)return;let[m,g]=he(c,h)<0?[c,h]:[h,c];s.set(`${m}/${g}`,[m,g])}else if(c||h){let m=c??h;s.set(`${m}/*0`,[m,null]),s.set(`${m}/*1`,[null,m])}};for(let c of a??[null])for(let h of t??[null])f(c,h);let n=new Map;for(let c of y)[...s.values()].some(([m,g])=>(!m||E(c.key.currency0,m))&&(!g||E(c.key.currency1,g)))&&n.set(c.poolId.toLowerCase(),{key:c.key,id:c.poolId});let d=typeof o.multicall=="function"&&!!o.chain?.contracts?.multicall3?ve:Ce,u=!1;for(let[c,h]of s.values()){let m=await Ne(o,c,h,d+y.length);u||=m.cut;for(let g of m.pools)n.set(g.id.toLowerCase(),g)}let l=new Set(y.map(c=>c.poolId.toLowerCase())),P=[...n.values()],p=P.filter(c=>l.has(c.id.toLowerCase())),A=P.filter(c=>!l.has(c.id.toLowerCase())).reverse();(A.length>d||u)&&i.push(`${u?"At least ":""}${A.length} v4 pools match; only the newest ${d} non-measured ones were considered. Pass both tokens, or a poolId, to narrow.`);let C=A.slice(0,d),N=await Te(o,C.map(c=>c.id)),D=C.sort((c,h)=>{let m=N.get(c.id.toLowerCase())??0n,g=N.get(h.id.toLowerCase())??0n;return m===g?0:m<g?1:-1}),V=[...p,...D];V.length>X&&i.push(`${V.length} v4 pools match; full state was read for Oak's measured pools plus the deepest of the rest (${X} total). Pass both tokens, or a poolId, to narrow.`);let G=[],M=0,j=V.slice(0,X);for(let c=0;c<j.length;c+=R){let h=await Promise.allSettled(j.slice(c,c+R).map(({key:m,id:g})=>H(o,m,g)));for(let m of h)m.status==="fulfilled"?G.push(m.value):M++}return M>0&&i.push(`${M} pool(s) were skipped because a token or pool state could not be read.`),G}async function Oe(o,e){let r=y.find(n=>E(n.poolId,e));if(r)return H(o,r.key,r.poolId);let[i,a,t,s,f]=await o.readContract({address:oe,abi:_e,functionName:"poolKeys",args:[e.slice(0,52)]});if(i===S&&a===S&&Number(s)===0)throw new b(`No Uniswap v4 pool ${e} is known to the PositionManager (no position was ever minted in it, or it is not initialized). Search by token pair instead.`);return H(o,{currency0:i,currency1:a,fee:Number(t),tickSpacing:Number(s),hooks:f},e)}function qe(o){let e=new Set([...y.map(t=>t.poolId.toLowerCase()),...B.map(t=>t.address.toLowerCase())]),r=new Set([S,K.toLowerCase(),L.toLowerCase()]),i=t=>r.has(t.address.toLowerCase())?"ETH":t.address.toLowerCase(),a=new Map;for(let t of o.filter(s=>s.initialized&&BigInt(s.liquidity)>0n)){let s=`${i(t.token0)}/${i(t.token1)}`;a.set(s,[...a.get(s)??[],t])}for(let t of a.values()){let s=t.filter(d=>e.has(d.id.toLowerCase()));if(s.length===0&&t.length<3)continue;let n=(s.length>0?s:t).map(d=>BigInt(d.sqrtPriceX96)).sort((d,u)=>d<u?-1:d>u?1:0),w=n[Math.floor(n.length/2)];for(let d of t){if(e.has(d.id.toLowerCase()))continue;let u=Q(BigInt(d.sqrtPriceX96),w);u>Se&&(d.priceOutlierBps=Number(u),d.note=`${d.note?`${d.note} `:""}Price differs ${u} bps from the ${s.length>0?"Oak-measured":"median"} price for this pair; do not treat this pool as the market price.`)}}}async function Re(o,e){let r=e.version;if(r!==void 0&&r!=="v3"&&r!=="v4")throw new b('version must be "v3" or "v4"; omit it to search both.');let i=e.limit===void 0?me:Number(e.limit);if(!Number.isInteger(i)||i<1||i>q)throw new b(`limit must be an integer from 1 to ${q}.`);let a=le(e.tokenA,"tokenA"),t=le(e.tokenB,"tokenB");if(!a&&t)throw new b("Provide tokenA when searching by token; tokenB narrows the search to a pair.");let s=o.clientFor(k),f=[],n=[];if(e.poolId!==void 0){if(typeof e.poolId!="string"||!/^0x[0-9a-fA-F]{64}$/.test(e.poolId))throw new b("poolId must be a 32-byte hex v4 poolId. For v3 search by tokenA/tokenB.");n=[await Oe(s,e.poolId)]}else if(a){if(r!=="v4"&&(t?n.push(...await Ee(s,a,t)):f.push("v3 pools are looked up per pair; pass tokenB to include them.")),r!=="v3")try{n.push(...await Be(s,a,t,f))}catch(l){throw F(l,-32601)?l:new b(`Could not search v4 pools. ${Y(l)}`)}}else{f.push("No token filter given: showing the pools Oak has measured. Pass tokenA (and tokenB) to search the chain for every pool of a pair.");let l=await Promise.all(B.map(async p=>{let[A,C]=await Promise.all([I(s,p.token0,k),I(s,p.token1,k)]);return ge(s,p.address,A,C,p.fee)})),P=await Promise.all(y.map(p=>H(s,p.key,p.poolId)));n=[...r==="v4"?[]:l,...r==="v3"?[]:P]}qe(n);let w=new Set([...y.map(l=>l.poolId.toLowerCase()),...B.map(l=>l.address.toLowerCase())]),d=0;n=n.filter(l=>!l.highFee||w.has(l.id.toLowerCase())?!0:e.includeHighFeePools===!0?(l.note=`Do not trade here: ${l.feePercent} fee.${l.note?` ${l.note}`:""}`,!0):(d++,!1)),d&&f.push(`${d} pools with fees of 5% or more were left out. To see them, pass includeHighFeePools: true.`),n.sort((l,P)=>BigInt(P.liquidity)>BigInt(l.liquidity)?1:BigInt(P.liquidity)<BigInt(l.liquidity)?-1:0),n.length>i&&f.push(`Showing the ${i} deepest of ${n.length} pools found; raise limit (max ${q}) to see more.`),n=n.slice(0,i);let u=n.filter(l=>l.initialized&&BigInt(l.liquidity)>0n).length;return n.length===0&&d===0&&f.push("No pool exists for this pair. Create one with uniswap_create_pool, or create it and add the first liquidity together with uniswap_add plus initialPrice."),{pools:n,notes:f,summary:`Found ${n.length} Uniswap pool(s), ${u} with active liquidity. price is token1 per 1 token0.`}}function ze(o){return{tools:[{name:"uniswap_pools",inputSchema:{type:"object",description:"Read-only pool discovery on Robinhood Chain (4663): every Uniswap v3 and v4 pool for a token pair with fee, tick spacing, hook, liquidity and price, or one v4 pool by poolId. No tokens given: the measured pools.",properties:{version:{type:"string",enum:["v3","v4"],description:"Limit to one version; omit to search both."},tokenA:{type:"string",description:'Token address, or "eth" for native ETH (searches v3 WETH and v4 native/WETH pools).'},tokenB:{type:"string",description:"Second token of the pair. Required for v3 lookups."},poolId:{type:"string",description:"32-byte v4 poolId to inspect."},includeHighFeePools:{description:"Include pools above the usual fee threshold in discovery.",type:"boolean"},limit:{description:"Maximum number of results to return, within the stated bounds.",type:"integer",minimum:1,maximum:q,default:me}}},execute:async r=>Re(o,r)}]}}export{Re as a,ze as b};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var a={partner:"Factor is an official Oak partner. Factor's own team runs its product and contracts; Oak didn't build them and doesn't run them.",trust:"Factor's desk contract has no owner, and its rules are fixed in its code. Factor's website and API are run by Factor and can lag the chain.",fees:"An advance costs a 1% fee taken from the advance, paid to Factor's burn pot contract. A settled job pays Factor's 2% job fee from the agent's payout.",half:"At most half of a job's price can be advanced before delivery.",poolBar:"If a job you drew on isn't delivered within 12 hours after its due time, anyone can refund it, and this wallet can never draw from Factor's pool again.",decline:"You can decline a job only before drawing on it. A rejected job settles at half, with no appeal.",payLink:"A signed pay link can't be revoked; anyone holding it can pay it until it expires.",names:"Names are first come, and a fixed-price application can't be withdrawn.",privateWork:"Your work text stays on this computer; only its fingerprint (a hash) goes on chain.",publicWork:"Your work text will be public on Factor's job page and can't be edited.",walletCode:"This wallet has contract code, so Factor would hold its payouts until they are collected, which Oak can't do yet. Nothing was sent.",compute:"Oak doesn't send compute advances: that ETH goes to Factor's gateway as off-chain credit Oak can't check. Nothing was sent.",lineAccount:"This wallet uses a Factor credit line, which Oak doesn't support yet. Nothing was sent.",offers:"This Factor job takes offers, which Oak can't send yet. Nothing was signed.",deskOnly:"Desk figures only; jobs and limits held through a Factor credit line are not shown.",stateMismatch:"Factor's site names a different desk than the one Oak checked on chain. Nothing was signed or sent.",stateUnavailable:"Factor's site isn't answering, so Oak can't date this message. Nothing was signed.",apiLabel:"Factor API (can lag the chain)"},e={factor_sign_up:`Register this wallet as a Factor agent on Robinhood Chain, then sign its public profile with a name and description. Gas for registration; identity, active plan and human confirmation required. ${a.partner} ${a.trust} ${a.names}`,factor_create_pay_link:`Sign a pay link for a fixed-price ETH job on Robinhood Chain. Price is a wei string; expiry is 1-30 days. No payment now; a customer pays later. Identity, active plan and human confirmation required. ${a.payLink} ${a.half} ${a.fees}`,factor_apply_to_job:`Sign an application for a fixed-price Factor open job. Identity, active plan and human confirmation required. ${a.offers} ${a.names}`,factor_draw:`Draw an early or pool advance to this wallet on Robinhood Chain, with amount in integer wei. Identity, active plan and human confirmation required. ${a.half} ${a.fees} ${a.poolBar} ${a.compute}`,factor_deliver:`Deliver a work fingerprint on Robinhood Chain. Show defaults to false; public posting follows successful delivery only when requested. Identity, active plan and human confirmation required. ${a.privateWork} With show true: ${a.publicWork}`,factor_decline:`Decline a Factor job on Robinhood Chain and return its price to the customer. Identity, active plan and human confirmation required. ${a.decline}`,factor_job:`Read a Factor job and its public details from the ${a.apiLabel}. API data does not authorize an action. No identity or plan required.`,factor_can_draw:`Read the desk's early and pool advance amounts in wei on Robinhood Chain; these amounts share the same half-price cap. No identity or plan required. ${a.deskOnly}`,factor_my_jobs:`Read at most 50 Factor jobs for this wallet as agent or customer from the ${a.apiLabel}. No identity or plan required. ${a.deskOnly}`,factor_open_jobs:`Read at most 25 Factor open-job listings from the ${a.apiLabel}. Filter by this wallet or verified owners when requested. No identity or plan required.`,factor_open_job:`Read a Factor open-job listing and public application details from the ${a.apiLabel}. No identity or plan required.`};export{a,e as b};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as s}from"./ZTX4WT62.js";import{formatUnits as c}from"viem";var r="Oak x Chop. Chop's own team runs its product and contracts; Oak didn't build them and doesn't run them.",i="Chop's upgrade key can replace log code without a timelock.",u="Chop's unwrap has no on-chain minimum output. Oak checks the simulated net output, but the contract itself will not stop a worse result if state moves before inclusion.",d="Farming pairs tokens 50/50 with impermanent loss and pays in $CHOP, which can fall in price or be paused by Chop. Stake and newly earned rewards can be locked for 10 minutes.",y=[r,i,u,d],g="Wrapping $OAK moves it out of your wallet. Chop's log contract holds the underlying token; unwrap the log to receive its share, subject to Chop's fees and contract risks.",k="Oak checks that CHOP actually reached your wallet; a successful transaction alone does not prove a payout.",p=e=>(e.bond+e.debond)/100;function m(e){return`Wrap fee ${e.fees.bond/100}%; unwrap fee ${e.fees.debond/100}%. A short round trip loses about ${p(e.fees)}%. Caller exemptions and rounding can change the actual fee.`}function $(e){return[r,i,m(e),u,d,...e.underlying.address.toLowerCase()===s.oak.toLowerCase()?[g]:[],...e.drift.length?[`Warning: Chop code changed since Oak checked it (${e.drift.join(", ")}). New wraps and farms are refused; this exit uses the changed code.`]:[]].join(`
|
|
2
|
-
`)}function f(e){let o=e.underlying.symbol;return[`A log is a wrapped version of one token. You hand in ${o} and receive a log token that stays worth a share of the ${o} the log holds.`,"You can earn two ways: the log's backing can grow from other people's trading fees, and you can farm the log for CHOP rewards. Neither is a promised rate.",`Getting in and out costs about ${p(e.fees)}% together: the wrap fee plus the unwrap fee. Other fees set by the log can also apply.`,"The biggest risk: Chop's team holds a key that can replace the log's code at any time, with no waiting period."].join(" ")}function C(e,o,n,t){let a=o.usdEstimate===null?`price unavailable: ${o.estimateReason}`:`$${o.usdEstimate}, estimate, not a quote`,l=n.usdEstimate===null?"The pool's full USD depth has price unavailable; each reserve shows its amount and available estimate.":`The pool holds about $${n.usdEstimate} (estimate, not a quote).`,h=t.pct===null?`A rough $100 price move is unavailable: ${t.reason}.`:`A rough $100 trade using ${t.inputToken.symbol} to buy the log would move its price about ${t.pct}%.`;return[f(e),`This farm's whole CHOP reward pot is about ${o.humanAmount} CHOP (${a}). Oak can't read a reward rate, so it shows no yield.`,l,h,t.assumptions].join(" ")}var x=e=>`You hold 0 ${e}, so there is nothing to unwrap. Unwrapping needs a balance of that log. Nothing was signed.`;function v(e,o,n){let t=a=>c(a,e.decimals);return`You asked to unwrap ${t(o)} ${e.symbol} but hold ${t(n)} ${e.symbol}. Ask for ${t(n)} or less ("${n}" in base units).`}export{r as a,i as b,u as c,d,y as e,g as f,k as g,p as h,m as i,$ as j,f as k,C as l,x as m,v as n};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{f as L,k as r,l as $}from"./MIKQWF6Q.js";import{a as I,e as c,h as v}from"./LEHBRAZX.js";import{j as h,k as p}from"./2GXHYI23.js";async function M(k,b,d={},O){I(b);let o=new AbortController,C=()=>o.abort(),l=()=>c(o.signal);c(d.signal),d.signal?.addEventListener("abort",C,{once:!0});let u=[];try{let f=await L(k,O,o.signal);l();let w=k.clientFor(4663),S=await v(w,o.signal),T=Array.from({length:Math.ceil(f.logs.length/r)},(t,n)=>f.logs.slice(n*r,(n+1)*r));return await Promise.all(T.map(async(t,n)=>{l(),await $(w,t,b,S,o.signal,(e,y)=>{if(l(),BigInt(e.logTokens.amount)===0n&&BigInt(e.stakedLp.amount)===0n&&BigInt(e.pendingChop.amount)===0n&&BigInt(e.claimableChop.amount)===0n)return;let a=t[y],m=BigInt(e.pendingChop.amount),B=BigInt(e.claimableChop.amount),g=B<=m,s=e.rewardsPaused?0n:B,i={principal:[],debt:[],rewards:[],backing:[],coverage:g?{complete:!0}:{complete:!1,reason:"Chop reward reads disagree."}};if(BigInt(e.logTokens.amount)>0n&&i.backing.push(p({...e.net,source:"chop.redemption.net",heldAs:e.logTokens.token.address,measuredAtBlock:e.measuredAtBlock})),BigInt(e.stakedLp.amount)>0n&&i.backing.push(p({token:a.underlying,amount:null,source:"chop.stakedLp",heldAs:e.stakedLp.token.address,measuredAtBlock:e.measuredAtBlock,unknownReason:"Staked log tokens are not redeemed in this read; unstake to see their redemption."})),g){let A={tool:"chop_harvest",args:{log:a.log.address}},P=m-s;P>0n&&i.rewards.push(h("unpaid",{token:e.pendingChop.token,amount:P.toString(),source:"chop.getUnpaid",measuredAtBlock:e.measuredAtBlock,claim:A})),s>0n&&i.rewards.push(h("claimable",{token:e.claimableChop.token,amount:s.toString(),source:"chop.getClaimable",measuredAtBlock:e.measuredAtBlock,claim:A}))}let E=g?`unpaid CHOP ${m-s} base units; claimable CHOP ${s} base units${e.rewardsPaused?"; rewards are paused":""}.`:"Chop reward reads disagree.";u[n*r+y]=[{module:"chop",id:`4663:${a.log.address}`,chainId:4663,assets:[e.logTokens,e.stakedLp,e.pendingChop],economics:i,description:`Chop log held: ${e.logTokens.amount} base units; redeemable net underlying ${e.net.amount} base units (${a.underlying.address}, decimals ${a.underlying.decimals}); staked LP ${e.stakedLp.amount} base units; ${E}`,oakNotice:e.warnings}]})}).map(t=>t.catch(n=>{throw o.abort(),n}))),[...u.flat(),{module:"chop",id:"4663:coverage",chainId:4663,assets:[],incomplete:!0,description:"Chop positions cover currently verified registry logs only. Delisted or unverified log holdings are not included."}]}catch{return o.abort(),c(d.signal),[...u.flat(),{module:"chop",id:"4663:coverage",chainId:4663,assets:[],incomplete:!0,description:"Chop positions are incomplete because a chain read is unavailable. Please try again."}]}finally{d.signal?.removeEventListener("abort",C)}}export{M as a};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{d as F,e as M}from"./MIKQWF6Q.js";import{a as y,b as x,c,f as $,j as L,l as S,m as O,n as U}from"./LEHBRAZX.js";import{a as N}from"./K6D6SDIG.js";import{g as H,j as R}from"./DHX3Q5RV.js";import{a as r}from"./ZTX4WT62.js";import{c as q}from"./43LI5NKJ.js";import{g as _}from"./NWNYJ26T.js";import{a as h}from"./XSD5NL7J.js";import{encodeFunctionData as W}from"viem";var j={chop_wrap:["log","underlying","amount","minLogOut"],chop_unwrap:["log","amount","quotedNet"],chop_farm:["log","amount","pairedAmount","minPaired","minStakedLp","slippageBps","deadline"],chop_unfarm:["log","amount","minLogOut","minPairedOut","deadline"],chop_harvest:["log"]};function z(l,o){if(Object.keys(l).some(n=>!o.includes(n)))throw new h("Unexpected Chop argument.");if(o.some(n=>l[n]===void 0))throw new h("Provide every required Chop input.")}async function V(l,o,n){let d=c(o),p=await l.getBlock({blockNumber:BigInt(n.measuredAtBlock)});if(p.number!==BigInt(n.measuredAtBlock)||d<=x(p.timestamp)||d>p.timestamp+1200n)throw new h("Chop deadline must be in the next 20 minutes.");return d}async function D(l,o,n,d){if(z(n,j[o]),y(d),l.network==="testnet")throw new h("Chop requires chain 4663.");let p=y(n.log),u=l.clientFor(4663),i=await S(u,p,o==="chop_wrap"||o==="chop_farm"?"enter":"exit"),s=BigInt(i.measuredAtBlock),f=[],g=[],C=(e,t,a)=>{f.push(q(e.address,t,a.toString(),4663)),g.push(l.approval(e.address,t,a.toString(),4663))},P=(e,t,a)=>{let m={to:e,data:W({abi:N,functionName:t,args:a}),value:"0",chainId:4663,description:`${o} on verified log ${p}.`,...o==="chop_harvest"?{gasLimit:"1000000"}:{}};f.push(m),g.push({...l.unsignedTx(m),...m.gasLimit===void 0?{}:{gasLimit:m.gasLimit}})},A=[],v=(e,t,a=!0)=>A.push({token:e,min:-t,max:a?-t:-1n}),w=(e,t)=>A.push({token:e,min:t}),T=async(e,t)=>{if(x(await $(u,e.address,"balanceOf",[d],s))<t)throw new h("This wallet does not hold enough tokens for the Chop action.")},k;if(o==="chop_wrap"){let e=c(n.amount),t=c(n.minLogOut);if(!_(y(n.underlying),i.underlying.address))throw new h("The underlying token does not match the verified Chop log.");await T(i.underlying,e),C(i.underlying,p,e),P(p,"bond",[i.underlying.address,e,t]),v(i.underlying,e,!1),w(i.log,t),k=`Wrap at most ${e} underlying base units; on-chain minimum ${t} log base units.`}else if(o==="chop_unwrap"){let e=c(n.amount),t=c(n.quotedNet);await T(i.log,e);let a=await M(u,i,d,e);if(BigInt(a.net.amount)<t)throw new h("Chop unwrap no longer meets the quoted net amount. Request a fresh quote.");let m=F(i,e);f.push(m),g.push(l.unsignedTx(m)),v(i.log,e),w(i.underlying,t),k=`Unwrap ${e} log base units; preview must return at least quoted ${t} underlying base units.`}else if(o==="chop_farm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.pairedAmount),a=c(n.minPaired),m=c(n.minStakedLp),I=await V(u,n.deadline,i),b=n.slippageBps;if(typeof b!="number"||!Number.isInteger(b)||b<0||b>1e3||b%10!==0||a>t)throw new h("Chop LP slippage must be 0\u20131000 basis points in multiples of 10; the paired minimum cannot exceed its input.");await Promise.all([T(i.log,e),T(i.paired,t)]),C(i.log,r.helper.address,e),C(i.paired,r.helper.address,t),P(r.helper.address,"addLPAndStake",[p,e,i.paired.address,t,a,BigInt(b/10),I]),v(i.log,e,!1),A.push({token:i.paired,min:-t,max:-a}),w(i.staking,m),k=`Farm up to ${e} log + ${t} paired base units; slippage ${b} bps; deadline ${I}. Staked LP minimum ${m} is checked in simulation; two-sided token minimums from slippage are enforced on chain. Paired consumption must also meet ${a} base units in the preview. This tool does not zap; the helper's paired minimum alone has no on-chain effect for a direct pair.`}else if(o==="chop_unfarm"){await L(u,r.helper,s);let e=c(n.amount),t=c(n.minLogOut),a=c(n.minPairedOut),m=await V(u,n.deadline,i);if(x(await $(u,i.staking.address,"withdrawableStake",[d],s))<e)throw new h("Chop stake is still locked or too small. Wait at least 10 minutes after staking.");C(i.staking,r.helper.address,e),P(r.helper.address,"unstakeAndRemoveLP",[p,e,t,a,m]),v(i.staking,e),w(i.log,t),w(i.paired,a),k=`Unfarm ${e} staked LP base units; on-chain minimums ${t} log and ${a} paired base units; deadline ${m}.`}else{if(await L(u,r.whitelist,s),await $(u,r.whitelist.address,"paused",[r.chop],s)!==!1)throw new h("Chop rewards are paused or their pause state is unavailable.");let e=x(await $(u,i.rewards,"getClaimable",[r.chop,d],s));if(e===0n)throw new h("No CHOP is claimable now. Rewards may still be inside the 10-minute maturity lock.");P(i.rewards,"claimReward",[d]),w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},e),k=`Harvest at least ${e} CHOP base units to ${d} in the preview. ${H} Allow at least 1,000,000 gas for this call.`}return(o==="chop_farm"||o==="chop_unfarm")&&!A.some(e=>_(e.token.address,r.chop))&&w({address:y(r.chop),symbol:"CHOP",decimals:18,chainId:4663},0n),O(g,f),{built:g,expected:f,rules:A,details:k,facts:i,log:p}}async function ie(l,o,n,d){let{built:p,expected:u,rules:B,details:i,facts:s,log:f}=await D(l,o,n,d),g=await l.preview(p,d);return O(g.txs,u,!0),U(g,B),{txs:p,preview:g,log:f,measuredAtBlock:s.measuredAtBlock,summary:`${R(s)}
|
|
2
|
-
${i}
|
|
3
|
-
Underlying ${s.underlying.address} (decimals ${s.underlying.decimals}); log ${f} (decimals ${s.log.decimals}); paired ${s.paired.address} (decimals ${s.paired.decimals}).`}}export{j as a,z as b,D as c,ie as d};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as b,b as h,c as R,e as f,f as A,g as k,h as P,i as I,j as v,l as S,m as B,n as $}from"./LEHBRAZX.js";import{a as E}from"./K6D6SDIG.js";import{c as O,e as T,i as M,j as x,k as V,m as D,n as N}from"./DHX3Q5RV.js";import{a as y}from"./ZTX4WT62.js";import{a as c}from"./XSD5NL7J.js";import{encodeFunctionData as j,formatUnits as z}from"viem";var m=(o,e)=>({token:o,amount:e.toString()}),J=6e4;function ie(){let o=new WeakMap;return{entry(e){let r=o.get(e);return(!r||Date.now()>=r.expiresAt)&&(r={logs:new Map,expiresAt:Date.now()+J},o.set(e,r)),r}}}function K(o,e){return{to:o.log.address,data:j({abi:E,functionName:"debond",args:[e,[],[]]}),value:"0",chainId:4663,description:`Unwrap ${e} log base units from ${o.log.address}.`}}async function _(o,e,r,a,t=BigInt(e.measuredAtBlock),s){if(a>BigInt(e.totalSupply))throw new c("Unwrap amount exceeds the issued Chop log supply.");let i=h(await A(o,e.log.address,"convertToAssets",[a],t,r,s)),p=1n<<96n,d=BigInt(e.managedUnderlying)*(a*p/BigInt(e.totalSupply))/p;if(i>d)throw new c("Chop redemption exceeds the measured backing.");return{gross:m(e.underlying,d),fee:m(e.underlying,d-i),net:m(e.underlying,i)}}async function F(o,e){if(f(e),o.network==="testnet")throw new c("Chop requires chain 4663.");let r=o.clientFor(4663),a=await P(r,e),t=I();await v(r,y.registry,a,e,t);let s=await A(r,y.registry.address,"allIndexes",[],a,void 0,e);if(!Array.isArray(s)||s.length>1e3)throw new c("Chop registry inventory is unreadable or too large.");let i=s.filter(n=>n&&n.verified===!0).map(n=>b(n.index));if(new Set(i).size!==i.length)throw new c("Chop registry returned duplicate logs.");let p=[];for(let n=0;n<i.length;n+=4)f(e),p.push(...await Promise.all(i.slice(n,n+4).map(l=>S(r,l,"read",a,e,t))));f(e);let d=p.map(n=>`${n.log.symbol} (${n.log.address}): ${M(n)}`),u=p.flatMap(n=>n.drift.length?[`Code changed for ${n.log.address}: ${n.drift.join(", ")}.`]:[]);return{logs:p.map(n=>({...n,plainSummary:V(n)})),measuredAtBlock:a.toString(),warnings:[...T,...d,...u]}}async function se(o,e,r){if(f(r),!e)return F(o,r);let a=o.clientFor(4663),t=e.entry(a);if(t.inventory)return structuredClone(t.inventory);let s=t.pending;if(!s){let n=new AbortController,l={controller:n,waiters:0,promise:F(o,n.signal)};l.promise=l.promise.then(g=>{f(n.signal),t.inventory=structuredClone(g);for(let w of g.logs)t.logs.set(w.log.address.toLowerCase(),structuredClone(w));return g}).finally(()=>{n.abort(),t.pending===l&&(t.pending=void 0)}),t.pending=s=l}let i=s;i.waiters++;let p,d=!1,u=()=>{d||(d=!0,--i.waiters===0&&t.pending===i&&(i.controller.abort(),t.pending=void 0))};try{let n=await new Promise((l,g)=>{p=()=>{u(),g(new c("Chop read was cancelled."))},r?.addEventListener("abort",p,{once:!0}),i.promise.then(l,g)});return f(r),structuredClone(n)}finally{p&&r?.removeEventListener("abort",p),u()}}async function ae(o,e,r){let{limit:a,offset:t}=r,s=new Set(e.logs.map(l=>`${l.log.symbol} (${l.log.address}): ${M(l)}`)),i=e.warnings.filter(l=>!s.has(l)),p=Object.entries(e).map(([l,g])=>({name:l,chars:JSON.stringify(g).length,...Array.isArray(g)?{items:g.length}:{}})),d=o.clientFor(4663),u=e.logs.slice(t,t+a),n=[];for(let l=0;l<u.length;l+=4)n.push(...await Promise.all(u.slice(l,l+4).map(async g=>{let w=await k(d,[{target:g.pool,fn:"balanceOf",args:[g.staking.address]},{target:g.pool,fn:"totalSupply"}],BigInt(g.measuredAtBlock)),L=h(w[0]),C=h(w[1]);if(L>C)throw new c("Chop staked LP balance exceeds the pool supply.");return{log:g.log.address,symbol:g.log.symbol,backingPerLog:g.backingPerLog,fees:g.fees,pool:g.pool,stakedShare:{stakedLp:L.toString(),totalLp:C.toString(),bps:C===0n?null:Number(L*10000n/C)},riskLines:x(g).split(`
|
|
2
|
-
`).filter(W=>!T.includes(W)).join(`
|
|
3
|
-
`)}})));for(;;){let l=t+n.length,g=`Use detail: "full" for every complete row, or fields: ["logs"] or ["warnings"] for whole sections. ${l<e.logs.length?`Continue with offset: ${l}, limit: ${a}.`:"End of this list; use offset: 0 to start again."} Summary rows omit financial measurements and full contract metadata.`,w={warnings:i,summary:{logs:n,offset:t,total:e.logs.length,omitted:e.logs.length-n.length,measuredAtBlock:e.measuredAtBlock},sections:p,more:g};if(JSON.stringify(w).length<=8e3)return w;if(n.length<=1)throw new c('Chop risk lines exceed the summary budget. Request fields or detail: "full" to read them whole.');n.pop()}}async function de(o,e){let r=o.clientFor(4663),a=[];for(let t=0;t<e.length;t+=4)a.push(...await Promise.all(e.slice(t,t+4).map(async s=>{let[i,p,d,u]=await k(r,[{target:b(y.chop),fn:"balanceOf",args:[s.rewards]},{target:s.pool,fn:"token0"},{target:s.pool,fn:"token1"},{target:s.pool,fn:"getReserves"}],BigInt(s.measuredAtBlock)),n=[b(p),b(d)].map(g=>[s.log,s.paired].find(w=>w.address.toLowerCase()===g.toLowerCase()));if(!n[0]||!n[1]||n[0]===n[1])throw new c("Chop pool tokens disagree with the verified log.");if(!Array.isArray(u)||u.length!==3)throw new c("Chop pool reserves are unavailable.");let l=m(s.underlying,BigInt(s.managedUnderlying));return{...s,backingNow:{...l,humanAmount:z(BigInt(l.amount),s.underlying.decimals)},rewardPot:m({address:b(y.chop),symbol:"CHOP",decimals:18,chainId:4663},h(i)),reserves:[m(n[0],h(u[0])),m(n[1],h(u[1]))]}})));return a}var U=o=>BigInt(o.replace(".","")),H=o=>`${o/100n}.${(o%100n).toString().padStart(2,"0")}`;function le(o){return o.some(e=>e.usdEstimate===null)?{reserves:o,usdEstimate:null,estimateLabel:"price unavailable",estimateReason:"A pool reserve has no USD estimate"}:{reserves:o,usdEstimate:H(o.reduce((e,r)=>e+U(r.usdEstimate),0n)),estimateLabel:"estimate, not a quote",estimateSource:"sum of the two reserve estimates"}}function pe(o,e){let r={label:"rough",pct:null,inputToken:e,assumptions:"Constant-product marginal price move for buying the log with $100 of the paired token; excludes pool and token fees, gas and other trades."};if(o.some(d=>BigInt(d.amount)===0n))return{...r,reason:"The pool is empty on at least one side"};let a=o.find(d=>d.token.address.toLowerCase()===e.address.toLowerCase());if(!a?.usdEstimate||U(a.usdEstimate)===0n)return{...r,reason:"Paired reserve price unavailable or below one cent"};let t=U(a.usdEstimate),i=((t+10000n)**2n-t**2n)*10000n,p=t**2n;return{...r,pct:H((2n*i+p)/(2n*p))}}var q=new WeakMap,Y=10;async function Z(o,e,r,a,t,s){if(f(t),e.length>Y)throw new c("Chop holdings probes support at most ten logs per call.");if(e.length===0)return[];let i=t?q.get(t):void 0;t&&!i&&(i=I(),q.set(t,i)),await v(o,y.whitelist,a,t,i);let p=await k(o,e.flatMap(d=>[{target:d.log.address,fn:"balanceOf",args:[r]},{target:d.staking.address,fn:"balanceOf",args:[r]},{target:d.staking.address,fn:"withdrawableStake",args:[r]},{target:d.rewards,fn:"getUnpaid",args:[y.chop,r]},{target:d.rewards,fn:"getClaimable",args:[y.chop,r]},{target:y.whitelist.address,fn:"paused",args:[y.chop]},{target:d.log.address,fn:"totalSupply"},{target:d.log.address,fn:"totalAssets",args:[d.underlying.address]}]),a,t);return f(t),Promise.all(e.map(async(d,u)=>{let n=await Q(o,d,r,a,t,p.slice(u*8,(u+1)*8));return f(t),s?.(n,u),n}))}async function G(o,e,r,a=BigInt(e.measuredAtBlock),t){return(await Z(o,[e],r,a,t))[0]}async function Q(o,e,r,a,t,s){if(f(t),typeof s[5]!="boolean")throw new c("Chop reward pause state is unavailable.");let i=h(s[0]),p=h(s[6]),d=h(s[7]);if(p===0n)throw new c("This Chop log has no issued supply.");let u={...e,totalSupply:p.toString(),managedUnderlying:d.toString()},n=i===0n?{gross:m(e.underlying,0n),fee:m(e.underlying,0n),net:m(e.underlying,0n)}:await _(o,u,r,i,a,t),l={address:b(y.chop),symbol:"CHOP",decimals:18,chainId:4663};return{log:e.log.address,logTokens:m(e.log,i),...n,stakedLp:m(e.staking,h(s[1])),withdrawableLp:m(e.staking,h(s[2])),pendingChop:m(l,h(s[3])),claimableChop:m(l,h(s[4])),rewardsPaused:s[5],measuredAtBlock:a.toString(),warnings:x(e)}}async function ge(o,e,r,a){let t=o.clientFor(4663);b(r);let s=a?.entry(t),i=b(e).toLowerCase(),p=s?.logs.get(i)??await S(t,e,"read");return s&&!s.logs.has(i)&&s.logs.set(i,structuredClone(p)),G(t,p,r,await P(t))}async function ue(o,e,r,a){let t=R(a),s=o.clientFor(4663);b(r);let i=await S(s,e,"exit"),p=h(await A(s,i.log.address,"balanceOf",[r],BigInt(i.measuredAtBlock)));if(p===0n)throw new c(D(i.log.symbol));if(t>p)throw new c(N(i.log,t,p));let d=await _(s,i,r,t),u=BigInt(d.net.amount);if(u===0n)throw new c("This Chop unwrap would return no underlying.");let n=K(i,t),l=o.unsignedTx(n);B([l],[n]);let g=await o.preview([l],r);B(g.txs,[n]);let w=$(g,[{token:i.log,min:-t,max:-t},{token:i.underlying,min:u}]);return{log:i.log.address,amount:t.toString(),...d,simulatedNet:m(i.underlying,w.get(i.underlying.address.toLowerCase())),quotedNet:d.net.amount,preview:g,measuredAtBlock:i.measuredAtBlock,warning:O,summary:x(i)}}export{m as a,J as b,ie as c,K as d,_ as e,se as f,ae as g,de as h,le as i,pe as j,Y as k,Z as l,G as m,ge as n,ue as o};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{l}from"./BA66J5YQ.js";import{a}from"./XSD5NL7J.js";var m=4295128739n,h=1461446703485210103287273052203988822378723970342n,d=-887272,$=887272;function I(t){if(t<2n)return t;let n=t,i=n+1n>>1n;for(;i<n;)n=i,i=n+t/n>>1n;return n}function w(t,n){if(typeof t!="string"||!/^\d+(?:\.\d+)?$/.test(t.trim()))throw new a(`${n} must be a positive decimal string such as "3000.5".`);let[i,e=""]=t.trim().split("."),r=BigInt(`${i}${e}`);if(r<=0n)throw new a(`${n} must be greater than zero.`);return{n:r,d:10n**BigInt(e.length)}}function _(t,n,i){let{n:e,d:r}=w(t,"initialPrice"),s=e*10n**BigInt(i),o=r*10n**BigInt(n),c=I((s<<192n)/o);return b(c)}function b(t){if(t<m||t>=h)throw new a("Initial price is outside the range Uniswap can represent.");return t}function S(t){b(t);let n=d,i=$;for(;n<i;){let e=Math.ceil((n+i)/2);l(e)<=t?n=e:i=e-1}return n}function f(t,n,i){let r=(t*t*10n**BigInt(n+18)/((1n<<192n)*10n**BigInt(i))).toString().padStart(19,"0"),s=r.slice(0,-18),o=r.slice(-18).replace(/0+$/,"");return o?`${s}.${o}`:s}function x(t,n){let i=t*t,e=n*n;return(i>e?i-e:e-i)*10000n/e}var P=500n;function R(t,n,i,e,r){if(n.length===0)return"No other pool for this pair was found, so the starting price could not be checked against a market. Anyone can trade against a wrong price immediately.";let s=[...n].sort((p,u)=>p.sqrtPriceX96<u.sqrtPriceX96?-1:p.sqrtPriceX96>u.sqrtPriceX96?1:0),o=s[Math.floor(s.length/2)],c=x(t,o.sqrtPriceX96),g=`${f(o.sqrtPriceX96,e,r)} (${o.label})`;if(c>P&&!i)throw new a(`Initial price ${f(t,e,r)} is ${c} bps from the existing market price ${g}. A mispriced new pool is arbitraged against your deposit. Fix the price, or pass acceptPriceDeviation:true if this is intentional.`);return`Existing market price ${g}; starting price deviates ${c} bps.`}function T(t,n){return typeof t=="string"&&/^[A-Za-z0-9][A-Za-z0-9.$_-]{0,15}$/.test(t)?t:`${n.slice(0,6)}\u2026${n.slice(-4)}`}export{m as a,h as b,_ as c,b as d,S as e,f,x as g,P as h,R as i,T as j};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as t}from"./LCH6F5HT.js";import{c as o}from"./4J245N3F.js";function s(e,n,a){return t(e,n,a,o)}export{s as a};
|