@oracle-agent/oracle 0.35.49 → 0.35.50

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.
Files changed (81) hide show
  1. package/README.md +3 -2
  2. package/artifacts/specialist-packs/oracle-full-crypto.json +11 -0
  3. package/dist/agent-sessions.mjs +19 -19
  4. package/dist/artifacts/token-dashboard.mjs +1 -1
  5. package/dist/assets/profiles/near-agent/SOUL.md +46 -0
  6. package/dist/assets/profiles/near-agent/profile.json +30 -0
  7. package/dist/assets/profiles/oracle/SOUL.md +1 -0
  8. package/dist/assets/skills/oracle-desk-product/SKILL.md +1 -1
  9. package/dist/assets/skills/oracle-near/SKILL.md +66 -0
  10. package/dist/automation-plan.mjs +1 -1
  11. package/dist/bin/desk-server.mjs +33 -33
  12. package/dist/bin/oracle-data-mcp.mjs +16 -16
  13. package/dist/bin/oracle-gateway.mjs +3 -3
  14. package/dist/bin/oracle-launch-radar-shadow.mjs +3 -3
  15. package/dist/bin/oracle-mev-arb-shadow.mjs +4 -4
  16. package/dist/bin/oracle-mev-shadow.mjs +4 -4
  17. package/dist/bin/oracle-public-server.mjs +5 -5
  18. package/dist/bin/oracle-route.mjs +27 -27
  19. package/dist/bin/oracle-scan.mjs +3 -3
  20. package/dist/bin/oracle-telegram-mcp.mjs +1 -1
  21. package/dist/chains.mjs +1 -1
  22. package/dist/cli/commands/account.mjs +22 -22
  23. package/dist/cli/commands/agent-session.mjs +23 -23
  24. package/dist/cli/commands/auth.mjs +16 -15
  25. package/dist/cli/commands/chain.mjs +5 -5
  26. package/dist/cli/commands/chat.mjs +310 -228
  27. package/dist/cli/commands/data.mjs +37 -37
  28. package/dist/cli/commands/doctor.mjs +5 -5
  29. package/dist/cli/commands/eval.mjs +249 -167
  30. package/dist/cli/commands/farm.mjs +1 -1
  31. package/dist/cli/commands/follow.mjs +4 -4
  32. package/dist/cli/commands/harness.mjs +6 -6
  33. package/dist/cli/commands/mint.mjs +11 -11
  34. package/dist/cli/commands/model.mjs +313 -231
  35. package/dist/cli/commands/project.mjs +8 -7
  36. package/dist/cli/commands/quickstart.mjs +2 -2
  37. package/dist/cli/commands/receipt.mjs +2 -2
  38. package/dist/cli/commands/resolve.mjs +4 -4
  39. package/dist/cli/commands/session-vault.mjs +4 -4
  40. package/dist/cli/commands/setup.mjs +53 -52
  41. package/dist/cli/commands/snipe.mjs +13 -13
  42. package/dist/cli/commands/strategy.mjs +5 -5
  43. package/dist/cli/commands/swap.mjs +11 -11
  44. package/dist/cli/commands/telegram.mjs +7 -7
  45. package/dist/cli/commands/venues.mjs +1 -1
  46. package/dist/cli/project-access.mjs +4 -3
  47. package/dist/data/desk-data.mjs +31 -31
  48. package/dist/data/holder-table.mjs +2 -2
  49. package/dist/data/market-tape.mjs +1 -1
  50. package/dist/data/names.mjs +3 -3
  51. package/dist/data/providers/farming.mjs +2 -2
  52. package/dist/data/providers/lp-destination-discovery.mjs +4 -4
  53. package/dist/index.mjs +49 -49
  54. package/dist/launch-radar/index.mjs +5 -5
  55. package/dist/lp/index.mjs +4 -4
  56. package/dist/nft/universal-mint-router.mjs +4 -4
  57. package/dist/notifications/index.mjs +1 -1
  58. package/dist/router/index.mjs +3 -3
  59. package/dist/router/prepare-bridge.mjs +2 -2
  60. package/dist/router/prepare-route.mjs +3 -3
  61. package/dist/scanner/index.mjs +3 -3
  62. package/dist/strategy/index.mjs +4 -4
  63. package/dist/task.mjs +1 -1
  64. package/dist/teams/index.mjs +6 -6
  65. package/dist/telegram/chart-card.mjs +5 -5
  66. package/dist/telegram/market-commands.mjs +1 -1
  67. package/dist/tui/standalone-client.mjs +179 -97
  68. package/package.json +2 -2
  69. package/public/oracle-splash/docs/browser-and-web/index.html +2 -2
  70. package/public/oracle-splash/docs/connectors/index.html +2 -2
  71. package/public/oracle-splash/docs/getting-started/index.html +2 -2
  72. package/public/oracle-splash/docs/index.html +3 -3
  73. package/public/oracle-splash/docs/reference/index.html +2 -2
  74. package/public/oracle-splash/docs/security/index.html +2 -2
  75. package/public/oracle-splash/docs/using-oracle/index.html +2 -2
  76. package/public/oracle-splash/download/index.html +3 -3
  77. package/public/oracle-splash/downloads/index.html +1 -1
  78. package/public/oracle-splash/eval/index.html +19 -19
  79. package/public/oracle-splash/eval/releases/oracle-0.35.49.json +852 -0
  80. package/public/oracle-splash/index.html +9 -9
  81. package/server.json +2 -2
