@continuumdao/ctm-mpc-defi 0.2.1 → 0.2.2

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 (57) hide show
  1. package/dist/agent/catalog.cjs +62 -11
  2. package/dist/agent/catalog.cjs.map +1 -1
  3. package/dist/agent/catalog.d.ts +27 -1
  4. package/dist/agent/catalog.js +61 -12
  5. package/dist/agent/catalog.js.map +1 -1
  6. package/dist/agent/skills/curve-dao/SKILL.md +2 -1
  7. package/dist/chains/evm/index.cjs +54 -0
  8. package/dist/chains/evm/index.cjs.map +1 -1
  9. package/dist/chains/evm/index.d.ts +13 -1
  10. package/dist/chains/evm/index.js +52 -2
  11. package/dist/chains/evm/index.js.map +1 -1
  12. package/dist/core/index.cjs +64 -0
  13. package/dist/core/index.cjs.map +1 -1
  14. package/dist/core/index.d.ts +20 -1
  15. package/dist/core/index.js +56 -1
  16. package/dist/core/index.js.map +1 -1
  17. package/dist/index.cjs +131 -0
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +2 -2
  20. package/dist/index.js +120 -2
  21. package/dist/index.js.map +1 -1
  22. package/dist/protocols/evm/aave-v4/index.cjs +766 -6
  23. package/dist/protocols/evm/aave-v4/index.cjs.map +1 -1
  24. package/dist/protocols/evm/aave-v4/index.d.ts +417 -1
  25. package/dist/protocols/evm/aave-v4/index.js +741 -8
  26. package/dist/protocols/evm/aave-v4/index.js.map +1 -1
  27. package/dist/protocols/evm/curve-dao/index.cjs +233 -7
  28. package/dist/protocols/evm/curve-dao/index.cjs.map +1 -1
  29. package/dist/protocols/evm/curve-dao/index.d.ts +66 -1
  30. package/dist/protocols/evm/curve-dao/index.js +227 -9
  31. package/dist/protocols/evm/curve-dao/index.js.map +1 -1
  32. package/dist/protocols/evm/ethena/index.cjs +104 -0
  33. package/dist/protocols/evm/ethena/index.cjs.map +1 -1
  34. package/dist/protocols/evm/ethena/index.d.ts +46 -1
  35. package/dist/protocols/evm/ethena/index.js +99 -1
  36. package/dist/protocols/evm/ethena/index.js.map +1 -1
  37. package/dist/protocols/evm/euler-v2/index.cjs +2334 -37
  38. package/dist/protocols/evm/euler-v2/index.cjs.map +1 -1
  39. package/dist/protocols/evm/euler-v2/index.d.ts +464 -1
  40. package/dist/protocols/evm/euler-v2/index.js +2286 -39
  41. package/dist/protocols/evm/euler-v2/index.js.map +1 -1
  42. package/dist/protocols/evm/lido/index.cjs +110 -0
  43. package/dist/protocols/evm/lido/index.cjs.map +1 -1
  44. package/dist/protocols/evm/lido/index.d.ts +33 -2
  45. package/dist/protocols/evm/lido/index.js +107 -2
  46. package/dist/protocols/evm/lido/index.js.map +1 -1
  47. package/dist/protocols/evm/maple/index.cjs +83 -0
  48. package/dist/protocols/evm/maple/index.cjs.map +1 -1
  49. package/dist/protocols/evm/maple/index.d.ts +22 -1
  50. package/dist/protocols/evm/maple/index.js +82 -1
  51. package/dist/protocols/evm/maple/index.js.map +1 -1
  52. package/dist/protocols/evm/sky/index.cjs +217 -0
  53. package/dist/protocols/evm/sky/index.cjs.map +1 -1
  54. package/dist/protocols/evm/sky/index.d.ts +56 -1
  55. package/dist/protocols/evm/sky/index.js +210 -2
  56. package/dist/protocols/evm/sky/index.js.map +1 -1
  57. package/package.json +1 -1
