@continuumdao/ctm-mpc-defi 0.2.2 → 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 +34 -14
- package/dist/agent/catalog.cjs.map +1 -1
- package/dist/agent/catalog.js +34 -14
- package/dist/agent/catalog.js.map +1 -1
- package/dist/index.cjs +34 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -14
- package/dist/index.js.map +1 -1
- package/dist/protocols/evm/curve-dao/index.cjs +38 -17
- package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
- package/dist/protocols/evm/curve-dao/index.d.ts +9 -9
- package/dist/protocols/evm/curve-dao/index.js +38 -17
- package/dist/protocols/evm/curve-dao/index.js.map +1 -1
- package/package.json +3 -3
package/dist/agent/catalog.cjs
CHANGED
|
@@ -215,44 +215,64 @@ function swappableCurveGraphNodeKeys(adj) {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
// src/protocols/evm/curve-dao/apiSession.ts
|
|
218
|
+
var CURVE_SESSION_CACHE_TTL_MS = 5 * 60 * 1e3;
|
|
219
|
+
var curveSessionCache = /* @__PURE__ */ new Map();
|
|
218
220
|
async function fetchAllCurvePools(curve) {
|
|
219
221
|
const run = (p) => p.catch(() => void 0);
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
const tasks = [];
|
|
223
|
+
for (const key of [
|
|
224
|
+
"factory",
|
|
225
|
+
"crvUSDFactory",
|
|
226
|
+
"EYWAFactory",
|
|
227
|
+
"cryptoFactory",
|
|
228
|
+
"twocryptoFactory",
|
|
229
|
+
"tricryptoFactory",
|
|
230
|
+
"stableNgFactory"
|
|
231
|
+
]) {
|
|
232
|
+
const f = curve[key];
|
|
233
|
+
if (f?.fetchPools) {
|
|
234
|
+
tasks.push(run(f.fetchPools()));
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
await Promise.all(tasks);
|
|
229
238
|
}
|
|
230
239
|
async function loadFullCurveSessionForRpc(rpcUrl) {
|
|
231
240
|
const url = (rpcUrl ?? "").trim();
|
|
232
|
-
if (!url)
|
|
241
|
+
if (!url) {
|
|
242
|
+
throw new Error("rpcUrl is required.");
|
|
243
|
+
}
|
|
244
|
+
const cached = curveSessionCache.get(url);
|
|
245
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
246
|
+
return cached.session;
|
|
247
|
+
}
|
|
233
248
|
try {
|
|
234
249
|
const { default: curve } = await import('@curvefi/api');
|
|
235
250
|
await curve.init("JsonRpc", { url }, {});
|
|
236
251
|
const wrapped = curve.getNetworkConstants().NATIVE_COIN?.wrappedAddress;
|
|
237
252
|
if (!curve.hasRouter || !curve.hasRouter()) {
|
|
238
|
-
|
|
253
|
+
const session2 = {
|
|
239
254
|
curve,
|
|
240
255
|
adj: /* @__PURE__ */ new Map(),
|
|
241
256
|
swappableNodeKeys: /* @__PURE__ */ new Set(),
|
|
242
257
|
wrappedNative: wrapped
|
|
243
258
|
};
|
|
259
|
+
curveSessionCache.set(url, { session: session2, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
|
|
260
|
+
return session2;
|
|
244
261
|
}
|
|
245
262
|
await fetchAllCurvePools(curve);
|
|
246
263
|
const adj = buildCurveLiquidityGraphFromApi(curve);
|
|
247
264
|
addNativeWethBridge(adj, wrapped);
|
|
248
|
-
|
|
265
|
+
const session = {
|
|
249
266
|
curve,
|
|
250
267
|
adj,
|
|
251
268
|
swappableNodeKeys: swappableCurveGraphNodeKeys(adj),
|
|
252
269
|
wrappedNative: wrapped
|
|
253
270
|
};
|
|
254
|
-
|
|
255
|
-
return
|
|
271
|
+
curveSessionCache.set(url, { session, expiresAt: Date.now() + CURVE_SESSION_CACHE_TTL_MS });
|
|
272
|
+
return session;
|
|
273
|
+
} catch (e) {
|
|
274
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
275
|
+
throw new Error(`Curve session init failed for RPC: ${msg}`);
|
|
256
276
|
}
|
|
257
277
|
}
|
|
258
278
|
|