@oracle-agent/oracle 0.35.38 → 0.35.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/agent-sessions.mjs +13 -13
- package/dist/assets/skills/blocked-page-recovery.md +16 -0
- package/dist/assets/skills/browser-use.md +19 -0
- package/dist/assets/skills/chrome-profile-browser.md +21 -0
- package/dist/assets/skills/oracle-agentic-crypto/SKILL.md +27 -0
- package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
- package/dist/assets/skills/oracle-x402/SKILL.md +54 -11
- package/dist/assets/skills/web-form-filling.md +19 -0
- package/dist/assets/skills/web-research.md +17 -0
- package/dist/assets/skills/x-read-browser.md +17 -0
- package/dist/assets/skills/xurl.md +1 -1
- package/dist/bin/desk-server.mjs +30 -30
- package/dist/bin/oracle-data-mcp.mjs +17 -13
- package/dist/bin/oracle-public-server.mjs +1 -1
- package/dist/bin/oracle-route.mjs +26 -14
- package/dist/bin/oracle-scan.mjs +4 -4
- package/dist/bin/oracle.mjs +11 -10
- package/dist/cli/commands/agent-session.mjs +18 -18
- package/dist/cli/commands/auth.mjs +20 -17
- package/dist/cli/commands/chat.mjs +231 -228
- package/dist/cli/commands/data.mjs +5 -5
- package/dist/cli/commands/doctor.mjs +1 -1
- package/dist/cli/commands/eval.mjs +154 -152
- package/dist/cli/commands/extension-policy.mjs +1 -1
- package/dist/cli/commands/follow.mjs +57 -19
- package/dist/cli/commands/governance-prepare.mjs +1 -1
- package/dist/cli/commands/init.mjs +2 -2
- package/dist/cli/commands/model.mjs +235 -232
- package/dist/cli/commands/public.mjs +3 -3
- package/dist/cli/commands/route.mjs +1 -1
- package/dist/cli/commands/setup.mjs +62 -59
- package/dist/cli/commands/signer.mjs +4 -4
- package/dist/cli/commands/upgrade.mjs +2 -2
- package/dist/cli/commands/x402.mjs +19 -0
- package/dist/control-plane/index.mjs +1 -1
- package/dist/data/desk-data.mjs +28 -28
- package/dist/index.mjs +46 -46
- package/dist/local-signer/runtime.mjs +6 -6
- package/dist/teams/index.mjs +6 -5
- package/dist/tui/standalone-client.mjs +84 -82
- package/package.json +1 -1
- package/public/eval-report.json +2 -2
- package/public/oracle-splash/docs/browser-and-web/index.html +32 -0
- package/public/oracle-splash/docs/connectors/index.html +18 -0
- package/public/oracle-splash/docs/docs.css +21 -0
- package/public/oracle-splash/docs/docs.js +108 -0
- package/public/oracle-splash/docs/getting-started/index.html +36 -0
- package/public/oracle-splash/docs/index.html +26 -0
- package/public/oracle-splash/docs/reference/index.html +20 -0
- package/public/oracle-splash/docs/security/index.html +19 -0
- package/public/oracle-splash/docs/using-oracle/index.html +32 -0
- package/public/oracle-splash/download/index.html +2584 -0
- package/public/oracle-splash/index.html +313 -942
- package/public/oracle-splash/pricing/index.html +2570 -0
- package/public/oracle-splash/security/index.html +2574 -0
- package/public/oracle-splash/what-it-does/index.html +2608 -0
- package/public/oracle-splash/where-it-works/index.html +2635 -0
- package/server.json +2 -2
- package/dist/assets/equities-fixtures/bridge_routes.json +0 -159
package/dist/bin/oracle-scan.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createHash as gt}from"node:crypto";import{types as H}from"node:util";import W from"node:net";import mt from"node:dns";var bt=new Set(["localhost","metadata.google.internal","metadata.goog"]);function se(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let r=a=>{if(!a)return[];let u=a.split(":"),p=u.at(-1);if(p?.includes(".")){let f=p.split(".").map(Number);if(f.length!==4||f.some(h=>!Number.isInteger(h)||h<0||h>255))return null;u.splice(u.length-1,1,(f[0]<<8|f[1]).toString(16),(f[2]<<8|f[3]).toString(16))}return u.some(f=>!/^[0-9a-f]{1,4}$/.test(f))?null:u.map(f=>Number.parseInt(f,16))},[n,s]=e.split("::"),o=r(n),i=r(s);if(!o||!i)return null;let l=e.includes("::"),c=8-o.length-i.length;if(!l&&c!==0||l&&c<1)return null;let d=[...o,...Array(Math.max(0,c)).fill(0),...i];return d.length!==8?null:Uint8Array.from(d.flatMap(a=>[a>>8,a&255]))}function he(t,e,r){let n=Math.floor(r/8),s=r%8;for(let i=0;i<n;i+=1)if(t[i]!==e[i])return!1;if(!s)return!0;let o=255<<8-s;return(t[n]&o)===(e[n]&o)}function me(t){if(W.isIPv4(t)){let e=t.split(".").map(Number);return!(e[0]===0||e[0]===10||e[0]===127||e[0]>=224||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&(e[1]===0||e[1]===2||e[1]===168)||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&(e[1]===18||e[1]===19||e[1]===51)||e[0]===203&&e[1]===0&&e[2]===113)}if(W.isIPv6(t)){let e=se(t);if(!e)return!1;let r=se("::ffff:0:0");return he(e,r,96)?me([...e.slice(12)].join(".")):he(e,se("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([s,o])=>he(e,se(s),o)):!1}return!1}function yt(t){let e;try{e=new URL(String(t))}catch{return{ok:!1,error:`not a valid URL: ${String(t).slice(0,120)}`}}if(e.protocol!=="http:"&&e.protocol!=="https:")return{ok:!1,error:`refused protocol ${e.protocol} (only http/https)`};let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(bt.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let n=W.isIP(r);return n!==0&&!me(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:e,host:r,isLiteralIp:n!==0}}async function be(t,{lookupFn:e=mt.promises.lookup}={}){let r=yt(t);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:W.isIPv6(r.host)?6:4}]};let n;try{n=await e(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(n)||n.length===0||n.some(s=>!me(s.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:n}}async function ye({requireUndici:t=!1,importUndici:e=()=>import("undici")}={}){let r,n;try{let u=await e();r=u.Agent,n=u.fetch}catch(u){if(t)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${u?.message||u}`);return null}if(typeof r!="function"||typeof n!="function"){if(t)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let s=u=>String(u).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),o=new Map,i=u=>(Array.isArray(u)?u:[u]).map(p=>typeof p=="string"?{address:p}:p).filter(p=>p&&p.address).map(p=>({address:p.address,family:p.family||(W.isIPv6(p.address)?6:4)})),l=(u,p,f)=>{o.set(s(u),i(typeof p=="string"?[{address:p,family:f}]:p))},c=u=>{let p=s(u);if(W.isIP(p))return[{address:p,family:W.isIPv6(p)?6:4}];let f=o.get(p);if(!f||!f.length)throw new Error(`refused: unpinned host ${u} during pinned fetch`);return f},d=new r({connect:{lookup(u,p,f){let h;try{h=c(u)}catch(b){return f(b)}return p?.all?f(null,h):f(null,h[0].address,h[0].family)}}}),a=wt((u,p={})=>n(u,{...p,dispatcher:d}),l);return{dispatcher:d,fetch:a,pin:l,resolve:c,async close(){try{await d.destroy()}catch{}}}}var we=Symbol.for("oracle.egressGuard.pinCapableFetch");function wt(t,e){if(typeof t!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof e!="function")throw new Error("markPinCapableFetch: pin must be a function");return t[we]=Object.freeze({pin:e}),t}function ge(t){return typeof t=="function"&&typeof t[we]?.pin=="function"}function Re(t,e,r){if(!ge(t))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");t[we].pin(e,r)}var vt=new Set([408,425,429,500,502,503,504]),Le=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),Et=2,Ue=4e3,St=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,At=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,xt=AbortSignal.prototype.throwIfAborted,Ct=EventTarget.prototype.addEventListener,_e=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,Se=t=>t?St.call(t):!1,Tt=t=>t?At.call(t):void 0,It=new Set([301,302,303,307,308]),ie=3,Sr=64*1024,j=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function N(t){return V(`HTTP JSON body refused: ${t}`)}function kt(t){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(e=>typeof H[e]=="function"&&H[e](t))}function Nt(t){let e=[],r=0,n=0,s=0,o=0,i=new WeakSet,l=a=>{if(r+=Buffer.byteLength(a,"utf8"),r>j.bytes)throw N("serialized byte limit exceeded");e.push(a)},c=a=>{if(Buffer.byteLength(a,"utf8")>j.bytes)throw N("serialized byte limit exceeded");return JSON.stringify(a)},d=(a,u)=>{if(n+=1,n>j.nodes)throw N("node limit exceeded");if(u>j.depth)throw N("depth limit exceeded");if(a===null){l("null");return}if(typeof a=="string"){l(c(a));return}if(typeof a=="boolean"){l(a?"true":"false");return}if(typeof a=="number"){if(!Number.isFinite(a))throw N("non-finite number");l(Object.is(a,-0)?"0":String(a));return}if(typeof a!="object")throw N("unsupported non-JSON value");if(H.isProxy(a))throw N("proxy value");if(kt(a))throw N("unsupported exotic object");if(i.has(a))throw N("cyclic value");i.add(a);try{if(Object.getOwnPropertySymbols(a).length>0)throw N("symbol-keyed fields are unsupported");if(Array.isArray(a)){let h=Object.getPrototypeOf(a),b=0;for(;h!==null;){if(H.isProxy(h))throw N("proxy array prototype");if(b+=1,b>j.depth)throw N("array prototype depth limit exceeded");h=Object.getPrototypeOf(h)}if(a.length>j.arrayLength)throw N("array length limit exceeded");for(let C=0;C<a.length;C+=1){let R=Object.getOwnPropertyDescriptor(a,String(C));if(!R||!Object.hasOwn(R,"value")||R.enumerable!==!0)throw N("array entries must be dense enumerable own data")}let w=0;for(let C in a){if(o+=1,o>j.fields)throw N("enumeration limit exceeded");if(Object.hasOwn(a,C)&&(w+=1,w>a.length))throw N("named array fields are unsupported")}if(w!==a.length)throw N("array entries must be dense enumerable own data");l("[");for(let C=0;C<a.length;C+=1)C&&l(","),d(Object.getOwnPropertyDescriptor(a,String(C)).value,u+1);l("]");return}let p=Object.getPrototypeOf(a);if(p!==Object.prototype&&p!==null)throw N("non-plain object");let f=[];for(let h in a){if(o+=1,o>j.fields)throw N("enumeration limit exceeded");if(!Object.hasOwn(a,h))continue;if(s+=1,s>j.fields)throw N("field limit exceeded");let b=Object.getOwnPropertyDescriptor(a,h);if(!b||!Object.hasOwn(b,"value")||b.enumerable!==!0)throw N("object fields must be enumerable own data");f.push([h,b.value])}l("{");for(let h=0;h<f.length;h+=1)h&&l(","),l(c(f[h][0])),l(":"),d(f[h][1],u+1);l("}")}finally{i.delete(a)}};return d(t,0),e.join("")}function Ot(t){let e=Object.create(null);if(t==null)return e;if(typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP headers must be an object");if(H.isProxy(t))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let n of Object.keys(t)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(n))throw new TypeError("HTTP header names must be valid tokens");let s=n.toLowerCase();if(r.has(s))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(s);let o=Object.getOwnPropertyDescriptor(t,n);if(!o||!Object.hasOwn(o,"value"))throw new TypeError("HTTP headers must contain own data properties");let i=o.value;if(i==null||["object","function","symbol"].includes(typeof i))throw new TypeError("HTTP header values must be scalar");e[n]=String(i)}return e}function Pt(){return Object.assign(Object.create(null),{Accept:"application/json"})}function Rt(t,e){if(!t)throw new Error(`HTTP redirect from ${e} missing Location`);let r=new URL(String(t),String(e));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${e} used unsupported protocol ${r.protocol}`);return r.toString()}function Lt(t,e){return new URL(String(t)).origin===new URL(String(e)).origin}var ve=new Map,qe=new WeakMap,Be=1;function ae(t){if((typeof t!="object"||t===null)&&typeof t!="function")return`${typeof t}:${String(t)}`;let e=qe.get(t);return e||(e=Be,Be+=1,qe.set(t,e)),`reference:${e}`}var Ut=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),_t=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function $e(t){if(!t||typeof t!="object"||Array.isArray(t)||!Object.hasOwn(t,"jsonrpc")||!Object.hasOwn(t,"method")||t.jsonrpc!=="2.0")return!1;let e=typeof t.method=="string"?t.method:"";return e?Ut.has(e)||/^get[A-Z0-9_]/u.test(e)||/^is[A-Z0-9_]/u.test(e)||/^eth_get[A-Z0-9_]/u.test(e):!1}function Fe(t,e){if(t==="GET"&&e==null)return!0;if(t!=="POST"||e==null)return!1;let r=e;if(typeof e=="string")try{r=JSON.parse(e)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every($e);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return $e(r);let n=Object.hasOwn(r,"type")?r.type:null;return typeof n=="string"&&_t.has(n)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function qt(t,e,r,n={},s=null){let o=gt("sha256"),i=(c,d)=>{let a=String(d);o.update(String(Buffer.byteLength(c,"utf8"))).update(":").update(c),o.update("=").update(String(Buffer.byteLength(a,"utf8"))).update(":").update(a).update(`
|
|
3
|
-
`)};i("method",t),i("url",e),Object.keys(r||{}).map((c,d)=>({name:c.toLowerCase(),order:d,value:String(r[c])})).sort((c,d)=>c.name.localeCompare(d.name)||c.order-d.order).forEach((c,d)=>{i(`header-name-${d}`,c.name),i(`header-value-${d}`,c.value)}),i("body",s??"-");for(let c of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])i(`context-${c}`,n[c]??"-");return o.digest("hex")}function Bt(t,e){let r=Number(e);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Ue):Math.min(250*2**t,Ue)+Math.floor(Math.random()*100)}var $t=t=>new Promise(e=>setTimeout(e,t));function V(t,e={}){let r=new Error(t);return r.retryable=!1,Object.assign(r,e),r}function Ee(t,e,r){return V(`HTTP response from ${t} exceeded maxResponseBytes ${r} (${e})`,{oversize:!0})}function K(t){try{let e=t?.body?.cancel?.();e&&typeof e.then=="function"&&e.catch(()=>{})}catch{}}function Ft(t){return t?t.byteLength??t.length??0:0}async function Dt(t,e,{url:r,truncate:n=!1,onOversize:s}={}){if(e==null)return await t.text();let o=Number(t.headers?.get?.("content-length"));if(Number.isFinite(o)&&o>e&&(K(t),!n))throw Ee(r,`content-length ${o}`,e);let i=t.body?.getReader?.();if(!i){let u=await t.text(),p=Buffer.byteLength(u,"utf8");if(p>e){if(!n)throw Ee(r,`body ${p} bytes`,e);return Buffer.from(u,"utf8").subarray(0,e).toString("utf8")}return u}let l=[],c=0,d=!1;try{for(;;){let{value:u,done:p}=await i.read();if(p)break;if(u&&(l.push(Buffer.from(u)),c+=Ft(u),c>e)){d=!0;break}}}finally{if(d)try{await i.cancel()}catch{}try{i.releaseLock?.()}catch{}}if(d&&(typeof s=="function"&&s(),!n))throw Ee(r,`streamed ${c} bytes`,e);let a=Buffer.concat(l);return(d?a.subarray(0,e):a).toString("utf8")}function jt(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function Ht(t,{fetchImpl:e,method:r,headers:n,body:s,timeoutMs:o,lookupFn:i,realFetch:l,untrustedUrl:c=!1,maxResponseBytes:d=null,sameOriginRedirectsOnly:a=!1,importUndici:u,validateResponse:p,signal:f,redirectPolicy:h="follow",maxRedirects:b=ie}){let w=new AbortController,C=setTimeout(()=>w.abort(),o),R=f?_e?_e([f,w.signal]):f:w.signal,S=null,L=e,O=i?{lookupFn:i}:{};if(c&&!l&&!ge(L))throw V(`HTTP refused ${t}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let A=async(v,{status:x=null}={})=>{let E=await be(v,O);if(!E.ok)throw V(x==null?`HTTP refused ${v}: ${E.error}`:`HTTP redirect to ${v} ${E.error}`,x==null?{}:{status:x});let U=new URL(v).hostname;if(l){if(S&&(await S.close(),S=null),!S)try{S=await ye({requireUndici:!0,...u?{importUndici:u}:{}})}catch(m){throw V(x==null?`HTTP refused ${v}: ${m?.message||m}`:`HTTP redirect to ${v} refused: ${m?.message||m}`,x==null?{}:{status:x})}S.pin(U,E.addresses),L=S.fetch}else Re(L,U,E.addresses);return E};try{let v=String(t),x=Object.assign(Object.create(null),n||{});c&&await A(v);for(let E=0;E<=b;E+=1){let U=Object.assign(Object.create(null),{method:r,headers:x,body:s,signal:R,redirect:"manual",dispatcher:void 0}),m=await L(v,U);if((h==="error"||b===0)&&m.status>=300&&m.status<400)throw K(m),V(`HTTP ${m.status} ${r} redirect refused`,{status:m.status,redirectRefused:!0});if(It.has(m.status)){let q=a===!0&&r==="POST"&&[307,308].includes(m.status)&&Fe(r,s);if(r!=="GET"&&r!=="HEAD"&&!q){K(m);let P=new Error(`HTTP ${m.status} ${r} ${v} redirected non-idempotent request`);throw P.status=m.status,P}if(E===b)throw K(m),V(`HTTP ${m.status} ${r} redirect budget exhausted`,{status:m.status,redirectRefused:!0});let Oe=m.headers?.get?.("location"),$;try{$=Rt(Oe,v)}catch(P){throw K(m),P}let M=!Lt($,v);if(K(m),M&&r==="POST"){let P=new Error(`HTTP ${m.status} ${r} cross-origin redirect refused`);throw P.status=m.status,P}if(M&&a){let P=new Error(`HTTP ${m.status} ${r} cross-origin redirect refused`);throw P.status=m.status,P.retryable=!1,P}if(M&&(x=Pt(x)),c)await A($,{status:m.status});else if(M){let P=await be($,O);if(!P.ok){let k=new Error(`HTTP redirect from ${v} ${P.error}`);throw k.status=m.status,k.retryable=!1,k}l&&P.addresses?.length&&(S||(S=await ye(u?{importUndici:u}:{})),S&&(S.pin(new URL($).hostname,P.addresses),L=S.fetch))}v=$;continue}if(typeof p=="function")try{await p(m,{url:v})}catch(q){throw K(m),V(q?.message||String(q))}let _=await Dt(m,d,{url:v,onOversize:()=>w.abort()}),X=jt(_);if(!m.ok){let q=new Error(`HTTP ${m.status} ${r} ${v}`);throw q.status=m.status,q.retryAfter=m.headers?.get?.("retry-after")??null,q.body=X??_.slice(0,300),q}return X??_}throw new Error(`HTTP redirect loop for ${t}`)}catch(v){if(w.signal.aborted&&!Se(f)){let x=v&&(typeof v=="object"||typeof v=="function")&&!H.isProxy(v)?v:null,E=x?Object.getOwnPropertyDescriptor(x,"oversize"):null;if(!(E&&Object.hasOwn(E,"value")&&E.value===!0))try{if(!x)throw new TypeError("unsafe rejection");Object.defineProperties(x,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let m=new Error("HTTP request timed out");throw Object.defineProperties(m,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),m}}throw v}finally{clearTimeout(C),S&&await S.close()}}async function ce(t,e={}){if(e!=null&&typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP options must be an object");if(e!=null&&H.isProxy(e))throw new TypeError("HTTP options must not be a proxy");let r=new Set(["body","dedupe","fetchImpl","headers","importUndici","lookupFn","maxRedirects","maxResponseBytes","method","redirectPolicy","retries","sameOriginRedirectsOnly","signal","timeoutMs","untrustedUrl","validateResponse"]);if(e!=null){if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP options contain unknown fields");for(let k of Object.getOwnPropertyNames(e)){let T=Object.getOwnPropertyDescriptor(e,k);if(!(k==="toJSON"&&T&&Object.hasOwn(T,"value")&&T.value===void 0)){if(!r.has(k))throw new TypeError("HTTP options contain unknown fields");if(!T||!T.enumerable||!Object.hasOwn(T,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let n=k=>{if(e==null||!Object.hasOwn(e,k))return;let T=Object.getOwnPropertyDescriptor(e,k);if(!T||!Object.hasOwn(T,"value"))throw new TypeError("HTTP options must contain own data properties");return T.value};if(typeof t!="string"||t.length===0||t.length>8192)throw new TypeError("HTTP URL must be a bounded string");let s=n("method");if(s!==void 0&&(typeof s!="string"||!/^[A-Za-z]+$/u.test(s)))throw new TypeError("HTTP method must be a string token");let o=n("timeoutMs");if(o!==void 0&&(!Number.isInteger(o)||o<1||o>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let i=n("retries");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>10))throw new TypeError("HTTP retries must be a bounded integer");let l=n("redirectPolicy");if(l!==void 0&&l!=="follow"&&l!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let c=n("maxRedirects");if(c!==void 0&&(!Number.isInteger(c)||c<0||c>ie))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ie}`);if(l==="error"&&c!==void 0&&c!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let d=l??"follow",a=d==="error"?0:c??ie;for(let k of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let T=n(k);if(T!==void 0&&typeof T!="boolean")throw new TypeError(`HTTP ${k} must be boolean`)}let u=n("maxResponseBytes");if(u!==void 0&&(!Number.isInteger(u)||u<1||u>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let p=n("signal");if(p!==void 0){if(H.isProxy(p)||!(p instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{Se(p)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let k of["importUndici","lookupFn","validateResponse"]){let T=n(k);if(T!==void 0&&typeof T!="function")throw new TypeError(`HTTP ${k} must be a function`)}let f=n("fetchImpl"),h=f||globalThis.fetch;if(typeof h!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let b=o??12e3,w=(s||"GET").toUpperCase(),C=n("headers"),R=Ot(C),S=Object.assign(Object.create(null),R);Object.keys(S).some(k=>k.toLowerCase()==="accept")||(S.Accept="application/json");let L=n("body");L!=null&&typeof L!="string"&&(Object.keys(S).find(T=>T.toLowerCase()==="content-type")||(S["Content-Type"]="application/json"),L=Nt(L));let O=i??Et,A=n("lookupFn"),v=!f,x=n("untrustedUrl")===!0,E=n("sameOriginRedirectsOnly")===!0,U=n("importUndici"),m=n("validateResponse"),_=p,X=u??null,q=async()=>{let k;for(let T=0;T<=O;T++){_&&xt.call(_);try{return await Ht(t,{fetchImpl:h,method:w,headers:S,body:L,timeoutMs:b,lookupFn:A,realFetch:v,untrustedUrl:x,maxResponseBytes:X,sameOriginRedirectsOnly:E,importUndici:U,validateResponse:m,signal:_,redirectPolicy:d,maxRedirects:a})}catch(z){k=z;let Y=fe=>{if(!z||typeof z!="object"&&typeof z!="function"||H.isProxy(z))return;let Z=Object.getOwnPropertyDescriptor(z,fe);return Z&&Object.hasOwn(Z,"value")?Z.value:void 0},pe=Y("status"),dt=Y("oracleTimeout")===!0||Y("name")==="AbortError"||Y("name")==="TimeoutError"||Se(_),pt=new Set([408,425,429]),ft=Y("retryable")===!1?!1:pe!=null?pt.has(pe)||vt.has(pe)&&Le.has(w):!dt&&Le.has(w);if(T===O||!ft)throw z;let Pe=Bt(T,Y("retryAfter"));_?await new Promise((fe,Z)=>{let ht=setTimeout(fe,Pe);Ct.call(_,"abort",()=>{clearTimeout(ht),Z(Tt(_)||new DOMException("Aborted","AbortError"))},{once:!0})}):await $t(Pe)}}throw k};if(!(n("dedupe")!==!1&&!_&&Fe(w,L)))return q();let $=qt(w,t,S,{untrustedUrl:x,maxResponseBytes:X,sameOriginRedirectsOnly:E,redirectPolicy:d,maxRedirects:a,timeoutMs:b,retries:O,fetchImpl:ae(h),realFetch:v,lookupFn:ae(A),importUndici:ae(U),validateResponse:ae(m)},L),M=ve.get($);if(M)return M;let P=q().finally(()=>ve.delete($));return ve.set($,P),P}async function De(t,e,r){let n=Array.from(t),s=Math.max(1,Math.min(Number(e)||1,n.length||1)),o=new Array(n.length),i=0;return await Promise.all(Array.from({length:s},async()=>{for(;i<n.length;){let l=i++;o[l]=await r(n[l],l)}})),o}var je={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}},Vt=new Map(Object.values(je).map(t=>[t.chainId,t]));function He(t){return Vt.get(Number(t))||null}function Ve(t,e=process.env){let r=He(t);if(!r)return null;for(let n of r.rpcEnv){let s=(e[n]||"").trim();if(s)return s}return null}import{Interface as Mt,getAddress as zt}from"ethers";var Me=new Mt(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function ze(t,e){try{return zt(t).toLowerCase()}catch{throw new Error(`${e} must be a valid EVM address`)}}var Wt={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 Kt(t,{rpcUrl:e,env:r=process.env}={}){if(e)return e;let n=Ve(t,r);return n||Wt[Number(t)]||null}var Gt=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function Qt(t){let e=String(t||""),r=e.toLowerCase();if(e!==e.trim()||!/^[a-zA-Z0-9_]+$/.test(e)||!Gt.test(r))throw new Error(`evm-rpc: ${e} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var ee=new Map,We=new Map;function Yt(t){let e=new Error(t?.message||JSON.stringify(t));return e.code=t?.code,e}function Jt(t){if(t?.error)throw Yt(t.error);return t?.result}function Xt(t,e,r){return`${t}
|
|
2
|
+
import{createHash as gt}from"node:crypto";import{types as H}from"node:util";import W from"node:net";import mt from"node:dns";var bt=new Set(["localhost","metadata.google.internal","metadata.goog"]);function se(t){let e=String(t).toLowerCase().split("%")[0];if((e.match(/::/g)||[]).length>1)return null;let r=i=>{if(!i)return[];let u=i.split(":"),p=u.at(-1);if(p?.includes(".")){let f=p.split(".").map(Number);if(f.length!==4||f.some(h=>!Number.isInteger(h)||h<0||h>255))return null;u.splice(u.length-1,1,(f[0]<<8|f[1]).toString(16),(f[2]<<8|f[3]).toString(16))}return u.some(f=>!/^[0-9a-f]{1,4}$/.test(f))?null:u.map(f=>Number.parseInt(f,16))},[n,s]=e.split("::"),o=r(n),a=r(s);if(!o||!a)return null;let l=e.includes("::"),c=8-o.length-a.length;if(!l&&c!==0||l&&c<1)return null;let d=[...o,...Array(Math.max(0,c)).fill(0),...a];return d.length!==8?null:Uint8Array.from(d.flatMap(i=>[i>>8,i&255]))}function he(t,e,r){let n=Math.floor(r/8),s=r%8;for(let a=0;a<n;a+=1)if(t[a]!==e[a])return!1;if(!s)return!0;let o=255<<8-s;return(t[n]&o)===(e[n]&o)}function me(t){if(W.isIPv4(t)){let e=t.split(".").map(Number);return!(e[0]===0||e[0]===10||e[0]===127||e[0]>=224||e[0]===100&&e[1]>=64&&e[1]<=127||e[0]===169&&e[1]===254||e[0]===172&&e[1]>=16&&e[1]<=31||e[0]===192&&(e[1]===0||e[1]===2||e[1]===168)||e[0]===192&&e[1]===88&&e[2]===99||e[0]===198&&(e[1]===18||e[1]===19||e[1]===51)||e[0]===203&&e[1]===0&&e[2]===113)}if(W.isIPv6(t)){let e=se(t);if(!e)return!1;let r=se("::ffff:0:0");return he(e,r,96)?me([...e.slice(12)].join(".")):he(e,se("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([s,o])=>he(e,se(s),o)):!1}return!1}function yt(t){let e;try{e=new URL(String(t))}catch{return{ok:!1,error:`not a valid URL: ${String(t).slice(0,120)}`}}if(e.protocol!=="http:"&&e.protocol!=="https:")return{ok:!1,error:`refused protocol ${e.protocol} (only http/https)`};let r=e.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(bt.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let n=W.isIP(r);return n!==0&&!me(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:e,host:r,isLiteralIp:n!==0}}async function be(t,{lookupFn:e=mt.promises.lookup}={}){let r=yt(t);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:W.isIPv6(r.host)?6:4}]};let n;try{n=await e(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(n)||n.length===0||n.some(s=>!me(s.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:n}}async function ye({requireUndici:t=!1,importUndici:e=()=>import("undici")}={}){let r,n;try{let u=await e();r=u.Agent,n=u.fetch}catch(u){if(t)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${u?.message||u}`);return null}if(typeof r!="function"||typeof n!="function"){if(t)throw new Error("egress-guard: untrustedUrl pinning requires undici's Agent and fetch exports, which were not found on the imported module");return null}let s=u=>String(u).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),o=new Map,a=u=>(Array.isArray(u)?u:[u]).map(p=>typeof p=="string"?{address:p}:p).filter(p=>p&&p.address).map(p=>({address:p.address,family:p.family||(W.isIPv6(p.address)?6:4)})),l=(u,p,f)=>{o.set(s(u),a(typeof p=="string"?[{address:p,family:f}]:p))},c=u=>{let p=s(u);if(W.isIP(p))return[{address:p,family:W.isIPv6(p)?6:4}];let f=o.get(p);if(!f||!f.length)throw new Error(`refused: unpinned host ${u} during pinned fetch`);return f},d=new r({connect:{lookup(u,p,f){let h;try{h=c(u)}catch(b){return f(b)}return p?.all?f(null,h):f(null,h[0].address,h[0].family)}}}),i=wt((u,p={})=>n(u,{...p,dispatcher:d}),l);return{dispatcher:d,fetch:i,pin:l,resolve:c,async close(){try{await d.destroy()}catch{}}}}var we=Symbol.for("oracle.egressGuard.pinCapableFetch");function wt(t,e){if(typeof t!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof e!="function")throw new Error("markPinCapableFetch: pin must be a function");return t[we]=Object.freeze({pin:e}),t}function ge(t){return typeof t=="function"&&typeof t[we]?.pin=="function"}function Re(t,e,r){if(!ge(t))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");t[we].pin(e,r)}var vt=new Set([408,425,429,500,502,503,504]),Le=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),Et=2,Ue=4e3,St=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,At=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,xt=AbortSignal.prototype.throwIfAborted,Ct=EventTarget.prototype.addEventListener,_e=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,Se=t=>t?St.call(t):!1,Tt=t=>t?At.call(t):void 0,It=new Set([301,302,303,307,308]),ae=3,Sr=64*1024,j=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function N(t){return V(`HTTP JSON body refused: ${t}`)}function kt(t){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(e=>typeof H[e]=="function"&&H[e](t))}function Nt(t){let e=[],r=0,n=0,s=0,o=0,a=new WeakSet,l=i=>{if(r+=Buffer.byteLength(i,"utf8"),r>j.bytes)throw N("serialized byte limit exceeded");e.push(i)},c=i=>{if(Buffer.byteLength(i,"utf8")>j.bytes)throw N("serialized byte limit exceeded");return JSON.stringify(i)},d=(i,u)=>{if(n+=1,n>j.nodes)throw N("node limit exceeded");if(u>j.depth)throw N("depth limit exceeded");if(i===null){l("null");return}if(typeof i=="string"){l(c(i));return}if(typeof i=="boolean"){l(i?"true":"false");return}if(typeof i=="number"){if(!Number.isFinite(i))throw N("non-finite number");l(Object.is(i,-0)?"0":String(i));return}if(typeof i!="object")throw N("unsupported non-JSON value");if(H.isProxy(i))throw N("proxy value");if(kt(i))throw N("unsupported exotic object");if(a.has(i))throw N("cyclic value");a.add(i);try{if(Object.getOwnPropertySymbols(i).length>0)throw N("symbol-keyed fields are unsupported");if(Array.isArray(i)){let h=Object.getPrototypeOf(i),b=0;for(;h!==null;){if(H.isProxy(h))throw N("proxy array prototype");if(b+=1,b>j.depth)throw N("array prototype depth limit exceeded");h=Object.getPrototypeOf(h)}if(i.length>j.arrayLength)throw N("array length limit exceeded");for(let C=0;C<i.length;C+=1){let R=Object.getOwnPropertyDescriptor(i,String(C));if(!R||!Object.hasOwn(R,"value")||R.enumerable!==!0)throw N("array entries must be dense enumerable own data")}let w=0;for(let C in i){if(o+=1,o>j.fields)throw N("enumeration limit exceeded");if(Object.hasOwn(i,C)&&(w+=1,w>i.length))throw N("named array fields are unsupported")}if(w!==i.length)throw N("array entries must be dense enumerable own data");l("[");for(let C=0;C<i.length;C+=1)C&&l(","),d(Object.getOwnPropertyDescriptor(i,String(C)).value,u+1);l("]");return}let p=Object.getPrototypeOf(i);if(p!==Object.prototype&&p!==null)throw N("non-plain object");let f=[];for(let h in i){if(o+=1,o>j.fields)throw N("enumeration limit exceeded");if(!Object.hasOwn(i,h))continue;if(s+=1,s>j.fields)throw N("field limit exceeded");let b=Object.getOwnPropertyDescriptor(i,h);if(!b||!Object.hasOwn(b,"value")||b.enumerable!==!0)throw N("object fields must be enumerable own data");f.push([h,b.value])}l("{");for(let h=0;h<f.length;h+=1)h&&l(","),l(c(f[h][0])),l(":"),d(f[h][1],u+1);l("}")}finally{a.delete(i)}};return d(t,0),e.join("")}function Ot(t){let e=Object.create(null);if(t==null)return e;if(typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP headers must be an object");if(H.isProxy(t))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let n of Object.keys(t)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(n))throw new TypeError("HTTP header names must be valid tokens");let s=n.toLowerCase();if(r.has(s))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(s);let o=Object.getOwnPropertyDescriptor(t,n);if(!o||!Object.hasOwn(o,"value"))throw new TypeError("HTTP headers must contain own data properties");let a=o.value;if(a==null||["object","function","symbol"].includes(typeof a))throw new TypeError("HTTP header values must be scalar");e[n]=String(a)}return e}function Pt(){return Object.assign(Object.create(null),{Accept:"application/json"})}function Rt(t,e){if(!t)throw new Error(`HTTP redirect from ${e} missing Location`);let r=new URL(String(t),String(e));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${e} used unsupported protocol ${r.protocol}`);return r.toString()}function Lt(t,e){return new URL(String(t)).origin===new URL(String(e)).origin}var ve=new Map,qe=new WeakMap,Be=1;function ie(t){if((typeof t!="object"||t===null)&&typeof t!="function")return`${typeof t}:${String(t)}`;let e=qe.get(t);return e||(e=Be,Be+=1,qe.set(t,e)),`reference:${e}`}var Ut=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),_t=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function $e(t){if(!t||typeof t!="object"||Array.isArray(t)||!Object.hasOwn(t,"jsonrpc")||!Object.hasOwn(t,"method")||t.jsonrpc!=="2.0")return!1;let e=typeof t.method=="string"?t.method:"";return e?Ut.has(e)||/^get[A-Z0-9_]/u.test(e)||/^is[A-Z0-9_]/u.test(e)||/^eth_get[A-Z0-9_]/u.test(e):!1}function Fe(t,e){if(t==="GET"&&e==null)return!0;if(t!=="POST"||e==null)return!1;let r=e;if(typeof e=="string")try{r=JSON.parse(e)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every($e);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return $e(r);let n=Object.hasOwn(r,"type")?r.type:null;return typeof n=="string"&&_t.has(n)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function qt(t,e,r,n={},s=null){let o=gt("sha256"),a=(c,d)=>{let i=String(d);o.update(String(Buffer.byteLength(c,"utf8"))).update(":").update(c),o.update("=").update(String(Buffer.byteLength(i,"utf8"))).update(":").update(i).update(`
|
|
3
|
+
`)};a("method",t),a("url",e),Object.keys(r||{}).map((c,d)=>({name:c.toLowerCase(),order:d,value:String(r[c])})).sort((c,d)=>c.name.localeCompare(d.name)||c.order-d.order).forEach((c,d)=>{a(`header-name-${d}`,c.name),a(`header-value-${d}`,c.value)}),a("body",s??"-");for(let c of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])a(`context-${c}`,n[c]??"-");return o.digest("hex")}function Bt(t,e){let r=Number(e);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Ue):Math.min(250*2**t,Ue)+Math.floor(Math.random()*100)}var $t=t=>new Promise(e=>setTimeout(e,t));function V(t,e={}){let r=new Error(t);return r.retryable=!1,Object.assign(r,e),r}function Ee(t,e,r){return V(`HTTP response from ${t} exceeded maxResponseBytes ${r} (${e})`,{oversize:!0})}function K(t){try{let e=t?.body?.cancel?.();e&&typeof e.then=="function"&&e.catch(()=>{})}catch{}}function Ft(t){return t?t.byteLength??t.length??0:0}async function Dt(t,e,{url:r,truncate:n=!1,onOversize:s}={}){if(e==null)return await t.text();let o=Number(t.headers?.get?.("content-length"));if(Number.isFinite(o)&&o>e&&(K(t),!n))throw Ee(r,`content-length ${o}`,e);let a=t.body?.getReader?.();if(!a){let u=await t.text(),p=Buffer.byteLength(u,"utf8");if(p>e){if(!n)throw Ee(r,`body ${p} bytes`,e);return Buffer.from(u,"utf8").subarray(0,e).toString("utf8")}return u}let l=[],c=0,d=!1;try{for(;;){let{value:u,done:p}=await a.read();if(p)break;if(u&&(l.push(Buffer.from(u)),c+=Ft(u),c>e)){d=!0;break}}}finally{if(d)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(d&&(typeof s=="function"&&s(),!n))throw Ee(r,`streamed ${c} bytes`,e);let i=Buffer.concat(l);return(d?i.subarray(0,e):i).toString("utf8")}function jt(t){if(!t)return null;try{return JSON.parse(t)}catch{return null}}async function Ht(t,{fetchImpl:e,method:r,headers:n,body:s,timeoutMs:o,lookupFn:a,realFetch:l,untrustedUrl:c=!1,maxResponseBytes:d=null,sameOriginRedirectsOnly:i=!1,importUndici:u,validateResponse:p,signal:f,redirectPolicy:h="follow",maxRedirects:b=ae}){let w=new AbortController,C=setTimeout(()=>w.abort(),o),R=f?_e?_e([f,w.signal]):f:w.signal,S=null,L=e,O=a?{lookupFn:a}:{};if(c&&!l&&!ge(L))throw V(`HTTP refused ${t}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let A=async(v,{status:x=null}={})=>{let E=await be(v,O);if(!E.ok)throw V(x==null?`HTTP refused ${v}: ${E.error}`:`HTTP redirect to ${v} ${E.error}`,x==null?{}:{status:x});let U=new URL(v).hostname;if(l){if(S&&(await S.close(),S=null),!S)try{S=await ye({requireUndici:!0,...u?{importUndici:u}:{}})}catch(m){throw V(x==null?`HTTP refused ${v}: ${m?.message||m}`:`HTTP redirect to ${v} refused: ${m?.message||m}`,x==null?{}:{status:x})}S.pin(U,E.addresses),L=S.fetch}else Re(L,U,E.addresses);return E};try{let v=String(t),x=Object.assign(Object.create(null),n||{});c&&await A(v);for(let E=0;E<=b;E+=1){let U=Object.assign(Object.create(null),{method:r,headers:x,body:s,signal:R,redirect:"manual",dispatcher:void 0}),m=await L(v,U);if((h==="error"||b===0)&&m.status>=300&&m.status<400)throw K(m),V(`HTTP ${m.status} ${r} redirect refused`,{status:m.status,redirectRefused:!0});if(It.has(m.status)){let q=i===!0&&r==="POST"&&[307,308].includes(m.status)&&Fe(r,s);if(r!=="GET"&&r!=="HEAD"&&!q){K(m);let P=new Error(`HTTP ${m.status} ${r} ${v} redirected non-idempotent request`);throw P.status=m.status,P}if(E===b)throw K(m),V(`HTTP ${m.status} ${r} redirect budget exhausted`,{status:m.status,redirectRefused:!0});let Oe=m.headers?.get?.("location"),$;try{$=Rt(Oe,v)}catch(P){throw K(m),P}let M=!Lt($,v);if(K(m),M&&r==="POST"){let P=new Error(`HTTP ${m.status} ${r} cross-origin redirect refused`);throw P.status=m.status,P}if(M&&i){let P=new Error(`HTTP ${m.status} ${r} cross-origin redirect refused`);throw P.status=m.status,P.retryable=!1,P}if(M&&(x=Pt(x)),c)await A($,{status:m.status});else if(M){let P=await be($,O);if(!P.ok){let k=new Error(`HTTP redirect from ${v} ${P.error}`);throw k.status=m.status,k.retryable=!1,k}l&&P.addresses?.length&&(S||(S=await ye(u?{importUndici:u}:{})),S&&(S.pin(new URL($).hostname,P.addresses),L=S.fetch))}v=$;continue}if(typeof p=="function")try{await p(m,{url:v})}catch(q){throw K(m),V(q?.message||String(q))}let _=await Dt(m,d,{url:v,onOversize:()=>w.abort()}),X=jt(_);if(!m.ok){let q=new Error(`HTTP ${m.status} ${r} ${v}`);throw q.status=m.status,q.retryAfter=m.headers?.get?.("retry-after")??null,q.body=X??_.slice(0,300),q}return X??_}throw new Error(`HTTP redirect loop for ${t}`)}catch(v){if(w.signal.aborted&&!Se(f)){let x=v&&(typeof v=="object"||typeof v=="function")&&!H.isProxy(v)?v:null,E=x?Object.getOwnPropertyDescriptor(x,"oversize"):null;if(!(E&&Object.hasOwn(E,"value")&&E.value===!0))try{if(!x)throw new TypeError("unsafe rejection");Object.defineProperties(x,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let m=new Error("HTTP request timed out");throw Object.defineProperties(m,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),m}}throw v}finally{clearTimeout(C),S&&await S.close()}}async function ce(t,e={}){if(e!=null&&typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP options must be an object");if(e!=null&&H.isProxy(e))throw new TypeError("HTTP options must not be a proxy");let r=new Set(["body","dedupe","fetchImpl","headers","importUndici","lookupFn","maxRedirects","maxResponseBytes","method","redirectPolicy","retries","sameOriginRedirectsOnly","signal","timeoutMs","untrustedUrl","validateResponse"]);if(e!=null){if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP options contain unknown fields");for(let k of Object.getOwnPropertyNames(e)){let T=Object.getOwnPropertyDescriptor(e,k);if(!(k==="toJSON"&&T&&Object.hasOwn(T,"value")&&T.value===void 0)){if(!r.has(k))throw new TypeError("HTTP options contain unknown fields");if(!T||!T.enumerable||!Object.hasOwn(T,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let n=k=>{if(e==null||!Object.hasOwn(e,k))return;let T=Object.getOwnPropertyDescriptor(e,k);if(!T||!Object.hasOwn(T,"value"))throw new TypeError("HTTP options must contain own data properties");return T.value};if(typeof t!="string"||t.length===0||t.length>8192)throw new TypeError("HTTP URL must be a bounded string");let s=n("method");if(s!==void 0&&(typeof s!="string"||!/^[A-Za-z]+$/u.test(s)))throw new TypeError("HTTP method must be a string token");let o=n("timeoutMs");if(o!==void 0&&(!Number.isInteger(o)||o<1||o>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let a=n("retries");if(a!==void 0&&(!Number.isInteger(a)||a<0||a>10))throw new TypeError("HTTP retries must be a bounded integer");let l=n("redirectPolicy");if(l!==void 0&&l!=="follow"&&l!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let c=n("maxRedirects");if(c!==void 0&&(!Number.isInteger(c)||c<0||c>ae))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ae}`);if(l==="error"&&c!==void 0&&c!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let d=l??"follow",i=d==="error"?0:c??ae;for(let k of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let T=n(k);if(T!==void 0&&typeof T!="boolean")throw new TypeError(`HTTP ${k} must be boolean`)}let u=n("maxResponseBytes");if(u!==void 0&&(!Number.isInteger(u)||u<1||u>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let p=n("signal");if(p!==void 0){if(H.isProxy(p)||!(p instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{Se(p)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let k of["importUndici","lookupFn","validateResponse"]){let T=n(k);if(T!==void 0&&typeof T!="function")throw new TypeError(`HTTP ${k} must be a function`)}let f=n("fetchImpl"),h=f||globalThis.fetch;if(typeof h!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let b=o??12e3,w=(s||"GET").toUpperCase(),C=n("headers"),R=Ot(C),S=Object.assign(Object.create(null),R);Object.keys(S).some(k=>k.toLowerCase()==="accept")||(S.Accept="application/json");let L=n("body");L!=null&&typeof L!="string"&&(Object.keys(S).find(T=>T.toLowerCase()==="content-type")||(S["Content-Type"]="application/json"),L=Nt(L));let O=a??Et,A=n("lookupFn"),v=!f,x=n("untrustedUrl")===!0,E=n("sameOriginRedirectsOnly")===!0,U=n("importUndici"),m=n("validateResponse"),_=p,X=u??null,q=async()=>{let k;for(let T=0;T<=O;T++){_&&xt.call(_);try{return await Ht(t,{fetchImpl:h,method:w,headers:S,body:L,timeoutMs:b,lookupFn:A,realFetch:v,untrustedUrl:x,maxResponseBytes:X,sameOriginRedirectsOnly:E,importUndici:U,validateResponse:m,signal:_,redirectPolicy:d,maxRedirects:i})}catch(z){k=z;let Y=fe=>{if(!z||typeof z!="object"&&typeof z!="function"||H.isProxy(z))return;let Z=Object.getOwnPropertyDescriptor(z,fe);return Z&&Object.hasOwn(Z,"value")?Z.value:void 0},pe=Y("status"),dt=Y("oracleTimeout")===!0||Y("name")==="AbortError"||Y("name")==="TimeoutError"||Se(_),pt=new Set([408,425,429]),ft=Y("retryable")===!1?!1:pe!=null?pt.has(pe)||vt.has(pe)&&Le.has(w):!dt&&Le.has(w);if(T===O||!ft)throw z;let Pe=Bt(T,Y("retryAfter"));_?await new Promise((fe,Z)=>{let ht=setTimeout(fe,Pe);Ct.call(_,"abort",()=>{clearTimeout(ht),Z(Tt(_)||new DOMException("Aborted","AbortError"))},{once:!0})}):await $t(Pe)}}throw k};if(!(n("dedupe")!==!1&&!_&&Fe(w,L)))return q();let $=qt(w,t,S,{untrustedUrl:x,maxResponseBytes:X,sameOriginRedirectsOnly:E,redirectPolicy:d,maxRedirects:i,timeoutMs:b,retries:O,fetchImpl:ie(h),realFetch:v,lookupFn:ie(A),importUndici:ie(U),validateResponse:ie(m)},L),M=ve.get($);if(M)return M;let P=q().finally(()=>ve.delete($));return ve.set($,P),P}async function De(t,e,r){let n=Array.from(t),s=Math.max(1,Math.min(Number(e)||1,n.length||1)),o=new Array(n.length),a=0;return await Promise.all(Array.from({length:s},async()=>{for(;a<n.length;){let l=a++;o[l]=await r(n[l],l)}})),o}var je={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}},Vt=new Map(Object.values(je).map(t=>[t.chainId,t]));function He(t){return Vt.get(Number(t))||null}function Ve(t,e=process.env){let r=He(t);if(!r)return null;for(let n of r.rpcEnv){let s=(e[n]||"").trim();if(s)return s}return null}import{Interface as Mt,getAddress as zt}from"ethers";var Me=new Mt(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function ze(t,e){try{return zt(t).toLowerCase()}catch{throw new Error(`${e} must be a valid EVM address`)}}var Wt={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 Kt(t,{rpcUrl:e,env:r=process.env}={}){if(e)return e;let n=Ve(t,r);return n||Wt[Number(t)]||null}var Gt=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function Qt(t){let e=String(t||""),r=e.toLowerCase();if(e!==e.trim()||!/^[a-zA-Z0-9_]+$/.test(e)||!Gt.test(r))throw new Error(`evm-rpc: ${e} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var ee=new Map,We=new Map;function Yt(t){let e=new Error(t?.message||JSON.stringify(t));return e.code=t?.code,e}function Jt(t){if(t?.error)throw Yt(t.error);return t?.result}function Xt(t,e,r){return`${t}
|
|
4
4
|
${e}
|
|
5
|
-
${JSON.stringify(r??[])}`}async function Zt(t,e,r){return ce(t,{method:"POST",body:e,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function F(t,e,r=[],n={}){let s=String(e||""),o=Qt(s),
|
|
5
|
+
${JSON.stringify(r??[])}`}async function Zt(t,e,r){return ce(t,{method:"POST",body:e,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function F(t,e,r=[],n={}){let s=String(e||""),o=Qt(s),a=Kt(t,n);if(!a)throw new Error(`No RPC URL for chainId ${t} (set env from chain registry rpcEnv or pass rpcUrl)`);if(o==="eth_chainid"&&n.cacheChainId!==!1){let i=We.get(a);if(i!=null)return i}let c=n.dedupe!==!1&&!n.signal?Xt(a,s,r):null;if(c&&ee.has(c))return ee.get(c);let d=(async()=>{let i=await Zt(a,{jsonrpc:"2.0",id:1,method:e,params:r},n),u=Jt(i);return o==="eth_chainid"&&typeof u=="string"&&We.set(a,u),u})();return c&&(ee.set(c,d),d.finally(()=>{ee.get(c)===d&&ee.delete(c)}).catch(()=>{})),d}async function Ke(t,e={}){let r=await F(t,"eth_blockNumber",[],e);return parseInt(r,16)}async function Ge(t,e,r={}){if(!e)throw new Error("rpcGetBalance requires address");let n=await F(t,"eth_getBalance",[e,"latest"],r);return{chainId:Number(t),address:e,balanceWei:BigInt(n).toString(),balanceHex:n}}async function Qe(t={},e={}){let r=Number(t.chainId??e.chainId??1),n=ze(t.token||t.tokenAddress,"token"),s=ze(t.account||t.owner||t.address,"account"),o=Me.encodeFunctionData("balanceOf",[s]),a=await F(r,"eth_call",[{to:n,data:o},t.blockTag||"latest"],e),l=Me.decodeFunctionResult("balanceOf",a),c=BigInt(l[0]);return{chainId:r,token:n,account:s,balance:c.toString(),balanceHex:`0x${c.toString(16)}`,blockTag:t.blockTag||"latest"}}var er=new Set(["usdc","usdt","usdg","dai","usd1","usde","pyusd"]);function Ye(t,e){let r=String(t||"").toLowerCase(),n=String(e?.quote||e?.quoteToken?.address||"").toLowerCase(),s=String(e?.base||e?.baseToken?.address||"").toLowerCase();return n===r?{address:e.base||e.baseToken?.address,symbol:e.baseToken?.symbol}:s===r?{address:e.quote||e.quoteToken?.address,symbol:e.quoteToken?.symbol}:{address:e.quote||e.quoteToken?.address,symbol:e.quoteToken?.symbol}}function Ae(t,e=[],{stables:r=[],wrappedNative:n=null}={}){let s=String(t||"").toLowerCase(),o=new Set((r||[]).map(c=>String(c).toLowerCase())),a=String(n||"").toLowerCase(),l=(e||[]).map((c,d)=>{let i=Ye(s,c),u=String(i.address||"").toLowerCase(),p=String(i.symbol||"").toLowerCase(),f=Number(c.liquidityUsd??c.liquidity?.usd),h=Number.isFinite(f)?f:0,b=String(c.dex||c.dexId||"").toLowerCase(),w=0;return o.has(u)||er.has(p)?w=300:a&&u===a&&(w=100),b.includes("v4")?w+=20:b.includes("v3")?w+=10:(b.includes("v2")||b.includes("raydium")||b.includes("orca")||b.includes("meteora"))&&(w+=8),{pool:c,score:w*1e12+h,index:d,otherAddr:u,liquidityUsd:h}});return l.sort((c,d)=>d.score-c.score||c.index-d.index),l.map(c=>c.pool)}function Je(t,e=[]){let r=Array.isArray(e)?e:[];return r.length&&Ye(t,r[0]).address||null}var tr="https://api.dexscreener.com",Lr=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function rr(t={}){return(t.baseUrl||process.env.DEXSCREENER_API_URL||tr).replace(/\/$/,"")}function nr(t,e){if(typeof t!="string"&&typeof t!="number")throw new Error(`${e} required`);let r=String(t).trim();if(!r||r.length>128||!/^[A-Za-z0-9][A-Za-z0-9._:+~-]*$/u.test(r))throw new Error(`${e} must be a valid path component of at most 128 characters`);return encodeURIComponent(r)}function or(t,e){return ce(`${rr(e)}${t}`,{fetchImpl:e.fetchImpl,timeoutMs:e.timeoutMs??12e3})}async function Xe(t,e={}){return or(`/latest/dex/tokens/${nr(t,"tokenAddress")}`,e)}var te=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"}),y=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),sr=/^0x[0-9a-fA-F]{40}$/;function ir(t={}){let e=[],r=[];if(!t||typeof t!="object")return{ok:!1,errors:["definition must be an object"],warnings:r};if((!Number.isInteger(t.chainId)||t.chainId<=0)&&e.push("chainId must be a positive integer"),(typeof t.key!="string"||!/^[a-z][a-z0-9-]*$/.test(t.key||""))&&e.push('key must be a lowercase slug (e.g. "base")'),(typeof t.name!="string"||!t.name.trim())&&e.push("name is required"),!Array.isArray(t.rpcEnv)||t.rpcEnv.length===0)e.push("rpcEnv must list at least one environment variable name");else for(let s of t.rpcEnv)(typeof s!="string"||!/^[A-Z][A-Z0-9_]*$/.test(s))&&e.push(`rpcEnv entry "${s}" should be an UPPER_SNAKE env var name`);if(t.nativeCurrency){let s=t.nativeCurrency;(typeof s.symbol!="string"||!s.symbol)&&e.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(s.decimals)||e.push("nativeCurrency.decimals must be an integer")}for(let[s,o]of(t.venues||[]).entries()){let a=`venues[${s}]`;if(!o||typeof o!="object"){e.push(`${a} must be an object`);continue}sr.test(o.address||"")||e.push(`${a}.address is not a valid 20-byte address`),/^0x0{40}$/.test(o.address||"")&&e.push(`${a}.address is the zero address -- placeholder left in place?`),o.kind||e.push(`${a}.kind is required (router|quoter|factory|...)`),o.verified?(o.verified.method||e.push(`${a}.verified.method is required`),o.verified.source||e.push(`${a}.verified.source is required`),o.verified.date||r.push(`${a}.verified.date missing -- add one so staleness is visible`)):e.push(`${a} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let n=t.capabilities||{};for(let s of Object.keys(n))te.includes(s)?typeof n[s]!="function"&&e.push(`capability "${s}" must be a function`):e.push(`unknown capability "${s}"`);return Object.keys(n).length===0&&r.push("scanner implements no capabilities -- it can only be registered, not used"),n.prepareUnsignedTx&&!n.quote&&r.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),n.prepareUnsignedTx&&!n.sellSimulation&&r.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:e.length===0,errors:e,warnings:r}}function ar(t){let{ok:e,errors:r,warnings:n}=ir(t);if(!e)throw new Error(`invalid scanner for ${t?.key??"<unknown>"}:
|
|
6
6
|
- ${r.join(`
|
|
7
|
-
- `)}`);let s=t.capabilities||{},o=te.filter(l=>typeof s[l]=="function"),i={key:t.key,chainId:t.chainId,name:t.name,rpcEnv:[...t.rpcEnv],nativeCurrency:t.nativeCurrency?{...t.nativeCurrency}:null,wrappedNative:t.wrappedNative||null,explorer:t.explorer||null,venues:(t.venues||[]).map(l=>({...l})),warnings:n,capabilities(){return{chainId:t.chainId,key:t.key,supported:[...o],unsupported:te.filter(l=>!o.includes(l))}},supports(l){return o.includes(l)}};for(let l of te)o.includes(l)?i[l]=async(...c)=>s[l](...c,{scanner:i}):i[l]=async()=>{throw new Error(`${t.key} (chain ${t.chainId}) does not implement "${l}". Supported: ${o.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(i)}var re=new Map;function Ze(t){let e=ir(t);return re.set(e.chainId,e),e}function xe(t){return re.get(Number(t))||null}function ue(){return[...re.values()]}function et(){let t={};for(let e of re.values())t[e.chainId]={key:e.key,name:e.name,...e.capabilities(),venueCount:e.venues.length,failClosed:e.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:re.size,capabilities:[...te],chains:t}}var Te={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},B=t=>BigInt(t).toString(16).padStart(64,"0"),ne=t=>t.slice(2).toLowerCase().padStart(64,"0");function cr(t,e){return`0x${Te.getAmountsOut}`+B(t)+B(64)+B(e.length)+e.map(ne).join("")}function ur(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length<128)return null;let r=Number(BigInt(`0x${e.slice(64,128)}`));if(!Number.isFinite(r)||r<1||r>16)return null;let n=[];for(let s=0;s<r;s++){let o=128+s*64;if(e.length<o+64)return null;n.push(BigInt(`0x${e.slice(o,o+64)}`))}return n}function Ce(t,e="router"){return(t?.venues||[]).find(n=>n.kind===e)?.address??null}var Ie=100;function lr(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Ie)throw new Error(`slippageBps ${r} exceeds the ${Ie} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(r))/10000n}function tt(t){let{chainId:e,wrappedNative:r}=t;async function n(s,o,i,l){let c=await F(e,"eth_call",[{to:s,data:cr(o,i)},"latest"],l);return ur(c?.result??c)}return{async quote({tokenIn:s,tokenOut:o,amountIn:i,path:l},c={}){let d=Ce(c.scanner);if(!d)return{chainId:e,evidence:g.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let a=l||[s,o];if(a.some(p=>!/^0x[0-9a-fA-F]{40}$/.test(p||"")))throw new Error("quote requires valid 20-byte addresses");let u=await n(d,i,a,c);return u?{chainId:e,router:d,path:a,amountIn:String(i),amountOut:u[u.length-1].toString(),hops:a.length-1,evidence:g.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:e,router:d,path:a,evidence:g.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:s,amountIn:o,base:i},l={}){let c=Ce(l.scanner),d=i||r;if(d&&String(s).toLowerCase()===String(d).toLowerCase())return{chainId:e,token:s,verdict:y.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||!d)return{chainId:e,token:s,verdict:y.UNKNOWN,evidence:g.UNAVAILABLE,reason:c?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let a=await n(c,o,[d,s],l);if(!a)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let u=a[a.length-1];if(u===0n)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let p=await n(c,u,[s,d],l);if(!p)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"sell",bought:u.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=p[p.length-1],h=Number(f*10000n/BigInt(o)),b=y.PASS,w="round trip completes with expected fee/impact loss";return h<5e3?(b=y.FAIL,w=`round trip returns only ${(h/100).toFixed(2)}% -- punitive tax or no real liquidity`):h<9e3&&(b=y.CAUTION,w=`round trip returns ${(h/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,token:s,base:d,router:c,verdict:b,reason:w,amountIn:String(o),bought:u.toString(),returned:f.toString(),retentionBps:h,evidence:g.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:o,amountIn:i,recipient:l,slippageBps:c=50,deadlineSeconds:d=900,path:a},u={}){let p=u.scanner,f=Ce(p);if(!f)throw new Error(`chain ${e} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(l||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let h=a||[s,o],b=await this.quote({tokenIn:s,tokenOut:o,amountIn:i,path:h},u);if(b.evidence!==g.LIVE)throw new Error(`cannot prepare without a live quote (${b.evidence}: ${b.reason??"no reason given"})`);let w=lr(b.amountOut,c);if(w<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let C=BigInt(Math.floor(Date.now()/1e3)+Number(d)),R=r&&h[0].toLowerCase()===r.toLowerCase()&&u.useNative,S=R?`0x${Te.swapExactETHForTokens}`+B(w)+B(128)+ne(l)+B(C)+B(h.length)+h.map(ne).join(""):`0x${Te.swapExactTokensForTokens}`+B(i)+B(w)+B(160)+ne(l)+B(C)+B(h.length)+h.map(ne).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:e,tx:{to:f,data:S,value:R?`0x${BigInt(i).toString(16)}`:"0x0"},guard:{quotedOut:b.amountOut,minOut:w.toString(),slippageBps:c,maxSlippageBps:Ie,deadline:C.toString()},requires:R?[]:[{step:"approve",token:h[0],spender:f,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 dr=[100,500,3e3,1e4],rt={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},G=t=>BigInt(t).toString(16).padStart(64,"0"),oe=t=>t.slice(2).toLowerCase().padStart(64,"0"),nt=/^0x[0-9a-fA-F]{40}$/,Ne=100;function pr(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Ne)throw new Error(`slippageBps ${r} exceeds the ${Ne} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(r))/10000n}function ke(t,e){return(t?.venues||[]).find(r=>r.kind===e)?.address??null}function ot(t){let{chainId:e,wrappedNative:r}=t;async function n({quoter:o,tokenIn:i,tokenOut:l,amountIn:c,fee:d},a){let u=`0x${rt.quoteExactInputSingle}`+oe(i)+oe(l)+G(c)+G(d)+G(0),p=await F(e,"eth_call",[{to:o,data:u},"latest"],a).catch(()=>null),f=p?.result??p;if(!f||f==="0x"||f.length<66)return null;let h=BigInt(`0x${f.slice(2,66)}`);return h>0n?h:null}async function s({quoter:o,tokenIn:i,tokenOut:l,amountIn:c},d){let a=await Promise.all(dr.map(async p=>{let f=await n({quoter:o,tokenIn:i,tokenOut:l,amountIn:c,fee:p},d);return{fee:p,amountOut:f?f.toString():null,out:f}})),u=null;for(let p of a)p.out&&(!u||p.out>u.amountOut)&&(u={fee:p.fee,amountOut:p.out});return{best:u,tried:a.map(({fee:p,amountOut:f})=>({fee:p,amountOut:f}))}}return{async quote({tokenIn:o,tokenOut:i,amountIn:l},c={}){let d=ke(c.scanner,"quoter");if(!d)return{chainId:e,evidence:g.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let p of[o,i])if(!nt.test(p||""))throw new Error("quote requires valid 20-byte addresses");let{best:a,tried:u}=await s({quoter:d,tokenIn:o,tokenOut:i,amountIn:l},c);return a?{chainId:e,venue:"uniswap-v3",quoter:d,tokenIn:o,tokenOut:i,amountIn:String(l),amountOut:a.amountOut.toString(),fee:a.fee,useNative:!!r&&String(o).toLowerCase()===String(r).toLowerCase(),triedFeeTiers:u,evidence:g.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:e,quoter:d,tokenIn:o,tokenOut:i,triedFeeTiers:u,evidence:g.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:o,amountIn:i,base:l},c={}){let d=ke(c.scanner,"quoter"),a=(t.stableQuoteAssets||[]).map(O=>String(O).toLowerCase()),u=null;!l&&typeof t.resolveQuoteAsset=="function"&&(u=await t.resolveQuoteAsset(o,c).catch(()=>null));let p=String(o).toLowerCase(),f=String(r||"").toLowerCase();if(f&&p===f)return{chainId:e,token:o,verdict:y.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."};let h=l||u||(a[0]&&p!==a[0]?a[0]:null)||r;if(h&&p===String(h).toLowerCase())return{chainId:e,token:o,verdict:y.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(!d||!h)return{chainId:e,token:o,verdict:y.UNKNOWN,evidence:g.UNAVAILABLE,reason:d?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let b=await s({quoter:d,tokenIn:h,tokenOut:o,amountIn:i},c);if(!b.best){let O=a.find(A=>A&&A!==String(h).toLowerCase()&&A!==String(o).toLowerCase());if(O){let A=await s({quoter:d,tokenIn:O,tokenOut:o,amountIn:i},c);if(A.best){let v=await s({quoter:d,tokenIn:o,tokenOut:O,amountIn:A.best.amountOut},c);if(v.best){let x=v.best.amountOut,E=Number(x*10000n/BigInt(i)),U=y.PASS,m="round trip vs dollar book completes with expected fee/impact loss";return E<5e3?(U=y.FAIL,m=`round trip vs dollar book returns only ${(E/100).toFixed(2)}% -- punitive tax or no real liquidity`):E<9e3&&(U=y.CAUTION,m=`round trip vs dollar book returns ${(E/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:U,reason:m,amountIn:String(i),bought:A.best.amountOut.toString(),returned:x.toString(),retentionBps:E,buyFee:A.best.fee,sellFee:v.best.fee,evidence:g.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:e,token:o,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let w=await s({quoter:d,tokenIn:o,tokenOut:h,amountIn:b.best.amountOut},c);if(!w.best){let O=a.find(A=>A&&A!==String(h).toLowerCase()&&A!==String(o).toLowerCase());if(O){let A=await s({quoter:d,tokenIn:O,tokenOut:o,amountIn:i},c),v=A.best?await s({quoter:d,tokenIn:o,tokenOut:O,amountIn:A.best.amountOut},c):{best:null};if(A.best&&v.best){let x=v.best.amountOut,E=Number(x*10000n/BigInt(i)),U=y.PASS,m="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return E<5e3?(U=y.FAIL,m=`dollar-book round trip returns only ${(E/100).toFixed(2)}%`):E<9e3&&(U=y.CAUTION,m=`dollar-book round trip returns ${(E/100).toFixed(2)}%`),{chainId:e,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:U,reason:m,amountIn:String(i),bought:A.best.amountOut.toString(),returned:x.toString(),retentionBps:E,buyFee:A.best.fee,sellFee:v.best.fee,evidence:g.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:e,token:o,verdict:y.FAIL,evidence:g.LIVE,leg:"sell",bought:b.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let C=w.best.amountOut,R=Number(C*10000n/BigInt(i)),S=y.PASS,L="round trip completes with expected fee/impact loss";return R<5e3?(S=y.FAIL,L=`round trip returns only ${(R/100).toFixed(2)}% -- punitive tax or no real liquidity`):R<9e3&&(S=y.CAUTION,L=`round trip returns ${(R/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:h,verdict:S,reason:L,amountIn:String(i),bought:b.best.amountOut.toString(),returned:C.toString(),retentionBps:R,buyFee:b.best.fee,sellFee:w.best.fee,evidence:g.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:o,tokenOut:i,amountIn:l,recipient:c,slippageBps:d=50,fee:a},u={}){let p=ke(u.scanner,"router");if(!p)throw new Error(`chain ${e} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!nt.test(c||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:o,tokenOut:i,amountIn:l},u);if(f.evidence!==g.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let h=a??f.fee,b=pr(f.amountOut,d);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let w=!!(u.useNative||f.useNative)&&r&&String(o).toLowerCase()===String(r).toLowerCase(),C=`0x${rt.exactInputSingle}`+oe(o)+oe(i)+G(h)+oe(c)+G(l)+G(b)+G(0);return{unsigned:!0,signedBy:"user-wallet",chainId:e,venue:"uniswap-v3",tx:{to:p,data:C,value:w?String(l):"0x0"},guard:{quotedOut:f.amountOut,minOut:b.toString(),slippageBps:d,maxSlippageBps:Ne,fee:h},requires:w?[]:[{step:"approve",token:o,spender:p,amount:String(l)}],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 le={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function st(t){if(!t||t==="0x")return null;try{return BigInt(t)}catch{return null}}function at(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length>=128){let n=Number(BigInt(`0x${e.slice(64,128)}`));if(n>0&&n<=256&&e.length>=128+n*2){let s=e.slice(128,128+n*2),o=Buffer.from(s,"hex").toString("utf8").replace(/\0+$/,"");if(o)return o}}return Buffer.from(e.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function fr(t){let{chainId:e}=t;async function r(n,s,o){return F(e,"eth_call",[{to:n,data:s},"latest"],o)}return{async blockNumber(n={}){let s=await Ke(e,n);return{chainId:e,blockNumber:s?.blockNumber??s,evidence:g.LIVE}},async nativeBalance(n,s={}){let o=await Ge(e,n,s);return{chainId:e,address:n,wei:o?.wei??o?.balance??null,symbol:t.nativeCurrency?.symbol??null,decimals:t.nativeCurrency?.decimals??18,evidence:g.LIVE}},async tokenBalance({token:n,owner:s},o={}){let i=await Qe({chainId:e,token:n,owner:s},o);return{chainId:e,token:n,owner:s,raw:i?.balance??i,evidence:g.LIVE}},async resolveToken(n,s={}){if(!/^0x[0-9a-fA-F]{40}$/.test(n||""))return{chainId:e,token:n,evidence:g.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,i,l,c]=await Promise.all([r(n,le.decimals,s).catch(()=>null),r(n,le.symbol,s).catch(()=>null),r(n,le.name,s).catch(()=>null),r(n,le.totalSupply,s).catch(()=>null)]),d=st(o?.result??o),a=d!==null||i?.result||l?.result,u={chainId:e,address:n,decimals:d===null?null:Number(d),symbol:at(i?.result??i),name:at(l?.result??l),totalSupply:(st(c?.result??c)??null)?.toString()??null,evidence:a?g.LIVE:g.UNKNOWN};return a||(u.warning="no ERC-20 metadata returned -- may not be a token contract"),u},async resolvePools(n,s={}){let o=t.dexscreenerSlug;if(!o)return{chainId:e,token:n,pools:[],evidence:g.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let i=await Xe(n,s).catch(()=>null),c=(i?.pairs||i?.data?.pairs||[]).filter(a=>String(a.chainId).toLowerCase()===String(o).toLowerCase()).map(a=>({pair:a.pairAddress,dex:a.dexId,base:a.baseToken?.address,quote:a.quoteToken?.address,liquidityUsd:a.liquidity?.usd??null,priceUsd:a.priceUsd??null,volume24hUsd:a.volume?.h24??null,createdAt:a.pairCreatedAt??null})).sort((a,u)=>(u.liquidityUsd??0)-(a.liquidityUsd??0)),d=Ae(n,c,{stables:t.stableQuoteAssets||[],wrappedNative:t.wrappedNative});return{chainId:e,token:n,pools:d,topPool:d[0]||null,quoteAsset:Je(n,d),evidence:d.length?g.LIVE:g.UNKNOWN}},async scanBlocks({fromBlock:n,toBlock:s,address:o,topics:i,chunkSize:l=2e3}={},c={}){if(!Number.isInteger(n)||!Number.isInteger(s))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(s<n)throw new Error("toBlock must be >= fromBlock");let d=[],a=[];for(let p=n;p<=s;p+=l){let f=Math.min(p+l-1,s);a.push([p,f])}let u=await De(a,4,async([p,f])=>{let h={fromBlock:`0x${p.toString(16)}`,toBlock:`0x${f.toString(16)}`};o&&(h.address=o),i&&(h.topics=i);let b=await F(e,"eth_getLogs",[h],c).catch(w=>({error:String(w?.message||w)}));return{start:p,end:f,res:b}});for(let{start:p,end:f,res:h}of u){if(h?.error)return{chainId:e,fromBlock:n,toBlock:s,logs:d,complete:!1,failedAt:[p,f],error:h.error,evidence:g.UNKNOWN};for(let b of h?.result??h??[])d.push(b)}return{chainId:e,fromBlock:n,toBlock:s,logs:d,complete:!0,chunks:a.length,evidence:g.LIVE}},async scoreRisk(n,s={}){let o=[],i=y.PASS,l=a=>{let u={[y.PASS]:0,[y.CAUTION]:1,[y.UNKNOWN]:2,[y.FAIL]:3};u[a]>u[i]&&(i=a)},[c,d]=await Promise.all([this.resolveToken(n,s),this.resolvePools(n,s)]);if(c.evidence!==g.LIVE?(o.push({check:"erc20-metadata",result:y.UNKNOWN,detail:c.warning}),l(y.UNKNOWN)):o.push({check:"erc20-metadata",result:y.PASS,detail:`${c.symbol} / ${c.decimals}d`}),d.evidence===g.UNAVAILABLE)o.push({check:"liquidity",result:y.UNKNOWN,detail:d.reason}),l(y.UNKNOWN);else if(!d.pools.length)o.push({check:"liquidity",result:y.FAIL,detail:"no pool with liquidity found"}),l(y.FAIL);else{let a=d.pools[0],u=a.liquidityUsd??0;u<5e3?(o.push({check:"liquidity",result:y.CAUTION,detail:`top pool only $${u}`}),l(y.CAUTION)):o.push({check:"liquidity",result:y.PASS,detail:`$${u} on ${a.dex}`}),a.createdAt&&Date.now()-a.createdAt<24*3600*1e3&&(o.push({check:"age",result:y.CAUTION,detail:"pool under 24h old"}),l(y.CAUTION))}if(typeof this.sellSimulation=="function"){let a=await this.sellSimulation({token:n,amountIn:(10n**16n).toString()},s).catch(u=>({verdict:y.UNKNOWN,reason:String(u?.message||u)}));o.push({check:"sellability",result:a.verdict,detail:a.retentionBps!=null?`round trip returns ${(a.retentionBps/100).toFixed(2)}% -- ${a.reason}`:a.reason}),l(a.verdict)}else o.push({check:"sellability",result:y.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."}),l(y.UNKNOWN);return{chainId:e,token:n,verdict:i,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function it(t){let r={...fr(t)},n=new Set((t.venues||[]).map(o=>o.kind));t.venueKind==="uniswap-v3"&&n.has("quoter")&&n.has("router")?Object.assign(r,ot({chainId:t.chainId,wrappedNative:t.wrappedNative,stableQuoteAssets:t.stableQuoteAssets||[],resolveQuoteAsset:async(o,i)=>(await r.resolvePools(o,i)).quoteAsset||null})):t.venueKind==="uniswap-v2"&&n.has("router")&&Object.assign(r,tt({chainId:t.chainId,wrappedNative:t.wrappedNative}));let s={};for(let[o,i]of Object.entries(r))s[o]=i.bind(r);return{key:t.key,chainId:t.chainId,name:t.name,rpcEnv:t.rpcEnv,nativeCurrency:t.nativeCurrency,explorer:t.explorer,venues:t.venues||[],capabilities:s}}var hr=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function ct(){return hr.map(t=>Ze(it(t)))}ct();var[ut,...lt]=process.argv.slice(2),de=lt.includes("--json"),I=lt.filter(t=>t!=="--json");function J(t){t||D("missing <chain>");let e=xe(Number(t));if(e)return e;let r=ue().find(n=>n.key===String(t).toLowerCase());if(r)return r;D(`unknown chain "${t}". Known: ${ue().map(n=>`${n.key}(${n.chainId})`).join(", ")}`)}function D(t){console.error(`error: ${t}`),process.exit(1)}function Q(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
7
|
+
- `)}`);let s=t.capabilities||{},o=te.filter(l=>typeof s[l]=="function"),a={key:t.key,chainId:t.chainId,name:t.name,rpcEnv:[...t.rpcEnv],nativeCurrency:t.nativeCurrency?{...t.nativeCurrency}:null,wrappedNative:t.wrappedNative||null,explorer:t.explorer||null,venues:(t.venues||[]).map(l=>({...l})),warnings:n,capabilities(){return{chainId:t.chainId,key:t.key,supported:[...o],unsupported:te.filter(l=>!o.includes(l))}},supports(l){return o.includes(l)}};for(let l of te)o.includes(l)?a[l]=async(...c)=>s[l](...c,{scanner:a}):a[l]=async()=>{throw new Error(`${t.key} (chain ${t.chainId}) does not implement "${l}". Supported: ${o.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(a)}var re=new Map;function Ze(t){let e=ar(t);return re.set(e.chainId,e),e}function xe(t){return re.get(Number(t))||null}function ue(){return[...re.values()]}function et(){let t={};for(let e of re.values())t[e.chainId]={key:e.key,name:e.name,...e.capabilities(),venueCount:e.venues.length,failClosed:e.venues.length===0};return{generatedAt:new Date().toISOString(),chainCount:re.size,capabilities:[...te],chains:t}}var Te={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},B=t=>BigInt(t).toString(16).padStart(64,"0"),ne=t=>t.slice(2).toLowerCase().padStart(64,"0");function cr(t,e){return`0x${Te.getAmountsOut}`+B(t)+B(64)+B(e.length)+e.map(ne).join("")}function ur(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length<128)return null;let r=Number(BigInt(`0x${e.slice(64,128)}`));if(!Number.isFinite(r)||r<1||r>16)return null;let n=[];for(let s=0;s<r;s++){let o=128+s*64;if(e.length<o+64)return null;n.push(BigInt(`0x${e.slice(o,o+64)}`))}return n}function Ce(t,e="router"){return(t?.venues||[]).find(n=>n.kind===e)?.address??null}var Ie=100;function lr(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Ie)throw new Error(`slippageBps ${r} exceeds the ${Ie} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(r))/10000n}function tt(t){let{chainId:e,wrappedNative:r}=t;async function n(s,o,a,l){let c=await F(e,"eth_call",[{to:s,data:cr(o,a)},"latest"],l);return ur(c?.result??c)}return{async quote({tokenIn:s,tokenOut:o,amountIn:a,path:l},c={}){let d=Ce(c.scanner);if(!d)return{chainId:e,evidence:g.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let i=l||[s,o];if(i.some(p=>!/^0x[0-9a-fA-F]{40}$/.test(p||"")))throw new Error("quote requires valid 20-byte addresses");let u=await n(d,a,i,c);return u?{chainId:e,router:d,path:i,amountIn:String(a),amountOut:u[u.length-1].toString(),hops:i.length-1,evidence:g.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:e,router:d,path:i,evidence:g.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:s,amountIn:o,base:a},l={}){let c=Ce(l.scanner),d=a||r;if(d&&String(s).toLowerCase()===String(d).toLowerCase())return{chainId:e,token:s,verdict:y.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||!d)return{chainId:e,token:s,verdict:y.UNKNOWN,evidence:g.UNAVAILABLE,reason:c?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let i=await n(c,o,[d,s],l);if(!i)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let u=i[i.length-1];if(u===0n)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let p=await n(c,u,[s,d],l);if(!p)return{chainId:e,token:s,verdict:y.FAIL,evidence:g.LIVE,leg:"sell",bought:u.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=p[p.length-1],h=Number(f*10000n/BigInt(o)),b=y.PASS,w="round trip completes with expected fee/impact loss";return h<5e3?(b=y.FAIL,w=`round trip returns only ${(h/100).toFixed(2)}% -- punitive tax or no real liquidity`):h<9e3&&(b=y.CAUTION,w=`round trip returns ${(h/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,token:s,base:d,router:c,verdict:b,reason:w,amountIn:String(o),bought:u.toString(),returned:f.toString(),retentionBps:h,evidence:g.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:o,amountIn:a,recipient:l,slippageBps:c=50,deadlineSeconds:d=900,path:i},u={}){let p=u.scanner,f=Ce(p);if(!f)throw new Error(`chain ${e} has no verified router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!/^0x[0-9a-fA-F]{40}$/.test(l||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let h=i||[s,o],b=await this.quote({tokenIn:s,tokenOut:o,amountIn:a,path:h},u);if(b.evidence!==g.LIVE)throw new Error(`cannot prepare without a live quote (${b.evidence}: ${b.reason??"no reason given"})`);let w=lr(b.amountOut,c);if(w<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let C=BigInt(Math.floor(Date.now()/1e3)+Number(d)),R=r&&h[0].toLowerCase()===r.toLowerCase()&&u.useNative,S=R?`0x${Te.swapExactETHForTokens}`+B(w)+B(128)+ne(l)+B(C)+B(h.length)+h.map(ne).join(""):`0x${Te.swapExactTokensForTokens}`+B(a)+B(w)+B(160)+ne(l)+B(C)+B(h.length)+h.map(ne).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:e,tx:{to:f,data:S,value:R?`0x${BigInt(a).toString(16)}`:"0x0"},guard:{quotedOut:b.amountOut,minOut:w.toString(),slippageBps:c,maxSlippageBps:Ie,deadline:C.toString()},requires:R?[]:[{step:"approve",token:h[0],spender:f,amount:String(a)}],note:"UNSIGNED. Re-verify the guard against a fresh quote immediately before signing -- a quote-time minimum is not a minimum at broadcast time."}}}}var dr=[100,500,3e3,1e4],rt={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},G=t=>BigInt(t).toString(16).padStart(64,"0"),oe=t=>t.slice(2).toLowerCase().padStart(64,"0"),nt=/^0x[0-9a-fA-F]{40}$/,Ne=100;function pr(t,e){let r=Number(e);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Ne)throw new Error(`slippageBps ${r} exceeds the ${Ne} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(t)*BigInt(1e4-Math.floor(r))/10000n}function ke(t,e){return(t?.venues||[]).find(r=>r.kind===e)?.address??null}function ot(t){let{chainId:e,wrappedNative:r}=t;async function n({quoter:o,tokenIn:a,tokenOut:l,amountIn:c,fee:d},i){let u=`0x${rt.quoteExactInputSingle}`+oe(a)+oe(l)+G(c)+G(d)+G(0),p=await F(e,"eth_call",[{to:o,data:u},"latest"],i).catch(()=>null),f=p?.result??p;if(!f||f==="0x"||f.length<66)return null;let h=BigInt(`0x${f.slice(2,66)}`);return h>0n?h:null}async function s({quoter:o,tokenIn:a,tokenOut:l,amountIn:c},d){let i=await Promise.all(dr.map(async p=>{let f=await n({quoter:o,tokenIn:a,tokenOut:l,amountIn:c,fee:p},d);return{fee:p,amountOut:f?f.toString():null,out:f}})),u=null;for(let p of i)p.out&&(!u||p.out>u.amountOut)&&(u={fee:p.fee,amountOut:p.out});return{best:u,tried:i.map(({fee:p,amountOut:f})=>({fee:p,amountOut:f}))}}return{async quote({tokenIn:o,tokenOut:a,amountIn:l},c={}){let d=ke(c.scanner,"quoter");if(!d)return{chainId:e,evidence:g.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let p of[o,a])if(!nt.test(p||""))throw new Error("quote requires valid 20-byte addresses");let{best:i,tried:u}=await s({quoter:d,tokenIn:o,tokenOut:a,amountIn:l},c);return i?{chainId:e,venue:"uniswap-v3",quoter:d,tokenIn:o,tokenOut:a,amountIn:String(l),amountOut:i.amountOut.toString(),fee:i.fee,useNative:!!r&&String(o).toLowerCase()===String(r).toLowerCase(),triedFeeTiers:u,evidence:g.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:e,quoter:d,tokenIn:o,tokenOut:a,triedFeeTiers:u,evidence:g.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:o,amountIn:a,base:l},c={}){let d=ke(c.scanner,"quoter"),i=(t.stableQuoteAssets||[]).map(O=>String(O).toLowerCase()),u=null;!l&&typeof t.resolveQuoteAsset=="function"&&(u=await t.resolveQuoteAsset(o,c).catch(()=>null));let p=String(o).toLowerCase(),f=String(r||"").toLowerCase();if(f&&p===f)return{chainId:e,token:o,verdict:y.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."};let h=l||u||(i[0]&&p!==i[0]?i[0]:null)||r;if(h&&p===String(h).toLowerCase())return{chainId:e,token:o,verdict:y.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(!d||!h)return{chainId:e,token:o,verdict:y.UNKNOWN,evidence:g.UNAVAILABLE,reason:d?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let b=await s({quoter:d,tokenIn:h,tokenOut:o,amountIn:a},c);if(!b.best){let O=i.find(A=>A&&A!==String(h).toLowerCase()&&A!==String(o).toLowerCase());if(O){let A=await s({quoter:d,tokenIn:O,tokenOut:o,amountIn:a},c);if(A.best){let v=await s({quoter:d,tokenIn:o,tokenOut:O,amountIn:A.best.amountOut},c);if(v.best){let x=v.best.amountOut,E=Number(x*10000n/BigInt(a)),U=y.PASS,m="round trip vs dollar book completes with expected fee/impact loss";return E<5e3?(U=y.FAIL,m=`round trip vs dollar book returns only ${(E/100).toFixed(2)}% -- punitive tax or no real liquidity`):E<9e3&&(U=y.CAUTION,m=`round trip vs dollar book returns ${(E/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:U,reason:m,amountIn:String(a),bought:A.best.amountOut.toString(),returned:x.toString(),retentionBps:E,buyFee:A.best.fee,sellFee:v.best.fee,evidence:g.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:e,token:o,verdict:y.FAIL,evidence:g.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let w=await s({quoter:d,tokenIn:o,tokenOut:h,amountIn:b.best.amountOut},c);if(!w.best){let O=i.find(A=>A&&A!==String(h).toLowerCase()&&A!==String(o).toLowerCase());if(O){let A=await s({quoter:d,tokenIn:O,tokenOut:o,amountIn:a},c),v=A.best?await s({quoter:d,tokenIn:o,tokenOut:O,amountIn:A.best.amountOut},c):{best:null};if(A.best&&v.best){let x=v.best.amountOut,E=Number(x*10000n/BigInt(a)),U=y.PASS,m="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return E<5e3?(U=y.FAIL,m=`dollar-book round trip returns only ${(E/100).toFixed(2)}%`):E<9e3&&(U=y.CAUTION,m=`dollar-book round trip returns ${(E/100).toFixed(2)}%`),{chainId:e,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:U,reason:m,amountIn:String(a),bought:A.best.amountOut.toString(),returned:x.toString(),retentionBps:E,buyFee:A.best.fee,sellFee:v.best.fee,evidence:g.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:e,token:o,verdict:y.FAIL,evidence:g.LIVE,leg:"sell",bought:b.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let C=w.best.amountOut,R=Number(C*10000n/BigInt(a)),S=y.PASS,L="round trip completes with expected fee/impact loss";return R<5e3?(S=y.FAIL,L=`round trip returns only ${(R/100).toFixed(2)}% -- punitive tax or no real liquidity`):R<9e3&&(S=y.CAUTION,L=`round trip returns ${(R/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:e,venue:"uniswap-v3",token:o,base:h,verdict:S,reason:L,amountIn:String(a),bought:b.best.amountOut.toString(),returned:C.toString(),retentionBps:R,buyFee:b.best.fee,sellFee:w.best.fee,evidence:g.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:o,tokenOut:a,amountIn:l,recipient:c,slippageBps:d=50,fee:i},u={}){let p=ke(u.scanner,"router");if(!p)throw new Error(`chain ${e} has no verified V3 router; preparing a swap stays fail-closed. Add a venue with recorded provenance first (see docs/adding-a-chain.md).`);if(!nt.test(c||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:o,tokenOut:a,amountIn:l},u);if(f.evidence!==g.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let h=i??f.fee,b=pr(f.amountOut,d);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let w=!!(u.useNative||f.useNative)&&r&&String(o).toLowerCase()===String(r).toLowerCase(),C=`0x${rt.exactInputSingle}`+oe(o)+oe(a)+G(h)+oe(c)+G(l)+G(b)+G(0);return{unsigned:!0,signedBy:"user-wallet",chainId:e,venue:"uniswap-v3",tx:{to:p,data:C,value:w?String(l):"0x0"},guard:{quotedOut:f.amountOut,minOut:b.toString(),slippageBps:d,maxSlippageBps:Ne,fee:h},requires:w?[]:[{step:"approve",token:o,spender:p,amount:String(l)}],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 le={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function st(t){if(!t||t==="0x")return null;try{return BigInt(t)}catch{return null}}function it(t){if(!t||t==="0x")return null;let e=t.slice(2);if(e.length>=128){let n=Number(BigInt(`0x${e.slice(64,128)}`));if(n>0&&n<=256&&e.length>=128+n*2){let s=e.slice(128,128+n*2),o=Buffer.from(s,"hex").toString("utf8").replace(/\0+$/,"");if(o)return o}}return Buffer.from(e.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function fr(t){let{chainId:e}=t;async function r(n,s,o){return F(e,"eth_call",[{to:n,data:s},"latest"],o)}return{async blockNumber(n={}){let s=await Ke(e,n);return{chainId:e,blockNumber:s?.blockNumber??s,evidence:g.LIVE}},async nativeBalance(n,s={}){let o=await Ge(e,n,s);return{chainId:e,address:n,wei:o?.wei??o?.balance??null,symbol:t.nativeCurrency?.symbol??null,decimals:t.nativeCurrency?.decimals??18,evidence:g.LIVE}},async tokenBalance({token:n,owner:s},o={}){let a=await Qe({chainId:e,token:n,owner:s},o);return{chainId:e,token:n,owner:s,raw:a?.balance??a,evidence:g.LIVE}},async resolveToken(n,s={}){if(!/^0x[0-9a-fA-F]{40}$/.test(n||""))return{chainId:e,token:n,evidence:g.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,a,l,c]=await Promise.all([r(n,le.decimals,s).catch(()=>null),r(n,le.symbol,s).catch(()=>null),r(n,le.name,s).catch(()=>null),r(n,le.totalSupply,s).catch(()=>null)]),d=st(o?.result??o),i=d!==null||a?.result||l?.result,u={chainId:e,address:n,decimals:d===null?null:Number(d),symbol:it(a?.result??a),name:it(l?.result??l),totalSupply:(st(c?.result??c)??null)?.toString()??null,evidence:i?g.LIVE:g.UNKNOWN};return i||(u.warning="no ERC-20 metadata returned -- may not be a token contract"),u},async resolvePools(n,s={}){let o=t.dexscreenerSlug;if(!o)return{chainId:e,token:n,pools:[],evidence:g.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let a=await Xe(n,s).catch(()=>null),c=(a?.pairs||a?.data?.pairs||[]).filter(i=>String(i.chainId).toLowerCase()===String(o).toLowerCase()).map(i=>({pair:i.pairAddress,dex:i.dexId,base:i.baseToken?.address,quote:i.quoteToken?.address,liquidityUsd:i.liquidity?.usd??null,priceUsd:i.priceUsd??null,volume24hUsd:i.volume?.h24??null,createdAt:i.pairCreatedAt??null})).sort((i,u)=>(u.liquidityUsd??0)-(i.liquidityUsd??0)),d=Ae(n,c,{stables:t.stableQuoteAssets||[],wrappedNative:t.wrappedNative});return{chainId:e,token:n,pools:d,topPool:d[0]||null,quoteAsset:Je(n,d),evidence:d.length?g.LIVE:g.UNKNOWN}},async scanBlocks({fromBlock:n,toBlock:s,address:o,topics:a,chunkSize:l=2e3}={},c={}){if(!Number.isInteger(n)||!Number.isInteger(s))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(s<n)throw new Error("toBlock must be >= fromBlock");let d=[],i=[];for(let p=n;p<=s;p+=l){let f=Math.min(p+l-1,s);i.push([p,f])}let u=await De(i,4,async([p,f])=>{let h={fromBlock:`0x${p.toString(16)}`,toBlock:`0x${f.toString(16)}`};o&&(h.address=o),a&&(h.topics=a);let b=await F(e,"eth_getLogs",[h],c).catch(w=>({error:String(w?.message||w)}));return{start:p,end:f,res:b}});for(let{start:p,end:f,res:h}of u){if(h?.error)return{chainId:e,fromBlock:n,toBlock:s,logs:d,complete:!1,failedAt:[p,f],error:h.error,evidence:g.UNKNOWN};for(let b of h?.result??h??[])d.push(b)}return{chainId:e,fromBlock:n,toBlock:s,logs:d,complete:!0,chunks:i.length,evidence:g.LIVE}},async scoreRisk(n,s={}){let o=[],a=y.PASS,l=i=>{let u={[y.PASS]:0,[y.CAUTION]:1,[y.UNKNOWN]:2,[y.FAIL]:3};u[i]>u[a]&&(a=i)},[c,d]=await Promise.all([this.resolveToken(n,s),this.resolvePools(n,s)]);if(c.evidence!==g.LIVE?(o.push({check:"erc20-metadata",result:y.UNKNOWN,detail:c.warning}),l(y.UNKNOWN)):o.push({check:"erc20-metadata",result:y.PASS,detail:`${c.symbol} / ${c.decimals}d`}),d.evidence===g.UNAVAILABLE)o.push({check:"liquidity",result:y.UNKNOWN,detail:d.reason}),l(y.UNKNOWN);else if(!d.pools.length)o.push({check:"liquidity",result:y.FAIL,detail:"no pool with liquidity found"}),l(y.FAIL);else{let i=d.pools[0],u=i.liquidityUsd??0;u<5e3?(o.push({check:"liquidity",result:y.CAUTION,detail:`top pool only $${u}`}),l(y.CAUTION)):o.push({check:"liquidity",result:y.PASS,detail:`$${u} on ${i.dex}`}),i.createdAt&&Date.now()-i.createdAt<24*3600*1e3&&(o.push({check:"age",result:y.CAUTION,detail:"pool under 24h old"}),l(y.CAUTION))}if(typeof this.sellSimulation=="function"){let i=await this.sellSimulation({token:n,amountIn:(10n**16n).toString()},s).catch(u=>({verdict:y.UNKNOWN,reason:String(u?.message||u)}));o.push({check:"sellability",result:i.verdict,detail:i.retentionBps!=null?`round trip returns ${(i.retentionBps/100).toFixed(2)}% -- ${i.reason}`:i.reason}),l(i.verdict)}else o.push({check:"sellability",result:y.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."}),l(y.UNKNOWN);return{chainId:e,token:n,verdict:a,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function at(t){let r={...fr(t)},n=new Set((t.venues||[]).map(o=>o.kind));t.venueKind==="uniswap-v3"&&n.has("quoter")&&n.has("router")?Object.assign(r,ot({chainId:t.chainId,wrappedNative:t.wrappedNative,stableQuoteAssets:t.stableQuoteAssets||[],resolveQuoteAsset:async(o,a)=>(await r.resolvePools(o,a)).quoteAsset||null})):t.venueKind==="uniswap-v2"&&n.has("router")&&Object.assign(r,tt({chainId:t.chainId,wrappedNative:t.wrappedNative}));let s={};for(let[o,a]of Object.entries(r))s[o]=a.bind(r);return{key:t.key,chainId:t.chainId,name:t.name,rpcEnv:t.rpcEnv,nativeCurrency:t.nativeCurrency,explorer:t.explorer,venues:t.venues||[],capabilities:s}}var hr=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function ct(){return hr.map(t=>Ze(at(t)))}ct();var[ut,...lt]=process.argv.slice(2),de=lt.includes("--json"),I=lt.filter(t=>t!=="--json");function J(t){t||D("missing <chain>");let e=xe(Number(t));if(e)return e;let r=ue().find(n=>n.key===String(t).toLowerCase());if(r)return r;D(`unknown chain "${t}". Known: ${ue().map(n=>`${n.key}(${n.chainId})`).join(", ")}`)}function D(t){console.error(`error: ${t}`),process.exit(1)}function Q(t){process.stdout.write(`${JSON.stringify(t,null,2)}
|
|
8
8
|
`)}function mr(t,e){let r=String(e?.message||e);return/rpc|fetch|ECONN|timeout|provider/i.test(r)?`${r}
|
|
9
9
|
|
|
10
10
|
This chain reads its RPC from: ${t.rpcEnv.join(" or ")}
|
package/dist/bin/oracle.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{realpathSync as N}from"node:fs";import{fileURLToPath as ie}from"node:url";import m from"node:fs";import h from"node:path";import{pathToFileURL as D}from"node:url";import d from"node:fs";import F from"node:os";import c from"node:path";import{fileURLToPath as H}from"node:url";var q=c.dirname(H(import.meta.url)),l=c.resolve(q,"../..");function u(){return process.env.ORACLE_FAKE_HOME||F.homedir()}function _(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function f(){return _()?process.env.ORACLE_CONFIG_DIR||c.join(u(),".config","oracle"):c.join(u(),".config","oracle")}function B(){return c.join(f(),"exec.env")}function k(){return c.join(f(),"desk.json")}function C(){return c.join(f(),"env")}function p({force:e=!1}={}){if(p._done&&!e)return p._result||null;p._done=!0;let r={},o=(n,t)=>{if(t==null)return;let
|
|
2
|
+
import{realpathSync as N}from"node:fs";import{fileURLToPath as ie}from"node:url";import m from"node:fs";import h from"node:path";import{pathToFileURL as D}from"node:url";import d from"node:fs";import F from"node:os";import c from"node:path";import{fileURLToPath as H}from"node:url";var q=c.dirname(H(import.meta.url)),l=c.resolve(q,"../..");function u(){return process.env.ORACLE_FAKE_HOME||F.homedir()}function _(){return process.env.ORACLE_PUBLIC_DESKTOP==="1"}function f(){return _()?process.env.ORACLE_CONFIG_DIR||c.join(u(),".config","oracle"):c.join(u(),".config","oracle")}function B(){return c.join(f(),"exec.env")}function k(){return c.join(f(),"desk.json")}function C(){return c.join(f(),"env")}function p({force:e=!1}={}){if(p._done&&!e)return p._result||null;p._done=!0;let r={},o=(n,t)=>{if(t==null)return;let a=String(t).trim();a&&(process.env[n]!=null&&String(process.env[n]).trim()!==""||(process.env[n]=a,r[n]=a))};try{let n=C();if(d.existsSync(n))for(let t of d.readFileSync(n,"utf8").split(/\r?\n/)){let a=t.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);if(!a||a[2].startsWith("#"))continue;let i=a[2];(i.startsWith('"')&&i.endsWith('"')||i.startsWith("'")&&i.endsWith("'"))&&(i=i.slice(1,-1)),o(a[1],i)}}catch{}try{let n=k();if(d.existsSync(n)){let t=JSON.parse(d.readFileSync(n,"utf8"));t&&typeof t=="object"&&(o("ORACLE_DESK_URL",t.deskUrl||t.dataUrl||t.url),o("ORACLE_DATA_URL",t.dataUrl||t.deskUrl||t.url),o("ORACLE_API_URL",t.apiUrl||t.dataUrl||t.deskUrl),o("ORACLE_PUBLIC_URL",t.publicUrl||t.deskUrl||t.dataUrl),o("ORACLE_EXEC_URL",t.execUrl),o("MAD_DESK_URL",t.deskUrl||t.dataUrl))}}catch{}let s=process.env.ORACLE_DESK_URL||process.env.ORACLE_DATA_URL||"";return s&&(o("ORACLE_DESK_URL",s),o("ORACLE_DATA_URL",s),o("ORACLE_API_URL",s),o("ORACLE_PUBLIC_URL",s),o("MAD_DESK_URL",s)),p._result=Object.keys(r).length?r:null,p._result}try{p()}catch{}function G(){return process.env.HERMES_HOME?c.resolve(process.env.HERMES_HOME):c.join(u(),".hermes")}function K(){return c.join(u(),".claude.json")}function V(e=process.cwd()){return c.join(e,".mcp.json")}function W(){return process.platform==="darwin"?c.join(u(),"Library","Application Support","Claude","claude_desktop_config.json"):c.join(u(),".config","Claude","claude_desktop_config.json")}function J(){return c.join(u(),".codex","config.toml")}function R(){return c.join(f(),"connectors")}function Y(){return c.join(R(),"chatgpt-openapi.json")}function z(){return c.join(f(),"active-chain.json")}function g(e){let r=[c.join(l,"bin",e),c.join(l,"dist","bin",e),c.join(l,"..","bin",e)];return r.find(o=>d.existsSync(o))||r[0]}function X(e){return d.mkdirSync(e,{recursive:!0}),e}var j={homeDir:u,isPublicDesktop:_,oracleConfigDir:f,oracleExecEnvPath:B,oracleDeskJsonPath:k,oracleEnvFilePath:C,loadDeskRouting:p,hermesRoot:G,activeChainPath:z,claudeCodeUserConfigPath:K,claudeCodeProjectMcpPath:V,claudeDesktopConfigPath:W,codexConfigPath:J,chatgptConnectorDir:R,chatgptOpenApiPath:Y,packageBin:g,ensureDir:X,PACKAGE_ROOT:l};import{execFile as Q}from"node:child_process";import{existsSync as xe,mkdirSync as ve,readFileSync as Z,realpathSync as Ee,writeFileSync as Ae}from"node:fs";import O from"node:path";import{promisify as ee}from"node:util";var ke=ee(Q);var Ce=1440*60*1e3;function L(e,r){let o=t=>String(t).replace(/^v/,"").split("-")[0].split(".").map(a=>Number.parseInt(a,10)||0),s=o(e),n=o(r);for(let t=0;t<Math.max(s.length,n.length);t+=1){let a=s[t]??0,i=n[t]??0;if(a>i)return 1;if(a<i)return-1}return 0}function te(e){let r=e?.stateDir||O.join(process.env.HOME||".",".oracle");return O.join(r,"update-check.json")}function b(e){try{return JSON.parse(Z(te(e),"utf8"))}catch{return null}}var re="\u25C7 ORACLE // self-custody multichain agent control plane",oe=`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
|
|
@@ -25,9 +25,10 @@ READ / RESEARCH
|
|
|
25
25
|
oracle resolve resolve a name or address
|
|
26
26
|
|
|
27
27
|
PREPARE
|
|
28
|
-
oracle route swap|bridge|prepare|prepare-bridge
|
|
28
|
+
oracle route swap|bridge|prepare|prepare-bridge|intent
|
|
29
29
|
oracle swap unsigned route and wallet-signable calldata
|
|
30
30
|
oracle prepare build an unsigned swap (alias of route prepare)
|
|
31
|
+
oracle x402 prepare|submit an x402 agent payment (never signs)
|
|
31
32
|
oracle session-vault unsigned optional vault prepare (no broadcast)
|
|
32
33
|
oracle strategy draft|validate|backtest|optimize|evidence \xB7 shadow \xB7 prepare
|
|
33
34
|
oracle shadow record|mark|summary prepare and NO_TRADE outcomes
|
|
@@ -62,16 +63,16 @@ BOUNDARY
|
|
|
62
63
|
MEV observe is read-only. Flash-loan execute needs ORACLE_MEV_EXECUTE_ENABLED=1
|
|
63
64
|
and literal --execute. There is no autonomous MEV loop.
|
|
64
65
|
Use oracle <command> --help for command details.
|
|
65
|
-
`;function T(){try{return JSON.parse(m.readFileSync(h.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function P(){let e=h.join(l,"src","cli","commands");return m.existsSync(e)?e:h.join(l,"dist","cli","commands")}var $=Object.freeze({clients:"harness"});function M(){let e=P();return m.existsSync(e)?new Map(m.readdirSync(e).filter(r=>r.endsWith(".mjs")).map(r=>[r.replace(/\.mjs$/,""),h.join(e,r)])):new Map}function ne(){return[...new Set([...M().keys(),...Object.keys($)])].sort()}async function y(e){let r=$[e]||e,o=M().get(r);if(!o)return null;try{let n=(await import(D(o).href)).default;if(!n||typeof n!="object"||typeof n.run!="function")return null;let t=n.name||r,
|
|
66
|
+
`;function T(){try{return JSON.parse(m.readFileSync(h.join(l,"package.json"),"utf8")).version||"0.0.0"}catch{return"0.0.0"}}function P(){let e=h.join(l,"src","cli","commands");return m.existsSync(e)?e:h.join(l,"dist","cli","commands")}var $=Object.freeze({clients:"harness"});function M(){let e=P();return m.existsSync(e)?new Map(m.readdirSync(e).filter(r=>r.endsWith(".mjs")).map(r=>[r.replace(/\.mjs$/,""),h.join(e,r)])):new Map}function ne(){return[...new Set([...M().keys(),...Object.keys($)])].sort()}async function y(e){let r=$[e]||e,o=M().get(r);if(!o)return null;try{let n=(await import(D(o).href)).default;if(!n||typeof n!="object"||typeof n.run!="function")return null;let t=n.name||r,a={...n,name:t,__file:o};return e!==r?{...a,name:e,aliasFor:t}:a}catch(s){return process.env.ORACLE_CLI_DEBUG&&console.error(`oracle: failed loading command ${r}: ${s.message}`),null}}async function x(){let e=P(),r=new Map;if(!m.existsSync(e))return r;let o=m.readdirSync(e).filter(s=>s.endsWith(".mjs")).sort();for(let s of o){let n=h.join(e,s);try{let a=(await import(D(n).href+`?t=${Date.now()}`)).default;if(!a||typeof a!="object"||typeof a.run!="function")continue;let i=a.name||s.replace(/\.mjs$/,""),A={...a,name:i,__file:n};r.set(i,A);for(let w of Array.isArray(a.aliases)?a.aliases:[])r.set(w,{...A,name:w,aliasFor:i})}catch(t){process.env.ORACLE_CLI_DEBUG&&console.error(`oracle: failed loading command ${s}: ${t.message}`)}}return r}function ae(e,r=b()){return!r?.latest||!e||L(r.latest,e)<=0?"":`
|
|
66
67
|
Update available: ${e} \u2192 ${r.latest}. Run 'oracle update'.
|
|
67
|
-
`}function
|
|
68
|
+
`}function v(e,r){let o=[];o.push(`${re} (v${e})`),o.push(""),o.push(oe.trimEnd());let s=[];for(let n of r.values()){if(["help","version"].includes(n.name))continue;!new Set(["init","doctor","chat","model","auth","chain","setup","data","data-mcp","scan","route","prepare","swap","farm","airdrop","follow","equities","strategy","shadow","mint","mev","snipe","public","mcp","plugins","harness","clients","upgrade","bootstrap","eval","fees","sign","signer","project","context","lifecycle","x402"]).has(n.name)&&n.summary&&s.push(` oracle ${n.name.padEnd(20)} ${n.summary}`)}return s.length&&(o.push(""),o.push("ADDITIONAL"),o.push(...s)),o.join(`
|
|
68
69
|
`)+`
|
|
69
|
-
`+
|
|
70
|
+
`+ae(e)}function S(e,r){let o=r?[...r.keys()].sort():ne(),s=o.length?o.join(", "):"(none loaded yet)";return`oracle: unknown command '${e}'. Known: ${s}
|
|
70
71
|
Try: oracle --help
|
|
71
|
-
`}function
|
|
72
|
-
`),
|
|
73
|
-
`),0):(process.stderr.write(S(
|
|
72
|
+
`}function E(e){return{argv:e,root:l,bin:g,paths:j}}async function I(e=[]){let r=T();if(e.includes("--version")||e.includes("-V"))return U();if(e[0]==="--help"||e[0]==="-h"){let t=await x();return process.stdout.write(v(r,t)),0}if(e.length===0){if(se(e)){let a=await y("chat");if(a)return a.run(E([]))}let t=await x();return process.stdout.write(v(r,t)),0}if(ce(e[0])){let t=await y("chat");if(t)return t.run(E(e))}let o=e[0],s=e.slice(1);if(o==="version")return U();if(o==="help"){if(s[0]){let a=await y(s[0]);return a?(process.stdout.write((a.usage||`oracle ${a.name}`)+`
|
|
73
|
+
`),a.summary&&process.stdout.write(a.summary+`
|
|
74
|
+
`),0):(process.stderr.write(S(s[0])),1)}let t=await x();return process.stdout.write(v(r,t)),0}let n=await y(o);if(n){if(s[0]==="--help"||s[0]==="-h")return process.stdout.write((n.usage||`oracle ${n.name}`)+`
|
|
74
75
|
`),n.summary&&process.stdout.write(n.summary+`
|
|
75
|
-
`),0;try{let t=await n.run(
|
|
76
|
+
`),0;try{let t=await n.run(E(s));return typeof t=="number"?t:0}catch(t){return process.stderr.write(`oracle ${o}: ${t?.message||t}
|
|
76
77
|
`),1}}return process.stderr.write(S(o)),1}async function U(){let e=T();return process.stdout.write(`oracle ${e}
|
|
77
|
-
`),0}function
|
|
78
|
+
`),0}function se(e=[],r={stdin:process.stdin,stdout:process.stdout}){return e.length!==0?!1:process.env.ORACLE_FORCE_CHAT==="1"?!0:r.stdin?.isTTY===!0&&r.stdout?.isTTY===!0}function ce(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 $e=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 le(){if(!process.argv[1])return!1;try{return N(ie(import.meta.url))===N(process.argv[1])}catch{return!1}}async function ue(e=process.argv.slice(2)){return I(e)}if(le()){let e=await ue();process.exit(typeof e=="number"?e:0)}export{$e as COMMANDS,ue as main};
|