@@ -86,6 +86,61 @@ function getActionsByChainCategory(category) {
86
86
  return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
87
87
  }
88
88
 
89
- export { coreChainCategoryModule, finalizeMultisign, getActionsByChainCategory, getProtocolModule, getProtocolModules, mergePurposeText, registerProtocolModule };
89
+ // src/core/defiProxy.ts
90
+ var aaveGraphqlProxyUrl;
91
+ var eulerGraphqlProxyUrl;
92
+ var mapleGraphqlProxyUrl;
93
+ var coingeckoProxyUrl;
94
+ function setAaveGraphqlProxyUrl(url) {
95
+ aaveGraphqlProxyUrl = url?.trim() || void 0;
96
+ }
97
+ function getAaveGraphqlProxyUrl() {
98
+ return aaveGraphqlProxyUrl;
99
+ }
100
+ function setEulerGraphqlProxyUrl(url) {
101
+ eulerGraphqlProxyUrl = url?.trim() || void 0;
102
+ }
103
+ function getEulerGraphqlProxyUrl() {
104
+ return eulerGraphqlProxyUrl;
105
+ }
106
+ function setMapleGraphqlProxyUrl(url) {
107
+ mapleGraphqlProxyUrl = url?.trim() || void 0;
108
+ }
109
+ function getMapleGraphqlProxyUrl() {
110
+ return mapleGraphqlProxyUrl;
111
+ }
112
+ function setCoingeckoProxyUrl(url) {
113
+ coingeckoProxyUrl = url?.trim() || void 0;
114
+ }
115
+ function getCoingeckoProxyUrl() {
116
+ return coingeckoProxyUrl;
117
+ }
118
+ async function postJsonViaOptionalProxy(args) {
119
+ const proxy = args.proxyUrl?.trim();
120
+ if (proxy) {
121
+ const r2 = await fetch(proxy, {
122
+ method: "POST",
123
+ headers: { "content-type": "application/json" },
124
+ body: JSON.stringify(args.proxyEnvelope ?? args.body)
125
+ });
126
+ if (!r2.ok) {
127
+ const t = await r2.text().catch(() => "");
128
+ throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
129
+ }
130
+ return await r2.json();
131
+ }
132
+ const r = await fetch(args.directUrl, {
133
+ method: "POST",
134
+ headers: { "content-type": "application/json" },
135
+ body: JSON.stringify(args.body)
136
+ });
137
+ if (!r.ok) {
138
+ const t = await r.text().catch(() => "");
139
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
140
+ }
141
+ return await r.json();
142
+ }
143
+
144
+ export { coreChainCategoryModule, finalizeMultisign, getAaveGraphqlProxyUrl, getActionsByChainCategory, getCoingeckoProxyUrl, getEulerGraphqlProxyUrl, getMapleGraphqlProxyUrl, getProtocolModule, getProtocolModules, mergePurposeText, postJsonViaOptionalProxy, registerProtocolModule, setAaveGraphqlProxyUrl, setCoingeckoProxyUrl, setEulerGraphqlProxyUrl, setMapleGraphqlProxyUrl };
90
145
  //# sourceMappingURL=index.js.map
