@oracle-agent/oracle 0.24.9 → 0.25.0

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.
@@ -46,7 +46,7 @@ ${A.format(t)}
46
46
  ${s}`;break;case"retry":lh(s)&&(t[n]=s);break;case"id":Ch(s)&&(t[n]=s);break;case"event":s.length>0&&(t[n]=s);break}}processEvent(A){A.retry&&lh(A.retry)&&(this.state.reconnectionTime=parseInt(A.retry,10)),A.id&&Ch(A.id)&&(this.state.lastEventId=A.id),A.data!==void 0&&this.push({type:A.event||"message",options:{data:A.data,lastEventId:this.state.lastEventId,origin:this.state.origin}})}clearEvent(){this.event={data:void 0,event:void 0,id:void 0,retry:void 0}}};uh.exports={EventSourceStream:Zc}});var mh=f((PM,kh)=>{"use strict";var{pipeline:SN}=d("node:stream"),{fetching:UN}=An(),{makeRequest:MN}=tr(),{webidl:pe}=gA(),{EventSourceStream:LN}=hh(),{parseMIMEType:TN}=uA(),{createFastMessageEvent:YN}=ar(),{isNetworkError:dh}=jr(),{delay:xN}=Oc(),{kEnumerableProperty:Bt}=L(),{environmentSettingsObject:fh}=pA(),wh=!1,yh=3e3,ln=0,ph=1,Cn=2,GN="anonymous",vN="use-credentials",Br=class e extends EventTarget{#A={open:null,error:null,message:null};#e=null;#t=!1;#s=ln;#n=null;#r=null;#i;#o;constructor(A,t={}){super(),pe.util.markAsUncloneable(this);let r="EventSource constructor";pe.argumentLengthCheck(arguments,1,r),wh||(wh=!0,process.emitWarning("EventSource is experimental, expect them to change at any time.",{code:"UNDICI-ES"})),A=pe.converters.USVString(A,r,"url"),t=pe.converters.EventSourceInitDict(t,r,"eventSourceInitDict"),this.#i=t.dispatcher,this.#o={lastEventId:"",reconnectionTime:yh};let n=fh,s;try{s=new URL(A,n.settingsObject.baseUrl),this.#o.origin=s.origin}catch(a){throw new DOMException(a,"SyntaxError")}this.#e=s.href;let i=GN;t.withCredentials&&(i=vN,this.#t=!0);let o={redirect:"follow",keepalive:!0,mode:"cors",credentials:i==="anonymous"?"same-origin":"omit",referrer:"no-referrer"};o.client=fh.settingsObject,o.headersList=[["accept",{name:"accept",value:"text/event-stream"}]],o.cache="no-store",o.initiator="other",o.urlList=[new URL(this.#e)],this.#n=MN(o),this.#c()}get readyState(){return this.#s}get url(){return this.#e}get withCredentials(){return this.#t}#c(){if(this.#s===Cn)return;this.#s=ln;let A={request:this.#n,dispatcher:this.#i},t=r=>{dh(r)&&(this.dispatchEvent(new Event("error")),this.close()),this.#a()};A.processResponseEndOfBody=t,A.processResponse=r=>{if(dh(r))if(r.aborted){this.close(),this.dispatchEvent(new Event("error"));return}else{this.#a();return}let n=r.headersList.get("content-type",!0),s=n!==null?TN(n):"failure",i=s!=="failure"&&s.essence==="text/event-stream";if(r.status!==200||i===!1){this.close(),this.dispatchEvent(new Event("error"));return}this.#s=ph,this.dispatchEvent(new Event("open")),this.#o.origin=r.urlList[r.urlList.length-1].origin;let o=new LN({eventSourceSettings:this.#o,push:a=>{this.dispatchEvent(YN(a.type,a.options))}});SN(r.body.stream,o,a=>{a?.aborted===!1&&(this.close(),this.dispatchEvent(new Event("error")))})},this.#r=UN(A)}async#a(){this.#s!==Cn&&(this.#s=ln,this.dispatchEvent(new Event("error")),await xN(this.#o.reconnectionTime),this.#s===ln&&(this.#o.lastEventId.length&&this.#n.headersList.set("last-event-id",this.#o.lastEventId,!0),this.#c()))}close(){pe.brandCheck(this,e),this.#s!==Cn&&(this.#s=Cn,this.#r.abort(),this.#n=null)}get onopen(){return this.#A.open}set onopen(A){this.#A.open&&this.removeEventListener("open",this.#A.open),typeof A=="function"?(this.#A.open=A,this.addEventListener("open",A)):this.#A.open=null}get onmessage(){return this.#A.message}set onmessage(A){this.#A.message&&this.removeEventListener("message",this.#A.message),typeof A=="function"?(this.#A.message=A,this.addEventListener("message",A)):this.#A.message=null}get onerror(){return this.#A.error}set onerror(A){this.#A.error&&this.removeEventListener("error",this.#A.error),typeof A=="function"?(this.#A.error=A,this.addEventListener("error",A)):this.#A.error=null}},Dh={CONNECTING:{__proto__:null,configurable:!1,enumerable:!0,value:ln,writable:!1},OPEN:{__proto__:null,configurable:!1,enumerable:!0,value:ph,writable:!1},CLOSED:{__proto__:null,configurable:!1,enumerable:!0,value:Cn,writable:!1}};Object.defineProperties(Br,Dh);Object.defineProperties(Br.prototype,Dh);Object.defineProperties(Br.prototype,{close:Bt,onerror:Bt,onmessage:Bt,onopen:Bt,readyState:Bt,url:Bt,withCredentials:Bt});pe.converters.EventSourceInitDict=pe.dictionaryConverter([{key:"withCredentials",converter:pe.converters.boolean,defaultValue:()=>!1},{key:"dispatcher",converter:pe.converters.any}]);kh.exports={EventSource:Br,defaultReconnectionTime:yh}});var Nh=f((ZM,S)=>{"use strict";var JN=Jt(),Fh=dr(),HN=Ht(),VN=DB(),qN=Vt(),WN=Ia(),ON=KB(),PN=eI(),Rh=J(),Ci=L(),{InvalidArgumentError:li}=Rh,Ir=HI(),ZN=wr(),KN=za(),zN=pl(),XN=ja(),_N=Ya(),jN=hs(),{getGlobalDispatcher:bh,setGlobalDispatcher:$N}=Rs(),AS=bs(),eS=os(),tS=as();Object.assign(Fh.prototype,Ir);S.exports.Dispatcher=Fh;S.exports.Client=JN;S.exports.Pool=HN;S.exports.BalancedPool=VN;S.exports.Agent=qN;S.exports.ProxyAgent=WN;S.exports.EnvHttpProxyAgent=ON;S.exports.RetryAgent=PN;S.exports.RetryHandler=jN;S.exports.DecoratorHandler=AS;S.exports.RedirectHandler=eS;S.exports.createRedirectInterceptor=tS;S.exports.interceptors={redirect:Nl(),retry:Ul(),dump:Ll(),dns:xl()};S.exports.buildConnector=ZN;S.exports.errors=Rh;S.exports.util={parseHeaders:Ci.parseHeaders,headerNameToString:Ci.headerNameToString};function un(e){return(A,t,r)=>{if(typeof t=="function"&&(r=t,t=null),!A||typeof A!="string"&&typeof A!="object"&&!(A instanceof URL))throw new li("invalid url");if(t!=null&&typeof t!="object")throw new li("invalid opts");if(t&&t.path!=null){if(typeof t.path!="string")throw new li("invalid opts.path");let i=t.path;t.path.startsWith("/")||(i=`/${i}`),A=new URL(Ci.parseOrigin(A).origin+i)}else t||(t=typeof A=="object"?A:{}),A=Ci.parseURL(A);let{agent:n,dispatcher:s=bh()}=t;if(n)throw new li("unsupported opts.agent. Did you mean opts.client?");return e.call(s,{...t,origin:A.origin,path:A.search?`${A.pathname}${A.search}`:A.pathname,method:t.method||(t.body?"PUT":"GET")},r)}}S.exports.setGlobalDispatcher=$N;S.exports.getGlobalDispatcher=bh;var rS=An().fetch;S.exports.fetch=async function(A,t=void 0){try{return await rS(A,t)}catch(r){throw r&&typeof r=="object"&&Error.captureStackTrace(r),r}};S.exports.Headers=it().Headers;S.exports.Response=jr().Response;S.exports.Request=tr().Request;S.exports.FormData=Rr().FormData;S.exports.File=globalThis.File??d("node:buffer").File;S.exports.FileReader=$C().FileReader;var{setGlobalOrigin:nS,getGlobalOrigin:sS}=Io();S.exports.setGlobalOrigin=nS;S.exports.getGlobalOrigin=sS;var{CacheStorage:iS}=au(),{kConstruct:oS}=Xs();S.exports.caches=new iS(oS);var{deleteCookie:aS,getCookies:cS,getSetCookies:gS,setCookie:QS}=du();S.exports.deleteCookie=aS;S.exports.getCookies=cS;S.exports.getSetCookies=gS;S.exports.setCookie=QS;var{parseMIMEType:ES,serializeAMimeType:BS}=uA();S.exports.parseMIMEType=ES;S.exports.serializeAMimeType=BS;var{CloseEvent:IS,ErrorEvent:lS,MessageEvent:CS}=ar();S.exports.WebSocket=Bh().WebSocket;S.exports.CloseEvent=IS;S.exports.ErrorEvent=lS;S.exports.MessageEvent=CS;S.exports.request=un(Ir.request);S.exports.stream=un(Ir.stream);S.exports.pipeline=un(Ir.pipeline);S.exports.connect=un(Ir.connect);S.exports.upgrade=un(Ir.upgrade);S.exports.MockClient=KN;S.exports.MockPool=XN;S.exports.MockAgent=zN;S.exports.mockErrors=_N;var{EventSource:uS}=mh();S.exports.EventSource=uS});import{createHash as wS}from"node:crypto";import lr from"node:net";import hS from"node:dns";var dS=new Set(["localhost","metadata.google.internal","metadata.goog"]);function ui(e){let A=String(e).toLowerCase().split("%")[0];if((A.match(/::/g)||[]).length>1)return null;let t=g=>{if(!g)return[];let Q=g.split(":"),E=Q.at(-1);if(E?.includes(".")){let B=E.split(".").map(Number);if(B.length!==4||B.some(I=>!Number.isInteger(I)||I<0||I>255))return null;Q.splice(Q.length-1,1,(B[0]<<8|B[1]).toString(16),(B[2]<<8|B[3]).toString(16))}return Q.some(B=>!/^[0-9a-f]{1,4}$/.test(B))?null:Q.map(B=>Number.parseInt(B,16))},[r,n]=A.split("::"),s=t(r),i=t(n);if(!s||!i)return null;let o=A.includes("::"),a=8-s.length-i.length;if(!o&&a!==0||o&&a<1)return null;let c=[...s,...Array(Math.max(0,a)).fill(0),...i];return c.length!==8?null:Uint8Array.from(c.flatMap(g=>[g>>8,g&255]))}function Kc(e,A,t){let r=Math.floor(t/8),n=t%8;for(let i=0;i<r;i+=1)if(e[i]!==A[i])return!1;if(!n)return!0;let s=255<<8-n;return(e[r]&s)===(A[r]&s)}function zc(e){if(lr.isIPv4(e)){let A=e.split(".").map(Number);return!(A[0]===0||A[0]===10||A[0]===127||A[0]>=224||A[0]===100&&A[1]>=64&&A[1]<=127||A[0]===169&&A[1]===254||A[0]===172&&A[1]>=16&&A[1]<=31||A[0]===192&&(A[1]===0||A[1]===2||A[1]===168)||A[0]===192&&A[1]===88&&A[2]===99||A[0]===198&&(A[1]===18||A[1]===19||A[1]===51)||A[0]===203&&A[1]===0&&A[2]===113)}if(lr.isIPv6(e)){let A=ui(e);if(!A)return!1;let t=ui("::ffff:0:0");return Kc(A,t,96)?zc([...A.slice(12)].join(".")):Kc(A,ui("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([n,s])=>Kc(A,ui(n),s)):!1}return!1}function fS(e){let A;try{A=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(A.protocol!=="http:"&&A.protocol!=="https:")return{ok:!1,error:`refused protocol ${A.protocol} (only http/https)`};let t=A.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(dS.has(t)||t.endsWith(".localhost")||t.endsWith(".internal"))return{ok:!1,error:`refused internal host ${t}`};let r=lr.isIP(t);return r!==0&&!zc(t)?{ok:!1,error:`refused private address ${t}`}:{ok:!0,url:A,host:t,isLiteralIp:r!==0}}async function Sh(e,{lookupFn:A=hS.promises.lookup}={}){let t=fS(e);if(!t.ok)return t;if(t.isLiteralIp)return{ok:!0,url:t.url};let r;try{r=await A(t.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${t.host} did not resolve`}}return!Array.isArray(r)||r.length===0||r.some(n=>!zc(n.address))?{ok:!1,error:`refused: ${t.host} resolves to a non-public address`}:{ok:!0,url:t.url,addresses:r}}async function Uh(){let e,A;try{let o=await Promise.resolve().then(()=>gd(Nh(),1));e=o.Agent,A=o.fetch}catch{return null}if(typeof e!="function"||typeof A!="function")return null;let t=o=>String(o).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),r=new Map,n=o=>(Array.isArray(o)?o:[o]).map(a=>typeof a=="string"?{address:a}:a).filter(a=>a&&a.address).map(a=>({address:a.address,family:a.family||(lr.isIPv6(a.address)?6:4)})),s=o=>{let a=t(o);if(lr.isIP(a))return[{address:a,family:lr.isIPv6(a)?6:4}];let c=r.get(a);if(!c||!c.length)throw new Error(`refused: unpinned host ${o} during pinned fetch`);return c},i=new e({connect:{lookup(o,a,c){let g;try{g=s(o)}catch(Q){return c(Q)}return a?.all?c(null,g):c(null,g[0].address,g[0].family)}}});return{dispatcher:i,fetch:(o,a={})=>A(o,{...a,dispatcher:i}),pin(o,a,c){r.set(t(o),n(typeof a=="string"?[{address:a,family:c}]:a))},resolve:s,async close(){try{await i.destroy()}catch{}}}}var yS=new Set([408,425,429,500,502,503,504]),Mh=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),pS=2,Lh=4e3,Yh=["authorization","x-api-key","x-tensor-api-key","0x-api-key","api-key","cookie","proxy-authorization"],DS=new Set([301,302,303,307,308]),Th=3;function kS(e){let A=String(e||"").toLowerCase();return Yh.includes(A)||/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(A)}function mS(e){let A={};for(let[t,r]of Object.entries(e||{}))kS(t)||(A[t]=r);return A}function FS(e,A){if(!e)throw new Error(`HTTP redirect from ${A} missing Location`);let t=new URL(String(e),String(A));if(t.protocol!=="http:"&&t.protocol!=="https:")throw new Error(`HTTP redirect from ${A} used unsupported protocol ${t.protocol}`);return t.toString()}function RS(e,A){return new URL(String(e)).origin===new URL(String(A)).origin}var Xc=new Map;function bS(e,A,t){let r={};for(let[a,c]of Object.entries(t||{}))r[a.toLowerCase()]=c;let n=Object.keys(r).filter(a=>/(^|-)(api[-_]?key|key|token|secret|auth|authorization|session|cookie|signature|access)(-|$)/.test(a)),i=[...new Set([...Yh,...n])].sort().map(a=>`${a}=${r[a]??""}`).join(`
47
47
  `),o=wS("sha256").update(i).digest("hex").slice(0,32);return`${e} ${A} ${o}`}function NS(e,A){let t=Number(A);return Number.isFinite(t)&&t>0?Math.min(t*1e3,Lh):Math.min(250*2**e,Lh)+Math.floor(Math.random()*100)}var SS=e=>new Promise(A=>setTimeout(A,e));async function US(e,{fetchImpl:A,method:t,headers:r,body:n,timeoutMs:s,lookupFn:i,realFetch:o}){let a=new AbortController,c=setTimeout(()=>a.abort(),s),g=null,Q=A;try{let E=String(e),B={...r||{}};for(let I=0;I<=Th;I+=1){let C=await Q(E,{method:t,headers:B,body:n,signal:a.signal,redirect:"manual"}),u=await C.text(),l=null;if(u)try{l=JSON.parse(u)}catch{l=null}if(DS.has(C.status)){if(t!=="GET"&&t!=="HEAD"){let p=new Error(`HTTP ${C.status} ${t} ${E} redirected non-idempotent request`);throw p.status=C.status,p.body=l??u.slice(0,300),p}if(I===Th)throw new Error(`HTTP redirect loop for ${e}`);let h=FS(C.headers?.get?.("location"),E);if(!RS(h,E)){let p=await Sh(h,i?{lookupFn:i}:{});if(!p.ok){let H=new Error(`HTTP redirect from ${E} ${p.error}`);throw H.status=C.status,H}B=mS(B),o&&p.addresses?.length&&(g||(g=await Uh()),g&&(g.pin(new URL(h).hostname,p.addresses[0].address,p.addresses[0].family),Q=g.fetch))}E=h;continue}if(!C.ok){let h=new Error(`HTTP ${C.status} ${t} ${E}`);throw h.status=C.status,h.retryAfter=C.headers?.get?.("retry-after")??null,h.body=l??u.slice(0,300),h}return l??u}throw new Error(`HTTP redirect loop for ${e}`)}finally{clearTimeout(c),g&&await g.close()}}async function hi(e,A={}){let t=A.fetchImpl||globalThis.fetch;if(typeof t!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let r=A.timeoutMs??12e3,n=(A.method||"GET").toUpperCase(),s={Accept:"application/json",...A.headers||{}},i=A.body;i!=null&&typeof i!="string"&&(s["Content-Type"]=s["Content-Type"]||"application/json",i=JSON.stringify(i));let o=Number.isInteger(A.retries)?Math.max(A.retries,0):pS,a=A.lookupFn,c=!A.fetchImpl,g=async()=>{let C;for(let u=0;u<=o;u++)try{return await US(e,{fetchImpl:t,method:n,headers:s,body:i,timeoutMs:r,lookupFn:a,realFetch:c})}catch(l){C=l;let h=l?.status,D=l?.name==="AbortError",p=new Set([408,425,429]),H=h!=null?p.has(h)||yS.has(h)&&Mh.has(n):!D&&Mh.has(n);if(u===o||!H)throw l;await SS(NS(u,l?.retryAfter))}throw C};if(!(A.dedupe!==!1&&n==="GET"&&i==null))return g();let E=bS(n,e,s),B=Xc.get(E);if(B)return B;let I=g().finally(()=>Xc.delete(E));return Xc.set(E,I),I}var xh={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}},MS=new Map(Object.values(xh).map(e=>[e.chainId,e]));function Gh(e){return MS.get(Number(e))||null}function vh(e,A=process.env){let t=Gh(e);if(!t)return null;for(let r of t.rpcEnv){let n=(A[r]||"").trim();if(n)return n}return null}import{Interface as LS,getAddress as TS}from"ethers";var Jh=new LS(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function Hh(e,A){try{return TS(e).toLowerCase()}catch{throw new Error(`${A} must be a valid EVM address`)}}var YS={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 xS(e,{rpcUrl:A,env:t=process.env}={}){if(A)return A;let r=vh(e,t);return r||YS[Number(e)]||null}var GS=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function vS(e){let A=String(e||""),t=A.toLowerCase();if(A!==A.trim()||!/^[a-zA-Z0-9_]+$/.test(A)||!GS.test(t))throw new Error(`evm-rpc: ${A} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return t}async function oe(e,A,t=[],r={}){let n=String(A||"");vS(n);let s=xS(e,r);if(!s)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);let o=await hi(s,{method:"POST",body:{jsonrpc:"2.0",id:1,method:A,params:t},fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3});if(o?.error){let a=new Error(o.error.message||JSON.stringify(o.error));throw a.code=o.error.code,a}return o.result}async function Vh(e,A={}){let t=await oe(e,"eth_blockNumber",[],A);return parseInt(t,16)}async function qh(e,A,t={}){if(!A)throw new Error("rpcGetBalance requires address");let r=await oe(e,"eth_getBalance",[A,"latest"],t);return{chainId:Number(e),address:A,balanceWei:BigInt(r).toString(),balanceHex:r}}async function Wh(e={},A={}){let t=Number(e.chainId??A.chainId??1),r=Hh(e.token||e.tokenAddress,"token"),n=Hh(e.account||e.owner||e.address,"account"),s=Jh.encodeFunctionData("balanceOf",[n]),i=await oe(t,"eth_call",[{to:r,data:s},e.blockTag||"latest"],A),o=Jh.decodeFunctionResult("balanceOf",i),a=BigInt(o[0]);return{chainId:t,token:r,account:n,balance:a.toString(),balanceHex:`0x${a.toString(16)}`,blockTag:e.blockTag||"latest"}}var JS="https://api.dexscreener.com",oL=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function HS(e={}){return(e.baseUrl||process.env.DEXSCREENER_API_URL||JS).replace(/\/$/,"")}async function Oh(e,A={}){if(!e)throw new Error("tokenAddress required");return hi(`${HS(A)}/latest/dex/tokens/${e}`,{fetchImpl:A.fetchImpl,timeoutMs:A.timeoutMs??12e3})}var hn=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),G=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),T=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),VS=/^0x[0-9a-fA-F]{40}$/;function qS(e={}){let A=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:["definition must be an object"],warnings:t};if((!Number.isInteger(e.chainId)||e.chainId<=0)&&A.push("chainId must be a positive integer"),(typeof e.key!="string"||!/^[a-z][a-z0-9-]*$/.test(e.key||""))&&A.push('key must be a lowercase slug (e.g. "base")'),(typeof e.name!="string"||!e.name.trim())&&A.push("name is required"),!Array.isArray(e.rpcEnv)||e.rpcEnv.length===0)A.push("rpcEnv must list at least one environment variable name");else for(let n of e.rpcEnv)(typeof n!="string"||!/^[A-Z][A-Z0-9_]*$/.test(n))&&A.push(`rpcEnv entry "${n}" should be an UPPER_SNAKE env var name`);if(e.nativeCurrency){let n=e.nativeCurrency;(typeof n.symbol!="string"||!n.symbol)&&A.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(n.decimals)||A.push("nativeCurrency.decimals must be an integer")}for(let[n,s]of(e.venues||[]).entries()){let i=`venues[${n}]`;if(!s||typeof s!="object"){A.push(`${i} must be an object`);continue}VS.test(s.address||"")||A.push(`${i}.address is not a valid 20-byte address`),/^0x0{40}$/.test(s.address||"")&&A.push(`${i}.address is the zero address -- placeholder left in place?`),s.kind||A.push(`${i}.kind is required (router|quoter|factory|...)`),s.verified?(s.verified.method||A.push(`${i}.verified.method is required`),s.verified.source||A.push(`${i}.verified.source is required`),s.verified.date||t.push(`${i}.verified.date missing -- add one so staleness is visible`)):A.push(`${i} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let r=e.capabilities||{};for(let n of Object.keys(r))hn.includes(n)?typeof r[n]!="function"&&A.push(`capability "${n}" must be a function`):A.push(`unknown capability "${n}"`);return Object.keys(r).length===0&&t.push("scanner implements no capabilities -- it can only be registered, not used"),r.prepareUnsignedTx&&!r.quote&&t.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),r.prepareUnsignedTx&&!r.sellSimulation&&t.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:A.length===0,errors:A,warnings:t}}function WS(e){let{ok:A,errors:t,warnings:r}=qS(e);if(!A)throw new Error(`invalid scanner for ${e?.key??"<unknown>"}:
48
48
  - ${t.join(`
49
- - `)}`);let n=e.capabilities||{},s=hn.filter(o=>typeof n[o]=="function"),i={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,explorer:e.explorer||null,venues:(e.venues||[]).map(o=>({...o})),warnings:r,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...s],unsupported:hn.filter(o=>!s.includes(o))}},supports(o){return s.includes(o)}};for(let o of hn)s.includes(o)?i[o]=async(...a)=>n[o](...a,{scanner:i}):i[o]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${o}". Supported: ${s.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(i)}var dn=new Map;function Ph(e){let A=WS(e);return dn.set(A.chainId,A),A}function _c(e){return dn.get(Number(e))||null}function di(){return[...dn.values()]}function Zh(){let e={};for(let A of dn.values())e[A.chainId]={key:A.key,name:A.name,...A.capabilities(),venueCount:A.venues.length,failClosed:A.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:dn.size,capabilities:[...hn],chains:e}}var $c={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},vA=e=>BigInt(e).toString(16).padStart(64,"0"),fn=e=>e.slice(2).toLowerCase().padStart(64,"0");function OS(e,A){return`0x${$c.getAmountsOut}`+vA(e)+vA(64)+vA(A.length)+A.map(fn).join("")}function PS(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length<128)return null;let t=Number(BigInt(`0x${A.slice(64,128)}`));if(!Number.isFinite(t)||t<1||t>16)return null;let r=[];for(let n=0;n<t;n++){let s=128+n*64;if(A.length<s+64)return null;r.push(BigInt(`0x${A.slice(s,s+64)}`))}return r}function jc(e,A="router"){return(e?.venues||[]).find(r=>r.kind===A)?.address??null}var Ag=100;function ZS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Ag)throw new Error(`slippageBps ${t} exceeds the ${Ag} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function Kh(e){let{chainId:A,wrappedNative:t}=e;async function r(n,s,i,o){let a=await oe(A,"eth_call",[{to:n,data:OS(s,i)},"latest"],o);return PS(a?.result??a)}return{async quote({tokenIn:n,tokenOut:s,amountIn:i,path:o},a={}){let c=jc(a.scanner);if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let g=o||[n,s];if(g.some(E=>!/^0x[0-9a-fA-F]{40}$/.test(E||"")))throw new Error("quote requires valid 20-byte addresses");let Q=await r(c,i,g,a);return Q?{chainId:A,router:c,path:g,amountIn:String(i),amountOut:Q[Q.length-1].toString(),hops:g.length-1,evidence:G.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:A,router:c,path:g,evidence:G.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:s,base:i},o={}){let a=jc(o.scanner),c=i||t;if(c&&String(n).toLowerCase()===String(c).toLowerCase())return{chainId:A,token:n,verdict:T.UNKNOWN,evidence:G.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(!a||!c)return{chainId:A,token:n,verdict:T.UNKNOWN,evidence:G.UNAVAILABLE,reason:a?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let g=await r(a,s,[c,n],o);if(!g)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let Q=g[g.length-1];if(Q===0n)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let E=await r(a,Q,[n,c],o);if(!E)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E[E.length-1],I=Number(B*10000n/BigInt(s)),C=T.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(C=T.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(C=T.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,token:n,base:c,router:a,verdict:C,reason:u,amountIn:String(s),bought:Q.toString(),returned:B.toString(),retentionBps:I,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:i,recipient:o,slippageBps:a=50,deadlineSeconds:c=900,path:g},Q={}){let E=Q.scanner,B=jc(E);if(!B)throw new Error(`chain ${A} 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(o||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let I=g||[n,s],C=await this.quote({tokenIn:n,tokenOut:s,amountIn:i,path:I},Q);if(C.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${C.evidence}: ${C.reason??"no reason given"})`);let u=ZS(C.amountOut,a);if(u<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let l=BigInt(Math.floor(Date.now()/1e3)+Number(c)),h=t&&I[0].toLowerCase()===t.toLowerCase()&&Q.useNative,D=h?`0x${$c.swapExactETHForTokens}`+vA(u)+vA(128)+fn(o)+vA(l)+vA(I.length)+I.map(fn).join(""):`0x${$c.swapExactTokensForTokens}`+vA(i)+vA(u)+vA(160)+fn(o)+vA(l)+vA(I.length)+I.map(fn).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:A,tx:{to:B,data:D,value:h?`0x${BigInt(i).toString(16)}`:"0x0"},guard:{quotedOut:C.amountOut,minOut:u.toString(),slippageBps:a,maxSlippageBps:Ag,deadline:l.toString()},requires:h?[]:[{step:"approve",token:I[0],spender:B,amount:String(i)}],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 KS=[100,500,3e3,1e4],zh={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},It=e=>BigInt(e).toString(16).padStart(64,"0"),wn=e=>e.slice(2).toLowerCase().padStart(64,"0"),Xh=/^0x[0-9a-fA-F]{40}$/,tg=100;function zS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>tg)throw new Error(`slippageBps ${t} exceeds the ${tg} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function eg(e,A){return(e?.venues||[]).find(t=>t.kind===A)?.address??null}function _h(e){let{chainId:A,wrappedNative:t}=e;async function r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:c},g){let Q=`0x${zh.quoteExactInputSingle}`+wn(i)+wn(o)+It(a)+It(c)+It(0),E=await oe(A,"eth_call",[{to:s,data:Q},"latest"],g).catch(()=>null),B=E?.result??E;if(!B||B==="0x"||B.length<66)return null;let I=BigInt(`0x${B.slice(2,66)}`);return I>0n?I:null}async function n({quoter:s,tokenIn:i,tokenOut:o,amountIn:a},c){let g=[],Q=null;for(let E of KS){let B=await r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:E},c);g.push({fee:E,amountOut:B?B.toString():null}),B&&(!Q||B>Q.amountOut)&&(Q={fee:E,amountOut:B})}return{best:Q,tried:g}}return{async quote({tokenIn:s,tokenOut:i,amountIn:o},a={}){let c=eg(a.scanner,"quoter");if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let E of[s,i])if(!Xh.test(E||""))throw new Error("quote requires valid 20-byte addresses");let{best:g,tried:Q}=await n({quoter:c,tokenIn:s,tokenOut:i,amountIn:o},a);return g?{chainId:A,venue:"uniswap-v3",quoter:c,tokenIn:s,tokenOut:i,amountIn:String(o),amountOut:g.amountOut.toString(),fee:g.fee,triedFeeTiers:Q,evidence:G.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:A,quoter:c,tokenIn:s,tokenOut:i,triedFeeTiers:Q,evidence:G.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:s,amountIn:i,base:o},a={}){let c=eg(a.scanner,"quoter"),g=o||t;if(g&&String(s).toLowerCase()===String(g).toLowerCase())return{chainId:A,token:s,verdict:T.UNKNOWN,evidence:G.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(!c||!g)return{chainId:A,token:s,verdict:T.UNKNOWN,evidence:G.UNAVAILABLE,reason:c?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let Q=await n({quoter:c,tokenIn:g,tokenOut:s,amountIn:i},a);if(!Q.best)return{chainId:A,token:s,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier"};let E=await n({quoter:c,tokenIn:s,tokenOut:g,amountIn:Q.best.amountOut},a);if(!E.best)return{chainId:A,token:s,verdict:T.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.best.amountOut.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E.best.amountOut,I=Number(B*10000n/BigInt(i)),C=T.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(C=T.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(C=T.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,venue:"uniswap-v3",token:s,base:g,verdict:C,reason:u,amountIn:String(i),bought:Q.best.amountOut.toString(),returned:B.toString(),retentionBps:I,buyFee:Q.best.fee,sellFee:E.best.fee,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:i,amountIn:o,recipient:a,slippageBps:c=50,fee:g},Q={}){let E=eg(Q.scanner,"router");if(!E)throw new Error(`chain ${A} 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(!Xh.test(a||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let B=await this.quote({tokenIn:s,tokenOut:i,amountIn:o},Q);if(B.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${B.evidence}: ${B.reason??"no reason given"})`);let I=g??B.fee,C=zS(B.amountOut,c);if(C<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let u=`0x${zh.exactInputSingle}`+wn(s)+wn(i)+It(I)+wn(a)+It(o)+It(C)+It(0);return{unsigned:!0,signedBy:"user-wallet",chainId:A,venue:"uniswap-v3",tx:{to:E,data:u,value:"0x0"},guard:{quotedOut:B.amountOut,minOut:C.toString(),slippageBps:c,maxSlippageBps:tg,fee:I},requires:[{step:"approve",token:s,spender:E,amount:String(o)}],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 fi={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function jh(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function $h(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length>=128){let r=Number(BigInt(`0x${A.slice(64,128)}`));if(r>0&&r<=256&&A.length>=128+r*2){let n=A.slice(128,128+r*2),s=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(s)return s}}return Buffer.from(A.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function XS(e){let{chainId:A}=e;async function t(r,n,s){return oe(A,"eth_call",[{to:r,data:n},"latest"],s)}return{async blockNumber(r={}){let n=await Vh(A,r);return{chainId:A,blockNumber:n?.blockNumber??n,evidence:G.LIVE}},async nativeBalance(r,n={}){let s=await qh(A,r,n);return{chainId:A,address:r,wei:s?.wei??s?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:G.LIVE}},async tokenBalance({token:r,owner:n},s={}){let i=await Wh({chainId:A,token:r,owner:n},s);return{chainId:A,token:r,owner:n,raw:i?.balance??i,evidence:G.LIVE}},async resolveToken(r,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:A,token:r,evidence:G.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[s,i,o,a]=await Promise.all([t(r,fi.decimals,n).catch(()=>null),t(r,fi.symbol,n).catch(()=>null),t(r,fi.name,n).catch(()=>null),t(r,fi.totalSupply,n).catch(()=>null)]),c=jh(s?.result??s),g=c!==null||i?.result||o?.result;return{chainId:A,address:r,decimals:c===null?null:Number(c),symbol:$h(i?.result??i),name:$h(o?.result??o),totalSupply:(jh(a?.result??a)??null)?.toString()??null,evidence:g?G.LIVE:G.UNKNOWN,warning:g?void 0:"no ERC-20 metadata returned -- may not be a token contract"}},async resolvePools(r,n={}){let s=e.dexscreenerSlug;if(!s)return{chainId:A,token:r,pools:[],evidence:G.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let i=await Oh(r,n).catch(()=>null),a=(i?.pairs||i?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(s).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,g)=>(g.liquidityUsd??0)-(c.liquidityUsd??0));return{chainId:A,token:r,pools:a,evidence:a.length?G.LIVE:G.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:n,address:s,topics:i,chunkSize:o=2e3}={},a={}){if(!Number.isInteger(r)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<r)throw new Error("toBlock must be >= fromBlock");let c=[],g=[];for(let Q=r;Q<=n;Q+=o){let E=Math.min(Q+o-1,n);g.push([Q,E])}for(let[Q,E]of g){let B={fromBlock:`0x${Q.toString(16)}`,toBlock:`0x${E.toString(16)}`};s&&(B.address=s),i&&(B.topics=i);let I=await oe(A,"eth_getLogs",[B],a).catch(C=>({error:String(C?.message||C)}));if(I?.error)return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!1,failedAt:[Q,E],error:I.error,evidence:G.UNKNOWN};for(let C of I?.result??I??[])c.push(C)}return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!0,chunks:g.length,evidence:G.LIVE}},async scoreRisk(r,n={}){let s=[],i=T.PASS,o=g=>{let Q={[T.PASS]:0,[T.CAUTION]:1,[T.UNKNOWN]:2,[T.FAIL]:3};Q[g]>Q[i]&&(i=g)},a=await this.resolveToken(r,n);a.evidence!==G.LIVE?(s.push({check:"erc20-metadata",result:T.UNKNOWN,detail:a.warning}),o(T.UNKNOWN)):s.push({check:"erc20-metadata",result:T.PASS,detail:`${a.symbol} / ${a.decimals}d`});let c=await this.resolvePools(r,n);if(c.evidence===G.UNAVAILABLE)s.push({check:"liquidity",result:T.UNKNOWN,detail:c.reason}),o(T.UNKNOWN);else if(!c.pools.length)s.push({check:"liquidity",result:T.FAIL,detail:"no pool with liquidity found"}),o(T.FAIL);else{let g=c.pools[0],Q=g.liquidityUsd??0;Q<5e3?(s.push({check:"liquidity",result:T.CAUTION,detail:`top pool only $${Q}`}),o(T.CAUTION)):s.push({check:"liquidity",result:T.PASS,detail:`$${Q} on ${g.dex}`}),g.createdAt&&Date.now()-g.createdAt<24*3600*1e3&&(s.push({check:"age",result:T.CAUTION,detail:"pool under 24h old"}),o(T.CAUTION))}if(typeof this.sellSimulation=="function"){let g=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},n).catch(Q=>({verdict:T.UNKNOWN,reason:String(Q?.message||Q)}));s.push({check:"sellability",result:g.verdict,detail:g.retentionBps!=null?`round trip returns ${(g.retentionBps/100).toFixed(2)}% -- ${g.reason}`:g.reason}),o(g.verdict)}else s.push({check:"sellability",result:T.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."}),o(T.UNKNOWN);return{chainId:A,token:r,verdict:i,checks:s,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function Ad(e){let t={...XS(e)},r=new Set((e.venues||[]).map(s=>s.kind));e.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(t,_h({chainId:e.chainId,wrappedNative:e.wrappedNative})):e.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(t,Kh({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[s,i]of Object.entries(t))n[s]=i.bind(t);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var _S=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",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",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",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",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",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",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",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",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 ed(){return _S.map(e=>Ph(Ad(e)))}ed();var[td,...rd]=process.argv.slice(2),wi=rd.includes("--json"),AA=rd.filter(e=>e!=="--json");function Cr(e){e||ae("missing <chain>");let A=_c(Number(e));if(A)return A;let t=di().find(r=>r.key===String(e).toLowerCase());if(t)return t;ae(`unknown chain "${e}". Known: ${di().map(r=>`${r.key}(${r.chainId})`).join(", ")}`)}function ae(e){console.error(`error: ${e}`),process.exit(1)}function lt(e){process.stdout.write(`${JSON.stringify(e,null,2)}
49
+ - `)}`);let n=e.capabilities||{},s=hn.filter(o=>typeof n[o]=="function"),i={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,wrappedNative:e.wrappedNative||null,explorer:e.explorer||null,venues:(e.venues||[]).map(o=>({...o})),warnings:r,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...s],unsupported:hn.filter(o=>!s.includes(o))}},supports(o){return s.includes(o)}};for(let o of hn)s.includes(o)?i[o]=async(...a)=>n[o](...a,{scanner:i}):i[o]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${o}". Supported: ${s.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(i)}var dn=new Map;function Ph(e){let A=WS(e);return dn.set(A.chainId,A),A}function _c(e){return dn.get(Number(e))||null}function di(){return[...dn.values()]}function Zh(){let e={};for(let A of dn.values())e[A.chainId]={key:A.key,name:A.name,...A.capabilities(),venueCount:A.venues.length,failClosed:A.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:dn.size,capabilities:[...hn],chains:e}}var $c={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},vA=e=>BigInt(e).toString(16).padStart(64,"0"),fn=e=>e.slice(2).toLowerCase().padStart(64,"0");function OS(e,A){return`0x${$c.getAmountsOut}`+vA(e)+vA(64)+vA(A.length)+A.map(fn).join("")}function PS(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length<128)return null;let t=Number(BigInt(`0x${A.slice(64,128)}`));if(!Number.isFinite(t)||t<1||t>16)return null;let r=[];for(let n=0;n<t;n++){let s=128+n*64;if(A.length<s+64)return null;r.push(BigInt(`0x${A.slice(s,s+64)}`))}return r}function jc(e,A="router"){return(e?.venues||[]).find(r=>r.kind===A)?.address??null}var Ag=100;function ZS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>Ag)throw new Error(`slippageBps ${t} exceeds the ${Ag} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function Kh(e){let{chainId:A,wrappedNative:t}=e;async function r(n,s,i,o){let a=await oe(A,"eth_call",[{to:n,data:OS(s,i)},"latest"],o);return PS(a?.result??a)}return{async quote({tokenIn:n,tokenOut:s,amountIn:i,path:o},a={}){let c=jc(a.scanner);if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let g=o||[n,s];if(g.some(E=>!/^0x[0-9a-fA-F]{40}$/.test(E||"")))throw new Error("quote requires valid 20-byte addresses");let Q=await r(c,i,g,a);return Q?{chainId:A,router:c,path:g,amountIn:String(i),amountOut:Q[Q.length-1].toString(),hops:g.length-1,evidence:G.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:A,router:c,path:g,evidence:G.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:s,base:i},o={}){let a=jc(o.scanner),c=i||t;if(c&&String(n).toLowerCase()===String(c).toLowerCase())return{chainId:A,token:n,verdict:T.UNKNOWN,evidence:G.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(!a||!c)return{chainId:A,token:n,verdict:T.UNKNOWN,evidence:G.UNAVAILABLE,reason:a?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let g=await r(a,s,[c,n],o);if(!g)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let Q=g[g.length-1];if(Q===0n)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let E=await r(a,Q,[n,c],o);if(!E)return{chainId:A,token:n,verdict:T.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E[E.length-1],I=Number(B*10000n/BigInt(s)),C=T.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(C=T.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(C=T.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,token:n,base:c,router:a,verdict:C,reason:u,amountIn:String(s),bought:Q.toString(),returned:B.toString(),retentionBps:I,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:i,recipient:o,slippageBps:a=50,deadlineSeconds:c=900,path:g},Q={}){let E=Q.scanner,B=jc(E);if(!B)throw new Error(`chain ${A} 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(o||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let I=g||[n,s],C=await this.quote({tokenIn:n,tokenOut:s,amountIn:i,path:I},Q);if(C.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${C.evidence}: ${C.reason??"no reason given"})`);let u=ZS(C.amountOut,a);if(u<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let l=BigInt(Math.floor(Date.now()/1e3)+Number(c)),h=t&&I[0].toLowerCase()===t.toLowerCase()&&Q.useNative,D=h?`0x${$c.swapExactETHForTokens}`+vA(u)+vA(128)+fn(o)+vA(l)+vA(I.length)+I.map(fn).join(""):`0x${$c.swapExactTokensForTokens}`+vA(i)+vA(u)+vA(160)+fn(o)+vA(l)+vA(I.length)+I.map(fn).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:A,tx:{to:B,data:D,value:h?`0x${BigInt(i).toString(16)}`:"0x0"},guard:{quotedOut:C.amountOut,minOut:u.toString(),slippageBps:a,maxSlippageBps:Ag,deadline:l.toString()},requires:h?[]:[{step:"approve",token:I[0],spender:B,amount:String(i)}],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 KS=[100,500,3e3,1e4],zh={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},It=e=>BigInt(e).toString(16).padStart(64,"0"),wn=e=>e.slice(2).toLowerCase().padStart(64,"0"),Xh=/^0x[0-9a-fA-F]{40}$/,tg=100;function zS(e,A){let t=Number(A);if(!Number.isFinite(t)||t<0)throw new Error("slippageBps must be a non-negative number");if(t>tg)throw new Error(`slippageBps ${t} exceeds the ${tg} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(t))/10000n}function eg(e,A){return(e?.venues||[]).find(t=>t.kind===A)?.address??null}function _h(e){let{chainId:A,wrappedNative:t}=e;async function r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:c},g){let Q=`0x${zh.quoteExactInputSingle}`+wn(i)+wn(o)+It(a)+It(c)+It(0),E=await oe(A,"eth_call",[{to:s,data:Q},"latest"],g).catch(()=>null),B=E?.result??E;if(!B||B==="0x"||B.length<66)return null;let I=BigInt(`0x${B.slice(2,66)}`);return I>0n?I:null}async function n({quoter:s,tokenIn:i,tokenOut:o,amountIn:a},c){let g=[],Q=null;for(let E of KS){let B=await r({quoter:s,tokenIn:i,tokenOut:o,amountIn:a,fee:E},c);g.push({fee:E,amountOut:B?B.toString():null}),B&&(!Q||B>Q.amountOut)&&(Q={fee:E,amountOut:B})}return{best:Q,tried:g}}return{async quote({tokenIn:s,tokenOut:i,amountIn:o},a={}){let c=eg(a.scanner,"quoter");if(!c)return{chainId:A,evidence:G.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let E of[s,i])if(!Xh.test(E||""))throw new Error("quote requires valid 20-byte addresses");let{best:g,tried:Q}=await n({quoter:c,tokenIn:s,tokenOut:i,amountIn:o},a);return g?{chainId:A,venue:"uniswap-v3",quoter:c,tokenIn:s,tokenOut:i,amountIn:String(o),amountOut:g.amountOut.toString(),fee:g.fee,useNative:!!t&&String(s).toLowerCase()===String(t).toLowerCase(),triedFeeTiers:Q,evidence:G.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:A,quoter:c,tokenIn:s,tokenOut:i,triedFeeTiers:Q,evidence:G.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:s,amountIn:i,base:o},a={}){let c=eg(a.scanner,"quoter"),g=o||t;if(g&&String(s).toLowerCase()===String(g).toLowerCase())return{chainId:A,token:s,verdict:T.UNKNOWN,evidence:G.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(!c||!g)return{chainId:A,token:s,verdict:T.UNKNOWN,evidence:G.UNAVAILABLE,reason:c?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let Q=await n({quoter:c,tokenIn:g,tokenOut:s,amountIn:i},a);if(!Q.best)return{chainId:A,token:s,verdict:T.FAIL,evidence:G.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier"};let E=await n({quoter:c,tokenIn:s,tokenOut:g,amountIn:Q.best.amountOut},a);if(!E.best)return{chainId:A,token:s,verdict:T.FAIL,evidence:G.LIVE,leg:"sell",bought:Q.best.amountOut.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let B=E.best.amountOut,I=Number(B*10000n/BigInt(i)),C=T.PASS,u="round trip completes with expected fee/impact loss";return I<5e3?(C=T.FAIL,u=`round trip returns only ${(I/100).toFixed(2)}% -- punitive tax or no real liquidity`):I<9e3&&(C=T.CAUTION,u=`round trip returns ${(I/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:A,venue:"uniswap-v3",token:s,base:g,verdict:C,reason:u,amountIn:String(i),bought:Q.best.amountOut.toString(),returned:B.toString(),retentionBps:I,buyFee:Q.best.fee,sellFee:E.best.fee,evidence:G.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:i,amountIn:o,recipient:a,slippageBps:c=50,fee:g},Q={}){let E=eg(Q.scanner,"router");if(!E)throw new Error(`chain ${A} 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(!Xh.test(a||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let B=await this.quote({tokenIn:s,tokenOut:i,amountIn:o},Q);if(B.evidence!==G.LIVE)throw new Error(`cannot prepare without a live quote (${B.evidence}: ${B.reason??"no reason given"})`);let I=g??B.fee,C=zS(B.amountOut,c);if(C<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let u=!!(Q.useNative||B.useNative)&&t&&String(s).toLowerCase()===String(t).toLowerCase(),l=`0x${zh.exactInputSingle}`+wn(s)+wn(i)+It(I)+wn(a)+It(o)+It(C)+It(0);return{unsigned:!0,signedBy:"user-wallet",chainId:A,venue:"uniswap-v3",tx:{to:E,data:l,value:u?String(o):"0x0"},guard:{quotedOut:B.amountOut,minOut:C.toString(),slippageBps:c,maxSlippageBps:tg,fee:I},requires:u?[]:[{step:"approve",token:s,spender:E,amount:String(o)}],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 fi={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function jh(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function $h(e){if(!e||e==="0x")return null;let A=e.slice(2);if(A.length>=128){let r=Number(BigInt(`0x${A.slice(64,128)}`));if(r>0&&r<=256&&A.length>=128+r*2){let n=A.slice(128,128+r*2),s=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(s)return s}}return Buffer.from(A.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function XS(e){let{chainId:A}=e;async function t(r,n,s){return oe(A,"eth_call",[{to:r,data:n},"latest"],s)}return{async blockNumber(r={}){let n=await Vh(A,r);return{chainId:A,blockNumber:n?.blockNumber??n,evidence:G.LIVE}},async nativeBalance(r,n={}){let s=await qh(A,r,n);return{chainId:A,address:r,wei:s?.wei??s?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:G.LIVE}},async tokenBalance({token:r,owner:n},s={}){let i=await Wh({chainId:A,token:r,owner:n},s);return{chainId:A,token:r,owner:n,raw:i?.balance??i,evidence:G.LIVE}},async resolveToken(r,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(r||""))return{chainId:A,token:r,evidence:G.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[s,i,o,a]=await Promise.all([t(r,fi.decimals,n).catch(()=>null),t(r,fi.symbol,n).catch(()=>null),t(r,fi.name,n).catch(()=>null),t(r,fi.totalSupply,n).catch(()=>null)]),c=jh(s?.result??s),g=c!==null||i?.result||o?.result;return{chainId:A,address:r,decimals:c===null?null:Number(c),symbol:$h(i?.result??i),name:$h(o?.result??o),totalSupply:(jh(a?.result??a)??null)?.toString()??null,evidence:g?G.LIVE:G.UNKNOWN,warning:g?void 0:"no ERC-20 metadata returned -- may not be a token contract"}},async resolvePools(r,n={}){let s=e.dexscreenerSlug;if(!s)return{chainId:A,token:r,pools:[],evidence:G.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let i=await Oh(r,n).catch(()=>null),a=(i?.pairs||i?.data?.pairs||[]).filter(c=>String(c.chainId).toLowerCase()===String(s).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,g)=>(g.liquidityUsd??0)-(c.liquidityUsd??0));return{chainId:A,token:r,pools:a,evidence:a.length?G.LIVE:G.UNKNOWN}},async scanBlocks({fromBlock:r,toBlock:n,address:s,topics:i,chunkSize:o=2e3}={},a={}){if(!Number.isInteger(r)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<r)throw new Error("toBlock must be >= fromBlock");let c=[],g=[];for(let Q=r;Q<=n;Q+=o){let E=Math.min(Q+o-1,n);g.push([Q,E])}for(let[Q,E]of g){let B={fromBlock:`0x${Q.toString(16)}`,toBlock:`0x${E.toString(16)}`};s&&(B.address=s),i&&(B.topics=i);let I=await oe(A,"eth_getLogs",[B],a).catch(C=>({error:String(C?.message||C)}));if(I?.error)return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!1,failedAt:[Q,E],error:I.error,evidence:G.UNKNOWN};for(let C of I?.result??I??[])c.push(C)}return{chainId:A,fromBlock:r,toBlock:n,logs:c,complete:!0,chunks:g.length,evidence:G.LIVE}},async scoreRisk(r,n={}){let s=[],i=T.PASS,o=g=>{let Q={[T.PASS]:0,[T.CAUTION]:1,[T.UNKNOWN]:2,[T.FAIL]:3};Q[g]>Q[i]&&(i=g)},a=await this.resolveToken(r,n);a.evidence!==G.LIVE?(s.push({check:"erc20-metadata",result:T.UNKNOWN,detail:a.warning}),o(T.UNKNOWN)):s.push({check:"erc20-metadata",result:T.PASS,detail:`${a.symbol} / ${a.decimals}d`});let c=await this.resolvePools(r,n);if(c.evidence===G.UNAVAILABLE)s.push({check:"liquidity",result:T.UNKNOWN,detail:c.reason}),o(T.UNKNOWN);else if(!c.pools.length)s.push({check:"liquidity",result:T.FAIL,detail:"no pool with liquidity found"}),o(T.FAIL);else{let g=c.pools[0],Q=g.liquidityUsd??0;Q<5e3?(s.push({check:"liquidity",result:T.CAUTION,detail:`top pool only $${Q}`}),o(T.CAUTION)):s.push({check:"liquidity",result:T.PASS,detail:`$${Q} on ${g.dex}`}),g.createdAt&&Date.now()-g.createdAt<24*3600*1e3&&(s.push({check:"age",result:T.CAUTION,detail:"pool under 24h old"}),o(T.CAUTION))}if(typeof this.sellSimulation=="function"){let g=await this.sellSimulation({token:r,amountIn:(10n**16n).toString()},n).catch(Q=>({verdict:T.UNKNOWN,reason:String(Q?.message||Q)}));s.push({check:"sellability",result:g.verdict,detail:g.retentionBps!=null?`round trip returns ${(g.retentionBps/100).toFixed(2)}% -- ${g.reason}`:g.reason}),o(g.verdict)}else s.push({check:"sellability",result:T.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."}),o(T.UNKNOWN);return{chainId:A,token:r,verdict:i,checks:s,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function Ad(e){let t={...XS(e)},r=new Set((e.venues||[]).map(s=>s.kind));e.venueKind==="uniswap-v3"&&r.has("quoter")&&r.has("router")?Object.assign(t,_h({chainId:e.chainId,wrappedNative:e.wrappedNative})):e.venueKind==="uniswap-v2"&&r.has("router")&&Object.assign(t,Kh({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[s,i]of Object.entries(t))n[s]=i.bind(t);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var _S=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",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",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",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",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",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",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",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",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 ed(){return _S.map(e=>Ph(Ad(e)))}ed();var[td,...rd]=process.argv.slice(2),wi=rd.includes("--json"),AA=rd.filter(e=>e!=="--json");function Cr(e){e||ae("missing <chain>");let A=_c(Number(e));if(A)return A;let t=di().find(r=>r.key===String(e).toLowerCase());if(t)return t;ae(`unknown chain "${e}". Known: ${di().map(r=>`${r.key}(${r.chainId})`).join(", ")}`)}function ae(e){console.error(`error: ${e}`),process.exit(1)}function lt(e){process.stdout.write(`${JSON.stringify(e,null,2)}
50
50
  `)}function jS(e,A){let t=String(A?.message||A);return/rpc|fetch|ECONN|timeout|provider/i.test(t)?`${t}
51
51
 
52
52
  This chain reads its RPC from: ${e.rpcEnv.join(" or ")}
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import B from"node:os";import g from"node:path";import{fileURLToPath as L}from"node:url";import a from"node:fs";import u from"node:path";import{randomBytes as O}from"node:crypto";var w="oracle-profile-upgrade/v1";function m(e){try{return a.accessSync(e),!0}catch{return!1}}function v(e){return m(e)?a.readdirSync(e,{recursive:!0,withFileTypes:!0}).filter(r=>r.isFile()).map(r=>u.join(r.parentPath||r.path,r.name)).sort().map(r=>[u.relative(e,r),a.readFileSync(r)]):[]}function P(e){let r=v(e);return r.push([".oracle-upgrade-version",Buffer.from(`${w}
3
- `)]),r.sort(([t],[n])=>t.localeCompare(n))}function R(e,r){let t=v(e);return t.length===r.length&&t.every(([n,s],c)=>n===r[c][0]&&s.equals(r[c][1]))}function E(e){return`${e}.tmp-oracle-upgrade-${process.pid}-${O(6).toString("hex")}`}function j(e){let r=`${e}.bak-oracle-upgrade`;for(let t=1;m(r);t+=1)r=`${e}.bak-oracle-upgrade-${t}`;return r}function N(e,r,t,n){if(!m(e)||!a.statSync(e).isDirectory())return;let s=P(e);if(R(r,s)){n.unchanged.push(r);return}let c=m(r);if((c?n.updated:n.created).push(r),!t)return;a.mkdirSync(u.dirname(r),{recursive:!0});let o=E(r),l=null;a.mkdirSync(o);try{for(let[p,h]of s){let i=u.join(o,p);a.mkdirSync(u.dirname(i),{recursive:!0}),a.writeFileSync(i,h)}c&&(l=j(r),a.renameSync(r,l),n.backups.push({path:l,original:r})),a.renameSync(o,r)}catch(p){throw m(o)&&a.rmSync(o,{recursive:!0,force:!0}),l&&!m(r)&&m(l)&&a.renameSync(l,r),p}}function T(e,r){if(/^mcp_servers:[ \t]*(?!\{\}[ \t]*(?:#.*)?$)\S+/m.test(e))throw new Error(`${r}: mcp_servers must be a block mapping`);let t=[],n=new Map,s=e.split(/\r?\n/),c=0;for(let o=0;o<s.length;o+=1){let l=s[o];if(/^\s*#/.test(l))continue;if(/^\s*\t|^ +\t/.test(l))throw new Error(`${r}:${o+1}: tabs are not supported in YAML indentation`);let p=l.replace(/\s+#.*$/,"");if(!p.trim()||/^\s*(?:---|\.\.\.)\s*$/.test(p))continue;let h=p.replace(/'(?:[^']|'')*'|"(?:[^"\\]|\\.)*"/g,"");for(let i of h)if("[{".includes(i)&&(c+=1),"]}".includes(i)&&(c-=1),c<0)throw new Error(`${r}:${o+1}: unbalanced flow collection`);if(/^\s*[^#\-][^:]*:\s*(?:.*)?$/.test(p)){let i=p.match(/^ */)[0].length,d=p.trimStart().match(/^([^:]+):/)[1].trim();for(;t.length&&t.at(-1).indent>=i;)t.pop();let y=`${t.map(_=>_.key).join("/")}|${i}|${d}`;if(n.has(y))throw new Error(`${r}:${o+1}: duplicate mapping key ${d}`);n.set(y,!0),/^[^:]+:\s*(?:#.*)?$/.test(p.trimStart())&&t.push({indent:i,key:d})}else if(!/^\s*-\s+/.test(p)&&c===0)throw new Error(`${r}:${o+1}: unsupported or malformed YAML`)}if(c!==0)throw new Error(`${r}: unbalanced flow collection`);if(/^\s*[^#\n]*:\s*[>|][+-]?\s*$/m.test(e)){let o=F(e,"mcp_servers");if(o&&/:\s*[>|][+-]?\s*$/m.test(o.body))throw new Error(`${r}: block scalars inside mcp_servers are unsupported`)}}function F(e,r){let n=new RegExp(`^${r}:[^\\S\\r\\n]*(?:#.*)?$`,"m").exec(e);if(!n)return null;let s=n.index,c=e.indexOf(`
4
- `,s)+1;if(!c)return{start:s,end:e.length,bodyStart:e.length,body:""};let o=e.slice(c),l=/^(?=\S[^\r\n]*:)/m.exec(o),p=l?c+l.index:e.length;return{start:s,bodyStart:c,end:p,body:e.slice(c,p)}}function k(e){return JSON.stringify(e)}function b(e,r){let t=r.command==="node"?[r.script]:r.args,n=[` ${e}:`,` command: ${k(r.command)}`];return t?.length&&n.push(" args:",...t.map(s=>` - ${k(s)}`)),n.push(" enabled: true",` # ${w}`),`${n.join(`
2
+ import B from"node:os";import g from"node:path";import{fileURLToPath as L}from"node:url";import a from"node:fs";import p from"node:path";import{randomBytes as O}from"node:crypto";var w="oracle-profile-upgrade/v1";function m(r){try{return a.accessSync(r),!0}catch{return!1}}function v(r){return m(r)?a.readdirSync(r,{recursive:!0,withFileTypes:!0}).filter(e=>e.isFile()).map(e=>p.join(e.parentPath||e.path,e.name)).sort().map(e=>[p.relative(r,e),a.readFileSync(e)]):[]}function P(r){let e=v(r);return e.push([".oracle-upgrade-version",Buffer.from(`${w}
3
+ `)]),e.sort(([t],[n])=>t.localeCompare(n))}function N(r,e){let t=v(r);return t.length===e.length&&t.every(([n,s],c)=>n===e[c][0]&&s.equals(e[c][1]))}function j(r){return`${r}.tmp-oracle-upgrade-${process.pid}-${O(6).toString("hex")}`}function E(r){let e=`${r}.bak-oracle-upgrade`;for(let t=1;m(e);t+=1)e=`${r}.bak-oracle-upgrade-${t}`;return e}function R(r,e,t,n){if(!m(r)||!a.statSync(r).isDirectory())return;let s=P(r);if(N(e,s)){n.unchanged.push(e);return}let c=m(e);if((c?n.updated:n.created).push(e),!t)return;a.mkdirSync(p.dirname(e),{recursive:!0});let o=j(e),l=null;a.mkdirSync(o);try{for(let[u,h]of s){let i=p.join(o,u);a.mkdirSync(p.dirname(i),{recursive:!0}),a.writeFileSync(i,h)}c&&(l=E(e),a.renameSync(e,l),n.backups.push({path:l,original:e})),a.renameSync(o,e)}catch(u){throw m(o)&&a.rmSync(o,{recursive:!0,force:!0}),l&&!m(e)&&m(l)&&a.renameSync(l,e),u}}function T(r,e){if(/^mcp_servers:[ \t]*(?!\{\}[ \t]*(?:#.*)?$)\S+/m.test(r))throw new Error(`${e}: mcp_servers must be a block mapping`);let t=[],n=new Map,s=r.split(/\r?\n/),c=0;for(let o=0;o<s.length;o+=1){let l=s[o];if(/^\s*#/.test(l))continue;if(/^\s*\t|^ +\t/.test(l))throw new Error(`${e}:${o+1}: tabs are not supported in YAML indentation`);let u=l.replace(/\s+#.*$/,"");if(!u.trim()||/^\s*(?:---|\.\.\.)\s*$/.test(u))continue;let h=u.replace(/'(?:[^']|'')*'|"(?:[^"\\]|\\.)*"/g,"");for(let i of h)if("[{".includes(i)&&(c+=1),"]}".includes(i)&&(c-=1),c<0)throw new Error(`${e}:${o+1}: unbalanced flow collection`);if(/^\s*[^#\-][^:]*:\s*(?:.*)?$/.test(u)){let i=u.match(/^ */)[0].length,d=u.trimStart().match(/^([^:]+):/)[1].trim();for(;t.length&&t.at(-1).indent>=i;)t.pop();let y=`${t.map(_=>_.key).join("/")}|${i}|${d}`;if(n.has(y))throw new Error(`${e}:${o+1}: duplicate mapping key ${d}`);n.set(y,!0),/^[^:]+:\s*(?:#.*)?$/.test(u.trimStart())&&t.push({indent:i,key:d})}else if(!/^\s*-\s+/.test(u)&&c===0)throw new Error(`${e}:${o+1}: unsupported or malformed YAML`)}if(c!==0)throw new Error(`${e}: unbalanced flow collection`);if(/^\s*[^#\n]*:\s*[>|][+-]?\s*$/m.test(r)){let o=F(r,"mcp_servers");if(o&&/:\s*[>|][+-]?\s*$/m.test(o.body))throw new Error(`${e}: block scalars inside mcp_servers are unsupported`)}}function F(r,e){let n=new RegExp(`^${e}:[^\\S\\r\\n]*(?:#.*)?$`,"m").exec(r);if(!n)return null;let s=n.index,c=r.indexOf(`
4
+ `,s)+1;if(!c)return{start:s,end:r.length,bodyStart:r.length,body:""};let o=r.slice(c),l=/^(?=\S[^\r\n]*:)/m.exec(o),u=l?c+l.index:r.length;return{start:s,bodyStart:c,end:u,body:r.slice(c,u)}}function k(r){return JSON.stringify(r)}function b(r,e){let t=e.command==="node"?[e.script]:e.args,n=[` ${r}:`,` command: ${k(e.command)}`];return t?.length&&n.push(" args:",...t.map(s=>` - ${k(s)}`)),n.push(" enabled: true",` # ${w}`),`${n.join(`
5
5
  `)}
6
- `}function q(e,r){e=e.replace(/^(mcp_servers:)\s*\{\}\s*(#.*)?$/m,(s,c,o)=>`${c}${o?` ${o}`:""}`);let t=F(e,"mcp_servers");if(!t){let s=e.length&&!e.endsWith(`
6
+ `}function q(r,e){r=r.replace(/^(mcp_servers:)\s*\{\}\s*(#.*)?$/m,(s,c,o)=>`${c}${o?` ${o}`:""}`);let t=F(r,"mcp_servers");if(!t){let s=r.length&&!r.endsWith(`
7
7
  `)?`
8
- `:"";return`${e}${s}mcp_servers:
9
- ${[...r].map(([c,o])=>b(c,o)).join("")}`}let n=t.body;for(let[s,c]of r){let o=new RegExp(`^ ${s}:[^\\S\\r\\n]*(?:#.*)?\\r?\\n(?:^(?: {3,}|\\s*$).*\\r?\\n?)*`,"m"),l=b(s,c);n=o.test(n)?n.replace(o,l):`${n}${n&&!n.endsWith(`
8
+ `:"";return`${r}${s}mcp_servers:
9
+ ${[...e].map(([c,o])=>b(c,o)).join("")}`}let n=t.body;for(let[s,c]of e){let o=new RegExp(`^ ${s}:[^\\S\\r\\n]*(?:#.*)?\\r?\\n(?:^(?: {3,}|\\s*$).*\\r?\\n?)*`,"m"),l=b(s,c);n=o.test(n)?n.replace(o,l):`${n}${n&&!n.endsWith(`
10
10
  `)?`
11
- `:""}${l}`}return`${e.slice(0,t.bodyStart)}${n}${e.slice(t.end)}`}function A(e,r,t){let n=m(e);if((n?a.readFileSync(e,"utf8"):null)===r){t.unchanged.push(e);return}if((n?t.updated:t.created).push(e),!t.applied)return;if(a.mkdirSync(u.dirname(e),{recursive:!0}),n){let o=j(e);a.copyFileSync(e,o),t.backups.push({path:o,original:e})}let c=E(e);try{a.writeFileSync(c,r,{mode:n?a.statSync(e).mode:384}),a.renameSync(c,e)}catch(o){throw m(c)&&a.rmSync(c,{force:!0}),o}}function M({hermesHome:e,packageRoot:r,only:t=null,apply:n=!1}){let s=u.join(e,"profiles"),c={ok:!0,applied:n,version:w,hermesHome:e,packageRoot:r,profiles:[],created:[],updated:[],unchanged:[],backups:[]},o=m(s)?a.readdirSync(s,{withFileTypes:!0}).filter(i=>i.isDirectory()).map(i=>i.name).sort():[];if(t&&(o=o.filter(i=>i===t)),t&&o.length===0)throw new Error(`profile not found: ${t}`);c.profiles=o;let l=new Map;for(let i of o){let d=u.join(s,i,"config.yaml"),$=m(d)?a.readFileSync(d,"utf8"):"";T($,d),l.set(i,$)}let p=u.join(r,"skills","oracle-action-semantics");if(!m(p))throw new Error(`required Oracle skill is missing: ${p}`);let h=u.join(r,"bin","oracle-data-mcp.mjs");if(!m(h))throw new Error(`oracle-data MCP command is missing: ${h}`);for(let i of o){let d=u.join(s,i);N(p,u.join(d,"skills","oracle-action-semantics"),n,c);let $=new Map([["oracle-data",{command:"node",script:h}]]),y=q(l.get(i),$);A(u.join(d,"config.yaml"),y,c)}return c}var f=process.argv.slice(2),S=e=>{let r=f.indexOf(e);if(r<0)return null;if(!f[r+1]||f[r+1].startsWith("--"))throw new Error(`${e} requires a value`);return f[r+1]};try{let e=new Set(["--apply","--json","--only","--hermes-home","--package-root"]);for(let s=0;s<f.length;s+=1){if(!e.has(f[s]))throw new Error(`unknown option: ${f[s]}`);["--only","--hermes-home","--package-root"].includes(f[s])&&(s+=1)}let r=g.resolve(S("--package-root")||g.join(g.dirname(L(import.meta.url)),"..")),t=g.resolve(S("--hermes-home")||process.env.HERMES_HOME||g.join(B.homedir(),".hermes")),n=M({hermesHome:t,packageRoot:r,only:S("--only"),apply:f.includes("--apply")});if(f.includes("--json"))process.stdout.write(`${JSON.stringify(n,null,2)}
12
- `);else{console.log(`oracle-upgrade ${n.applied?"applied":"dry run"}: ${n.profiles.length} profile(s)`);for(let s of["created","updated","unchanged","backups"])console.log(`${s}: ${n[s].length}`);n.applied||console.log("Re-run with --apply to make these changes.")}}catch(e){let r={ok:!1,error:e.message};f.includes("--json")?process.stdout.write(`${JSON.stringify(r,null,2)}
13
- `):console.error(`oracle-upgrade: ${e.message}`),process.exitCode=1}
11
+ `:""}${l}`}return`${r.slice(0,t.bodyStart)}${n}${r.slice(t.end)}`}function A(r,e,t){let n=m(r);if((n?a.readFileSync(r,"utf8"):null)===e){t.unchanged.push(r);return}if((n?t.updated:t.created).push(r),!t.applied)return;if(a.mkdirSync(p.dirname(r),{recursive:!0}),n){let o=E(r);a.copyFileSync(r,o),t.backups.push({path:o,original:r})}let c=j(r);try{a.writeFileSync(c,e,{mode:n?a.statSync(r).mode:384}),a.renameSync(c,r)}catch(o){throw m(c)&&a.rmSync(c,{force:!0}),o}}function M({hermesHome:r,packageRoot:e,only:t=null,apply:n=!1}){let s=p.join(r,"profiles"),c={ok:!0,applied:n,version:w,hermesHome:r,packageRoot:e,profiles:[],created:[],updated:[],unchanged:[],backups:[]},o=m(s)?a.readdirSync(s,{withFileTypes:!0}).filter(i=>i.isDirectory()).map(i=>i.name).sort():[];if(t&&(o=o.filter(i=>i===t)),t&&o.length===0)throw new Error(`profile not found: ${t}`);c.profiles=o;let l=new Map;for(let i of o){let d=p.join(s,i,"config.yaml"),$=m(d)?a.readFileSync(d,"utf8"):"";T($,d),l.set(i,$)}let u=[p.join(e,"skills","oracle-action-semantics"),p.join(e,"assets","skills","oracle-action-semantics")].find(i=>m(i));if(!u)throw new Error(`required Oracle skill is missing: ${p.join(e,"skills","oracle-action-semantics")}`);let h=p.join(e,"bin","oracle-data-mcp.mjs");if(!m(h))throw new Error(`oracle-data MCP command is missing: ${h}`);for(let i of o){let d=p.join(s,i);R(u,p.join(d,"skills","oracle-action-semantics"),n,c);let $=new Map([["oracle-data",{command:"node",script:h}]]),y=q(l.get(i),$);A(p.join(d,"config.yaml"),y,c)}return c}var f=process.argv.slice(2),S=r=>{let e=f.indexOf(r);if(e<0)return null;if(!f[e+1]||f[e+1].startsWith("--"))throw new Error(`${r} requires a value`);return f[e+1]};try{let r=new Set(["--apply","--json","--only","--hermes-home","--package-root"]);for(let s=0;s<f.length;s+=1){if(!r.has(f[s]))throw new Error(`unknown option: ${f[s]}`);["--only","--hermes-home","--package-root"].includes(f[s])&&(s+=1)}let e=g.resolve(S("--package-root")||g.join(g.dirname(L(import.meta.url)),"..")),t=g.resolve(S("--hermes-home")||process.env.HERMES_HOME||g.join(B.homedir(),".hermes")),n=M({hermesHome:t,packageRoot:e,only:S("--only"),apply:f.includes("--apply")});if(f.includes("--json"))process.stdout.write(`${JSON.stringify(n,null,2)}
12
+ `);else{console.log(`oracle-upgrade ${n.applied?"applied":"dry run"}: ${n.profiles.length} profile(s)`);for(let s of["created","updated","unchanged","backups"])console.log(`${s}: ${n[s].length}`);n.applied||console.log("Re-run with --apply to make these changes.")}}catch(r){let e={ok:!1,error:r.message};f.includes("--json")?process.stdout.write(`${JSON.stringify(e,null,2)}
13
+ `):console.error(`oracle-upgrade: ${r.message}`),process.exitCode=1}
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{realpathSync as U}from"node:fs";import{fileURLToPath as re}from"node:url";import h from"node:fs";import g from"node:path";import{pathToFileURL as Y}from"node:url";import d from"node:fs";import D from"node:os";import i from"node:path";import{fileURLToPath as T}from"node:url";var P=i.dirname(T(import.meta.url)),l=i.resolve(P,"../..");function u(){return process.env.ORACLE_FAKE_HOME||D.homedir()}function A(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function f(){return A()?process.env.ORACLE_CONFIG_DIR||i.join(u(),".config","oracle"):i.join(u(),".config","oracle")}function $(){return i.join(f(),"exec.env")}function _(){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 o={},r=(a,t)=>{if(t==null)return;let n=String(t).trim();n&&(process.env[a]!=null&&String(process.env[a]).trim()!==""||(process.env[a]=n,o[a]=n))};try{let a=R();if(d.existsSync(a))for(let t of d.readFileSync(a,"utf8").split(/\r?\n/)){let n=t.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!n||n[2].startsWith("#"))continue;let c=n[2];(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),r(n[1],c)}}catch{}try{let a=_();if(d.existsSync(a)){let t=JSON.parse(d.readFileSync(a,"utf8"));t&&typeof t=="object"&&(r("ORACLE_DESK_URL",t.deskUrl||t.dataUrl||t.url),r("ORACLE_DATA_URL",t.dataUrl||t.deskUrl||t.url),r("ORACLE_API_URL",t.apiUrl||t.dataUrl||t.deskUrl),r("ORACLE_PUBLIC_URL",t.publicUrl||t.deskUrl||t.dataUrl),r("ORACLE_EXEC_URL",t.execUrl),r("MAD_DESK_URL",t.deskUrl||t.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(r("ORACLE_DESK_URL",s),r("ORACLE_DATA_URL",s),r("ORACLE_API_URL",s),r("ORACLE_PUBLIC_URL",s),r("MAD_DESK_URL",s)),p._result=Object.keys(o).length?o:null,p._result}try{p()}catch{}function I(){return process.env.HERMES_HOME?i.resolve(process.env.HERMES_HOME):i.join(u(),".hermes")}function M(){return i.join(u(),".claude.json")}function H(e=process.cwd()){return i.join(e,".mcp.json")}function N(){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 F(){return i.join(u(),".codex","config.toml")}function k(){return i.join(f(),"connectors")}function q(){return i.join(k(),"chatgpt-openapi.json")}function K(){return i.join(f(),"active-chain.json")}function y(e){let o=[i.join(l,"bin",e),i.join(l,"dist","bin",e),i.join(l,"..","bin",e)];return o.find(r=>d.existsSync(r))||o[0]}function G(e){return d.mkdirSync(e,{recursive:!0}),e}var C={homeDir:u,isPublicDesktop:A,oracleConfigDir:f,oracleExecEnvPath:$,oracleDeskJsonPath:_,oracleEnvFilePath:R,loadDeskRouting:p,hermesRoot:I,activeChainPath:K,claudeCodeUserConfigPath:M,claudeCodeProjectMcpPath:H,claudeDesktopConfigPath:N,codexConfigPath:F,chatgptConnectorDir:k,chatgptOpenApiPath:q,packageBin:y,ensureDir:G,PACKAGE_ROOT:l};import{execFile as B}from"node:child_process";import{existsSync as de,mkdirSync as fe,readFileSync as V,realpathSync as me,writeFileSync as he}from"node:fs";import j from"node:path";import{promisify as J}from"node:util";var xe=J(B);var Ee=1440*60*1e3;function v(e,o){let r=t=>String(t).replace(/^v/,"").split("-")[0].split(".").map(n=>Number.parseInt(n,10)||0),s=r(e),a=r(o);for(let t=0;t<Math.max(s.length,a.length);t+=1){let n=s[t]??0,c=a[t]??0;if(n>c)return 1;if(n<c)return-1}return 0}function W(e){let o=e?.stateDir||j.join(process.env.HOME||".",".oracle");return j.join(o,"update-check.json")}function w(e){try{return JSON.parse(V(W(e),"utf8"))}catch{return null}}var z="\u25C7 ORACLE // self-custody multichain agent control plane",X=`START
2
+ import{realpathSync as b}from"node:fs";import{fileURLToPath as re}from"node:url";import h from"node:fs";import g from"node:path";import{pathToFileURL as Y}from"node:url";import d from"node:fs";import D from"node:os";import i from"node:path";import{fileURLToPath as T}from"node:url";var P=i.dirname(T(import.meta.url)),l=i.resolve(P,"../..");function u(){return process.env.ORACLE_FAKE_HOME||D.homedir()}function A(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function f(){return A()?process.env.ORACLE_CONFIG_DIR||i.join(u(),".config","oracle"):i.join(u(),".config","oracle")}function $(){return i.join(f(),"exec.env")}function _(){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 o={},r=(a,t)=>{if(t==null)return;let n=String(t).trim();n&&(process.env[a]!=null&&String(process.env[a]).trim()!==""||(process.env[a]=n,o[a]=n))};try{let a=R();if(d.existsSync(a))for(let t of d.readFileSync(a,"utf8").split(/\r?\n/)){let n=t.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!n||n[2].startsWith("#"))continue;let c=n[2];(c.startsWith('"')&&c.endsWith('"')||c.startsWith("'")&&c.endsWith("'"))&&(c=c.slice(1,-1)),r(n[1],c)}}catch{}try{let a=_();if(d.existsSync(a)){let t=JSON.parse(d.readFileSync(a,"utf8"));t&&typeof t=="object"&&(r("ORACLE_DESK_URL",t.deskUrl||t.dataUrl||t.url),r("ORACLE_DATA_URL",t.dataUrl||t.deskUrl||t.url),r("ORACLE_API_URL",t.apiUrl||t.dataUrl||t.deskUrl),r("ORACLE_PUBLIC_URL",t.publicUrl||t.deskUrl||t.dataUrl),r("ORACLE_EXEC_URL",t.execUrl),r("MAD_DESK_URL",t.deskUrl||t.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(r("ORACLE_DESK_URL",s),r("ORACLE_DATA_URL",s),r("ORACLE_API_URL",s),r("ORACLE_PUBLIC_URL",s),r("MAD_DESK_URL",s)),p._result=Object.keys(o).length?o:null,p._result}try{p()}catch{}function I(){return process.env.HERMES_HOME?i.resolve(process.env.HERMES_HOME):i.join(u(),".hermes")}function M(){return i.join(u(),".claude.json")}function H(e=process.cwd()){return i.join(e,".mcp.json")}function N(){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 F(){return i.join(u(),".codex","config.toml")}function k(){return i.join(f(),"connectors")}function q(){return i.join(k(),"chatgpt-openapi.json")}function K(){return i.join(f(),"active-chain.json")}function y(e){let o=[i.join(l,"bin",e),i.join(l,"dist","bin",e),i.join(l,"..","bin",e)];return o.find(r=>d.existsSync(r))||o[0]}function G(e){return d.mkdirSync(e,{recursive:!0}),e}var C={homeDir:u,isPublicDesktop:A,oracleConfigDir:f,oracleExecEnvPath:$,oracleDeskJsonPath:_,oracleEnvFilePath:R,loadDeskRouting:p,hermesRoot:I,activeChainPath:K,claudeCodeUserConfigPath:M,claudeCodeProjectMcpPath:H,claudeDesktopConfigPath:N,codexConfigPath:F,chatgptConnectorDir:k,chatgptOpenApiPath:q,packageBin:y,ensureDir:G,PACKAGE_ROOT:l};import{execFile as B}from"node:child_process";import{existsSync as de,mkdirSync as fe,readFileSync as V,realpathSync as me,writeFileSync as he}from"node:fs";import v from"node:path";import{promisify as J}from"node:util";var xe=J(B);var Ee=1440*60*1e3;function j(e,o){let r=t=>String(t).replace(/^v/,"").split("-")[0].split(".").map(n=>Number.parseInt(n,10)||0),s=r(e),a=r(o);for(let t=0;t<Math.max(s.length,a.length);t+=1){let n=s[t]??0,c=a[t]??0;if(n>c)return 1;if(n<c)return-1}return 0}function W(e){let o=e?.stateDir||v.join(process.env.HOME||".",".oracle");return v.join(o,"update-check.json")}function w(e){try{return JSON.parse(V(W(e),"utf8"))}catch{return null}}var z="\u25C7 ORACLE // self-custody multichain agent control plane",X=`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
@@ -35,24 +35,24 @@ SYSTEM
35
35
  oracle bootstrap optional Hermes installation
36
36
  oracle public serve secret-free public HTTP surface
37
37
  oracle fees status \xB7 check
38
- oracle eval desk \xB7 fidelity \xB7 hybrid \xB7 guards \xB7 all
38
+ oracle eval desk \xB7 fidelity \xB7 hybrid \xB7 guards \xB7 contracts \xB7 all
39
39
  oracle upgrade update installed agent lanes
40
40
 
41
41
  BOUNDARY
42
- Default and hosted Oracle remain prepare-only. Self-hosters may explicitly
43
- enable the encrypted local signer with exact confirmation and policy rails.
42
+ Oracle ships armed local-signer surfaces for self-hosters. Hosted/keyless
43
+ access cannot move value without the operator's encrypted local signer.
44
44
  Autonomous execution additionally requires ORACLE_AUTONOMOUS_TRADING=1.
45
45
  Use oracle <command> --help for command details.
46
- `;function S(){try{return JSON.parse(h.readFileSync(g.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function Q(){let e=g.join(l,"src","cli","commands");return h.existsSync(e)?e:g.join(l,"dist","cli","commands")}async function m(){let e=Q(),o=new Map;if(!h.existsSync(e))return o;let r=h.readdirSync(e).filter(s=>s.endsWith(".mjs")).sort();for(let s of r){let a=g.join(e,s);try{let n=(await import(Y(a).href+`?t=${Date.now()}`)).default;if(!n||typeof n!="object"||typeof n.run!="function")continue;let c=n.name||s.replace(/\.mjs$/,"");o.set(c,{...n,name:c,__file:a})}catch(t){process.env.ORACLE_CLI_DEBUG&&console.error(`oracle: failed loading command ${s}: ${t.message}`)}}return o}function Z(e,o=w()){return!o?.latest||!e||v(o.latest,e)<=0?"":`
46
+ `;function S(){try{return JSON.parse(h.readFileSync(g.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function Q(){let e=g.join(l,"src","cli","commands");return h.existsSync(e)?e:g.join(l,"dist","cli","commands")}async function m(){let e=Q(),o=new Map;if(!h.existsSync(e))return o;let r=h.readdirSync(e).filter(s=>s.endsWith(".mjs")).sort();for(let s of r){let a=g.join(e,s);try{let n=(await import(Y(a).href+`?t=${Date.now()}`)).default;if(!n||typeof n!="object"||typeof n.run!="function")continue;let c=n.name||s.replace(/\.mjs$/,"");o.set(c,{...n,name:c,__file:a})}catch(t){process.env.ORACLE_CLI_DEBUG&&console.error(`oracle: failed loading command ${s}: ${t.message}`)}}return o}function Z(e,o=w()){return!o?.latest||!e||j(o.latest,e)<=0?"":`
47
47
  Update available: ${e} \u2192 ${o.latest}. Run 'oracle update'.
48
48
  `}function x(e,o){let r=[];r.push(`${z} (v${e})`),r.push(""),r.push(X.trimEnd());let s=[];for(let a of o.values()){if(["help","version"].includes(a.name))continue;!new Set(["init","doctor","chat","model","auth","chain","setup","data","data-mcp","scan","route","prepare","swap","farm","follow","equities","strategy","public","mcp","plugins","harness","upgrade","bootstrap","eval","fees","sign","signer"]).has(a.name)&&a.summary&&s.push(` oracle ${a.name.padEnd(20)} ${a.summary}`)}return s.length&&(r.push(""),r.push("ADDITIONAL"),r.push(...s)),r.join(`
49
49
  `)+`
50
50
  `+Z(e)}function L(e,o){let r=[...o.keys()].sort(),s=r.length?r.join(", "):"(none loaded yet)";return`oracle: unknown command '${e}'. Known: ${s}
51
51
  Try: oracle --help
52
- `}function E(e){return{argv:e,root:l,bin:y,paths:C}}async function b(e=[]){let o=S();if(e.includes("--version")||e.includes("-V"))return O();if(e[0]==="--help"||e[0]==="-h"){let n=await m();return process.stdout.write(x(o,n)),0}if(e.length===0){let n=await m();if(ee(e)){let c=n.get("chat");if(c)return c.run(E([]))}return process.stdout.write(x(o,n)),0}if(te(e[0])){let c=(await m()).get("chat");if(c)return c.run(E(e))}let r=e[0],s=e.slice(1);if(r==="version")return O();if(r==="help"){let n=await m();if(s[0]){let c=n.get(s[0]);return c?(process.stdout.write((c.usage||`oracle ${c.name}`)+`
52
+ `}function E(e){return{argv:e,root:l,bin:y,paths:C}}async function U(e=[]){let o=S();if(e.includes("--version")||e.includes("-V"))return O();if(e[0]==="--help"||e[0]==="-h"){let n=await m();return process.stdout.write(x(o,n)),0}if(e.length===0){let n=await m();if(ee(e)){let c=n.get("chat");if(c)return c.run(E([]))}return process.stdout.write(x(o,n)),0}if(te(e[0])){let c=(await m()).get("chat");if(c)return c.run(E(e))}let r=e[0],s=e.slice(1);if(r==="version")return O();if(r==="help"){let n=await m();if(s[0]){let c=n.get(s[0]);return c?(process.stdout.write((c.usage||`oracle ${c.name}`)+`
53
53
  `),c.summary&&process.stdout.write(c.summary+`
54
54
  `),0):(process.stderr.write(L(s[0],n)),1)}return process.stdout.write(x(o,n)),0}let a=await m(),t=a.get(r);if(t){if(s[0]==="--help"||s[0]==="-h")return process.stdout.write((t.usage||`oracle ${t.name}`)+`
55
55
  `),t.summary&&process.stdout.write(t.summary+`
56
56
  `),0;try{let n=await t.run(E(s));return typeof n=="number"?n:0}catch(n){return process.stderr.write(`oracle ${r}: ${n?.message||n}
57
57
  `),1}}return process.stderr.write(L(r,a)),1}async function O(){let e=S();return process.stdout.write(`oracle ${e}
58
- `),0}function ee(e=[],o={stdin:process.stdin,stdout:process.stdout}){return e.length!==0?!1:process.env.ORACLE_FORCE_CHAT==="1"?!0:o.stdin?.isTTY===!0&&o.stdout?.isTTY===!0}function te(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 Se=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 ne(){if(!process.argv[1])return!1;try{return U(re(import.meta.url))===U(process.argv[1])}catch{return!1}}async function oe(e=process.argv.slice(2)){return b(e)}if(ne()){let e=await oe();process.exit(typeof e=="number"?e:0)}export{Se as COMMANDS,oe as main};
58
+ `),0}function ee(e=[],o={stdin:process.stdin,stdout:process.stdout}){return e.length!==0?!1:process.env.ORACLE_FORCE_CHAT==="1"?!0:o.stdin?.isTTY===!0&&o.stdout?.isTTY===!0}function te(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 Se=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 ne(){if(!process.argv[1])return!1;try{return b(re(import.meta.url))===b(process.argv[1])}catch{return!1}}async function oe(e=process.argv.slice(2)){return U(e)}if(ne()){let e=await oe();process.exit(typeof e=="number"?e:0)}export{Se as COMMANDS,oe as main};