@oracle-agent/oracle 0.35.21 → 0.35.22
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/README.md +24 -1
- package/dist/agent-lifecycle.mjs +3 -0
- package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/bin/desk-server.mjs +36 -36
- package/dist/bin/oracle-mev-arb-shadow.mjs +4 -4
- package/dist/bin/oracle-mev-shadow.mjs +6 -6
- package/dist/bin/oracle-route.mjs +11 -11
- package/dist/bin/oracle-scan.mjs +15 -15
- package/dist/bin/oracle.mjs +19 -10
- package/dist/cli/commands/chat.mjs +1 -1
- package/dist/cli/commands/context.mjs +16 -0
- package/dist/cli/commands/doctor.mjs +5 -5
- package/dist/cli/commands/eval.mjs +89 -89
- package/dist/cli/commands/lifecycle.mjs +17 -0
- package/dist/cli/commands/model.mjs +1 -1
- package/dist/cli/commands/quickstart.mjs +5 -5
- package/dist/cli/commands/sign.mjs +1 -1
- package/dist/cli/commands/signer.mjs +22 -22
- package/dist/cli/commands/snipe.mjs +4 -4
- package/dist/cli/commands/swap.mjs +4 -4
- package/dist/cli/commands/venues.mjs +2 -2
- package/dist/context-graph.mjs +3 -0
- package/dist/data/desk-data.mjs +34 -34
- package/dist/data/providers/lp-destination-discovery.mjs +6 -0
- package/dist/data/providers/lp-liquidity-ranker.mjs +1 -0
- package/dist/index.mjs +50 -48
- package/dist/local-signer/anvil-attestation-worker.mjs +1 -1
- package/dist/local-signer/runtime.mjs +1 -1
- package/dist/router/index.mjs +3 -3
- package/dist/router/prepare-bridge.mjs +2 -2
- package/dist/scanner/index.mjs +4 -4
- package/dist/tenant-rbac.mjs +1 -1
- package/dist/workflow-telemetry.mjs +1 -1
- package/package.json +5 -1
- package/public/eval-report.json +1 -1
- package/public/oracle-splash/brand/liquidlaunch.webp +0 -0
- package/public/oracle-splash/brand/markets.webp +0 -0
- package/public/oracle-splash/brand/motion.webp +0 -0
- package/public/oracle-splash/brand/nest.webp +0 -0
- package/public/oracle-splash/brand/outcome.webp +0 -0
- package/public/oracle-splash/brand/silhouette.webp +0 -0
- package/public/oracle-splash/brand/tradexyz.webp +0 -0
- package/public/oracle-splash/index.html +9 -9
- package/server.json +2 -2
package/dist/bin/oracle-scan.mjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createHash as me}from"node:crypto";import B from"node:net";import Ge from"node:dns";var Ye=new Set(["localhost","metadata.google.internal","metadata.goog"]);function Q(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let
|
|
3
|
-
`),p=me("sha256").update(u).digest("hex").slice(0,32),c=`${
|
|
2
|
+
import{createHash as me}from"node:crypto";import B from"node:net";import Ge from"node:dns";var Ye=new Set(["localhost","metadata.google.internal","metadata.goog"]);function Q(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let n=c=>{if(!c)return[];let i=c.split(":"),l=i.at(-1);if(l?.includes(".")){let f=l.split(".").map(Number);if(f.length!==4||f.some(h=>!Number.isInteger(h)||h<0||h>255))return null;i.splice(i.length-1,1,(f[0]<<8|f[1]).toString(16),(f[2]<<8|f[3]).toString(16))}return i.some(f=>!/^[0-9a-f]{1,4}$/.test(f))?null:i.map(f=>Number.parseInt(f,16))},[r,s]=e.split("::"),o=n(r),a=n(s);if(!o||!a)return null;let d=e.includes("::"),u=8-o.length-a.length;if(!d&&u!==0||d&&u<1)return null;let p=[...o,...Array(Math.max(0,u)).fill(0),...a];return p.length!==8?null:Uint8Array.from(p.flatMap(c=>[c>>8,c&255]))}function Z(t,e,n){let r=Math.floor(n/8),s=n%8;for(let a=0;a<r;a+=1)if(t[a]!==e[a])return!1;if(!s)return!0;let o=255<<8-s;return(t[r]&o)===(e[r]&o)}function ee(t){if(B.isIPv4(t)){let e=t.split(".").map(Number);return!(e[0]===0||e[0]===10||e[0]===127||e[0]>=224||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&(e[1]===0||e[1]===2||e[1]===168)||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&(e[1]===18||e[1]===19||e[1]===51)||e[0]===203&&e[1]===0&&e[2]===113)}if(B.isIPv6(t)){let e=Q(t);if(!e)return!1;let n=Q("::ffff:0:0");return Z(e,n,96)?ee([...e.slice(12)].join(".")):Z(e,Q("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([s,o])=>Z(e,Q(s),o)):!1}return!1}function Je(t){let e;try{e=new URL(String(t))}catch{return{ok:!1,error:`not a valid URL: ${String(t).slice(0,120)}`}}if(e.protocol!=="http:"&&e.protocol!=="https:")return{ok:!1,error:`refused protocol ${e.protocol} (only http/https)`};let n=e.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(Ye.has(n)||n.endsWith(".localhost")||n.endsWith(".internal"))return{ok:!1,error:`refused internal host ${n}`};let r=B.isIP(n);return r!==0&&!ee(n)?{ok:!1,error:`refused private address ${n}`}:{ok:!0,url:e,host:n,isLiteralIp:r!==0}}async function te(t,{lookupFn:e=Ge.promises.lookup}={}){let n=Je(t);if(!n.ok)return n;if(n.isLiteralIp)return{ok:!0,url:n.url,addresses:[{address:n.host,family:B.isIPv6(n.host)?6:4}]};let r;try{r=await e(n.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${n.host} did not resolve`}}return!Array.isArray(r)||r.length===0||r.some(s=>!ee(s.address))?{ok:!1,error:`refused: ${n.host} resolves to a non-public address`}:{ok:!0,url:n.url,addresses:r}}async function ne({requireUndici:t=!1,importUndici:e=()=>import("undici")}={}){let n,r;try{let i=await e();n=i.Agent,r=i.fetch}catch(i){if(t)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${i?.message||i}`);return null}if(typeof n!="function"||typeof r!="function"){if(t)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let s=i=>String(i).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),o=new Map,a=i=>(Array.isArray(i)?i:[i]).map(l=>typeof l=="string"?{address:l}:l).filter(l=>l&&l.address).map(l=>({address:l.address,family:l.family||(B.isIPv6(l.address)?6:4)})),d=(i,l,f)=>{o.set(s(i),a(typeof l=="string"?[{address:l,family:f}]:l))},u=i=>{let l=s(i);if(B.isIP(l))return[{address:l,family:B.isIPv6(l)?6:4}];let f=o.get(l);if(!f||!f.length)throw new Error(`refused: unpinned host ${i} during pinned fetch`);return f},p=new n({connect:{lookup(i,l,f){let h;try{h=u(i)}catch(y){return f(y)}return l?.all?f(null,h):f(null,h[0].address,h[0].family)}}}),c=Xe((i,l={})=>r(i,{...l,dispatcher:p}),d);return{dispatcher:p,fetch:c,pin:d,resolve:u,async close(){try{await p.destroy()}catch{}}}}var re=Symbol.for("oracle.egressGuard.pinCapableFetch");function Xe(t,e){if(typeof t!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof e!="function")throw new Error("markPinCapableFetch: pin must be a function");return t[re]=Object.freeze({pin:e}),t}function oe(t){return typeof t=="function"&&typeof t[re]?.pin=="function"}function he(t,e,n){if(!oe(t))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");t[re].pin(e,n)}var Ze=new Set([408,425,429,500,502,503,504]),be=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),et=2,ve=4e3,Ee=["authorization","x-api-key","x-tensor-api-key","0x-api-key","api-key","cookie","proxy-authorization"],tt=new Set([301,302,303,307,308]),ye=3,nt=64*1024;function rt(t){let e=String(t||"").toLowerCase();return Ee.includes(e)||/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(e)}function ot(t){let e={};for(let[n,r]of Object.entries(t||{}))rt(n)||(e[n]=r);return e}function st(t,e){if(!t)throw new Error(`HTTP redirect from ${e} missing Location`);let n=new URL(String(t),String(e));if(n.protocol!=="http:"&&n.protocol!=="https:")throw new Error(`HTTP redirect from ${e} used unsupported protocol ${n.protocol}`);return n.toString()}function at(t,e){return new URL(String(t)).origin===new URL(String(e)).origin}var se=new Map,it=/(?:^|_)(send|submit|broadcast|sign|requestAirdrop)(?=[A-Z_]|$)/i,ct=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function ge(t){let e=String(t?.method||"");return e?!it.test(e):!1}function ut(t,e){if(t==="GET"&&e==null)return!0;if(t!=="POST"||e==null)return!1;let n=e;if(typeof e=="string")try{n=JSON.parse(e)}catch{return!1}return Array.isArray(n)?n.length>0&&n.every(ge):!n||typeof n!="object"?!1:n.jsonrpc&&n.method?ge(n):typeof n.type=="string"&&ct.has(n.type)&&n.action==null&&n.signature==null&&n.nonce==null}function lt(t,e,n,r={},s=null){let o={};for(let[l,f]of Object.entries(n||{}))o[l.toLowerCase()]=f;let a=Object.keys(o).filter(l=>/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(l)),u=[...new Set([...Ee,...a])].sort().map(l=>`${l}=${o[l]??""}`).join(`
|
|
3
|
+
`),p=me("sha256").update(u).digest("hex").slice(0,32),c=`${r.untrustedUrl?"untrusted":"trusted"}:${r.maxResponseBytes??"unbounded"}`,i=s==null?"-":me("sha256").update(String(s)).digest("hex").slice(0,32);return`${t} ${e} ${c} ${p} ${i}`}function dt(t,e){let n=Number(e);return Number.isFinite(n)&&n>0?Math.min(n*1e3,ve):Math.min(250*2**t,ve)+Math.floor(Math.random()*100)}var pt=t=>new Promise(e=>setTimeout(e,t));function V(t,e={}){let n=new Error(t);return n.retryable=!1,Object.assign(n,e),n}function ae(t,e,n){return V(`HTTP response from ${t} exceeded maxResponseBytes ${n} (${e})`,{oversize:!0})}function H(t){try{let e=t?.body?.cancel?.();e&&typeof e.then=="function"&&e.catch(()=>{})}catch{}}function ft(t){return t?t.byteLength??t.length??0:0}async function we(t,e,{url:n,truncate:r=!1,onOversize:s}={}){if(e==null)return await t.text();let o=Number(t.headers?.get?.("content-length"));if(Number.isFinite(o)&&o>e&&(H(t),!r))throw ae(n,`content-length ${o}`,e);let a=t.body?.getReader?.();if(!a){let i=await t.text(),l=Buffer.byteLength(i,"utf8");if(l>e){if(!r)throw ae(n,`body ${l} bytes`,e);return Buffer.from(i,"utf8").subarray(0,e).toString("utf8")}return i}let d=[],u=0,p=!1;try{for(;;){let{value:i,done:l}=await a.read();if(l)break;if(i&&(d.push(Buffer.from(i)),u+=ft(i),u>e)){p=!0;break}}}finally{if(p)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(p&&(typeof s=="function"&&s(),!r))throw ae(n,`streamed ${u} bytes`,e);let c=Buffer.concat(d);return(p?c.subarray(0,e):c).toString("utf8")}function Se(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function ht(t,{fetchImpl:e,method:n,headers:r,body:s,timeoutMs:o,lookupFn:a,realFetch:d,untrustedUrl:u=!1,maxResponseBytes:p=null,importUndici:c,validateResponse:i,signal:l}){let f=new AbortController,h=setTimeout(()=>f.abort(),o),y=l?typeof AbortSignal.any=="function"?AbortSignal.any([l,f.signal]):l:f.signal,b=null,T=e,I=a?{lookupFn:a}:{};if(u&&!d&&!oe(T))throw V(`HTTP refused ${t}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let U=async(E,{status:S=null}={})=>{let w=await te(E,I);if(!w.ok)throw V(S==null?`HTTP refused ${E}: ${w.error}`:`HTTP redirect to ${E} ${w.error}`,S==null?{}:{status:S});let g=new URL(E).hostname;if(d){if(b&&(await b.close(),b=null),!b)try{b=await ne({requireUndici:!0,...c?{importUndici:c}:{}})}catch(A){throw V(S==null?`HTTP refused ${E}: ${A?.message||A}`:`HTTP redirect to ${E} refused: ${A?.message||A}`,S==null?{}:{status:S})}b.pin(g,w.addresses),T=b.fetch}else he(T,g,w.addresses);return w};try{let E=String(t),S={...r||{}};u&&await U(E);for(let w=0;w<=ye;w+=1){let g=await T(E,{method:n,headers:S,body:s,signal:y,redirect:"manual"});if(tt.has(g.status)){if(n!=="GET"&&n!=="HEAD"){let L=await we(g,p??nt,{url:E,truncate:!0}),$=new Error(`HTTP ${g.status} ${n} ${E} redirected non-idempotent request`);throw $.status=g.status,$.body=Se(L)??L.slice(0,300),$}if(w===ye)throw H(g),new Error(`HTTP redirect loop for ${t}`);let x=g.headers?.get?.("location"),N;try{N=st(x,E)}catch(L){throw H(g),L}let D=!at(N,E);if(H(g),D&&(S=ot(S)),u)await U(N,{status:g.status});else if(D){let L=await te(N,I);if(!L.ok){let $=new Error(`HTTP redirect from ${E} ${L.error}`);throw $.status=g.status,$.retryable=!1,$}d&&L.addresses?.length&&(b||(b=await ne(c?{importUndici:c}:{})),b&&(b.pin(new URL(N).hostname,L.addresses),T=b.fetch))}E=N;continue}if(typeof i=="function")try{await i(g,{url:E})}catch(x){throw H(g),V(x?.message||String(x))}let A=await we(g,p,{url:E,onOversize:()=>f.abort()}),k=Se(A);if(!g.ok){let x=new Error(`HTTP ${g.status} ${n} ${E}`);throw x.status=g.status,x.retryAfter=g.headers?.get?.("retry-after")??null,x.body=k??A.slice(0,300),x}return k??A}throw new Error(`HTTP redirect loop for ${t}`)}finally{clearTimeout(h),b&&await b.close()}}async function G(t,e={}){let n=e.fetchImpl||globalThis.fetch;if(typeof n!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let r=e.timeoutMs??12e3,s=(e.method||"GET").toUpperCase(),o={Accept:"application/json",...e.headers||{}},a=e.body;a!=null&&typeof a!="string"&&(o["Content-Type"]=o["Content-Type"]||"application/json",a=JSON.stringify(a));let d=Number.isInteger(e.retries)?Math.max(e.retries,0):et,u=e.lookupFn,p=!e.fetchImpl,c=e.untrustedUrl===!0,i=e.importUndici,l=e.validateResponse,f=e.signal,h=Number(e.maxResponseBytes),y=Number.isFinite(h)&&h>0?Math.floor(h):null,b=async()=>{let S;for(let w=0;w<=d;w++){f?.throwIfAborted?.();try{return await ht(t,{fetchImpl:n,method:s,headers:o,body:a,timeoutMs:r,lookupFn:u,realFetch:p,untrustedUrl:c,maxResponseBytes:y,importUndici:i,validateResponse:l,signal:f})}catch(g){S=g;let A=g?.status,k=g?.name==="AbortError"||g?.name==="TimeoutError"||f?.aborted,x=new Set([408,425,429]),N=g?.retryable===!1?!1:A!=null?x.has(A)||Ze.has(A)&&be.has(s):!k&&be.has(s);if(w===d||!N)throw g;let D=dt(w,g?.retryAfter);f?await new Promise((L,$)=>{let Qe=setTimeout(L,D);f.addEventListener("abort",()=>{clearTimeout(Qe),$(f.reason||new DOMException("Aborted","AbortError"))},{once:!0})}):await pt(D)}}throw S};if(!(e.dedupe!==!1&&!f&&ut(s,a)))return b();let I=lt(s,t,o,{untrustedUrl:c,maxResponseBytes:y},a),U=se.get(I);if(U)return U;let E=b().finally(()=>se.delete(I));return se.set(I,E),E}async function Ce(t,e,n){let r=Array.from(t),s=Math.max(1,Math.min(Number(e)||1,r.length||1)),o=new Array(r.length),a=0;return await Promise.all(Array.from({length:s},async()=>{for(;a<r.length;){let d=a++;o[d]=await n(r[d],d)}})),o}var xe={robinhood:{chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC"],evm:!0},ethereum:{chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],evm:!0},polygon:{chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],evm:!0},arbitrum:{chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],evm:!0},base:{chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],evm:!0},hyperevm:{chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],evm:!0},bsc:{chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],evm:!0},avalanche:{chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],evm:!0},optimism:{chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],evm:!0},abstract:{chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],evm:!0},stable:{chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],evm:!0}},mt=new Map(Object.values(xe).map(t=>[t.chainId,t]));function Ae(t){return mt.get(Number(t))||null}function Ie(t,e=process.env){let n=Ae(t);if(!n)return null;for(let r of n.rpcEnv){let s=(e[r]||"").trim();if(s)return s}return null}import{Interface as bt,getAddress as vt}from"ethers";var ke=new bt(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function Ne(t,e){try{return vt(t).toLowerCase()}catch{throw new Error(`${e} must be a valid EVM address`)}}var yt={1:"https://ethereum.publicnode.com",137:"https://polygon-bor-rpc.publicnode.com",42161:"https://arbitrum-one-rpc.publicnode.com",8453:"https://base-rpc.publicnode.com",10:"https://optimism-rpc.publicnode.com",988:"https://rpc.stable.xyz",56:"https://bsc-rpc.publicnode.com",43114:"https://avalanche-c-chain-rpc.publicnode.com",999:"https://rpc.hyperliquid.xyz/evm",2741:"https://api.mainnet.abs.xyz",4663:"https://rpc.mainnet.chain.robinhood.com"};function gt(t,{rpcUrl:e,env:n=process.env}={}){if(e)return e;let r=Ie(t,n);return r||yt[Number(t)]||null}var wt=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function St(t){let e=String(t||""),n=e.toLowerCase();if(e!==e.trim()||!/^[a-zA-Z0-9_]+$/.test(e)||!wt.test(n))throw new Error(`evm-rpc: ${e} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return n}var M=new Map,Te=new Map;function Et(t){let e=new Error(t?.message||JSON.stringify(t));return e.code=t?.code,e}function Ct(t){if(t?.error)throw Et(t.error);return t?.result}function xt(t,e,n){return`${t}
|
|
4
4
|
${e}
|
|
5
|
-
${JSON.stringify(
|
|
6
|
-
- ${
|
|
7
|
-
- `)}`);let a=t.capabilities||{},o=j.filter(d=>typeof a[d]=="function"),s={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:n,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)?s[d]=async(...u)=>a[d](...u,{scanner:s}):s[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(s)}var W=new Map;function Be(t){let e=qt(t);return W.set(e.chainId,e),e}function ce(t){return W.get(Number(t))||null}function Y(){return[...W.values()]}function Pe(){let t={};for(let e of W.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:W.size,capabilities:[...j],chains:t}}var le={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},L=t=>BigInt(t).toString(16).padStart(64,"0"),K=t=>t.slice(2).toLowerCase().padStart(64,"0");function Ut(t,e){return`0x${le.getAmountsOut}`+L(t)+L(64)+L(e.length)+e.map(K).join("")}function _t(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length<128)return null;let r=Number(BigInt(`0x${e.slice(64,128)}`));if(!Number.isFinite(r)||r<1||r>16)return null;let n=[];for(let a=0;a<r;a++){let o=128+a*64;if(e.length<o+64)return null;n.push(BigInt(`0x${e.slice(o,o+64)}`))}return n}function ue(t,e="router"){return(t?.venues||[]).find(n=>n.kind===e)?.address??null}var de=100;function Rt(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>de)throw new Error(`slippageBps ${r} 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(r))/10000n}function Fe(t){let{chainId:e,wrappedNative:r}=t;async function n(a,o,s,d){let u=await _(e,"eth_call",[{to:a,data:Ut(o,s)},"latest"],d);return _t(u?.result??u)}return{async quote({tokenIn:a,tokenOut:o,amountIn:s,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||[a,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 n(p,s,c,u);return i?{chainId:e,router:p,path:c,amountIn:String(s),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:a,amountIn:o,base:s},d={}){let u=ue(d.scanner),p=s||r;if(p&&String(a).toLowerCase()===String(p).toLowerCase())return{chainId:e,token:a,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:a,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 n(u,o,[p,a],d);if(!c)return{chainId:e,token:a,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:a,verdict:m.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let l=await n(u,i,[a,p],d);if(!l)return{chainId:e,token:a,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 h=l[l.length-1],f=Number(h*10000n/BigInt(o)),g=m.PASS,b="round trip completes with expected fee/impact loss";return f<5e3?(g=m.FAIL,b=`round trip returns only ${(f/100).toFixed(2)}% -- punitive tax or no real liquidity`):f<9e3&&(g=m.CAUTION,b=`round trip returns ${(f/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,token:a,base:p,router:u,verdict:g,reason:b,amountIn:String(o),bought:i.toString(),returned:h.toString(),retentionBps:f,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:a,tokenOut:o,amountIn:s,recipient:d,slippageBps:u=50,deadlineSeconds:p=900,path:c},i={}){let l=i.scanner,h=ue(l);if(!h)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 f=c||[a,o],g=await this.quote({tokenIn:a,tokenOut:o,amountIn:s,path:f},i);if(g.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${g.evidence}: ${g.reason??"no reason given"})`);let b=Rt(g.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=r&&f[0].toLowerCase()===r.toLowerCase()&&i.useNative,q=I?`0x${le.swapExactETHForTokens}`+L(b)+L(128)+K(d)+L(T)+L(f.length)+f.map(K).join(""):`0x${le.swapExactTokensForTokens}`+L(s)+L(b)+L(160)+K(d)+L(T)+L(f.length)+f.map(K).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:e,tx:{to:h,data:q,value:I?`0x${BigInt(s).toString(16)}`:"0x0"},guard:{quotedOut:g.amountOut,minOut:b.toString(),slippageBps:u,maxSlippageBps:de,deadline:T.toString()},requires:I?[]:[{step:"approve",token:f[0],spender:h,amount:String(s)}],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],Oe={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},P=t=>BigInt(t).toString(16).padStart(64,"0"),z=t=>t.slice(2).toLowerCase().padStart(64,"0"),De=/^0x[0-9a-fA-F]{40}$/,he=100;function Bt(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>he)throw new Error(`slippageBps ${r} exceeds the ${he} 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(r))/10000n}function pe(t,e){return(t?.venues||[]).find(r=>r.kind===e)?.address??null}function Ve(t){let{chainId:e,wrappedNative:r}=t;async function n({quoter:o,tokenIn:s,tokenOut:d,amountIn:u,fee:p},c){let i=`0x${Oe.quoteExactInputSingle}`+z(s)+z(d)+P(u)+P(p)+P(0),l=await _(e,"eth_call",[{to:o,data:i},"latest"],c).catch(()=>null),h=l?.result??l;if(!h||h==="0x"||h.length<66)return null;let f=BigInt(`0x${h.slice(2,66)}`);return f>0n?f:null}async function a({quoter:o,tokenIn:s,tokenOut:d,amountIn:u},p){let c=await Promise.all($t.map(async l=>{let h=await n({quoter:o,tokenIn:s,tokenOut:d,amountIn:u,fee:l},p);return{fee:l,amountOut:h?h.toString():null,out:h}})),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:h})=>({fee:l,amountOut:h}))}}return{async quote({tokenIn:o,tokenOut:s,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,s])if(!De.test(l||""))throw new Error("quote requires valid 20-byte addresses");let{best:c,tried:i}=await a({quoter:p,tokenIn:o,tokenOut:s,amountIn:d},u);return c?{chainId:e,venue:"uniswap-v3",quoter:p,tokenIn:o,tokenOut:s,amountIn:String(d),amountOut:c.amountOut.toString(),fee:c.fee,useNative:!!r&&String(o).toLowerCase()===String(r).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:s,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:s,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(),h=String(r||"").toLowerCase();if(h&&l===h)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 f=d||i||(c[0]&&l!==c[0]?c[0]:null)||r;if(f&&l===String(f).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||!f)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 g=await a({quoter:p,tokenIn:f,tokenOut:o,amountIn:s},u);if(!g.best){let S=c.find(w=>w&&w!==String(f).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await a({quoter:p,tokenIn:S,tokenOut:o,amountIn:s},u);if(w.best){let y=await a({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u);if(y.best){let x=y.best.amountOut,k=Number(x*10000n/BigInt(s)),A=m.PASS,N="round trip vs dollar book completes with expected fee/impact loss";return k<5e3?(A=m.FAIL,N=`round trip vs dollar book returns only ${(k/100).toFixed(2)}% -- punitive tax or no real liquidity`):k<9e3&&(A=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:A,reason:N,amountIn:String(s),bought:w.best.amountOut.toString(),returned:x.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:y.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 a({quoter:p,tokenIn:o,tokenOut:f,amountIn:g.best.amountOut},u);if(!b.best){let S=c.find(w=>w&&w!==String(f).toLowerCase()&&w!==String(o).toLowerCase());if(S){let w=await a({quoter:p,tokenIn:S,tokenOut:o,amountIn:s},u),y=w.best?await a({quoter:p,tokenIn:o,tokenOut:S,amountIn:w.best.amountOut},u):{best:null};if(w.best&&y.best){let x=y.best.amountOut,k=Number(x*10000n/BigInt(s)),A=m.PASS,N="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return k<5e3?(A=m.FAIL,N=`dollar-book round trip returns only ${(k/100).toFixed(2)}%`):k<9e3&&(A=m.CAUTION,N=`dollar-book round trip returns ${(k/100).toFixed(2)}%`),{chainId:e,venue:"uniswap-v3",token:o,base:S,quoteAsset:S,verdict:A,reason:N,amountIn:String(s),bought:w.best.amountOut.toString(),returned:x.toString(),retentionBps:k,buyFee:w.best.fee,sellFee:y.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:g.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(s)),q=m.PASS,E="round trip completes with expected fee/impact loss";return I<5e3?(q=m.FAIL,E=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(q=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:f,verdict:q,reason:E,amountIn:String(s),bought:g.best.amountOut.toString(),returned:T.toString(),retentionBps:I,buyFee:g.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:s,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 h=await this.quote({tokenIn:o,tokenOut:s,amountIn:d},i);if(h.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${h.evidence}: ${h.reason??"no reason given"})`);let f=c??h.fee,g=Bt(h.amountOut,p);if(g<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let b=!!(i.useNative||h.useNative)&&r&&String(o).toLowerCase()===String(r).toLowerCase(),T=`0x${Oe.exactInputSingle}`+z(o)+z(s)+P(f)+z(u)+P(d)+P(g)+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:h.amountOut,minOut:g.toString(),slippageBps:p,maxSlippageBps:he,fee:f},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 n=Number(BigInt(`0x${e.slice(64,128)}`));if(n>0&&n<=256&&e.length>=128+n*2){let a=e.slice(128,128+n*2),o=Buffer.from(a,"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 r(n,a,o){return _(e,"eth_call",[{to:n,data:a},"latest"],o)}return{async blockNumber(n={}){let a=await Le(e,n);return{chainId:e,blockNumber:a?.blockNumber??a,evidence:v.LIVE}},async nativeBalance(n,a={}){let o=await qe(e,n,a);return{chainId:e,address:n,wei:o?.wei??o?.balance??null,symbol:t.nativeCurrency?.symbol??null,decimals:t.nativeCurrency?.decimals??18,evidence:v.LIVE}},async tokenBalance({token:n,owner:a},o={}){let s=await Ue({chainId:e,token:n,owner:a},o);return{chainId:e,token:n,owner:a,raw:s?.balance??s,evidence:v.LIVE}},async resolveToken(n,a={}){if(!/^0x[0-9a-fA-F]{40}$/.test(n||""))return{chainId:e,token:n,evidence:v.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,s,d,u]=await Promise.all([r(n,J.decimals,a).catch(()=>null),r(n,J.symbol,a).catch(()=>null),r(n,J.name,a).catch(()=>null),r(n,J.totalSupply,a).catch(()=>null)]),p=He(o?.result??o),c=p!==null||s?.result||d?.result;return{chainId:e,address:n,decimals:p===null?null:Number(p),symbol:Me(s?.result??s),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(n,a={}){let o=t.dexscreenerSlug;if(!o)return{chainId:e,token:n,pools:[],evidence:v.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let s=await $e(n,a).catch(()=>null),u=(s?.pairs||s?.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(n,u,{stables:t.stableQuoteAssets||[],wrappedNative:t.wrappedNative});return{chainId:e,token:n,pools:p,topPool:p[0]||null,quoteAsset:Re(n,p),evidence:p.length?v.LIVE:v.UNKNOWN}},async scanBlocks({fromBlock:n,toBlock:a,address:o,topics:s,chunkSize:d=2e3}={},u={}){if(!Number.isInteger(n)||!Number.isInteger(a))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(a<n)throw new Error("toBlock must be >= fromBlock");let p=[],c=[];for(let l=n;l<=a;l+=d){let h=Math.min(l+d-1,a);c.push([l,h])}let i=await Ce(c,4,async([l,h])=>{let f={fromBlock:`0x${l.toString(16)}`,toBlock:`0x${h.toString(16)}`};o&&(f.address=o),s&&(f.topics=s);let g=await _(e,"eth_getLogs",[f],u).catch(b=>({error:String(b?.message||b)}));return{start:l,end:h,res:g}});for(let{start:l,end:h,res:f}of i){if(f?.error)return{chainId:e,fromBlock:n,toBlock:a,logs:p,complete:!1,failedAt:[l,h],error:f.error,evidence:v.UNKNOWN};for(let g of f?.result??f??[])p.push(g)}return{chainId:e,fromBlock:n,toBlock:a,logs:p,complete:!0,chunks:c.length,evidence:v.LIVE}},async scoreRisk(n,a={}){let o=[],s=m.PASS,d=c=>{let i={[m.PASS]:0,[m.CAUTION]:1,[m.UNKNOWN]:2,[m.FAIL]:3};i[c]>i[s]&&(s=c)},[u,p]=await Promise.all([this.resolveToken(n,a),this.resolvePools(n,a)]);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:n,amountIn:(10n**16n).toString()},a).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:n,verdict:s,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function je(t){let r={...Pt(t)},n=new Set((t.venues||[]).map(o=>o.kind));t.venueKind==="uniswap-v3"&&n.has("quoter")&&n.has("router")?Object.assign(r,Ve({chainId:t.chainId,wrappedNative:t.wrappedNative,stableQuoteAssets:t.stableQuoteAssets||[],resolveQuoteAsset:async(o,s)=>(await r.resolvePools(o,s)).quoteAsset||null})):t.venueKind==="uniswap-v2"&&n.has("router")&&Object.assign(r,Fe({chainId:t.chainId,wrappedNative:t.wrappedNative}));let a={};for(let[o,s]of Object.entries(r))a[o]=s.bind(r);return{key:t.key,chainId:t.chainId,name:t.name,rpcEnv:t.rpcEnv,nativeCurrency:t.nativeCurrency,explorer:t.explorer,venues:t.venues||[],capabilities:a}}var Ft=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 We(){return Ft.map(t=>Be(je(t)))}We();var[Ke,...ze]=process.argv.slice(2),X=ze.includes("--json"),C=ze.filter(t=>t!=="--json");function O(t){t||R("missing <chain>");let e=ce(Number(t));if(e)return e;let r=Y().find(n=>n.key===String(t).toLowerCase());if(r)return r;R(`unknown chain "${t}". Known: ${Y().map(n=>`${n.key}(${n.chainId})`).join(", ")}`)}function R(t){console.error(`error: ${t}`),process.exit(1)}function F(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
8
|
-
`)}function
|
|
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
|
+
- ${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)}
|
|
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 ")}
|
|
11
|
-
Set one, e.g.: export ${t.rpcEnv[0]}=https://...`:
|
|
12
|
-
`);let e=Object.entries(t.chains).map(([
|
|
11
|
+
Set one, e.g.: export ${t.rpcEnv[0]}=https://...`:n}try{switch(We){case"chains":{let t=Pe();if(X){O(t);break}console.log(`${t.chainCount} chains registered
|
|
12
|
+
`);let e=Object.entries(t.chains).map(([r,s])=>({chain:`${s.key} (${r})`,caps:s.supported.length,routing:s.failClosed?"fail-closed (no verified venue)":`${s.venueCount} venue(s)`})),n=Math.max(...e.map(r=>r.chain.length));for(let r of e)console.log(` ${r.chain.padEnd(n)} ${String(r.caps).padStart(2)} caps ${r.routing}`);console.log(`
|
|
13
13
|
Every chain is read/research capable. Routing value requires a verified
|
|
14
|
-
venue -- see CONTRIBUTING.md for the verification rule.`);break}case"head":{let t=
|
|
15
|
-
`);for(let
|
|
16
|
-
${e.note}`);break}case"quote":{let t=
|
|
17
|
-
Add a venue with recorded provenance -- see docs/adding-a-chain.md.`);let e=C[3]||(10n**18n).toString();
|
|
18
|
-
Without it, treat every token on this chain as unproven for exit.`);let e=C[2]||(10n**16n).toString(),
|
|
19
|
-
${
|
|
20
|
-
`)),process.exit(
|
|
14
|
+
venue -- see CONTRIBUTING.md for the verification rule.`);break}case"head":{let t=F(C[0]);O(await t.blockNumber());break}case"token":{let t=F(C[0]);C[1]||R("usage: oracle-scan token <chain> <address>"),O(await t.resolveToken(C[1]));break}case"pools":{let t=F(C[0]);C[1]||R("usage: oracle-scan pools <chain> <address>");let e=await t.resolvePools(C[1]);if(X){O(e);break}console.log(`evidence: ${e.evidence}`),e.reason&&console.log(`reason: ${e.reason}`);for(let n of e.pools.slice(0,10)){let r=n.liquidityUsd==null?"?":`$${Math.round(n.liquidityUsd).toLocaleString()}`;console.log(` ${n.dex.padEnd(12)} ${r.padStart(14)} ${n.pair}`)}e.pools.length||console.log(" (no pools with liquidity found)");break}case"risk":{let t=F(C[0]);C[1]||R("usage: oracle-scan risk <chain> <address>");let e=await t.scoreRisk(C[1]);if(X){O(e);break}console.log(`verdict: ${e.verdict}
|
|
15
|
+
`);for(let n of e.checks)console.log(` ${n.result.padEnd(8)} ${n.check.padEnd(16)} ${n.detail??""}`);console.log(`
|
|
16
|
+
${e.note}`);break}case"quote":{let t=F(C[0]);(!C[1]||!C[2])&&R("usage: oracle-scan quote <chain> <tokenIn> <tokenOut> [amountIn]"),t.supports("quote")||R(`${t.key} has no verified router, so quoting stays fail-closed.
|
|
17
|
+
Add a venue with recorded provenance -- see docs/adding-a-chain.md.`);let e=C[3]||(10n**18n).toString();O(await t.quote({tokenIn:C[1],tokenOut:C[2],amountIn:e}));break}case"sell":{let t=F(C[0]);C[1]||R("usage: oracle-scan sell <chain> <token> [amountIn]"),t.supports("sellSimulation")||R(`${t.key} has no verified router, so sell simulation is unavailable.
|
|
18
|
+
Without it, treat every token on this chain as unproven for exit.`);let e=C[2]||(10n**16n).toString(),n=await t.sellSimulation({token:C[1],amountIn:e});if(X){O(n);break}console.log(`verdict: ${n.verdict}`),console.log(`reason: ${n.reason??""}`),n.retentionBps!=null&&console.log(`retention: ${(n.retentionBps/100).toFixed(2)}%`),n.leg&&console.log(`failed at: ${n.leg} leg`),n.note&&console.log(`
|
|
19
|
+
${n.note}`);break}default:console.log(["oracle-scan -- chain scanner CLI",""," oracle-scan chains coverage matrix"," oracle-scan head <chain> current block"," oracle-scan token <chain> <address> ERC-20 identity"," oracle-scan pools <chain> <address> pools by liquidity"," oracle-scan risk <chain> <address> structural risk checks"," oracle-scan quote <chain> <tIn> <tOut> [amt] live exact-input quote"," oracle-scan sell <chain> <token> [amt] round-trip: can you exit?",""," <chain> is an id (8453) or key (base). --json for machine output."," quote/sell need a chain with a verified router (see: oracle-scan chains)."].join(`
|
|
20
|
+
`)),process.exit(We?1:0)}}catch(t){let e=C[0]?ce(Number(C[0]))||Y().find(n=>n.key===C[0]):null;R(e?Ft(e,t):String(t?.message||t))}
|
package/dist/bin/oracle.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{realpathSync as T}from"node:fs";import{fileURLToPath as
|
|
2
|
+
import{realpathSync as T}from"node:fs";import{fileURLToPath as ne}from"node:url";import h from"node:fs";import g from"node:path";import{pathToFileURL as z}from"node:url";import d from"node:fs";import P from"node:os";import i from"node:path";import{fileURLToPath as $}from"node:url";var I=i.dirname($(import.meta.url)),l=i.resolve(I,"../..");function u(){return process.env.ORACLE_FAKE_HOME||P.homedir()}function _(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function f(){return _()?process.env.ORACLE_CONFIG_DIR||i.join(u(),".config","oracle"):i.join(u(),".config","oracle")}function M(){return i.join(f(),"exec.env")}function k(){return i.join(f(),"desk.json")}function R(){return i.join(f(),"env")}function p({force:e=!1}={}){if(p._done&&!e)return p._result||null;p._done=!0;let n={},o=(c,t)=>{if(t==null)return;let r=String(t).trim();r&&(process.env[c]!=null&&String(process.env[c]).trim()!==""||(process.env[c]=r,n[c]=r))};try{let c=R();if(d.existsSync(c))for(let t of d.readFileSync(c,"utf8").split(/\r?\n/)){let r=t.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!r||r[2].startsWith("#"))continue;let a=r[2];(a.startsWith('"')&&a.endsWith('"')||a.startsWith("'")&&a.endsWith("'"))&&(a=a.slice(1,-1)),o(r[1],a)}}catch{}try{let c=k();if(d.existsSync(c)){let t=JSON.parse(d.readFileSync(c,"utf8"));t&&typeof t=="object"&&(o("ORACLE_DESK_URL",t.deskUrl||t.dataUrl||t.url),o("ORACLE_DATA_URL",t.dataUrl||t.deskUrl||t.url),o("ORACLE_API_URL",t.apiUrl||t.dataUrl||t.deskUrl),o("ORACLE_PUBLIC_URL",t.publicUrl||t.deskUrl||t.dataUrl),o("ORACLE_EXEC_URL",t.execUrl),o("MAD_DESK_URL",t.deskUrl||t.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(o("ORACLE_DESK_URL",s),o("ORACLE_DATA_URL",s),o("ORACLE_API_URL",s),o("ORACLE_PUBLIC_URL",s),o("MAD_DESK_URL",s)),p._result=Object.keys(n).length?n:null,p._result}try{p()}catch{}function F(){return process.env.HERMES_HOME?i.resolve(process.env.HERMES_HOME):i.join(u(),".hermes")}function H(){return i.join(u(),".claude.json")}function N(e=process.cwd()){return i.join(e,".mcp.json")}function q(){return process.platform==="darwin"?i.join(u(),"Library","Application Support","Claude","claude_desktop_config.json"):i.join(u(),".config","Claude","claude_desktop_config.json")}function K(){return i.join(u(),".codex","config.toml")}function w(){return i.join(f(),"connectors")}function B(){return i.join(w(),"chatgpt-openapi.json")}function G(){return i.join(f(),"active-chain.json")}function y(e){let n=[i.join(l,"bin",e),i.join(l,"dist","bin",e),i.join(l,"..","bin",e)];return n.find(o=>d.existsSync(o))||n[0]}function V(e){return d.mkdirSync(e,{recursive:!0}),e}var C={homeDir:u,isPublicDesktop:_,oracleConfigDir:f,oracleExecEnvPath:M,oracleDeskJsonPath:k,oracleEnvFilePath:R,loadDeskRouting:p,hermesRoot:F,activeChainPath:G,claudeCodeUserConfigPath:H,claudeCodeProjectMcpPath:N,claudeDesktopConfigPath:q,codexConfigPath:K,chatgptConnectorDir:w,chatgptOpenApiPath:B,packageBin:y,ensureDir:V,PACKAGE_ROOT:l};import{execFile as J}from"node:child_process";import{existsSync as me,mkdirSync as he,readFileSync as W,realpathSync as ge,writeFileSync as ye}from"node:fs";import j from"node:path";import{promisify as Y}from"node:util";var ve=Y(J);var Ae=1440*60*1e3;function L(e,n){let o=t=>String(t).replace(/^v/,"").split("-")[0].split(".").map(r=>Number.parseInt(r,10)||0),s=o(e),c=o(n);for(let t=0;t<Math.max(s.length,c.length);t+=1){let r=s[t]??0,a=c[t]??0;if(r>a)return 1;if(r<a)return-1}return 0}function X(e){let n=e?.stateDir||j.join(process.env.HOME||".",".oracle");return j.join(n,"update-check.json")}function O(e){try{return JSON.parse(W(X(e),"utf8"))}catch{return null}}var Q="\u25C7 ORACLE // self-custody multichain agent control plane",Z=`START
|
|
3
3
|
oracle open the native Oracle chat (TTY)
|
|
4
4
|
oracle chat open chat explicitly
|
|
5
5
|
oracle setup connect a model and optional messaging
|
|
@@ -14,6 +14,14 @@ READ / RESEARCH
|
|
|
14
14
|
oracle scan chains|head|token|pools|risk|quote|sell
|
|
15
15
|
oracle farm methods \xB7 discover \xB7 airdrop
|
|
16
16
|
oracle equities venues \xB7 quote \xB7 prepare
|
|
17
|
+
oracle tax-lots FIFO/LIFO/HIFO cost-basis records
|
|
18
|
+
oracle position-health lending/yield health over a snapshot
|
|
19
|
+
oracle portfolio-risk portfolio risk over caller-supplied lots
|
|
20
|
+
oracle safety-intelligence address/tx safety findings
|
|
21
|
+
oracle governance-prepare proposal/delegation/vote preview
|
|
22
|
+
oracle context provenance + freshness knowledge graph
|
|
23
|
+
oracle follow follow a name or address
|
|
24
|
+
oracle resolve resolve a name or address
|
|
17
25
|
|
|
18
26
|
PREPARE
|
|
19
27
|
oracle route swap|bridge|prepare|prepare-bridge
|
|
@@ -40,6 +48,7 @@ SYSTEM
|
|
|
40
48
|
oracle public serve secret-free public HTTP surface
|
|
41
49
|
oracle telegram native interactive Telegram cards (no Hermes)
|
|
42
50
|
oracle fees status \xB7 check
|
|
51
|
+
oracle lifecycle inventory \xB7 eval health \xB7 quarantine \xB7 retirement
|
|
43
52
|
oracle eval desk \xB7 fidelity \xB7 hybrid \xB7 guards \xB7 contracts \xB7 all
|
|
44
53
|
oracle upgrade update installed agent lanes
|
|
45
54
|
|
|
@@ -50,16 +59,16 @@ BOUNDARY
|
|
|
50
59
|
MEV observe is read-only. Flash-loan execute needs ORACLE_MEV_EXECUTE_ENABLED=1
|
|
51
60
|
and literal --execute. There is no autonomous MEV loop.
|
|
52
61
|
Use oracle <command> --help for command details.
|
|
53
|
-
`;function U(){try{return JSON.parse(h.readFileSync(g.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function ee(){let e=g.join(l,"src","cli","commands");return h.existsSync(e)?e:g.join(l,"dist","cli","commands")}async function
|
|
54
|
-
Update available: ${e} \u2192 ${
|
|
55
|
-
`}function
|
|
62
|
+
`;function U(){try{return JSON.parse(h.readFileSync(g.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function ee(){let e=g.join(l,"src","cli","commands");return h.existsSync(e)?e:g.join(l,"dist","cli","commands")}async function m(){let e=ee(),n=new Map;if(!h.existsSync(e))return n;let o=h.readdirSync(e).filter(s=>s.endsWith(".mjs")).sort();for(let s of o){let c=g.join(e,s);try{let r=(await import(z(c).href+`?t=${Date.now()}`)).default;if(!r||typeof r!="object"||typeof r.run!="function")continue;let a=r.name||s.replace(/\.mjs$/,""),v={...r,name:a,__file:c};n.set(a,v);for(let A of Array.isArray(r.aliases)?r.aliases:[])n.set(A,{...v,name:A,aliasFor:a})}catch(t){process.env.ORACLE_CLI_DEBUG&&console.error(`oracle: failed loading command ${s}: ${t.message}`)}}return n}function te(e,n=O()){return!n?.latest||!e||L(n.latest,e)<=0?"":`
|
|
63
|
+
Update available: ${e} \u2192 ${n.latest}. Run 'oracle update'.
|
|
64
|
+
`}function x(e,n){let o=[];o.push(`${Q} (v${e})`),o.push(""),o.push(Z.trimEnd());let s=[];for(let c of n.values()){if(["help","version"].includes(c.name))continue;!new Set(["init","doctor","chat","model","auth","chain","setup","data","data-mcp","scan","route","prepare","swap","farm","follow","equities","strategy","shadow","mev","snipe","public","mcp","plugins","harness","clients","upgrade","bootstrap","eval","fees","sign","signer","project","context","lifecycle"]).has(c.name)&&c.summary&&s.push(` oracle ${c.name.padEnd(20)} ${c.summary}`)}return s.length&&(o.push(""),o.push("ADDITIONAL"),o.push(...s)),o.join(`
|
|
56
65
|
`)+`
|
|
57
|
-
`+te(e)}function
|
|
66
|
+
`+te(e)}function b(e,n){let o=[...n.keys()].sort(),s=o.length?o.join(", "):"(none loaded yet)";return`oracle: unknown command '${e}'. Known: ${s}
|
|
58
67
|
Try: oracle --help
|
|
59
|
-
`}function
|
|
68
|
+
`}function E(e){return{argv:e,root:l,bin:y,paths:C}}async function D(e=[]){let n=U();if(e.includes("--version")||e.includes("-V"))return S();if(e[0]==="--help"||e[0]==="-h"){let r=await m();return process.stdout.write(x(n,r)),0}if(e.length===0){let r=await m();if(re(e)){let a=r.get("chat");if(a)return a.run(E([]))}return process.stdout.write(x(n,r)),0}if(oe(e[0])){let a=(await m()).get("chat");if(a)return a.run(E(e))}let o=e[0],s=e.slice(1);if(o==="version")return S();if(o==="help"){let r=await m();if(s[0]){let a=r.get(s[0]);return a?(process.stdout.write((a.usage||`oracle ${a.name}`)+`
|
|
60
69
|
`),a.summary&&process.stdout.write(a.summary+`
|
|
61
|
-
`),0):(process.stderr.write(
|
|
70
|
+
`),0):(process.stderr.write(b(s[0],r)),1)}return process.stdout.write(x(n,r)),0}let c=await m(),t=c.get(o);if(t){if(s[0]==="--help"||s[0]==="-h")return process.stdout.write((t.usage||`oracle ${t.name}`)+`
|
|
62
71
|
`),t.summary&&process.stdout.write(t.summary+`
|
|
63
|
-
`),0;try{let r=await t.run(
|
|
64
|
-
`),1}}return process.stderr.write(
|
|
65
|
-
`),0}function re(e=[],
|
|
72
|
+
`),0;try{let r=await t.run(E(s));return typeof r=="number"?r:0}catch(r){return process.stderr.write(`oracle ${o}: ${r?.message||r}
|
|
73
|
+
`),1}}return process.stderr.write(b(o,c)),1}async function S(){let e=U();return process.stdout.write(`oracle ${e}
|
|
74
|
+
`),0}function re(e=[],n={stdin:process.stdin,stdout:process.stdout}){return e.length!==0?!1:process.env.ORACLE_FORCE_CHAT==="1"?!0:n.stdin?.isTTY===!0&&n.stdout?.isTTY===!0}function oe(e){return["-m","--model","--provider","-q","--query","-Q","--quiet","-c","--continue","-r","--resume","-s","--skills","-t","--toolsets","--reasoning","--tui","--cli","--yolo","--checkpoints","--source","--max-turns"].includes(String(e||""))}var Ue=Object.freeze({data:"./desk-server.mjs",public:"./oracle-public-server.mjs","data-mcp":"./oracle-data-mcp.mjs",init:"./oracle-init.mjs",upgrade:"./oracle-upgrade.mjs",scan:"./oracle-scan.mjs",route:"./oracle-route.mjs",equities:"./oracle-equities.mjs"});function se(){if(!process.argv[1])return!1;try{return T(ne(import.meta.url))===T(process.argv[1])}catch{return!1}}async function ae(e=process.argv.slice(2)){return D(e)}if(se()){let e=await ae();process.exit(typeof e=="number"?e:0)}export{Ue as COMMANDS,ae as main};
|