@oracle-agent/oracle 0.35.47 → 0.35.48

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.
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import{createInterface as ht}from"node:readline";var P=Object.freeze({maxRequestBytes:256*1024,maxResponseBytes:2*1024*1024,maxTools:256,maxToolNameLength:64,maxArgumentBytes:128*1024,defaultCallTimeoutMs:3e4,maxCallTimeoutMs:6e4,maxConcurrentCalls:32}),bt=/^[A-Za-z0-9_-]{1,64}$/;function Z(t,e){return{jsonrpc:"2.0",id:t??null,result:e}}function A(t,e,r){return{jsonrpc:"2.0",id:t??null,error:{code:e,message:r}}}function gt(t){return!!(t&&typeof t=="object"&&!Array.isArray(t)&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&t.method.length>0)}function yt(t){if(!Array.isArray(t))return[];let e=[],r=new Set;for(let o of t){if(e.length>=P.maxTools)break;if(!o||typeof o!="object"||Array.isArray(o))continue;let n=typeof o.name=="string"?o.name.trim():"";if(!bt.test(n)||r.has(n))continue;r.add(n);let i=o.inputSchema&&typeof o.inputSchema=="object"&&!Array.isArray(o.inputSchema)?{...o.inputSchema}:{type:"object",properties:{},additionalProperties:!1};i.type==="object"&&i.additionalProperties===void 0&&(i.additionalProperties=!1),e.push({...o,name:n,inputSchema:i})}return e}function wt(t){let e=Number(t)||P.defaultCallTimeoutMs;return Math.min(Math.max(e,1),P.maxCallTimeoutMs)}async function xt(t,e,r){let o;try{return await Promise.race([t,new Promise((n,i)=>{o=setTimeout(()=>{let s=new Error("tool call timed out");s.code="ORACLE_MCP_TIMEOUT",i(s);try{r?.()}catch{}},e)})])}finally{clearTimeout(o)}}function St(t){return t===null?"null":Array.isArray(t)?"array":Number.isInteger(t)?"integer":typeof t}function X(t,e,r="arguments",o=0){if(!e||typeof e!="object"||Array.isArray(e))return null;if(o>12)return`${r} exceeded the nesting limit`;if(Array.isArray(e.oneOf)&&e.oneOf.length&&!e.oneOf.some(i=>X(t,i,r,o+1)===null))return`${r} did not match an allowed shape`;if(Array.isArray(e.anyOf)&&e.anyOf.length&&!e.anyOf.some(i=>X(t,i,r,o+1)===null))return`${r} did not match a required alternative`;if(Array.isArray(e.enum)&&!e.enum.some(n=>Object.is(n,t)))return`${r} must be one of the allowed values`;if(Object.hasOwn(e,"const")&&!Object.is(e.const,t))return`${r} must equal the required constant`;if(e.type){let n=St(t);if(!(e.type==="number"?typeof t=="number"&&Number.isFinite(t):e.type==="integer"?Number.isSafeInteger(t):n===e.type))return`${r} must be ${e.type}`}if(typeof t=="string"){let n=Math.min(Number.isSafeInteger(e.maxLength)?e.maxLength:16384,16384);if(t.length>n)return`${r} exceeded the string limit`;if(Number.isSafeInteger(e.minLength)&&t.length<e.minLength)return`${r} is too short`}if(Array.isArray(t)){let n=Math.min(Number.isSafeInteger(e.maxItems)?e.maxItems:1e3,1e3);if(t.length>n)return`${r} exceeded the array limit`;if(Number.isSafeInteger(e.minItems)&&t.length<e.minItems)return`${r} has too few items`;if(e.items)for(let i=0;i<t.length;i+=1){let s=X(t[i],e.items,`${r}[${i}]`,o+1);if(s)return s}}if(t&&typeof t=="object"&&!Array.isArray(t)){let n=Object.keys(t);if(n.length>256)return`${r} exceeded the property limit`;let i=e.properties&&typeof e.properties=="object"?e.properties:{};for(let s of Array.isArray(e.required)?e.required:[])if(!Object.hasOwn(t,s))return`${r}.${s} is required`;if(e.additionalProperties===!1){let s=n.find(l=>!Object.hasOwn(i,l));if(s)return`${r}.${s} is not allowed`}for(let s of n){if(!Object.hasOwn(i,s))continue;let l=X(t[s],i[s],`${r}.${s}`,o+1);if(l)return l}}return null}function kt(t,e={}){let r=yt(t?.tools),o=new Set(r.map(c=>c.name)),n=new Map(r.map(c=>[c.name,c])),i=typeof t?.name=="string"&&t.name?t.name.slice(0,80):"oracle-mcp",s=typeof t?.version=="string"&&t.version?t.version.slice(0,40):"1",l=wt(e.callTimeoutMs),d=!1;return async function(u){let f=u?.id??null;if(!gt(u))return A(f,-32600,"invalid request");if(u.method==="initialize")return d=!0,Z(f,{protocolVersion:u.params?.protocolVersion??"2025-03-26",capabilities:{tools:{}},serverInfo:{name:i,version:s}});if(u.method==="notifications/initialized")return null;if(u.method==="ping")return Z(f,{});if(!d)return A(f,-32002,"server not initialized");if(u.method==="tools/list")return Z(f,{tools:r});if(u.method==="tools/call"){let h=u.params?.name,b=u.params?.arguments??{};if(typeof h!="string"||!o.has(h))return A(f,-32602,"unknown tool");if(!b||typeof b!="object"||Array.isArray(b))return A(f,-32602,"tool arguments must be an object");let p;try{p=JSON.stringify(b)}catch{return A(f,-32602,"tool arguments are not serializable")}if(Buffer.byteLength(p)>P.maxArgumentBytes)return A(f,-32602,"tool arguments exceeded the size limit");let y=X(b,n.get(h)?.inputSchema);if(y)return A(f,-32602,y);try{let w=new AbortController,$=await xt(Promise.resolve(t.call(h,b,{signal:w.signal})),l,()=>w.abort(new Error("tool call timed out")));return Z(f,$)}catch(w){if(w?.code==="ORACLE_MCP_TIMEOUT")return A(f,-32001,"tool call timed out");let $=typeof w?.message=="string"?w.message.replace(/\s+/g," ").trim():"",M=/\b(requires?|must be|missing|unknown|invalid|expected|unsupported|out of range|too (?:large|small|long|many)|not a|cannot convert)\b/i.test($),K=/https?:\/\/|[/~][\w.-]+\/|0x[0-9a-fA-F]{8,}|[A-Za-z0-9+/_-]{24,}={0,2}|\b(?:secret|apikey|api[-_ ]key|private[-_ ]?key|token|password|credential|seed|mnemonic)s?\b/i.test($.replace(/\btoken(?:In|Out|s\b)/g,"asset"));return M&&!K&&$.length<=200?A(f,-32e3,`tool call failed: ${$}`):A(f,-32e3,"tool call failed")}}return A(f,-32601,"method not found")}}function Se(t,e={}){let r=e.input||process.stdin,o=e.output||process.stdout,n=Math.min(Math.max(Number(e.maxRequestBytes)||P.maxRequestBytes,64),P.maxRequestBytes),i=Math.min(Math.max(Number(e.maxResponseBytes)||P.maxResponseBytes,256),P.maxResponseBytes),s=Math.min(Math.max(Number(e.maxConcurrentCalls)||P.maxConcurrentCalls,1),P.maxConcurrentCalls),l=s*8,d=kt(t,e),c={closed:!1,inflight:0},u=ht({input:r,terminal:!1,crlfDelay:1/0}),f=0,h=[],b=!1,p=!1;function y(){if(c.closed||c.readerClosed)return;let E=c.inflight>=s||h.length>0||p;E&&!b?(b=!0,u.pause(),typeof r.pause=="function"&&r.pause()):!E&&b&&(b=!1,typeof r.resume=="function"&&r.resume(),u.resume())}function w(E){if(!E||c.closed)return;let O=JSON.stringify(E);Buffer.byteLength(O)>i&&(O=JSON.stringify(A(E.id,-32003,"response exceeded the size limit"))),o.write(`${O}
2
+ import{createInterface as ht}from"node:readline";var P=Object.freeze({maxRequestBytes:256*1024,maxResponseBytes:2*1024*1024,maxTools:256,maxToolNameLength:64,maxArgumentBytes:128*1024,defaultCallTimeoutMs:3e4,maxCallTimeoutMs:6e4,maxConcurrentCalls:32}),bt=/^[A-Za-z0-9_-]{1,64}$/;function Z(t,e){return{jsonrpc:"2.0",id:t??null,result:e}}function A(t,e,r){return{jsonrpc:"2.0",id:t??null,error:{code:e,message:r}}}function gt(t){return!!(t&&typeof t=="object"&&!Array.isArray(t)&&t.jsonrpc==="2.0"&&typeof t.method=="string"&&t.method.length>0)}function yt(t){if(!Array.isArray(t))return[];let e=[],r=new Set;for(let o of t){if(e.length>=P.maxTools)break;if(!o||typeof o!="object"||Array.isArray(o))continue;let n=typeof o.name=="string"?o.name.trim():"";if(!bt.test(n)||r.has(n))continue;r.add(n);let i=o.inputSchema&&typeof o.inputSchema=="object"&&!Array.isArray(o.inputSchema)?{...o.inputSchema}:{type:"object",properties:{},additionalProperties:!1};i.type==="object"&&i.additionalProperties===void 0&&(i.additionalProperties=!1),e.push({...o,name:n,inputSchema:i})}return e}function wt(t){let e=Number(t)||P.defaultCallTimeoutMs;return Math.min(Math.max(e,1),P.maxCallTimeoutMs)}async function xt(t,e,r){let o;try{return await Promise.race([t,new Promise((n,i)=>{o=setTimeout(()=>{let s=new Error("tool call timed out");s.code="ORACLE_MCP_TIMEOUT",i(s);try{r?.()}catch{}},e)})])}finally{clearTimeout(o)}}function St(t){return t===null?"null":Array.isArray(t)?"array":Number.isInteger(t)?"integer":typeof t}function X(t,e,r="arguments",o=0){if(!e||typeof e!="object"||Array.isArray(e))return null;if(o>12)return`${r} exceeded the nesting limit`;if(Array.isArray(e.oneOf)&&e.oneOf.length&&!e.oneOf.some(i=>X(t,i,r,o+1)===null))return`${r} did not match an allowed shape`;if(Array.isArray(e.anyOf)&&e.anyOf.length&&!e.anyOf.some(i=>X(t,i,r,o+1)===null))return`${r} did not match a required alternative`;if(Array.isArray(e.enum)&&!e.enum.some(n=>Object.is(n,t)))return`${r} must be one of the allowed values`;if(Object.hasOwn(e,"const")&&!Object.is(e.const,t))return`${r} must equal the required constant`;if(e.type){let n=St(t);if(!(e.type==="number"?typeof t=="number"&&Number.isFinite(t):e.type==="integer"?Number.isSafeInteger(t):n===e.type))return`${r} must be ${e.type}`}if(typeof t=="string"){let n=Math.min(Number.isSafeInteger(e.maxLength)?e.maxLength:16384,16384);if(t.length>n)return`${r} exceeded the string limit`;if(Number.isSafeInteger(e.minLength)&&t.length<e.minLength)return`${r} is too short`}if(Array.isArray(t)){let n=Math.min(Number.isSafeInteger(e.maxItems)?e.maxItems:1e3,1e3);if(t.length>n)return`${r} exceeded the array limit`;if(Number.isSafeInteger(e.minItems)&&t.length<e.minItems)return`${r} has too few items`;if(e.items)for(let i=0;i<t.length;i+=1){let s=X(t[i],e.items,`${r}[${i}]`,o+1);if(s)return s}}if(t&&typeof t=="object"&&!Array.isArray(t)){let n=Object.keys(t);if(n.length>256)return`${r} exceeded the property limit`;let i=e.properties&&typeof e.properties=="object"?e.properties:{};for(let s of Array.isArray(e.required)?e.required:[])if(!Object.hasOwn(t,s))return`${r}.${s} is required`;if(e.additionalProperties===!1&&n.find(l=>!Object.hasOwn(i,l))!==void 0)return`${r} contains an unsupported property`;for(let s of n){if(!Object.hasOwn(i,s))continue;let l=X(t[s],i[s],`${r}.${s}`,o+1);if(l)return l}}return null}function kt(t,e={}){let r=yt(t?.tools),o=new Set(r.map(c=>c.name)),n=new Map(r.map(c=>[c.name,c])),i=typeof t?.name=="string"&&t.name?t.name.slice(0,80):"oracle-mcp",s=typeof t?.version=="string"&&t.version?t.version.slice(0,40):"1",l=wt(e.callTimeoutMs),d=!1;return async function(u){let f=u?.id??null;if(!gt(u))return A(f,-32600,"invalid request");if(u.method==="initialize")return d=!0,Z(f,{protocolVersion:u.params?.protocolVersion??"2025-03-26",capabilities:{tools:{}},serverInfo:{name:i,version:s}});if(u.method==="notifications/initialized")return null;if(u.method==="ping")return Z(f,{});if(!d)return A(f,-32002,"server not initialized");if(u.method==="tools/list")return Z(f,{tools:r});if(u.method==="tools/call"){let h=u.params?.name,b=u.params?.arguments??{};if(typeof h!="string"||!o.has(h))return A(f,-32602,"unknown tool");if(!b||typeof b!="object"||Array.isArray(b))return A(f,-32602,"tool arguments must be an object");let p;try{p=JSON.stringify(b)}catch{return A(f,-32602,"tool arguments are not serializable")}if(Buffer.byteLength(p)>P.maxArgumentBytes)return A(f,-32602,"tool arguments exceeded the size limit");let y=X(b,n.get(h)?.inputSchema);if(y)return A(f,-32602,y);try{let w=new AbortController,$=await xt(Promise.resolve(t.call(h,b,{signal:w.signal})),l,()=>w.abort(new Error("tool call timed out")));return Z(f,$)}catch(w){if(w?.code==="ORACLE_MCP_TIMEOUT")return A(f,-32001,"tool call timed out");let $=typeof w?.message=="string"?w.message.replace(/\s+/g," ").trim():"",M=/\b(requires?|must be|missing|unknown|invalid|expected|unsupported|out of range|too (?:large|small|long|many)|not a|cannot convert)\b/i.test($),K=/https?:\/\/|[/~][\w.-]+\/|0x[0-9a-fA-F]{8,}|[A-Za-z0-9+/_-]{24,}={0,2}|\b(?:secret|apikey|api[-_ ]key|private[-_ ]?key|token|password|credential|seed|mnemonic)s?\b/i.test($.replace(/\btoken(?:In|Out|s\b)/g,"asset"));return M&&!K&&$.length<=200?A(f,-32e3,`tool call failed: ${$}`):A(f,-32e3,"tool call failed")}}return A(f,-32601,"method not found")}}function Se(t,e={}){let r=e.input||process.stdin,o=e.output||process.stdout,n=Math.min(Math.max(Number(e.maxRequestBytes)||P.maxRequestBytes,64),P.maxRequestBytes),i=Math.min(Math.max(Number(e.maxResponseBytes)||P.maxResponseBytes,256),P.maxResponseBytes),s=Math.min(Math.max(Number(e.maxConcurrentCalls)||P.maxConcurrentCalls,1),P.maxConcurrentCalls),l=s*8,d=kt(t,e),c={closed:!1,inflight:0},u=ht({input:r,terminal:!1,crlfDelay:1/0}),f=0,h=[],b=!1,p=!1;function y(){if(c.closed||c.readerClosed)return;let E=c.inflight>=s||h.length>0||p;E&&!b?(b=!0,u.pause(),typeof r.pause=="function"&&r.pause()):!E&&b&&(b=!1,typeof r.resume=="function"&&r.resume(),u.resume())}function w(E){if(!E||c.closed)return;let O=JSON.stringify(E);Buffer.byteLength(O)>i&&(O=JSON.stringify(A(E.id,-32003,"response exceeded the size limit"))),o.write(`${O}
3
3
  `)===!1&&!p&&(p=!0,y(),o.once("drain",()=>{p=!1,M()}))}function $(E){c.inflight+=1,y(),Promise.resolve(d(E)).then(w).catch(()=>w(A(E?.id,-32603,"internal error"))).finally(()=>{c.inflight-=1,M()})}function M(){for(;!c.closed&&!p&&c.inflight<s&&h.length>0;)$(h.shift());y()}function K(){c.closed||(w(A(null,-32700,"request exceeded the size limit")),c.closed=!0,u.close(),typeof r.destroy=="function"&&r.destroy())}return r.on("data",E=>{if(c.closed)return;let O=String(E).split(`
4
4
  `);for(let H=0;H<O.length;H+=1){if(f+=Buffer.byteLength(O[H]),f>n){K();return}H<O.length-1&&(f=0)}}),u.on("line",E=>{if(c.closed)return;if(Buffer.byteLength(E)>n){K();return}let O;try{O=JSON.parse(E)}catch{w(A(null,-32700,"parse error"));return}if(h.length>=l){w(A(O?.id,-32e3,"server busy"));return}h.push(O),M()}),u.on("close",()=>{c.readerClosed=!0,e.exitOnClose!==!1&&(process.exitCode=0)}),c}import{createHash as kr,randomBytes as Er}from"node:crypto";import{mkdirSync as Ar,readFileSync as Ir,writeFileSync as Cr}from"node:fs";import{homedir as Or}from"node:os";import{dirname as vr,join as Ge}from"node:path";function ke(t){let e=String(t||"").trim();if(!e||e.includes("ts.net")||!/^https:\/\//i.test(e))return null;try{return new URL(e)}catch{return null}}var At=/^[A-Z0-9][A-Z0-9._-]{0,11}$/;function Ee(t,{coin:e,side:r,sizeUsd:o,leverage:n,venue:i,confirm:s,user:l}={}){let d=ke(t);if(!d)return null;if(e&&At.test(String(e).toUpperCase())&&d.searchParams.set("coin",String(e).toUpperCase()),(r==="long"||r==="short")&&d.searchParams.set("side",r),Number.isFinite(Number(o))&&Number(o)>=1&&d.searchParams.set("size",String(Math.min(1e5,Math.round(Number(o))))),Number.isInteger(Number(n))&&Number(n)>=1&&d.searchParams.set("lev",String(Math.min(50,Number(n)))),i){let c=String(i).toLowerCase()==="hl"?"hyperliquid":String(i).toLowerCase();d.searchParams.set("venue",c)}else d.searchParams.get("venue")||d.searchParams.set("venue","hyperliquid");return d.searchParams.set("view","perps"),d.searchParams.set("build","1"),s&&/^[0-9a-f]{32}$/i.test(String(s))&&d.searchParams.set("confirm",String(s).toLowerCase()),l&&/^0x[0-9a-fA-F]{40}$/.test(String(l))&&d.searchParams.set("user",String(l).toLowerCase()),d.toString()}var se={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 It=new Map(Object.values(se).map(t=>[t.chainId,t]));function ae(t){return It.get(Number(t))||null}var Ct=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}}]}]);var Ot=Object.freeze({1:"https://eth.blockscout.com",10:"https://explorer.optimism.io",137:"https://polygon.blockscout.com",324:"https://zksync.blockscout.com",8453:"https://base.blockscout.com",42161:"https://arbitrum.blockscout.com",534352:"https://scrollscan.com"});var yn=Object.freeze([100,50,25]),wn=Object.freeze([100,50,25,10]);var m="UNKNOWN",An=Object.freeze(["token","launch","hip3","hip4","polymarket","twap","bridge","swap","approve"]),vt=/[_*[\]`]/g;function a(t){return x(t)?String(t).replace(vt,e=>`\\${e}`):m}function x(t){return t==null?!1:typeof t=="number"?Number.isFinite(t):typeof t=="string"?t.trim()!=="":!0}function L(t){if(!x(t))return m;let e=String(t).replace(/`/g,"");return e===""?m:`\`${e}\``}function z(t,{decimals:e=2}={}){if(!x(t))return m;let r=Number(t);return Number.isFinite(r)?r.toLocaleString("en-US",{minimumFractionDigits:0,maximumFractionDigits:e}):m}function S(t,{decimals:e=2}={}){let r=z(t,{decimals:e});return r===m?m:`${r} USD`}function ce(t,{decimals:e=2}={}){let r=z(t,{decimals:e});return r===m?m:`${r}%`}function ee(t){let e=z(t,{decimals:0});return e===m?m:`${e} bps`}function V(t,e){if(!x(t))return m;let r=Number(e);if(!Number.isInteger(r)||r<0||r>77)return m;let o;try{o=BigInt(typeof t=="string"?t.trim():t)}catch{return m}let n=o<0n,i=n?-o:o,s=10n**BigInt(r),l=(i/s).toString(),d=(i%s).toString().padStart(r,"0").replace(/0+$/,"");return`${n?"-":""}${l}${d?`.${d}`:""}`}function ue(t){if(typeof t=="number"&&Number.isFinite(t))return t<0||t>1?m:t>=.75?"HIGH":t>=.4?"MEDIUM":"LOW";if(typeof t=="string"){let e=t.trim().toUpperCase();if(e==="HIGH"||e==="MEDIUM"||e==="LOW")return e}return m}function q(t={}){let e=t.chainId;if(!x(e)||!Number.isFinite(Number(e)))return x(t.chain)?a(t.chain):m;let o=ae(e)?.name||(x(t.chain)?String(t.chain):m);return`${a(o)} (chainId ${Number(e)})`}function Ae(t={}){return a(t.venue??t.dex??t.pool?.venue)}function $t(t){return t==null?"NONE (text card only)":typeof t=="string"?t.trim()?L(t):"NONE (text card only)":t.error||t.ok===!1||t.available===!1?`UNAVAILABLE${x(t.error)?` \u2014 ${a(t.error)}`:""} (text card stands)`:x(t.url)?L(t.url):"NONE (text card only)"}function Y(t={},{now:e=Date.now()}={}){let r=t.grant??t.session??null;if(!r||typeof r!="object")return{allowed:!1,reason:"no local grant/session",actions:[]};if(r.local===!1)return{allowed:!1,reason:"grant is not local",actions:[]};if(r.revoked===!0)return{allowed:!1,reason:"grant revoked",actions:[]};let o=r.expiresAt??r.expiry;if(x(o)){let i=typeof o=="number"?o:Date.parse(o);if(!Number.isFinite(i))return{allowed:!1,reason:"grant expiry unreadable",actions:[]};if(i<=e)return{allowed:!1,reason:"grant expired",actions:[]}}return{allowed:!0,reason:"valid local grant",actions:Array.isArray(r.actions)&&r.actions.length?r.actions.slice():["BUY","SELL"]}}function Tt(t){let e=Y(t);return e.allowed?`${e.actions.map(r=>a(r)).join(" / ")} (${a(e.reason)})`:`prepare-only \u2014 ${a(e.reason)}`}function B(t,e,r={}){let o=[`*${t}*`];for(let n of e){if(!n)continue;let[i,s]=n;o.push(`${i}: ${s==null||s===""?m:s}`)}return o.push(`Chart: ${$t(r.chart)}`),o.push(`Actions: ${Tt(r)}`),Array.isArray(r.warnings)&&r.warnings.length&&o.push(`Warnings: ${r.warnings.map(n=>a(n)).join("; ")}`),(x(r.source)||x(r.fetchedAt))&&o.push(`Source: ${a(r.source)} at ${a(r.fetchedAt)}`),o.join(`
5
5
  `)}function D(t){let e=ue(t.confidence);return e===m?null:["Confidence",e]}function _t(t){let e=t.quote;if(!e||typeof e!="object")return[];let r=x(e.decimals)?V(e.amountOutRaw??e.out??e.raw,e.decimals):m;return[["Quote out (raw)",L(e.amountOutRaw??e.out??e.raw)],["Quote out",r===m?m:`${a(r)} ${a(e.symbol??"")}`.trim()]]}function Ie(t){let e=t.autoSlippage;if(!e||typeof e!="object")return["Auto-slippage",m];let r=ee(e.selectedBps),o=ee(e.capBps);return["Auto-slippage",r===m&&o===m?m:`${r} selected, cap ${o}`]}function Nt(t={}){let e=t||{};return B(`ORACLE TOKEN \u2014 ${a(e.symbol??e.token??e.name)}`,[["Chain",q(e)],["Venue",Ae(e)],["Name",a(e.name)],["Address",L(e.address??e.mint??e.contract)],["Price",S(e.priceUsd,{decimals:8})],["Market cap",S(e.marketCapUsd)],["Liquidity",S(e.liquidityUsd)],["Volume 24h",S(e.volume24hUsd)],["Change 24h",ce(e.priceChange24h)],["Fee tier",x(e.feeTier)?`${ee(Number(e.feeTier)/100)} (${z(e.feeTier,{decimals:0})})`:m],["Age",a(e.age)],..._t(e),Ie(e),D(e)],e)}function Rt(t={}){let e=t||{};return B(`ORACLE LAUNCH \u2014 ${a(e.symbol??e.token??e.name)}`,[["Chain",q(e)],["Venue",Ae(e)],["Address",L(e.address??e.mint??e.contract)],["Pool",L(e.pool?.address??e.poolAddress??e.pool)],["Liquidity",S(e.liquidityUsd)],["Route ready",a(e.routeReady)],["Sellable",a(e.sellable)],["Sell sim",a(e.sellSimulation??e.sellSim)],["Smart wallets",a(e.smartWalletOverlap)],["Risk",a(e.risk??e.riskStatus)],["Prepared ticket",a(e.preparedTicket??e.ticketStatus)],Ie(e),D(e)],e)}function Pt(t={}){let e=t||{};return B(`ORACLE HIP-3 \u2014 ${a(e.market??e.coin??e.name)}`,[["Venue",`Hyperliquid builder-dex ${a(e.dexName?`${e.dexName} (${e.dex})`:e.dex)}`],["Market",a(e.market??e.coin)],["Mark",S(e.markPx,{decimals:6})],["Oracle",S(e.oraclePx,{decimals:6})],["Funding",ce(e.funding,{decimals:6})],["Open interest",S(e.openInterestUsd)],["Depth",a(e.depth)],["Liquidation notes",a(e.liquidationNotes??e.riskNotes)],["Account context",a(e.accountContext)],D(e)],e)}function Lt(t={}){let e=t||{};return B(`ORACLE HIP-4 \u2014 ${a(e.event??e.market??e.name)}`,[["Venue",`Hyperliquid HIP-4 ${a(e.dex??"outcome")}`],["Event",a(e.event)],["Outcome",a(e.outcome)],["Market id",L(e.marketId??e.market)],["Bid",S(e.bid,{decimals:6})],["Ask",S(e.ask,{decimals:6})],["Depth",a(e.depth)],["Edge",ce(e.edge)],["Position",a(e.position)],D(e)],e)}function Mt(t={}){let e=t||{};return B(`ORACLE POLYMARKET \u2014 ${a(e.event??e.market??e.name)}`,[["Venue","Polymarket CLOB"],["Event",a(e.event)],["Market",a(e.market)],["Market id",L(e.marketId??e.conditionId??e.tokenId)],["Yes",S(e.yesPrice,{decimals:4})],["No",S(e.noPrice,{decimals:4})],["Best bid / ask",`${S(e.bestBid,{decimals:4})} / ${S(e.bestAsk,{decimals:4})}`],["Volume",S(e.volumeUsd)],["Resolution risk",a(e.resolutionRisk)],["Order intent",a(e.orderIntent)],D(e)],e)}function Bt(t={}){let e=t||{},r=x(e.completedSplits)&&x(e.totalSplits)?`${z(e.completedSplits,{decimals:0})} / ${z(e.totalSplits,{decimals:0})}`:m;return B(`ORACLE TWAP \u2014 ${a(e.pair??e.symbol??e.name)}`,[["Chain",q(e)],["Side",a(e.side??e.direction)],["Amount",`${a(V(e.amountTotal??e.amount,e.decimals??18))} ${a(e.symbol??"")}`.trim()],["Splits",`${z(e.totalSplits,{decimals:0})} over ${a(e.window)}`],["Progress",r],["Avg price",S(e.averagePrice,{decimals:6})],["Next split",a(e.nextSplitAt)],["Slippage cap",ee(e.slippageBps)],["Status",a(e.status)],D(e)],e)}function Dt(t={}){let e=t||{},r=e.approval??e.revokeCheck??{},o=r.needsRevoke&&r.spender?`revoke.cash \u2014 ${a(r.spender)}`:r.needsRevoke===!1?"revoke.cash \u2014 clean":"revoke.cash \u2014 unchecked";return B(`ORACLE BRIDGE \u2014 ${a(e.pair??e.fromSymbol)} \u2192 ${a(e.toSymbol??"")}`.replace(/→ $/,""),[["Bridging","deBridge \xB7 LI.FI \u2014 best route wins"],["From chain",q({chainId:e.fromChainId,chain:e.fromChain})],["To chain",q({chainId:e.toChainId,chain:e.toChain})],["Amount",`${a(V(e.amount,e.fromDecimals??18))} ${a(e.fromSymbol??"")}`.trim()],["Best route",a(e.bestRoute??e.winner)],["Est. received",`${a(V(e.amountOut,e.toDecimals??18))} ${a(e.toSymbol??"")}`.trim()],["Fee",S(e.feeUsd)],["Est. time",a(e.estimatedTime)],["Revoke check",o],["All providers",a(e.providers?.join(", "))],["Preparable",a(e.preparable)],D(e)],e)}function Ut(t){let r=(Array.isArray(t)?t:[]).slice(1,4).map(o=>{let n=a(o.source??o.venue??o.name),i=o.improvementBps==null&&o.deltaBps==null?null:Number(o.improvementBps??o.deltaBps),s=Number.isFinite(i)?`${Math.abs(i).toFixed(0)} bps behind`:"spread UNKNOWN";return`${n} (${s})`});return r.length?r.join("; "):m}function Ft(t){let e=t.rankedOn??t.swap?.rankedOn??t.best?.rankedOn;return x(e)?a(e):m}function qt(t={}){let e=t||{},r=e.swap&&typeof e.swap=="object"?e.swap:e,o=e.bridge&&typeof e.bridge=="object"?e.bridge:null,n=r.best??r.winner??{},i=`${a(e.tokenInSymbol??e.fromSymbol??"IN")} \u2192 ${a(e.tokenOutSymbol??e.toSymbol??"OUT")}`,s=[["Intent",a(e.intent??"swap")],["Chain",q({chainId:e.chainId??r.chainId,chain:e.chain??r.chain})],["Pair",i],["Amount in",`${a(V(e.amountIn??r.amountIn,e.decimalsIn??18))} ${a(e.tokenInSymbol??"")}`.trim()],["Best swap",a(n.source??n.venue??r.bestRoute??e.bestRoute)],["Net out",`${a(V(n.netOut??n.amountOut??r.amountOut,e.decimalsOut??18))} ${a(e.tokenOutSymbol??"")}`.trim()],["Ranked on",Ft(r)],["Gas accounted",a(n.costAccounted===!0?"yes":n.costAccounted===!1?"no \u2014 gross ranking may flatter this route":null)],["Spread vs next",x(r.improvementBps)?`${a(r.improvementBps)} bps`:m],["Runners-up",Ut(r.routes??e.routes)]];if(o){let l=o.best??o.winner??{};s.push(["Best bridge",a(l.source??o.bestRoute??e.bestBridge)],["Bridge out",`${a(V(l.netOut??l.amountOut??o.amountOut,e.bridgeDecimalsOut??e.decimalsOut??18))} ${a(e.bridgeOutSymbol??e.tokenOutSymbol??"")}`.trim()],["Bridge to",q({chainId:o.toChainId??e.toChainId,chain:o.toChain??e.toChain})],["Est. time",a(o.estimatedTime??l.meta?.durationSeconds)])}else s.push(["Best bridge","same-chain \u2014 use Best swap"]);return s.push(["Preparable",a(e.preparable??n.executionReady)],D(e)),B(`ORACLE SWAP \u2014 ${i}`,s,e)}function jt(t={}){let e=t||{};return B("ORACLE APPROVE \u2014 local signer",[["Pending id",L(e.id??(typeof e.digest=="string"?e.digest.slice(0,8):null))],["Surface",a(e.surface)],["Action",a(e.action)],["Chain",q({chainId:e.chain??e.chainId,chain:e.chainName})],["To",L(e.to??e.destination)],["Value",x(e.value)?a(e.value):m],["Signer",a(e.armed===!0?"running + armed":e.armed===!1?"running, disarmed":"not running")],D({confidence:e.confidence??(e.armed===!0?"high":"low")})],e)}var In=Object.freeze({token:Nt,launch:Rt,hip3:Pt,hip4:Lt,polymarket:Mt,twap:Bt,bridge:Dt,swap:qt,approve:jt});import{AbiCoder as tr,Interface as rr,getAddress as Le,isAddress as nr}from"ethers";import{AbiCoder as er,Interface as fe,getAddress as Eo,isAddress as Ao,keccak256 as Io}from"ethers";import{AsyncLocalStorage as Ht}from"node:async_hooks";var vn=new Ht;var Dn=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"aborted")?.get,Un=Object.getOwnPropertyDescriptor(AbortSignal.prototype,"reason")?.get,Fn=AbortSignal.prototype.throwIfAborted,qn=EventTarget.prototype.addEventListener,jn=EventTarget.prototype.removeEventListener,Hn=typeof AbortSignal.any=="function"?AbortSignal.any.bind(AbortSignal):null;var zn=64*1024,Vn=Object.freeze({depth:32,nodes:1e4,fields:1e4,arrayLength:1e4,bytes:1024*1024});import{Interface as Vt,getAddress as Jn}from"ethers";var Zn=new Vt(["function allowance(address owner,address spender) view returns (uint256)","function balanceOf(address account) view returns (uint256)"]);var io=Object.freeze({1:"ethereum",10:"optimism",56:"bsc",137:"polygon",8453:"base",42161:"arbitrum",43114:"avalanche",999:"hyperevm",4663:"robinhood"});import{createHash as Kt,createHmac as Wt,timingSafeEqual as bo}from"node:crypto";var Gt=2,Xt=300*1e3,Yt=(()=>{let t=Number(process.env.ORACLE_PREPARE_HARD_MAX_AGE_MS);return Number.isFinite(t)&&t>0?t:1800*1e3})();function le(t){return t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(le).join(",")}]`:`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${le(t[r])}`).join(",")}}`}function Ce(t){let e=String(t?.ORACLE_STAMP_HMAC_SECRET||"").trim();return e.length>=16?e:""}function Oe(t=process.env){return Ce(process.env)||Ce(t)}function Qt(t){let{prepareHash:e,prepareMac:r,note:o,...n}=t||{};return n}function Jt(t){let e=Qt(t);return Kt("sha256").update(le(e)).digest("hex")}function Zt(t,e=Oe()){return e?Wt("sha256",e).update(String(t)).digest("hex"):""}function de(t,{provider:e,kind:r,env:o=process.env,nowMs:n=Date.now(),expiresAtMs:i}={}){if(!t||typeof t!="object")throw new Error("stampPrepared: payload object required");let s=Object.prototype.hasOwnProperty.call(t,"oraclePrepared");if(s&&typeof t.oraclePrepared!="boolean")throw new Error("stampPrepared: oraclePrepared must be boolean");let l={...t,provider:t.provider||e,kind:t.kind||r,requiresUserSignature:t.requiresUserSignature!==!1,signingReady:!1,broadcastReady:!1,executionReady:!1,oraclePrepared:s?t.oraclePrepared:!0};if(!l.provider)throw new Error("stampPrepared: provider required");if(!l.kind)throw new Error("stampPrepared: kind required");let d=Number(n),c=i==null?d+Xt:Number(i),u=c-d;if(!Number.isSafeInteger(d)||!Number.isSafeInteger(c)||u<=0||u>Yt)throw new Error("stampPrepared: bounded preparedAt/expiresAt required");let h={...l,preparedAt:d,expiresAt:c,prepareVersion:Gt},b=Jt(h),p=Oe(o),y=p?Zt(b,p):void 0,w={...h,prepareHash:b};return y&&(w.prepareMac=y),w}var To=er.defaultAbiCoder();var ve={1:{name:"ethereum",poolManager:"0x000000000004444c5dc75cB358380D2e3dE08A90",quoter:"0x52f0e24d1c21c8a0cb1e5a5dd6198556bd9e1203",stateView:"0x7ffe42c4a5deea5b0fec41c94c136cf115597227",universalRouter:"0x66a9893cc07d91d95644aedd05d03f95e1dba8af",weth:"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",usdc:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},10:{name:"optimism",poolManager:"0x9a13f98cb987694c9f086b1f5eb990eea8264ec3",quoter:"0x1f3131a13296fb91c90870043742c3cdbff1a8d7",stateView:"0xc18a3169788f4f75a170290584eca6395c75ecdb",universalRouter:"0x851116d9223fabed8e56c0e6b8ad0c31d98b3507",weth:"0x4200000000000000000000000000000000000006",usdc:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85"},56:{name:"bsc",poolManager:"0x28e2ea090877bf75740558f6bfb36a5ffee9e9df",quoter:"0x9f75dd27d6664c475b90e105573e550ff69437b0",stateView:"0xd13dd3d6e93f276fafc9db9e6bb47c1180aee0c4",universalRouter:"0x1906c1d672b88cd1b9ac7593301ca990f94eae07",weth:"0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c",usdc:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"},137:{name:"polygon",poolManager:"0x67366782805870060151383f4bbff9dab53e5cd6",quoter:"0xb3d5c3dfc3a7aebff71895a7191796bffc2c81b9",stateView:"0x5ea1bd7974c8a611cbab0bdcafcb1d9cc9b3ba5a",universalRouter:"0x1095692a6237d83c6a72f3f5efedb9a670c49223",weth:"0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",usdc:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"},8453:{name:"base",poolManager:"0x498581fF718922c3f8e6A244956aF099B2652b2b",quoter:"0x0d5e0f971ed27fbff6c2837bf31316121532048d",stateView:"0xa3c0c9b65bad0b08107aa264b0f3db444b867a71",universalRouter:"0x6ff5693b99212da76ad316178a184ab56d299b43",weth:"0x4200000000000000000000000000000000000006",usdc:"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"},42161:{name:"arbitrum",poolManager:"0x360e68faccca8ca495c1b759fd9eee466db9fb32",quoter:"0x3972c00f7ed4885e145823eb7c655375d275a1c5",stateView:"0x76fd297e2d437cd7f76d50f01afe6160f86e9990",universalRouter:"0xa51afafe0263b40edaef0df8781ea9aa03e381a3",weth:"0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",usdc:"0xaf88d065e77c8cC2239327C5EDb3A432268e5831"},43114:{name:"avalanche",poolManager:"0x06380c0e0912312b5150364b9dc4542ba0dbbc85",quoter:"0xbe40675bb704506a3c2ccfb762dcfd1e979845c2",stateView:"0xc3c9e198c735a4b97e3e683f391ccbdd60b69286",universalRouter:"0x94b75331ae8d42c1b61065089b7d48fe14aa73b7",weth:"0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7",usdc:"0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"},4663:{name:"robinhood",poolManager:"0x8366a39cc670b4001a1121b8f6a443a643e40951",quoter:"0x8dc178efb8111bb0973dd9d722ebeff267c98f94",stateView:"0xf3334192d15450cdd385c8b70e03f9a6bd9e673b",universalRouter:"0x8876789976dEcBfCbBbe364623C63652db8C0904",weth:"0x0bd7d308f8e1639fab988df18a8011f41eacad73",usdc:"0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168"}};var _o=new fe(["function quoteExactInputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountOut, uint256 gasEstimate)","function quoteExactOutputSingle(((address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks) poolKey,bool zeroForOne,uint128 exactAmount,bytes hookData) params) returns (uint256 amountIn, uint256 gasEstimate)"]),No=new fe(["function execute(bytes commands,bytes[] inputs,uint256 deadline) payable"]),Ro=new fe(["function getSlot0(bytes32 poolId) view returns (uint160 sqrtPriceX96,int24 tick,uint24 protocolFee,uint24 lpFee)","function getLiquidity(bytes32 poolId) view returns (uint128 liquidity)"]),Po=Object.freeze([[13,"beforeInitialize"],[12,"afterInitialize"],[11,"beforeAddLiquidity"],[10,"afterAddLiquidity"],[9,"beforeRemoveLiquidity"],[8,"afterRemoveLiquidity"],[7,"beforeSwap"],[6,"afterSwap"],[5,"beforeDonate"],[4,"afterDonate"],[3,"beforeSwapReturnsDelta"],[2,"afterSwapReturnsDelta"],[1,"afterAddLiquidityReturnsDelta"],[0,"afterRemoveLiquidityReturnsDelta"]]),Lo=(1n<<14n)-1n;var Me=tr.defaultAbiCoder(),j="0x0000000000000000000000000000000000000000",$e="0x000000000022D473030F116dDEE9F6B43aC78BA3",Te=-887272,_e=887272,_=(1n<<128n)-1n,or=(1n<<256n)-1n,ir=(1n<<24n)-1n,Ne=30,Re=600,T=Object.freeze({INCREASE_LIQUIDITY:0,DECREASE_LIQUIDITY:1,MINT_POSITION:2,BURN_POSITION:3,SETTLE_PAIR:13,TAKE_PAIR:17,CLOSE_CURRENCY:18,SWEEP:20}),sr=Object.freeze(Object.fromEntries(Object.entries(T).map(([t,e])=>[e,t]))),ar=Object.freeze(["mint","decrease","collect","burn","rebalance"]),Be=new rr(["function modifyLiquidities(bytes unlockData, uint256 deadline) payable"]),cr=Be.getFunction("modifyLiquidities").selector,ur="tuple(address currency0,address currency1,uint24 fee,int24 tickSpacing,address hooks)",lr=Object.freeze({MINT_POSITION:Object.freeze([ur,"int24","int24","uint256","uint128","uint128","address","bytes"]),INCREASE_LIQUIDITY:Object.freeze(["uint256","uint256","uint128","uint128","bytes"]),DECREASE_LIQUIDITY:Object.freeze(["uint256","uint256","uint128","uint128","bytes"]),BURN_POSITION:Object.freeze(["uint256","uint128","uint128","bytes"]),SETTLE_PAIR:Object.freeze(["address","address"]),TAKE_PAIR:Object.freeze(["address","address","address"]),CLOSE_CURRENCY:Object.freeze(["address"]),SWEEP:Object.freeze(["address","address"])});function g(t){throw new Error(`uniswap-v4-lp: ${t}`)}function R(t,e){(t==null||t==="")&&g(`${e} address required`);let r=String(t);return nr(r)||g(`${e} is not a valid address: ${r}`),Le(r)}function k(t,e,{max:r=or,min:o=0n}={}){(t==null||t==="")&&g(`${e} required`);let n;try{n=typeof t=="bigint"?t:BigInt(String(t))}catch{g(`${e} must be an integer, got ${String(t)}`)}return n<o&&g(`${e} must be >= ${o}`),n>r&&g(`${e} exceeds ${e==="fee"?"uint24":r===_?"uint128":"uint256"}`),n}function Pe(t,e){let r=Number(t);return Number.isInteger(r)||g(`${e} must be an integer tick`),(r<Te||r>_e)&&g(`${e} ${r} outside [${Te}, ${_e}]`),r}function te(t){return t==null||t===""||String(t).toLowerCase()!=="0x"&&g("opaque hookData is inspect-only until a hook-specific adapter exists"),"0x"}function De(t={}){(!t||typeof t!="object")&&g("poolKey required");let e=t.currency0==null||t.currency0===""?j:R(t.currency0,"poolKey.currency0"),r=R(t.currency1,"poolKey.currency1");BigInt(e)>=BigInt(r)&&g("poolKey.currency0 must sort below currency1 (V4 PoolKey invariant); reordering would target a different pool");let o=Number(k(t.fee,"fee",{max:ir})),n=Number(t.tickSpacing);(!Number.isInteger(n)||n<=0||n>32767)&&g(`poolKey.tickSpacing must be a positive int16, got ${t.tickSpacing}`);let i=t.hooks==null||t.hooks===""?j:R(t.hooks,"poolKey.hooks");return{currency0:e,currency1:r,fee:o,tickSpacing:n,hooks:i}}function Ue(t,e,r){let o=Pe(t,"tickLower"),n=Pe(e,"tickUpper");return o>=n&&g(`tickLower ${o} must be below tickUpper ${n}`),(o%r!==0||n%r!==0)&&g(`ticks must be multiples of tickSpacing ${r} (got ${o}, ${n})`),{tickLower:o,tickUpper:n}}function dr(t){let e=Number(t);return(!Number.isSafeInteger(e)||e<=0)&&g("deadline (unix seconds) required"),e}function Fe(t){return`0x${t.map(e=>e.toString(16).padStart(2,"0")).join("")}`}function N(t,e){return Me.encode(lr[t],e)}function fr(t,e){return(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length||t.length===0)&&g("actions and params must be equal-length non-empty arrays"),Me.encode(["bytes","bytes[]"],[Fe(t),e])}function re({chainId:t,positionManager:e,actions:r,params:o,deadline:n,value:i,summary:s,extra:l={}}){let d=fr(r,o),c=Be.encodeFunctionData("modifyLiquidities",[d,BigInt(n)]);return Object.freeze({chainId:Number(t),to:e,data:c,value:i.toString(),deadline:n,actions:r.map(u=>sr[u]),actionsHex:Fe(r),summary:s,...l})}function ne(t){let e=Number(t.chainId);(!Number.isInteger(e)||e<=0)&&g("chainId required");let r=R(t.positionManager,"positionManager");return{chainId:e,positionManager:r,deadline:dr(t.deadline)}}function pr(t={}){let{chainId:e,positionManager:r,deadline:o}=ne(t),n=De(t.poolKey),{tickLower:i,tickUpper:s}=Ue(t.tickLower,t.tickUpper,n.tickSpacing),l=k(t.liquidity,"liquidity");l===0n&&g("liquidity must be > 0 for mint");let d=k(t.amount0Max,"amount0Max",{max:_}),c=k(t.amount1Max,"amount1Max",{max:_}),u=R(t.owner,"owner"),f=te(t.hookData),h=n.currency0===j,b=[T.MINT_POSITION,T.SETTLE_PAIR],p=[N("MINT_POSITION",[n,i,s,l,d,c,u,f]),N("SETTLE_PAIR",[n.currency0,n.currency1])];h&&(b.push(T.SWEEP),p.push(N("SWEEP",[j,u])));let y=h?d:0n,w=`mint v4 LP ${n.currency0}/${n.currency1} fee ${n.fee} ticks [${i}, ${s}] liquidity ${l} (max ${d} / ${c}) to ${u}${h?" paying native value":""}${n.hooks!==j?` hooked ${n.hooks}`:""}`;return re({chainId:e,positionManager:r,actions:b,params:p,deadline:o,value:y,summary:w,extra:{poolKey:n,tickLower:i,tickUpper:s,owner:u,requiresApproval:He(n,{amount0Max:d,amount1Max:c})}})}function qe(t={}){let{chainId:e,positionManager:r,deadline:o}=ne(t),n=k(t.tokenId,"tokenId"),i=k(t.liquidity,"liquidity"),s=k(t.amount0Min,"amount0Min",{max:_}),l=k(t.amount1Min,"amount1Min",{max:_}),{currency0:d,currency1:c}=je(t),u=R(t.recipient??t.owner,"recipient"),f=te(t.hookData),h=[T.DECREASE_LIQUIDITY,T.TAKE_PAIR],b=[N("DECREASE_LIQUIDITY",[n,i,s,l,f]),N("TAKE_PAIR",[d,c,u])],p=i===0n?`collect fees on v4 LP #${n} to ${u}`:`decrease v4 LP #${n} by ${i} liquidity (min ${s} / ${l}) to ${u}`;return re({chainId:e,positionManager:r,actions:h,params:b,deadline:o,value:0n,summary:p,extra:{tokenId:n.toString(),recipient:u,currency0:d,currency1:c}})}function mr(t={}){return qe({...t,liquidity:0n,amount0Min:0n,amount1Min:0n})}function hr(t={}){let{chainId:e,positionManager:r,deadline:o}=ne(t),n=k(t.tokenId,"tokenId"),i=k(t.amount0Min,"amount0Min",{max:_}),s=k(t.amount1Min,"amount1Min",{max:_}),{currency0:l,currency1:d}=je(t),c=R(t.recipient??t.owner,"recipient"),u=te(t.hookData),f=[T.BURN_POSITION,T.TAKE_PAIR],h=[N("BURN_POSITION",[n,i,s,u]),N("TAKE_PAIR",[l,d,c])];return re({chainId:e,positionManager:r,actions:f,params:h,deadline:o,value:0n,summary:`burn v4 LP #${n} (min ${i} / ${s}) to ${c}`,extra:{tokenId:n.toString(),recipient:c,currency0:l,currency1:d}})}function br(t={}){let{chainId:e,positionManager:r,deadline:o}=ne(t),n=t.burn||{},i=t.mint||{},s=k(n.tokenId,"burn.tokenId"),l=k(n.amount0Min??0n,"burn.amount0Min",{max:_}),d=k(n.amount1Min??0n,"burn.amount1Min",{max:_}),c=De(i.poolKey);c.currency0===j&&g("rebalance refuses native currency pools: shortfall msg.value cannot be sized offline");let{tickLower:u,tickUpper:f}=Ue(i.tickLower,i.tickUpper,c.tickSpacing),h=k(i.liquidity,"mint.liquidity");h===0n&&g("mint.liquidity must be > 0 for rebalance");let b=k(i.amount0Max,"mint.amount0Max",{max:_}),p=k(i.amount1Max,"mint.amount1Max",{max:_}),y=R(i.owner??t.owner,"owner"),w=te(i.hookData??n.hookData),$=[T.BURN_POSITION,T.MINT_POSITION,T.CLOSE_CURRENCY,T.CLOSE_CURRENCY],M=[N("BURN_POSITION",[s,l,d,w]),N("MINT_POSITION",[c,u,f,h,b,p,y,w]),N("CLOSE_CURRENCY",[c.currency0]),N("CLOSE_CURRENCY",[c.currency1])];return re({chainId:e,positionManager:r,actions:$,params:M,deadline:o,value:0n,summary:`rebalance v4 LP: burn #${s} then mint ${c.currency0}/${c.currency1} fee ${c.fee} ticks [${u}, ${f}] liquidity ${h} (max ${b} / ${p}) to ${y}, one unlock`,extra:{burnTokenId:s.toString(),poolKey:c,tickLower:u,tickUpper:f,owner:y,requiresApproval:He(c,{amount0Max:b,amount1Max:p})}})}function je(t){let e=t.poolKey&&typeof t.poolKey=="object"?t.poolKey:t,r=e.currency0==null||e.currency0===""?j:R(e.currency0,"currency0"),o=R(e.currency1,"currency1");return BigInt(r)>=BigInt(o)&&g("currency0 must sort below currency1"),{currency0:r,currency1:o}}function He(t,{amount0Max:e,amount1Max:r}){let o=[];return t.currency0!==j&&o.push({token:t.currency0,spender:$e,amount:e.toString()}),o.push({token:t.currency1,spender:$e,amount:r.toString()}),{note:"PositionManager settles ERC-20 debt via Permit2; token\u2192Permit2 approval and a Permit2 allowance for PositionManager are both required",approvals:o}}var gr=Object.freeze({mint:pr,decrease:qe,collect:mr,burn:hr,rebalance:br});function ze(t={},e={}){let r=e.chains||ve,o=Number(t.chainId);(!Number.isInteger(o)||o<=0)&&g("chainId required");let n=r[o];n||g(`unsupported chainId ${o} (supported: ${Object.keys(r).join(", ")})`),n.positionManager||g(`no v4 PositionManager registered for chain ${o} (${n.name||"unnamed"})`);let i=String(t.kind||"").toLowerCase(),s=gr[i];s||g(`unknown kind ${t.kind} (expected ${ar.join("|")})`);let l=Number(t.deadlineSec);(!Number.isInteger(l)||l<Ne||l>Re)&&g(`deadlineSec must be an integer from ${Ne} through ${Re}`);let c=Number(e.nowSeconds??Math.floor(Date.now()/1e3))+l,u=t.params&&typeof t.params=="object"?t.params:{},f=s({...u,chainId:o,positionManager:Le(n.positionManager),deadline:c}),h=t.from??u.owner??u.recipient??null,b=h?R(h,"from"):null,p={...f},{to:y,data:w,value:$,summary:M,actions:K,actionsHex:E,requiresApproval:O=null}=f;for(let H of["to","data","value","summary","actions","actionsHex","requiresApproval","chainId","deadline"])delete p[H];return de({provider:"uniswap-v4-lp",kind:`univ4-lp-${i}`,lpKind:i,prepareReady:!0,calldataReady:!0,executionReady:!1,executionAllowed:!1,requiresUserSignature:!0,requiresWalletSignature:!0,backendSigner:!1,unsigned:!0,houseSigned:!1,signingReady:!1,broadcastReady:!1,simulate:null,chainId:o,chainName:n.name||null,deadline:c,summary:M,plan:{actions:K,actionsHex:E,selector:cr},detail:p,requiresApproval:O,transaction:{chainId:o,from:b,to:y,data:w,value:$},notes:["prepare-only: user wallet must sign","one modifyLiquidities unlock; Telegram never sends","action bytes verified against v4-periphery Actions.sol; simulate before signing"]},{provider:"uniswap-v4-lp",kind:`univ4-lp-${i}`,env:e.env,nowMs:e.nowMs})}var Ve=1e3,I="unknown",yr=/^[a-z0-9-]{4,40}$/i;function v(t){return t==null?!1:typeof t=="number"?Number.isFinite(t):typeof t=="string"?t.trim()!==""&&t.trim().toLowerCase()!==I:!0}function Q(t,{estimate:e=!0,signed:r=!1}={}){if(!v(t))return I;let o=Number(t);if(!Number.isFinite(o))return I;let n=Math.abs(o),i=n>=1e3?n.toLocaleString("en-US",{maximumFractionDigits:0}):n.toFixed(2),s=o<0?"-":r&&o>0?"+":"";return`${e?"~":""}${s}$${i}`}function pe(t){if(!v(t))return I;let e=Number(t);return Number.isFinite(e)?e===0?"0":e>=1e3?e.toLocaleString("en-US",{maximumFractionDigits:2}):e>=1?e.toFixed(4):e.toPrecision(4):I}function wr(t){if(!v(t))return I;let e=Number(t);return Number.isFinite(e)?`${(e/1e4).toFixed(e%100===0?2:3)}%`:a(t)}function xr(t){let e={1:"Ethereum",10:"Optimism",56:"BSC",137:"Polygon",8453:"Base",42161:"Arbitrum",43114:"Avalanche",4663:"Robinhood"},r=Number(t);return Number.isInteger(r)?e[r]?`${e[r]} (${r})`:`chain ${r}`:I}function Sr(t){if(!t||typeof t!="object")return`Decision: ${I}`;let e=v(t.action)?String(t.action).toUpperCase():I,r=v(t.mode)?String(t.mode):"alert_only",o=v(t.reason)?a(t.reason):I;return`Decision: ${a(e)} (${a(r)}) \u2014 ${o}`}function Ke(t={}){let r=[`*LP ${v(t.pair)?a(t.pair):I} \xB7 ${a(xr(t.chainId))}*`,`Net: ${Q(t.netUsd,{signed:!0})}`,`Fees ${Q(t.feesUsd)} \xB7 IL ${Q(t.ilUsd)} \xB7 Gas ${Q(t.gasUsd)} \xB7 Slip ${Q(t.slippageUsd)}`,`Range: ${pe(t.rangeLower)} \u2013 ${pe(t.rangeUpper)} \xB7 now ${pe(t.priceNow)} \xB7 ${typeof t.inRange=="boolean"?t.inRange?"IN range":"OUT of range":`range ${I}`}`,`Fee tier: ${wr(t.feeTier)}`,Sr(t.decision)];(v(t.source)||v(t.observedAt))&&r.push(`Source: ${v(t.source)?a(t.source):I} at ${v(t.observedAt)?a(t.observedAt):I}`),r.push("Buttons open the graph or queue an unsigned prepare. Telegram never sends.");let o=r.join(`
@@ -31,7 +31,7 @@ PREPARE
31
31
  oracle prepare build an unsigned swap (alias of route prepare)
32
32
  oracle x402 prepare|submit an x402 agent payment (never signs)
33
33
  oracle session-vault unsigned optional vault prepare (no broadcast)
34
- oracle strategy draft|validate|backtest|optimize|evidence \xB7 shadow \xB7 prepare
34
+ oracle strategy draft|validate|backtest|optimize|evidence \xB7 shadow \xB7 prepare \xB7 collect \xB7 infer
35
35
  oracle shadow record|mark|summary prepare and NO_TRADE outcomes
36
36
  oracle mint check|prepare|watch; --queue needs local owner approval
37
37
  oracle mev observe \xB7 status \xB7 control \xB7 operator (execute needs --execute)