91
146
  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EAAA,EAAI;AACrC,IAAA,WAAA,CAAY,KAAA,GAAQ,SAAS,QAAA,EAAS;AAAA,EACxC;AAEA,EAAA,IAAI,QAAA,cAAsB,QAAA,GAAW,QAAA;AAErC,EAAA,OAAO,EAAE,WAAA,EAAa,aAAA,EAAe,IAAA,CAAK,SAAA,CAAU,WAAW,CAAA,EAAE;AACnE;AAEO,IAAM,uBAAA,GAA+C;AAAA,EAC1D,QAAA,EAAU,KAAA;AAAA,EACV;AACF;;;ACpGA,IAAM,UAA4B,EAAC;AAE5B,SAAS,uBAAuB,GAAA,EAA2B;AAChE,EAAA,MAAM,QAAA,GAAW,QAAQ,SAAA,CAAU,CAAC,MAAM,CAAA,CAAE,EAAA,KAAO,IAAI,EAAE,CAAA;AACzD,EAAA,IAAI,YAAY,CAAA,EAAG;AACjB,IAAA,OAAA,CAAQ,QAAQ,CAAA,GAAI,GAAA;AAAA,EACtB,CAAA,MAAO;AACL,IAAA,OAAA,CAAQ,KAAK,GAAG,CAAA;AAAA,EAClB;AACF;AAEO,SAAS,kBAAA,GAAgD;AAC9D,EAAA,OAAO,OAAA;AACT;AAEO,SAAS,kBAAkB,EAAA,EAAwC;AACxE,EAAA,OAAO,QAAQ,IAAA,CAAK,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,EAAE,CAAA;AACxC;AAEO,SAAS,0BAA0B,QAAA,EAA6C;AACrF,EAAA,OAAO,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,aAAA,KAAkB,QAAQ,CAAA,CAAE,OAAA,CAAQ,CAAC,CAAA,KAAM,CAAA,CAAE,OAAO,CAAA;AACrF","file":"index.js","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n"]}
