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