@oracle-agent/oracle 0.35.26 → 0.35.27
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/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/bin/desk-server.mjs +35 -35
- package/dist/bin/oracle-data-mcp.mjs +13 -13
- package/dist/bin/oracle-launch-radar-shadow.mjs +6 -6
- package/dist/bin/oracle-route.mjs +20 -20
- package/dist/bin/oracle-scan.mjs +1 -1
- package/dist/cli/commands/chat.mjs +168 -168
- package/dist/cli/commands/model.mjs +171 -171
- package/dist/cli/commands/snipe.mjs +1 -1
- package/dist/cli/commands/swap.mjs +32 -32
- package/dist/data/desk-data.mjs +33 -33
- package/dist/data/providers/lp-destination-discovery.mjs +4 -4
- package/dist/index.mjs +49 -49
- package/dist/launch-radar/index.mjs +5 -5
- package/dist/router/index.mjs +3 -3
- package/dist/router/prepare-bridge.mjs +2 -2
- package/dist/scanner/index.mjs +1 -1
- package/dist/teams/index.mjs +1 -0
- package/package.json +2 -1
- package/public/eval-report.json +2 -2
- package/server.json +2 -2
package/dist/bin/oracle-scan.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import{createHash as me}from"node:crypto";import B from"node:net";import Ge from
|
|
|
4
4
|
${e}
|
|
5
5
|
${JSON.stringify(n??[])}`}async function At(t,e,n){return G(t,{method:"POST",body:e,fetchImpl:n.fetchImpl,timeoutMs:n.timeoutMs??12e3,signal:n.signal})}async function _(t,e,n=[],r={}){let s=String(e||""),o=St(s),a=gt(t,r);if(!a)throw new Error(`No RPC URL for chainId ${t} (set env from chain registry rpcEnv or pass rpcUrl)`);if(o==="eth_chainid"&&r.cacheChainId!==!1){let c=Te.get(a);if(c!=null)return c}let u=r.dedupe!==!1&&!r.signal?xt(a,s,n):null;if(u&&M.has(u))return M.get(u);let p=(async()=>{let c=await At(a,{jsonrpc:"2.0",id:1,method:e,params:n},r),i=Ct(c);return o==="eth_chainid"&&typeof i=="string"&&Te.set(a,i),i})();return u&&(M.set(u,p),p.finally(()=>{M.get(u)===p&&M.delete(u)}).catch(()=>{})),p}async function qe(t,e={}){let n=await _(t,"eth_blockNumber",[],e);return parseInt(n,16)}async function Ue(t,e,n={}){if(!e)throw new Error("rpcGetBalance requires address");let r=await _(t,"eth_getBalance",[e,"latest"],n);return{chainId:Number(t),address:e,balanceWei:BigInt(r).toString(),balanceHex:r}}async function Le(t={},e={}){let n=Number(t.chainId??e.chainId??1),r=Ne(t.token||t.tokenAddress,"token"),s=Ne(t.account||t.owner||t.address,"account"),o=ke.encodeFunctionData("balanceOf",[s]),a=await _(n,"eth_call",[{to:r,data:o},t.blockTag||"latest"],e),d=ke.decodeFunctionResult("balanceOf",a),u=BigInt(d[0]);return{chainId:n,token:r,account:s,balance:u.toString(),balanceHex:`0x${u.toString(16)}`,blockTag:t.blockTag||"latest"}}var It=new Set(["usdc","usdt","usdg","dai","usd1","usde","pyusd"]);function _e(t,e){let n=String(t||"").toLowerCase(),r=String(e?.quote||e?.quoteToken?.address||"").toLowerCase(),s=String(e?.base||e?.baseToken?.address||"").toLowerCase();return r===n?{address:e.base||e.baseToken?.address,symbol:e.baseToken?.symbol}:s===n?{address:e.quote||e.quoteToken?.address,symbol:e.quoteToken?.symbol}:{address:e.quote||e.quoteToken?.address,symbol:e.quoteToken?.symbol}}function ie(t,e=[],{stables:n=[],wrappedNative:r=null}={}){let s=String(t||"").toLowerCase(),o=new Set((n||[]).map(u=>String(u).toLowerCase())),a=String(r||"").toLowerCase(),d=(e||[]).map((u,p)=>{let c=_e(s,u),i=String(c.address||"").toLowerCase(),l=String(c.symbol||"").toLowerCase(),f=Number(u.liquidityUsd??u.liquidity?.usd),h=Number.isFinite(f)?f:0,y=String(u.dex||u.dexId||"").toLowerCase(),b=0;return o.has(i)||It.has(l)?b=300:a&&i===a&&(b=100),y.includes("v4")?b+=20:y.includes("v3")?b+=10:(y.includes("v2")||y.includes("raydium")||y.includes("orca")||y.includes("meteora"))&&(b+=8),{pool:u,score:b*1e12+h,index:p,otherAddr:i,liquidityUsd:h}});return d.sort((u,p)=>p.score-u.score||u.index-p.index),d.map(u=>u.pool)}function Re(t,e=[]){let n=Array.isArray(e)?e:[];return n.length&&_e(t,n[0]).address||null}var kt="https://api.dexscreener.com",tn=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function Nt(t={}){return(t.baseUrl||process.env.DEXSCREENER_API_URL||kt).replace(/\/$/,"")}async function $e(t,e={}){if(!t)throw new Error("tokenAddress required");return G(`${Nt(e)}/latest/dex/tokens/${t}`,{fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs??12e3})}var j=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),v=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),m=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),Tt=/^0x[0-9a-fA-F]{40}$/;function qt(t={}){let e=[],n=[];if(!t||typeof t!="object")return{ok:!1,errors:["definition must be an object"],warnings:n};if((!Number.isInteger(t.chainId)||t.chainId<=0)&&e.push("chainId must be a positive integer"),(typeof t.key!="string"||!/^[a-z][a-z0-9-]*$/.test(t.key||""))&&e.push('key must be a lowercase slug (e.g. "base")'),(typeof t.name!="string"||!t.name.trim())&&e.push("name is required"),!Array.isArray(t.rpcEnv)||t.rpcEnv.length===0)e.push("rpcEnv must list at least one environment variable name");else for(let s of t.rpcEnv)(typeof s!="string"||!/^[A-Z][A-Z0-9_]*$/.test(s))&&e.push(`rpcEnv entry "${s}" should be an UPPER_SNAKE env var name`);if(t.nativeCurrency){let s=t.nativeCurrency;(typeof s.symbol!="string"||!s.symbol)&&e.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(s.decimals)||e.push("nativeCurrency.decimals must be an integer")}for(let[s,o]of(t.venues||[]).entries()){let a=`venues[${s}]`;if(!o||typeof o!="object"){e.push(`${a} must be an object`);continue}Tt.test(o.address||"")||e.push(`${a}.address is not a valid 20-byte address`),/^0x0{40}$/.test(o.address||"")&&e.push(`${a}.address is the zero address -- placeholder left in place?`),o.kind||e.push(`${a}.kind is required (router|quoter|factory|...)`),o.verified?(o.verified.method||e.push(`${a}.verified.method is required`),o.verified.source||e.push(`${a}.verified.source is required`),o.verified.date||n.push(`${a}.verified.date missing -- add one so staleness is visible`)):e.push(`${a} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let r=t.capabilities||{};for(let s of Object.keys(r))j.includes(s)?typeof r[s]!="function"&&e.push(`capability "${s}" must be a function`):e.push(`unknown capability "${s}"`);return Object.keys(r).length===0&&n.push("scanner implements no capabilities -- it can only be registered, not used"),r.prepareUnsignedTx&&!r.quote&&n.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),r.prepareUnsignedTx&&!r.sellSimulation&&n.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:e.length===0,errors:e,warnings:n}}function Ut(t){let{ok:e,errors:n,warnings:r}=qt(t);if(!e)throw new Error(`invalid scanner for ${t?.key??"<unknown>"}:
|
|
6
6
|
- ${n.join(`
|
|
7
|
-
- `)}`);let s=t.capabilities||{},o=j.filter(d=>typeof s[d]=="function"),a={key:t.key,chainId:t.chainId,name:t.name,rpcEnv:[...t.rpcEnv],nativeCurrency:t.nativeCurrency?{...t.nativeCurrency}:null,wrappedNative:t.wrappedNative||null,explorer:t.explorer||null,venues:(t.venues||[]).map(d=>({...d})),warnings:r,capabilities(){return{chainId:t.chainId,key:t.key,supported:[...o],unsupported:j.filter(d=>!o.includes(d))}},supports(d){return o.includes(d)}};for(let d of j)o.includes(d)?a[d]=async(...u)=>s[d](...u,{scanner:a}):a[d]=async()=>{throw new Error(`${t.key} (chain ${t.chainId}) does not implement "${d}". Supported: ${o.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(a)}var z=new Map;function Be(t){let e=Ut(t);return z.set(e.chainId,e),e}function ce(t){return z.get(Number(t))||null}function Y(){return[...z.values()]}function Pe(){let t={};for(let e of z.values())t[e.chainId]={key:e.key,name:e.name,...e.capabilities(),venueCount:e.venues.length,failClosed:e.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:z.size,capabilities:[...j],chains:t}}var le={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},q=t=>BigInt(t).toString(16).padStart(64,"0"),W=t=>t.slice(2).toLowerCase().padStart(64,"0");function Lt(t,e){return`0x${le.getAmountsOut}`+q(t)+q(64)+q(e.length)+e.map(W).join("")}function _t(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length<128)return null;let n=Number(BigInt(`0x${e.slice(64,128)}`));if(!Number.isFinite(n)||n<1||n>16)return null;let r=[];for(let s=0;s<n;s++){let o=128+s*64;if(e.length<o+64)return null;r.push(BigInt(`0x${e.slice(o,o+64)}`))}return r}function ue(t,e="router"){return(t?.venues||[]).find(r=>r.kind===e)?.address??null}var de=100;function Rt(t,e){let n=Number(e);if(!Number.isFinite(n)||n<0)throw new Error("slippageBps must be a non-negative number");if(n>de)throw new Error(`slippageBps ${n} exceeds the ${de} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(n))/10000n}function Oe(t){let{chainId:e,wrappedNative:n}=t;async function r(s,o,a,d){let u=await _(e,"eth_call",[{to:s,data:Lt(o,a)},"latest"],d);return _t(u?.result??u)}return{async quote({tokenIn:s,tokenOut:o,amountIn:a,path:d},u={}){let p=ue(u.scanner);if(!p)return{chainId:e,evidence:v.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let c=d||[s,o];if(c.some(l=>!/^0x[0-9a-fA-F]{40}$/.test(l||"")))throw new Error("quote requires valid 20-byte addresses");let i=await r(p,a,c,u);return i?{chainId:e,router:p,path:c,amountIn:String(a),amountOut:i[i.length-1].toString(),hops:c.length-1,evidence:v.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:e,router:p,path:c,evidence:v.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:s,amountIn:o,base:a},d={}){let u=ue(d.scanner),p=a||n;if(p&&String(s).toLowerCase()===String(p).toLowerCase())return{chainId:e,token:s,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!u||!p)return{chainId:e,token:s,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:u?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let c=await r(u,o,[p,s],d);if(!c)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let i=c[c.length-1];if(i===0n)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let l=await r(u,i,[s,p],d);if(!l)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"sell",bought:i.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=l[l.length-1],h=Number(f*10000n/BigInt(o)),y=m.PASS,b="round trip completes with expected fee/impact loss";return h<5e3?(y=m.FAIL,b=`round trip returns only ${(h/100).toFixed(2)}% -- punitive tax or no real liquidity`):h<9e3&&(y=m.CAUTION,b=`round trip returns ${(h/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,token:s,base:p,router:u,verdict:y,reason:b,amountIn:String(o),bought:i.toString(),returned:f.toString(),retentionBps:h,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:o,amountIn:a,recipient:d,slippageBps:u=50,deadlineSeconds:p=900,path:c},i={}){let l=i.scanner,f=ue(l);if(!f)throw new Error(`chain ${e} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(d||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let h=c||[s,o],y=await this.quote({tokenIn:s,tokenOut:o,amountIn:a,path:h},i);if(y.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${y.evidence}: ${y.reason??"no reason given"})`);let b=Rt(y.amountOut,u);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let T=BigInt(Math.floor(Date.now()/1e3)+Number(p)),I=n&&h[0].toLowerCase()===n.toLowerCase()&&i.useNative,U=I?`0x${le.swapExactETHForTokens}`+q(b)+q(128)+W(d)+q(T)+q(h.length)+h.map(W).join(""):`0x${le.swapExactTokensForTokens}`+q(a)+q(b)+q(160)+W(d)+q(T)+q(h.length)+h.map(W).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:e,tx:{to:f,data:U,value:I?`0x${BigInt(a).toString(16)}`:"0x0"},guard:{quotedOut:y.amountOut,minOut:b.toString(),slippageBps:u,maxSlippageBps:de,deadline:T.toString()},requires:I?[]:[{step:"approve",token:h[0],spender:f,amount:String(a)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var $t=[100,500,3e3,1e4],Fe={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},P=t=>BigInt(t).toString(16).padStart(64,"0"),K=t=>t.slice(2).toLowerCase().padStart(64,"0"),De=/^0x[0-9a-fA-F]{40}$/,fe=100;function Bt(t,e){let n=Number(e);if(!Number.isFinite(n)||n<0)throw new Error("slippageBps must be a non-negative number");if(n>fe)throw new Error(`slippageBps ${n} exceeds the ${fe} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(n))/10000n}function pe(t,e){return(t?.venues||[]).find(n=>n.kind===e)?.address??null}function Ve(t){let{chainId:e,wrappedNative:n}=t;async function r({quoter:o,tokenIn:a,tokenOut:d,amountIn:u,fee:p},c){let i=`0x${Fe.quoteExactInputSingle}`+K(a)+K(d)+P(u)+P(p)+P(0),l=await _(e,"eth_call",[{to:o,data:i},"latest"],c).catch(()=>null),f=l?.result??l;if(!f||f==="0x"||f.length<66)return null;let h=BigInt(`0x${f.slice(2,66)}`);return h>0n?h:null}async function s({quoter:o,tokenIn:a,tokenOut:d,amountIn:u},p){let c=await Promise.all($t.map(async l=>{let f=await r({quoter:o,tokenIn:a,tokenOut:d,amountIn:u,fee:l},p);return{fee:l,amountOut:f?f.toString():null,out:f}})),i=null;for(let l of c)l.out&&(!i||l.out>i.amountOut)&&(i={fee:l.fee,amountOut:l.out});return{best:i,tried:c.map(({fee:l,amountOut:f})=>({fee:l,amountOut:f}))}}return{async quote({tokenIn:o,tokenOut:a,amountIn:d},u={}){let p=pe(u.scanner,"quoter");if(!p)return{chainId:e,evidence:v.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let l of[o,a])if(!De.test(l||""))throw new Error("quote requires valid 20-byte addresses");let{best:c,tried:i}=await s({quoter:p,tokenIn:o,tokenOut:a,amountIn:d},u);return c?{chainId:e,venue:"uniswap-v3",quoter:p,tokenIn:o,tokenOut:a,amountIn:String(d),amountOut:c.amountOut.toString(),fee:c.fee,useNative:!!n&&String(o).toLowerCase()===String(n).toLowerCase(),triedFeeTiers:i,evidence:v.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:e,quoter:p,tokenIn:o,tokenOut:a,triedFeeTiers:i,evidence:v.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:o,amountIn:a,base:d},u={}){let p=pe(u.scanner,"quoter"),c=(t.stableQuoteAssets||[]).map(S=>String(S).toLowerCase()),i=null;!d&&typeof t.resolveQuoteAsset=="function"&&(i=await t.resolveQuoteAsset(o,u).catch(()=>null));let l=String(o).toLowerCase(),f=String(n||"").toLowerCase();if(f&&l===f)return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};let h=d||i||(c[0]&&l!==c[0]?c[0]:null)||n;if(h&&l===String(h).toLowerCase())return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!p||!h)return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:p?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let y=await s({quoter:p,tokenIn:h,tokenOut:o,amountIn:a},u);if(!y.best){let S=c.find(w=>w&&w!==String(h).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await s({quoter:p,tokenIn:S,tokenOut:o,amountIn:a},u);if(w.best){let g=await s({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u);if(g.best){let A=g.best.amountOut,k=Number(A*10000n/BigInt(a)),x=m.PASS,N="round trip vs dollar book completes with expected fee/impact loss";return k<5e3?(x=m.FAIL,N=`round trip vs dollar book returns only ${(k/100).toFixed(2)}% -- punitive tax or no real liquidity`):k<9e3&&(x=m.CAUTION,N=`round trip vs dollar book returns ${(k/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:S,quoteAsset:S,verdict:x,reason:N,amountIn:String(a),bought:w.best.amountOut.toString(),returned:A.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:g.best.fee,evidence:v.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:e,token:o,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let b=await s({quoter:p,tokenIn:o,tokenOut:h,amountIn:y.best.amountOut},u);if(!b.best){let S=c.find(w=>w&&w!==String(h).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await s({quoter:p,tokenIn:S,tokenOut:o,amountIn:a},u),g=w.best?await s({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u):{best:null};if(w.best&&g.best){let A=g.best.amountOut,k=Number(A*10000n/BigInt(a)),x=m.PASS,N="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return k<5e3?(x=m.FAIL,N=`dollar-book round trip returns only ${(k/100).toFixed(2)}%`):k<9e3&&(x=m.CAUTION,N=`dollar-book round trip returns ${(k/100).toFixed(2)}%`),{chainId:e,venue:"uniswap-v3",token:o,base:S,quoteAsset:S,verdict:x,reason:N,amountIn:String(a),bought:w.best.amountOut.toString(),returned:A.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:g.best.fee,evidence:v.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:e,token:o,verdict:m.FAIL,evidence:v.LIVE,leg:"sell",bought:y.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let T=b.best.amountOut,I=Number(T*10000n/BigInt(a)),U=m.PASS,E="round trip completes with expected fee/impact loss";return I<5e3?(U=m.FAIL,E=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(U=m.CAUTION,E=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:h,verdict:U,reason:E,amountIn:String(a),bought:y.best.amountOut.toString(),returned:T.toString(),retentionBps:I,buyFee:y.best.fee,sellFee:b.best.fee,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:o,tokenOut:a,amountIn:d,recipient:u,slippageBps:p=50,fee:c},i={}){let l=pe(i.scanner,"router");if(!l)throw new Error(`chain ${e} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!De.test(u||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:o,tokenOut:a,amountIn:d},i);if(f.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let h=c??f.fee,y=Bt(f.amountOut,p);if(y<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let b=!!(i.useNative||f.useNative)&&n&&String(o).toLowerCase()===String(n).toLowerCase(),T=`0x${Fe.exactInputSingle}`+K(o)+K(a)+P(h)+K(u)+P(d)+P(y)+P(0);return{unsigned:!0,signedBy:"user-wallet",chainId:e,venue:"uniswap-v3",tx:{to:l,data:T,value:b?String(d):"0x0"},guard:{quotedOut:f.amountOut,minOut:y.toString(),slippageBps:p,maxSlippageBps:fe,fee:h},requires:b?[]:[{step:"approve",token:o,spender:l,amount:String(d)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var J={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function He(t){if(!t||t==="0x")return null;try{return BigInt(t)}catch{return null}}function Me(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length>=128){let r=Number(BigInt(`0x${e.slice(64,128)}`));if(r>0&&r<=256&&e.length>=128+r*2){let s=e.slice(128,128+r*2),o=Buffer.from(s,"hex").toString("utf8").replace(/\0+$/,"");if(o)return o}}return Buffer.from(e.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function Pt(t){let{chainId:e}=t;async function n(r,s,o){return _(e,"eth_call",[{to:r,data:s},"latest"],o)}return{async blockNumber(r={}){let s=await qe(e,r);return{chainId:e,blockNumber:s?.blockNumber??s,evidence:v.LIVE}},async nativeBalance(r,s={}){let o=await Ue(e,r,s);return{chainId:e,address:r,wei:o?.wei??o?.balance??null,symbol:t.nativeCurrency?.symbol??null,decimals:t.nativeCurrency?.decimals??18,evidence:v.LIVE}},async tokenBalance({token:r,owner:s},o={}){let a=await Le({chainId:e,token:r,owner:s},o);return{chainId:e,token:r,owner:s,raw:a?.balance??a,evidence:v.LIVE}},async resolveToken(r,s={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:e,token:r,evidence:v.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,a,d,u]=await Promise.all([n(r,J.decimals,s).catch(()=>null),n(r,J.symbol,s).catch(()=>null),n(r,J.name,s).catch(()=>null),n(r,J.totalSupply,s).catch(()=>null)]),p=He(o?.result??o),c=p!==null||a?.result||d?.result;return{chainId:e,address:r,decimals:p===null?null:Number(p),symbol:Me(a?.result??a),name:Me(d?.result??d),totalSupply:(He(u?.result??u)??null)?.toString()??null,evidence:c?v.LIVE:v.UNKNOWN,warning:c?void 0:"no ERC-20 metadata returned -- may not be a token contract"}},async resolvePools(r,s={}){let o=t.dexscreenerSlug;if(!o)return{chainId:e,token:r,pools:[],evidence:v.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let a=await $e(r,s).catch(()=>null),u=(a?.pairs||a?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(o).toLowerCase()).map(c=>({pair:c.pairAddress,dex:c.dexId,base:c.baseToken?.address,quote:c.quoteToken?.address,liquidityUsd:c.liquidity?.usd??null,priceUsd:c.priceUsd??null,volume24hUsd:c.volume?.h24??null,createdAt:c.pairCreatedAt??null})).sort((c,i)=>(i.liquidityUsd??0)-(c.liquidityUsd??0)),p=ie(r,u,{stables:t.stableQuoteAssets||[],wrappedNative:t.wrappedNative});return{chainId:e,token:r,pools:p,topPool:p[0]||null,quoteAsset:Re(r,p),evidence:p.length?v.LIVE:v.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:s,address:o,topics:a,chunkSize:d=2e3}={},u={}){if(!Number.isInteger(r)||!Number.isInteger(s))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(s<r)throw new Error("toBlock must be >= fromBlock");let p=[],c=[];for(let l=r;l<=s;l+=d){let f=Math.min(l+d-1,s);c.push([l,f])}let i=await Ce(c,4,async([l,f])=>{let h={fromBlock:`0x${l.toString(16)}`,toBlock:`0x${f.toString(16)}`};o&&(h.address=o),a&&(h.topics=a);let y=await _(e,"eth_getLogs",[h],u).catch(b=>({error:String(b?.message||b)}));return{start:l,end:f,res:y}});for(let{start:l,end:f,res:h}of i){if(h?.error)return{chainId:e,fromBlock:r,toBlock:s,logs:p,complete:!1,failedAt:[l,f],error:h.error,evidence:v.UNKNOWN};for(let y of h?.result??h??[])p.push(y)}return{chainId:e,fromBlock:r,toBlock:s,logs:p,complete:!0,chunks:c.length,evidence:v.LIVE}},async scoreRisk(r,s={}){let o=[],a=m.PASS,d=c=>{let i={[m.PASS]:0,[m.CAUTION]:1,[m.UNKNOWN]:2,[m.FAIL]:3};i[c]>i[a]&&(a=c)},[u,p]=await Promise.all([this.resolveToken(r,s),this.resolvePools(r,s)]);if(u.evidence!==v.LIVE?(o.push({check:"erc20-metadata",result:m.UNKNOWN,detail:u.warning}),d(m.UNKNOWN)):o.push({check:"erc20-metadata",result:m.PASS,detail:`${u.symbol} / ${u.decimals}d`}),p.evidence===v.UNAVAILABLE)o.push({check:"liquidity",result:m.UNKNOWN,detail:p.reason}),d(m.UNKNOWN);else if(!p.pools.length)o.push({check:"liquidity",result:m.FAIL,detail:"no pool with liquidity found"}),d(m.FAIL);else{let c=p.pools[0],i=c.liquidityUsd??0;i<5e3?(o.push({check:"liquidity",result:m.CAUTION,detail:`top pool only $${i}`}),d(m.CAUTION)):o.push({check:"liquidity",result:m.PASS,detail:`$${i} on ${c.dex}`}),c.createdAt&&Date.now()-c.createdAt<24*3600*1e3&&(o.push({check:"age",result:m.CAUTION,detail:"pool under 24h old"}),d(m.CAUTION))}if(typeof this.sellSimulation=="function"){let c=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},s).catch(i=>({verdict:m.UNKNOWN,reason:String(i?.message||i)}));o.push({check:"sellability",result:c.verdict,detail:c.retentionBps!=null?`round trip returns ${(c.retentionBps/100).toFixed(2)}% -- ${c.reason}`:c.reason}),d(c.verdict)}else o.push({check:"sellability",result:m.UNKNOWN,detail:"no verified router on this chain, so a round-trip sell simulation cannot run. Treat as unproven -- a buy path is not an exit path."}),d(m.UNKNOWN);return{chainId:e,token:r,verdict:a,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function je(t){let n={...Pt(t)},r=new Set((t.venues||[]).map(o=>o.kind));t.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(n,Ve({chainId:t.chainId,wrappedNative:t.wrappedNative,stableQuoteAssets:t.stableQuoteAssets||[],resolveQuoteAsset:async(o,a)=>(await n.resolvePools(o,a)).quoteAsset||null})):t.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(n,Oe({chainId:t.chainId,wrappedNative:t.wrappedNative}));let s={};for(let[o,a]of Object.entries(n))s[o]=a.bind(n);return{key:t.key,chainId:t.chainId,name:t.name,rpcEnv:t.rpcEnv,nativeCurrency:t.nativeCurrency,explorer:t.explorer,venues:t.venues||[],capabilities:s}}var Ot=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function ze(){return Ot.map(t=>Be(je(t)))}ze();var[We,...Ke]=process.argv.slice(2),X=Ke.includes("--json"),C=Ke.filter(t=>t!=="--json");function F(t){t||R("missing <chain>");let e=ce(Number(t));if(e)return e;let n=Y().find(r=>r.key===String(t).toLowerCase());if(n)return n;R(`unknown chain "${t}". Known: ${Y().map(r=>`${r.key}(${r.chainId})`).join(", ")}`)}function R(t){console.error(`error: ${t}`),process.exit(1)}function O(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
7
|
+
- `)}`);let s=t.capabilities||{},o=j.filter(d=>typeof s[d]=="function"),a={key:t.key,chainId:t.chainId,name:t.name,rpcEnv:[...t.rpcEnv],nativeCurrency:t.nativeCurrency?{...t.nativeCurrency}:null,wrappedNative:t.wrappedNative||null,explorer:t.explorer||null,venues:(t.venues||[]).map(d=>({...d})),warnings:r,capabilities(){return{chainId:t.chainId,key:t.key,supported:[...o],unsupported:j.filter(d=>!o.includes(d))}},supports(d){return o.includes(d)}};for(let d of j)o.includes(d)?a[d]=async(...u)=>s[d](...u,{scanner:a}):a[d]=async()=>{throw new Error(`${t.key} (chain ${t.chainId}) does not implement "${d}". Supported: ${o.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(a)}var z=new Map;function Be(t){let e=Ut(t);return z.set(e.chainId,e),e}function ce(t){return z.get(Number(t))||null}function Y(){return[...z.values()]}function Pe(){let t={};for(let e of z.values())t[e.chainId]={key:e.key,name:e.name,...e.capabilities(),venueCount:e.venues.length,failClosed:e.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:z.size,capabilities:[...j],chains:t}}var le={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},q=t=>BigInt(t).toString(16).padStart(64,"0"),W=t=>t.slice(2).toLowerCase().padStart(64,"0");function Lt(t,e){return`0x${le.getAmountsOut}`+q(t)+q(64)+q(e.length)+e.map(W).join("")}function _t(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length<128)return null;let n=Number(BigInt(`0x${e.slice(64,128)}`));if(!Number.isFinite(n)||n<1||n>16)return null;let r=[];for(let s=0;s<n;s++){let o=128+s*64;if(e.length<o+64)return null;r.push(BigInt(`0x${e.slice(o,o+64)}`))}return r}function ue(t,e="router"){return(t?.venues||[]).find(r=>r.kind===e)?.address??null}var de=100;function Rt(t,e){let n=Number(e);if(!Number.isFinite(n)||n<0)throw new Error("slippageBps must be a non-negative number");if(n>de)throw new Error(`slippageBps ${n} exceeds the ${de} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(n))/10000n}function Oe(t){let{chainId:e,wrappedNative:n}=t;async function r(s,o,a,d){let u=await _(e,"eth_call",[{to:s,data:Lt(o,a)},"latest"],d);return _t(u?.result??u)}return{async quote({tokenIn:s,tokenOut:o,amountIn:a,path:d},u={}){let p=ue(u.scanner);if(!p)return{chainId:e,evidence:v.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let c=d||[s,o];if(c.some(l=>!/^0x[0-9a-fA-F]{40}$/.test(l||"")))throw new Error("quote requires valid 20-byte addresses");let i=await r(p,a,c,u);return i?{chainId:e,router:p,path:c,amountIn:String(a),amountOut:i[i.length-1].toString(),hops:c.length-1,evidence:v.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:e,router:p,path:c,evidence:v.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:s,amountIn:o,base:a},d={}){let u=ue(d.scanner),p=a||n;if(p&&String(s).toLowerCase()===String(p).toLowerCase())return{chainId:e,token:s,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!u||!p)return{chainId:e,token:s,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:u?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let c=await r(u,o,[p,s],d);if(!c)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let i=c[c.length-1];if(i===0n)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let l=await r(u,i,[s,p],d);if(!l)return{chainId:e,token:s,verdict:m.FAIL,evidence:v.LIVE,leg:"sell",bought:i.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=l[l.length-1],h=Number(f*10000n/BigInt(o)),y=m.PASS,b="round trip completes with expected fee/impact loss";return h<5e3?(y=m.FAIL,b=`round trip returns only ${(h/100).toFixed(2)}% -- punitive tax or no real liquidity`):h<9e3&&(y=m.CAUTION,b=`round trip returns ${(h/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,token:s,base:p,router:u,verdict:y,reason:b,amountIn:String(o),bought:i.toString(),returned:f.toString(),retentionBps:h,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:o,amountIn:a,recipient:d,slippageBps:u=50,deadlineSeconds:p=900,path:c},i={}){let l=i.scanner,f=ue(l);if(!f)throw new Error(`chain ${e} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(d||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let h=c||[s,o],y=await this.quote({tokenIn:s,tokenOut:o,amountIn:a,path:h},i);if(y.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${y.evidence}: ${y.reason??"no reason given"})`);let b=Rt(y.amountOut,u);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let T=BigInt(Math.floor(Date.now()/1e3)+Number(p)),I=n&&h[0].toLowerCase()===n.toLowerCase()&&i.useNative,U=I?`0x${le.swapExactETHForTokens}`+q(b)+q(128)+W(d)+q(T)+q(h.length)+h.map(W).join(""):`0x${le.swapExactTokensForTokens}`+q(a)+q(b)+q(160)+W(d)+q(T)+q(h.length)+h.map(W).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:e,tx:{to:f,data:U,value:I?`0x${BigInt(a).toString(16)}`:"0x0"},guard:{quotedOut:y.amountOut,minOut:b.toString(),slippageBps:u,maxSlippageBps:de,deadline:T.toString()},requires:I?[]:[{step:"approve",token:h[0],spender:f,amount:String(a)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var $t=[100,500,3e3,1e4],Fe={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},P=t=>BigInt(t).toString(16).padStart(64,"0"),K=t=>t.slice(2).toLowerCase().padStart(64,"0"),De=/^0x[0-9a-fA-F]{40}$/,fe=100;function Bt(t,e){let n=Number(e);if(!Number.isFinite(n)||n<0)throw new Error("slippageBps must be a non-negative number");if(n>fe)throw new Error(`slippageBps ${n} exceeds the ${fe} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(n))/10000n}function pe(t,e){return(t?.venues||[]).find(n=>n.kind===e)?.address??null}function Ve(t){let{chainId:e,wrappedNative:n}=t;async function r({quoter:o,tokenIn:a,tokenOut:d,amountIn:u,fee:p},c){let i=`0x${Fe.quoteExactInputSingle}`+K(a)+K(d)+P(u)+P(p)+P(0),l=await _(e,"eth_call",[{to:o,data:i},"latest"],c).catch(()=>null),f=l?.result??l;if(!f||f==="0x"||f.length<66)return null;let h=BigInt(`0x${f.slice(2,66)}`);return h>0n?h:null}async function s({quoter:o,tokenIn:a,tokenOut:d,amountIn:u},p){let c=await Promise.all($t.map(async l=>{let f=await r({quoter:o,tokenIn:a,tokenOut:d,amountIn:u,fee:l},p);return{fee:l,amountOut:f?f.toString():null,out:f}})),i=null;for(let l of c)l.out&&(!i||l.out>i.amountOut)&&(i={fee:l.fee,amountOut:l.out});return{best:i,tried:c.map(({fee:l,amountOut:f})=>({fee:l,amountOut:f}))}}return{async quote({tokenIn:o,tokenOut:a,amountIn:d},u={}){let p=pe(u.scanner,"quoter");if(!p)return{chainId:e,evidence:v.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let l of[o,a])if(!De.test(l||""))throw new Error("quote requires valid 20-byte addresses");let{best:c,tried:i}=await s({quoter:p,tokenIn:o,tokenOut:a,amountIn:d},u);return c?{chainId:e,venue:"uniswap-v3",quoter:p,tokenIn:o,tokenOut:a,amountIn:String(d),amountOut:c.amountOut.toString(),fee:c.fee,useNative:!!n&&String(o).toLowerCase()===String(n).toLowerCase(),triedFeeTiers:i,evidence:v.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:e,quoter:p,tokenIn:o,tokenOut:a,triedFeeTiers:i,evidence:v.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:o,amountIn:a,base:d},u={}){let p=pe(u.scanner,"quoter"),c=(t.stableQuoteAssets||[]).map(S=>String(S).toLowerCase()),i=null;!d&&typeof t.resolveQuoteAsset=="function"&&(i=await t.resolveQuoteAsset(o,u).catch(()=>null));let l=String(o).toLowerCase(),f=String(n||"").toLowerCase();if(f&&l===f)return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};let h=d||i||(c[0]&&l!==c[0]?c[0]:null)||n;if(h&&l===String(h).toLowerCase())return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!p||!h)return{chainId:e,token:o,verdict:m.UNKNOWN,evidence:v.UNAVAILABLE,reason:p?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let y=await s({quoter:p,tokenIn:h,tokenOut:o,amountIn:a},u);if(!y.best){let S=c.find(w=>w&&w!==String(h).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await s({quoter:p,tokenIn:S,tokenOut:o,amountIn:a},u);if(w.best){let g=await s({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u);if(g.best){let A=g.best.amountOut,k=Number(A*10000n/BigInt(a)),x=m.PASS,N="round trip vs dollar book completes with expected fee/impact loss";return k<5e3?(x=m.FAIL,N=`round trip vs dollar book returns only ${(k/100).toFixed(2)}% -- punitive tax or no real liquidity`):k<9e3&&(x=m.CAUTION,N=`round trip vs dollar book returns ${(k/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:S,quoteAsset:S,verdict:x,reason:N,amountIn:String(a),bought:w.best.amountOut.toString(),returned:A.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:g.best.fee,evidence:v.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:e,token:o,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let b=await s({quoter:p,tokenIn:o,tokenOut:h,amountIn:y.best.amountOut},u);if(!b.best){let S=c.find(w=>w&&w!==String(h).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await s({quoter:p,tokenIn:S,tokenOut:o,amountIn:a},u),g=w.best?await s({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u):{best:null};if(w.best&&g.best){let A=g.best.amountOut,k=Number(A*10000n/BigInt(a)),x=m.PASS,N="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return k<5e3?(x=m.FAIL,N=`dollar-book round trip returns only ${(k/100).toFixed(2)}%`):k<9e3&&(x=m.CAUTION,N=`dollar-book round trip returns ${(k/100).toFixed(2)}%`),{chainId:e,venue:"uniswap-v3",token:o,base:S,quoteAsset:S,verdict:x,reason:N,amountIn:String(a),bought:w.best.amountOut.toString(),returned:A.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:g.best.fee,evidence:v.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:e,token:o,verdict:m.FAIL,evidence:v.LIVE,leg:"sell",bought:y.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let T=b.best.amountOut,I=Number(T*10000n/BigInt(a)),U=m.PASS,E="round trip completes with expected fee/impact loss";return I<5e3?(U=m.FAIL,E=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(U=m.CAUTION,E=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:h,verdict:U,reason:E,amountIn:String(a),bought:y.best.amountOut.toString(),returned:T.toString(),retentionBps:I,buyFee:y.best.fee,sellFee:b.best.fee,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:o,tokenOut:a,amountIn:d,recipient:u,slippageBps:p=50,fee:c},i={}){let l=pe(i.scanner,"router");if(!l)throw new Error(`chain ${e} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!De.test(u||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:o,tokenOut:a,amountIn:d},i);if(f.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let h=c??f.fee,y=Bt(f.amountOut,p);if(y<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let b=!!(i.useNative||f.useNative)&&n&&String(o).toLowerCase()===String(n).toLowerCase(),T=`0x${Fe.exactInputSingle}`+K(o)+K(a)+P(h)+K(u)+P(d)+P(y)+P(0);return{unsigned:!0,signedBy:"user-wallet",chainId:e,venue:"uniswap-v3",tx:{to:l,data:T,value:b?String(d):"0x0"},guard:{quotedOut:f.amountOut,minOut:y.toString(),slippageBps:p,maxSlippageBps:fe,fee:h},requires:b?[]:[{step:"approve",token:o,spender:l,amount:String(d)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var J={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function He(t){if(!t||t==="0x")return null;try{return BigInt(t)}catch{return null}}function Me(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length>=128){let r=Number(BigInt(`0x${e.slice(64,128)}`));if(r>0&&r<=256&&e.length>=128+r*2){let s=e.slice(128,128+r*2),o=Buffer.from(s,"hex").toString("utf8").replace(/\0+$/,"");if(o)return o}}return Buffer.from(e.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function Pt(t){let{chainId:e}=t;async function n(r,s,o){return _(e,"eth_call",[{to:r,data:s},"latest"],o)}return{async blockNumber(r={}){let s=await qe(e,r);return{chainId:e,blockNumber:s?.blockNumber??s,evidence:v.LIVE}},async nativeBalance(r,s={}){let o=await Ue(e,r,s);return{chainId:e,address:r,wei:o?.wei??o?.balance??null,symbol:t.nativeCurrency?.symbol??null,decimals:t.nativeCurrency?.decimals??18,evidence:v.LIVE}},async tokenBalance({token:r,owner:s},o={}){let a=await Le({chainId:e,token:r,owner:s},o);return{chainId:e,token:r,owner:s,raw:a?.balance??a,evidence:v.LIVE}},async resolveToken(r,s={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:e,token:r,evidence:v.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,a,d,u]=await Promise.all([n(r,J.decimals,s).catch(()=>null),n(r,J.symbol,s).catch(()=>null),n(r,J.name,s).catch(()=>null),n(r,J.totalSupply,s).catch(()=>null)]),p=He(o?.result??o),c=p!==null||a?.result||d?.result,i={chainId:e,address:r,decimals:p===null?null:Number(p),symbol:Me(a?.result??a),name:Me(d?.result??d),totalSupply:(He(u?.result??u)??null)?.toString()??null,evidence:c?v.LIVE:v.UNKNOWN};return c||(i.warning="no ERC-20 metadata returned -- may not be a token contract"),i},async resolvePools(r,s={}){let o=t.dexscreenerSlug;if(!o)return{chainId:e,token:r,pools:[],evidence:v.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let a=await $e(r,s).catch(()=>null),u=(a?.pairs||a?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(o).toLowerCase()).map(c=>({pair:c.pairAddress,dex:c.dexId,base:c.baseToken?.address,quote:c.quoteToken?.address,liquidityUsd:c.liquidity?.usd??null,priceUsd:c.priceUsd??null,volume24hUsd:c.volume?.h24??null,createdAt:c.pairCreatedAt??null})).sort((c,i)=>(i.liquidityUsd??0)-(c.liquidityUsd??0)),p=ie(r,u,{stables:t.stableQuoteAssets||[],wrappedNative:t.wrappedNative});return{chainId:e,token:r,pools:p,topPool:p[0]||null,quoteAsset:Re(r,p),evidence:p.length?v.LIVE:v.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:s,address:o,topics:a,chunkSize:d=2e3}={},u={}){if(!Number.isInteger(r)||!Number.isInteger(s))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(s<r)throw new Error("toBlock must be >= fromBlock");let p=[],c=[];for(let l=r;l<=s;l+=d){let f=Math.min(l+d-1,s);c.push([l,f])}let i=await Ce(c,4,async([l,f])=>{let h={fromBlock:`0x${l.toString(16)}`,toBlock:`0x${f.toString(16)}`};o&&(h.address=o),a&&(h.topics=a);let y=await _(e,"eth_getLogs",[h],u).catch(b=>({error:String(b?.message||b)}));return{start:l,end:f,res:y}});for(let{start:l,end:f,res:h}of i){if(h?.error)return{chainId:e,fromBlock:r,toBlock:s,logs:p,complete:!1,failedAt:[l,f],error:h.error,evidence:v.UNKNOWN};for(let y of h?.result??h??[])p.push(y)}return{chainId:e,fromBlock:r,toBlock:s,logs:p,complete:!0,chunks:c.length,evidence:v.LIVE}},async scoreRisk(r,s={}){let o=[],a=m.PASS,d=c=>{let i={[m.PASS]:0,[m.CAUTION]:1,[m.UNKNOWN]:2,[m.FAIL]:3};i[c]>i[a]&&(a=c)},[u,p]=await Promise.all([this.resolveToken(r,s),this.resolvePools(r,s)]);if(u.evidence!==v.LIVE?(o.push({check:"erc20-metadata",result:m.UNKNOWN,detail:u.warning}),d(m.UNKNOWN)):o.push({check:"erc20-metadata",result:m.PASS,detail:`${u.symbol} / ${u.decimals}d`}),p.evidence===v.UNAVAILABLE)o.push({check:"liquidity",result:m.UNKNOWN,detail:p.reason}),d(m.UNKNOWN);else if(!p.pools.length)o.push({check:"liquidity",result:m.FAIL,detail:"no pool with liquidity found"}),d(m.FAIL);else{let c=p.pools[0],i=c.liquidityUsd??0;i<5e3?(o.push({check:"liquidity",result:m.CAUTION,detail:`top pool only $${i}`}),d(m.CAUTION)):o.push({check:"liquidity",result:m.PASS,detail:`$${i} on ${c.dex}`}),c.createdAt&&Date.now()-c.createdAt<24*3600*1e3&&(o.push({check:"age",result:m.CAUTION,detail:"pool under 24h old"}),d(m.CAUTION))}if(typeof this.sellSimulation=="function"){let c=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},s).catch(i=>({verdict:m.UNKNOWN,reason:String(i?.message||i)}));o.push({check:"sellability",result:c.verdict,detail:c.retentionBps!=null?`round trip returns ${(c.retentionBps/100).toFixed(2)}% -- ${c.reason}`:c.reason}),d(c.verdict)}else o.push({check:"sellability",result:m.UNKNOWN,detail:"no verified router on this chain, so a round-trip sell simulation cannot run. Treat as unproven -- a buy path is not an exit path."}),d(m.UNKNOWN);return{chainId:e,token:r,verdict:a,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function je(t){let n={...Pt(t)},r=new Set((t.venues||[]).map(o=>o.kind));t.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(n,Ve({chainId:t.chainId,wrappedNative:t.wrappedNative,stableQuoteAssets:t.stableQuoteAssets||[],resolveQuoteAsset:async(o,a)=>(await n.resolvePools(o,a)).quoteAsset||null})):t.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(n,Oe({chainId:t.chainId,wrappedNative:t.wrappedNative}));let s={};for(let[o,a]of Object.entries(n))s[o]=a.bind(n);return{key:t.key,chainId:t.chainId,name:t.name,rpcEnv:t.rpcEnv,nativeCurrency:t.nativeCurrency,explorer:t.explorer,venues:t.venues||[],capabilities:s}}var Ot=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function ze(){return Ot.map(t=>Be(je(t)))}ze();var[We,...Ke]=process.argv.slice(2),X=Ke.includes("--json"),C=Ke.filter(t=>t!=="--json");function F(t){t||R("missing <chain>");let e=ce(Number(t));if(e)return e;let n=Y().find(r=>r.key===String(t).toLowerCase());if(n)return n;R(`unknown chain "${t}". Known: ${Y().map(r=>`${r.key}(${r.chainId})`).join(", ")}`)}function R(t){console.error(`error: ${t}`),process.exit(1)}function O(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
8
8
|
`)}function Ft(t,e){let n=String(e?.message||e);return/rpc|fetch|ECONN|timeout|provider/i.test(n)?`${n}
|
|
9
9
|
|
|
10
10
|
This chain reads its RPC from: ${t.rpcEnv.join(" or ")}
|