@continuumdao/ctm-mpc-defi 0.2.55 → 0.2.57
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 +692 -310
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.d.ts +279 -99
- package/dist/agent/catalog.js +687 -312
- package/dist/agent/catalog.js.map +1 -1
- package/dist/agent/skills/aave-v4/SKILL.md +26 -3
- package/dist/agent/skills/aerodrome/SKILL.md +3 -1
- package/dist/agent/skills/circle-cctp/SKILL.md +5 -4
- package/dist/agent/skills/continuum-dao-marketplace/SKILL.md +4 -4
- package/dist/agent/skills/curve-dao/SKILL.md +2 -2
- package/dist/agent/skills/uniswap-v4/SKILL.md +2 -2
- package/dist/index.cjs +165 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +166 -20
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/aave-v4/index.cjs +198 -15
- package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/aave-v4/index.d.ts +62 -7
- package/dist/protocols/evm/aave-v4/index.js +189 -16
- package/dist/protocols/evm/aave-v4/index.js.map +1 -1
- package/dist/protocols/evm/aerodrome/index.cjs +152 -63
- package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
- package/dist/protocols/evm/aerodrome/index.d.ts +30 -58
- package/dist/protocols/evm/aerodrome/index.js +151 -64
- package/dist/protocols/evm/aerodrome/index.js.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.cjs +77 -19
- package/dist/protocols/evm/circle-cctp/index.cjs.map +1 -1
- package/dist/protocols/evm/circle-cctp/index.d.ts +53 -3
- package/dist/protocols/evm/circle-cctp/index.js +76 -20
- package/dist/protocols/evm/circle-cctp/index.js.map +1 -1
- package/dist/protocols/evm/compound-v3/index.cjs +115 -2
- package/dist/protocols/evm/compound-v3/index.cjs.map +1 -1
- package/dist/protocols/evm/compound-v3/index.js +116 -3
- package/dist/protocols/evm/compound-v3/index.js.map +1 -1
- package/dist/protocols/evm/continuum-dao/index.cjs +288 -32
- package/dist/protocols/evm/continuum-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/continuum-dao/index.d.ts +14 -1
- package/dist/protocols/evm/continuum-dao/index.js +287 -33
- package/dist/protocols/evm/continuum-dao/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +120 -5
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.js +120 -5
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/dist/protocols/evm/euler-v2/index.cjs +121 -6
- package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
- package/dist/protocols/evm/euler-v2/index.js +121 -6
- package/dist/protocols/evm/euler-v2/index.js.map +1 -1
- package/dist/protocols/evm/morpho/index.cjs +129 -57
- package/dist/protocols/evm/morpho/index.cjs.map +1 -1
- package/dist/protocols/evm/morpho/index.d.ts +2 -1
- package/dist/protocols/evm/morpho/index.js +129 -58
- package/dist/protocols/evm/morpho/index.js.map +1 -1
- package/dist/protocols/evm/pendle/index.cjs +129 -10
- package/dist/protocols/evm/pendle/index.cjs.map +1 -1
- package/dist/protocols/evm/pendle/index.js +129 -10
- package/dist/protocols/evm/pendle/index.js.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.cjs +164 -17
- package/dist/protocols/evm/uniswap-v4/index.cjs.map +1 -1
- package/dist/protocols/evm/uniswap-v4/index.js +165 -18
- package/dist/protocols/evm/uniswap-v4/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAddress, parseAbi, stringToHex, zeroAddress, formatUnits, defineChain, createPublicClient, encodeFunctionData, maxUint256, encodeAbiParameters, parseUnits, http, parseGwei, serializeTransaction, keccak256 } from 'viem';
|
|
1
|
+
import { getAddress, parseAbi, stringToHex, zeroAddress, formatUnits, defineChain, createPublicClient, encodeFunctionData, maxUint256, encodeAbiParameters, parseUnits, http, isAddress, parseGwei, serializeTransaction, keccak256 } from 'viem';
|
|
2
2
|
import { fetchChainFeeParams, gasLimitFromEstimateAndChainConfig, gweiToDecimalString, proposalTxParamsToFeeSnapshot, alignEip1559FeesWithLatestBase, getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk';
|
|
3
3
|
|
|
4
4
|
// src/core/registry.ts
|
|
@@ -1107,6 +1107,119 @@ async function buildEvmMultisignBatch(args) {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
return result;
|
|
1109
1109
|
}
|
|
1110
|
+
var COINBASE_B20_STOCK_DECIMALS = 8;
|
|
1111
|
+
var COINBASE_B20_ASSET_PREFIX = "0xb200000000000000000000";
|
|
1112
|
+
function isCoinbaseB20AssetToken(address) {
|
|
1113
|
+
try {
|
|
1114
|
+
return getAddress(address).toLowerCase().startsWith(COINBASE_B20_ASSET_PREFIX);
|
|
1115
|
+
} catch {
|
|
1116
|
+
return false;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
function looksLikeCoinbaseStockSymbol(symbol) {
|
|
1120
|
+
return /^[A-Za-z][A-Za-z0-9]{0,8}(?:\.[A-Za-z][A-Za-z0-9]{0,4})?c$/.test((symbol ?? "").trim());
|
|
1121
|
+
}
|
|
1122
|
+
var COINBASE_TOKENIZED_STOCKS_API_URL = "https://api.coinbase.com/v1/tokenized-stocks";
|
|
1123
|
+
var CATALOG_TTL_MS = 15 * 60 * 1e3;
|
|
1124
|
+
var CATALOG_MAX = 500;
|
|
1125
|
+
var catalogRows = null;
|
|
1126
|
+
var catalogAt = 0;
|
|
1127
|
+
var catalogInflight = null;
|
|
1128
|
+
var catalogBySymbol = /* @__PURE__ */ new Map();
|
|
1129
|
+
var catalogByAddress = /* @__PURE__ */ new Map();
|
|
1130
|
+
function indexCatalog(rows) {
|
|
1131
|
+
catalogRows = rows;
|
|
1132
|
+
catalogAt = Date.now();
|
|
1133
|
+
catalogBySymbol.clear();
|
|
1134
|
+
catalogByAddress.clear();
|
|
1135
|
+
for (const row of rows) {
|
|
1136
|
+
catalogBySymbol.set(row.symbol.toLowerCase(), row);
|
|
1137
|
+
catalogByAddress.set(row.address.toLowerCase(), row);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
function parseCoinbaseTokenizedStocksPayload(payload) {
|
|
1141
|
+
const tokens = Array.isArray(payload) ? payload : payload && typeof payload === "object" && Array.isArray(payload.tokens) ? payload.tokens : [];
|
|
1142
|
+
const out = [];
|
|
1143
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1144
|
+
for (const row of tokens) {
|
|
1145
|
+
if (!row || typeof row !== "object") continue;
|
|
1146
|
+
const rec = row;
|
|
1147
|
+
const symbol = typeof rec.symbol === "string" ? rec.symbol.trim() : "";
|
|
1148
|
+
const addressRaw = typeof rec.contract_address === "string" ? rec.contract_address.trim() : "";
|
|
1149
|
+
if (!looksLikeCoinbaseStockSymbol(symbol) || !isCoinbaseB20AssetToken(addressRaw)) continue;
|
|
1150
|
+
const address = getAddress(addressRaw);
|
|
1151
|
+
const key = address.toLowerCase();
|
|
1152
|
+
if (seen.has(key)) continue;
|
|
1153
|
+
seen.add(key);
|
|
1154
|
+
const name = typeof rec.name === "string" && rec.name.trim() ? rec.name.trim() : symbol;
|
|
1155
|
+
const iconUrl = typeof rec.icon_url === "string" && rec.icon_url.trim() ? rec.icon_url.trim() : void 0;
|
|
1156
|
+
const decimals = typeof rec.decimals === "number" && Number.isInteger(rec.decimals) && rec.decimals >= 0 && rec.decimals <= 18 ? rec.decimals : COINBASE_B20_STOCK_DECIMALS;
|
|
1157
|
+
out.push({ address, symbol, name, decimals, iconUrl });
|
|
1158
|
+
if (out.length >= CATALOG_MAX) break;
|
|
1159
|
+
}
|
|
1160
|
+
return out;
|
|
1161
|
+
}
|
|
1162
|
+
async function fetchCoinbaseB20StockCatalog() {
|
|
1163
|
+
const merged = [];
|
|
1164
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1165
|
+
let pageToken = "";
|
|
1166
|
+
for (let page = 0; page < 4; page++) {
|
|
1167
|
+
const url = new URL(COINBASE_TOKENIZED_STOCKS_API_URL);
|
|
1168
|
+
url.searchParams.set("page_size", "500");
|
|
1169
|
+
if (pageToken) url.searchParams.set("page_token", pageToken);
|
|
1170
|
+
const res = await fetch(url, { cache: "no-store", signal: AbortSignal.timeout(8e3) });
|
|
1171
|
+
if (!res.ok) break;
|
|
1172
|
+
const json = await res.json();
|
|
1173
|
+
for (const row of parseCoinbaseTokenizedStocksPayload(json)) {
|
|
1174
|
+
const key = row.address.toLowerCase();
|
|
1175
|
+
if (seen.has(key)) continue;
|
|
1176
|
+
seen.add(key);
|
|
1177
|
+
merged.push(row);
|
|
1178
|
+
if (merged.length >= CATALOG_MAX) break;
|
|
1179
|
+
}
|
|
1180
|
+
pageToken = typeof json.next_page_token === "string" ? json.next_page_token.trim() : "";
|
|
1181
|
+
if (!pageToken || merged.length >= CATALOG_MAX) break;
|
|
1182
|
+
}
|
|
1183
|
+
if (merged.length > 0) indexCatalog(merged);
|
|
1184
|
+
return catalogRows ?? [];
|
|
1185
|
+
}
|
|
1186
|
+
async function ensureCoinbaseB20StockCatalog() {
|
|
1187
|
+
if (catalogRows && catalogRows.length > 0 && Date.now() - catalogAt < CATALOG_TTL_MS) return catalogRows;
|
|
1188
|
+
if (!catalogInflight) {
|
|
1189
|
+
catalogInflight = fetchCoinbaseB20StockCatalog().finally(() => {
|
|
1190
|
+
catalogInflight = null;
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
try {
|
|
1194
|
+
return await catalogInflight;
|
|
1195
|
+
} catch {
|
|
1196
|
+
return catalogRows ?? [];
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
function lookupCoinbaseB20StockToken(token) {
|
|
1200
|
+
const key = (token ?? "").trim();
|
|
1201
|
+
if (!key) return null;
|
|
1202
|
+
const fromCatalog = catalogBySymbol.get(key.toLowerCase());
|
|
1203
|
+
if (fromCatalog) return fromCatalog;
|
|
1204
|
+
try {
|
|
1205
|
+
return catalogByAddress.get(getAddress(key).toLowerCase()) ?? null;
|
|
1206
|
+
} catch {
|
|
1207
|
+
return null;
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
async function canonicalizeEvmTokenInput(token) {
|
|
1211
|
+
const raw = (token ?? "").trim();
|
|
1212
|
+
if (!raw || isAddress(raw)) return raw;
|
|
1213
|
+
if (!looksLikeCoinbaseStockSymbol(raw)) return raw;
|
|
1214
|
+
await ensureCoinbaseB20StockCatalog().catch(() => []);
|
|
1215
|
+
const hit = lookupCoinbaseB20StockToken(raw);
|
|
1216
|
+
if (!hit) {
|
|
1217
|
+
throw new Error(
|
|
1218
|
+
`Unknown Coinbase stock ticker "${raw}". It is not in the live tokenized-stocks catalog.`
|
|
1219
|
+
);
|
|
1220
|
+
}
|
|
1221
|
+
return hit.address;
|
|
1222
|
+
}
|
|
1110
1223
|
function createCompoundV3PublicClient(rpcUrl, chainId) {
|
|
1111
1224
|
const chain = defineChain({
|
|
1112
1225
|
id: chainId,
|
|
@@ -1216,7 +1329,7 @@ async function buildEvmMultisignBodyCompoundV3Supply(args) {
|
|
|
1216
1329
|
const market = requireCompoundV3Market(args.chainId, args.comet);
|
|
1217
1330
|
const resolved = resolveCompoundV3ActionAsset({
|
|
1218
1331
|
chainId: args.chainId,
|
|
1219
|
-
asset: args.asset,
|
|
1332
|
+
asset: await canonicalizeEvmTokenInput(args.asset),
|
|
1220
1333
|
isNative: args.isNative ?? args.isNativeIn
|
|
1221
1334
|
});
|
|
1222
1335
|
const amountWei = await resolveAmountWei({
|
|
@@ -1274,7 +1387,7 @@ async function buildEvmMultisignBodyCompoundV3Withdraw(args) {
|
|
|
1274
1387
|
const market = requireCompoundV3Market(args.chainId, args.comet);
|
|
1275
1388
|
const resolved = resolveCompoundV3ActionAsset({
|
|
1276
1389
|
chainId: args.chainId,
|
|
1277
|
-
asset: args.asset,
|
|
1390
|
+
asset: await canonicalizeEvmTokenInput(args.asset),
|
|
1278
1391
|
isNative: args.isNative ?? args.isNativeIn
|
|
1279
1392
|
});
|
|
1280
1393
|
const amountWei = await resolveAmountWei({
|