@continuumdao/ctm-mpc-defi 0.2.1 → 0.2.3
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 +96 -25
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +27 -1
- package/dist/agent/catalog.js +95 -26
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/curve-dao/SKILL.md +2 -1
- package/dist/chains/evm/index.cjs +54 -0
- package/dist/chains/evm/index.cjs.map +1 -1
- package/dist/chains/evm/index.d.ts +13 -1
- package/dist/chains/evm/index.js +52 -2
- package/dist/chains/evm/index.js.map +1 -1
- package/dist/core/index.cjs +64 -0
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.ts +20 -1
- package/dist/core/index.js +56 -1
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +165 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +154 -16
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +766 -6
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +417 -1
- package/dist/protocols/evm/aave-v4/index.js +741 -8
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +268 -21
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +74 -9
- package/dist/protocols/evm/curve-dao/index.js +262 -23
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/ethena/index.cjs +104 -0
- package/dist/protocols/evm/ethena/index.cjs.map +1 -1
- package/dist/protocols/evm/ethena/index.d.ts +46 -1
- package/dist/protocols/evm/ethena/index.js +99 -1
- package/dist/protocols/evm/ethena/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +2334 -37
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.d.ts +464 -1
- package/dist/protocols/evm/euler-v2/index.js +2286 -39
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/lido/index.cjs +110 -0
- package/dist/protocols/evm/lido/index.cjs.map +1 -1
- package/dist/protocols/evm/lido/index.d.ts +33 -2
- package/dist/protocols/evm/lido/index.js +107 -2
- package/dist/protocols/evm/lido/index.js.map +1 -1
- package/dist/protocols/evm/maple/index.cjs +83 -0
- package/dist/protocols/evm/maple/index.cjs.map +1 -1
- package/dist/protocols/evm/maple/index.d.ts +22 -1
- package/dist/protocols/evm/maple/index.js +82 -1
- package/dist/protocols/evm/maple/index.js.map +1 -1
- package/dist/protocols/evm/sky/index.cjs +217 -0
- package/dist/protocols/evm/sky/index.cjs.map +1 -1
- package/dist/protocols/evm/sky/index.d.ts +56 -1
- package/dist/protocols/evm/sky/index.js +210 -2
- package/dist/protocols/evm/sky/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { C as ChainCategory, a as ChainSupportContext, E as EvmTokenKind, K as KeyGenSubset, b as KeyGenSubsetForPermit, M as MultisignBuildResult, c as MultisignCommonArgs, N as NearTokenKind, P as ParamDoc, d as ProtocolActionDescriptor, e as ProtocolModule, S as SolanaTokenKind, T as TokenRef } from './types-BfjWdw1j.js';
|
|
2
2
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
-
export { mergePurposeText } from './core/index.js';
|
|
3
|
+
export { getAaveGraphqlProxyUrl, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, mergePurposeText, postJsonViaOptionalProxy, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl } from './core/index.js';
|
|
4
4
|
export { C as ChainCategoryBuildInput, a as ChainCategoryModule, M as MultisignLeg, c as coreChainCategoryModule, f as finalizeMultisign } from './envelope-CpBUh9eP.js';
|
|
5
5
|
export { g as getActionsByChainCategory, a as getProtocolModule, b as getProtocolModules, r as registerProtocolModule } from './registry-Bv5o37_w.js';
|
|
6
6
|
export { E as EvmChainDetail, a as EvmProtocolContext, b as EvmTxStep, i as isEvmNativeToken, m as matchEvmTokenKind } from './types-DUeNJLr9.js';
|
|
7
|
-
export { EvmBatchMetaBuilder, EvmBuildBatchArgs, buildEvmMultisignBatch, evmChainCategoryModule, parseEvmChainIdToNumber, routerSwapGasLimitFromEstimate } from './chains/evm/index.js';
|
|
7
|
+
export { COINGECKO_PLATFORM_BY_CHAIN_ID, EvmBatchMetaBuilder, EvmBuildBatchArgs, buildEvmMultisignBatch, coingeckoPlatformForChainId, evmChainCategoryModule, normalizeCurveRouterAmountString, normalizeHumanDecimalAmount, parseEvmChainIdToNumber, routerSwapGasLimitFromEstimate } from './chains/evm/index.js';
|
|
8
8
|
export { SOLANA_CHAIN_CATEGORY, solanaChainCategoryModule } from './chains/solana/index.js';
|
|
9
9
|
export { NEAR_CHAIN_CATEGORY, nearChainCategoryModule } from './chains/near/index.js';
|
|
10
10
|
export { uniswapV4, uniswapV4ProtocolModule } from './protocols/evm/uniswap-v4/index.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getClientIdFromKeyGenResult, gasLimitFromEstimateAndChainConfig, fetchChainFeeParams, gweiToDecimalString, proposalTxParamsToFeeSnapshot, alignEip1559FeesWithLatestBase, nodeFetchWithReadAuth } from '@continuumdao/continuum-node-sdk';
|
|
2
2
|
export { getClientIdFromKeyGenResult as firstClientIdFromKeyGen } from '@continuumdao/continuum-node-sdk';
|
|
3
|
-
import { getAddress, zeroAddress, defineChain, createPublicClient, http, parseGwei, serializeTransaction, keccak256, encodeFunctionData, erc20Abi, parseAbi,
|
|
3
|
+
import { getAddress, zeroAddress, defineChain, createPublicClient, http, parseGwei, serializeTransaction, keccak256, parseUnits, formatUnits, encodeFunctionData, erc20Abi, parseAbi, decodeFunctionData, isAddress } from 'viem';
|
|
4
4
|
|
|
5
5
|
// src/core/index.ts
|
|
6
6
|
|
|
@@ -86,6 +86,61 @@ function getProtocolModule(id) {
|
|
|
86
86
|
function getActionsByChainCategory(category) {
|
|
87
87
|
return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
|
|
88
88
|
}
|
|
89
|
+
|
|
90
|
+
// src/core/defiProxy.ts
|
|
91
|
+
var aaveGraphqlProxyUrl;
|
|
92
|
+
var eulerGraphqlProxyUrl;
|
|
93
|
+
var mapleGraphqlProxyUrl;
|
|
94
|
+
var coingeckoProxyUrl;
|
|
95
|
+
function setAaveGraphqlProxyUrl(url) {
|
|
96
|
+
aaveGraphqlProxyUrl = url?.trim() || void 0;
|
|
97
|
+
}
|
|
98
|
+
function getAaveGraphqlProxyUrl() {
|
|
99
|
+
return aaveGraphqlProxyUrl;
|
|
100
|
+
}
|
|
101
|
+
function setEulerGraphqlProxyUrl(url) {
|
|
102
|
+
eulerGraphqlProxyUrl = url?.trim() || void 0;
|
|
103
|
+
}
|
|
104
|
+
function getEulerGraphqlProxyUrl() {
|
|
105
|
+
return eulerGraphqlProxyUrl;
|
|
106
|
+
}
|
|
107
|
+
function setMapleGraphqlProxyUrl(url) {
|
|
108
|
+
mapleGraphqlProxyUrl = url?.trim() || void 0;
|
|
109
|
+
}
|
|
110
|
+
function getMapleGraphqlProxyUrl() {
|
|
111
|
+
return mapleGraphqlProxyUrl;
|
|
112
|
+
}
|
|
113
|
+
function setCoingeckoProxyUrl(url) {
|
|
114
|
+
coingeckoProxyUrl = url?.trim() || void 0;
|
|
115
|
+
}
|
|
116
|
+
function getCoingeckoProxyUrl() {
|
|
117
|
+
return coingeckoProxyUrl;
|
|
118
|
+
}
|
|
119
|
+
async function postJsonViaOptionalProxy(args) {
|
|
120
|
+
const proxy = args.proxyUrl?.trim();
|
|
121
|
+
if (proxy) {
|
|
122
|
+
const r2 = await fetch(proxy, {
|
|
123
|
+
method: "POST",
|
|
124
|
+
headers: { "content-type": "application/json" },
|
|
125
|
+
body: JSON.stringify(args.proxyEnvelope ?? args.body)
|
|
126
|
+
});
|
|
127
|
+
if (!r2.ok) {
|
|
128
|
+
const t = await r2.text().catch(() => "");
|
|
129
|
+
throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
|
|
130
|
+
}
|
|
131
|
+
return await r2.json();
|
|
132
|
+
}
|
|
133
|
+
const r = await fetch(args.directUrl, {
|
|
134
|
+
method: "POST",
|
|
135
|
+
headers: { "content-type": "application/json" },
|
|
136
|
+
body: JSON.stringify(args.body)
|
|
137
|
+
});
|
|
138
|
+
if (!r.ok) {
|
|
139
|
+
const t = await r.text().catch(() => "");
|
|
140
|
+
throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
|
|
141
|
+
}
|
|
142
|
+
return await r.json();
|
|
143
|
+
}
|
|
89
144
|
function isEvmNativeToken(address) {
|
|
90
145
|
try {
|
|
91
146
|
return getAddress(address) === zeroAddress;
|
|
@@ -298,6 +353,56 @@ function parseEvmChainIdToNumber(chainId) {
|
|
|
298
353
|
}
|
|
299
354
|
return Number.parseInt(t, 10);
|
|
300
355
|
}
|
|
356
|
+
function normalizeHumanDecimalAmount(raw, tokenDecimals) {
|
|
357
|
+
const t = raw.trim().replace(/,/g, "");
|
|
358
|
+
if (!t) return "";
|
|
359
|
+
if (!Number.isInteger(tokenDecimals) || tokenDecimals < 0 || tokenDecimals > 18) {
|
|
360
|
+
throw new Error("Invalid token decimals for amount normalization.");
|
|
361
|
+
}
|
|
362
|
+
const wei = parseUnits(t, tokenDecimals);
|
|
363
|
+
return formatUnits(wei, tokenDecimals);
|
|
364
|
+
}
|
|
365
|
+
var normalizeCurveRouterAmountString = normalizeHumanDecimalAmount;
|
|
366
|
+
|
|
367
|
+
// src/chains/evm/coingecko.ts
|
|
368
|
+
var COINGECKO_PLATFORM_BY_CHAIN_ID = {
|
|
369
|
+
"1": "ethereum",
|
|
370
|
+
"56": "binance-smart-chain",
|
|
371
|
+
"137": "polygon-pos",
|
|
372
|
+
"42161": "arbitrum-one",
|
|
373
|
+
"10": "optimistic-ethereum",
|
|
374
|
+
"43114": "avalanche",
|
|
375
|
+
"8453": "base",
|
|
376
|
+
"324": "zk-sync-era",
|
|
377
|
+
"42220": "celo",
|
|
378
|
+
"250": "fantom",
|
|
379
|
+
"100": "gnosis",
|
|
380
|
+
"204": "op-bnb",
|
|
381
|
+
"534352": "scroll",
|
|
382
|
+
"5000": "mantle",
|
|
383
|
+
"169": "manta-pacific",
|
|
384
|
+
"1116": "core",
|
|
385
|
+
"30": "rootstock",
|
|
386
|
+
"288": "boba",
|
|
387
|
+
"1088": "metis-andromeda",
|
|
388
|
+
"34443": "mode",
|
|
389
|
+
"80084": "berachain",
|
|
390
|
+
"146": "sonic",
|
|
391
|
+
"60808": "bob-network",
|
|
392
|
+
"80094": "berachain",
|
|
393
|
+
"130": "unichain",
|
|
394
|
+
"57073": "ink",
|
|
395
|
+
"999": "hyperevm",
|
|
396
|
+
"239": "tac",
|
|
397
|
+
"9745": "plasma",
|
|
398
|
+
"1923": "swellchain",
|
|
399
|
+
"59144": "linea",
|
|
400
|
+
"81457": "blast",
|
|
401
|
+
"7777777": "zora"
|
|
402
|
+
};
|
|
403
|
+
function coingeckoPlatformForChainId(chainId) {
|
|
404
|
+
return COINGECKO_PLATFORM_BY_CHAIN_ID[String(chainId).trim()];
|
|
405
|
+
}
|
|
301
406
|
|
|
302
407
|
// src/chains/solana/types.ts
|
|
303
408
|
var solanaChainCategoryModule = {
|
|
@@ -1371,44 +1476,64 @@ function swappableCurveGraphNodeKeys(adj) {
|
|
|
1371
1476
|
}
|
|
1372
1477
|
|
|
1373
1478
|
// src/protocols/evm/curve-dao/apiSession.ts
|
|
1479
|
+
var CURVE_SESSION_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
1480
|
+
var curveSessionCache = /* @__PURE__ */ new Map();
|
|
1374
1481
|
async function fetchAllCurvePools(curve) {
|
|
1375
1482
|
const run = (p) => p.catch(() => void 0);
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1483
|
+
const tasks = [];
|
|
1484
|
+
for (const key of [
|
|
1485
|
+
"factory",
|
|
1486
|
+
"crvUSDFactory",
|
|
1487
|
+
"EYWAFactory",
|
|
1488
|
+
"cryptoFactory",
|
|
1489
|
+
"twocryptoFactory",
|
|
1490
|
+
"tricryptoFactory",
|
|
1491
|
+
"stableNgFactory"
|
|
1492
|
+
]) {
|
|
1493
|
+
const f = curve[key];
|
|
1494
|
+
if (f?.fetchPools) {
|
|
1495
|
+
tasks.push(run(f.fetchPools()));
|
|
1496
|
+
}
|
|
1497
|
+
}
|
|
1498
|
+
await Promise.all(tasks);
|
|
1385
1499
|
}
|
|
1386
1500
|
async function loadFullCurveSessionForRpc(rpcUrl) {
|
|
1387
1501
|
const url = (rpcUrl ?? "").trim();
|
|
1388
|
-
if (!url)
|
|
1502
|
+
if (!url) {
|
|
1503
|
+
throw new Error("rpcUrl is required.");
|
|
1504
|
+
}
|
|
1505
|
+
const cached = curveSessionCache.get(url);
|
|
1506
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
1507
|
+
return cached.session;
|
|
1508
|
+
}
|
|
1389
1509
|
try {
|
|
1390
1510
|
const { default: curve } = await import('@curvefi/api');
|
|
1391
1511
|
await curve.init("JsonRpc", { url }, {});
|
|
1392
1512
|
const wrapped = curve.getNetworkConstants().NATIVE_COIN?.wrappedAddress;
|
|
1393
1513
|
if (!curve.hasRouter || !curve.hasRouter()) {
|
|
1394
|
-
|
|
1514
|
+
const session2 = {
|
|
1395
1515
|
curve,
|
|
1396
1516
|
adj: /* @__PURE__ */ new Map(),
|
|
1397
1517
|
swappableNodeKeys: /* @__PURE__ */ new Set(),
|
|
1398
1518
|
wrappedNative: wrapped
|
|
1399
1519
|
};
|
|
1520
|
+
curveSessionCache.set(url, { session: session2, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
|
|
1521
|
+
return session2;
|
|
1400
1522
|
}
|
|
1401
1523
|
await fetchAllCurvePools(curve);
|
|
1402
1524
|
const adj = buildCurveLiquidityGraphFromApi(curve);
|
|
1403
1525
|
addNativeWethBridge(adj, wrapped);
|
|
1404
|
-
|
|
1526
|
+
const session = {
|
|
1405
1527
|
curve,
|
|
1406
1528
|
adj,
|
|
1407
1529
|
swappableNodeKeys: swappableCurveGraphNodeKeys(adj),
|
|
1408
1530
|
wrappedNative: wrapped
|
|
1409
1531
|
};
|
|
1410
|
-
|
|
1411
|
-
return
|
|
1532
|
+
curveSessionCache.set(url, { session, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
|
|
1533
|
+
return session;
|
|
1534
|
+
} catch (e) {
|
|
1535
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
1536
|
+
throw new Error(`Curve session init failed for RPC: ${msg}`);
|
|
1412
1537
|
}
|
|
1413
1538
|
}
|
|
1414
1539
|
|
|
@@ -1588,6 +1713,19 @@ var curveDaoProtocolModule = {
|
|
|
1588
1713
|
return token.kind === "native" || token.kind === "erc20";
|
|
1589
1714
|
},
|
|
1590
1715
|
actions: [
|
|
1716
|
+
{
|
|
1717
|
+
id: "curve-dao.quote",
|
|
1718
|
+
protocolId: CURVE_DAO_PROTOCOL_ID,
|
|
1719
|
+
chainCategory: "evm",
|
|
1720
|
+
description: "Quote swap via Curve Router NG (getBestRouteAndOutput)",
|
|
1721
|
+
commonParams: [],
|
|
1722
|
+
params: {
|
|
1723
|
+
chainId: { type: "number", required: true, description: "EVM chain id" },
|
|
1724
|
+
tokenIn: { type: "address", required: true, description: "Token in or native placeholder" },
|
|
1725
|
+
tokenOut: { type: "address", required: true, description: "Token out or native placeholder" },
|
|
1726
|
+
amountHuman: { type: "string", required: true, description: "Human-readable input amount" }
|
|
1727
|
+
}
|
|
1728
|
+
},
|
|
1591
1729
|
{
|
|
1592
1730
|
id: "curve-dao.swap",
|
|
1593
1731
|
protocolId: CURVE_DAO_PROTOCOL_ID,
|
|
@@ -1614,6 +1752,6 @@ var curveDao = {
|
|
|
1614
1752
|
registerProtocolModule(uniswapV4ProtocolModule);
|
|
1615
1753
|
registerProtocolModule(curveDaoProtocolModule);
|
|
1616
1754
|
|
|
1617
|
-
export { NEAR_CHAIN_CATEGORY, SOLANA_CHAIN_CATEGORY, buildEvmMultisignBatch, coreChainCategoryModule, curveDao, curveDaoProtocolModule, evmChainCategoryModule, finalizeMultisign, getActionsByChainCategory, getProtocolModule, getProtocolModules, isEvmNativeToken, matchEvmTokenKind, mergePurposeText, nearChainCategoryModule, parseEvmChainIdToNumber, registerProtocolModule, routerSwapGasLimitFromEstimate, solanaChainCategoryModule, uniswapV4, uniswapV4ProtocolModule };
|
|
1755
|
+
export { COINGECKO_PLATFORM_BY_CHAIN_ID, NEAR_CHAIN_CATEGORY, SOLANA_CHAIN_CATEGORY, buildEvmMultisignBatch, coingeckoPlatformForChainId, coreChainCategoryModule, curveDao, curveDaoProtocolModule, evmChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getProtocolModule, getProtocolModules, isEvmNativeToken, matchEvmTokenKind, mergePurposeText, nearChainCategoryModule, normalizeCurveRouterAmountString, normalizeHumanDecimalAmount, parseEvmChainIdToNumber, postJsonViaOptionalProxy, registerProtocolModule, routerSwapGasLimitFromEstimate, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl, solanaChainCategoryModule, uniswapV4, uniswapV4ProtocolModule };
|
|
1618
1756
|
//# sourceMappingURL=index.js.map
|
|
1619
1757
|
//# sourceMappingURL=index.js.map
|