1
+ {"version":3,"sources":["../../src/core/purpose.ts","../../src/core/envelope.ts","../../src/core/registry.ts","../../src/core/defiProxy.ts"],"names":["r"],"mappings":";;;;;;AACO,SAAS,gBAAA,CAAiB,aAAqB,aAAA,EAAgC;AACpF,EAAA,MAAM,CAAA,GAAI,YAAY,IAAA,EAAK;AAC3B,EAAA,MAAM,MAAA,GAAA,CAAU,aAAA,IAAiB,EAAA,EAAI,IAAA,EAAK;AAC1C,EAAA,IAAI,CAAC,QAAQ,OAAO,CAAA;AACpB,EAAA,OAAO,CAAA,GAAI,GAAG,CAAC;;AAAA,EAAO,MAAM,CAAA,C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M,MAAM,EAAE,CAAA;AACvC,IAAA,MAAM,IAAI,KAAA,CAAM,CAAA,GAAI,CAAA,KAAA,EAAQ,CAAA,CAAE,MAAM,CAAA,EAAA,EAAK,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,GAAG,CAAC,CAAA,CAAA,GAAK,CAAA,KAAA,EAAQ,CAAA,CAAE,MAAM,CAAA,CAAE,CAAA;AAAA,EACjF;AACA,EAAA,OAAQ,MAAM,EAAE,IAAA,EAAK;AACvB","file":"index.js","sourcesContent":["/** Merge user purpose text with an optional batch / protocol suffix. */\nexport function mergePurposeText(purposeText: string, purposeSuffix?: string): string {\n const t = purposeText.trim()\n const suffix = (purposeSuffix ?? '').trim()\n if (!suffix) return t\n return t ? `${t}\\n\\n${suffix}` : suffix\n}\n","import type { ChainCategory, MultisignBuildResult, KeyGenSubset } from './types.js'\nimport { getClientIdFromKeyGenResult } from '@continuumdao/continuum-node-sdk'\nimport { mergePurposeText } from './purpose.js'\n\nexport interface MultisignLeg {\n msgHash: string\n msgRaw: string\n destinationAddress: string\n signatureText: string\n audit: Record<string, unknown>\n feeSnapshot: Record<string, unknown>\n proposalTxParams?: Record<string, unknown>\n /** Payable value wei string for first leg only when relevant */\n valueWei?: bigint\n}\n\nexport interface ChainCategoryBuildInput {\n keyGen: KeyGenSubset\n purposeText: string\n purposeSuffix?: string\n destinationChainID: string\n legs: MultisignLeg[]\n extraJSON?: Record<string, unknown>\n /** Top-level destination address (first leg destination if omitted) */\n destinationAddress?: string\n}\n\nexport interface ChainCategoryModule {\n category: ChainCategory\n finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult\n}\n\n/**\n * Assemble mpc-auth `bodyForSign` from category-built legs.\n * Supports single-tx and batch (messageHashes / messageRawBatch / proposalTxParams).\n */\nexport function finalizeMultisign(input: ChainCategoryBuildInput): MultisignBuildResult {\n const { keyGen, destinationChainID, legs } = input\n if (legs.length === 0) {\n throw new Error('finalizeMultisign requires at least one leg')\n }\n\n const ph = (keyGen.pubkeyhex ?? '').trim()\n if (!ph) throw new Error('keyGen pubKey (pubkeyhex) is required')\n\n const keyList = keyGen.keylist ?? []\n const clientId = getClientIdFromKeyGenResult(keyGen)\n const first = legs[0]!\n\n const messageHashes = legs.map((l) => l.msgHash)\n const messageRawBatch = legs.map((l) => l.msgRaw)\n const batchMeta = legs.map((l) => ({\n destinationAddress: l.destinationAddress,\n signatureText: l.signatureText,\n ...l.audit,\n }))\n\n const proposalTxParams = legs\n .map((l) => l.proposalTxParams)\n .filter((p): p is Record<string, unknown> => p != null && typeof p === 'object')\n\n const extraPayload: Record<string, unknown> = {\n batchMeta,\n ...(input.extraJSON ?? {}),\n }\n const extraJSON = JSON.stringify(extraPayload)\n\n const bodyForSign: Record<string, unknown> = {\n keyList,\n pubKey: ph,\n msgHash: messageHashes[0],\n msgRaw: first.msgRaw,\n destinationChainID,\n destinationAddress: input.destinationAddress ?? first.destinationAddress,\n extraJSON,\n signatureText: first.signatureText,\n purpose: mergePurposeText(input.purposeText, input.purposeSuffix),\n ...first.feeSnapshot,\n }\n\n if (legs.length > 1) {\n bodyForSign.messageHashes = messageHashes\n bodyForSign.messageRawBatch = messageRawBatch\n }\n\n if (proposalTxParams.length > 0) {\n bodyForSign.proposalTxParams = proposalTxParams\n }\n\n const valueWei = first.valueWei\n if (valueWei != null && valueWei > 0n) {\n bodyForSign.value = valueWei.toString()\n }\n\n if (clientId) bodyForSign.clientId = clientId\n\n return { bodyForSign, messageToSign: JSON.stringify(bodyForSign) }\n}\n\nexport const coreChainCategoryModule: ChainCategoryModule = {\n category: 'evm',\n finalizeMultisign,\n}\n","import type { ProtocolModule } from './types.js'\n\nconst modules: ProtocolModule[] = []\n\nexport function registerProtocolModule(mod: ProtocolModule): void {\n const existing = modules.findIndex((m) => m.id === mod.id)\n if (existing >= 0) {\n modules[existing] = mod\n } else {\n modules.push(mod)\n }\n}\n\nexport function getProtocolModules(): readonly ProtocolModule[] {\n return modules\n}\n\nexport function getProtocolModule(id: string): ProtocolModule | undefined {\n return modules.find((m) => m.id === id)\n}\n\nexport function getActionsByChainCategory(category: string): ProtocolModule['actions'] {\n return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions)\n}\n","/**\n * Optional browser → Next.js API proxy paths for DeFi upstream calls.\n * Set once from continuumdao-node-app client bootstrap.\n */\n\nlet aaveGraphqlProxyUrl: string | undefined\nlet eulerGraphqlProxyUrl: string | undefined\nlet mapleGraphqlProxyUrl: string | undefined\nlet coingeckoProxyUrl: string | undefined\n\nexport function setAaveGraphqlProxyUrl(url: string | undefined): void {\n aaveGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getAaveGraphqlProxyUrl(): string | undefined {\n return aaveGraphqlProxyUrl\n}\n\nexport function setEulerGraphqlProxyUrl(url: string | undefined): void {\n eulerGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getEulerGraphqlProxyUrl(): string | undefined {\n return eulerGraphqlProxyUrl\n}\n\nexport function setMapleGraphqlProxyUrl(url: string | undefined): void {\n mapleGraphqlProxyUrl = url?.trim() || undefined\n}\n\nexport function getMapleGraphqlProxyUrl(): string | undefined {\n return mapleGraphqlProxyUrl\n}\n\nexport function setCoingeckoProxyUrl(url: string | undefined): void {\n coingeckoProxyUrl = url?.trim() || undefined\n}\n\nexport function getCoingeckoProxyUrl(): string | undefined {\n return coingeckoProxyUrl\n}\n\nexport async function postJsonViaOptionalProxy<T>(args: {\n directUrl: string\n body: unknown\n proxyUrl?: string\n proxyEnvelope?: unknown\n}): Promise<T> {\n const proxy = args.proxyUrl?.trim()\n if (proxy) {\n const r = await fetch(proxy, {\n method: 'POST',\n headers: {'content-type': 'application/json'},\n body: JSON.stringify(args.proxyEnvelope ?? args.body),\n })\n if (!r.ok) {\n const t = await r.text().catch(() => '')\n throw new Error(t ? `Proxy HTTP ${r.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r.status}`)\n }\n return (await r.json()) as T\n }\n const r = await fetch(args.directUrl, {\n method: 'POST',\n headers: {'content-type': 'application/json'},\n body: JSON.stringify(args.body),\n })\n if (!r.ok) {\n const t = await r.text().catch(() => '')\n throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`)\n }\n return (await r.json()) as T\n}\n"]}
package/dist/index.cjs CHANGED
@@ -87,6 +87,61 @@ function getProtocolModule(id) {
87
87
  function getActionsByChainCategory(category) {
88
88
  return modules.filter((m) => m.chainCategory === category).flatMap((m) => m.actions);
89
89
  }
90
+
91
+ // src/core/defiProxy.ts
92
+ var aaveGraphqlProxyUrl;
93
+ var eulerGraphqlProxyUrl;
94
+ var mapleGraphqlProxyUrl;
95
+ var coingeckoProxyUrl;
96
+ function setAaveGraphqlProxyUrl(url) {
97
+ aaveGraphqlProxyUrl = url?.trim() || void 0;
98
+ }
99
+ function getAaveGraphqlProxyUrl() {
100
+ return aaveGraphqlProxyUrl;
101
+ }
102
+ function setEulerGraphqlProxyUrl(url) {
103
+ eulerGraphqlProxyUrl = url?.trim() || void 0;
104
+ }
105
+ function getEulerGraphqlProxyUrl() {
106
+ return eulerGraphqlProxyUrl;
107
+ }
108
+ function setMapleGraphqlProxyUrl(url) {
109
+ mapleGraphqlProxyUrl = url?.trim() || void 0;
110
+ }
111
+ function getMapleGraphqlProxyUrl() {
112
+ return mapleGraphqlProxyUrl;
113
+ }
114
+ function setCoingeckoProxyUrl(url) {
115
+ coingeckoProxyUrl = url?.trim() || void 0;
116
+ }
117
+ function getCoingeckoProxyUrl() {
118
+ return coingeckoProxyUrl;
119
+ }
120
+ async function postJsonViaOptionalProxy(args) {
121
+ const proxy = args.proxyUrl?.trim();
122
+ if (proxy) {
123
+ const r2 = await fetch(proxy, {
124
+ method: "POST",
125
+ headers: { "content-type": "application/json" },
126
+ body: JSON.stringify(args.proxyEnvelope ?? args.body)
127
+ });
128
+ if (!r2.ok) {
129
+ const t = await r2.text().catch(() => "");
130
+ throw new Error(t ? `Proxy HTTP ${r2.status}: ${t.slice(0, 200)}` : `Proxy HTTP ${r2.status}`);
131
+ }
132
+ return await r2.json();
133
+ }
134
+ const r = await fetch(args.directUrl, {
135
+ method: "POST",
136
+ headers: { "content-type": "application/json" },
137
+ body: JSON.stringify(args.body)
138
+ });
139
+ if (!r.ok) {
140
+ const t = await r.text().catch(() => "");
141
+ throw new Error(t ? `HTTP ${r.status}: ${t.slice(0, 200)}` : `HTTP ${r.status}`);
142
+ }
143
+ return await r.json();
144
+ }
90
145
  function isEvmNativeToken(address) {
91
146
  try {
92
147
  return viem.getAddress(address) === viem.zeroAddress;
@@ -299,6 +354,56 @@ function parseEvmChainIdToNumber(chainId) {
299
354
  }
300
355
  return Number.parseInt(t, 10);
301
356
  }
357
+ function normalizeHumanDecimalAmount(raw, tokenDecimals) {
358
+ const t = raw.trim().replace(/,/g, "");
359
+ if (!t) return "";
360
+ if (!Number.isInteger(tokenDecimals) || tokenDecimals < 0 || tokenDecimals > 18) {
361
+ throw new Error("Invalid token decimals for amount normalization.");
362
+ }
363
+ const wei = viem.parseUnits(t, tokenDecimals);
364
+ return viem.formatUnits(wei, tokenDecimals);
365
+ }
366
+ var normalizeCurveRouterAmountString = normalizeHumanDecimalAmount;
367
+
368
+ // src/chains/evm/coingecko.ts
369
+ var COINGECKO_PLATFORM_BY_CHAIN_ID = {
370
+ "1": "ethereum",
371
+ "56": "binance-smart-chain",
372
+ "137": "polygon-pos",
373
+ "42161": "arbitrum-one",
374
+ "10": "optimistic-ethereum",
375
+ "43114": "avalanche",
376
+ "8453": "base",
377
+ "324": "zk-sync-era",
378
+ "42220": "celo",
379
+ "250": "fantom",
380
+ "100": "gnosis",
381
+ "204": "op-bnb",
382
+ "534352": "scroll",
383
+ "5000": "mantle",
384
+ "169": "manta-pacific",
385
+ "1116": "core",
386
+ "30": "rootstock",
387
+ "288": "boba",
388
+ "1088": "metis-andromeda",
389
+ "34443": "mode",
390
+ "80084": "berachain",
391
+ "146": "sonic",
392
+ "60808": "bob-network",
393
+ "80094": "berachain",
394
+ "130": "unichain",
395
+ "57073": "ink",
396
+ "999": "hyperevm",
397
+ "239": "tac",
398
+ "9745": "plasma",
399
+ "1923": "swellchain",
400
+ "59144": "linea",
401
+ "81457": "blast",
402
+ "7777777": "zora"
403
+ };
404
+ function coingeckoPlatformForChainId(chainId) {
405
+ return COINGECKO_PLATFORM_BY_CHAIN_ID[String(chainId).trim()];
406
+ }
302
407
 
303
408
  // src/chains/solana/types.ts
304
409
  var solanaChainCategoryModule = {
@@ -1589,6 +1694,19 @@ var curveDaoProtocolModule = {
1589
1694
  return token.kind === "native" || token.kind === "erc20";
1590
1695
  },
1591
1696
  actions: [
1697
+ {
1698
+ id: "curve-dao.quote",
1699
+ protocolId: CURVE_DAO_PROTOCOL_ID,
1700
+ chainCategory: "evm",
1701
+ description: "Quote swap via Curve Router NG (getBestRouteAndOutput)",
1702
+ commonParams: [],
1703
+ params: {
1704
+ chainId: { type: "number", required: true, description: "EVM chain id" },
1705
+ tokenIn: { type: "address", required: true, description: "Token in or native placeholder" },
1706
+ tokenOut: { type: "address", required: true, description: "Token out or native placeholder" },
1707
+ amountHuman: { type: "string", required: true, description: "Human-readable input amount" }
1708
+ }
1709
+ },
1592
1710
  {
1593
1711
  id: "curve-dao.swap",
1594
1712
  protocolId: CURVE_DAO_PROTOCOL_ID,
@@ -1619,24 +1737,37 @@ Object.defineProperty(exports, "firstClientIdFromKeyGen", {
1619
1737
  enumerable: true,
1620
1738
  get: function () { return continuumNodeSdk.getClientIdFromKeyGenResult; }
1621
1739
  });
1740
+ exports.COINGECKO_PLATFORM_BY_CHAIN_ID = COINGECKO_PLATFORM_BY_CHAIN_ID;
1622
1741
  exports.NEAR_CHAIN_CATEGORY = NEAR_CHAIN_CATEGORY;
1623
1742
  exports.SOLANA_CHAIN_CATEGORY = SOLANA_CHAIN_CATEGORY;
1624
1743
  exports.buildEvmMultisignBatch = buildEvmMultisignBatch;
1744
+ exports.coingeckoPlatformForChainId = coingeckoPlatformForChainId;
1625
1745
  exports.coreChainCategoryModule = coreChainCategoryModule;
1626
1746
  exports.curveDao = curveDao;
1627
1747
  exports.curveDaoProtocolModule = curveDaoProtocolModule;
1628
1748
  exports.evmChainCategoryModule = evmChainCategoryModule;
1629
1749
  exports.finalizeMultisign = finalizeMultisign;
1750
+ exports.getAaveGraphqlProxyUrl = getAaveGraphqlProxyUrl;
1630
1751
  exports.getActionsByChainCategory = getActionsByChainCategory;
1752
+ exports.getCoingeckoProxyUrl = getCoingeckoProxyUrl;
1753
+ exports.getEulerGraphqlProxyUrl = getEulerGraphqlProxyUrl;
1754
+ exports.getMapleGraphqlProxyUrl = getMapleGraphqlProxyUrl;
1631
1755
  exports.getProtocolModule = getProtocolModule;
1632
1756
  exports.getProtocolModules = getProtocolModules;
1633
1757
  exports.isEvmNativeToken = isEvmNativeToken;
1634
1758
  exports.matchEvmTokenKind = matchEvmTokenKind;
1635
1759
  exports.mergePurposeText = mergePurposeText;
1636
1760
  exports.nearChainCategoryModule = nearChainCategoryModule;
1761
+ exports.normalizeCurveRouterAmountString = normalizeCurveRouterAmountString;
1762
+ exports.normalizeHumanDecimalAmount = normalizeHumanDecimalAmount;
1637
1763
  exports.parseEvmChainIdToNumber = parseEvmChainIdToNumber;
1764
+ exports.postJsonViaOptionalProxy = postJsonViaOptionalProxy;
1638
1765
  exports.registerProtocolModule = registerProtocolModule;
1639
1766
  exports.routerSwapGasLimitFromEstimate = routerSwapGasLimitFromEstimate;
1767
+ exports.setAaveGraphqlProxyUrl = setAaveGraphqlProxyUrl;
1768
+ exports.setCoingeckoProxyUrl = setCoingeckoProxyUrl;
1769
+ exports.setEulerGraphqlProxyUrl = setEulerGraphqlProxyUrl;
1770
+ exports.setMapleGraphqlProxyUrl = setMapleGraphqlProxyUrl;
1640
1771
  exports.solanaChainCategoryModule = solanaChainCategoryModule;
1641
1772
  exports.uniswapV4 = uniswapV4;
1642
1773
  exports.uniswapV4ProtocolModule = uniswapV4ProtocolModule;