@continuumdao/ctm-mpc-defi 0.2.61 → 0.2.63

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.
Files changed (32) hide show
  1. package/dist/agent/catalog.cjs +328 -78
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +217 -27
  4. package/dist/agent/catalog.js +324 -79
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/aerodrome/SKILL.md +8 -8
  7. package/dist/agent/skills/railgun/SKILL.md +10 -4
  8. package/dist/agent/skills/yield-compare/SKILL.md +5 -5
  9. package/dist/index.cjs +5 -4
  10. package/dist/index.cjs.map +1 -1
  11. package/dist/index.js +5 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/protocols/evm/aerodrome/index.cjs +476 -282
  14. package/dist/protocols/evm/aerodrome/index.cjs.map +1 -1
  15. package/dist/protocols/evm/aerodrome/index.d.ts +38 -13
  16. package/dist/protocols/evm/aerodrome/index.js +473 -284
  17. package/dist/protocols/evm/aerodrome/index.js.map +1 -1
  18. package/dist/protocols/evm/curve-dao/index.cjs +54 -6
  19. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  20. package/dist/protocols/evm/curve-dao/index.js +54 -6
  21. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  22. package/dist/protocols/evm/euler-v2/index.cjs +45 -10
  23. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  24. package/dist/protocols/evm/euler-v2/index.d.ts +10 -2
  25. package/dist/protocols/evm/euler-v2/index.js +44 -11
  26. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  27. package/dist/protocols/evm/railgun/index.cjs +26 -9
  28. package/dist/protocols/evm/railgun/index.cjs.map +1 -1
  29. package/dist/protocols/evm/railgun/index.d.ts +1 -0
  30. package/dist/protocols/evm/railgun/index.js +26 -9
  31. package/dist/protocols/evm/railgun/index.js.map +1 -1
  32. package/package.json +1 -1
@@ -1095,10 +1095,24 @@ var REGISTRIES = [
1095
1095
  "factory-twocrypto",
1096
1096
  "factory-tricrypto"
1097
1097
  ];
1098
+ function apyNumbers(n) {
1099
+ const ok = (x) => typeof x === "number" && Number.isFinite(x) && x >= 0 && x < 1e5;
1100
+ if (ok(n)) return [n];
1101
+ if (Array.isArray(n)) return n.filter(ok);
1102
+ return [];
1103
+ }
1104
+ function formatApyNumber(n) {
1105
+ if (n > 0 && n < 1e-4) return n.toFixed(6);
1106
+ if (n > 0 && n < 0.01) return n.toFixed(4);
1107
+ return n.toFixed(2);
1108
+ }
1098
1109
  function formatApy(n) {
1099
- if (typeof n === "number" && Number.isFinite(n) && n >= 0) return `${n.toFixed(2)}%`;
1100
- if (Array.isArray(n) && typeof n[0] === "number" && Number.isFinite(n[0])) return `${n[0].toFixed(2)}%`;
1101
- return null;
1110
+ const nums = apyNumbers(n);
1111
+ if (!nums.length) return null;
1112
+ const lo = Math.min(...nums);
1113
+ const hi = Math.max(...nums);
1114
+ if (Math.abs(lo - hi) < 1e-9) return `${formatApyNumber(lo)}%`;
1115
+ return `${formatApyNumber(lo)}\u2013${formatApyNumber(hi)}%`;
1102
1116
  }
1103
1117
  function pickApy(pool, keys) {
1104
1118
  for (const k of keys) {
@@ -1172,11 +1186,45 @@ async function curveDaoFetchImportantPools(args) {
1172
1186
  notes: `Official api.curve.fi catalog, TVL-ranked, hard cap ${CURVE_IMPORTANT_POOL_CAP}. Dead/zero-TVL dropped. Do not call fetchAllCurvePools or invent a list-all-pools tool. gauge_crv_apy requires staking LP in the gauge.`
1173
1187
  };
1174
1188
  }
1189
+ async function fetchCurveSubgraphApyByPool(slug) {
1190
+ const out = /* @__PURE__ */ new Map();
1191
+ try {
1192
+ const res = await fetch(`https://api.curve.finance/api/getSubgraphData/${slug}`, { cache: "no-store" });
1193
+ if (!res.ok) return out;
1194
+ const j = await res.json();
1195
+ for (const row of j.data?.poolList ?? []) {
1196
+ const addr = String(row.address ?? "").trim().toLowerCase();
1197
+ if (!addr) continue;
1198
+ const daily = typeof row.latestDailyApy === "number" && Number.isFinite(row.latestDailyApy) ? row.latestDailyApy : null;
1199
+ const weekly = typeof row.latestWeeklyApy === "number" && Number.isFinite(row.latestWeeklyApy) ? row.latestWeeklyApy : null;
1200
+ out.set(addr, { daily, weekly });
1201
+ }
1202
+ } catch {
1203
+ return out;
1204
+ }
1205
+ return out;
1206
+ }
1207
+ function withSubgraphBaseApy(pool, apy) {
1208
+ if (pool.baseApy) return pool;
1209
+ const hit = apy.get(pool.address.toLowerCase());
1210
+ if (!hit) return pool;
1211
+ const label = formatApy(hit.daily) ?? formatApy(hit.weekly);
1212
+ if (!label) return pool;
1213
+ return { ...pool, baseApy: label };
1214
+ }
1175
1215
  async function curveDaoFetchLpYields(args) {
1176
- const { pools, notes } = await curveDaoFetchImportantPools({ chainId: args.chainId, query: args.query });
1216
+ const slug = CHAIN_SLUG[args.chainId];
1217
+ const [listed, apyByPool] = await Promise.all([
1218
+ curveDaoFetchImportantPools({ chainId: args.chainId, query: args.query }),
1219
+ slug ? fetchCurveSubgraphApyByPool(slug) : Promise.resolve(/* @__PURE__ */ new Map())
1220
+ ]);
1177
1221
  const poolFilter = (args.pool ?? "").trim().toLowerCase();
1178
- const filtered = poolFilter ? pools.filter((p) => p.address.toLowerCase() === poolFilter || p.id.toLowerCase() === poolFilter) : pools;
1179
- return { chainId: args.chainId, pools: filtered, notes };
1222
+ const filtered = (poolFilter ? listed.pools.filter((p) => p.address.toLowerCase() === poolFilter || p.id.toLowerCase() === poolFilter) : listed.pools).map((p) => withSubgraphBaseApy(p, apyByPool));
1223
+ return {
1224
+ chainId: args.chainId,
1225
+ pools: filtered,
1226
+ notes: `${listed.notes} baseApy is getSubgraphData latestDailyApy (else latestWeeklyApy), in percent. gaugeCrvApy is the unboosted\u2013boosted range from getPools; staking the LP in the gauge is required for that CRV yield.`
1227
+ };
1180
1228
  }
1181
1229
  var erc20ApproveAbi = parseAbi(["function approve(address spender, uint256 amount) returns (bool)"]);
1182
1230
  var erc20AllowanceAbi = parseAbi([