@continuumdao/ctm-mpc-defi 0.2.20 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/catalog.cjs +118 -37
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +310 -97
- package/dist/agent/catalog.js +117 -38
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/uniswap-v4/SKILL.md +58 -0
- package/dist/chains/evm/index.cjs +5 -1
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +4 -4
- package/dist/chains/evm/index.js +5 -1
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/chains/near/index.d.ts +1 -1
- package/dist/chains/solana/index.d.ts +1 -1
- package/dist/core/index.cjs +25 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +12 -5
- package/dist/core/index.js +23 -1
- package/dist/core/index.js.map +1 -1
- package/dist/{envelope-CpBUh9eP.d.ts → envelope-C_bfuKab.d.ts} +3 -1
- package/dist/index.cjs +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +25 -2
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +5 -1
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +1 -1
- package/dist/protocols/evm/aave-v4/index.js +5 -1
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.cjs +5 -1
- package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.d.ts +2 -2
- package/dist/protocols/evm/circle-cctp/index.js +5 -1
- package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +5 -1
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +2 -2
- package/dist/protocols/evm/curve-dao/index.js +5 -1
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +5 -1
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +1 -1
- package/dist/protocols/evm/ethena/index.js +5 -1
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +5 -1
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +1 -1
- package/dist/protocols/evm/euler-v2/index.js +5 -1
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/gmx/index.cjs +5 -1
- package/dist/protocols/evm/gmx/index.cjs.map +1 -1
- package/dist/protocols/evm/gmx/index.d.ts +2 -2
- package/dist/protocols/evm/gmx/index.js +5 -1
- package/dist/protocols/evm/gmx/index.js.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.cjs +6 -1
- package/dist/protocols/evm/hyperliquid/index.cjs.map +1 -1
- package/dist/protocols/evm/hyperliquid/index.d.ts +2 -2
- package/dist/protocols/evm/hyperliquid/index.js +6 -1
- package/dist/protocols/evm/hyperliquid/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +5 -1
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +1 -1
- package/dist/protocols/evm/lido/index.js +5 -1
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +5 -1
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +1 -1
- package/dist/protocols/evm/maple/index.js +5 -1
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +5 -1
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +1 -1
- package/dist/protocols/evm/morpho/index.js +5 -1
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/permit2/index.cjs +4 -0
- package/dist/protocols/evm/permit2/index.cjs.map +1 -1
- package/dist/protocols/evm/permit2/index.d.ts +1 -1
- package/dist/protocols/evm/permit2/index.js +4 -0
- package/dist/protocols/evm/permit2/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs +5 -1
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +1 -1
- package/dist/protocols/evm/sky/index.js +5 -1
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +684 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.d.ts +180 -3
- package/dist/protocols/evm/uniswap-v4/index.js +662 -2
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/dist/{registry-Bv5o37_w.d.ts → registry-DxDSPQ-p.d.ts} +1 -1
- package/dist/{types-BfjWdw1j.d.ts → types-PZrvtjv8.d.ts} +2 -0
- package/dist/{types-DUeNJLr9.d.ts → types-RZWOTm8c.d.ts} +1 -1
- package/package.json +2 -2
|
@@ -598,6 +598,9 @@ function finalizeMultisign(input) {
|
|
|
598
598
|
bodyForSign.value = valueWei.toString();
|
|
599
599
|
}
|
|
600
600
|
if (clientId) bodyForSign.clientId = clientId;
|
|
601
|
+
if (input.expiryDate != null && input.expiryDate > 0) {
|
|
602
|
+
bodyForSign.expiryDate = Math.floor(input.expiryDate);
|
|
603
|
+
}
|
|
601
604
|
return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) };
|
|
602
605
|
}
|
|
603
606
|
function routerSwapGasLimitFromEstimate(estimatedGas, chainGasLimit) {
|
|
@@ -761,7 +764,8 @@ async function buildEvmMultisignBatch(args) {
|
|
|
761
764
|
destinationChainID: String(chainId),
|
|
762
765
|
destinationAddress: args.destinationAddress ?? steps[0].to,
|
|
763
766
|
legs,
|
|
764
|
-
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0
|
|
767
|
+
extraJSON: Object.keys(extraJSON).length > 0 ? extraJSON : void 0,
|
|
768
|
+
expiryDate: context.expiryDate
|
|
765
769
|
});
|
|
766
770
|
const pv = args.payableValueWei;
|
|
767
771
|
if (pv != null && pv > 0n) {
|
|
@@ -2578,6 +2582,662 @@ async function swapExactInput(args) {
|
|
|
2578
2582
|
return swapFromQuote({ ...args, swap });
|
|
2579
2583
|
}
|
|
2580
2584
|
|
|
2585
|
+
// src/core/defiProxy.ts
|
|
2586
|
+
async function postJsonViaOptionalProxy(args) {
|
|
2587
|
+
const proxy = args.proxyUrl?.trim();
|
|
2588
|
+
if (proxy) {
|
|
2589
|
+
const r2 = await fetch(proxy, {
|
|
2590
|
+
method: "POST",
|
|
2591
|
+
headers: { "content-type": "application/json" },
|
|
2592
|
+
body: JSON.stringify(args.proxyEnvelope ?? args.body)
|
|
2593
|
+
});
|
|
2594
|
+
if (!r2.ok) {
|
|
2595
|
+
const t = await r2.text().catch(() => "");
|
|
2596
|
+
throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
|
|
2597
|
+
}
|
|
2598
|
+
return await r2.json();
|
|
2599
|
+
}
|
|
2600
|
+
const r = await fetch(args.directUrl, {
|
|
2601
|
+
method: "POST",
|
|
2602
|
+
headers: { "content-type": "application/json" },
|
|
2603
|
+
body: JSON.stringify(args.body)
|
|
2604
|
+
});
|
|
2605
|
+
if (!r.ok) {
|
|
2606
|
+
const t = await r.text().catch(() => "");
|
|
2607
|
+
throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
|
|
2608
|
+
}
|
|
2609
|
+
return await r.json();
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
// src/protocols/evm/uniswap-v4/theGraphApiKey.ts
|
|
2613
|
+
var THE_GRAPH_API_KEY_ENV = "THE_GRAPH_API_KEY";
|
|
2614
|
+
var THE_GRAPH_API_KEY_SIGNUP_URL = "https://thegraph.com/studio/apikeys/";
|
|
2615
|
+
var THE_GRAPH_API_KEY_DOCS_URL = "https://thegraph.com/docs/en/subgraphs/querying/managing-api-keys/";
|
|
2616
|
+
function isTheGraphRateLimitOrAuthError(message) {
|
|
2617
|
+
const m = message.toLowerCase();
|
|
2618
|
+
return m.includes("429") || m.includes("rate limit") || m.includes("too many requests") || m.includes("auth error") || m.includes("missing authorization") || m.includes("unauthorized");
|
|
2619
|
+
}
|
|
2620
|
+
function theGraphApiKeyVariablesHint() {
|
|
2621
|
+
return [
|
|
2622
|
+
`Set \`${THE_GRAPH_API_KEY_ENV}\` in Node \u2192 AI Agent \u2192 Variables (+ Add: paste the key as the value).`,
|
|
2623
|
+
`Get a free API key at ${THE_GRAPH_API_KEY_SIGNUP_URL}`
|
|
2624
|
+
].join(" ");
|
|
2625
|
+
}
|
|
2626
|
+
function theGraphRateLimitErrorMessage(baseError) {
|
|
2627
|
+
return `${baseError}
|
|
2628
|
+
|
|
2629
|
+
The Graph rate limit or auth issue \u2014 ${theGraphApiKeyVariablesHint()}`;
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2632
|
+
// src/protocols/evm/uniswap-v4/subgraph.ts
|
|
2633
|
+
var UNISWAP_V4_SUBGRAPH_ID_BY_CHAIN_ID = {
|
|
2634
|
+
1: "DiYPVdygkfjDWhbxGSqAQxwBKmfKnkWQojqeM2rkLb3G",
|
|
2635
|
+
// Ethereum
|
|
2636
|
+
10: "3Tn7Y1NJAr4ySKm7KFu1dwvH2WM3mHJnXzXAxQsdBDvW",
|
|
2637
|
+
// Optimism
|
|
2638
|
+
56: "2qQpC8inZPZL4tYfRQPFGZhsE8mYzE67n5z3Yf5uuKMu",
|
|
2639
|
+
// BSC
|
|
2640
|
+
130: "EoCvJ5tyMLMJcTnLQwWpjAtPdn74PcrZgzfcT5bYxNBH",
|
|
2641
|
+
// Unichain
|
|
2642
|
+
137: "CwpebM66AH5uqS5sreKij8yEkkPcHvmyEs7EwFtdM5ND",
|
|
2643
|
+
// Polygon
|
|
2644
|
+
8453: "HNCFA9TyBqpo5qpe6QreQABAA1kV8g46mhkCcicu6v2R",
|
|
2645
|
+
// Base
|
|
2646
|
+
81457: "FCHYK3Ab6bBnkfeCKRhFbs1Q8rX4yt6rKJibpDTC74ns",
|
|
2647
|
+
// Blast
|
|
2648
|
+
42161: "G5TsTKNi8yhPSV7kycaE23oWbqv9zzNqR49FoEQjzq1r",
|
|
2649
|
+
// Arbitrum
|
|
2650
|
+
43114: "49JxRo9FGxWpSf5Y5GKQPj5NUpX2HhpoZHpGzNEWQZjq"
|
|
2651
|
+
// Avalanche
|
|
2652
|
+
};
|
|
2653
|
+
var SUBGRAPH_PAGE_SIZE = 1e3;
|
|
2654
|
+
function uniswapV4SubgraphIdForChain(chainId) {
|
|
2655
|
+
return UNISWAP_V4_SUBGRAPH_ID_BY_CHAIN_ID[chainId];
|
|
2656
|
+
}
|
|
2657
|
+
function uniswapV4SubgraphSupportedChainIds() {
|
|
2658
|
+
return Object.keys(UNISWAP_V4_SUBGRAPH_ID_BY_CHAIN_ID).map(Number).sort((a, b) => a - b);
|
|
2659
|
+
}
|
|
2660
|
+
function uniswapV4SubgraphUrlForChain(chainId, apiKey) {
|
|
2661
|
+
const id = uniswapV4SubgraphIdForChain(chainId);
|
|
2662
|
+
if (!id) {
|
|
2663
|
+
throw new Error(
|
|
2664
|
+
`Uniswap V4 subgraph is not configured for chainId ${chainId}. Supported: ${uniswapV4SubgraphSupportedChainIds().join(", ")}`
|
|
2665
|
+
);
|
|
2666
|
+
}
|
|
2667
|
+
const key = apiKey?.trim();
|
|
2668
|
+
if (key) {
|
|
2669
|
+
return `https://gateway.thegraph.com/api/${key}/subgraphs/id/${id}`;
|
|
2670
|
+
}
|
|
2671
|
+
return `https://gateway.thegraph.com/api/subgraphs/id/${id}`;
|
|
2672
|
+
}
|
|
2673
|
+
function resolveTheGraphApiKey(override) {
|
|
2674
|
+
const fromOverride = override?.trim();
|
|
2675
|
+
if (fromOverride) return fromOverride;
|
|
2676
|
+
const raw = process.env[THE_GRAPH_API_KEY_ENV]?.trim();
|
|
2677
|
+
return raw || void 0;
|
|
2678
|
+
}
|
|
2679
|
+
async function postUniswapV4SubgraphGql(chainId, query, variables, theGraphApiKey) {
|
|
2680
|
+
const url = uniswapV4SubgraphUrlForChain(chainId, resolveTheGraphApiKey(theGraphApiKey));
|
|
2681
|
+
const body = { query, variables: variables ?? {} };
|
|
2682
|
+
let j;
|
|
2683
|
+
try {
|
|
2684
|
+
j = await postJsonViaOptionalProxy({ directUrl: url, body });
|
|
2685
|
+
} catch (e) {
|
|
2686
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
2687
|
+
if (isTheGraphRateLimitOrAuthError(msg)) {
|
|
2688
|
+
throw new Error(theGraphRateLimitErrorMessage(msg));
|
|
2689
|
+
}
|
|
2690
|
+
throw e;
|
|
2691
|
+
}
|
|
2692
|
+
if (j.errors?.length) {
|
|
2693
|
+
const msg = j.errors.map((e) => e.message ?? "GraphQL error").join("; ");
|
|
2694
|
+
if (isTheGraphRateLimitOrAuthError(msg)) {
|
|
2695
|
+
throw new Error(theGraphRateLimitErrorMessage(msg));
|
|
2696
|
+
}
|
|
2697
|
+
throw new Error(msg);
|
|
2698
|
+
}
|
|
2699
|
+
if (j.data == null) {
|
|
2700
|
+
throw new Error("Uniswap V4 subgraph: empty response");
|
|
2701
|
+
}
|
|
2702
|
+
return j.data;
|
|
2703
|
+
}
|
|
2704
|
+
var POOL_HOUR_PAGE_GQL = `
|
|
2705
|
+
query UniswapV4PoolHourDatas($pool: String!, $from: Int!, $to: Int!, $first: Int!, $skip: Int!) {
|
|
2706
|
+
poolHourDatas(
|
|
2707
|
+
where: { pool: $pool, periodStartUnix_gte: $from, periodStartUnix_lt: $to }
|
|
2708
|
+
orderBy: periodStartUnix
|
|
2709
|
+
orderDirection: asc
|
|
2710
|
+
first: $first
|
|
2711
|
+
skip: $skip
|
|
2712
|
+
) {
|
|
2713
|
+
periodStartUnix
|
|
2714
|
+
open
|
|
2715
|
+
high
|
|
2716
|
+
low
|
|
2717
|
+
close
|
|
2718
|
+
volumeUSD
|
|
2719
|
+
}
|
|
2720
|
+
}`;
|
|
2721
|
+
var POOL_DAY_PAGE_GQL = `
|
|
2722
|
+
query UniswapV4PoolDayDatas($pool: String!, $from: Int!, $to: Int!, $first: Int!, $skip: Int!) {
|
|
2723
|
+
poolDayDatas(
|
|
2724
|
+
where: { pool: $pool, date_gte: $from, date_lt: $to }
|
|
2725
|
+
orderBy: date
|
|
2726
|
+
orderDirection: asc
|
|
2727
|
+
first: $first
|
|
2728
|
+
skip: $skip
|
|
2729
|
+
) {
|
|
2730
|
+
date
|
|
2731
|
+
open
|
|
2732
|
+
high
|
|
2733
|
+
low
|
|
2734
|
+
close
|
|
2735
|
+
volumeUSD
|
|
2736
|
+
}
|
|
2737
|
+
}`;
|
|
2738
|
+
var SWAPS_PAGE_GQL = `
|
|
2739
|
+
query UniswapV4Swaps($pool: String!, $from: BigInt!, $to: BigInt!, $first: Int!, $skip: Int!) {
|
|
2740
|
+
swaps(
|
|
2741
|
+
where: { pool: $pool, timestamp_gte: $from, timestamp_lt: $to }
|
|
2742
|
+
orderBy: timestamp
|
|
2743
|
+
orderDirection: asc
|
|
2744
|
+
first: $first
|
|
2745
|
+
skip: $skip
|
|
2746
|
+
) {
|
|
2747
|
+
timestamp
|
|
2748
|
+
amountUSD
|
|
2749
|
+
token0Price
|
|
2750
|
+
sqrtPriceX96
|
|
2751
|
+
}
|
|
2752
|
+
}`;
|
|
2753
|
+
var POOL_META_GQL = `
|
|
2754
|
+
query UniswapV4PoolMeta($id: ID!) {
|
|
2755
|
+
pool(id: $id) {
|
|
2756
|
+
id
|
|
2757
|
+
token0 { symbol }
|
|
2758
|
+
token1 { symbol }
|
|
2759
|
+
}
|
|
2760
|
+
}`;
|
|
2761
|
+
async function paginateSubgraphRows(fetchPage, maxPages) {
|
|
2762
|
+
const rows = [];
|
|
2763
|
+
for (let page = 0; page < maxPages; page++) {
|
|
2764
|
+
const batch = await fetchPage(page * SUBGRAPH_PAGE_SIZE);
|
|
2765
|
+
rows.push(...batch);
|
|
2766
|
+
if (batch.length < SUBGRAPH_PAGE_SIZE) {
|
|
2767
|
+
return { rows, truncated: false };
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
return { rows, truncated: true };
|
|
2771
|
+
}
|
|
2772
|
+
function normalizePoolId(poolReference) {
|
|
2773
|
+
return poolReference.trim().toLowerCase();
|
|
2774
|
+
}
|
|
2775
|
+
async function fetchUniswapV4PoolHourDatas(args) {
|
|
2776
|
+
const pool = normalizePoolId(args.poolReference);
|
|
2777
|
+
const maxPages = args.maxPages ?? 20;
|
|
2778
|
+
return paginateSubgraphRows(async (skip) => {
|
|
2779
|
+
const data = await postUniswapV4SubgraphGql(args.chainId, POOL_HOUR_PAGE_GQL, {
|
|
2780
|
+
pool,
|
|
2781
|
+
from: args.fromSec,
|
|
2782
|
+
to: args.toSec,
|
|
2783
|
+
first: SUBGRAPH_PAGE_SIZE,
|
|
2784
|
+
skip
|
|
2785
|
+
});
|
|
2786
|
+
return data.poolHourDatas ?? [];
|
|
2787
|
+
}, maxPages);
|
|
2788
|
+
}
|
|
2789
|
+
async function fetchUniswapV4PoolDayDatas(args) {
|
|
2790
|
+
const pool = normalizePoolId(args.poolReference);
|
|
2791
|
+
const maxPages = args.maxPages ?? 20;
|
|
2792
|
+
return paginateSubgraphRows(async (skip) => {
|
|
2793
|
+
const data = await postUniswapV4SubgraphGql(args.chainId, POOL_DAY_PAGE_GQL, {
|
|
2794
|
+
pool,
|
|
2795
|
+
from: args.fromSec,
|
|
2796
|
+
to: args.toSec,
|
|
2797
|
+
first: SUBGRAPH_PAGE_SIZE,
|
|
2798
|
+
skip
|
|
2799
|
+
});
|
|
2800
|
+
return data.poolDayDatas ?? [];
|
|
2801
|
+
}, maxPages);
|
|
2802
|
+
}
|
|
2803
|
+
async function fetchUniswapV4Swaps(args) {
|
|
2804
|
+
const pool = normalizePoolId(args.poolReference);
|
|
2805
|
+
const maxPages = args.maxPages ?? 50;
|
|
2806
|
+
return paginateSubgraphRows(async (skip) => {
|
|
2807
|
+
const data = await postUniswapV4SubgraphGql(
|
|
2808
|
+
args.chainId,
|
|
2809
|
+
SWAPS_PAGE_GQL,
|
|
2810
|
+
{
|
|
2811
|
+
pool,
|
|
2812
|
+
from: String(args.fromSec),
|
|
2813
|
+
to: String(args.toSec),
|
|
2814
|
+
first: SUBGRAPH_PAGE_SIZE,
|
|
2815
|
+
skip
|
|
2816
|
+
}
|
|
2817
|
+
);
|
|
2818
|
+
return data.swaps ?? [];
|
|
2819
|
+
}, maxPages);
|
|
2820
|
+
}
|
|
2821
|
+
async function fetchUniswapV4PoolMeta(args) {
|
|
2822
|
+
const id = normalizePoolId(args.poolReference);
|
|
2823
|
+
const data = await postUniswapV4SubgraphGql(
|
|
2824
|
+
args.chainId,
|
|
2825
|
+
POOL_META_GQL,
|
|
2826
|
+
{ id }
|
|
2827
|
+
);
|
|
2828
|
+
return data.pool ?? null;
|
|
2829
|
+
}
|
|
2830
|
+
|
|
2831
|
+
// src/protocols/evm/uniswap-v4/ohlcvInterval.ts
|
|
2832
|
+
var UNISWAP_V4_OHLCV_INTERVALS = [
|
|
2833
|
+
"1m",
|
|
2834
|
+
"5m",
|
|
2835
|
+
"15m",
|
|
2836
|
+
"30m",
|
|
2837
|
+
"1h",
|
|
2838
|
+
"2h",
|
|
2839
|
+
"4h",
|
|
2840
|
+
"6h",
|
|
2841
|
+
"8h",
|
|
2842
|
+
"12h",
|
|
2843
|
+
"1d",
|
|
2844
|
+
"2d",
|
|
2845
|
+
"3d",
|
|
2846
|
+
"1w",
|
|
2847
|
+
"1M"
|
|
2848
|
+
];
|
|
2849
|
+
var INTERVAL_SECONDS = {
|
|
2850
|
+
"1m": 60,
|
|
2851
|
+
"5m": 300,
|
|
2852
|
+
"15m": 900,
|
|
2853
|
+
"30m": 1800,
|
|
2854
|
+
"1h": 3600,
|
|
2855
|
+
"2h": 7200,
|
|
2856
|
+
"4h": 14400,
|
|
2857
|
+
"6h": 21600,
|
|
2858
|
+
"8h": 28800,
|
|
2859
|
+
"12h": 43200,
|
|
2860
|
+
"1d": 86400,
|
|
2861
|
+
"2d": 172800,
|
|
2862
|
+
"3d": 259200,
|
|
2863
|
+
"1w": 604800,
|
|
2864
|
+
"1M": 2592e3
|
|
2865
|
+
};
|
|
2866
|
+
function assertUniswapV4OhlcvInterval(interval) {
|
|
2867
|
+
const normalized = interval.trim();
|
|
2868
|
+
if (!UNISWAP_V4_OHLCV_INTERVALS.includes(normalized)) {
|
|
2869
|
+
throw new Error(
|
|
2870
|
+
`Invalid interval "${interval}". Valid: ${UNISWAP_V4_OHLCV_INTERVALS.join(", ")}`
|
|
2871
|
+
);
|
|
2872
|
+
}
|
|
2873
|
+
return normalized;
|
|
2874
|
+
}
|
|
2875
|
+
function uniswapV4OhlcvIntervalToBucketSec(interval) {
|
|
2876
|
+
return INTERVAL_SECONDS[interval];
|
|
2877
|
+
}
|
|
2878
|
+
function resolveUniswapV4OhlcvDataTier(intervalRaw) {
|
|
2879
|
+
const interval = assertUniswapV4OhlcvInterval(intervalRaw);
|
|
2880
|
+
const bucketSec = uniswapV4OhlcvIntervalToBucketSec(interval);
|
|
2881
|
+
if (bucketSec === 3600) {
|
|
2882
|
+
return { kind: "subgraph_native", entity: "hourly", bucketSec, interval };
|
|
2883
|
+
}
|
|
2884
|
+
if (bucketSec === 86400) {
|
|
2885
|
+
return { kind: "subgraph_native", entity: "daily", bucketSec, interval };
|
|
2886
|
+
}
|
|
2887
|
+
if (bucketSec < 3600) {
|
|
2888
|
+
return { kind: "swaps", bucketSec, interval };
|
|
2889
|
+
}
|
|
2890
|
+
if (bucketSec < 86400 && bucketSec % 3600 === 0) {
|
|
2891
|
+
return { kind: "subgraph_aggregate", baseEntity: "hourly", bucketSec, interval };
|
|
2892
|
+
}
|
|
2893
|
+
if (bucketSec > 86400 && bucketSec % 86400 === 0) {
|
|
2894
|
+
return { kind: "subgraph_aggregate", baseEntity: "daily", bucketSec, interval };
|
|
2895
|
+
}
|
|
2896
|
+
throw new Error(
|
|
2897
|
+
`Interval "${interval}" is not supported for Uniswap V4 OHLCV routing. Valid: ${UNISWAP_V4_OHLCV_INTERVALS.join(", ")}`
|
|
2898
|
+
);
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
// src/protocols/evm/uniswap-v4/swapCandles.ts
|
|
2902
|
+
function parseDecimal(raw) {
|
|
2903
|
+
if (raw == null) return null;
|
|
2904
|
+
const n = Number(raw);
|
|
2905
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
2906
|
+
}
|
|
2907
|
+
function priceFromSwapRow(row) {
|
|
2908
|
+
const fromToken0 = parseDecimal(row.token0Price);
|
|
2909
|
+
if (fromToken0 != null) return fromToken0;
|
|
2910
|
+
const sqrt = row.sqrtPriceX96?.trim();
|
|
2911
|
+
if (!sqrt) return null;
|
|
2912
|
+
try {
|
|
2913
|
+
const sqrtPrice = BigInt(sqrt);
|
|
2914
|
+
if (sqrtPrice <= 0n) return null;
|
|
2915
|
+
const ratio = Number(sqrtPrice) / 2 ** 96;
|
|
2916
|
+
const price = ratio * ratio;
|
|
2917
|
+
return Number.isFinite(price) && price > 0 ? price : null;
|
|
2918
|
+
} catch {
|
|
2919
|
+
return null;
|
|
2920
|
+
}
|
|
2921
|
+
}
|
|
2922
|
+
function bucketStartSec(timestampSec, bucketSec) {
|
|
2923
|
+
return Math.floor(timestampSec / bucketSec) * bucketSec;
|
|
2924
|
+
}
|
|
2925
|
+
function bucketUniswapV4SwapsIntoCandles(args) {
|
|
2926
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
2927
|
+
for (const swap of args.swaps) {
|
|
2928
|
+
const ts = Number(swap.timestamp);
|
|
2929
|
+
const price = priceFromSwapRow(swap);
|
|
2930
|
+
if (!Number.isFinite(ts) || price == null) continue;
|
|
2931
|
+
const bucket = bucketStartSec(Math.floor(ts), args.bucketSec);
|
|
2932
|
+
const vol = parseDecimal(swap.amountUSD) ?? 0;
|
|
2933
|
+
const existing = buckets.get(bucket);
|
|
2934
|
+
if (!existing) {
|
|
2935
|
+
buckets.set(bucket, { open: price, high: price, low: price, close: price, volume: vol });
|
|
2936
|
+
continue;
|
|
2937
|
+
}
|
|
2938
|
+
existing.close = price;
|
|
2939
|
+
if (price > existing.high) existing.high = price;
|
|
2940
|
+
if (price < existing.low) existing.low = price;
|
|
2941
|
+
existing.volume += vol;
|
|
2942
|
+
}
|
|
2943
|
+
return [...buckets.entries()].sort(([a], [b]) => a - b).map(([bucketSec, bar]) => ({
|
|
2944
|
+
timestampMs: bucketSec * 1e3,
|
|
2945
|
+
open: String(bar.open),
|
|
2946
|
+
high: String(bar.high),
|
|
2947
|
+
low: String(bar.low),
|
|
2948
|
+
close: String(bar.close),
|
|
2949
|
+
volume: bar.volume > 0 ? String(bar.volume) : void 0
|
|
2950
|
+
}));
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
// src/protocols/evm/uniswap-v4/ohlcv.ts
|
|
2954
|
+
var MAX_CANDLES = 2e3;
|
|
2955
|
+
function invertCandleRow(row) {
|
|
2956
|
+
const inv = (raw) => {
|
|
2957
|
+
const n = Number(raw);
|
|
2958
|
+
if (!Number.isFinite(n) || n <= 0) return raw;
|
|
2959
|
+
return String(1 / n);
|
|
2960
|
+
};
|
|
2961
|
+
const open = inv(row.open);
|
|
2962
|
+
const close = inv(row.close);
|
|
2963
|
+
const highRaw = Number(row.high);
|
|
2964
|
+
const lowRaw = Number(row.low);
|
|
2965
|
+
const high = Number.isFinite(highRaw) && Number.isFinite(lowRaw) && highRaw > 0 && lowRaw > 0 ? String(1 / Math.min(highRaw, lowRaw)) : inv(row.high);
|
|
2966
|
+
const low = Number.isFinite(highRaw) && Number.isFinite(lowRaw) && highRaw > 0 && lowRaw > 0 ? String(1 / Math.max(highRaw, lowRaw)) : inv(row.low);
|
|
2967
|
+
return {
|
|
2968
|
+
timestampMs: row.timestampMs,
|
|
2969
|
+
open,
|
|
2970
|
+
high,
|
|
2971
|
+
low,
|
|
2972
|
+
close,
|
|
2973
|
+
...row.volume != null ? { volume: row.volume } : {}
|
|
2974
|
+
};
|
|
2975
|
+
}
|
|
2976
|
+
function mapSubgraphHourRow(row) {
|
|
2977
|
+
return {
|
|
2978
|
+
timestampMs: row.periodStartUnix * 1e3,
|
|
2979
|
+
open: row.open,
|
|
2980
|
+
high: row.high,
|
|
2981
|
+
low: row.low,
|
|
2982
|
+
close: row.close,
|
|
2983
|
+
volume: row.volumeUSD
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2986
|
+
function mapSubgraphDayRow(row) {
|
|
2987
|
+
return {
|
|
2988
|
+
timestampMs: row.date * 1e3,
|
|
2989
|
+
open: row.open,
|
|
2990
|
+
high: row.high,
|
|
2991
|
+
low: row.low,
|
|
2992
|
+
close: row.close,
|
|
2993
|
+
volume: row.volumeUSD
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
function aggregateOhlcvCandles(bars, bucketSec) {
|
|
2997
|
+
if (bars.length === 0) return [];
|
|
2998
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
2999
|
+
for (const bar of bars) {
|
|
3000
|
+
const bucketStart = Math.floor(bar.timestampMs / 1e3 / bucketSec) * bucketSec;
|
|
3001
|
+
const list = buckets.get(bucketStart) ?? [];
|
|
3002
|
+
list.push(bar);
|
|
3003
|
+
buckets.set(bucketStart, list);
|
|
3004
|
+
}
|
|
3005
|
+
return [...buckets.entries()].sort(([a], [b]) => a - b).map(([bucketStartSec2, group]) => {
|
|
3006
|
+
const sorted = [...group].sort((a, b) => a.timestampMs - b.timestampMs);
|
|
3007
|
+
const first = sorted[0];
|
|
3008
|
+
const last = sorted[sorted.length - 1];
|
|
3009
|
+
let high = Number(first.high);
|
|
3010
|
+
let low = Number(first.low);
|
|
3011
|
+
let volume = 0;
|
|
3012
|
+
for (const row of sorted) {
|
|
3013
|
+
const h = Number(row.high);
|
|
3014
|
+
const l = Number(row.low);
|
|
3015
|
+
if (Number.isFinite(h) && h > high) high = h;
|
|
3016
|
+
if (Number.isFinite(l) && l < low) low = l;
|
|
3017
|
+
const v = row.volume != null ? Number(row.volume) : 0;
|
|
3018
|
+
if (Number.isFinite(v)) volume += v;
|
|
3019
|
+
}
|
|
3020
|
+
return {
|
|
3021
|
+
timestampMs: bucketStartSec2 * 1e3,
|
|
3022
|
+
open: first.open,
|
|
3023
|
+
high: String(high),
|
|
3024
|
+
low: String(low),
|
|
3025
|
+
close: last.close,
|
|
3026
|
+
volume: volume > 0 ? String(volume) : void 0
|
|
3027
|
+
};
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
function windowFromArgs(args) {
|
|
3031
|
+
const nowMs = Date.now();
|
|
3032
|
+
if (args.startTimeMs != null || args.endTimeMs != null) {
|
|
3033
|
+
const endTimeMs = args.endTimeMs ?? nowMs;
|
|
3034
|
+
const startTimeMs = args.startTimeMs ?? endTimeMs - 7 * 864e5;
|
|
3035
|
+
if (startTimeMs >= endTimeMs) {
|
|
3036
|
+
throw new Error("startTimeMs must be before endTimeMs.");
|
|
3037
|
+
}
|
|
3038
|
+
return { startTimeMs, endTimeMs };
|
|
3039
|
+
}
|
|
3040
|
+
if (args.lookbackHours != null) {
|
|
3041
|
+
const hours = Math.max(1, Math.floor(args.lookbackHours));
|
|
3042
|
+
return { startTimeMs: nowMs - hours * 36e5, endTimeMs: nowMs };
|
|
3043
|
+
}
|
|
3044
|
+
const days = args.lookbackDays ?? 7;
|
|
3045
|
+
const lookbackDays = Math.max(1, Math.floor(days));
|
|
3046
|
+
return { startTimeMs: nowMs - lookbackDays * 864e5, endTimeMs: nowMs };
|
|
3047
|
+
}
|
|
3048
|
+
function candleWindowFromRows(candles) {
|
|
3049
|
+
if (candles.length === 0) return {};
|
|
3050
|
+
let startTimeMs = candles[0].timestampMs;
|
|
3051
|
+
let endTimeMs = candles[0].timestampMs;
|
|
3052
|
+
for (const c of candles) {
|
|
3053
|
+
if (c.timestampMs < startTimeMs) startTimeMs = c.timestampMs;
|
|
3054
|
+
if (c.timestampMs > endTimeMs) endTimeMs = c.timestampMs;
|
|
3055
|
+
}
|
|
3056
|
+
return { startTimeMs, endTimeMs };
|
|
3057
|
+
}
|
|
3058
|
+
async function resolveUniswapV4OhlcvPool(args) {
|
|
3059
|
+
const chainId = parseUniswapChainId(args.chainId);
|
|
3060
|
+
if (args.poolPreset?.trim()) {
|
|
3061
|
+
const preset = resolveUniswapV4LpPoolPreset({ chainId, presetId: args.poolPreset });
|
|
3062
|
+
return {
|
|
3063
|
+
poolReference: preset.poolReference,
|
|
3064
|
+
pairLabel: preset.pairLabel,
|
|
3065
|
+
token0Symbol: preset.token0Symbol,
|
|
3066
|
+
token1Symbol: preset.token1Symbol
|
|
3067
|
+
};
|
|
3068
|
+
}
|
|
3069
|
+
if (args.poolReference?.trim()) {
|
|
3070
|
+
const poolReference = args.poolReference.trim();
|
|
3071
|
+
let pairLabel = poolReference.slice(0, 10) + "\u2026";
|
|
3072
|
+
let token0Symbol;
|
|
3073
|
+
let token1Symbol;
|
|
3074
|
+
try {
|
|
3075
|
+
const meta = await fetchUniswapV4PoolMeta({ chainId, poolReference });
|
|
3076
|
+
if (meta?.token0?.symbol && meta?.token1?.symbol) {
|
|
3077
|
+
token0Symbol = meta.token0.symbol;
|
|
3078
|
+
token1Symbol = meta.token1.symbol;
|
|
3079
|
+
pairLabel = `${meta.token0.symbol}/${meta.token1.symbol}`;
|
|
3080
|
+
}
|
|
3081
|
+
} catch {
|
|
3082
|
+
}
|
|
3083
|
+
return { poolReference, pairLabel, token0Symbol, token1Symbol };
|
|
3084
|
+
}
|
|
3085
|
+
const existing = args.existingPool;
|
|
3086
|
+
if (existing?.token0Address && existing?.token1Address) {
|
|
3087
|
+
const resolved = resolveUniswapV4LpExistingPoolFromKey({
|
|
3088
|
+
token0Address: existing.token0Address,
|
|
3089
|
+
token1Address: existing.token1Address,
|
|
3090
|
+
fee: existing.fee ?? 0,
|
|
3091
|
+
tickSpacing: existing.tickSpacing ?? 60,
|
|
3092
|
+
hooks: existing.hooks,
|
|
3093
|
+
poolReference: existing.poolReference
|
|
3094
|
+
});
|
|
3095
|
+
const t0 = existing.token0Address;
|
|
3096
|
+
const t1 = existing.token1Address;
|
|
3097
|
+
return {
|
|
3098
|
+
poolReference: resolved.poolReference,
|
|
3099
|
+
pairLabel: `${t0.slice(0, 6)}\u2026/${t1.slice(0, 6)}\u2026`
|
|
3100
|
+
};
|
|
3101
|
+
}
|
|
3102
|
+
throw new Error(
|
|
3103
|
+
"Pool is required: pass poolPreset (from ctm_uniswap_v4_list_lp_pools), poolReference, or existingPool."
|
|
3104
|
+
);
|
|
3105
|
+
}
|
|
3106
|
+
async function fetchFromSubgraphTier(args) {
|
|
3107
|
+
const warnings = [];
|
|
3108
|
+
if (args.tier.kind === "subgraph_native") {
|
|
3109
|
+
if (args.tier.entity === "hourly") {
|
|
3110
|
+
const { rows: rows2, truncated: truncated2 } = await fetchUniswapV4PoolHourDatas({
|
|
3111
|
+
chainId: args.chainId,
|
|
3112
|
+
poolReference: args.poolReference,
|
|
3113
|
+
fromSec: args.fromSec,
|
|
3114
|
+
toSec: args.toSec
|
|
3115
|
+
});
|
|
3116
|
+
if (truncated2) warnings.push("Hourly subgraph page limit reached; history may be truncated.");
|
|
3117
|
+
return { candles: rows2.map(mapSubgraphHourRow), warnings };
|
|
3118
|
+
}
|
|
3119
|
+
const { rows, truncated } = await fetchUniswapV4PoolDayDatas({
|
|
3120
|
+
chainId: args.chainId,
|
|
3121
|
+
poolReference: args.poolReference,
|
|
3122
|
+
fromSec: args.fromSec,
|
|
3123
|
+
toSec: args.toSec
|
|
3124
|
+
});
|
|
3125
|
+
if (truncated) warnings.push("Daily subgraph page limit reached; history may be truncated.");
|
|
3126
|
+
return { candles: rows.map(mapSubgraphDayRow), warnings };
|
|
3127
|
+
}
|
|
3128
|
+
if (args.tier.kind === "subgraph_aggregate") {
|
|
3129
|
+
if (args.tier.baseEntity === "hourly") {
|
|
3130
|
+
const { rows: rows2, truncated: truncated2 } = await fetchUniswapV4PoolHourDatas({
|
|
3131
|
+
chainId: args.chainId,
|
|
3132
|
+
poolReference: args.poolReference,
|
|
3133
|
+
fromSec: args.fromSec,
|
|
3134
|
+
toSec: args.toSec
|
|
3135
|
+
});
|
|
3136
|
+
if (truncated2) warnings.push("Hourly subgraph page limit reached before aggregation.");
|
|
3137
|
+
const base2 = rows2.map(mapSubgraphHourRow);
|
|
3138
|
+
return { candles: aggregateOhlcvCandles(base2, args.tier.bucketSec), warnings };
|
|
3139
|
+
}
|
|
3140
|
+
const { rows, truncated } = await fetchUniswapV4PoolDayDatas({
|
|
3141
|
+
chainId: args.chainId,
|
|
3142
|
+
poolReference: args.poolReference,
|
|
3143
|
+
fromSec: args.fromSec,
|
|
3144
|
+
toSec: args.toSec
|
|
3145
|
+
});
|
|
3146
|
+
if (truncated) warnings.push("Daily subgraph page limit reached before aggregation.");
|
|
3147
|
+
const base = rows.map(mapSubgraphDayRow);
|
|
3148
|
+
return { candles: aggregateOhlcvCandles(base, args.tier.bucketSec), warnings };
|
|
3149
|
+
}
|
|
3150
|
+
return { candles: [], warnings };
|
|
3151
|
+
}
|
|
3152
|
+
async function fetchFromSwapsTier(args) {
|
|
3153
|
+
const warnings = [];
|
|
3154
|
+
const { rows, truncated } = await fetchUniswapV4Swaps({
|
|
3155
|
+
chainId: args.chainId,
|
|
3156
|
+
poolReference: args.poolReference,
|
|
3157
|
+
fromSec: args.fromSec,
|
|
3158
|
+
toSec: args.toSec
|
|
3159
|
+
});
|
|
3160
|
+
if (truncated) {
|
|
3161
|
+
warnings.push(
|
|
3162
|
+
"Swap pagination limit reached; sub-hour candles may be incomplete. Try a shorter lookback or a coarser interval (1h+)."
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
if (rows.length === 0) {
|
|
3166
|
+
warnings.push("No swaps found in the requested window for this pool.");
|
|
3167
|
+
}
|
|
3168
|
+
return {
|
|
3169
|
+
candles: bucketUniswapV4SwapsIntoCandles({ swaps: rows, bucketSec: args.bucketSec }),
|
|
3170
|
+
warnings
|
|
3171
|
+
};
|
|
3172
|
+
}
|
|
3173
|
+
async function uniswapV4FetchOhlcv(args) {
|
|
3174
|
+
const chainId = parseUniswapChainId(args.chainId);
|
|
3175
|
+
const interval = assertUniswapV4OhlcvInterval(args.interval ?? "1h");
|
|
3176
|
+
const tier = resolveUniswapV4OhlcvDataTier(interval);
|
|
3177
|
+
const pool = await resolveUniswapV4OhlcvPool(args);
|
|
3178
|
+
const { startTimeMs, endTimeMs } = windowFromArgs(args);
|
|
3179
|
+
const fromSec = Math.floor(startTimeMs / 1e3);
|
|
3180
|
+
const toSec = Math.ceil(endTimeMs / 1e3);
|
|
3181
|
+
const expectedBars = Math.ceil((toSec - fromSec) / tier.bucketSec);
|
|
3182
|
+
if (expectedBars > MAX_CANDLES) {
|
|
3183
|
+
throw new Error(
|
|
3184
|
+
`Requested window would produce ~${expectedBars} bars (max ${MAX_CANDLES}). Use a coarser interval or shorter lookback.`
|
|
3185
|
+
);
|
|
3186
|
+
}
|
|
3187
|
+
let candles;
|
|
3188
|
+
let warnings = [];
|
|
3189
|
+
let dataSource;
|
|
3190
|
+
let baseSubgraphEntity;
|
|
3191
|
+
if (tier.kind === "swaps") {
|
|
3192
|
+
const result = await fetchFromSwapsTier({
|
|
3193
|
+
chainId,
|
|
3194
|
+
poolReference: pool.poolReference,
|
|
3195
|
+
bucketSec: tier.bucketSec,
|
|
3196
|
+
fromSec,
|
|
3197
|
+
toSec
|
|
3198
|
+
});
|
|
3199
|
+
candles = result.candles;
|
|
3200
|
+
warnings = result.warnings;
|
|
3201
|
+
dataSource = "swaps";
|
|
3202
|
+
} else {
|
|
3203
|
+
const result = await fetchFromSubgraphTier({
|
|
3204
|
+
chainId,
|
|
3205
|
+
poolReference: pool.poolReference,
|
|
3206
|
+
tier,
|
|
3207
|
+
fromSec,
|
|
3208
|
+
toSec
|
|
3209
|
+
});
|
|
3210
|
+
candles = result.candles;
|
|
3211
|
+
warnings = result.warnings;
|
|
3212
|
+
dataSource = tier.kind;
|
|
3213
|
+
if (tier.kind === "subgraph_aggregate") {
|
|
3214
|
+
baseSubgraphEntity = tier.baseEntity;
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
const quoteToken = args.quoteToken ?? "token0";
|
|
3218
|
+
if (quoteToken === "token1") {
|
|
3219
|
+
candles = candles.map(invertCandleRow);
|
|
3220
|
+
}
|
|
3221
|
+
if (candles.length === 0 && warnings.length === 0) {
|
|
3222
|
+
warnings.push("No candles returned for this pool and window.");
|
|
3223
|
+
}
|
|
3224
|
+
const window = candleWindowFromRows(candles);
|
|
3225
|
+
return {
|
|
3226
|
+
symbol: pool.pairLabel,
|
|
3227
|
+
timeframe: interval,
|
|
3228
|
+
chainId,
|
|
3229
|
+
poolReference: pool.poolReference,
|
|
3230
|
+
dataSource,
|
|
3231
|
+
...baseSubgraphEntity ? { baseSubgraphEntity } : {},
|
|
3232
|
+
priceQuote: quoteToken === "token1" ? "token1PerToken0" : "token0PerToken1",
|
|
3233
|
+
...window,
|
|
3234
|
+
candleCount: candles.length,
|
|
3235
|
+
candles,
|
|
3236
|
+
fetchedAtMs: Date.now(),
|
|
3237
|
+
...warnings.length > 0 ? { warnings } : {}
|
|
3238
|
+
};
|
|
3239
|
+
}
|
|
3240
|
+
|
|
2581
3241
|
// src/protocols/evm/uniswap-v4/index.ts
|
|
2582
3242
|
var UNISWAP_V4_PROTOCOL_ID = "uniswap-v4";
|
|
2583
3243
|
var uniswapV4ProtocolModule = {
|
|
@@ -2695,6 +3355,9 @@ var uniswapV4 = {
|
|
|
2695
3355
|
exports.MAX_UINT160 = MAX_UINT160;
|
|
2696
3356
|
exports.MAX_UINT48 = MAX_UINT48;
|
|
2697
3357
|
exports.PERMIT2_ADDRESS = PERMIT2_ADDRESS;
|
|
3358
|
+
exports.THE_GRAPH_API_KEY_DOCS_URL = THE_GRAPH_API_KEY_DOCS_URL;
|
|
3359
|
+
exports.THE_GRAPH_API_KEY_ENV = THE_GRAPH_API_KEY_ENV;
|
|
3360
|
+
exports.THE_GRAPH_API_KEY_SIGNUP_URL = THE_GRAPH_API_KEY_SIGNUP_URL;
|
|
2698
3361
|
exports.UNISWAP_LP_API_BASE_DEFAULT = UNISWAP_LP_API_BASE_DEFAULT;
|
|
2699
3362
|
exports.UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET = UNISWAP_LP_DEFAULT_DEADLINE_SEC_OFFSET;
|
|
2700
3363
|
exports.UNISWAP_LP_DEFAULT_EXPIRY_MINUTES = UNISWAP_LP_DEFAULT_EXPIRY_MINUTES;
|
|
@@ -2714,8 +3377,13 @@ exports.UNISWAP_V4_LP_MINT_DEFAULT_GAS_UNITS = UNISWAP_V4_LP_MINT_DEFAULT_GAS_UN
|
|
|
2714
3377
|
exports.UNISWAP_V4_LP_POOL_LOOKUP_HINT = UNISWAP_V4_LP_POOL_LOOKUP_HINT;
|
|
2715
3378
|
exports.UNISWAP_V4_LP_POSITION_REGISTRY_HINT = UNISWAP_V4_LP_POSITION_REGISTRY_HINT;
|
|
2716
3379
|
exports.UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK = UNISWAP_V4_LP_WETH_DEPOSIT_FALLBACK;
|
|
3380
|
+
exports.UNISWAP_V4_OHLCV_INTERVALS = UNISWAP_V4_OHLCV_INTERVALS;
|
|
2717
3381
|
exports.UNISWAP_V4_PROTOCOL_ID = UNISWAP_V4_PROTOCOL_ID;
|
|
3382
|
+
exports.UNISWAP_V4_SUBGRAPH_ID_BY_CHAIN_ID = UNISWAP_V4_SUBGRAPH_ID_BY_CHAIN_ID;
|
|
3383
|
+
exports.aggregateOhlcvCandles = aggregateOhlcvCandles;
|
|
2718
3384
|
exports.applySlippagePercentToApproveWei = applySlippagePercentToApproveWei;
|
|
3385
|
+
exports.assertUniswapV4OhlcvInterval = assertUniswapV4OhlcvInterval;
|
|
3386
|
+
exports.bucketUniswapV4SwapsIntoCandles = bucketUniswapV4SwapsIntoCandles;
|
|
2719
3387
|
exports.buildEvmMultisignBodyUniswapV4CollectFeesBatch = buildEvmMultisignBodyUniswapV4CollectFeesBatch;
|
|
2720
3388
|
exports.buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch = buildEvmMultisignBodyUniswapV4DecreaseLiquidityBatch;
|
|
2721
3389
|
exports.buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch = buildEvmMultisignBodyUniswapV4IncreaseLiquidityBatch;
|
|
@@ -2730,6 +3398,10 @@ exports.errorMessageFromUniswapJsonBody = errorMessageFromUniswapJsonBody;
|
|
|
2730
3398
|
exports.extractUniswapLpTokenAmounts = extractUniswapLpTokenAmounts;
|
|
2731
3399
|
exports.extractUniswapLpTransaction = extractUniswapLpTransaction;
|
|
2732
3400
|
exports.fetchEthereumAddressForKeyGen = fetchEthereumAddressForKeyGen;
|
|
3401
|
+
exports.fetchUniswapV4PoolDayDatas = fetchUniswapV4PoolDayDatas;
|
|
3402
|
+
exports.fetchUniswapV4PoolHourDatas = fetchUniswapV4PoolHourDatas;
|
|
3403
|
+
exports.fetchUniswapV4PoolMeta = fetchUniswapV4PoolMeta;
|
|
3404
|
+
exports.fetchUniswapV4Swaps = fetchUniswapV4Swaps;
|
|
2733
3405
|
exports.formatUniswapAmountFieldFromWei = formatUniswapAmountFieldFromWei;
|
|
2734
3406
|
exports.formatUniswapLpAmountHuman = formatUniswapLpAmountHuman;
|
|
2735
3407
|
exports.formatUniswapPercentForUi = formatUniswapPercentForUi;
|
|
@@ -2741,6 +3413,7 @@ exports.getUniswapV4PositionManagerDeployBlock = getUniswapV4PositionManagerDepl
|
|
|
2741
3413
|
exports.getUniswapV4PositionManagerOrThrow = getUniswapV4PositionManagerOrThrow;
|
|
2742
3414
|
exports.isEthGetLogsBlockRangeTooLargeError = isEthGetLogsBlockRangeTooLargeError;
|
|
2743
3415
|
exports.isNativeUniswapLpTokenAddress = isNativeUniswapLpTokenAddress;
|
|
3416
|
+
exports.isTheGraphRateLimitOrAuthError = isTheGraphRateLimitOrAuthError;
|
|
2744
3417
|
exports.isUniswapFullQuoteResponseNativeIn = isUniswapFullQuoteResponseNativeIn;
|
|
2745
3418
|
exports.isUniswapTokenInAddressNative = isUniswapTokenInAddressNative;
|
|
2746
3419
|
exports.isUniswapV4ChainSupported = isUniswapV4ChainSupported;
|
|
@@ -2758,13 +3431,18 @@ exports.quoteSwap = quoteSwap;
|
|
|
2758
3431
|
exports.readUniswapV4PositionInfoRaw = readUniswapV4PositionInfoRaw;
|
|
2759
3432
|
exports.resolveBlockAtOrAfterUnixTime = resolveBlockAtOrAfterUnixTime;
|
|
2760
3433
|
exports.resolveRouterSwapGasUnitsFromSignRequest = resolveRouterSwapGasUnitsFromSignRequest;
|
|
3434
|
+
exports.resolveTheGraphApiKey = resolveTheGraphApiKey;
|
|
2761
3435
|
exports.resolveUniswapV4LpExistingPoolFromKey = resolveUniswapV4LpExistingPoolFromKey;
|
|
2762
3436
|
exports.resolveUniswapV4LpPoolPreset = resolveUniswapV4LpPoolPreset;
|
|
3437
|
+
exports.resolveUniswapV4OhlcvDataTier = resolveUniswapV4OhlcvDataTier;
|
|
3438
|
+
exports.resolveUniswapV4OhlcvPool = resolveUniswapV4OhlcvPool;
|
|
2763
3439
|
exports.resolveUniswapV4PositionScanFromDate = resolveUniswapV4PositionScanFromDate;
|
|
2764
3440
|
exports.sortUniswapV4PoolCurrencies = sortUniswapV4PoolCurrencies;
|
|
2765
3441
|
exports.swapExactInput = swapExactInput;
|
|
2766
3442
|
exports.swapFromQuote = swapFromQuote;
|
|
2767
3443
|
exports.swapTransactionDeadlineUnixFromExpiryMinutes = swapTransactionDeadlineUnixFromExpiryMinutes;
|
|
3444
|
+
exports.theGraphApiKeyVariablesHint = theGraphApiKeyVariablesHint;
|
|
3445
|
+
exports.theGraphRateLimitErrorMessage = theGraphRateLimitErrorMessage;
|
|
2768
3446
|
exports.tryGetUniswapV4PositionManager = tryGetUniswapV4PositionManager;
|
|
2769
3447
|
exports.uniswapCreateSwap = uniswapCreateSwap;
|
|
2770
3448
|
exports.uniswapLpClaimFees = uniswapLpClaimFees;
|
|
@@ -2775,13 +3453,18 @@ exports.uniswapLpTxFieldForAction = uniswapLpTxFieldForAction;
|
|
|
2775
3453
|
exports.uniswapQuoteToJsonQuoteOneLine = uniswapQuoteToJsonQuoteOneLine;
|
|
2776
3454
|
exports.uniswapTradeQuote = uniswapTradeQuote;
|
|
2777
3455
|
exports.uniswapV4 = uniswapV4;
|
|
3456
|
+
exports.uniswapV4FetchOhlcv = uniswapV4FetchOhlcv;
|
|
2778
3457
|
exports.uniswapV4ListPositionsForMcp = uniswapV4ListPositionsForMcp;
|
|
2779
3458
|
exports.uniswapV4ListPositionsFromRegistryForMcp = uniswapV4ListPositionsFromRegistryForMcp;
|
|
2780
3459
|
exports.uniswapV4ListPositionsRegistryMcpPlaceholder = uniswapV4ListPositionsRegistryMcpPlaceholder;
|
|
2781
3460
|
exports.uniswapV4ListStandardLpPools = uniswapV4ListStandardLpPools;
|
|
3461
|
+
exports.uniswapV4OhlcvIntervalToBucketSec = uniswapV4OhlcvIntervalToBucketSec;
|
|
2782
3462
|
exports.uniswapV4PositionMintedTokenIdsFromReceipt = uniswapV4PositionMintedTokenIdsFromReceipt;
|
|
2783
3463
|
exports.uniswapV4ProtocolModule = uniswapV4ProtocolModule;
|
|
2784
3464
|
exports.uniswapV4RegisterPositionFromMintTxPlaceholder = uniswapV4RegisterPositionFromMintTxPlaceholder;
|
|
2785
3465
|
exports.uniswapV4RegisterPositionNftPlaceholder = uniswapV4RegisterPositionNftPlaceholder;
|
|
3466
|
+
exports.uniswapV4SubgraphIdForChain = uniswapV4SubgraphIdForChain;
|
|
3467
|
+
exports.uniswapV4SubgraphSupportedChainIds = uniswapV4SubgraphSupportedChainIds;
|
|
3468
|
+
exports.uniswapV4SubgraphUrlForChain = uniswapV4SubgraphUrlForChain;
|
|
2786
3469
|
//# sourceMappingURL=index.cjs.map
|
|
2787
3470
|
//# sourceMappingURL=index.cjs.map
|