@@ -1,11 +1,11 @@
1
- var Kt=/\b0x[a-fA-F0-9]{40}\b/g,Xt=/\b[1-9A-HJ-NP-Za-km-z]{32,44}\b/g,Yt=new Set(["0x0000000000000000000000000000000000000000","0x000000000000000000000000000000000000dead","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].map(e=>e.toLowerCase())),Zt=new Set(["So11111111111111111111111111111111111111112","EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","11111111111111111111111111111111"]);function Qt(e){return!(Zt.has(e)||/^0x/i.test(e)||!/\d/.test(e)&&e===e.toLowerCase()||!/\d/.test(e)&&e===e.toUpperCase())}function Ve(e,{extras:t=[]}={}){let r=[e,...t].map(o=>String(o||"")).join(`
2
- `),s=[...new Set((r.match(Kt)||[]).map(o=>o.toLowerCase()))].filter(o=>!Yt.has(o)),n=[...new Set(r.match(Xt)||[])].filter(Qt);return{evm:s,solana:n,all:[...s.map(o=>({chainFamily:"evm",address:o})),...n.map(o=>({chainFamily:"solana",address:o}))]}}function ze(e){let t=String(e||"").trim();if(!t)return[];let r=[],s=n=>{if(!n||typeof n!="object")return;let o=String(n.id||n.id_str||n.tweetId||n.statusId||""),a=n.text||n.full_text||n.fullText||n.body||n.note_tweet?.text||"",c=[],i=n.entities?.urls||n.entities?.Urls||[];for(let l of i)l?.expanded_url&&c.push(l.expanded_url),l?.url&&c.push(l.url);(o||a)&&r.push({id:o,text:String(a),urls:c,raw:n})};try{let n=JSON.parse(t),o=Array.isArray(n)?n:n.data?Array.isArray(n.data)?n.data:[n.data]:n.tweets||n.statuses||n.results||[];Array.isArray(o)?o.forEach(s):s(n)}catch{for(let n of t.split(`
3
- `)){let o=n.trim();if(o.startsWith("{"))try{s(JSON.parse(o))}catch{}}r.length||r.push({id:"",text:t,urls:[]})}return r}import{spawnSync as dr}from"node:child_process";import We from"node:fs";import ge from"node:path";var Jt=(process.env.ORACLE_REDACT_SECRETS??"true").toLowerCase(),er=["1","true","yes","on"].includes(Jt),tr=[/sk-[A-Za-z0-9_-]{10,}/g,/sk_live_[A-Za-z0-9]{10,}/g,/sk_test_[A-Za-z0-9]{10,}/g,/ghp_[A-Za-z0-9]{10,}/g,/github_pat_[A-Za-z0-9_]{10,}/g,/gho_[A-Za-z0-9]{10,}/g,/ghs_[A-Za-z0-9]{10,}/g,/xox[baprs]-[A-Za-z0-9-]{10,}/g,/AIza[A-Za-z0-9_-]{30,}/g,/AKIA[A-Z0-9]{16}/g,/pplx-[A-Za-z0-9]{10,}/g,/hf_[A-Za-z0-9]{10,}/g,/xai-[A-Za-z0-9]{30,}/g,/gsk_[A-Za-z0-9]{10,}/g,/npm_[A-Za-z0-9]{10,}/g,/tvly-[A-Za-z0-9]{10,}/g,/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi],rr=/\b0x[a-fA-F0-9]{64}\b/g,nr=/-----BEGIN (?:RSA |EC |OPENSSH |ENCRYPTED )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/g,or=/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,sr=/\b([A-Z][A-Z0-9_]{0,40}(?:API_?KEY|TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE_?KEY|MNEMONIC|SEED|AUTH)[A-Z0-9_]{0,20})\s*=\s*(['"]?)(\S+)\2/g,ir=/^(?:export\s+)?((?:api[_-]?key|token|secret|password|private[_-]?key|mnemonic|seed[_-]?phrase|authorization))\s*[:=]\s*(['"]?)([^\s&]+)\2/gim,ar=/("(?:api[_-]?key|apiKey|access[_-]?token|refresh[_-]?token|client[_-]?secret|private[_-]?key|privateKey|secret|password|authorization|bearer|mnemonic|seedPhrase)"\s*:\s*")([^"]{6,})(")/gi,cr=new Set(["access_token","refresh_token","id_token","token","api_key","apikey","client_secret","password","auth","jwt","session","secret","key","code","signature","x-amz-signature","private_key","authorization"]),eo=new Set([...cr].map(e=>e.replace(/[^a-z0-9]/gi,"").toLowerCase()));function ur(e){let t=String(e??"");return t.length<18?"[REDACTED]":`${t.slice(0,6)}\u2026${t.slice(-4)}`}function lr(e){return`\xABredacted:${String(e??"").slice(0,4)}\u2026\xBB`}function ne(e,t={}){if(e==null)return e;let r=typeof e=="string"?e:String(e);if(!r||!(t.force||er))return r;let s=t.fileRead?lr:ur;r=r.replace(nr,"[REDACTED_PRIVATE_KEY]"),r=r.replace(rr,"[REDACTED_EVM_KEY]"),r=r.replace(or,n=>s(n));for(let n of tr)n.lastIndex=0,r=r.replace(n,o=>s(o));return r=r.replace(sr,(n,o,a,c)=>/^(?:os\.(?:getenv|environ)|process\.env|\$ENV\{)/.test(c)?`${o}=${a||""}${c}${a||""}`:`${o}=${a||""}${s(c)}${a||""}`),r=r.replace(ir,(n,o,a,c)=>n.replace(c,s(c))),r=r.replace(ar,(n,o,a,c)=>`${o}${s(a)}${c}`),r}var Ge=45e3,pr=4e4,fr=Object.freeze(["whoami","user","read","search","timeline","mentions","bookmarks","likes","following","followers","dms","auth"]),hr=Object.freeze(["post","reply","quote","delete","like","unlike","repost","unrepost","bookmark","unbookmark","follow","unfollow","block","unblock","mute","unmute","dm"]),Ke=Object.freeze(["--verbose","-v","--trace","-t","--bearer-token","--consumer-key","--consumer-secret","--access-token","--token-secret","--client-id","--client-secret"]);function mr(e=process.env){let t=String(e.ORACLE_XURL_ENABLED||"").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function Xe(e=process.env){let t=String(e.ORACLE_XURL_ALLOW_WRITE||"").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function br(e=process.env){let t=String(e.ORACLE_XURL_BIN||"").trim();if(t)return ge.isAbsolute(t)?We.existsSync(t)?{ok:!0,bin:t}:{ok:!1,error:`ORACLE_XURL_BIN not found: ${t}`}:{ok:!1,error:"ORACLE_XURL_BIN must be absolute"};let r=String(e.PATH||process.env.PATH||"");for(let s of r.split(ge.delimiter)){if(!s)continue;let n=ge.join(s,"xurl");try{if(We.existsSync(n))return{ok:!0,bin:n}}catch{}}return{ok:!1,error:"xurl binary not found on PATH. Install: curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | bash"}}function gr(e=process.env){let t=e.HOME||process.env.HOME||"";return{PATH:e.PATH||process.env.PATH||"/usr/bin:/bin",HOME:t,USER:e.USER||process.env.USER||"",LANG:e.LANG||process.env.LANG||"C.UTF-8",LC_ALL:e.LC_ALL||process.env.LC_ALL||"C.UTF-8",XDG_CONFIG_HOME:e.XDG_CONFIG_HOME||process.env.XDG_CONFIG_HOME||"",XDG_DATA_HOME:e.XDG_DATA_HOME||process.env.XDG_DATA_HOME||"",NO_COLOR:"1"}}function wr(e){for(let t of e){let r=String(t);if(Ke.includes(r))return r;if(Ke.some(s=>s.startsWith("--")&&r.startsWith(`${s}=`)))return r.split("=")[0]}return null}function yr(e={},t=process.env){let r;if(Array.isArray(e.argv))r=e.argv.map(i=>String(i));else{let i=String(e.command||e.cmd||"").trim();if(!i)return{ok:!1,error:"command is required (e.g. whoami, search, read, post)"};let l=Array.isArray(e.args)?e.args.map(u=>String(u)):typeof e.query=="string"?[e.query]:typeof e.text=="string"?[e.text]:typeof e.id=="string"?[e.id]:typeof e.handle=="string"?[e.handle]:[];i==="search"&&e.limit!=null&&l.push("-n",String(Math.min(50,Math.max(1,Number(e.limit)||10)))),(i==="timeline"||i==="mentions")&&e.limit!=null&&l.push("-n",String(Math.min(50,Math.max(1,Number(e.limit)||10)))),r=[i,...l]}if(r.length===0)return{ok:!1,error:"empty argv"};if(r.length>24)return{ok:!1,error:"too many arguments"};for(let i of r)if(String(i).length>4e3)return{ok:!1,error:"argument too long"};let s=wr(r);if(s)return{ok:!1,error:`forbidden flag: ${s}`};if(r.some(i=>String(i).includes("\0")))return{ok:!1,error:"nul byte in argv"};let n=String(r[0]||"").replace(/^\//,"");if(n.startsWith("2/")||r[0].startsWith("/2/")||r[0].startsWith("https://api.x.com/")){if(!Xe(t)&&r.some(i=>/^-X$/.test(i)||/^--request$/.test(i))){let i=r.findIndex(u=>u==="-X"||u==="--request"),l=String(r[i+1]||"GET").toUpperCase();if(l!=="GET"&&l!=="HEAD")return{ok:!1,error:"raw non-GET requires ORACLE_XURL_ALLOW_WRITE=true"}}}else if(n==="auth"){if(String(r[1]||"")!=="status")return{ok:!1,error:"only `auth status` is allowed (no apps add / oauth2 from the agent)"}}else if(!fr.includes(n))if(hr.includes(n)){if(!Xe(t))return{ok:!1,error:`write command '${n}' requires ORACLE_XURL_ALLOW_WRITE=true`}}else return n==="media"?{ok:!1,error:"media upload is disabled in the agent tool (run xurl media outside the agent)"}:{ok:!1,error:`command not allowlisted: ${n}`};let o=[...r],a=String(t.ORACLE_XURL_APP||"").trim(),c=String(t.ORACLE_XURL_USER||"").trim();if(a&&!o.includes("--app")&&o.unshift("--app",a),c&&!o.includes("--username")&&!o.includes("-u")){let i=0;o[0]==="--app"&&(i=2),i<o.length&&o.splice(i+1,0,"-u",c)}return{ok:!0,argv:o,command:n}}async function Ye(e,t={},r={}){if(e!=="xurl")return{ok:!1,error:`unknown tool: ${e}`};let s=r.env||process.env;if(!mr(s))return{ok:!1,error:"xurl is disabled. Set ORACLE_XURL_ENABLED=true after `xurl auth status` succeeds. Writes stay off until ORACLE_XURL_ALLOW_WRITE=true."};let n=yr(t,s);if(!n.ok)return n;let o=br(s);if(!o.ok)return o;let c=(r.spawnFn||dr)(o.bin,n.argv,{encoding:"utf8",timeout:r.timeoutMs||Ge,maxBuffer:1024*1024,env:gr(s)});if(c.error){let d=c.error.code==="ETIMEDOUT"?`xurl timed out after ${r.timeoutMs||Ge}ms`:String(c.error.message||c.error);return{ok:!1,error:ne(d,{force:!0})}}let i=ne(String(c.stdout||"").slice(0,pr),{force:!0}),l=ne(String(c.stderr||"").slice(0,2e3),{force:!0}),u=typeof c.status=="number"?c.status:1;return{ok:u===0,status:u,command:n.command,argv:n.argv.map(d=>/=/.test(d)&&/token|secret|key|bearer/i.test(d)?"[redacted-arg]":d),stdout:i,stderr:l||void 0}}var io=Object.freeze([{type:"function",function:{name:"xurl",description:"Call the official xurl CLI against the X API with an allowlisted command. Reads (whoami/user/read/search/timeline/mentions/...) work when ORACLE_XURL_ENABLED=true. Writes (post/reply/like/follow/dm/...) also need ORACLE_XURL_ALLOW_WRITE=true. Never pass secrets or --verbose. Auth is whatever the operator configured in ~/.xurl.",parameters:{type:"object",properties:{command:{type:"string",description:"xurl subcommand: whoami, user, read, search, timeline, mentions, post, reply, ..."},args:{type:"array",items:{type:"string"},description:"Positional args after the command (query, id, handle, text)."},query:{type:"string",description:"Convenience for search query."},text:{type:"string",description:"Convenience for post/reply/dm text."},id:{type:"string",description:"Convenience for read/like/reply target id or URL."},handle:{type:"string",description:"Convenience for user/follow/dm handle."},limit:{type:"integer",description:"Result limit for search/timeline/mentions (1-50)."},argv:{type:"array",items:{type:"string"},description:"Raw argv alternative (still allowlisted + flag-filtered)."}},additionalProperties:!1}}}]);import{createHash as _r}from"node:crypto";import{types as M}from"node:util";import{AsyncLocalStorage as vr}from"node:async_hooks";var Er=new vr,Sr=["http","retry","shared"],Ar=512;function oe(e){let t=Er.getStore();if(!t||t.closed||!Sr.includes(e))return null;if(t.spans.length>=Ar)return t.droppedSpans++,null;let r={stage:e,startMs:t.now()-t.start,durationMs:null,outcome:"pending",status:null};return t.spans.push(r),(s,n=null)=>{t.closed||r.durationMs!==null||(r.durationMs=Math.max(0,t.now()-t.start-r.startMs),r.outcome=s==="succeeded"?"succeeded":"failed",r.status=Number.isInteger(n)&&n>=100&&n<=599?n:null)}}import V from"node:net";import xr from"node:dns";var Cr=new Set(["localhost","metadata.google.internal","metadata.goog"]);function se(e){let t=String(e).toLowerCase().split("%")[0];if((t.match(/::/g)||[]).length>1)return null;let r=u=>{if(!u)return[];let d=u.split(":"),h=d.at(-1);if(h?.includes(".")){let f=h.split(".").map(Number);if(f.length!==4||f.some(p=>!Number.isInteger(p)||p<0||p>255))return null;d.splice(d.length-1,1,(f[0]<<8|f[1]).toString(16),(f[2]<<8|f[3]).toString(16))}return d.some(f=>!/^[0-9a-f]{1,4}$/.test(f))?null:d.map(f=>Number.parseInt(f,16))},[s,n]=t.split("::"),o=r(s),a=r(n);if(!o||!a)return null;let c=t.includes("::"),i=8-o.length-a.length;if(!c&&i!==0||c&&i<1)return null;let l=[...o,...Array(Math.max(0,i)).fill(0),...a];return l.length!==8?null:Uint8Array.from(l.flatMap(u=>[u>>8,u&255]))}function we(e,t,r){let s=Math.floor(r/8),n=r%8;for(let a=0;a<s;a+=1)if(e[a]!==t[a])return!1;if(!n)return!0;let o=255<<8-n;return(e[s]&o)===(t[s]&o)}function ye(e){if(V.isIPv4(e)){let t=e.split(".").map(Number);return!(t[0]===0||t[0]===10||t[0]===127||t[0]>=224||t[0]===100&&t[1]>=64&&t[1]<=127||t[0]===169&&t[1]===254||t[0]===172&&t[1]>=16&&t[1]<=31||t[0]===192&&(t[1]===0||t[1]===2||t[1]===168)||t[0]===192&&t[1]===88&&t[2]===99||t[0]===198&&(t[1]===18||t[1]===19||t[1]===51)||t[0]===203&&t[1]===0&&t[2]===113)}if(V.isIPv6(e)){let t=se(e);if(!t)return!1;let r=se("::ffff:0:0");return we(t,r,96)?ye([...t.slice(12)].join(".")):we(t,se("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([n,o])=>we(t,se(n),o)):!1}return!1}function kr(e){let t;try{t=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,error:`refused protocol ${t.protocol} (only http/https)`};let r=t.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(Cr.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let s=V.isIP(r);return s!==0&&!ye(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:t,host:r,isLiteralIp:s!==0}}async function ve(e,{lookupFn:t=xr.promises.lookup}={}){let r=kr(e);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:V.isIPv6(r.host)?6:4}]};let s;if(process.env.ORACLE_HOSTED_EGRESS_PROXY)return{ok:!0,url:r.url,addresses:[]};try{s=await t(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(s)||s.length===0||s.some(n=>!ye(n.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:s}}function Tr(e=process.env){let t=e.ORACLE_HOSTED_EGRESS_PROXY||"";if(!t)return null;let r;try{r=new URL(t)}catch{throw new Error("egress-guard: ORACLE_HOSTED_EGRESS_PROXY is not a URL")}if(r.protocol!=="http:"||!["127.0.0.1","::1","localhost","[::1]"].includes(r.hostname)||!r.port||r.username||r.password)throw new Error("egress-guard: egress proxy must be an exact loopback http origin");let s=e.ORACLE_HOSTED_EGRESS_TOKEN||"";if(!/^[A-Za-z0-9_-]{43}$/.test(s))throw new Error("egress-guard: egress proxy token is missing");return{uri:r.origin,token:s}}async function Ee({requireUndici:e=!1,importUndici:t=()=>import("undici")}={}){let r,s,n;try{n=await t(),r=n.Agent,s=n.fetch}catch(f){if(e)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${f?.message||f}`);return null}if(typeof r!="function"||typeof s!="function"){if(e)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 o=f=>String(f).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),a=new Map,c=f=>(Array.isArray(f)?f:[f]).map(p=>typeof p=="string"?{address:p}:p).filter(p=>p&&p.address).map(p=>({address:p.address,family:p.family||(V.isIPv6(p.address)?6:4)})),i=(f,p,m)=>{a.set(o(f),c(typeof p=="string"?[{address:p,family:m}]:p))},l=f=>{let p=o(f);if(V.isIP(p))return[{address:p,family:V.isIPv6(p)?6:4}];let m=a.get(p);if(!m||!m.length)throw new Error(`refused: unpinned host ${f} during pinned fetch`);return m},u=Tr(),d=u&&typeof n.ProxyAgent=="function"?new n.ProxyAgent({uri:u.uri,token:`Bearer ${u.token}`,connectTimeout:1e4}):new r({connect:{lookup(f,p,m){let b;try{b=l(f)}catch(y){return m(y)}return p?.all?m(null,b):m(null,b[0].address,b[0].family)}}}),h=Ir((f,p={})=>s(f,{...p,dispatcher:d}),i);return{dispatcher:d,fetch:h,pin:i,resolve:l,async close(){try{await d.destroy()}catch{}}}}var Se=Symbol.for("oracle.egressGuard.pinCapableFetch");function Ir(e,t){if(typeof e!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof t!="function")throw new Error("markPinCapableFetch: pin must be a function");return e[Se]=Object.freeze({pin:t}),e}function Ae(e){return typeof e=="function"&&typeof e[Se]?.pin=="function"}function Ze(e,t,r){if(!Ae(e))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");e[Se].pin(t,r)}var Or=new Set([408,425,429,500,502,503,504]),Qe=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),Nr=2,Je=4e3,Rr=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Lr=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,Pr=AbortSignal.prototype.throwIfAborted,Ur=EventTarget.prototype.addEventListener,et=EventTarget.prototype.removeEventListener,tt=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,Z=e=>e?Rr.call(e):!1,qr=e=>e?Lr.call(e):void 0,Br=new Set([301,302,303,307,308]),ae=3,wo=64*1024,D=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function N(e){return H(`HTTP JSON body refused: ${e}`)}function $r(e){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(t=>typeof M[t]=="function"&&M[t](e))}function Fr(e){let t=[],r=0,s=0,n=0,o=0,a=new WeakSet,c=u=>{if(r+=Buffer.byteLength(u,"utf8"),r>D.bytes)throw N("serialized byte limit exceeded");t.push(u)},i=u=>{if(Buffer.byteLength(u,"utf8")>D.bytes)throw N("serialized byte limit exceeded");return JSON.stringify(u)},l=(u,d)=>{if(s+=1,s>D.nodes)throw N("node limit exceeded");if(d>D.depth)throw N("depth limit exceeded");if(u===null){c("null");return}if(typeof u=="string"){c(i(u));return}if(typeof u=="boolean"){c(u?"true":"false");return}if(typeof u=="number"){if(!Number.isFinite(u))throw N("non-finite number");c(Object.is(u,-0)?"0":String(u));return}if(typeof u!="object")throw N("unsupported non-JSON value");if(M.isProxy(u))throw N("proxy value");if($r(u))throw N("unsupported exotic object");if(a.has(u))throw N("cyclic value");a.add(u);try{if(Object.getOwnPropertySymbols(u).length>0)throw N("symbol-keyed fields are unsupported");if(Array.isArray(u)){let p=Object.getPrototypeOf(u),m=0;for(;p!==null;){if(M.isProxy(p))throw N("proxy array prototype");if(m+=1,m>D.depth)throw N("array prototype depth limit exceeded");p=Object.getPrototypeOf(p)}if(u.length>D.arrayLength)throw N("array length limit exceeded");for(let y=0;y<u.length;y+=1){let x=Object.getOwnPropertyDescriptor(u,String(y));if(!x||!Object.hasOwn(x,"value")||x.enumerable!==!0)throw N("array entries must be dense enumerable own data")}let b=0;for(let y in u){if(o+=1,o>D.fields)throw N("enumeration limit exceeded");if(Object.hasOwn(u,y)&&(b+=1,b>u.length))throw N("named array fields are unsupported")}if(b!==u.length)throw N("array entries must be dense enumerable own data");c("[");for(let y=0;y<u.length;y+=1)y&&c(","),l(Object.getOwnPropertyDescriptor(u,String(y)).value,d+1);c("]");return}let h=Object.getPrototypeOf(u);if(h!==Object.prototype&&h!==null)throw N("non-plain object");let f=[];for(let p in u){if(o+=1,o>D.fields)throw N("enumeration limit exceeded");if(!Object.hasOwn(u,p))continue;if(n+=1,n>D.fields)throw N("field limit exceeded");let m=Object.getOwnPropertyDescriptor(u,p);if(!m||!Object.hasOwn(m,"value")||m.enumerable!==!0)throw N("object fields must be enumerable own data");f.push([p,m.value])}c("{");for(let p=0;p<f.length;p+=1)p&&c(","),c(i(f[p][0])),c(":"),l(f[p][1],d+1);c("}")}finally{a.delete(u)}};return l(e,0),t.join("")}function Dr(e){let t=Object.create(null);if(e==null)return t;if(typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP headers must be an object");if(M.isProxy(e))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let s of Object.keys(e)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(s))throw new TypeError("HTTP header names must be valid tokens");let n=s.toLowerCase();if(r.has(n))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(n);let o=Object.getOwnPropertyDescriptor(e,s);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");t[s]=String(a)}return t}function Mr(){return Object.assign(Object.create(null),{Accept:"application/json"})}function Hr(e,t){if(!e)throw new Error(`HTTP redirect from ${t} missing Location`);let r=new URL(String(e),String(t));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${t} used unsupported protocol ${r.protocol}`);return r.toString()}function jr(e,t){return new URL(String(e)).origin===new URL(String(t)).origin}var xe=new Map,rt=new WeakMap,nt=1;function ie(e){if((typeof e!="object"||e===null)&&typeof e!="function")return`${typeof e}:${String(e)}`;let t=rt.get(e);return t||(t=nt,nt+=1,rt.set(e,t)),`reference:${t}`}var Vr=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),zr=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function ot(e){if(!e||typeof e!="object"||Array.isArray(e)||!Object.hasOwn(e,"jsonrpc")||!Object.hasOwn(e,"method")||e.jsonrpc!=="2.0")return!1;let t=typeof e.method=="string"?e.method:"";return t?Vr.has(t)||/^get[A-Z0-9_]/u.test(t)||/^is[A-Z0-9_]/u.test(t)||/^eth_get[A-Z0-9_]/u.test(t):!1}function st(e,t){if(e==="GET"&&t==null)return!0;if(e!=="POST"||t==null)return!1;let r=t;if(typeof t=="string")try{r=JSON.parse(t)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every(ot);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return ot(r);let s=Object.hasOwn(r,"type")?r.type:null;return typeof s=="string"&&zr.has(s)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function Wr(e,t,r,s={},n=null){let o=_r("sha256"),a=(i,l)=>{let u=String(l);o.update(String(Buffer.byteLength(i,"utf8"))).update(":").update(i),o.update("=").update(String(Buffer.byteLength(u,"utf8"))).update(":").update(u).update(`
4
- `)};a("method",e),a("url",t),Object.keys(r||{}).map((i,l)=>({name:i.toLowerCase(),order:l,value:String(r[i])})).sort((i,l)=>i.name.localeCompare(l.name)||i.order-l.order).forEach((i,l)=>{a(`header-name-${l}`,i.name),a(`header-value-${l}`,i.value)}),a("body",n??"-");for(let i of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])a(`context-${i}`,s[i]??"-");return o.digest("hex")}function Gr(e,t){let r=Number(t);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Je):Math.min(250*2**e,Je)+Math.floor(Math.random()*100)}var Kr=e=>new Promise(t=>setTimeout(t,e));function H(e,t={}){let r=new Error(e);return r.retryable=!1,Object.assign(r,t),r}function Ce(e,t,r){return H(`HTTP response from ${e} exceeded maxResponseBytes ${r} (${t})`,{oversize:!0})}function z(e){try{let t=e?.body?.cancel?.();t&&typeof t.then=="function"&&t.catch(()=>{})}catch{}}function Xr(e){return e?e.byteLength??e.length??0:0}async function Yr(e,t,{url:r,truncate:s=!1,onOversize:n}={}){if(t==null)return await e.text();let o=Number(e.headers?.get?.("content-length"));if(Number.isFinite(o)&&o>t&&(z(e),!s))throw Ce(r,`content-length ${o}`,t);let a=e.body?.getReader?.();if(!a){let d=await e.text(),h=Buffer.byteLength(d,"utf8");if(h>t){if(!s)throw Ce(r,`body ${h} bytes`,t);return Buffer.from(d,"utf8").subarray(0,t).toString("utf8")}return d}let c=[],i=0,l=!1;try{for(;;){let{value:d,done:h}=await a.read();if(h)break;if(d&&(c.push(Buffer.from(d)),i+=Xr(d),i>t)){l=!0;break}}}finally{if(l)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(l&&(typeof n=="function"&&n(),!s))throw Ce(r,`streamed ${i} bytes`,t);let u=Buffer.concat(c);return(l?u.subarray(0,t):u).toString("utf8")}function Zr(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}async function Qr(e,{fetchImpl:t,method:r,headers:s,body:n,timeoutMs:o,lookupFn:a,realFetch:c,untrustedUrl:i=!1,maxResponseBytes:l=null,sameOriginRedirectsOnly:u=!1,importUndici:d,validateResponse:h,signal:f,redirectPolicy:p="follow",maxRedirects:m=ae}){let b=null,y=t,x=a?{lookupFn:a}:{};if(i&&!c&&!Ae(y))throw H(`HTTP refused ${e}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let C=new AbortController,_=setTimeout(()=>C.abort(),o),O=f?tt?tt([f,C.signal]):f:C.signal,T=async(E,{status:I=null}={})=>{let S=await ve(E,x);if(!S.ok)throw H(I==null?`HTTP refused ${E}: ${S.error}`:`HTTP redirect to ${E} ${S.error}`,I==null?{}:{status:I});let L=new URL(E).hostname;if(c){if(b&&(await b.close(),b=null),!b)try{b=await Ee({requireUndici:!0,...d?{importUndici:d}:{}})}catch(g){throw H(I==null?`HTTP refused ${E}: ${g?.message||g}`:`HTTP redirect to ${E} refused: ${g?.message||g}`,I==null?{}:{status:I})}b.pin(L,S.addresses),y=b.fetch}else Ze(y,L,S.addresses);return S};try{let E=String(e),I=Object.assign(Object.create(null),s||{});i&&await T(E);for(let S=0;S<=m;S+=1){let L=Object.assign(Object.create(null),{method:r,headers:I,body:n,signal:O,redirect:"manual",dispatcher:void 0}),g=await y(E,L);if((p==="error"||m===0)&&g.status>=300&&g.status<400)throw z(g),H(`HTTP ${g.status} ${r} redirect refused`,{status:g.status,redirectRefused:!0});if(Br.has(g.status)){let U=u===!0&&r==="POST"&&[307,308].includes(g.status)&&st(r,n);if(r!=="GET"&&r!=="HEAD"&&!U){z(g);let R=new Error(`HTTP ${g.status} ${r} ${E} redirected non-idempotent request`);throw R.status=g.status,R}if(S===m)throw z(g),H(`HTTP ${g.status} ${r} redirect budget exhausted`,{status:g.status,redirectRefused:!0});let Fe=g.headers?.get?.("location"),$;try{$=Hr(Fe,E)}catch(R){throw z(g),R}let j=!jr($,E);if(z(g),j&&r==="POST"){let R=new Error(`HTTP ${g.status} ${r} cross-origin redirect refused`);throw R.status=g.status,R}if(j&&u){let R=new Error(`HTTP ${g.status} ${r} cross-origin redirect refused`);throw R.status=g.status,R.retryable=!1,R}if(j&&(I=Mr(I)),i)await T($,{status:g.status});else if(j){let R=await ve($,x);if(!R.ok){let k=new Error(`HTTP redirect from ${E} ${R.error}`);throw k.status=g.status,k.retryable=!1,k}c&&R.addresses?.length&&(b||(b=await Ee(d?{importUndici:d}:{})),b&&(b.pin(new URL($).hostname,R.addresses),y=b.fetch))}E=$;continue}if(typeof h=="function")try{await h(g,{url:E})}catch(U){throw z(g),H(U?.message||String(U))}let P=await Yr(g,l,{url:E,onOversize:()=>C.abort()}),K=Zr(P);if(!g.ok){let U=new Error(`HTTP ${g.status} ${r} ${E}`);throw U.status=g.status,U.retryAfter=g.headers?.get?.("retry-after")??null,U.body=K??P.slice(0,300),U}return K??P}throw new Error(`HTTP redirect loop for ${e}`)}catch(E){if(C.signal.aborted&&!Z(f)){let I=E&&(typeof E=="object"||typeof E=="function")&&!M.isProxy(E)?E:null,S=I?Object.getOwnPropertyDescriptor(I,"oversize"):null;if(!(S&&Object.hasOwn(S,"value")&&S.value===!0))try{if(!I)throw new TypeError("unsafe rejection");Object.defineProperties(I,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let g=new Error("HTTP request timed out");throw Object.defineProperties(g,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),g}}throw E}finally{clearTimeout(_),b&&await b.close()}}async function ce(e,t={}){if(t!=null&&typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP options must be an object");if(t!=null&&M.isProxy(t))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(t!=null){if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP options contain unknown fields");for(let k of Object.getOwnPropertyNames(t)){let A=Object.getOwnPropertyDescriptor(t,k);if(!(k==="toJSON"&&A&&Object.hasOwn(A,"value")&&A.value===void 0)){if(!r.has(k))throw new TypeError("HTTP options contain unknown fields");if(!A||!A.enumerable||!Object.hasOwn(A,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let s=k=>{if(t==null||!Object.hasOwn(t,k))return;let A=Object.getOwnPropertyDescriptor(t,k);if(!A||!Object.hasOwn(A,"value"))throw new TypeError("HTTP options must contain own data properties");return A.value};if(typeof e!="string"||e.length===0||e.length>8192)throw new TypeError("HTTP URL must be a bounded string");let n=s("method");if(n!==void 0&&(typeof n!="string"||!/^[A-Za-z]+$/u.test(n)))throw new TypeError("HTTP method must be a string token");let o=s("timeoutMs");if(o!==void 0&&(!Number.isInteger(o)||o<1||o>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let a=s("retries");if(a!==void 0&&(!Number.isInteger(a)||a<0||a>10))throw new TypeError("HTTP retries must be a bounded integer");let c=s("redirectPolicy");if(c!==void 0&&c!=="follow"&&c!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let i=s("maxRedirects");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>ae))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ae}`);if(c==="error"&&i!==void 0&&i!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let l=c??"follow",u=l==="error"?0:i??ae;for(let k of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let A=s(k);if(A!==void 0&&typeof A!="boolean")throw new TypeError(`HTTP ${k} must be boolean`)}let d=s("maxResponseBytes");if(d!==void 0&&(!Number.isInteger(d)||d<1||d>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let h=s("signal");if(h!==void 0){if(M.isProxy(h)||!(h instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{Z(h)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let k of["importUndici","lookupFn","validateResponse"]){let A=s(k);if(A!==void 0&&typeof A!="function")throw new TypeError(`HTTP ${k} must be a function`)}let f=s("fetchImpl"),p=f||globalThis.fetch;if(typeof p!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let m=o??12e3,b=(n||"GET").toUpperCase(),y=s("headers"),x=Dr(y),C=Object.assign(Object.create(null),x);Object.keys(C).some(k=>k.toLowerCase()==="accept")||(C.Accept="application/json");let _=s("body");_!=null&&typeof _!="string"&&(Object.keys(C).find(A=>A.toLowerCase()==="content-type")||(C["Content-Type"]="application/json"),_=Fr(_));let O=a??Nr,T=s("lookupFn"),E=!f,I=s("untrustedUrl")===!0,S=s("sameOriginRedirectsOnly")===!0,L=s("importUndici"),g=s("validateResponse"),P=h,K=d??null,U=async()=>{let k;for(let A=0;A<=O;A++){P&&Pr.call(P);let De=oe("http");try{let F=await Qr(e,{fetchImpl:p,method:b,headers:C,body:_,timeoutMs:m,lookupFn:T,realFetch:E,untrustedUrl:I,maxResponseBytes:K,sameOriginRedirectsOnly:S,importUndici:L,validateResponse:g,signal:P,redirectPolicy:l,maxRedirects:u});return De?.("succeeded"),F}catch(F){k=F;let G=be=>{if(!F||typeof F!="object"&&typeof F!="function"||M.isProxy(F))return;let X=Object.getOwnPropertyDescriptor(F,be);return X&&Object.hasOwn(X,"value")?X.value:void 0},re=G("status");De?.("failed",re);let Vt=G("oracleTimeout")===!0||G("name")==="AbortError"||G("name")==="TimeoutError"||Z(P),zt=new Set([408,425,429]),Wt=G("retryable")===!1?!1:re!=null?zt.has(re)||Or.has(re)&&Qe.has(b):!Vt&&Qe.has(b);if(A===O||!Wt)throw F;let Me=Gr(A,G("retryAfter")),Gt=oe("retry"),He=!1;try{P?await new Promise((be,X)=>{let je,Y=()=>{clearTimeout(je),et.call(P,"abort",Y),X(qr(P)||new DOMException("Aborted","AbortError"))};if(Z(P)){Y();return}je=setTimeout(()=>{et.call(P,"abort",Y),be()},Me),Ur.call(P,"abort",Y,{once:!0}),Z(P)&&Y()}):await Kr(Me),He=!0}finally{Gt?.(He?"succeeded":"failed")}}}throw k};if(!(s("dedupe")!==!1&&!P&&st(b,_)))return U();let $=Wr(b,e,C,{untrustedUrl:I,maxResponseBytes:K,sameOriginRedirectsOnly:S,redirectPolicy:l,maxRedirects:u,timeoutMs:m,retries:O,fetchImpl:ie(p),realFetch:E,lookupFn:ie(T),importUndici:ie(L),validateResponse:ie(g)},_),j=xe.get($);if(j){let k=oe("shared");try{let A=await j;return k?.("succeeded"),A}catch(A){throw k?.("failed"),A}}let R=U().finally(()=>xe.delete($));return xe.set($,R),R}async function it(e,t,r){let s=Array.from(e),n=Math.max(1,Math.min(Number(t)||1,s.length||1)),o=new Array(s.length),a=0;return await Promise.all(Array.from({length:n},async()=>{for(;a<s.length;){let c=a++;o[c]=await r(s[c],c)}})),o}var ke={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}};var Jr=new Map(Object.values(ke).map(e=>[e.chainId,e]));function at(e){return Jr.get(Number(e))||null}function ct(e,t=process.env){let r=at(e);if(!r)return null;for(let s of r.rpcEnv){let n=(t[s]||"").trim();if(n)return n}return null}import{Interface as en,getAddress as tn}from"ethers";var ut=new en(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function lt(e,t){try{return tn(e).toLowerCase()}catch{throw new Error(`${t} must be a valid EVM address`)}}var rn={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 nn(e,{rpcUrl:t,env:r=process.env}={}){if(t)return t;let s=ct(e,r);return s||rn[Number(e)]||null}var on=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function sn(e){let t=String(e||""),r=t.toLowerCase();if(t!==t.trim()||!/^[a-zA-Z0-9_]+$/.test(t)||!on.test(r))throw new Error(`evm-rpc: ${t} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var Q=new Map,dt=new Map;function an(e){let t=new Error(e?.message||JSON.stringify(e));return t.code=e?.code,t}function cn(e){if(e?.error)throw an(e.error);return e?.result}function un(e,t,r){return`${e}
1
+ var Yt=/\b0x[a-fA-F0-9]{40}\b/g,Zt=/\b[1-9A-HJ-NP-Za-km-z]{32,44}\b/g,Qt=new Set(["0x0000000000000000000000000000000000000000","0x000000000000000000000000000000000000dead","0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"].map(e=>e.toLowerCase())),Jt=new Set(["So11111111111111111111111111111111111111112","EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB","11111111111111111111111111111111"]);function er(e){return!(Jt.has(e)||/^0x/i.test(e)||!/\d/.test(e)&&e===e.toLowerCase()||!/\d/.test(e)&&e===e.toUpperCase())}function Ve(e,{extras:t=[]}={}){let r=[e,...t].map(s=>String(s||"")).join(`
2
+ `),o=[...new Set((r.match(Yt)||[]).map(s=>s.toLowerCase()))].filter(s=>!Qt.has(s)),n=[...new Set(r.match(Zt)||[])].filter(er);return{evm:o,solana:n,all:[...o.map(s=>({chainFamily:"evm",address:s})),...n.map(s=>({chainFamily:"solana",address:s}))]}}function ze(e){let t=String(e||"").trim();if(!t)return[];let r=[],o=n=>{if(!n||typeof n!="object")return;let s=String(n.id||n.id_str||n.tweetId||n.statusId||""),a=n.text||n.full_text||n.fullText||n.body||n.note_tweet?.text||"",c=[],i=n.entities?.urls||n.entities?.Urls||[];for(let l of i)l?.expanded_url&&c.push(l.expanded_url),l?.url&&c.push(l.url);(s||a)&&r.push({id:s,text:String(a),urls:c,raw:n})};try{let n=JSON.parse(t),s=Array.isArray(n)?n:n.data?Array.isArray(n.data)?n.data:[n.data]:n.tweets||n.statuses||n.results||[];Array.isArray(s)?s.forEach(o):o(n)}catch{for(let n of t.split(`
3
+ `)){let s=n.trim();if(s.startsWith("{"))try{o(JSON.parse(s))}catch{}}r.length||r.push({id:"",text:t,urls:[]})}return r}import{spawnSync as fr}from"node:child_process";import We from"node:fs";import we from"node:path";var tr=(process.env.ORACLE_REDACT_SECRETS??"true").toLowerCase(),rr=["1","true","yes","on"].includes(tr),nr=[/sk-[A-Za-z0-9_-]{10,}/g,/sk_live_[A-Za-z0-9]{10,}/g,/sk_test_[A-Za-z0-9]{10,}/g,/ghp_[A-Za-z0-9]{10,}/g,/github_pat_[A-Za-z0-9_]{10,}/g,/gho_[A-Za-z0-9]{10,}/g,/ghs_[A-Za-z0-9]{10,}/g,/xox[baprs]-[A-Za-z0-9-]{10,}/g,/AIza[A-Za-z0-9_-]{30,}/g,/AKIA[A-Z0-9]{16}/g,/pplx-[A-Za-z0-9]{10,}/g,/hf_[A-Za-z0-9]{10,}/g,/xai-[A-Za-z0-9]{30,}/g,/gsk_[A-Za-z0-9]{10,}/g,/npm_[A-Za-z0-9]{10,}/g,/tvly-[A-Za-z0-9]{10,}/g,/Bearer\s+[A-Za-z0-9\-._~+/]+=*/gi],or=/\b0x[a-fA-F0-9]{64}\b/g,sr=/-----BEGIN (?:RSA |EC |OPENSSH |ENCRYPTED )?PRIVATE KEY-----[\s\S]*?-----END (?:RSA |EC |OPENSSH |ENCRYPTED )?PRIVATE KEY-----/g,ir=/\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b/g,ar=/\b([A-Z][A-Z0-9_]{0,40}(?:API_?KEY|TOKEN|SECRET|PASSWORD|PASSWD|PRIVATE_?KEY|MNEMONIC|SEED|AUTH)[A-Z0-9_]{0,20})\s*=\s*(['"]?)(\S+)\2/g,cr=/^(?:export\s+)?((?:api[_-]?key|token|secret|password|private[_-]?key|mnemonic|seed[_-]?phrase|authorization))\s*[:=]\s*(['"]?)([^\s&]+)\2/gim,ur=/("(?:api[_-]?key|apiKey|access[_-]?token|refresh[_-]?token|client[_-]?secret|private[_-]?key|privateKey|secret|password|authorization|bearer|mnemonic|seedPhrase)"\s*:\s*")([^"]{6,})(")/gi,lr=new Set(["access_token","refresh_token","id_token","token","api_key","apikey","client_secret","password","auth","jwt","session","secret","key","code","signature","x-amz-signature","private_key","authorization"]),to=new Set([...lr].map(e=>e.replace(/[^a-z0-9]/gi,"").toLowerCase()));function dr(e){let t=String(e??"");return t.length<18?"[REDACTED]":`${t.slice(0,6)}\u2026${t.slice(-4)}`}function pr(e){return`\xABredacted:${String(e??"").slice(0,4)}\u2026\xBB`}function ne(e,t={}){if(e==null)return e;let r=typeof e=="string"?e:String(e);if(!r||!(t.force||rr))return r;let o=t.fileRead?pr:dr;r=r.replace(sr,"[REDACTED_PRIVATE_KEY]"),r=r.replace(or,"[REDACTED_EVM_KEY]"),r=r.replace(ir,n=>o(n));for(let n of nr)n.lastIndex=0,r=r.replace(n,s=>o(s));return r=r.replace(ar,(n,s,a,c)=>/^(?:os\.(?:getenv|environ)|process\.env|\$ENV\{)/.test(c)?`${s}=${a||""}${c}${a||""}`:`${s}=${a||""}${o(c)}${a||""}`),r=r.replace(cr,(n,s,a,c)=>n.replace(c,o(c))),r=r.replace(ur,(n,s,a,c)=>`${s}${o(a)}${c}`),r}var Ge=45e3,hr=4e4,mr=Object.freeze(["whoami","user","read","search","timeline","mentions","bookmarks","likes","following","followers","dms","auth"]),br=Object.freeze(["post","reply","quote","delete","like","unlike","repost","unrepost","bookmark","unbookmark","follow","unfollow","block","unblock","mute","unmute","dm"]),Ke=Object.freeze(["--verbose","-v","--trace","-t","--bearer-token","--consumer-key","--consumer-secret","--access-token","--token-secret","--client-id","--client-secret"]);function gr(e=process.env){let t=String(e.ORACLE_XURL_ENABLED||"").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function Xe(e=process.env){let t=String(e.ORACLE_XURL_ALLOW_WRITE||"").trim().toLowerCase();return t==="1"||t==="true"||t==="yes"||t==="on"}function wr(e=process.env){let t=String(e.ORACLE_XURL_BIN||"").trim();if(t)return we.isAbsolute(t)?We.existsSync(t)?{ok:!0,bin:t}:{ok:!1,error:`ORACLE_XURL_BIN not found: ${t}`}:{ok:!1,error:"ORACLE_XURL_BIN must be absolute"};let r=String(e.PATH||process.env.PATH||"");for(let o of r.split(we.delimiter)){if(!o)continue;let n=we.join(o,"xurl");try{if(We.existsSync(n))return{ok:!0,bin:n}}catch{}}return{ok:!1,error:"xurl binary not found on PATH. Install: curl -fsSL https://raw.githubusercontent.com/xdevplatform/xurl/main/install.sh | bash"}}function yr(e=process.env){let t=e.HOME||process.env.HOME||"";return{PATH:e.PATH||process.env.PATH||"/usr/bin:/bin",HOME:t,USER:e.USER||process.env.USER||"",LANG:e.LANG||process.env.LANG||"C.UTF-8",LC_ALL:e.LC_ALL||process.env.LC_ALL||"C.UTF-8",XDG_CONFIG_HOME:e.XDG_CONFIG_HOME||process.env.XDG_CONFIG_HOME||"",XDG_DATA_HOME:e.XDG_DATA_HOME||process.env.XDG_DATA_HOME||"",NO_COLOR:"1"}}function Er(e){for(let t of e){let r=String(t);if(Ke.includes(r))return r;if(Ke.some(o=>o.startsWith("--")&&r.startsWith(`${o}=`)))return r.split("=")[0]}return null}function vr(e={},t=process.env){let r;if(Array.isArray(e.argv))r=e.argv.map(i=>String(i));else{let i=String(e.command||e.cmd||"").trim();if(!i)return{ok:!1,error:"command is required (e.g. whoami, search, read, post)"};let l=Array.isArray(e.args)?e.args.map(u=>String(u)):typeof e.query=="string"?[e.query]:typeof e.text=="string"?[e.text]:typeof e.id=="string"?[e.id]:typeof e.handle=="string"?[e.handle]:[];i==="search"&&e.limit!=null&&l.push("-n",String(Math.min(50,Math.max(1,Number(e.limit)||10)))),(i==="timeline"||i==="mentions")&&e.limit!=null&&l.push("-n",String(Math.min(50,Math.max(1,Number(e.limit)||10)))),r=[i,...l]}if(r.length===0)return{ok:!1,error:"empty argv"};if(r.length>24)return{ok:!1,error:"too many arguments"};for(let i of r)if(String(i).length>4e3)return{ok:!1,error:"argument too long"};let o=Er(r);if(o)return{ok:!1,error:`forbidden flag: ${o}`};if(r.some(i=>String(i).includes("\0")))return{ok:!1,error:"nul byte in argv"};let n=String(r[0]||"").replace(/^\//,"");if(n.startsWith("2/")||r[0].startsWith("/2/")||r[0].startsWith("https://api.x.com/")){if(!Xe(t)&&r.some(i=>/^-X$/.test(i)||/^--request$/.test(i))){let i=r.findIndex(u=>u==="-X"||u==="--request"),l=String(r[i+1]||"GET").toUpperCase();if(l!=="GET"&&l!=="HEAD")return{ok:!1,error:"raw non-GET requires ORACLE_XURL_ALLOW_WRITE=true"}}}else if(n==="auth"){if(String(r[1]||"")!=="status")return{ok:!1,error:"only `auth status` is allowed (no apps add / oauth2 from the agent)"}}else if(!mr.includes(n))if(br.includes(n)){if(!Xe(t))return{ok:!1,error:`write command '${n}' requires ORACLE_XURL_ALLOW_WRITE=true`}}else return n==="media"?{ok:!1,error:"media upload is disabled in the agent tool (run xurl media outside the agent)"}:{ok:!1,error:`command not allowlisted: ${n}`};let s=[...r],a=String(t.ORACLE_XURL_APP||"").trim(),c=String(t.ORACLE_XURL_USER||"").trim();if(a&&!s.includes("--app")&&s.unshift("--app",a),c&&!s.includes("--username")&&!s.includes("-u")){let i=0;s[0]==="--app"&&(i=2),i<s.length&&s.splice(i+1,0,"-u",c)}return{ok:!0,argv:s,command:n}}async function Ye(e,t={},r={}){if(e!=="xurl")return{ok:!1,error:`unknown tool: ${e}`};let o=r.env||process.env;if(!gr(o))return{ok:!1,error:"xurl is disabled. Set ORACLE_XURL_ENABLED=true after `xurl auth status` succeeds. Writes stay off until ORACLE_XURL_ALLOW_WRITE=true."};let n=vr(t,o);if(!n.ok)return n;let s=wr(o);if(!s.ok)return s;let c=(r.spawnFn||fr)(s.bin,n.argv,{encoding:"utf8",timeout:r.timeoutMs||Ge,maxBuffer:1024*1024,env:yr(o)});if(c.error){let d=c.error.code==="ETIMEDOUT"?`xurl timed out after ${r.timeoutMs||Ge}ms`:String(c.error.message||c.error);return{ok:!1,error:ne(d,{force:!0})}}let i=ne(String(c.stdout||"").slice(0,hr),{force:!0}),l=ne(String(c.stderr||"").slice(0,2e3),{force:!0}),u=typeof c.status=="number"?c.status:1;return{ok:u===0,status:u,command:n.command,argv:n.argv.map(d=>/=/.test(d)&&/token|secret|key|bearer/i.test(d)?"[redacted-arg]":d),stdout:i,stderr:l||void 0}}var ao=Object.freeze([{type:"function",function:{name:"xurl",description:"Call the official xurl CLI against the X API with an allowlisted command. Reads (whoami/user/read/search/timeline/mentions/...) work when ORACLE_XURL_ENABLED=true. Writes (post/reply/like/follow/dm/...) also need ORACLE_XURL_ALLOW_WRITE=true. Never pass secrets or --verbose. Auth is whatever the operator configured in ~/.xurl.",parameters:{type:"object",properties:{command:{type:"string",description:"xurl subcommand: whoami, user, read, search, timeline, mentions, post, reply, ..."},args:{type:"array",items:{type:"string"},description:"Positional args after the command (query, id, handle, text)."},query:{type:"string",description:"Convenience for search query."},text:{type:"string",description:"Convenience for post/reply/dm text."},id:{type:"string",description:"Convenience for read/like/reply target id or URL."},handle:{type:"string",description:"Convenience for user/follow/dm handle."},limit:{type:"integer",description:"Result limit for search/timeline/mentions (1-50)."},argv:{type:"array",items:{type:"string"},description:"Raw argv alternative (still allowlisted + flag-filtered)."}},additionalProperties:!1}}}]);import{createHash as Nr}from"node:crypto";import{types as M}from"node:util";import{AsyncLocalStorage as Sr}from"node:async_hooks";var Ar=new Sr,xr=["http","retry","shared"],Cr=512;function oe(e){let t=Ar.getStore();if(!t||t.closed||!xr.includes(e))return null;if(t.spans.length>=Cr)return t.droppedSpans++,null;let r={stage:e,startMs:t.now()-t.start,durationMs:null,outcome:"pending",status:null};return t.spans.push(r),(o,n=null)=>{t.closed||r.durationMs!==null||(r.durationMs=Math.max(0,t.now()-t.start-r.startMs),r.outcome=o==="succeeded"?"succeeded":"failed",r.status=Number.isInteger(n)&&n>=100&&n<=599?n:null)}}import V from"node:net";import kr from"node:dns";var Tr=new Set(["localhost","metadata.google.internal","metadata.goog"]);function se(e){let t=String(e).toLowerCase().split("%")[0];if((t.match(/::/g)||[]).length>1)return null;let r=u=>{if(!u)return[];let d=u.split(":"),h=d.at(-1);if(h?.includes(".")){let f=h.split(".").map(Number);if(f.length!==4||f.some(p=>!Number.isInteger(p)||p<0||p>255))return null;d.splice(d.length-1,1,(f[0]<<8|f[1]).toString(16),(f[2]<<8|f[3]).toString(16))}return d.some(f=>!/^[0-9a-f]{1,4}$/.test(f))?null:d.map(f=>Number.parseInt(f,16))},[o,n]=t.split("::"),s=r(o),a=r(n);if(!s||!a)return null;let c=t.includes("::"),i=8-s.length-a.length;if(!c&&i!==0||c&&i<1)return null;let l=[...s,...Array(Math.max(0,i)).fill(0),...a];return l.length!==8?null:Uint8Array.from(l.flatMap(u=>[u>>8,u&255]))}function ye(e,t,r){let o=Math.floor(r/8),n=r%8;for(let a=0;a<o;a+=1)if(e[a]!==t[a])return!1;if(!n)return!0;let s=255<<8-n;return(e[o]&s)===(t[o]&s)}function Ee(e){if(V.isIPv4(e)){let t=e.split(".").map(Number);return!(t[0]===0||t[0]===10||t[0]===127||t[0]>=224||t[0]===100&&t[1]>=64&&t[1]<=127||t[0]===169&&t[1]===254||t[0]===172&&t[1]>=16&&t[1]<=31||t[0]===192&&(t[1]===0||t[1]===2||t[1]===168)||t[0]===192&&t[1]===88&&t[2]===99||t[0]===198&&(t[1]===18||t[1]===19||t[1]===51)||t[0]===203&&t[1]===0&&t[2]===113)}if(V.isIPv6(e)){let t=se(e);if(!t)return!1;let r=se("::ffff:0:0");return ye(t,r,96)?Ee([...t.slice(12)].join(".")):ye(t,se("2000::"),3)?![["2001::",23],["2001:db8::",32],["2001:10::",28],["2001:2::",48],["2002::",16],["3fff::",20]].some(([n,s])=>ye(t,se(n),s)):!1}return!1}function Ir(e){let t;try{t=new URL(String(e))}catch{return{ok:!1,error:`not a valid URL: ${String(e).slice(0,120)}`}}if(t.protocol!=="http:"&&t.protocol!=="https:")return{ok:!1,error:`refused protocol ${t.protocol} (only http/https)`};let r=t.hostname.toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,"");if(Tr.has(r)||r.endsWith(".localhost")||r.endsWith(".internal"))return{ok:!1,error:`refused internal host ${r}`};let o=V.isIP(r);return o!==0&&!Ee(r)?{ok:!1,error:`refused private address ${r}`}:{ok:!0,url:t,host:r,isLiteralIp:o!==0}}async function ve(e,{lookupFn:t=kr.promises.lookup}={}){let r=Ir(e);if(!r.ok)return r;if(r.isLiteralIp)return{ok:!0,url:r.url,addresses:[{address:r.host,family:V.isIPv6(r.host)?6:4}]};let o;if(process.env.ORACLE_HOSTED_EGRESS_PROXY)return{ok:!0,url:r.url,addresses:[]};try{o=await t(r.host,{all:!0,verbatim:!0})}catch{return{ok:!1,error:`refused: ${r.host} did not resolve`}}return!Array.isArray(o)||o.length===0||o.some(n=>!Ee(n.address))?{ok:!1,error:`refused: ${r.host} resolves to a non-public address`}:{ok:!0,url:r.url,addresses:o}}function _r(e=process.env){let t=e.ORACLE_HOSTED_EGRESS_PROXY||"";if(!t)return null;let r;try{r=new URL(t)}catch{throw new Error("egress-guard: ORACLE_HOSTED_EGRESS_PROXY is not a URL")}if(r.protocol!=="http:"||!["127.0.0.1","::1","localhost","[::1]"].includes(r.hostname)||!r.port||r.username||r.password)throw new Error("egress-guard: egress proxy must be an exact loopback http origin");let o=e.ORACLE_HOSTED_EGRESS_TOKEN||"";if(!/^[A-Za-z0-9_-]{43}$/.test(o))throw new Error("egress-guard: egress proxy token is missing");return{uri:r.origin,token:o}}async function Se({requireUndici:e=!1,importUndici:t=()=>import("undici")}={}){let r,o,n;try{n=await t(),r=n.Agent,o=n.fetch}catch(f){if(e)throw new Error(`egress-guard: untrustedUrl pinning requires the undici package, which failed to load: ${f?.message||f}`);return null}if(typeof r!="function"||typeof o!="function"){if(e)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=f=>String(f).toLowerCase().replace(/^\[|\]$/g,"").replace(/\.+$/,""),a=new Map,c=f=>(Array.isArray(f)?f:[f]).map(p=>typeof p=="string"?{address:p}:p).filter(p=>p&&p.address).map(p=>({address:p.address,family:p.family||(V.isIPv6(p.address)?6:4)})),i=(f,p,m)=>{a.set(s(f),c(typeof p=="string"?[{address:p,family:m}]:p))},l=f=>{let p=s(f);if(V.isIP(p))return[{address:p,family:V.isIPv6(p)?6:4}];let m=a.get(p);if(!m||!m.length)throw new Error(`refused: unpinned host ${f} during pinned fetch`);return m},u=_r(),d=u&&typeof n.ProxyAgent=="function"?new n.ProxyAgent({uri:u.uri,token:`Bearer ${u.token}`,connectTimeout:1e4}):new r({connect:{lookup(f,p,m){let b;try{b=l(f)}catch(y){return m(y)}return p?.all?m(null,b):m(null,b[0].address,b[0].family)}}}),h=Or((f,p={})=>o(f,{...p,dispatcher:d}),i);return{dispatcher:d,fetch:h,pin:i,resolve:l,async close(){try{await d.destroy()}catch{}}}}var Ae=Symbol.for("oracle.egressGuard.pinCapableFetch");function Or(e,t){if(typeof e!="function")throw new Error("markPinCapableFetch: fetchImpl must be a function");if(typeof t!="function")throw new Error("markPinCapableFetch: pin must be a function");return e[Ae]=Object.freeze({pin:t}),e}function xe(e){return typeof e=="function"&&typeof e[Ae]?.pin=="function"}function Ze(e,t,r){if(!xe(e))throw new Error("pinFetchToAddresses: fetchImpl is not pin-capable");e[Ae].pin(t,r)}var Rr=new Set([408,425,429,500,502,503,504]),Qe=new Set(["GET","HEAD","OPTIONS","PUT","DELETE"]),Lr=2,Je=4e3,Pr=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Ur=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,qr=AbortSignal.prototype.throwIfAborted,Br=EventTarget.prototype.addEventListener,et=EventTarget.prototype.removeEventListener,tt=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null,Z=e=>e?Pr.call(e):!1,$r=e=>e?Ur.call(e):void 0,Fr=new Set([301,302,303,307,308]),ae=3,yo=64*1024,D=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});function N(e){return H(`HTTP JSON body refused: ${e}`)}function Dr(e){return["isArgumentsObject","isArrayBuffer","isAnyArrayBuffer","isArrayBufferView","isBoxedPrimitive","isDataView","isDate","isExternal","isGeneratorObject","isKeyObject","isCryptoKey","isMap","isMapIterator","isModuleNamespaceObject","isNativeError","isPromise","isRegExp","isSet","isSetIterator","isTypedArray","isWeakMap","isWeakSet"].some(t=>typeof M[t]=="function"&&M[t](e))}function Mr(e){let t=[],r=0,o=0,n=0,s=0,a=new WeakSet,c=u=>{if(r+=Buffer.byteLength(u,"utf8"),r>D.bytes)throw N("serialized byte limit exceeded");t.push(u)},i=u=>{if(Buffer.byteLength(u,"utf8")>D.bytes)throw N("serialized byte limit exceeded");return JSON.stringify(u)},l=(u,d)=>{if(o+=1,o>D.nodes)throw N("node limit exceeded");if(d>D.depth)throw N("depth limit exceeded");if(u===null){c("null");return}if(typeof u=="string"){c(i(u));return}if(typeof u=="boolean"){c(u?"true":"false");return}if(typeof u=="number"){if(!Number.isFinite(u))throw N("non-finite number");c(Object.is(u,-0)?"0":String(u));return}if(typeof u!="object")throw N("unsupported non-JSON value");if(M.isProxy(u))throw N("proxy value");if(Dr(u))throw N("unsupported exotic object");if(a.has(u))throw N("cyclic value");a.add(u);try{if(Object.getOwnPropertySymbols(u).length>0)throw N("symbol-keyed fields are unsupported");if(Array.isArray(u)){let p=Object.getPrototypeOf(u),m=0;for(;p!==null;){if(M.isProxy(p))throw N("proxy array prototype");if(m+=1,m>D.depth)throw N("array prototype depth limit exceeded");p=Object.getPrototypeOf(p)}if(u.length>D.arrayLength)throw N("array length limit exceeded");for(let y=0;y<u.length;y+=1){let x=Object.getOwnPropertyDescriptor(u,String(y));if(!x||!Object.hasOwn(x,"value")||x.enumerable!==!0)throw N("array entries must be dense enumerable own data")}let b=0;for(let y in u){if(s+=1,s>D.fields)throw N("enumeration limit exceeded");if(Object.hasOwn(u,y)&&(b+=1,b>u.length))throw N("named array fields are unsupported")}if(b!==u.length)throw N("array entries must be dense enumerable own data");c("[");for(let y=0;y<u.length;y+=1)y&&c(","),l(Object.getOwnPropertyDescriptor(u,String(y)).value,d+1);c("]");return}let h=Object.getPrototypeOf(u);if(h!==Object.prototype&&h!==null)throw N("non-plain object");let f=[];for(let p in u){if(s+=1,s>D.fields)throw N("enumeration limit exceeded");if(!Object.hasOwn(u,p))continue;if(n+=1,n>D.fields)throw N("field limit exceeded");let m=Object.getOwnPropertyDescriptor(u,p);if(!m||!Object.hasOwn(m,"value")||m.enumerable!==!0)throw N("object fields must be enumerable own data");f.push([p,m.value])}c("{");for(let p=0;p<f.length;p+=1)p&&c(","),c(i(f[p][0])),c(":"),l(f[p][1],d+1);c("}")}finally{a.delete(u)}};return l(e,0),t.join("")}function Hr(e){let t=Object.create(null);if(e==null)return t;if(typeof e!="object"&&typeof e!="function")throw new TypeError("HTTP headers must be an object");if(M.isProxy(e))throw new TypeError("HTTP headers must not be a proxy");if(Object.getOwnPropertySymbols(e).length>0)throw new TypeError("HTTP headers must not contain symbol fields");let r=new Set;for(let o of Object.keys(e)){if(!/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/u.test(o))throw new TypeError("HTTP header names must be valid tokens");let n=o.toLowerCase();if(r.has(n))throw new TypeError("HTTP headers contain a duplicate canonical name");r.add(n);let s=Object.getOwnPropertyDescriptor(e,o);if(!s||!Object.hasOwn(s,"value"))throw new TypeError("HTTP headers must contain own data properties");let a=s.value;if(a==null||["object","function","symbol"].includes(typeof a))throw new TypeError("HTTP header values must be scalar");t[o]=String(a)}return t}function jr(){return Object.assign(Object.create(null),{Accept:"application/json"})}function Vr(e,t){if(!e)throw new Error(`HTTP redirect from ${t} missing Location`);let r=new URL(String(e),String(t));if(r.protocol!=="http:"&&r.protocol!=="https:")throw new Error(`HTTP redirect from ${t} used unsupported protocol ${r.protocol}`);return r.toString()}function zr(e,t){return new URL(String(e)).origin===new URL(String(t)).origin}var Ce=new Map,rt=new WeakMap,nt=1;function ie(e){if((typeof e!="object"||e===null)&&typeof e!="function")return`${typeof e}:${String(e)}`;let t=rt.get(e);return t||(t=nt,nt+=1,rt.set(e,t)),`reference:${t}`}var Wr=new Set(["eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","getHealth","minimumLedgerSlot","net_version","simulateTransaction","web3_clientVersion"]),Gr=new Set(["allMids","l2Book","outcomeMeta","spotClearinghouseState","userFills","meta","metaAndAssetCtxs","perpDexs","candleSnapshot","fundingHistory","openOrders","frontendOpenOrders","clearinghouseState","spotMeta","validatorSummaries","delegatorSummary","delegations","delegatorRewards","delegatorHistory","maxBuilderFee"]);function ot(e){if(!e||typeof e!="object"||Array.isArray(e)||!Object.hasOwn(e,"jsonrpc")||!Object.hasOwn(e,"method")||e.jsonrpc!=="2.0")return!1;let t=typeof e.method=="string"?e.method:"";return t?Wr.has(t)||/^get[A-Z0-9_]/u.test(t)||/^is[A-Z0-9_]/u.test(t)||/^eth_get[A-Z0-9_]/u.test(t):!1}function st(e,t){if(e==="GET"&&t==null)return!0;if(e!=="POST"||t==null)return!1;let r=t;if(typeof t=="string")try{r=JSON.parse(t)}catch{return!1}if(Array.isArray(r))return r.length>0&&r.every(ot);if(!r||typeof r!="object")return!1;if(Object.hasOwn(r,"jsonrpc")||Object.hasOwn(r,"method"))return ot(r);let o=Object.hasOwn(r,"type")?r.type:null;return typeof o=="string"&&Gr.has(o)&&(!Object.hasOwn(r,"action")||r.action==null)&&(!Object.hasOwn(r,"signature")||r.signature==null)&&(!Object.hasOwn(r,"nonce")||r.nonce==null)}function Kr(e,t,r,o={},n=null){let s=Nr("sha256"),a=(i,l)=>{let u=String(l);s.update(String(Buffer.byteLength(i,"utf8"))).update(":").update(i),s.update("=").update(String(Buffer.byteLength(u,"utf8"))).update(":").update(u).update(`
4
+ `)};a("method",e),a("url",t),Object.keys(r||{}).map((i,l)=>({name:i.toLowerCase(),order:l,value:String(r[i])})).sort((i,l)=>i.name.localeCompare(l.name)||i.order-l.order).forEach((i,l)=>{a(`header-name-${l}`,i.name),a(`header-value-${l}`,i.value)}),a("body",n??"-");for(let i of["untrustedUrl","maxResponseBytes","sameOriginRedirectsOnly","redirectPolicy","maxRedirects","timeoutMs","retries","fetchImpl","realFetch","lookupFn","importUndici","validateResponse"])a(`context-${i}`,o[i]??"-");return s.digest("hex")}function Xr(e,t){let r=Number(t);return Number.isFinite(r)&&r>0?Math.min(r*1e3,Je):Math.min(250*2**e,Je)+Math.floor(Math.random()*100)}var Yr=e=>new Promise(t=>setTimeout(t,e));function H(e,t={}){let r=new Error(e);return r.retryable=!1,Object.assign(r,t),r}function ke(e,t,r){return H(`HTTP response from ${e} exceeded maxResponseBytes ${r} (${t})`,{oversize:!0})}function z(e){try{let t=e?.body?.cancel?.();t&&typeof t.then=="function"&&t.catch(()=>{})}catch{}}function Zr(e){return e?e.byteLength??e.length??0:0}async function Qr(e,t,{url:r,truncate:o=!1,onOversize:n}={}){if(t==null)return await e.text();let s=Number(e.headers?.get?.("content-length"));if(Number.isFinite(s)&&s>t&&(z(e),!o))throw ke(r,`content-length ${s}`,t);let a=e.body?.getReader?.();if(!a){let d=await e.text(),h=Buffer.byteLength(d,"utf8");if(h>t){if(!o)throw ke(r,`body ${h} bytes`,t);return Buffer.from(d,"utf8").subarray(0,t).toString("utf8")}return d}let c=[],i=0,l=!1;try{for(;;){let{value:d,done:h}=await a.read();if(h)break;if(d&&(c.push(Buffer.from(d)),i+=Zr(d),i>t)){l=!0;break}}}finally{if(l)try{await a.cancel()}catch{}try{a.releaseLock?.()}catch{}}if(l&&(typeof n=="function"&&n(),!o))throw ke(r,`streamed ${i} bytes`,t);let u=Buffer.concat(c);return(l?u.subarray(0,t):u).toString("utf8")}function Jr(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}async function en(e,{fetchImpl:t,method:r,headers:o,body:n,timeoutMs:s,lookupFn:a,realFetch:c,untrustedUrl:i=!1,maxResponseBytes:l=null,sameOriginRedirectsOnly:u=!1,importUndici:d,validateResponse:h,signal:f,redirectPolicy:p="follow",maxRedirects:m=ae}){let b=null,y=t,x=a?{lookupFn:a}:{};if(i&&!c&&!xe(y))throw H(`HTTP refused ${e}: untrustedUrl requires a pin-capable fetchImpl (see markPinCapableFetch in egress-guard.mjs) or no fetchImpl override so Oracle can pin the connection itself`);let C=new AbortController,_=setTimeout(()=>C.abort(),s),O=f?tt?tt([f,C.signal]):f:C.signal,T=async(v,{status:I=null}={})=>{let S=await ve(v,x);if(!S.ok)throw H(I==null?`HTTP refused ${v}: ${S.error}`:`HTTP redirect to ${v} ${S.error}`,I==null?{}:{status:I});let L=new URL(v).hostname;if(c){if(b&&(await b.close(),b=null),!b)try{b=await Se({requireUndici:!0,...d?{importUndici:d}:{}})}catch(g){throw H(I==null?`HTTP refused ${v}: ${g?.message||g}`:`HTTP redirect to ${v} refused: ${g?.message||g}`,I==null?{}:{status:I})}b.pin(L,S.addresses),y=b.fetch}else Ze(y,L,S.addresses);return S};try{let v=String(e),I=Object.assign(Object.create(null),o||{});i&&await T(v);for(let S=0;S<=m;S+=1){let L=Object.assign(Object.create(null),{method:r,headers:I,body:n,signal:O,redirect:"manual",dispatcher:void 0}),g=await y(v,L);if((p==="error"||m===0)&&g.status>=300&&g.status<400)throw z(g),H(`HTTP ${g.status} ${r} redirect refused`,{status:g.status,redirectRefused:!0});if(Fr.has(g.status)){let U=u===!0&&r==="POST"&&[307,308].includes(g.status)&&st(r,n);if(r!=="GET"&&r!=="HEAD"&&!U){z(g);let R=new Error(`HTTP ${g.status} ${r} ${v} redirected non-idempotent request`);throw R.status=g.status,R}if(S===m)throw z(g),H(`HTTP ${g.status} ${r} redirect budget exhausted`,{status:g.status,redirectRefused:!0});let Fe=g.headers?.get?.("location"),$;try{$=Vr(Fe,v)}catch(R){throw z(g),R}let j=!zr($,v);if(z(g),j&&r==="POST"){let R=new Error(`HTTP ${g.status} ${r} cross-origin redirect refused`);throw R.status=g.status,R}if(j&&u){let R=new Error(`HTTP ${g.status} ${r} cross-origin redirect refused`);throw R.status=g.status,R.retryable=!1,R}if(j&&(I=jr(I)),i)await T($,{status:g.status});else if(j){let R=await ve($,x);if(!R.ok){let k=new Error(`HTTP redirect from ${v} ${R.error}`);throw k.status=g.status,k.retryable=!1,k}c&&R.addresses?.length&&(b||(b=await Se(d?{importUndici:d}:{})),b&&(b.pin(new URL($).hostname,R.addresses),y=b.fetch))}v=$;continue}if(typeof h=="function")try{await h(g,{url:v})}catch(U){throw z(g),H(U?.message||String(U))}let P=await Qr(g,l,{url:v,onOversize:()=>C.abort()}),K=Jr(P);if(!g.ok){let U=new Error(`HTTP ${g.status} ${r} ${v}`);throw U.status=g.status,U.retryAfter=g.headers?.get?.("retry-after")??null,U.body=K??P.slice(0,300),U}return K??P}throw new Error(`HTTP redirect loop for ${e}`)}catch(v){if(C.signal.aborted&&!Z(f)){let I=v&&(typeof v=="object"||typeof v=="function")&&!M.isProxy(v)?v:null,S=I?Object.getOwnPropertyDescriptor(I,"oversize"):null;if(!(S&&Object.hasOwn(S,"value")&&S.value===!0))try{if(!I)throw new TypeError("unsafe rejection");Object.defineProperties(I,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}})}catch{let g=new Error("HTTP request timed out");throw Object.defineProperties(g,{oracleTimeout:{value:!0,enumerable:!1},retryable:{value:!1,enumerable:!1}}),g}}throw v}finally{clearTimeout(_),b&&await b.close()}}async function ce(e,t={}){if(t!=null&&typeof t!="object"&&typeof t!="function")throw new TypeError("HTTP options must be an object");if(t!=null&&M.isProxy(t))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(t!=null){if(Object.getOwnPropertySymbols(t).length>0)throw new TypeError("HTTP options contain unknown fields");for(let k of Object.getOwnPropertyNames(t)){let A=Object.getOwnPropertyDescriptor(t,k);if(!(k==="toJSON"&&A&&Object.hasOwn(A,"value")&&A.value===void 0)){if(!r.has(k))throw new TypeError("HTTP options contain unknown fields");if(!A||!A.enumerable||!Object.hasOwn(A,"value"))throw new TypeError("HTTP options must contain enumerable own data properties")}}}let o=k=>{if(t==null||!Object.hasOwn(t,k))return;let A=Object.getOwnPropertyDescriptor(t,k);if(!A||!Object.hasOwn(A,"value"))throw new TypeError("HTTP options must contain own data properties");return A.value};if(typeof e!="string"||e.length===0||e.length>8192)throw new TypeError("HTTP URL must be a bounded string");let n=o("method");if(n!==void 0&&(typeof n!="string"||!/^[A-Za-z]+$/u.test(n)))throw new TypeError("HTTP method must be a string token");let s=o("timeoutMs");if(s!==void 0&&(!Number.isInteger(s)||s<1||s>12e4))throw new TypeError("HTTP timeoutMs must be a bounded integer");let a=o("retries");if(a!==void 0&&(!Number.isInteger(a)||a<0||a>10))throw new TypeError("HTTP retries must be a bounded integer");let c=o("redirectPolicy");if(c!==void 0&&c!=="follow"&&c!=="error")throw new TypeError('HTTP redirectPolicy must be "follow" or "error"');let i=o("maxRedirects");if(i!==void 0&&(!Number.isInteger(i)||i<0||i>ae))throw new TypeError(`HTTP maxRedirects must be an integer from 0 through ${ae}`);if(c==="error"&&i!==void 0&&i!==0)throw new TypeError('HTTP redirectPolicy "error" requires maxRedirects 0 when supplied');let l=c??"follow",u=l==="error"?0:i??ae;for(let k of["dedupe","untrustedUrl","sameOriginRedirectsOnly"]){let A=o(k);if(A!==void 0&&typeof A!="boolean")throw new TypeError(`HTTP ${k} must be boolean`)}let d=o("maxResponseBytes");if(d!==void 0&&(!Number.isInteger(d)||d<1||d>64*1024*1024))throw new TypeError("HTTP maxResponseBytes must be a bounded integer");let h=o("signal");if(h!==void 0){if(M.isProxy(h)||!(h instanceof AbortSignal))throw new TypeError("HTTP signal must be a native AbortSignal");try{Z(h)}catch{throw new TypeError("HTTP signal must be a native AbortSignal")}}for(let k of["importUndici","lookupFn","validateResponse"]){let A=o(k);if(A!==void 0&&typeof A!="function")throw new TypeError(`HTTP ${k} must be a function`)}let f=o("fetchImpl"),p=f||globalThis.fetch;if(typeof p!="function")throw new Error("fetch unavailable \u2014 pass opts.fetchImpl");let m=s??12e3,b=(n||"GET").toUpperCase(),y=o("headers"),x=Hr(y),C=Object.assign(Object.create(null),x);Object.keys(C).some(k=>k.toLowerCase()==="accept")||(C.Accept="application/json");let _=o("body");_!=null&&typeof _!="string"&&(Object.keys(C).find(A=>A.toLowerCase()==="content-type")||(C["Content-Type"]="application/json"),_=Mr(_));let O=a??Lr,T=o("lookupFn"),v=!f,I=o("untrustedUrl")===!0,S=o("sameOriginRedirectsOnly")===!0,L=o("importUndici"),g=o("validateResponse"),P=h,K=d??null,U=async()=>{let k;for(let A=0;A<=O;A++){P&&qr.call(P);let De=oe("http");try{let F=await en(e,{fetchImpl:p,method:b,headers:C,body:_,timeoutMs:m,lookupFn:T,realFetch:v,untrustedUrl:I,maxResponseBytes:K,sameOriginRedirectsOnly:S,importUndici:L,validateResponse:g,signal:P,redirectPolicy:l,maxRedirects:u});return De?.("succeeded"),F}catch(F){k=F;let G=ge=>{if(!F||typeof F!="object"&&typeof F!="function"||M.isProxy(F))return;let X=Object.getOwnPropertyDescriptor(F,ge);return X&&Object.hasOwn(X,"value")?X.value:void 0},re=G("status");De?.("failed",re);let Wt=G("oracleTimeout")===!0||G("name")==="AbortError"||G("name")==="TimeoutError"||Z(P),Gt=new Set([408,425,429]),Kt=G("retryable")===!1?!1:re!=null?Gt.has(re)||Rr.has(re)&&Qe.has(b):!Wt&&Qe.has(b);if(A===O||!Kt)throw F;let Me=Xr(A,G("retryAfter")),Xt=oe("retry"),He=!1;try{P?await new Promise((ge,X)=>{let je,Y=()=>{clearTimeout(je),et.call(P,"abort",Y),X($r(P)||new DOMException("Aborted","AbortError"))};if(Z(P)){Y();return}je=setTimeout(()=>{et.call(P,"abort",Y),ge()},Me),Br.call(P,"abort",Y,{once:!0}),Z(P)&&Y()}):await Yr(Me),He=!0}finally{Xt?.(He?"succeeded":"failed")}}}throw k};if(!(o("dedupe")!==!1&&!P&&st(b,_)))return U();let $=Kr(b,e,C,{untrustedUrl:I,maxResponseBytes:K,sameOriginRedirectsOnly:S,redirectPolicy:l,maxRedirects:u,timeoutMs:m,retries:O,fetchImpl:ie(p),realFetch:v,lookupFn:ie(T),importUndici:ie(L),validateResponse:ie(g)},_),j=Ce.get($);if(j){let k=oe("shared");try{let A=await j;return k?.("succeeded"),A}catch(A){throw k?.("failed"),A}}let R=U().finally(()=>Ce.delete($));return Ce.set($,R),R}async function it(e,t,r){let o=Array.from(e),n=Math.max(1,Math.min(Number(t)||1,o.length||1)),s=new Array(o.length),a=0;return await Promise.all(Array.from({length:n},async()=>{for(;a<o.length;){let c=a++;s[c]=await r(o[c],c)}})),s}var ue={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},elysium:{chainId:1339,name:"Elysium",rpcEnv:["ELYSIUM_RPC_URL"],evm:!0,readOnly:!0}};var at=new Map(Object.values(ue).map(e=>[e.chainId,e]));function ct(e){return at.get(Number(e))||null}function ut(e,t=process.env){let r=ct(e);if(!r)return null;for(let o of r.rpcEnv){let n=(t[o]||"").trim();if(n)return n}return null}function lt(e,t="prepare"){if(e==null||e==="")return;let r=String(e).trim().toLowerCase(),o=/^\d+$/.test(r)?at.get(Number(r)):ue[r];if(o?.readOnly===!0)throw new Error(`${t}: ${o.name} (${o.chainId}) is registered read-only \u2014 no venue, no prepare, no signer. UNSUPPORTED.`)}import{Interface as tn,getAddress as rn}from"ethers";var dt=new tn(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);function pt(e,t){try{return rn(e).toLowerCase()}catch{throw new Error(`${t} must be a valid EVM address`)}}var nn={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",1339:"https://rpc.elysiumchain.tech"};function on(e,{rpcUrl:t,env:r=process.env}={}){if(t)return t;let o=ut(e,r);return o||nn[Number(e)]||null}var sn=/^(?:eth_(?:call|blocknumber|chainid|get[a-z0-9]+|feehistory|gasprice|maxpriorityfeepergas|syncing|protocolversion|estimategas|createaccesslist)|net_(?:version|listening|peercount)|web3_(?:clientversion|sha3))$/;function an(e){let t=String(e||""),r=t.toLowerCase();if(t!==t.trim()||!/^[a-zA-Z0-9_]+$/.test(t)||!sn.test(r))throw new Error(`evm-rpc: ${t} refused \u2014 @oracle-agent/oracle is prepare-only (read RPC only; no broadcast/sign)`);return r}var Q=new Map,ft=new Map;function cn(e){let t=new Error(e?.message||JSON.stringify(e));return t.code=e?.code,t}function un(e){if(e?.error)throw cn(e.error);return e?.result}function ln(e,t,r){return`${e}
5
5
  ${t}
6
- ${JSON.stringify(r??[])}`}async function ln(e,t,r){return ce(e,{method:"POST",body:t,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function q(e,t,r=[],s={}){let n=String(t||""),o=sn(n),a=nn(e,s);if(!a)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);if(o==="eth_chainid"&&s.cacheChainId!==!1){let u=dt.get(a);if(u!=null)return u}let i=s.dedupe!==!1&&!s.signal?un(a,n,r):null;if(i&&Q.has(i))return Q.get(i);let l=(async()=>{let u=await ln(a,{jsonrpc:"2.0",id:1,method:t,params:r},s),d=cn(u);return o==="eth_chainid"&&typeof d=="string"&&dt.set(a,d),d})();return i&&(Q.set(i,l),l.finally(()=>{Q.get(i)===l&&Q.delete(i)}).catch(()=>{})),l}async function pt(e,t={}){let r=await q(e,"eth_blockNumber",[],t);return parseInt(r,16)}async function ft(e,t,r={}){if(!t)throw new Error("rpcGetBalance requires address");let s=await q(e,"eth_getBalance",[t,"latest"],r);return{chainId:Number(e),address:t,balanceWei:BigInt(s).toString(),balanceHex:s}}async function ht(e={},t={}){let r=Number(e.chainId??t.chainId??1),s=lt(e.token||e.tokenAddress,"token"),n=lt(e.account||e.owner||e.address,"account"),o=ut.encodeFunctionData("balanceOf",[n]),a=await q(r,"eth_call",[{to:s,data:o},e.blockTag||"latest"],t),c=ut.decodeFunctionResult("balanceOf",a),i=BigInt(c[0]);return{chainId:r,token:s,account:n,balance:i.toString(),balanceHex:`0x${i.toString(16)}`,blockTag:e.blockTag||"latest"}}var dn=new Set(["usdc","usdt","usdg","dai","usd1","usde","pyusd"]);function mt(e,t){let r=String(e||"").toLowerCase(),s=String(t?.quote||t?.quoteToken?.address||"").toLowerCase(),n=String(t?.base||t?.baseToken?.address||"").toLowerCase();return s===r?{address:t.base||t.baseToken?.address,symbol:t.baseToken?.symbol}:n===r?{address:t.quote||t.quoteToken?.address,symbol:t.quoteToken?.symbol}:{address:t.quote||t.quoteToken?.address,symbol:t.quoteToken?.symbol}}function ue(e,t=[],{stables:r=[],wrappedNative:s=null}={}){let n=String(e||"").toLowerCase(),o=new Set((r||[]).map(i=>String(i).toLowerCase())),a=String(s||"").toLowerCase(),c=(t||[]).map((i,l)=>{let u=mt(n,i),d=String(u.address||"").toLowerCase(),h=String(u.symbol||"").toLowerCase(),f=Number(i.liquidityUsd??i.liquidity?.usd),p=Number.isFinite(f)?f:0,m=String(i.dex||i.dexId||"").toLowerCase(),b=0;return o.has(d)||dn.has(h)?b=300:a&&d===a&&(b=100),m.includes("v4")?b+=20:m.includes("v3")?b+=10:(m.includes("v2")||m.includes("raydium")||m.includes("orca")||m.includes("meteora"))&&(b+=8),{pool:i,score:b*1e12+p,index:l,otherAddr:d,liquidityUsd:p}});return c.sort((i,l)=>l.score-i.score||i.index-l.index),c.map(i=>i.pool)}function bt(e,t=[]){let r=Array.isArray(t)?t:[];return r.length&&mt(e,r[0]).address||null}var pn="https://api.dexscreener.com",No=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function fn(e={}){return(e.baseUrl||process.env.DEXSCREENER_API_URL||pn).replace(/\/$/,"")}function hn(e,t){if(typeof e!="string"&&typeof e!="number")throw new Error(`${t} required`);let r=String(e).trim();if(!r||r.length>128||!/^[A-Za-z0-9][A-Za-z0-9._:+~-]*$/u.test(r))throw new Error(`${t} must be a valid path component of at most 128 characters`);return encodeURIComponent(r)}function mn(e,t){return ce(`${fn(t)}${e}`,{fetchImpl:t.fetchImpl,timeoutMs:t.timeoutMs??12e3})}async function Te(e,t={}){return mn(`/latest/dex/tokens/${hn(e,"tokenAddress")}`,t)}var bn=["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"];async function gt(e,{chainSlug:t="solana",stables:r=bn}={},s={}){let n=await Te(e,s),a=(n?.pairs||n?.data?.pairs||[]).filter(i=>String(i.chainId).toLowerCase()===String(t).toLowerCase()).map(i=>({pair:i.pairAddress,dex:i.dexId,dexId:i.dexId,base:i.baseToken?.address,quote:i.quoteToken?.address,baseToken:i.baseToken,quoteToken:i.quoteToken,liquidityUsd:i.liquidity?.usd??null,priceUsd:i.priceUsd??null,volume24hUsd:i.volume?.h24??null,createdAt:i.pairCreatedAt??null})),c=ue(e,a,{stables:r});return{chain:t,token:e,pools:c,topPool:c[0]||null}}var le=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),v=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),w=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),gn=/^0x[0-9a-fA-F]{40}$/;function wn(e={}){let t=[],r=[];if(!e||typeof e!="object")return{ok:!1,errors:["definition must be an object"],warnings:r};if((!Number.isInteger(e.chainId)||e.chainId<=0)&&t.push("chainId must be a positive integer"),(typeof e.key!="string"||!/^[a-z][a-z0-9-]*$/.test(e.key||""))&&t.push('key must be a lowercase slug (e.g. "base")'),(typeof e.name!="string"||!e.name.trim())&&t.push("name is required"),!Array.isArray(e.rpcEnv)||e.rpcEnv.length===0)t.push("rpcEnv must list at least one environment variable name");else for(let n of e.rpcEnv)(typeof n!="string"||!/^[A-Z][A-Z0-9_]*$/.test(n))&&t.push(`rpcEnv entry "${n}" should be an UPPER_SNAKE env var name`);if(e.nativeCurrency){let n=e.nativeCurrency;(typeof n.symbol!="string"||!n.symbol)&&t.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(n.decimals)||t.push("nativeCurrency.decimals must be an integer")}for(let[n,o]of(e.venues||[]).entries()){let a=`venues[${n}]`;if(!o||typeof o!="object"){t.push(`${a} must be an object`);continue}gn.test(o.address||"")||t.push(`${a}.address is not a valid 20-byte address`),/^0x0{40}$/.test(o.address||"")&&t.push(`${a}.address is the zero address -- placeholder left in place?`),o.kind||t.push(`${a}.kind is required (router|quoter|factory|...)`),o.verified?(o.verified.method||t.push(`${a}.verified.method is required`),o.verified.source||t.push(`${a}.verified.source is required`),o.verified.date||r.push(`${a}.verified.date missing -- add one so staleness is visible`)):t.push(`${a} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let s=e.capabilities||{};for(let n of Object.keys(s))le.includes(n)?typeof s[n]!="function"&&t.push(`capability "${n}" must be a function`):t.push(`unknown capability "${n}"`);return Object.keys(s).length===0&&r.push("scanner implements no capabilities -- it can only be registered, not used"),s.prepareUnsignedTx&&!s.quote&&r.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),s.prepareUnsignedTx&&!s.sellSimulation&&r.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:t.length===0,errors:t,warnings:r}}function yn(e){let{ok:t,errors:r,warnings:s}=wn(e);if(!t)throw new Error(`invalid scanner for ${e?.key??"<unknown>"}:
6
+ ${JSON.stringify(r??[])}`}async function dn(e,t,r){return ce(e,{method:"POST",body:t,fetchImpl:r.fetchImpl,timeoutMs:r.timeoutMs??12e3,signal:r.signal})}async function q(e,t,r=[],o={}){let n=String(t||""),s=an(n),a=on(e,o);if(!a)throw new Error(`No RPC URL for chainId ${e} (set env from chain registry rpcEnv or pass rpcUrl)`);if(s==="eth_chainid"&&o.cacheChainId!==!1){let u=ft.get(a);if(u!=null)return u}let i=o.dedupe!==!1&&!o.signal?ln(a,n,r):null;if(i&&Q.has(i))return Q.get(i);let l=(async()=>{let u=await dn(a,{jsonrpc:"2.0",id:1,method:t,params:r},o),d=un(u);return s==="eth_chainid"&&typeof d=="string"&&ft.set(a,d),d})();return i&&(Q.set(i,l),l.finally(()=>{Q.get(i)===l&&Q.delete(i)}).catch(()=>{})),l}async function ht(e,t={}){let r=await q(e,"eth_blockNumber",[],t);return parseInt(r,16)}async function mt(e,t,r={}){if(!t)throw new Error("rpcGetBalance requires address");let o=await q(e,"eth_getBalance",[t,"latest"],r);return{chainId:Number(e),address:t,balanceWei:BigInt(o).toString(),balanceHex:o}}async function bt(e={},t={}){let r=Number(e.chainId??t.chainId??1),o=pt(e.token||e.tokenAddress,"token"),n=pt(e.account||e.owner||e.address,"account"),s=dt.encodeFunctionData("balanceOf",[n]),a=await q(r,"eth_call",[{to:o,data:s},e.blockTag||"latest"],t),c=dt.decodeFunctionResult("balanceOf",a),i=BigInt(c[0]);return{chainId:r,token:o,account:n,balance:i.toString(),balanceHex:`0x${i.toString(16)}`,blockTag:e.blockTag||"latest"}}var pn=new Set(["usdc","usdt","usdg","dai","usd1","usde","pyusd"]);function gt(e,t){let r=String(e||"").toLowerCase(),o=String(t?.quote||t?.quoteToken?.address||"").toLowerCase(),n=String(t?.base||t?.baseToken?.address||"").toLowerCase();return o===r?{address:t.base||t.baseToken?.address,symbol:t.baseToken?.symbol}:n===r?{address:t.quote||t.quoteToken?.address,symbol:t.quoteToken?.symbol}:{address:t.quote||t.quoteToken?.address,symbol:t.quoteToken?.symbol}}function le(e,t=[],{stables:r=[],wrappedNative:o=null}={}){let n=String(e||"").toLowerCase(),s=new Set((r||[]).map(i=>String(i).toLowerCase())),a=String(o||"").toLowerCase(),c=(t||[]).map((i,l)=>{let u=gt(n,i),d=String(u.address||"").toLowerCase(),h=String(u.symbol||"").toLowerCase(),f=Number(i.liquidityUsd??i.liquidity?.usd),p=Number.isFinite(f)?f:0,m=String(i.dex||i.dexId||"").toLowerCase(),b=0;return s.has(d)||pn.has(h)?b=300:a&&d===a&&(b=100),m.includes("v4")?b+=20:m.includes("v3")?b+=10:(m.includes("v2")||m.includes("raydium")||m.includes("orca")||m.includes("meteora"))&&(b+=8),{pool:i,score:b*1e12+p,index:l,otherAddr:d,liquidityUsd:p}});return c.sort((i,l)=>l.score-i.score||i.index-l.index),c.map(i=>i.pool)}function wt(e,t=[]){let r=Array.isArray(t)?t:[];return r.length&&gt(e,r[0]).address||null}var fn="https://api.dexscreener.com",Ro=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});function hn(e={}){return(e.baseUrl||process.env.DEXSCREENER_API_URL||fn).replace(/\/$/,"")}function mn(e,t){if(typeof e!="string"&&typeof e!="number")throw new Error(`${t} required`);let r=String(e).trim();if(!r||r.length>128||!/^[A-Za-z0-9][A-Za-z0-9._:+~-]*$/u.test(r))throw new Error(`${t} must be a valid path component of at most 128 characters`);return encodeURIComponent(r)}function bn(e,t){return ce(`${hn(t)}${e}`,{fetchImpl:t.fetchImpl,timeoutMs:t.timeoutMs??12e3})}async function Te(e,t={}){return bn(`/latest/dex/tokens/${mn(e,"tokenAddress")}`,t)}var gn=["EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v","Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB"];async function yt(e,{chainSlug:t="solana",stables:r=gn}={},o={}){let n=await Te(e,o),a=(n?.pairs||n?.data?.pairs||[]).filter(i=>String(i.chainId).toLowerCase()===String(t).toLowerCase()).map(i=>({pair:i.pairAddress,dex:i.dexId,dexId:i.dexId,base:i.baseToken?.address,quote:i.quoteToken?.address,baseToken:i.baseToken,quoteToken:i.quoteToken,liquidityUsd:i.liquidity?.usd??null,priceUsd:i.priceUsd??null,volume24hUsd:i.volume?.h24??null,createdAt:i.pairCreatedAt??null})),c=le(e,a,{stables:r});return{chain:t,token:e,pools:c,topPool:c[0]||null}}var de=Object.freeze(["blockNumber","nativeBalance","tokenBalance","resolveToken","resolvePools","scanBlocks","scoreRisk","quote","sellSimulation","prepareUnsignedTx"]),E=Object.freeze({LIVE:"LIVE",CACHED:"CACHED",STALE:"STALE",UNKNOWN:"UNKNOWN",UNAVAILABLE:"UNAVAILABLE"}),w=Object.freeze({PASS:"PASS",CAUTION:"CAUTION",FAIL:"FAIL",UNKNOWN:"UNKNOWN"}),wn=/^0x[0-9a-fA-F]{40}$/;function yn(e={}){let t=[],r=[];if(!e||typeof e!="object")return{ok:!1,errors:["definition must be an object"],warnings:r};if((!Number.isInteger(e.chainId)||e.chainId<=0)&&t.push("chainId must be a positive integer"),(typeof e.key!="string"||!/^[a-z][a-z0-9-]*$/.test(e.key||""))&&t.push('key must be a lowercase slug (e.g. "base")'),(typeof e.name!="string"||!e.name.trim())&&t.push("name is required"),!Array.isArray(e.rpcEnv)||e.rpcEnv.length===0)t.push("rpcEnv must list at least one environment variable name");else for(let n of e.rpcEnv)(typeof n!="string"||!/^[A-Z][A-Z0-9_]*$/.test(n))&&t.push(`rpcEnv entry "${n}" should be an UPPER_SNAKE env var name`);if(e.nativeCurrency){let n=e.nativeCurrency;(typeof n.symbol!="string"||!n.symbol)&&t.push("nativeCurrency.symbol is required when nativeCurrency is set"),Number.isInteger(n.decimals)||t.push("nativeCurrency.decimals must be an integer")}for(let[n,s]of(e.venues||[]).entries()){let a=`venues[${n}]`;if(!s||typeof s!="object"){t.push(`${a} must be an object`);continue}wn.test(s.address||"")||t.push(`${a}.address is not a valid 20-byte address`),/^0x0{40}$/.test(s.address||"")&&t.push(`${a}.address is the zero address -- placeholder left in place?`),s.kind||t.push(`${a}.kind is required (router|quoter|factory|...)`),s.verified?(s.verified.method||t.push(`${a}.verified.method is required`),s.verified.source||t.push(`${a}.verified.source is required`),s.verified.date||r.push(`${a}.verified.date missing -- add one so staleness is visible`)):t.push(`${a} must record verification: { verified: { method, source, date } }. An unverified venue stays blocked.`)}let o=e.capabilities||{};for(let n of Object.keys(o))de.includes(n)?typeof o[n]!="function"&&t.push(`capability "${n}" must be a function`):t.push(`unknown capability "${n}"`);return Object.keys(o).length===0&&r.push("scanner implements no capabilities -- it can only be registered, not used"),o.prepareUnsignedTx&&!o.quote&&r.push("prepareUnsignedTx without quote: no priced expectation to validate the built tx against"),o.prepareUnsignedTx&&!o.sellSimulation&&r.push("prepareUnsignedTx without sellSimulation: cannot prove an asset is exitable before buying"),{ok:t.length===0,errors:t,warnings:r}}function En(e){let{ok:t,errors:r,warnings:o}=yn(e);if(!t)throw new Error(`invalid scanner for ${e?.key??"<unknown>"}:
7
7
  - ${r.join(`
8
- - `)}`);let n=e.capabilities||{},o=le.filter(c=>typeof n[c]=="function"),a={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,wrappedNative:e.wrappedNative||null,explorer:e.explorer||null,venues:(e.venues||[]).map(c=>({...c})),warnings:s,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...o],unsupported:le.filter(c=>!o.includes(c))}},supports(c){return o.includes(c)}};for(let c of le)o.includes(c)?a[c]=async(...i)=>n[c](...i,{scanner:a}):a[c]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${c}". 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 wt=new Map;function yt(e){let t=yn(e);return wt.set(t.chainId,t),t}function vt(e){return wt.get(Number(e))||null}var _e={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},B=e=>BigInt(e).toString(16).padStart(64,"0"),J=e=>e.slice(2).toLowerCase().padStart(64,"0");function vn(e,t){return`0x${_e.getAmountsOut}`+B(e)+B(64)+B(t.length)+t.map(J).join("")}function En(e){if(!e||e==="0x")return null;let t=e.slice(2);if(t.length<128)return null;let r=Number(BigInt(`0x${t.slice(64,128)}`));if(!Number.isFinite(r)||r<1||r>16)return null;let s=[];for(let n=0;n<r;n++){let o=128+n*64;if(t.length<o+64)return null;s.push(BigInt(`0x${t.slice(o,o+64)}`))}return s}function Ie(e,t="router"){return(e?.venues||[]).find(s=>s.kind===t)?.address??null}var Oe=100;function Sn(e,t){let r=Number(t);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Oe)throw new Error(`slippageBps ${r} exceeds the ${Oe} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(r))/10000n}function Et(e){let{chainId:t,wrappedNative:r}=e;async function s(n,o,a,c){let i=await q(t,"eth_call",[{to:n,data:vn(o,a)},"latest"],c);return En(i?.result??i)}return{async quote({tokenIn:n,tokenOut:o,amountIn:a,path:c},i={}){let l=Ie(i.scanner);if(!l)return{chainId:t,evidence:v.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let u=c||[n,o];if(u.some(h=>!/^0x[0-9a-fA-F]{40}$/.test(h||"")))throw new Error("quote requires valid 20-byte addresses");let d=await s(l,a,u,i);return d?{chainId:t,router:l,path:u,amountIn:String(a),amountOut:d[d.length-1].toString(),hops:u.length-1,evidence:v.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:t,router:l,path:u,evidence:v.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:o,base:a},c={}){let i=Ie(c.scanner),l=a||r;if(l&&String(n).toLowerCase()===String(l).toLowerCase())return{chainId:t,token:n,verdict:w.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!i||!l)return{chainId:t,token:n,verdict:w.UNKNOWN,evidence:v.UNAVAILABLE,reason:i?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let u=await s(i,o,[l,n],c);if(!u)return{chainId:t,token:n,verdict:w.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let d=u[u.length-1];if(d===0n)return{chainId:t,token:n,verdict:w.FAIL,evidence:v.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let h=await s(i,d,[n,l],c);if(!h)return{chainId:t,token:n,verdict:w.FAIL,evidence:v.LIVE,leg:"sell",bought:d.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=h[h.length-1],p=Number(f*10000n/BigInt(o)),m=w.PASS,b="round trip completes with expected fee/impact loss";return p<5e3?(m=w.FAIL,b=`round trip returns only ${(p/100).toFixed(2)}% -- punitive tax or no real liquidity`):p<9e3&&(m=w.CAUTION,b=`round trip returns ${(p/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,token:n,base:l,router:i,verdict:m,reason:b,amountIn:String(o),bought:d.toString(),returned:f.toString(),retentionBps:p,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:o,amountIn:a,recipient:c,slippageBps:i=50,deadlineSeconds:l=900,path:u},d={}){let h=d.scanner,f=Ie(h);if(!f)throw new Error(`chain ${t} 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(c||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let p=u||[n,o],m=await this.quote({tokenIn:n,tokenOut:o,amountIn:a,path:p},d);if(m.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${m.evidence}: ${m.reason??"no reason given"})`);let b=Sn(m.amountOut,i);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let y=BigInt(Math.floor(Date.now()/1e3)+Number(l)),x=r&&p[0].toLowerCase()===r.toLowerCase()&&d.useNative,C=x?`0x${_e.swapExactETHForTokens}`+B(b)+B(128)+J(c)+B(y)+B(p.length)+p.map(J).join(""):`0x${_e.swapExactTokensForTokens}`+B(a)+B(b)+B(160)+J(c)+B(y)+B(p.length)+p.map(J).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:t,tx:{to:f,data:C,value:x?`0x${BigInt(a).toString(16)}`:"0x0"},guard:{quotedOut:m.amountOut,minOut:b.toString(),slippageBps:i,maxSlippageBps:Oe,deadline:y.toString()},requires:x?[]:[{step:"approve",token:p[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 An=[100,500,3e3,1e4],St={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},W=e=>BigInt(e).toString(16).padStart(64,"0"),ee=e=>e.slice(2).toLowerCase().padStart(64,"0"),At=/^0x[0-9a-fA-F]{40}$/,Re=100;function xn(e,t){let r=Number(t);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Re)throw new Error(`slippageBps ${r} exceeds the ${Re} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(r))/10000n}function Ne(e,t){return(e?.venues||[]).find(r=>r.kind===t)?.address??null}function xt(e){let{chainId:t,wrappedNative:r}=e;async function s({quoter:o,tokenIn:a,tokenOut:c,amountIn:i,fee:l},u){let d=`0x${St.quoteExactInputSingle}`+ee(a)+ee(c)+W(i)+W(l)+W(0),h=await q(t,"eth_call",[{to:o,data:d},"latest"],u).catch(()=>null),f=h?.result??h;if(!f||f==="0x"||f.length<66)return null;let p=BigInt(`0x${f.slice(2,66)}`);return p>0n?p:null}async function n({quoter:o,tokenIn:a,tokenOut:c,amountIn:i},l){let u=await Promise.all(An.map(async h=>{let f=await s({quoter:o,tokenIn:a,tokenOut:c,amountIn:i,fee:h},l);return{fee:h,amountOut:f?f.toString():null,out:f}})),d=null;for(let h of u)h.out&&(!d||h.out>d.amountOut)&&(d={fee:h.fee,amountOut:h.out});return{best:d,tried:u.map(({fee:h,amountOut:f})=>({fee:h,amountOut:f}))}}return{async quote({tokenIn:o,tokenOut:a,amountIn:c},i={}){let l=Ne(i.scanner,"quoter");if(!l)return{chainId:t,evidence:v.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let h of[o,a])if(!At.test(h||""))throw new Error("quote requires valid 20-byte addresses");let{best:u,tried:d}=await n({quoter:l,tokenIn:o,tokenOut:a,amountIn:c},i);return u?{chainId:t,venue:"uniswap-v3",quoter:l,tokenIn:o,tokenOut:a,amountIn:String(c),amountOut:u.amountOut.toString(),fee:u.fee,useNative:!!r&&String(o).toLowerCase()===String(r).toLowerCase(),triedFeeTiers:d,evidence:v.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:t,quoter:l,tokenIn:o,tokenOut:a,triedFeeTiers:d,evidence:v.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:o,amountIn:a,base:c},i={}){let l=Ne(i.scanner,"quoter"),u=(e.stableQuoteAssets||[]).map(O=>String(O).toLowerCase()),d=null;!c&&typeof e.resolveQuoteAsset=="function"&&(d=await e.resolveQuoteAsset(o,i).catch(()=>null));let h=String(o).toLowerCase(),f=String(r||"").toLowerCase();if(f&&h===f)return{chainId:t,token:o,verdict:w.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};let p=c||d||(u[0]&&h!==u[0]?u[0]:null)||r;if(p&&h===String(p).toLowerCase())return{chainId:t,token:o,verdict:w.UNKNOWN,evidence:v.UNAVAILABLE,reason:"token is the base asset for this chain, so there is nothing to round-trip against. Sellability must be judged against a different quote asset."};if(!l||!p)return{chainId:t,token:o,verdict:w.UNKNOWN,evidence:v.UNAVAILABLE,reason:l?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let m=await n({quoter:l,tokenIn:p,tokenOut:o,amountIn:a},i);if(!m.best){let O=u.find(T=>T&&T!==String(p).toLowerCase()&&T!==String(o).toLowerCase());if(O){let T=await n({quoter:l,tokenIn:O,tokenOut:o,amountIn:a},i);if(T.best){let E=await n({quoter:l,tokenIn:o,tokenOut:O,amountIn:T.best.amountOut},i);if(E.best){let I=E.best.amountOut,S=Number(I*10000n/BigInt(a)),L=w.PASS,g="round trip vs dollar book completes with expected fee/impact loss";return S<5e3?(L=w.FAIL,g=`round trip vs dollar book returns only ${(S/100).toFixed(2)}% -- punitive tax or no real liquidity`):S<9e3&&(L=w.CAUTION,g=`round trip vs dollar book returns ${(S/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:L,reason:g,amountIn:String(a),bought:T.best.amountOut.toString(),returned:I.toString(),retentionBps:S,buyFee:T.best.fee,sellFee:E.best.fee,evidence:v.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:t,token:o,verdict:w.FAIL,evidence:v.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let b=await n({quoter:l,tokenIn:o,tokenOut:p,amountIn:m.best.amountOut},i);if(!b.best){let O=u.find(T=>T&&T!==String(p).toLowerCase()&&T!==String(o).toLowerCase());if(O){let T=await n({quoter:l,tokenIn:O,tokenOut:o,amountIn:a},i),E=T.best?await n({quoter:l,tokenIn:o,tokenOut:O,amountIn:T.best.amountOut},i):{best:null};if(T.best&&E.best){let I=E.best.amountOut,S=Number(I*10000n/BigInt(a)),L=w.PASS,g="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return S<5e3?(L=w.FAIL,g=`dollar-book round trip returns only ${(S/100).toFixed(2)}%`):S<9e3&&(L=w.CAUTION,g=`dollar-book round trip returns ${(S/100).toFixed(2)}%`),{chainId:t,venue:"uniswap-v3",token:o,base:O,quoteAsset:O,verdict:L,reason:g,amountIn:String(a),bought:T.best.amountOut.toString(),returned:I.toString(),retentionBps:S,buyFee:T.best.fee,sellFee:E.best.fee,evidence:v.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:t,token:o,verdict:w.FAIL,evidence:v.LIVE,leg:"sell",bought:m.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let y=b.best.amountOut,x=Number(y*10000n/BigInt(a)),C=w.PASS,_="round trip completes with expected fee/impact loss";return x<5e3?(C=w.FAIL,_=`round trip returns only ${(x/100).toFixed(2)}% -- punitive tax or no real liquidity`):x<9e3&&(C=w.CAUTION,_=`round trip returns ${(x/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,venue:"uniswap-v3",token:o,base:p,verdict:C,reason:_,amountIn:String(a),bought:m.best.amountOut.toString(),returned:y.toString(),retentionBps:x,buyFee:m.best.fee,sellFee:b.best.fee,evidence:v.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:o,tokenOut:a,amountIn:c,recipient:i,slippageBps:l=50,fee:u},d={}){let h=Ne(d.scanner,"router");if(!h)throw new Error(`chain ${t} 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(!At.test(i||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:o,tokenOut:a,amountIn:c},d);if(f.evidence!==v.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let p=u??f.fee,m=xn(f.amountOut,l);if(m<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let b=!!(d.useNative||f.useNative)&&r&&String(o).toLowerCase()===String(r).toLowerCase(),y=`0x${St.exactInputSingle}`+ee(o)+ee(a)+W(p)+ee(i)+W(c)+W(m)+W(0);return{unsigned:!0,signedBy:"user-wallet",chainId:t,venue:"uniswap-v3",tx:{to:h,data:y,value:b?String(c):"0x0"},guard:{quotedOut:f.amountOut,minOut:m.toString(),slippageBps:l,maxSlippageBps:Re,fee:p},requires:b?[]:[{step:"approve",token:o,spender:h,amount:String(c)}],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 de={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function Ct(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function kt(e){if(!e||e==="0x")return null;let t=e.slice(2);if(t.length>=128){let s=Number(BigInt(`0x${t.slice(64,128)}`));if(s>0&&s<=256&&t.length>=128+s*2){let n=t.slice(128,128+s*2),o=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(o)return o}}return Buffer.from(t.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function Cn(e){let{chainId:t}=e;async function r(s,n,o){return q(t,"eth_call",[{to:s,data:n},"latest"],o)}return{async blockNumber(s={}){let n=await pt(t,s);return{chainId:t,blockNumber:n?.blockNumber??n,evidence:v.LIVE}},async nativeBalance(s,n={}){let o=await ft(t,s,n);return{chainId:t,address:s,wei:o?.wei??o?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:v.LIVE}},async tokenBalance({token:s,owner:n},o={}){let a=await ht({chainId:t,token:s,owner:n},o);return{chainId:t,token:s,owner:n,raw:a?.balance??a,evidence:v.LIVE}},async resolveToken(s,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(s||""))return{chainId:t,token:s,evidence:v.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[o,a,c,i]=await Promise.all([r(s,de.decimals,n).catch(()=>null),r(s,de.symbol,n).catch(()=>null),r(s,de.name,n).catch(()=>null),r(s,de.totalSupply,n).catch(()=>null)]),l=Ct(o?.result??o),u=l!==null||a?.result||c?.result,d={chainId:t,address:s,decimals:l===null?null:Number(l),symbol:kt(a?.result??a),name:kt(c?.result??c),totalSupply:(Ct(i?.result??i)??null)?.toString()??null,evidence:u?v.LIVE:v.UNKNOWN};return u||(d.warning="no ERC-20 metadata returned -- may not be a token contract"),d},async resolvePools(s,n={}){let o=e.dexscreenerSlug;if(!o)return{chainId:t,token:s,pools:[],evidence:v.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let a=await Te(s,n).catch(()=>null),i=(a?.pairs||a?.data?.pairs||[]).filter(u=>String(u.chainId).toLowerCase()===String(o).toLowerCase()).map(u=>({pair:u.pairAddress,dex:u.dexId,base:u.baseToken?.address,quote:u.quoteToken?.address,liquidityUsd:u.liquidity?.usd??null,priceUsd:u.priceUsd??null,volume24hUsd:u.volume?.h24??null,createdAt:u.pairCreatedAt??null})).sort((u,d)=>(d.liquidityUsd??0)-(u.liquidityUsd??0)),l=ue(s,i,{stables:e.stableQuoteAssets||[],wrappedNative:e.wrappedNative});return{chainId:t,token:s,pools:l,topPool:l[0]||null,quoteAsset:bt(s,l),evidence:l.length?v.LIVE:v.UNKNOWN}},async scanBlocks({fromBlock:s,toBlock:n,address:o,topics:a,chunkSize:c=2e3}={},i={}){if(!Number.isInteger(s)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<s)throw new Error("toBlock must be >= fromBlock");let l=[],u=[];for(let h=s;h<=n;h+=c){let f=Math.min(h+c-1,n);u.push([h,f])}let d=await it(u,4,async([h,f])=>{let p={fromBlock:`0x${h.toString(16)}`,toBlock:`0x${f.toString(16)}`};o&&(p.address=o),a&&(p.topics=a);let m=await q(t,"eth_getLogs",[p],i).catch(b=>({error:String(b?.message||b)}));return{start:h,end:f,res:m}});for(let{start:h,end:f,res:p}of d){if(p?.error)return{chainId:t,fromBlock:s,toBlock:n,logs:l,complete:!1,failedAt:[h,f],error:p.error,evidence:v.UNKNOWN};for(let m of p?.result??p??[])l.push(m)}return{chainId:t,fromBlock:s,toBlock:n,logs:l,complete:!0,chunks:u.length,evidence:v.LIVE}},async scoreRisk(s,n={}){let o=[],a=w.PASS,c=u=>{let d={[w.PASS]:0,[w.CAUTION]:1,[w.UNKNOWN]:2,[w.FAIL]:3};d[u]>d[a]&&(a=u)},[i,l]=await Promise.all([this.resolveToken(s,n),this.resolvePools(s,n)]);if(i.evidence!==v.LIVE?(o.push({check:"erc20-metadata",result:w.UNKNOWN,detail:i.warning}),c(w.UNKNOWN)):o.push({check:"erc20-metadata",result:w.PASS,detail:`${i.symbol} / ${i.decimals}d`}),l.evidence===v.UNAVAILABLE)o.push({check:"liquidity",result:w.UNKNOWN,detail:l.reason}),c(w.UNKNOWN);else if(!l.pools.length)o.push({check:"liquidity",result:w.FAIL,detail:"no pool with liquidity found"}),c(w.FAIL);else{let u=l.pools[0],d=u.liquidityUsd??0;d<5e3?(o.push({check:"liquidity",result:w.CAUTION,detail:`top pool only $${d}`}),c(w.CAUTION)):o.push({check:"liquidity",result:w.PASS,detail:`$${d} on ${u.dex}`}),u.createdAt&&Date.now()-u.createdAt<24*3600*1e3&&(o.push({check:"age",result:w.CAUTION,detail:"pool under 24h old"}),c(w.CAUTION))}if(typeof this.sellSimulation=="function"){let u=await this.sellSimulation({token:s,amountIn:(10n**16n).toString()},n).catch(d=>({verdict:w.UNKNOWN,reason:String(d?.message||d)}));o.push({check:"sellability",result:u.verdict,detail:u.retentionBps!=null?`round trip returns ${(u.retentionBps/100).toFixed(2)}% -- ${u.reason}`:u.reason}),c(u.verdict)}else o.push({check:"sellability",result:w.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."}),c(w.UNKNOWN);return{chainId:t,token:s,verdict:a,checks:o,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function Tt(e){let r={...Cn(e)},s=new Set((e.venues||[]).map(o=>o.kind));e.venueKind==="uniswap-v3"&&s.has("quoter")&&s.has("router")?Object.assign(r,xt({chainId:e.chainId,wrappedNative:e.wrappedNative,stableQuoteAssets:e.stableQuoteAssets||[],resolveQuoteAsset:async(o,a)=>(await r.resolvePools(o,a)).quoteAsset||null})):e.venueKind==="uniswap-v2"&&s.has("router")&&Object.assign(r,Et({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[o,a]of Object.entries(r))n[o]=a.bind(r);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var It=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 _t(){return It.map(e=>yt(Tt(e)))}import{createHash as _n,createHmac as Rt,timingSafeEqual as On}from"node:crypto";import{readFileSync as kn}from"node:fs";import{homedir as Tn}from"node:os";import{join as pe}from"node:path";function In(){if(process.env.ORACLE_TEST_ISOLATE_SECRETS==="1"){let r=(process.env.ORACLE_EXEC_ENV_FILE||"").trim();return r?[r]:[]}let e=(process.env.ORACLE_EXEC_ENV_FILE||process.env.MAD_EXEC_ENV_FILE||"").trim(),t=Tn();if(process.env.ORACLE_PUBLIC_DESKTOP==="1"){let r=(process.env.ORACLE_CONFIG_DIR||pe(t,".config","oracle")).trim();return[e,pe(r,"exec.env")].filter(Boolean)}return[e,pe(t,".config","oracle","exec.env"),pe(t,".config","mad-desk","exec.env")].filter(Boolean)}function Ot(e,t,r){let s=e??process.env[t]??process.env[r];if(!String(s||"").trim())for(let n of In())try{let o=kn(n,"utf8"),a=o.match(new RegExp(`^${t}=(.*)$`,"m"))||o.match(new RegExp(`^${r}=(.*)$`,"m"));if(a&&(s=a[1].trim(),s))break}catch{}if(!String(s||"").trim())throw new Error(`${t} required for attestation. Set it in the environment, or place ${t}=<value> in ~/.config/oracle/exec.env`);return s}var fe=100,Nt=2e4;function he(e){return Array.isArray(e)?`[${e.map(he).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${he(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function Lt(e,{required:t=!1}={}){try{return Ot(e,"ORACLE_ROUTE_ATTESTATION_SECRET","MAD_ROUTE_ATTESTATION_SECRET")}catch(r){if(t)throw r;return null}}function Pe(e){let{signature:t,...r}=e;return r}function Pt(e,{secret:t}={}){let r=Lt(t);return r?{...e,signature:Rt("sha256",r).update(he(Pe(e))).digest("hex")}:e}function Nn(e){let t=String(e||"").toLowerCase();if(!/^0x[0-9a-f]+$/.test(t)||t.length<10||t.length%2!==0)throw new Error("auto-slippage calldata must be even-length hex with a selector");return _n("sha256").update(Buffer.from(t.slice(2),"hex")).digest("hex")}function Ut(e,{chainId:t,venue:r,data:s,secret:n}={}){if(!e||e.mode!=="auto")throw new Error("bounded auto-slippage guard required");if(Number(e.chainId)!==Number(t))throw new Error("auto-slippage guard chain mismatch");if(String(e.venue).toLowerCase()!==String(r||"").toLowerCase())throw new Error("auto-slippage guard venue mismatch");let o=Lt(n);if(o){let f=Rt("sha256",o).update(he(Pe(e))).digest("hex");if(!Rn(e.signature,f))throw new Error("auto-slippage guard signature mismatch \u2014 refusing to bind a guard this Oracle did not issue")}let a=Number(e.selectedBps),c=Number(e.capBps);if(!Number.isInteger(a)||a<0||a>fe||!Number.isInteger(c)||c<0||c>fe||a>c)throw new Error("auto-slippage guard bounds are invalid");let i=BigInt(e.quoteAmountOut??0),l=BigInt(e.minAmountOut??0);if(i<=0n||l<=0n)throw new Error("auto-slippage guard amounts must be positive");let u=i*BigInt(1e4-a),d=u/10000n;if(u%10000n!==0n&&(d+=1n),l<d)throw new Error("auto-slippage guard is under-protected relative to its quote");let h=Un(s);if(h!=null&&h!==l)throw new Error(`auto-slippage: calldata encodes floor ${h}, not the guard floor ${l} \u2014 refusing to bind`);return Pt({...Pe(e),calldataHash:Nn(s)},{secret:n})}function Rn(e,t){let r=Buffer.from(String(e??""),"utf8"),s=Buffer.from(String(t??""),"utf8");return r.length!==s.length||r.length===0?!1:On(r,s)}function Le(e,t=0){let r=Number(e);return Number.isFinite(r)?r:t}function Ln(e){let t=e==null?fe:Number(e);if(!Number.isInteger(t)||t<0)throw new Error("auto-slippage cap must be a non-negative integer bps value");return Math.min(t,fe)}function Pn({liquidityUsd:e,priceChange5m:t=0,quoteAgeMs:r=0,crossChain:s=!1,requestedCapBps:n}={}){let o=Le(e,0),a=o>0?o>=25e4?5:o>=1e5?10:o>=5e4?20:o>=1e4?40:70:s?30:10,c=Math.min(60,Math.abs(Le(t,0))*2),i=Math.min(40,Math.floor(Math.max(0,Le(r,0))/5e3)*5),l=Math.max(25,Math.ceil(20+a+c+i)),u=Ln(n);return{mode:"auto",requiredBps:l,selectedBps:Math.min(l,u),capBps:u,executable:l<=u}}function qt({chainId:e,venue:t,quoteAmountOut:r,liquidityUsd:s,priceChange5m:n=0,quoteAgeMs:o=0,crossChain:a=!1,requestedCapBps:c,quotedAtMs:i=Date.now(),ttlMs:l=Nt,secret:u}={}){let d=BigInt(r??0);if(d<=0n)throw new Error("auto-slippage guard requires positive quoteAmountOut");let h=Pn({liquidityUsd:s,priceChange5m:n,quoteAgeMs:o,crossChain:a,requestedCapBps:c});if(!h.executable)throw new Error(`auto-slippage requires ${h.requiredBps} bps above hard/requested cap ${h.capBps}; route blocked`);let f=Number(i);if(!Number.isFinite(f))throw new Error("auto-slippage: quotedAtMs must be a finite number");let p=Math.min(3e4,Math.max(1e3,Number(l)||Nt)),m=d*BigInt(1e4-h.selectedBps),b=m/10000n;if(m%10000n!==0n&&(b+=1n),b>d&&(b=d),d>0n&&b<=0n)throw new Error(`auto-slippage: quote ${d} is too small to express a ${h.selectedBps} bps floor without rounding to zero`);let y=Number((d-b)*10000n/(d===0n?1n:d));if(y>h.capBps)throw new Error(`auto-slippage: realised floor implies ${y} bps, above cap ${h.capBps} \u2014 refusing to issue a guard weaker than advertised`);return Pt({mode:"auto",chainId:Number(e),venue:String(t||"unknown"),quoteAmountOut:d.toString(),minAmountOut:b.toString(),requiredBps:h.requiredBps,selectedBps:h.selectedBps,capBps:h.capBps,quotedAtMs:f,expiresAtMs:f+p},{secret:u})}function Un(e){let t=String(e||"");if(!/^0x[0-9a-fA-F]+$/.test(t)||t.length<10||t.length%2!==0)return null;let r=t.slice(0,10).toLowerCase(),s=[];for(let o=10;o+64<=t.length;o+=64)s.push(t.slice(o,o+64));let n=o=>s[o]==null?null:BigInt("0x"+s[o]);switch(r){case"0x414bf389":return n(6);case"0x04e45aaf":return n(5);case"0xc04b8d59":{let o=n(0);if(o==null)return null;let a=Number(o)/32;return!Number.isInteger(a)||a<0?null:n(a+4)}case"0xb858183f":{let o=n(0);if(o==null)return null;let a=Number(o)/32;return!Number.isInteger(a)||a<0?null:n(a+3)}case"0xa026383e":return n(6);case"0x38ed1739":case"0x5c11d795":return n(1);case"0x7ff36ab5":case"0xb6f9de95":return n(0);case"0x18cbafe5":case"0x791ac947":return n(1);default:return null}}var qn=Object.freeze({"8da5cb5b":{name:"owner()",weight:"low",note:"contract has an owner"},f2fde38b:{name:"transferOwnership(address)",weight:"low",note:"ownership transferable"},"40c10f19":{name:"mint(address,uint256)",weight:"high",note:"owner can mint new supply"},a0712d68:{name:"mint(uint256)",weight:"high",note:"owner can mint new supply"},f9f92be4:{name:"blacklist(address)",weight:"high",note:"addresses can be blocked from selling"},e4997dc5:{name:"removeBlackList(address)",weight:"high",note:"blacklist machinery present"},"8456cb59":{name:"pause()",weight:"high",note:"transfers can be frozen"},"3f4ba83a":{name:"unpause()",weight:"high",note:"pausable transfers"},c0246668:{name:"setFee/excludeFromFee",weight:"high",note:"transfer fees can be changed"},"3659cfe6":{name:"upgradeTo(address)",weight:"high",note:"logic can be replaced entirely"},"4f1ef286":{name:"upgradeToAndCall(address,bytes)",weight:"high",note:"logic can be replaced entirely"}}),Bn=Object.freeze([{label:"eip1967",slot:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"},{label:"zeppelinos",slot:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"},{label:"eip1822",slot:"0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"}]),$n=`0x${"0".repeat(64)}`;function Fn(e){return!e||e==="0x"||e===$n}async function Bt(e={},t={}){let r=t.rpcCall||q,s=String(e.address||"").trim().toLowerCase(),n=Number(e.chainId);if(!/^0x[a-f0-9]{40}$/.test(s))return{status:"error",error:"address must be a 0x-prefixed EVM address",risk:"unknown-risk",findings:[],notes:[]};if(!Number.isInteger(n))return{status:"error",error:"chainId is required",risk:"unknown-risk",findings:[],notes:[]};let o;try{o=await r(n,"eth_getCode",[s,"latest"],t)}catch(m){return{address:s,chainId:n,status:"unavailable",error:m?.message||"eth_getCode failed",risk:"unknown-risk",findings:[],isProxy:!1,codeSize:0,notes:["could not read contract code; treat as unverified"]}}if(!o||o==="0x")return{address:s,chainId:n,status:"ok",risk:"high",findings:[{selector:"-",name:"no-code",weight:"high",note:"no contract deployed at this address"}],isProxy:!1,codeSize:0,notes:["nothing is deployed here \u2014 an approval or transfer to this address is unrecoverable"]};let a=[],c=[],i=o.slice(2).toLowerCase();for(let[m,b]of Object.entries(qn))i.includes(m)&&c.push({selector:`0x${m}`,...b});let l=!1,u=null,d=null,h=await Promise.all(Bn.map(async({label:m,slot:b})=>{try{let y=await r(n,"eth_getStorageAt",[s,b,"latest"],t);return{label:m,word:y,error:null}}catch{return{label:m,word:null,error:`proxy slot (${m}) unreadable; proxy status uncertain`}}}));for(let m of h)m.error&&a.push(m.error),!l&&m.word&&!Fn(m.word)&&(l=!0,u=m.label,d=`0x${String(m.word).slice(-40)}`);l&&(c.push({selector:u,name:"proxy",weight:"high",note:"implementation is upgradeable \u2014 current behaviour is not a guarantee"}),a.push(`bytecode scan covers the proxy (${u}), not the implementation ${d} it delegates to`));let p=c.filter(m=>m.weight==="high").length>0?"high":c.length>0?"elevated":"unknown-risk";return p==="unknown-risk"&&a.push("no owner-power selectors found; this is weak evidence, not a safety guarantee"),{address:s,chainId:n,status:"ok",risk:p,findings:c,isProxy:l,proxyStandard:u,implementation:d,codeSize:Math.floor(i.length/2),notes:a}}var Dn=/^0x[0-9a-fA-F]{40}$/,Mn=4663;function me(e,t){let r=String(e||"").trim();if(!Dn.test(r))throw new Error(`evm-token-sniper: ${t} must be a 0x EVM address`);return r}function Ue(e,t){let r=String(e??"").trim();if(!/^\d+$/.test(r)||BigInt(r)<=0n)throw new Error(`evm-token-sniper: ${t} must be a positive raw integer amount`);return r}function te(e,t){return e==null||e===""?null:Ue(e,t)}function Hn({chainId:e,tokenAddress:t,tokenIn:r,amountIn:s,recipient:n,quote:o,topPool:a,unsignedTx:c,args:i,opts:l}){let u=c?.tx;if(!u||typeof u!="object")throw new Error("local-signer envelope requires unsigned tx object");let d=me(u.to,"prepared destination"),h=String(u.data||"").toLowerCase();if(!/^0x[0-9a-f]+$/.test(h))throw new Error("local-signer envelope requires hex calldata");let f=Ue(u.value??s,"prepared native value");if(BigInt(f)!==BigInt(s))throw new Error("local-signer envelope requires native value equal amountIn");let p=te(u.gasLimit??i.gasLimit,"gasLimit"),m=te(u.maxFeePerGas??i.maxFeePerGas,"maxFeePerGas");if(!p||!m)throw new Error("local-signer envelope requires explicit gasLimit and maxFeePerGas caps");let b=Number(l.nowMs??Date.now()),y=Math.min(6e4,Math.max(1e3,Number(i.ttlMs??i.expiresInMs??3e4)||3e4)),x=qt({chainId:e,venue:"uniswap-v3",quoteAmountOut:o?.amountOut,liquidityUsd:a?.liquidityUsd,requestedCapBps:i.slippageBps??50,quotedAtMs:b,ttlMs:y,secret:l.routeAttestationSecret}),C=Ut(x,{chainId:e,venue:"uniswap-v3",data:h,secret:l.routeAttestationSecret}),_={chainId:e,from:n,to:d,data:h,value:f,gasLimit:p,maxFeePerGas:m,slippageBps:C.selectedBps,expiresAtMs:b+y},O=te(u.maxPriorityFeePerGas??i.maxPriorityFeePerGas,"maxPriorityFeePerGas");return O&&(_.maxPriorityFeePerGas=O),i.nonce!==void 0&&(_.nonce=Number(i.nonce)),(i.txType!==void 0||O)&&(_.type=Number(i.txType??2)),i.l1FeeWei!==void 0&&(_.l1FeeWei=te(i.l1FeeWei,"l1FeeWei")??"0"),i.operatorFeeWei!==void 0&&(_.operatorFeeWei=te(i.operatorFeeWei,"operatorFeeWei")??"0"),{version:1,surface:"evm-swap",action:"swap",provider:"uniswap-v3",owner:n,destination:d,tradeId:i.tradeId||`evm-token-sniper-${e}-${t.toLowerCase()}`,slippageBps:C.selectedBps,expiresAtMs:b+y,fee:{oracleFeeBps:5},autoSlippage:C,artifact:{chainId:e,owner:n,transactions:[_]},meta:{source:"evm-token-sniper",tokenIn:r,tokenOut:t}}}function jn(e,t){if(t){if(Number(t.chainId)!==e)throw new Error(`evm-token-sniper: supplied scanner chain ${t.chainId} does not match ${e}`);return t}_t();let r=vt(e);if(!r)throw new Error(`evm-token-sniper: unsupported EVM chainId ${e}`);return r}function Vn({token:e,pools:t,structuralRisk:r,scannerRisk:s,sellability:n,quote:o,args:a,scanner:c}){let i=[];return e?.evidence!==v.LIVE&&i.push("token identity is not live-verified"),(!Array.isArray(t?.pools)||t.pools.length===0)&&i.push("no liquid pool was resolved"),r?.status!=="ok"&&i.push("structural contract risk is unavailable"),r?.risk==="high"&&i.push("structural contract risk is high"),s?.verdict!==w.PASS&&i.push(`scanner risk verdict is ${s?.verdict||"UNKNOWN"}`),c.supports?.("sellSimulation")?n?.verdict!==w.PASS&&i.push(`sellability verdict is ${n?.verdict||"UNKNOWN"}`):i.push("sell simulation is unavailable on this chain"),c.supports?.("quote")?o?.evidence!==v.LIVE&&i.push("no live quote was returned"):i.push("live quoting is unavailable on this chain"),c.supports?.("prepareUnsignedTx")||i.push("unsigned transaction preparation is unavailable on this chain"),a.tokenIn||i.push("tokenIn is required to prepare"),a.amountIn||i.push("amountIn is required to prepare"),a.recipient||i.push("recipient is required to prepare"),i}async function $t(e={},t={}){let r=Number(e.chainId??Mn);if(!Number.isInteger(r)||r<=0)throw new Error("evm-token-sniper: chainId must be a positive integer");let s=me(e.tokenAddress||e.address||e.token,"tokenAddress"),n=e.tokenIn?me(e.tokenIn,"tokenIn"):null,o=e.recipient?me(e.recipient,"recipient"):null,a=e.amountIn==null?null:Ue(e.amountIn,"amountIn"),c=jn(r,t.scanner),i=t.scanContractRisk||Bt,[l,u,d]=await Promise.all([c.resolveToken(s),c.resolvePools(s),i({address:s,chainId:r},t.contractRiskOpts||t)]),h=await c.scoreRisk(s),f=null;c.supports?.("sellSimulation")&&a?f=await c.sellSimulation({token:s,amountIn:a,base:n||void 0}):c.supports?.("sellSimulation")&&(f=await c.sellSimulation({token:s,amountIn:"10000000000000000"}));let p=null;c.supports?.("quote")&&n&&a&&(p=await c.quote({tokenIn:n,tokenOut:s,amountIn:a}));let m={...e,tokenIn:n,amountIn:a,recipient:o},b=Vn({token:l,pools:u,structuralRisk:d,scannerRisk:h,sellability:f,quote:p,args:m,scanner:c}),y=null,x=null,C=null;if(e.prepare===!0&&b.length===0){y=await c.prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:a,recipient:o,slippageBps:e.slippageBps??50,fee:p?.fee});try{x=Hn({chainId:r,tokenAddress:s,tokenIn:n,amountIn:a,recipient:o,quote:p,topPool:u?.pools?.[0]||null,unsignedTx:y,args:e,opts:t})}catch(_){C=String(_?.message||_).slice(0,200)}}return{provider:"evm-token-sniper",execution:"armed-local",armed:!!x,signing:"local-signer",broadcasting:"local-signer",chainId:r,chain:{key:c.key,name:c.name,nativeCurrency:c.nativeCurrency},token:l,pools:u,topPool:u?.pools?.[0]||null,structuralRisk:d,scannerRisk:h,sellability:f,quote:p,blockedReasons:b,prepared:!!y,unsignedTx:y,localSignerEnvelope:x,localSignerBlockedReason:C,signed:x?"pending-local-signer":!1,broadcast:x?"pending-local-signer":!1}}import{homedir as qe}from"node:os";import{join as Be}from"node:path";var Ft=process.env.ORACLE_PUBLIC_DESKTOP==="1",zn=Ft?process.env.ORACLE_CONFIG_DIR||Be(qe(),".config","oracle"):Be(qe(),".config","oracle"),ys=Ft?zn:Be(qe(),".config","mad-desk");var Wn=4663,Gn="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",Kn="Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";function $e(e=process.env){return String((e||process.env).ORACLE_SNIPE_EXECUTE||"").trim()==="1"}function Dt(e){return String(e||"").trim().replace(/^@/,"")}async function Xn({handle:e,limit:t=5,xurlFn:r=Ye}={},s={}){let n=Dt(e);if(!n)throw new Error("twitter-ca-watch: handle required");let o=await r("xurl",{command:"search",query:`from:${n}`,limit:Math.min(20,Math.max(1,Number(t)||5))},s);return o?.ok?{ok:!0,tweets:ze(o.stdout),raw:o}:{ok:!1,error:o?.error||"xurl search failed",tweets:[]}}async function Yn(e,{chainId:t,amountIn:r,tokenIn:s,recipient:n,prepare:o},a){let c=await $t({chainId:t,tokenAddress:e,amountIn:r,tokenIn:s,recipient:n,prepare:o===!0},a),i=c.topPool||c.pools?.pools?.[0]||null;return{chainFamily:"evm",chainId:t,address:e,topPool:i,quoteAsset:c.pools?.quoteAsset||null,sellability:c.sellability||null,blockedReasons:c.blockedReasons||[],prepared:!!c.prepared,unsignedTx:c.unsignedTx||null,localSignerEnvelope:c.localSignerEnvelope||null,execution:!1,broadcast:!1}}async function Zn(e,t){let r=await gt(e,{chainSlug:"solana",stables:[Gn,Kn]},t);return{chainFamily:"solana",chainId:"solana",address:e,topPool:r.topPool,pools:r.pools,prepared:!1,execution:!1,broadcast:!1,note:"Solana CA ranked on USD book. Prepare stays Jupiter/local-signer; this tick does not broadcast."}}async function Qn(e,t={},r={}){let s=Number(t.chainId??Wn),n=[];for(let o of e.evm||[])n.push(await Yn(o,{...t,chainId:s},r));for(let o of e.solana||[])n.push(await Zn(o,r));return n}async function Mt(e={},t={}){let r=Dt(e.handle),s=e.seen instanceof Set?e.seen:new Set(e.seen||[]),n=await Xn({handle:r,limit:e.limit,xurlFn:t.xurlFn},t);if(!n.ok)return{ok:!1,handle:r,error:n.error,hits:[],seen:[...s]};let o=[];for(let c of n.tweets){let i=c.id||`${r}:${c.text.slice(0,80)}`;if(s.has(i))continue;let l=Ve(c.text,{extras:c.urls||[]});if(!l.all.length){s.add(i);continue}let d=await(t.evaluateFn||Qn)(l,e,t);s.add(i),o.push({tweetId:c.id||null,handle:r,text:c.text,contracts:l,evaluations:d})}let a=e.automated!==!1;return{ok:!0,handle:r,source:"twitter-ca-watch",automated:a,card:!1,notify:!1,telegram:!1,execution:!1,broadcast:!1,snipeExecuteEnabled:$e(t.env||process.env),hits:o,seen:[...s]}}var Ht=`oracle snipe twitter <handle> [--chain 4663] [--json]
8
+ - `)}`);let n=e.capabilities||{},s=de.filter(c=>typeof n[c]=="function"),a={key:e.key,chainId:e.chainId,name:e.name,rpcEnv:[...e.rpcEnv],nativeCurrency:e.nativeCurrency?{...e.nativeCurrency}:null,wrappedNative:e.wrappedNative||null,explorer:e.explorer||null,venues:(e.venues||[]).map(c=>({...c})),warnings:o,capabilities(){return{chainId:e.chainId,key:e.key,supported:[...s],unsupported:de.filter(c=>!s.includes(c))}},supports(c){return s.includes(c)}};for(let c of de)s.includes(c)?a[c]=async(...i)=>n[c](...i,{scanner:a}):a[c]=async()=>{throw new Error(`${e.key} (chain ${e.chainId}) does not implement "${c}". Supported: ${s.join(", ")||"none"}. An unimplemented capability is absent, not assumed -- implement it or treat this chain as fail-closed for that operation.`)};return Object.freeze(a)}var Et=new Map;function vt(e){let t=En(e);return Et.set(t.chainId,t),t}function St(e){return Et.get(Number(e))||null}var _e={getAmountsOut:"d06ca61f",swapExactTokensForTokens:"38ed1739",swapExactETHForTokens:"7ff36ab5"},B=e=>BigInt(e).toString(16).padStart(64,"0"),J=e=>e.slice(2).toLowerCase().padStart(64,"0");function vn(e,t){return`0x${_e.getAmountsOut}`+B(e)+B(64)+B(t.length)+t.map(J).join("")}function Sn(e){if(!e||e==="0x")return null;let t=e.slice(2);if(t.length<128)return null;let r=Number(BigInt(`0x${t.slice(64,128)}`));if(!Number.isFinite(r)||r<1||r>16)return null;let o=[];for(let n=0;n<r;n++){let s=128+n*64;if(t.length<s+64)return null;o.push(BigInt(`0x${t.slice(s,s+64)}`))}return o}function Ie(e,t="router"){return(e?.venues||[]).find(o=>o.kind===t)?.address??null}var Oe=100;function An(e,t){let r=Number(t);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Oe)throw new Error(`slippageBps ${r} exceeds the ${Oe} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(r))/10000n}function At(e){let{chainId:t,wrappedNative:r}=e;async function o(n,s,a,c){let i=await q(t,"eth_call",[{to:n,data:vn(s,a)},"latest"],c);return Sn(i?.result??i)}return{async quote({tokenIn:n,tokenOut:s,amountIn:a,path:c},i={}){let l=Ie(i.scanner);if(!l)return{chainId:t,evidence:E.UNAVAILABLE,reason:"no verified router configured for this chain; quoting stays fail-closed rather than guessing a venue address"};let u=c||[n,s];if(u.some(h=>!/^0x[0-9a-fA-F]{40}$/.test(h||"")))throw new Error("quote requires valid 20-byte addresses");let d=await o(l,a,u,i);return d?{chainId:t,router:l,path:u,amountIn:String(a),amountOut:d[d.length-1].toString(),hops:u.length-1,evidence:E.LIVE,note:"exact-input quote at current reserves; not a guaranteed fill"}:{chainId:t,router:l,path:u,evidence:E.UNKNOWN,reason:"router returned no amounts -- no pool for this path, or the call reverted"}},async sellSimulation({token:n,amountIn:s,base:a},c={}){let i=Ie(c.scanner),l=a||r;if(l&&String(n).toLowerCase()===String(l).toLowerCase())return{chainId:t,token:n,verdict:w.UNKNOWN,evidence:E.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(!i||!l)return{chainId:t,token:n,verdict:w.UNKNOWN,evidence:E.UNAVAILABLE,reason:i?"no wrappedNative configured for this chain, so no base asset to round-trip against":"no verified router configured for this chain"};let u=await o(i,s,[l,n],c);if(!u)return{chainId:t,token:n,verdict:w.FAIL,evidence:E.LIVE,leg:"buy",reason:"buy leg returned no amounts -- no route in"};let d=u[u.length-1];if(d===0n)return{chainId:t,token:n,verdict:w.FAIL,evidence:E.LIVE,leg:"buy",reason:"buy leg quotes zero output"};let h=await o(i,d,[n,l],c);if(!h)return{chainId:t,token:n,verdict:w.FAIL,evidence:E.LIVE,leg:"sell",bought:d.toString(),reason:"SELL LEG FAILED while the buy leg quoted fine. This is the honeypot signature: do not trade."};let f=h[h.length-1],p=Number(f*10000n/BigInt(s)),m=w.PASS,b="round trip completes with expected fee/impact loss";return p<5e3?(m=w.FAIL,b=`round trip returns only ${(p/100).toFixed(2)}% -- punitive tax or no real liquidity`):p<9e3&&(m=w.CAUTION,b=`round trip returns ${(p/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,token:n,base:l,router:i,verdict:m,reason:b,amountIn:String(s),bought:d.toString(),returned:f.toString(),retentionBps:p,evidence:E.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:n,tokenOut:s,amountIn:a,recipient:c,slippageBps:i=50,deadlineSeconds:l=900,path:u},d={}){let h=d.scanner,f=Ie(h);if(!f)throw new Error(`chain ${t} 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(c||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let p=u||[n,s],m=await this.quote({tokenIn:n,tokenOut:s,amountIn:a,path:p},d);if(m.evidence!==E.LIVE)throw new Error(`cannot prepare without a live quote (${m.evidence}: ${m.reason??"no reason given"})`);let b=An(m.amountOut,i);if(b<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let y=BigInt(Math.floor(Date.now()/1e3)+Number(l)),x=r&&p[0].toLowerCase()===r.toLowerCase()&&d.useNative,C=x?`0x${_e.swapExactETHForTokens}`+B(b)+B(128)+J(c)+B(y)+B(p.length)+p.map(J).join(""):`0x${_e.swapExactTokensForTokens}`+B(a)+B(b)+B(160)+J(c)+B(y)+B(p.length)+p.map(J).join("");return{unsigned:!0,signedBy:"user-wallet",chainId:t,tx:{to:f,data:C,value:x?`0x${BigInt(a).toString(16)}`:"0x0"},guard:{quotedOut:m.amountOut,minOut:b.toString(),slippageBps:i,maxSlippageBps:Oe,deadline:y.toString()},requires:x?[]:[{step:"approve",token:p[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 xn=[100,500,3e3,1e4],xt={quoteExactInputSingle:"c6a5026a",exactInputSingle:"04e45aaf"},W=e=>BigInt(e).toString(16).padStart(64,"0"),ee=e=>e.slice(2).toLowerCase().padStart(64,"0"),Ct=/^0x[0-9a-fA-F]{40}$/,Re=100;function Cn(e,t){let r=Number(t);if(!Number.isFinite(r)||r<0)throw new Error("slippageBps must be a non-negative number");if(r>Re)throw new Error(`slippageBps ${r} exceeds the ${Re} bps ceiling. Block and requote or split the order -- do not widen the guard to force a fill.`);return BigInt(e)*BigInt(1e4-Math.floor(r))/10000n}function Ne(e,t){return(e?.venues||[]).find(r=>r.kind===t)?.address??null}function kt(e){let{chainId:t,wrappedNative:r}=e;async function o({quoter:s,tokenIn:a,tokenOut:c,amountIn:i,fee:l},u){let d=`0x${xt.quoteExactInputSingle}`+ee(a)+ee(c)+W(i)+W(l)+W(0),h=await q(t,"eth_call",[{to:s,data:d},"latest"],u).catch(()=>null),f=h?.result??h;if(!f||f==="0x"||f.length<66)return null;let p=BigInt(`0x${f.slice(2,66)}`);return p>0n?p:null}async function n({quoter:s,tokenIn:a,tokenOut:c,amountIn:i},l){let u=await Promise.all(xn.map(async h=>{let f=await o({quoter:s,tokenIn:a,tokenOut:c,amountIn:i,fee:h},l);return{fee:h,amountOut:f?f.toString():null,out:f}})),d=null;for(let h of u)h.out&&(!d||h.out>d.amountOut)&&(d={fee:h.fee,amountOut:h.out});return{best:d,tried:u.map(({fee:h,amountOut:f})=>({fee:h,amountOut:f}))}}return{async quote({tokenIn:s,tokenOut:a,amountIn:c},i={}){let l=Ne(i.scanner,"quoter");if(!l)return{chainId:t,evidence:E.UNAVAILABLE,reason:"no verified quoter configured for this chain; quoting stays fail-closed rather than guessing a venue address"};for(let h of[s,a])if(!Ct.test(h||""))throw new Error("quote requires valid 20-byte addresses");let{best:u,tried:d}=await n({quoter:l,tokenIn:s,tokenOut:a,amountIn:c},i);return u?{chainId:t,venue:"uniswap-v3",quoter:l,tokenIn:s,tokenOut:a,amountIn:String(c),amountOut:u.amountOut.toString(),fee:u.fee,useNative:!!r&&String(s).toLowerCase()===String(r).toLowerCase(),triedFeeTiers:d,evidence:E.LIVE,note:"exact-input single-hop quote at current tick; not a guaranteed fill"}:{chainId:t,quoter:l,tokenIn:s,tokenOut:a,triedFeeTiers:d,evidence:E.UNKNOWN,reason:"no fee tier returned a quote -- no V3 pool for this pair, or no liquidity"}},async sellSimulation({token:s,amountIn:a,base:c},i={}){let l=Ne(i.scanner,"quoter"),u=(e.stableQuoteAssets||[]).map(O=>String(O).toLowerCase()),d=null;!c&&typeof e.resolveQuoteAsset=="function"&&(d=await e.resolveQuoteAsset(s,i).catch(()=>null));let h=String(s).toLowerCase(),f=String(r||"").toLowerCase();if(f&&h===f)return{chainId:t,token:s,verdict:w.UNKNOWN,evidence:E.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 p=c||d||(u[0]&&h!==u[0]?u[0]:null)||r;if(p&&h===String(p).toLowerCase())return{chainId:t,token:s,verdict:w.UNKNOWN,evidence:E.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(!l||!p)return{chainId:t,token:s,verdict:w.UNKNOWN,evidence:E.UNAVAILABLE,reason:l?"no wrappedNative configured, so there is no base asset to round-trip against":"no verified quoter configured for this chain"};let m=await n({quoter:l,tokenIn:p,tokenOut:s,amountIn:a},i);if(!m.best){let O=u.find(T=>T&&T!==String(p).toLowerCase()&&T!==String(s).toLowerCase());if(O){let T=await n({quoter:l,tokenIn:O,tokenOut:s,amountIn:a},i);if(T.best){let v=await n({quoter:l,tokenIn:s,tokenOut:O,amountIn:T.best.amountOut},i);if(v.best){let I=v.best.amountOut,S=Number(I*10000n/BigInt(a)),L=w.PASS,g="round trip vs dollar book completes with expected fee/impact loss";return S<5e3?(L=w.FAIL,g=`round trip vs dollar book returns only ${(S/100).toFixed(2)}% -- punitive tax or no real liquidity`):S<9e3&&(L=w.CAUTION,g=`round trip vs dollar book returns ${(S/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,venue:"uniswap-v3",token:s,base:O,quoteAsset:O,verdict:L,reason:g,amountIn:String(a),bought:T.best.amountOut.toString(),returned:I.toString(),retentionBps:S,buyFee:T.best.fee,sellFee:v.best.fee,evidence:E.LIVE,note:"Quoted against the dollar book, not wrapped native. A missing WETH pool is not a honeypot."}}}}return{chainId:t,token:s,verdict:w.FAIL,evidence:E.LIVE,leg:"buy",reason:"no V3 pool priced the buy leg on any fee tier against wrapped native or the dollar book"}}let b=await n({quoter:l,tokenIn:s,tokenOut:p,amountIn:m.best.amountOut},i);if(!b.best){let O=u.find(T=>T&&T!==String(p).toLowerCase()&&T!==String(s).toLowerCase());if(O){let T=await n({quoter:l,tokenIn:O,tokenOut:s,amountIn:a},i),v=T.best?await n({quoter:l,tokenIn:s,tokenOut:O,amountIn:T.best.amountOut},i):{best:null};if(T.best&&v.best){let I=v.best.amountOut,S=Number(I*10000n/BigInt(a)),L=w.PASS,g="round trip vs dollar book completes; missing WETH sell pool is not a honeypot";return S<5e3?(L=w.FAIL,g=`dollar-book round trip returns only ${(S/100).toFixed(2)}%`):S<9e3&&(L=w.CAUTION,g=`dollar-book round trip returns ${(S/100).toFixed(2)}%`),{chainId:t,venue:"uniswap-v3",token:s,base:O,quoteAsset:O,verdict:L,reason:g,amountIn:String(a),bought:T.best.amountOut.toString(),returned:I.toString(),retentionBps:S,buyFee:T.best.fee,sellFee:v.best.fee,evidence:E.LIVE,note:"Sell vs wrapped native failed; dollar book succeeded. Not labelled honeypot."}}}return{chainId:t,token:s,verdict:w.FAIL,evidence:E.LIVE,leg:"sell",bought:m.best.amountOut.toString(),reason:"SELL LEG FAILED against wrapped native and the dollar book. This is the honeypot signature: do not trade."}}let y=b.best.amountOut,x=Number(y*10000n/BigInt(a)),C=w.PASS,_="round trip completes with expected fee/impact loss";return x<5e3?(C=w.FAIL,_=`round trip returns only ${(x/100).toFixed(2)}% -- punitive tax or no real liquidity`):x<9e3&&(C=w.CAUTION,_=`round trip returns ${(x/100).toFixed(2)}% -- transfer tax or thin liquidity at this size`),{chainId:t,venue:"uniswap-v3",token:s,base:p,verdict:C,reason:_,amountIn:String(a),bought:m.best.amountOut.toString(),returned:y.toString(),retentionBps:x,buyFee:m.best.fee,sellFee:b.best.fee,evidence:E.LIVE,note:"Quote-level round trip. It does not prove transfer hooks absent at execution time."}},async prepareUnsignedTx({tokenIn:s,tokenOut:a,amountIn:c,recipient:i,slippageBps:l=50,fee:u},d={}){let h=Ne(d.scanner,"router");if(!h)throw new Error(`chain ${t} 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(!Ct.test(i||""))throw new Error("prepareUnsignedTx requires a valid recipient address");let f=await this.quote({tokenIn:s,tokenOut:a,amountIn:c},d);if(f.evidence!==E.LIVE)throw new Error(`cannot prepare without a live quote (${f.evidence}: ${f.reason??"no reason given"})`);let p=u??f.fee,m=Cn(f.amountOut,l);if(m<=0n)throw new Error("computed minOut is zero -- refusing to prepare");let b=!!(d.useNative||f.useNative)&&r&&String(s).toLowerCase()===String(r).toLowerCase(),y=`0x${xt.exactInputSingle}`+ee(s)+ee(a)+W(p)+ee(i)+W(c)+W(m)+W(0);return{unsigned:!0,signedBy:"user-wallet",chainId:t,venue:"uniswap-v3",tx:{to:h,data:y,value:b?String(c):"0x0"},guard:{quotedOut:f.amountOut,minOut:m.toString(),slippageBps:l,maxSlippageBps:Re,fee:p},requires:b?[]:[{step:"approve",token:s,spender:h,amount:String(c)}],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 pe={decimals:"0x313ce567",symbol:"0x95d89b41",name:"0x06fdde03",totalSupply:"0x18160ddd",owner:"0x8da5cb5b"};function Tt(e){if(!e||e==="0x")return null;try{return BigInt(e)}catch{return null}}function It(e){if(!e||e==="0x")return null;let t=e.slice(2);if(t.length>=128){let o=Number(BigInt(`0x${t.slice(64,128)}`));if(o>0&&o<=256&&t.length>=128+o*2){let n=t.slice(128,128+o*2),s=Buffer.from(n,"hex").toString("utf8").replace(/\0+$/,"");if(s)return s}}return Buffer.from(t.slice(0,64),"hex").toString("utf8").replace(/\0+$/,"")||null}function kn(e){let{chainId:t}=e;async function r(o,n,s){return q(t,"eth_call",[{to:o,data:n},"latest"],s)}return{async blockNumber(o={}){let n=await ht(t,o);return{chainId:t,blockNumber:n?.blockNumber??n,evidence:E.LIVE}},async nativeBalance(o,n={}){let s=await mt(t,o,n);return{chainId:t,address:o,wei:s?.wei??s?.balance??null,symbol:e.nativeCurrency?.symbol??null,decimals:e.nativeCurrency?.decimals??18,evidence:E.LIVE}},async tokenBalance({token:o,owner:n},s={}){let a=await bt({chainId:t,token:o,owner:n},s);return{chainId:t,token:o,owner:n,raw:a?.balance??a,evidence:E.LIVE}},async resolveToken(o,n={}){if(!/^0x[0-9a-fA-F]{40}$/.test(o||""))return{chainId:t,token:o,evidence:E.UNKNOWN,error:"resolveToken needs a 20-byte address; symbol lookup is a market-data concern"};let[s,a,c,i]=await Promise.all([r(o,pe.decimals,n).catch(()=>null),r(o,pe.symbol,n).catch(()=>null),r(o,pe.name,n).catch(()=>null),r(o,pe.totalSupply,n).catch(()=>null)]),l=Tt(s?.result??s),u=l!==null||a?.result||c?.result,d={chainId:t,address:o,decimals:l===null?null:Number(l),symbol:It(a?.result??a),name:It(c?.result??c),totalSupply:(Tt(i?.result??i)??null)?.toString()??null,evidence:u?E.LIVE:E.UNKNOWN};return u||(d.warning="no ERC-20 metadata returned -- may not be a token contract"),d},async resolvePools(o,n={}){let s=e.dexscreenerSlug;if(!s)return{chainId:t,token:o,pools:[],evidence:E.UNAVAILABLE,reason:"no dexscreenerSlug configured for this chain; pool discovery is unavailable rather than guessed"};let a=await Te(o,n).catch(()=>null),i=(a?.pairs||a?.data?.pairs||[]).filter(u=>String(u.chainId).toLowerCase()===String(s).toLowerCase()).map(u=>({pair:u.pairAddress,dex:u.dexId,base:u.baseToken?.address,quote:u.quoteToken?.address,liquidityUsd:u.liquidity?.usd??null,priceUsd:u.priceUsd??null,volume24hUsd:u.volume?.h24??null,createdAt:u.pairCreatedAt??null})).sort((u,d)=>(d.liquidityUsd??0)-(u.liquidityUsd??0)),l=le(o,i,{stables:e.stableQuoteAssets||[],wrappedNative:e.wrappedNative});return{chainId:t,token:o,pools:l,topPool:l[0]||null,quoteAsset:wt(o,l),evidence:l.length?E.LIVE:E.UNKNOWN}},async scanBlocks({fromBlock:o,toBlock:n,address:s,topics:a,chunkSize:c=2e3}={},i={}){if(!Number.isInteger(o)||!Number.isInteger(n))throw new Error("scanBlocks requires integer fromBlock and toBlock");if(n<o)throw new Error("toBlock must be >= fromBlock");let l=[],u=[];for(let h=o;h<=n;h+=c){let f=Math.min(h+c-1,n);u.push([h,f])}let d=await it(u,4,async([h,f])=>{let p={fromBlock:`0x${h.toString(16)}`,toBlock:`0x${f.toString(16)}`};s&&(p.address=s),a&&(p.topics=a);let m=await q(t,"eth_getLogs",[p],i).catch(b=>({error:String(b?.message||b)}));return{start:h,end:f,res:m}});for(let{start:h,end:f,res:p}of d){if(p?.error)return{chainId:t,fromBlock:o,toBlock:n,logs:l,complete:!1,failedAt:[h,f],error:p.error,evidence:E.UNKNOWN};for(let m of p?.result??p??[])l.push(m)}return{chainId:t,fromBlock:o,toBlock:n,logs:l,complete:!0,chunks:u.length,evidence:E.LIVE}},async scoreRisk(o,n={}){let s=[],a=w.PASS,c=u=>{let d={[w.PASS]:0,[w.CAUTION]:1,[w.UNKNOWN]:2,[w.FAIL]:3};d[u]>d[a]&&(a=u)},[i,l]=await Promise.all([this.resolveToken(o,n),this.resolvePools(o,n)]);if(i.evidence!==E.LIVE?(s.push({check:"erc20-metadata",result:w.UNKNOWN,detail:i.warning}),c(w.UNKNOWN)):s.push({check:"erc20-metadata",result:w.PASS,detail:`${i.symbol} / ${i.decimals}d`}),l.evidence===E.UNAVAILABLE)s.push({check:"liquidity",result:w.UNKNOWN,detail:l.reason}),c(w.UNKNOWN);else if(!l.pools.length)s.push({check:"liquidity",result:w.FAIL,detail:"no pool with liquidity found"}),c(w.FAIL);else{let u=l.pools[0],d=u.liquidityUsd??0;d<5e3?(s.push({check:"liquidity",result:w.CAUTION,detail:`top pool only $${d}`}),c(w.CAUTION)):s.push({check:"liquidity",result:w.PASS,detail:`$${d} on ${u.dex}`}),u.createdAt&&Date.now()-u.createdAt<24*3600*1e3&&(s.push({check:"age",result:w.CAUTION,detail:"pool under 24h old"}),c(w.CAUTION))}if(typeof this.sellSimulation=="function"){let u=await this.sellSimulation({token:o,amountIn:(10n**16n).toString()},n).catch(d=>({verdict:w.UNKNOWN,reason:String(d?.message||d)}));s.push({check:"sellability",result:u.verdict,detail:u.retentionBps!=null?`round trip returns ${(u.retentionBps/100).toFixed(2)}% -- ${u.reason}`:u.reason}),c(u.verdict)}else s.push({check:"sellability",result:w.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."}),c(w.UNKNOWN);return{chainId:t,token:o,verdict:a,checks:s,note:"Structural checks only. UNKNOWN is not PASS. A token is not tradeable until a sell simulation succeeds."}}}}function _t(e){let r={...kn(e)},o=new Set((e.venues||[]).map(s=>s.kind));e.venueKind==="uniswap-v3"&&o.has("quoter")&&o.has("router")?Object.assign(r,kt({chainId:e.chainId,wrappedNative:e.wrappedNative,stableQuoteAssets:e.stableQuoteAssets||[],resolveQuoteAsset:async(s,a)=>(await r.resolvePools(s,a)).quoteAsset||null})):e.venueKind==="uniswap-v2"&&o.has("router")&&Object.assign(r,At({chainId:e.chainId,wrappedNative:e.wrappedNative}));let n={};for(let[s,a]of Object.entries(r))n[s]=a.bind(r);return{key:e.key,chainId:e.chainId,name:e.name,rpcEnv:e.rpcEnv,nativeCurrency:e.nativeCurrency,explorer:e.explorer,venues:e.venues||[],capabilities:n}}var Ot=Object.freeze([{key:"ethereum",chainId:1,name:"Ethereum",rpcEnv:["ETH_RPC_URL","ETHEREUM_RPC_URL","MAINNET_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://etherscan.io",dexscreenerSlug:"ethereum",venueKind:"uniswap-v3",wrappedNative:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",stableQuoteAssets:["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48","0xdAC17F958D2ee523a2206206994597C13D831ec7"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.71 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:1}}]},{key:"optimism",chainId:10,name:"OP Mainnet",rpcEnv:["OPTIMISM_RPC_URL","OP_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://optimistic.etherscan.io",dexscreenerSlug:"optimism",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85","0x94b008aA00579c1307B0EF2c499aD98a8ce58e58"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1905.23 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:10}}]},{key:"bsc",chainId:56,name:"BNB Smart Chain",rpcEnv:["BSC_RPC_URL","BNB_RPC_URL"],nativeCurrency:{symbol:"BNB",decimals:18},explorer:"https://bscscan.com",dexscreenerSlug:"bsc",venueKind:"uniswap-v3",wrappedNative:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",stableQuoteAssets:["0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d","0x55d398326f99059fF775485246999027B3197955"],venues:[{kind:"quoter",address:"0x78D78E420Da98ad378D7799bE8f4AF69033EB077",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WBNB->USDC fee 500 quoted 413.86 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}},{kind:"router",address:"0xB971eF87ede563556b2ED4b1C0b0019111Dd85d2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:56}}]},{key:"polygon",chainId:137,name:"Polygon",rpcEnv:["POLYGON_RPC_URL","POLYGON_RPC"],nativeCurrency:{symbol:"POL",decimals:18},explorer:"https://polygonscan.com",dexscreenerSlug:"polygon",venueKind:"uniswap-v3",wrappedNative:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",stableQuoteAssets:["0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359","0xc2132D05D31c914a87C6611C10748AEb04B58e8F"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WMATIC->USDC fee 500 quoted 0.0720 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:137}}]},{key:"stable",chainId:988,name:"Stable Mainnet",rpcEnv:["STABLE_RPC_URL","STABLE_RPC"],nativeCurrency:{symbol:"USDT0",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x5d442b349590a6048Eb2dC0eC346cAA5F47A9ab5",venues:[{kind:"quoter",address:"0xb070179E7032CdA868b53e6C1742F80c9e940d1A",label:"Uniswap V3 QuoterV2 (canonical)",verified:{method:"Stable is on the OFFICIAL Uniswap v3 Deployments List (governance-recognised 2026-05-12, UAC process completed 2026-04, deployed by Protofire), so this is a canonical deployment rather than a fork. eth_getCode returned 8273 bytes, the same size as the canonical quoter on the seven already-verified chains. Functional probe on a live pool (TOAST -> USDT0, fee 10000): 100 in -> 0.000003, 1000 -> 0.000031, 10000 -> 0.000319 USDT0. Output scales monotonically with input, which is a working quoter answering, not a revert. Two of three sampled pools carry non-zero liquidity. NOTE: the pools discovered so far are thin, so real routing size is limited -- the venue is proved, deep liquidity is not.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:988}},{kind:"router",address:"0x32eaf9B5d5F2CD7361c5012890C943D7de84C22a",label:"Uniswap SwapRouter02 (canonical)",verified:{method:"eth_getCode returned 24497 bytes. Cross-checked on-chain rather than trusted from docs: router.factory() returns 0x88f0a512ef09175d456bc9547f914f48c013e4aa, the same v3 core factory that created the pools quoted above, and router.WETH9() returns the wrappedNative recorded on this chain entry. Address published in the Stable docs DEX reference and the Uniswap deployments list.",source:"docs.stable.xyz/en/reference/dexes + on-chain factory()/WETH9() round-trip",date:"2026-08-05",chainId:988}}]},{key:"hyperevm",chainId:999,name:"HyperEVM",rpcEnv:["HYPEREVM_RPC_URL","HYPER_EVM_RPC"],nativeCurrency:{symbol:"HYPE",decimals:18},dexscreenerSlug:"hyperevm",venueKind:"uniswap-v3",wrappedNative:"0x5555555555555555555555555555555555555555",venues:[{kind:"quoter",address:"0x03A918028f22D9E1473B7959C927AD7425A45C7C",label:"HyperSwap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle(1 WHYPE -> USDT0) returned live output on all four fee tiers (100: 57.3385, 500: 57.4187, 3000: 57.3237, 10000: 56.1963 USDT0). Decimals read on-chain: WHYPE 18, USDT0 6. Best tier checked against an INDEPENDENT control the same minute -- Hyperliquid allMids put HYPE at 57.3205, so the pool is 0.171% from the perp mid, which is the right shape for fee plus impact rather than a wrong contract or a decimals bug.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}},{kind:"router",address:"0x4E2960a8cd19B467b82d26D83fAcb0fAE26b094D",label:"HyperSwap V3 SwapRouter",verified:{method:"eth_getCode returned 12070 bytes, and it is the router paired with the quoter proved above -- the same pair already shipped in UNI_V3_VENUES[999].hyperswap, which is the map the quote/prepare path actually routes through.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:999}}]},{key:"abstract",chainId:2741,name:"Abstract",rpcEnv:["ABSTRACT_RPC_URL","ABS_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},venueKind:"uniswap-v3",wrappedNative:"0x3439153EB7AF838Ad19d56E1571FBD09333C2809",venues:[{kind:"quoter",address:"0x728BD3eC25D5EDBafebB84F3d67367Cd9EBC7693",label:"Uniswap V3 QuoterV2 (Abstract deployment)",verified:{method:"Abstract is a ZK-stack chain, so CREATE2 addresses differ and the canonical Uniswap addresses are NOT valid here -- probing them returns codesize 0, which is what previously made this chain look like it had no V3 at all. Found the real deployment from live traffic instead: scanned recent Swap(...) logs, took the busiest pool, read pool.factory() = 0xa1160e73b63f322ae88cc2d8e700833e71d0b2a1, then enumerated that factory's deployer (0xf3d63166F0Ca56C3c1A3508FcE03Ff0Cf3Fb691e) and probed each of its 56 contracts with a real quoteExactInputSingle call. Exactly one answered: 1 WETH -> 1846.475731 USDC.e at fee 500. Independent sanity check: the pool's own slot0() spot price is 1873.11 USDC.e per WETH, so the quoter sits ~1.4% below spot, the right shape for fee plus price impact on this size.",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-08-05",chainId:2741}},{kind:"router",address:"0x7712FA47387542819d4E35A23f8116C90C18767C",label:"Uniswap SwapRouter02 (Abstract deployment)",verified:{method:"eth_getCode returned 167392 bytes and the runtime contains the exactInputSingle selector. router.factory() matches the factory proved above and router.WETH9() matches the wrappedNative on this entry. Chosen over its byte-identical twin (0xfD6257F4...) because this is the address real users actually route through: it appeared as tx.to on live swaps against the WETH/USDC.e pool.",source:"on-chain factory()/WETH9() round-trip + live swap tx.to sampling",date:"2026-08-05",chainId:2741}}]},{key:"robinhood",chainId:4663,name:"Robinhood Chain",rpcEnv:["RH_CHAIN_RPC","ROBINHOOD_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},dexscreenerSlug:"robinhood",venueKind:"uniswap-v3",wrappedNative:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",stableQuoteAssets:["0x5fc5360d0400a0fd4f2af552add042d716f1d168"],venues:[{kind:"quoter",address:"0x33e885ed0ec9bf04ecfb19341582aadcb4c8a9e7",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDG fee 100 quoted 1866.58 USDG, and USDG->CASHCAT fee 10000 quoted a live amount). A contract that correctly prices known pairs IS a working V3 quoter",source:"live eth_call against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"router",address:"0xcaf681a66d020601342297493863e78c959e5cb2",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode (24497 bytes) on this chain and the paired quoter at the same deployment passed a live functional quote",source:"live eth_getCode against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}},{kind:"factory",address:"0x1f7d7550b1b028f7571e69a784071f0205fd2efa",label:"Uniswap V3 Factory",verified:{method:"eth_getCode returned real bytecode (24535 bytes) and a PoolCreated log scan over this factory returned 76 pools in ~9000 recent blocks",source:"live eth_getLogs against rpc.mainnet.chain.robinhood.com",date:"2026-07-31",chainId:4663}}]},{key:"base",chainId:8453,name:"Base",rpcEnv:["BASE_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://basescan.org",dexscreenerSlug:"base",venueKind:"uniswap-v3",wrappedNative:"0x4200000000000000000000000000000000000006",stableQuoteAssets:["0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"],venues:[{kind:"quoter",address:"0x3d4e44Eb1374240CE5F1B871ab261CD16335B76a",label:"Uniswap V3 QuoterV2 (Base)",verified:{method:"functional probe: quoteExactInputSingle returned WETH->USDC at fee 500 = 1908.44 USDC, a live sane price. The canonical mainnet quoter address also has bytecode on Base but does NOT price this pair, which is exactly the false positive a codesize-only check accepts",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router",address:"0x2626664c2603336E57B271c5C0b26F421741e481",label:"Uniswap V3 SwapRouter02 (Base)",verified:{method:"eth_getCode returned real bytecode and the paired Base quoter passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:8453}},{kind:"router-v2",address:"0x4752ba5DBc23f44D87826276BF6Fd6b1C372aD24",label:"Uniswap V2 Router02 (Base)",verified:{method:"eth_getCode returned 17891 bytes; live getAmountsOut on WETH->USDC round-tripped to 98.75% (2x0.30% fee + impact)",source:"https://docs.uniswap.org/contracts/v2/reference/smart-contracts/v2-deployments",date:"2026-07-30",chainId:8453}}]},{key:"arbitrum",chainId:42161,name:"Arbitrum One",rpcEnv:["ARBITRUM_RPC_URL","ARB_RPC_URL"],nativeCurrency:{symbol:"ETH",decimals:18},explorer:"https://arbiscan.io",dexscreenerSlug:"arbitrum",venueKind:"uniswap-v3",wrappedNative:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",stableQuoteAssets:["0xaf88d065e77c8cC2239327C5EDb3A432268e5831","0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"],venues:[{kind:"quoter",address:"0x61fFE014bA17989E743c5F6cB21bF9697530B21e",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WETH->USDC fee 500 quoted 1908.72 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}},{kind:"router",address:"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:42161}}]},{key:"avalanche",chainId:43114,name:"Avalanche C-Chain",rpcEnv:["AVALANCHE_RPC_URL","AVAX_RPC_URL"],nativeCurrency:{symbol:"AVAX",decimals:18},explorer:"https://snowtrace.io",dexscreenerSlug:"avalanche",venueKind:"uniswap-v3",wrappedNative:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",stableQuoteAssets:["0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"],venues:[{kind:"quoter",address:"0xbe0F5544EC67e9B3b2D979aaA43f18Fd87E6257F",label:"Uniswap V3 QuoterV2",verified:{method:"functional probe, not a codesize check: quoteExactInputSingle returned a live sane price (WAVAX->USDC fee 500 quoted 6.48 USDC). A contract that correctly prices a known pair IS a working V3 quoter",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}},{kind:"router",address:"0xbb00FF08d01D300023C629E8fFfFcb65A5a578cE",label:"Uniswap V3 SwapRouter02",verified:{method:"eth_getCode returned real bytecode on this chain and the paired quoter at the same deployment passed a live functional quote",source:"scripts/verify-v3-venues.mjs (re-runnable)",date:"2026-07-30",chainId:43114}}]}]);function Nt(){return Ot.map(e=>vt(_t(e)))}import{createHash as On,createHmac as Pt,timingSafeEqual as Nn}from"node:crypto";import{readFileSync as Tn}from"node:fs";import{homedir as In}from"node:os";import{join as fe}from"node:path";function _n(){if(process.env.ORACLE_TEST_ISOLATE_SECRETS==="1"){let r=(process.env.ORACLE_EXEC_ENV_FILE||"").trim();return r?[r]:[]}let e=(process.env.ORACLE_EXEC_ENV_FILE||process.env.MAD_EXEC_ENV_FILE||"").trim(),t=In();if(process.env.ORACLE_PUBLIC_DESKTOP==="1"){let r=(process.env.ORACLE_CONFIG_DIR||fe(t,".config","oracle")).trim();return[e,fe(r,"exec.env")].filter(Boolean)}return[e,fe(t,".config","oracle","exec.env"),fe(t,".config","mad-desk","exec.env")].filter(Boolean)}function Rt(e,t,r){let o=e??process.env[t]??process.env[r];if(!String(o||"").trim())for(let n of _n())try{let s=Tn(n,"utf8"),a=s.match(new RegExp(`^${t}=(.*)$`,"m"))||s.match(new RegExp(`^${r}=(.*)$`,"m"));if(a&&(o=a[1].trim(),o))break}catch{}if(!String(o||"").trim())throw new Error(`${t} required for attestation. Set it in the environment, or place ${t}=<value> in ~/.config/oracle/exec.env`);return o}var he=100,Lt=2e4;function me(e){return Array.isArray(e)?`[${e.map(me).join(",")}]`:e&&typeof e=="object"?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${me(e[t])}`).join(",")}}`:JSON.stringify(e??null)}function Ut(e,{required:t=!1}={}){try{return Rt(e,"ORACLE_ROUTE_ATTESTATION_SECRET","MAD_ROUTE_ATTESTATION_SECRET")}catch(r){if(t)throw r;return null}}function Pe(e){let{signature:t,...r}=e;return r}function qt(e,{secret:t}={}){let r=Ut(t);return r?{...e,signature:Pt("sha256",r).update(me(Pe(e))).digest("hex")}:e}function Rn(e){let t=String(e||"").toLowerCase();if(!/^0x[0-9a-f]+$/.test(t)||t.length<10||t.length%2!==0)throw new Error("auto-slippage calldata must be even-length hex with a selector");return On("sha256").update(Buffer.from(t.slice(2),"hex")).digest("hex")}function Bt(e,{chainId:t,venue:r,data:o,secret:n}={}){if(!e||e.mode!=="auto")throw new Error("bounded auto-slippage guard required");if(Number(e.chainId)!==Number(t))throw new Error("auto-slippage guard chain mismatch");if(String(e.venue).toLowerCase()!==String(r||"").toLowerCase())throw new Error("auto-slippage guard venue mismatch");let s=Ut(n);if(s){let f=Pt("sha256",s).update(me(Pe(e))).digest("hex");if(!Ln(e.signature,f))throw new Error("auto-slippage guard signature mismatch \u2014 refusing to bind a guard this Oracle did not issue")}let a=Number(e.selectedBps),c=Number(e.capBps);if(!Number.isInteger(a)||a<0||a>he||!Number.isInteger(c)||c<0||c>he||a>c)throw new Error("auto-slippage guard bounds are invalid");let i=BigInt(e.quoteAmountOut??0),l=BigInt(e.minAmountOut??0);if(i<=0n||l<=0n)throw new Error("auto-slippage guard amounts must be positive");let u=i*BigInt(1e4-a),d=u/10000n;if(u%10000n!==0n&&(d+=1n),l<d)throw new Error("auto-slippage guard is under-protected relative to its quote");let h=qn(o);if(h!=null&&h!==l)throw new Error(`auto-slippage: calldata encodes floor ${h}, not the guard floor ${l} \u2014 refusing to bind`);return qt({...Pe(e),calldataHash:Rn(o)},{secret:n})}function Ln(e,t){let r=Buffer.from(String(e??""),"utf8"),o=Buffer.from(String(t??""),"utf8");return r.length!==o.length||r.length===0?!1:Nn(r,o)}function Le(e,t=0){let r=Number(e);return Number.isFinite(r)?r:t}function Pn(e){let t=e==null?he:Number(e);if(!Number.isInteger(t)||t<0)throw new Error("auto-slippage cap must be a non-negative integer bps value");return Math.min(t,he)}function Un({liquidityUsd:e,priceChange5m:t=0,quoteAgeMs:r=0,crossChain:o=!1,requestedCapBps:n}={}){let s=Le(e,0),a=s>0?s>=25e4?5:s>=1e5?10:s>=5e4?20:s>=1e4?40:70:o?30:10,c=Math.min(60,Math.abs(Le(t,0))*2),i=Math.min(40,Math.floor(Math.max(0,Le(r,0))/5e3)*5),l=Math.max(25,Math.ceil(20+a+c+i)),u=Pn(n);return{mode:"auto",requiredBps:l,selectedBps:Math.min(l,u),capBps:u,executable:l<=u}}function $t({chainId:e,venue:t,quoteAmountOut:r,liquidityUsd:o,priceChange5m:n=0,quoteAgeMs:s=0,crossChain:a=!1,requestedCapBps:c,quotedAtMs:i=Date.now(),ttlMs:l=Lt,secret:u}={}){let d=BigInt(r??0);if(d<=0n)throw new Error("auto-slippage guard requires positive quoteAmountOut");let h=Un({liquidityUsd:o,priceChange5m:n,quoteAgeMs:s,crossChain:a,requestedCapBps:c});if(!h.executable)throw new Error(`auto-slippage requires ${h.requiredBps} bps above hard/requested cap ${h.capBps}; route blocked`);let f=Number(i);if(!Number.isFinite(f))throw new Error("auto-slippage: quotedAtMs must be a finite number");let p=Math.min(3e4,Math.max(1e3,Number(l)||Lt)),m=d*BigInt(1e4-h.selectedBps),b=m/10000n;if(m%10000n!==0n&&(b+=1n),b>d&&(b=d),d>0n&&b<=0n)throw new Error(`auto-slippage: quote ${d} is too small to express a ${h.selectedBps} bps floor without rounding to zero`);let y=Number((d-b)*10000n/(d===0n?1n:d));if(y>h.capBps)throw new Error(`auto-slippage: realised floor implies ${y} bps, above cap ${h.capBps} \u2014 refusing to issue a guard weaker than advertised`);return qt({mode:"auto",chainId:Number(e),venue:String(t||"unknown"),quoteAmountOut:d.toString(),minAmountOut:b.toString(),requiredBps:h.requiredBps,selectedBps:h.selectedBps,capBps:h.capBps,quotedAtMs:f,expiresAtMs:f+p},{secret:u})}function qn(e){let t=String(e||"");if(!/^0x[0-9a-fA-F]+$/.test(t)||t.length<10||t.length%2!==0)return null;let r=t.slice(0,10).toLowerCase(),o=[];for(let s=10;s+64<=t.length;s+=64)o.push(t.slice(s,s+64));let n=s=>o[s]==null?null:BigInt("0x"+o[s]);switch(r){case"0x414bf389":return n(6);case"0x04e45aaf":return n(5);case"0xc04b8d59":{let s=n(0);if(s==null)return null;let a=Number(s)/32;return!Number.isInteger(a)||a<0?null:n(a+4)}case"0xb858183f":{let s=n(0);if(s==null)return null;let a=Number(s)/32;return!Number.isInteger(a)||a<0?null:n(a+3)}case"0xa026383e":return n(6);case"0x38ed1739":case"0x5c11d795":return n(1);case"0x7ff36ab5":case"0xb6f9de95":return n(0);case"0x18cbafe5":case"0x791ac947":return n(1);default:return null}}var Bn=Object.freeze({"8da5cb5b":{name:"owner()",weight:"low",note:"contract has an owner"},f2fde38b:{name:"transferOwnership(address)",weight:"low",note:"ownership transferable"},"40c10f19":{name:"mint(address,uint256)",weight:"high",note:"owner can mint new supply"},a0712d68:{name:"mint(uint256)",weight:"high",note:"owner can mint new supply"},f9f92be4:{name:"blacklist(address)",weight:"high",note:"addresses can be blocked from selling"},e4997dc5:{name:"removeBlackList(address)",weight:"high",note:"blacklist machinery present"},"8456cb59":{name:"pause()",weight:"high",note:"transfers can be frozen"},"3f4ba83a":{name:"unpause()",weight:"high",note:"pausable transfers"},c0246668:{name:"setFee/excludeFromFee",weight:"high",note:"transfer fees can be changed"},"3659cfe6":{name:"upgradeTo(address)",weight:"high",note:"logic can be replaced entirely"},"4f1ef286":{name:"upgradeToAndCall(address,bytes)",weight:"high",note:"logic can be replaced entirely"}}),$n=Object.freeze([{label:"eip1967",slot:"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc"},{label:"zeppelinos",slot:"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3"},{label:"eip1822",slot:"0xc5f16f0fcc639fa48a6947836d9850f504798523bf8c9a3a87d5876cf622bcf7"}]),Fn=`0x${"0".repeat(64)}`;function Dn(e){return!e||e==="0x"||e===Fn}async function Ft(e={},t={}){let r=t.rpcCall||q,o=String(e.address||"").trim().toLowerCase(),n=Number(e.chainId);if(!/^0x[a-f0-9]{40}$/.test(o))return{status:"error",error:"address must be a 0x-prefixed EVM address",risk:"unknown-risk",findings:[],notes:[]};if(!Number.isInteger(n))return{status:"error",error:"chainId is required",risk:"unknown-risk",findings:[],notes:[]};let s;try{s=await r(n,"eth_getCode",[o,"latest"],t)}catch(m){return{address:o,chainId:n,status:"unavailable",error:m?.message||"eth_getCode failed",risk:"unknown-risk",findings:[],isProxy:!1,codeSize:0,notes:["could not read contract code; treat as unverified"]}}if(!s||s==="0x")return{address:o,chainId:n,status:"ok",risk:"high",findings:[{selector:"-",name:"no-code",weight:"high",note:"no contract deployed at this address"}],isProxy:!1,codeSize:0,notes:["nothing is deployed here \u2014 an approval or transfer to this address is unrecoverable"]};let a=[],c=[],i=s.slice(2).toLowerCase();for(let[m,b]of Object.entries(Bn))i.includes(m)&&c.push({selector:`0x${m}`,...b});let l=!1,u=null,d=null,h=await Promise.all($n.map(async({label:m,slot:b})=>{try{let y=await r(n,"eth_getStorageAt",[o,b,"latest"],t);return{label:m,word:y,error:null}}catch{return{label:m,word:null,error:`proxy slot (${m}) unreadable; proxy status uncertain`}}}));for(let m of h)m.error&&a.push(m.error),!l&&m.word&&!Dn(m.word)&&(l=!0,u=m.label,d=`0x${String(m.word).slice(-40)}`);l&&(c.push({selector:u,name:"proxy",weight:"high",note:"implementation is upgradeable \u2014 current behaviour is not a guarantee"}),a.push(`bytecode scan covers the proxy (${u}), not the implementation ${d} it delegates to`));let p=c.filter(m=>m.weight==="high").length>0?"high":c.length>0?"elevated":"unknown-risk";return p==="unknown-risk"&&a.push("no owner-power selectors found; this is weak evidence, not a safety guarantee"),{address:o,chainId:n,status:"ok",risk:p,findings:c,isProxy:l,proxyStandard:u,implementation:d,codeSize:Math.floor(i.length/2),notes:a}}var Mn=/^0x[0-9a-fA-F]{40}$/,Hn=4663;function be(e,t){let r=String(e||"").trim();if(!Mn.test(r))throw new Error(`evm-token-sniper: ${t} must be a 0x EVM address`);return r}function Ue(e,t){let r=String(e??"").trim();if(!/^\d+$/.test(r)||BigInt(r)<=0n)throw new Error(`evm-token-sniper: ${t} must be a positive raw integer amount`);return r}function te(e,t){return e==null||e===""?null:Ue(e,t)}function jn({chainId:e,tokenAddress:t,tokenIn:r,amountIn:o,recipient:n,quote:s,topPool:a,unsignedTx:c,args:i,opts:l}){let u=c?.tx;if(!u||typeof u!="object")throw new Error("local-signer envelope requires unsigned tx object");let d=be(u.to,"prepared destination"),h=String(u.data||"").toLowerCase();if(!/^0x[0-9a-f]+$/.test(h))throw new Error("local-signer envelope requires hex calldata");let f=Ue(u.value??o,"prepared native value");if(BigInt(f)!==BigInt(o))throw new Error("local-signer envelope requires native value equal amountIn");let p=te(u.gasLimit??i.gasLimit,"gasLimit"),m=te(u.maxFeePerGas??i.maxFeePerGas,"maxFeePerGas");if(!p||!m)throw new Error("local-signer envelope requires explicit gasLimit and maxFeePerGas caps");let b=Number(l.nowMs??Date.now()),y=Math.min(6e4,Math.max(1e3,Number(i.ttlMs??i.expiresInMs??3e4)||3e4)),x=$t({chainId:e,venue:"uniswap-v3",quoteAmountOut:s?.amountOut,liquidityUsd:a?.liquidityUsd,requestedCapBps:i.slippageBps??50,quotedAtMs:b,ttlMs:y,secret:l.routeAttestationSecret}),C=Bt(x,{chainId:e,venue:"uniswap-v3",data:h,secret:l.routeAttestationSecret}),_={chainId:e,from:n,to:d,data:h,value:f,gasLimit:p,maxFeePerGas:m,slippageBps:C.selectedBps,expiresAtMs:b+y},O=te(u.maxPriorityFeePerGas??i.maxPriorityFeePerGas,"maxPriorityFeePerGas");return O&&(_.maxPriorityFeePerGas=O),i.nonce!==void 0&&(_.nonce=Number(i.nonce)),(i.txType!==void 0||O)&&(_.type=Number(i.txType??2)),i.l1FeeWei!==void 0&&(_.l1FeeWei=te(i.l1FeeWei,"l1FeeWei")??"0"),i.operatorFeeWei!==void 0&&(_.operatorFeeWei=te(i.operatorFeeWei,"operatorFeeWei")??"0"),{version:1,surface:"evm-swap",action:"swap",provider:"uniswap-v3",owner:n,destination:d,tradeId:i.tradeId||`evm-token-sniper-${e}-${t.toLowerCase()}`,slippageBps:C.selectedBps,expiresAtMs:b+y,fee:{oracleFeeBps:5},autoSlippage:C,artifact:{chainId:e,owner:n,transactions:[_]},meta:{source:"evm-token-sniper",tokenIn:r,tokenOut:t}}}function Vn(e,t){if(t){if(Number(t.chainId)!==e)throw new Error(`evm-token-sniper: supplied scanner chain ${t.chainId} does not match ${e}`);return t}Nt();let r=St(e);if(!r)throw new Error(`evm-token-sniper: unsupported EVM chainId ${e}`);return r}function zn({token:e,pools:t,structuralRisk:r,scannerRisk:o,sellability:n,quote:s,args:a,scanner:c}){let i=[];return e?.evidence!==E.LIVE&&i.push("token identity is not live-verified"),(!Array.isArray(t?.pools)||t.pools.length===0)&&i.push("no liquid pool was resolved"),r?.status!=="ok"&&i.push("structural contract risk is unavailable"),r?.risk==="high"&&i.push("structural contract risk is high"),o?.verdict!==w.PASS&&i.push(`scanner risk verdict is ${o?.verdict||"UNKNOWN"}`),c.supports?.("sellSimulation")?n?.verdict!==w.PASS&&i.push(`sellability verdict is ${n?.verdict||"UNKNOWN"}`):i.push("sell simulation is unavailable on this chain"),c.supports?.("quote")?s?.evidence!==E.LIVE&&i.push("no live quote was returned"):i.push("live quoting is unavailable on this chain"),c.supports?.("prepareUnsignedTx")||i.push("unsigned transaction preparation is unavailable on this chain"),a.tokenIn||i.push("tokenIn is required to prepare"),a.amountIn||i.push("amountIn is required to prepare"),a.recipient||i.push("recipient is required to prepare"),i}async function Dt(e={},t={}){let r=Number(e.chainId??Hn);if(!Number.isInteger(r)||r<=0)throw new Error("evm-token-sniper: chainId must be a positive integer");lt(r,"evm-token-sniper");let o=be(e.tokenAddress||e.address||e.token,"tokenAddress"),n=e.tokenIn?be(e.tokenIn,"tokenIn"):null,s=e.recipient?be(e.recipient,"recipient"):null,a=e.amountIn==null?null:Ue(e.amountIn,"amountIn"),c=Vn(r,t.scanner),i=t.scanContractRisk||Ft,[l,u,d]=await Promise.all([c.resolveToken(o),c.resolvePools(o),i({address:o,chainId:r},t.contractRiskOpts||t)]),h=await c.scoreRisk(o),f=null;c.supports?.("sellSimulation")&&a?f=await c.sellSimulation({token:o,amountIn:a,base:n||void 0}):c.supports?.("sellSimulation")&&(f=await c.sellSimulation({token:o,amountIn:"10000000000000000"}));let p=null;c.supports?.("quote")&&n&&a&&(p=await c.quote({tokenIn:n,tokenOut:o,amountIn:a}));let m={...e,tokenIn:n,amountIn:a,recipient:s},b=zn({token:l,pools:u,structuralRisk:d,scannerRisk:h,sellability:f,quote:p,args:m,scanner:c}),y=null,x=null,C=null;if(e.prepare===!0&&b.length===0){y=await c.prepareUnsignedTx({tokenIn:n,tokenOut:o,amountIn:a,recipient:s,slippageBps:e.slippageBps??50,fee:p?.fee});try{x=jn({chainId:r,tokenAddress:o,tokenIn:n,amountIn:a,recipient:s,quote:p,topPool:u?.pools?.[0]||null,unsignedTx:y,args:e,opts:t})}catch(_){C=String(_?.message||_).slice(0,200)}}return{provider:"evm-token-sniper",execution:"armed-local",armed:!!x,signing:"local-signer",broadcasting:"local-signer",chainId:r,chain:{key:c.key,name:c.name,nativeCurrency:c.nativeCurrency},token:l,pools:u,topPool:u?.pools?.[0]||null,structuralRisk:d,scannerRisk:h,sellability:f,quote:p,blockedReasons:b,prepared:!!y,unsignedTx:y,localSignerEnvelope:x,localSignerBlockedReason:C,signed:x?"pending-local-signer":!1,broadcast:x?"pending-local-signer":!1}}import{homedir as qe}from"node:os";import{join as Be}from"node:path";var Mt=process.env.ORACLE_PUBLIC_DESKTOP==="1",Wn=Mt?process.env.ORACLE_CONFIG_DIR||Be(qe(),".config","oracle"):Be(qe(),".config","oracle"),vs=Mt?Wn:Be(qe(),".config","mad-desk");var Gn=4663,Kn="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",Xn="Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB";function $e(e=process.env){return String((e||process.env).ORACLE_SNIPE_EXECUTE||"").trim()==="1"}function Ht(e){return String(e||"").trim().replace(/^@/,"")}async function Yn({handle:e,limit:t=5,xurlFn:r=Ye}={},o={}){let n=Ht(e);if(!n)throw new Error("twitter-ca-watch: handle required");let s=await r("xurl",{command:"search",query:`from:${n}`,limit:Math.min(20,Math.max(1,Number(t)||5))},o);return s?.ok?{ok:!0,tweets:ze(s.stdout),raw:s}:{ok:!1,error:s?.error||"xurl search failed",tweets:[]}}async function Zn(e,{chainId:t,amountIn:r,tokenIn:o,recipient:n,prepare:s},a){let c=await Dt({chainId:t,tokenAddress:e,amountIn:r,tokenIn:o,recipient:n,prepare:s===!0},a),i=c.topPool||c.pools?.pools?.[0]||null;return{chainFamily:"evm",chainId:t,address:e,topPool:i,quoteAsset:c.pools?.quoteAsset||null,sellability:c.sellability||null,blockedReasons:c.blockedReasons||[],prepared:!!c.prepared,unsignedTx:c.unsignedTx||null,localSignerEnvelope:c.localSignerEnvelope||null,execution:!1,broadcast:!1}}async function Qn(e,t){let r=await yt(e,{chainSlug:"solana",stables:[Kn,Xn]},t);return{chainFamily:"solana",chainId:"solana",address:e,topPool:r.topPool,pools:r.pools,prepared:!1,execution:!1,broadcast:!1,note:"Solana CA ranked on USD book. Prepare stays Jupiter/local-signer; this tick does not broadcast."}}async function Jn(e,t={},r={}){let o=Number(t.chainId??Gn),n=[];for(let s of e.evm||[])n.push(await Zn(s,{...t,chainId:o},r));for(let s of e.solana||[])n.push(await Qn(s,r));return n}async function jt(e={},t={}){let r=Ht(e.handle),o=e.seen instanceof Set?e.seen:new Set(e.seen||[]),n=await Yn({handle:r,limit:e.limit,xurlFn:t.xurlFn},t);if(!n.ok)return{ok:!1,handle:r,error:n.error,hits:[],seen:[...o]};let s=[];for(let c of n.tweets){let i=c.id||`${r}:${c.text.slice(0,80)}`;if(o.has(i))continue;let l=Ve(c.text,{extras:c.urls||[]});if(!l.all.length){o.add(i);continue}let d=await(t.evaluateFn||Jn)(l,e,t);o.add(i),s.push({tweetId:c.id||null,handle:r,text:c.text,contracts:l,evaluations:d})}let a=e.automated!==!1;return{ok:!0,handle:r,source:"twitter-ca-watch",automated:a,card:!1,notify:!1,telegram:!1,execution:!1,broadcast:!1,snipeExecuteEnabled:$e(t.env||process.env),hits:s,seen:[...o]}}var Vt=`oracle snipe twitter <handle> [--chain 4663] [--json]
9
9
 
10
10
  Watch one X/Twitter account for contract addresses, rank the USD book, sell-sim,
11
11
  and PREPARE only. This does not broadcast.
@@ -15,12 +15,12 @@ and PREPARE only. This does not broadcast.
15
15
  Automated ticks never send a Telegram / Claude / Codex card.
16
16
  Fill still requires the local signer + Telegram Allow / /approve.
17
17
  ORACLE_SNIPE_EXECUTE=1 does not start an autonomous loop.
18
- `;function jt(e,t){let r=e.indexOf(`--${t}`);if(r>=0&&e[r+1]&&!e[r+1].startsWith("--"))return e[r+1];let s=e.find(n=>n.startsWith(`--${t}=`));return s?s.split("=").slice(1).join("="):null}var _s={name:"snipe",summary:"Twitter CA watch \u2192 USD-book prepare (no broadcast)",group:"read",usage:Ht,async run(e){let t=e.argv||[];if(!t.length||t[0]==="--help"||t[0]==="-h")return process.stdout.write(Ht),0;if(t[0]!=="twitter")return process.stderr.write(`usage: oracle snipe twitter <handle>
18
+ `;function zt(e,t){let r=e.indexOf(`--${t}`);if(r>=0&&e[r+1]&&!e[r+1].startsWith("--"))return e[r+1];let o=e.find(n=>n.startsWith(`--${t}=`));return o?o.split("=").slice(1).join("="):null}var Ns={name:"snipe",summary:"Twitter CA watch \u2192 USD-book prepare (no broadcast)",group:"read",usage:Vt,async run(e){let t=e.argv||[];if(!t.length||t[0]==="--help"||t[0]==="-h")return process.stdout.write(Vt),0;if(t[0]!=="twitter")return process.stderr.write(`usage: oracle snipe twitter <handle>
19
19
  `),1;let r=t[1];if(!r)return process.stderr.write(`snipe twitter requires a handle
20
- `),1;let s=await Mt({handle:r,chainId:jt(t,"chain")?Number(jt(t,"chain")):4663});if(t.includes("--json"))return process.stdout.write(`${JSON.stringify({...s,snipeExecuteEnabled:$e()},null,2)}
21
- `),s.ok?0:1;if(!s.ok)return process.stderr.write(`${s.error}
22
- `),1;if(!s.hits.length)return process.stdout.write(`no new CA tweets from @${r}
23
- `),0;for(let n of s.hits){process.stdout.write(`@${r} ${n.tweetId||""} ${n.contracts.all.map(o=>o.address).join(" ")}
24
- `);for(let o of n.evaluations){let a=o.topPool;process.stdout.write(` ${o.chainFamily} ${o.address} pool=${a?.dex||"none"} liq=${a?.liquidityUsd??"n/a"} prepared=${o.prepared} broadcast=false
20
+ `),1;let o=await jt({handle:r,chainId:zt(t,"chain")?Number(zt(t,"chain")):4663});if(t.includes("--json"))return process.stdout.write(`${JSON.stringify({...o,snipeExecuteEnabled:$e()},null,2)}
21
+ `),o.ok?0:1;if(!o.ok)return process.stderr.write(`${o.error}
22
+ `),1;if(!o.hits.length)return process.stdout.write(`no new CA tweets from @${r}
23
+ `),0;for(let n of o.hits){process.stdout.write(`@${r} ${n.tweetId||""} ${n.contracts.all.map(s=>s.address).join(" ")}
24
+ `);for(let s of n.evaluations){let a=s.topPool;process.stdout.write(` ${s.chainFamily} ${s.address} pool=${a?.dex||"none"} liq=${a?.liquidityUsd??"n/a"} prepared=${s.prepared} broadcast=false
25
25
  `)}}return process.stdout.write(`PREPARE only. No card. Allow on Telegram / local signer still required to fill.
26
- `),0}};export{_s as default};
26
+ `),0}};export{Ns as default};