@oracle-agent/oracle 0.11.0 → 0.12.0

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 (308) hide show
  1. package/LICENSE +115 -201
  2. package/README.md +66 -84
  3. package/SECURITY.md +37 -12
  4. package/SETUP.md +207 -272
  5. package/dist/action-receipts.mjs +1 -0
  6. package/dist/action-semantics.mjs +1 -0
  7. package/dist/address-book.mjs +2 -0
  8. package/dist/bin/desk-server.mjs +14 -0
  9. package/dist/bin/oracle-data-mcp.mjs +8 -0
  10. package/dist/bin/oracle-init.mjs +24 -0
  11. package/dist/bin/oracle-public-server.mjs +5 -0
  12. package/dist/bin/oracle-route.mjs +22 -0
  13. package/dist/bin/oracle-scan.mjs +18 -0
  14. package/dist/bin/oracle-upgrade.mjs +21 -0
  15. package/dist/bin/oracle.mjs +68 -0
  16. package/dist/chains.mjs +1 -0
  17. package/dist/cli/commands/auth.mjs +16 -0
  18. package/dist/cli/commands/bootstrap.mjs +18 -0
  19. package/dist/cli/commands/chain.mjs +21 -0
  20. package/dist/cli/commands/chat.mjs +35 -0
  21. package/dist/cli/commands/credential.mjs +1 -0
  22. package/dist/cli/commands/data-mcp.mjs +2 -0
  23. package/dist/cli/commands/data.mjs +12 -0
  24. package/dist/cli/commands/doctor.mjs +5 -0
  25. package/dist/cli/commands/gate.mjs +13 -0
  26. package/dist/cli/commands/help.mjs +1 -0
  27. package/dist/cli/commands/init.mjs +3 -0
  28. package/dist/cli/commands/mcp.mjs +33 -0
  29. package/dist/cli/commands/model.mjs +44 -0
  30. package/dist/cli/commands/prepare.mjs +2 -0
  31. package/dist/cli/commands/public.mjs +3 -0
  32. package/dist/cli/commands/route.mjs +2 -0
  33. package/dist/cli/commands/runner.mjs +1 -0
  34. package/dist/cli/commands/scan.mjs +2 -0
  35. package/dist/cli/commands/setup.mjs +34 -0
  36. package/dist/cli/commands/sign.mjs +4 -0
  37. package/dist/cli/commands/signer.mjs +1 -0
  38. package/dist/cli/commands/upgrade.mjs +2 -0
  39. package/dist/cli/commands/vault.mjs +1 -0
  40. package/dist/cli/commands/version.mjs +2 -0
  41. package/dist/data/desk-data.mjs +12 -0
  42. package/dist/index.mjs +17 -0
  43. package/dist/nft-gas-war-guard.mjs +1 -0
  44. package/dist/onboarding/harness-configs.mjs +4 -0
  45. package/dist/portfolio-risk.mjs +1 -0
  46. package/dist/prepare-envelope.mjs +1 -0
  47. package/dist/public-control/policy-schema.mjs +1 -0
  48. package/dist/router/index.mjs +2 -0
  49. package/dist/scanner/index.mjs +4 -0
  50. package/dist/signals/index.mjs +1 -0
  51. package/dist/watch-preferences.mjs +1 -0
  52. package/package.json +27 -65
  53. package/public/oracle-splash/index.html +11 -1
  54. package/CONTRIBUTING.md +0 -98
  55. package/bin/desk-server.mjs +0 -440
  56. package/bin/oracle-data-mcp.mjs +0 -1019
  57. package/bin/oracle-init.mjs +0 -496
  58. package/bin/oracle-public-server.mjs +0 -36
  59. package/bin/oracle-route.mjs +0 -254
  60. package/bin/oracle-scan.mjs +0 -192
  61. package/bin/oracle-upgrade.mjs +0 -42
  62. package/bin/oracle.mjs +0 -33
  63. package/docs/adding-a-chain.md +0 -229
  64. package/docs/architecture.md +0 -138
  65. package/docs/cli.md +0 -47
  66. package/docs/connectors.md +0 -13
  67. package/docs/oracle-pack-standard.md +0 -29
  68. package/docs/profiles.md +0 -151
  69. package/docs/public-surface.md +0 -133
  70. package/examples/add-a-chain.mjs +0 -65
  71. package/examples/oracle-pack-template.mjs +0 -38
  72. package/examples/research-a-token.mjs +0 -70
  73. package/plugins/oracle-owner-gate/__init__.py +0 -227
  74. package/plugins/oracle-owner-gate/plugin.yaml +0 -9
  75. package/profiles/_template/SOUL.md +0 -54
  76. package/profiles/_template/profile.json +0 -22
  77. package/profiles/bitcoin-agent/SOUL.md +0 -31
  78. package/profiles/bitcoin-agent/profile.json +0 -32
  79. package/profiles/hyperliquid-agent/SOUL.md +0 -34
  80. package/profiles/hyperliquid-agent/profile.json +0 -37
  81. package/profiles/oracle/SOUL.md +0 -107
  82. package/profiles/oracle/profile.json +0 -39
  83. package/profiles/polymarket-agent/SOUL.md +0 -35
  84. package/profiles/polymarket-agent/profile.json +0 -34
  85. package/profiles/profile.schema.json +0 -90
  86. package/profiles/protocol-builder/SOUL.md +0 -57
  87. package/profiles/protocol-builder/profile.json +0 -39
  88. package/profiles/robinhood-agent/SOUL.md +0 -53
  89. package/profiles/robinhood-agent/profile.json +0 -40
  90. package/profiles/solana-agent/SOUL.md +0 -37
  91. package/profiles/solana-agent/profile.json +0 -37
  92. package/profiles/stable-agent/SOUL.md +0 -43
  93. package/profiles/stable-agent/profile.json +0 -37
  94. package/protocols/templates/safe-erc20/SECURITY.md +0 -16
  95. package/protocols/templates/safe-erc20/foundry.toml +0 -12
  96. package/protocols/templates/safe-erc20/remappings.txt +0 -2
  97. package/protocols/templates/safe-erc20/src/SafeERC20.sol +0 -53
  98. package/protocols/templates/safe-erc20/test/SafeERC20.t.sol +0 -72
  99. package/scripts/adversarial-bench.mjs +0 -114
  100. package/scripts/build-inscription.py +0 -230
  101. package/scripts/check-doc-drift.mjs +0 -123
  102. package/scripts/check-test-count.mjs +0 -105
  103. package/scripts/e2e-hl-markets.mjs +0 -21
  104. package/scripts/e2e-hl-perps.mjs +0 -48
  105. package/scripts/e2e-hypercore-staking.mjs +0 -128
  106. package/scripts/e2e-solana-bitcoin.mjs +0 -183
  107. package/scripts/protocol-template-gate.mjs +0 -15
  108. package/scripts/public-api-scan.mjs +0 -23
  109. package/scripts/secret-scan.mjs +0 -181
  110. package/scripts/verify-v3-venues.mjs +0 -192
  111. package/skills/balance/SKILL.md +0 -176
  112. package/skills/oracle-action-semantics/SKILL.md +0 -40
  113. package/skills/oracle-best-execution/SKILL.md +0 -127
  114. package/skills/oracle-bitcoin/SKILL.md +0 -53
  115. package/skills/oracle-chain-graphs-telegram-cards/SKILL.md +0 -59
  116. package/skills/oracle-chat/SKILL.md +0 -61
  117. package/skills/oracle-chat/chain.SKILL.md +0 -31
  118. package/skills/oracle-chat/setup.SKILL.md +0 -37
  119. package/skills/oracle-circuit-breaker/SKILL.md +0 -51
  120. package/skills/oracle-contract-research/SKILL.md +0 -55
  121. package/skills/oracle-desk/SKILL.md +0 -58
  122. package/skills/oracle-dex-launch/SKILL.md +0 -38
  123. package/skills/oracle-grants/SKILL.md +0 -69
  124. package/skills/oracle-hypercore-staking/SKILL.md +0 -57
  125. package/skills/oracle-hyperliquid/SKILL.md +0 -56
  126. package/skills/oracle-meme-token-sniper/SKILL.md +0 -73
  127. package/skills/oracle-multichain-nft-launch/SKILL.md +0 -338
  128. package/skills/oracle-multichain-token-launch/SKILL.md +0 -300
  129. package/skills/oracle-nft-gacha-launch/SKILL.md +0 -48
  130. package/skills/oracle-nft-mint-gas-war/SKILL.md +0 -63
  131. package/skills/oracle-polymarket/SKILL.md +0 -60
  132. package/skills/oracle-protocol-builder/SKILL.md +0 -59
  133. package/skills/oracle-protocol-security/SKILL.md +0 -60
  134. package/skills/oracle-public-product/SKILL.md +0 -44
  135. package/skills/oracle-receipts/SKILL.md +0 -52
  136. package/skills/oracle-rfq-tokenized-assets/SKILL.md +0 -69
  137. package/skills/oracle-smart-wallet-scanner/SKILL.md +0 -49
  138. package/skills/oracle-solana/SKILL.md +0 -65
  139. package/skills/oracle-solana-nft/SKILL.md +0 -54
  140. package/skills/oracle-token-research/SKILL.md +0 -67
  141. package/skins/oracle.yaml +0 -56
  142. package/src/action-receipts.mjs +0 -265
  143. package/src/action-semantics.mjs +0 -62
  144. package/src/address-book.mjs +0 -208
  145. package/src/agent-auth.mjs +0 -206
  146. package/src/approval-guard.mjs +0 -282
  147. package/src/attestation-secret.mjs +0 -88
  148. package/src/audit-log.mjs +0 -196
  149. package/src/auth/oauth.mjs +0 -672
  150. package/src/auto-slippage.mjs +0 -378
  151. package/src/capability-posture.mjs +0 -125
  152. package/src/chains.mjs +0 -62
  153. package/src/cli/chain-catalog.mjs +0 -215
  154. package/src/cli/chain-state.mjs +0 -74
  155. package/src/cli/commands/auth.mjs +0 -193
  156. package/src/cli/commands/bootstrap.mjs +0 -87
  157. package/src/cli/commands/chain.mjs +0 -143
  158. package/src/cli/commands/chat.mjs +0 -434
  159. package/src/cli/commands/credential.mjs +0 -9
  160. package/src/cli/commands/data-mcp.mjs +0 -18
  161. package/src/cli/commands/data.mjs +0 -75
  162. package/src/cli/commands/doctor.mjs +0 -136
  163. package/src/cli/commands/help.mjs +0 -7
  164. package/src/cli/commands/init.mjs +0 -27
  165. package/src/cli/commands/mcp.mjs +0 -142
  166. package/src/cli/commands/model.mjs +0 -99
  167. package/src/cli/commands/prepare.mjs +0 -12
  168. package/src/cli/commands/public.mjs +0 -20
  169. package/src/cli/commands/route.mjs +0 -12
  170. package/src/cli/commands/runner.mjs +0 -9
  171. package/src/cli/commands/scan.mjs +0 -12
  172. package/src/cli/commands/setup.mjs +0 -275
  173. package/src/cli/commands/sign.mjs +0 -21
  174. package/src/cli/commands/signer.mjs +0 -9
  175. package/src/cli/commands/upgrade.mjs +0 -12
  176. package/src/cli/commands/vault.mjs +0 -9
  177. package/src/cli/commands/version.mjs +0 -22
  178. package/src/cli/first-run.mjs +0 -23
  179. package/src/cli/kernel.mjs +0 -239
  180. package/src/cli/mcp-targets/chatgpt.mjs +0 -51
  181. package/src/cli/mcp-targets/claude-code.mjs +0 -39
  182. package/src/cli/mcp-targets/claude-desktop.mjs +0 -24
  183. package/src/cli/mcp-targets/codex.mjs +0 -41
  184. package/src/cli/mcp-targets/shared.mjs +0 -61
  185. package/src/cli/messaging-platforms.mjs +0 -209
  186. package/src/cli/model-config.mjs +0 -70
  187. package/src/cli/operator-dispatch.mjs +0 -258
  188. package/src/cli/oracle-harness.py +0 -415
  189. package/src/cli/paths.mjs +0 -83
  190. package/src/cli/runtime.mjs +0 -351
  191. package/src/cli/setup-state.mjs +0 -168
  192. package/src/cli/spawn-child.mjs +0 -43
  193. package/src/data/catalog.mjs +0 -585
  194. package/src/data/desk-data.mjs +0 -695
  195. package/src/data/http.mjs +0 -253
  196. package/src/data/provider-endpoint.mjs +0 -94
  197. package/src/data/providers/aerodrome.mjs +0 -245
  198. package/src/data/providers/balancer.mjs +0 -209
  199. package/src/data/providers/bitcoin-esplora.mjs +0 -216
  200. package/src/data/providers/bitcoin-meta.mjs +0 -378
  201. package/src/data/providers/blockscout.mjs +0 -14
  202. package/src/data/providers/bridges.mjs +0 -242
  203. package/src/data/providers/cowswap.mjs +0 -415
  204. package/src/data/providers/curve.mjs +0 -201
  205. package/src/data/providers/defillama.mjs +0 -88
  206. package/src/data/providers/dexscreener.mjs +0 -43
  207. package/src/data/providers/evm-rpc.mjs +0 -225
  208. package/src/data/providers/geckoterminal.mjs +0 -34
  209. package/src/data/providers/gmx.mjs +0 -496
  210. package/src/data/providers/hl-assets.mjs +0 -165
  211. package/src/data/providers/hl-info.mjs +0 -108
  212. package/src/data/providers/hl-markets.mjs +0 -210
  213. package/src/data/providers/hl-outcome.mjs +0 -61
  214. package/src/data/providers/hl-perps.mjs +0 -387
  215. package/src/data/providers/hl-staking.mjs +0 -353
  216. package/src/data/providers/hl-ws.mjs +0 -119
  217. package/src/data/providers/hyperevm-dex.mjs +0 -49
  218. package/src/data/providers/jupiter-venues.mjs +0 -119
  219. package/src/data/providers/jupiter.mjs +0 -315
  220. package/src/data/providers/lifi.mjs +0 -151
  221. package/src/data/providers/magiceden-sol.mjs +0 -406
  222. package/src/data/providers/morpho.mjs +0 -177
  223. package/src/data/providers/nft-gallery.mjs +0 -163
  224. package/src/data/providers/nft-portfolio.mjs +0 -494
  225. package/src/data/providers/odos.mjs +0 -156
  226. package/src/data/providers/oneinch.mjs +0 -174
  227. package/src/data/providers/opensea-multichain.mjs +0 -136
  228. package/src/data/providers/opensea-nft.mjs +0 -371
  229. package/src/data/providers/paraswap.mjs +0 -118
  230. package/src/data/providers/pendle.mjs +0 -188
  231. package/src/data/providers/poly-clob.mjs +0 -283
  232. package/src/data/providers/poly-public.mjs +0 -96
  233. package/src/data/providers/poly-ws.mjs +0 -103
  234. package/src/data/providers/portfolio-history.mjs +0 -394
  235. package/src/data/providers/portfolio.mjs +0 -594
  236. package/src/data/providers/rfq.mjs +0 -15
  237. package/src/data/providers/rh-agent.mjs +0 -59
  238. package/src/data/providers/satflow.mjs +0 -341
  239. package/src/data/providers/signed-material-guard.mjs +0 -108
  240. package/src/data/providers/solana-rpc.mjs +0 -197
  241. package/src/data/providers/uniswap-v3.mjs +0 -349
  242. package/src/data/providers/uniswap-v4.mjs +0 -414
  243. package/src/data/providers/zerox.mjs +0 -167
  244. package/src/data/public-api-scan.mjs +0 -61
  245. package/src/data/quote-placeholder.mjs +0 -31
  246. package/src/exact-integer.mjs +0 -72
  247. package/src/exec-policy.mjs +0 -455
  248. package/src/flags.mjs +0 -15
  249. package/src/fresh-window.mjs +0 -76
  250. package/src/gmx-attestation.mjs +0 -176
  251. package/src/index.mjs +0 -100
  252. package/src/nft-gas-war-guard.mjs +0 -139
  253. package/src/onboarding/agent-keys.mjs +0 -161
  254. package/src/onboarding/harness-configs.mjs +0 -102
  255. package/src/onboarding/index.mjs +0 -18
  256. package/src/onboarding/tiers.mjs +0 -139
  257. package/src/oracle-env.mjs +0 -47
  258. package/src/portfolio-risk.mjs +0 -170
  259. package/src/prepare-envelope.mjs +0 -204
  260. package/src/profile-upgrade.mjs +0 -277
  261. package/src/protocol-execution.mjs +0 -84
  262. package/src/protocol-templates/gate.mjs +0 -179
  263. package/src/protocol-templates/prepare-deploy.mjs +0 -81
  264. package/src/public-api/buzz-integration.mjs +0 -256
  265. package/src/public-api/connect-agent.mjs +0 -416
  266. package/src/public-api/grants.mjs +0 -142
  267. package/src/public-api/http.mjs +0 -389
  268. package/src/public-control/aa-adapter.mjs +0 -402
  269. package/src/public-control/build-registry.mjs +0 -227
  270. package/src/public-control/bundler-client.mjs +0 -357
  271. package/src/public-control/grant-indexer.mjs +0 -296
  272. package/src/public-control/policy-render.mjs +0 -69
  273. package/src/public-control/policy-schema.mjs +0 -318
  274. package/src/public-control/runtime-config.mjs +0 -275
  275. package/src/public-control/session-key-model.mjs +0 -374
  276. package/src/public-control/session-orchestrator.mjs +0 -412
  277. package/src/rfq/intent.mjs +0 -180
  278. package/src/rfq/sources.mjs +0 -181
  279. package/src/route-attestation.mjs +0 -132
  280. package/src/router/best-execution.mjs +0 -326
  281. package/src/router/index.mjs +0 -226
  282. package/src/router/prepare-bridge.mjs +0 -289
  283. package/src/router/prepare-route.mjs +0 -398
  284. package/src/router/proposal.mjs +0 -311
  285. package/src/router/risk-classifier.mjs +0 -119
  286. package/src/router/route-sources.mjs +0 -364
  287. package/src/scanner/chains.config.mjs +0 -430
  288. package/src/scanner/contract.mjs +0 -270
  289. package/src/scanner/evm-scanner.mjs +0 -394
  290. package/src/scanner/index.mjs +0 -9
  291. package/src/scanner/v2-venue.mjs +0 -335
  292. package/src/scanner/v3-venue.mjs +0 -290
  293. package/src/scopes.mjs +0 -44
  294. package/src/sell-simulation.mjs +0 -167
  295. package/src/signals/engine.mjs +0 -146
  296. package/src/signals/index.mjs +0 -1
  297. package/src/token-transfer-guard.mjs +0 -188
  298. package/src/tui/app.mjs +0 -438
  299. package/src/tui/backend.mjs +0 -145
  300. package/src/tui/format.mjs +0 -272
  301. package/src/tui/gateway-client.mjs +0 -177
  302. package/src/tui/input.mjs +0 -501
  303. package/src/tui/renderer.mjs +0 -443
  304. package/src/tui/standalone-client.mjs +0 -666
  305. package/src/tui/theme.mjs +0 -81
  306. package/src/vault-attestation.mjs +0 -146
  307. package/src/venues.mjs +0 -206
  308. package/src/watch-preferences.mjs +0 -85
@@ -1,415 +0,0 @@
1
- // CoW Swap Order Book API — public, no key. Quotes are read-only. Order
2
- // prepare returns a guarded EIP-712 intent; signing/submission is a separate
3
- // executable artifact flow and must never be treated as normal tx prepare.
4
-
5
- import { TypedDataEncoder, getAddress, isAddress, verifyTypedData } from "ethers";
6
- import { httpJson } from "../http.mjs";
7
- import { attachAutoSlippage } from "../../auto-slippage.mjs";
8
- import { autonomousTradingEnabled } from "../../capability-posture.mjs";
9
- import { QUOTE_PLACEHOLDER_ADDRESS, quoteAddress } from "../quote-placeholder.mjs";
10
- import { stampPrepared } from "../../prepare-envelope.mjs";
11
-
12
- export const COW_HOSTS = {
13
- 1: "https://api.cow.fi/mainnet/api/v1",
14
- 100: "https://api.cow.fi/xdai/api/v1",
15
- 42161: "https://api.cow.fi/arbitrum_one/api/v1",
16
- 8453: "https://api.cow.fi/base/api/v1",
17
- };
18
-
19
- export const COW_SETTLEMENT = Object.freeze({
20
- 1: "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
21
- 100: "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
22
- 42161: "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
23
- 8453: "0x9008D19f58AAbD9eD0D60971565AA8510560ab41",
24
- });
25
-
26
- export const COW_VAULT_RELAYER = Object.freeze({
27
- 1: "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",
28
- 100: "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",
29
- 42161: "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",
30
- 8453: "0xC92E8bdf79f0507f65a392b0ab4667716BFE0110",
31
- });
32
-
33
- const WETH = {
34
- 1: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
35
- 8453: "0x4200000000000000000000000000000000000006",
36
- 42161: "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1",
37
- };
38
- const USDC = {
39
- 1: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
40
- 8453: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
41
- 42161: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
42
- };
43
-
44
- export const COW_ORDER_TYPES = Object.freeze({
45
- Order: [
46
- { name: "sellToken", type: "address" },
47
- { name: "buyToken", type: "address" },
48
- { name: "receiver", type: "address" },
49
- { name: "sellAmount", type: "uint256" },
50
- { name: "buyAmount", type: "uint256" },
51
- { name: "validTo", type: "uint32" },
52
- { name: "appData", type: "bytes32" },
53
- { name: "feeAmount", type: "uint256" },
54
- { name: "kind", type: "string" },
55
- { name: "partiallyFillable", type: "bool" },
56
- { name: "sellTokenBalance", type: "string" },
57
- { name: "buyTokenBalance", type: "string" },
58
- ],
59
- });
60
-
61
- export const COW_CANCEL_TYPES = Object.freeze({
62
- OrderCancellations: [{ name: "orderUids", type: "bytes[]" }],
63
- });
64
-
65
- function host(chainId, opts = {}) {
66
- if (opts.baseUrl) return opts.baseUrl.replace(/\/$/, "");
67
- const h = COW_HOSTS[Number(chainId)];
68
- if (!h) throw new Error(`cowswap: unsupported chainId ${chainId}`);
69
- return h;
70
- }
71
-
72
- function apiHost(chainId, version = "v1", opts = {}) {
73
- const h = host(chainId, opts);
74
- if (version === "v1") return h;
75
- return h.replace(/\/api\/v1$/, `/api/${version}`);
76
- }
77
-
78
- function addr(value, label) {
79
- const text = String(value || "").trim();
80
- if (!isAddress(text)) throw new Error(`cowswap: ${label} must be an address`);
81
- return getAddress(text).toLowerCase();
82
- }
83
-
84
- function uintString(value, label) {
85
- try {
86
- const n = BigInt(String(value));
87
- if (n < 0n) throw new Error("negative");
88
- return n.toString();
89
- } catch {
90
- throw new Error(`cowswap: ${label} must be a non-negative integer string`);
91
- }
92
- }
93
-
94
- function bytes32(value, label) {
95
- const text = String(value || "").trim();
96
- if (!/^0x[0-9a-fA-F]{64}$/.test(text)) throw new Error(`cowswap: ${label} must be bytes32 hex`);
97
- return text.toLowerCase();
98
- }
99
-
100
- function orderUid(value, label = "uid") {
101
- const text = String(value || "").trim();
102
- if (!/^0x[0-9a-fA-F]{112}$/.test(text)) throw new Error(`cowswap: ${label} must be 56-byte order UID hex`);
103
- return text.toLowerCase();
104
- }
105
-
106
- /**
107
- * Market submission gate.
108
- *
109
- * Posture: submission is ARMED once the user has a signer wired up — that is
110
- * the authorization. `opts.execute === true` records that THIS placement was
111
- * asked for, so an order is never posted as a side effect of quoting. The
112
- * separate opt-in exists only for UNATTENDED trading, which is checked by the
113
- * autonomous flag, not here.
114
- */
115
- function requireExecuteGate(opts = {}) {
116
- if (opts.execute !== true) throw new Error("cowswap execute gate required for order signing/submission/cancel");
117
- if (opts.autonomous === true && !autonomousTradingEnabled()) {
118
- throw new Error(
119
- "cowswap: autonomous order placement is off — set ORACLE_AUTONOMOUS_TRADING=1 to let Oracle trade unattended"
120
- );
121
- }
122
- }
123
-
124
- function assertCowOrderGuard(intent = {}, typedData = {}, owner, { nowMs = Date.now() } = {}) {
125
- const guard = intent.cowGuard;
126
- if (!guard || guard.mode !== "cow-order") throw new Error("cowswap: fresh cow order guard required");
127
- if (Number(guard.expiresAtMs) <= Number(nowMs)) throw new Error("cowswap: cow order guard expired");
128
- const chainId = Number(intent.chainId ?? typedData?.domain?.chainId);
129
- if (Number(guard.chainId) !== chainId) throw new Error("cowswap: cow order guard chain mismatch");
130
- if (addr(guard.owner, "guard owner") !== owner) throw new Error("cowswap: cow order guard owner mismatch");
131
- const domain = orderDomain(chainId);
132
- if (Number(typedData?.domain?.chainId) !== chainId) throw new Error("cowswap: typedData chain mismatch");
133
- if (addr(typedData?.domain?.verifyingContract, "settlement") !== domain.verifyingContract.toLowerCase()) {
134
- throw new Error("cowswap: typedData settlement mismatch");
135
- }
136
- if (addr(guard.settlement, "guard settlement") !== domain.verifyingContract.toLowerCase()) {
137
- throw new Error("cowswap: cow order guard settlement mismatch");
138
- }
139
- const message = typedData?.message;
140
- if (!message) throw new Error("cowswap: typedData order message required");
141
- const typedDataHash = TypedDataEncoder.hash(domain, COW_ORDER_TYPES, message);
142
- if (String(guard.typedDataHash || "").toLowerCase() !== typedDataHash.toLowerCase()) {
143
- throw new Error("cowswap: cow order guard typedData hash mismatch");
144
- }
145
- if (addr(guard.sellToken, "guard sellToken") !== addr(message.sellToken, "sellToken")) throw new Error("cowswap: cow order guard sellToken mismatch");
146
- if (addr(guard.buyToken, "guard buyToken") !== addr(message.buyToken, "buyToken")) throw new Error("cowswap: cow order guard buyToken mismatch");
147
- if (String(guard.sellAmount) !== uintString(message.sellAmount, "sellAmount")) throw new Error("cowswap: cow order guard sellAmount mismatch");
148
- if (String(guard.buyAmount) !== uintString(message.buyAmount, "buyAmount")) throw new Error("cowswap: cow order guard buyAmount mismatch");
149
- if (Number(guard.validTo) !== Number(message.validTo)) throw new Error("cowswap: cow order guard validTo mismatch");
150
- if (Number(message.validTo) * 1000 <= Number(nowMs)) throw new Error("cowswap: order expired");
151
- return true;
152
- }
153
-
154
- function toCowOrderUid({ digest, owner, validTo } = {}) {
155
- const d = bytes32(digest, "order digest").slice(2);
156
- const o = addr(owner, "owner").slice(2).toLowerCase();
157
- const v = Number(validTo);
158
- if (!Number.isInteger(v) || v < 0 || v > 0xffffffff) throw new Error("cowswap: validTo must fit uint32");
159
- return `0x${d}${o}${v.toString(16).padStart(8, "0")}`.toLowerCase();
160
- }
161
-
162
- function orderDomain(chainId) {
163
- const verifyingContract = COW_SETTLEMENT[Number(chainId)];
164
- if (!verifyingContract) throw new Error(`cowswap: settlement contract not registered for chain ${chainId}`);
165
- return {
166
- name: "Gnosis Protocol",
167
- version: "v2",
168
- chainId: Number(chainId),
169
- verifyingContract: getAddress(verifyingContract),
170
- };
171
- }
172
-
173
- function normalizeOrderQuote(q = {}, chainId, owner) {
174
- const sellToken = addr(q.sellToken, "sellToken");
175
- const buyToken = addr(q.buyToken, "buyToken");
176
- const receiver = addr(q.receiver || owner, "receiver");
177
- const validTo = Number(q.validTo);
178
- if (!Number.isInteger(validTo) || validTo <= 0) throw new Error("cowswap: quote.validTo required");
179
- const appData = bytes32(q.appData || q.appDataHash || `0x${"0".repeat(64)}`, "appData");
180
- return {
181
- sellToken,
182
- buyToken,
183
- receiver,
184
- sellAmount: uintString(q.sellAmount, "sellAmount"),
185
- buyAmount: uintString(q.buyAmount, "buyAmount"),
186
- validTo,
187
- appData,
188
- feeAmount: uintString(q.feeAmount ?? "0", "feeAmount"),
189
- kind: String(q.kind || "sell"),
190
- partiallyFillable: Boolean(q.partiallyFillable),
191
- sellTokenBalance: String(q.sellTokenBalance || "erc20"),
192
- buyTokenBalance: String(q.buyTokenBalance || "erc20"),
193
- };
194
- }
195
-
196
- export async function cowHealth(opts = {}) {
197
- try {
198
- const q = await cowQuote(
199
- {
200
- chainId: 1,
201
- sellToken: WETH[1],
202
- buyToken: USDC[1],
203
- sellAmountBeforeFee: "1000000000000000",
204
- from: QUOTE_PLACEHOLDER_ADDRESS,
205
- },
206
- opts
207
- );
208
- return { ok: true, buyAmount: q.quote?.buyAmount || q.buyAmount };
209
- } catch (e) {
210
- return { ok: false, error: String(e.message || e).slice(0, 160) };
211
- }
212
- }
213
-
214
- export async function cowQuote(q = {}, opts = {}) {
215
- const chainId = Number(q.chainId ?? 1);
216
- const from = quoteAddress(q.from || q.owner);
217
- let sellToken = q.sellToken || WETH[chainId];
218
- const buyToken = q.buyToken || USDC[chainId];
219
- const sellAmountBeforeFee = String(q.sellAmountBeforeFee || q.sellAmount || "0");
220
- if (!sellToken || !buyToken || sellAmountBeforeFee === "0") {
221
- throw new Error("cowQuote requires sellToken, buyToken, sellAmountBeforeFee");
222
- }
223
- // Cow rejects native ETH — map to WETH
224
- if (/eeeeeeee|native|^eth$/i.test(sellToken)) {
225
- sellToken = WETH[chainId];
226
- if (!sellToken) throw new Error("no WETH mapping for chain");
227
- }
228
- const body = {
229
- sellToken,
230
- buyToken,
231
- from,
232
- receiver: q.receiver || from,
233
- sellAmountBeforeFee,
234
- kind: q.kind || "sell",
235
- signingScheme: q.signingScheme || "eip1271",
236
- };
237
- const result = await httpJson(`${host(chainId, opts)}/quote`, {
238
- method: "POST",
239
- body,
240
- fetchImpl: opts.fetchImpl,
241
- timeoutMs: opts.timeoutMs ?? 15_000,
242
- });
243
- const amountOut = result?.quote?.buyAmount || result?.buyAmount;
244
- if (!amountOut) return result;
245
- // A CoW sell order's signed buyAmount is itself the executable floor. The
246
- // attached guard keeps policy/reporting consistent with direct swap routes.
247
- return attachAutoSlippage(result, {
248
- chainId,
249
- venue: "cowswap-order",
250
- amountOut,
251
- liquidityUsd: q.liquidityUsd,
252
- priceChange5m: q.priceChange5m,
253
- requestedCapBps: q.maxSlippageBps ?? q.slippageBps,
254
- });
255
- }
256
-
257
- export async function cowPrepareOrder(q = {}, opts = {}) {
258
- const chainId = Number(q.chainId ?? 1);
259
- const owner = addr(quoteAddress(q.from || q.owner || q.signer), "owner");
260
- const quote = await cowQuote({ ...q, chainId, from: owner, signingScheme: q.signingScheme || "eip712" }, opts);
261
- const order = normalizeOrderQuote(quote?.quote || quote, chainId, owner);
262
- const domain = orderDomain(chainId);
263
- const typedData = { domain, types: COW_ORDER_TYPES, primaryType: "Order", message: order };
264
- const typedDataHash = TypedDataEncoder.hash(domain, COW_ORDER_TYPES, order);
265
- const relayer = COW_VAULT_RELAYER[chainId];
266
- if (!relayer) throw new Error(`cowswap: vault relayer not registered for chain ${chainId}`);
267
- return stampPrepared({
268
- provider: "cowswap",
269
- orderReady: true,
270
- executionReady: false,
271
- chainId,
272
- owner,
273
- signingScheme: "eip712",
274
- settlement: domain.verifyingContract.toLowerCase(),
275
- vaultRelayer: getAddress(relayer).toLowerCase(),
276
- quote,
277
- quoteId: quote?.id ?? q.quoteId ?? null,
278
- typedData,
279
- cowGuard: {
280
- mode: "cow-order",
281
- version: 1,
282
- provider: "cowswap",
283
- chainId,
284
- owner,
285
- settlement: domain.verifyingContract.toLowerCase(),
286
- vaultRelayer: getAddress(relayer).toLowerCase(),
287
- sellToken: order.sellToken,
288
- buyToken: order.buyToken,
289
- sellAmount: order.sellAmount,
290
- buyAmount: order.buyAmount,
291
- validTo: order.validTo,
292
- quoteId: quote?.id ?? q.quoteId ?? null,
293
- typedDataHash,
294
- issuedAtMs: Date.now(),
295
- expiresAtMs: Math.min(order.validTo * 1000, Date.now() + 20_000),
296
- },
297
- requiresApproval: {
298
- token: order.sellToken,
299
- spender: getAddress(relayer).toLowerCase(),
300
- amount: order.sellAmount,
301
- },
302
- }, { provider: "cowswap", kind: "cow-order" });
303
- }
304
-
305
- export async function cowOrderStatus(q = {}, opts = {}) {
306
- const chainId = Number(q.chainId ?? 1);
307
- const uid = String(q.uid || q.orderUid || "").trim();
308
- if (!uid) throw new Error("cowOrderStatus requires uid");
309
- return httpJson(`${host(chainId, opts)}/orders/${encodeURIComponent(uid)}/status`, {
310
- fetchImpl: opts.fetchImpl,
311
- timeoutMs: opts.timeoutMs ?? 15_000,
312
- });
313
- }
314
-
315
- export async function cowOrder(q = {}, opts = {}) {
316
- const chainId = Number(q.chainId ?? 1);
317
- const uid = String(q.uid || q.orderUid || "").trim();
318
- if (!uid) throw new Error("cowOrder requires uid");
319
- return httpJson(`${host(chainId, opts)}/orders/${encodeURIComponent(uid)}`, {
320
- fetchImpl: opts.fetchImpl,
321
- timeoutMs: opts.timeoutMs ?? 15_000,
322
- });
323
- }
324
-
325
- export function cowOrderUid(intent = {}) {
326
- const typedData = intent.typedData || intent;
327
- const chainId = Number(intent.chainId ?? typedData?.domain?.chainId);
328
- const message = typedData?.message || intent.order || intent.message;
329
- if (!message) throw new Error("cowswap: typed order message required");
330
- const digest = intent.cowGuard?.typedDataHash || TypedDataEncoder.hash(orderDomain(chainId), COW_ORDER_TYPES, message);
331
- const owner = intent.owner || intent.from || intent.signer || message.receiver;
332
- return toCowOrderUid({ digest, owner, validTo: message.validTo });
333
- }
334
-
335
- export async function cowSignOrder(_a = {}, _o = {}) {
336
- throw new Error("cowswap.cowSignOrder refused: @oracle-agent/oracle is prepare-only. Sign with the user wallet; do not pass private keys here.");
337
- }
338
-
339
- export async function cowSubmitSignedOrder(_a = {}, _o = {}) {
340
- throw new Error("cowswap.cowSubmitSignedOrder refused: @oracle-agent/oracle is prepare-only. Submit signed orders from the user wallet or local operator.");
341
- }
342
-
343
- export function cowPrepareCancel(q = {}) {
344
- const chainId = Number(q.chainId ?? 1);
345
- const owner = addr(q.owner || q.from || q.signer, "owner");
346
- const orderUids = (q.orderUids || q.uids || [q.uid]).filter(Boolean).map((u, i) => orderUid(u, `orderUids[${i}]`));
347
- if (!orderUids.length) throw new Error("cowswap: orderUids required");
348
- const domain = orderDomain(chainId);
349
- const message = { orderUids };
350
- return stampPrepared({
351
- provider: "cowswap",
352
- chainId,
353
- owner,
354
- orderUids,
355
- signingScheme: "eip712",
356
- typedData: { domain, types: COW_CANCEL_TYPES, primaryType: "OrderCancellations", message },
357
- cancelReady: true,
358
- executableArtifact: true,
359
- }, { provider: "cowswap", kind: "cow-cancel" });
360
- }
361
-
362
- export async function cowSignCancel(_a = {}, _o = {}) {
363
- throw new Error("cowswap.cowSignCancel refused: @oracle-agent/oracle is prepare-only. Cancel-sign with the user wallet.");
364
- }
365
-
366
- export async function cowCancelOrders(_a = {}, _o = {}) {
367
- throw new Error("cowswap.cowCancelOrders refused: @oracle-agent/oracle is prepare-only. Cancel from the user wallet or local operator.");
368
- }
369
-
370
-
371
- function tradeBuyAmount(trade = {}) {
372
- return uintString(trade.buyAmount ?? trade.executedBuyAmount ?? "0", "trade.buyAmount");
373
- }
374
-
375
- export async function cowVerifyOrderFill(q = {}, opts = {}) {
376
- const chainId = Number(q.chainId ?? 1);
377
- const uid = orderUid(q.uid || q.orderUid);
378
- const order = opts.order || await cowOrder({ chainId, uid }, opts);
379
- const status = opts.status || order.status || await cowOrderStatus({ chainId, uid }, opts).catch(() => null);
380
- const trades = opts.trades || await httpJson(`${apiHost(chainId, "v2", opts)}/trades?orderUid=${encodeURIComponent(uid)}`, {
381
- fetchImpl: opts.fetchImpl,
382
- timeoutMs: opts.timeoutMs ?? 15_000,
383
- });
384
- const list = Array.isArray(trades) ? trades : [];
385
- const expectedOwner = q.expectedOwner ? addr(q.expectedOwner, "expectedOwner") : null;
386
- if (expectedOwner) {
387
- const owner = addr(order.owner || list[0]?.owner || expectedOwner, "owner");
388
- if (owner !== expectedOwner) return { ok: false, provider: "cowswap", chainId, uid, reason: "owner mismatch", order, status, trades: list };
389
- }
390
- let executedBuy = 0n;
391
- for (const t of list.filter((t) => String(t.orderUid || "").toLowerCase() === uid)) {
392
- executedBuy += BigInt(tradeBuyAmount(t));
393
- }
394
- if (executedBuy === 0n && order.executedBuyAmount != null) executedBuy = BigInt(uintString(order.executedBuyAmount, "executedBuyAmount"));
395
- const minBuy = q.minBuyAmount != null ? BigInt(uintString(q.minBuyAmount, "minBuyAmount")) : 0n;
396
- const ok = executedBuy >= minBuy && (String(order.status || status?.status || "").toLowerCase() !== "expired");
397
- return {
398
- ok,
399
- provider: "cowswap",
400
- chainId,
401
- uid,
402
- status: order.status || status?.status || null,
403
- executedBuyAmount: executedBuy.toString(),
404
- minBuyAmount: q.minBuyAmount ?? null,
405
- trades: list,
406
- settlementTxs: [...new Set(list.map((t) => t.txHash).filter(Boolean))],
407
- order,
408
- orderStatus: status,
409
- reason: ok ? null : "insufficient fill or expired order",
410
- };
411
- }
412
-
413
- export function cowChains() {
414
- return Object.keys(COW_HOSTS).map(Number);
415
- }
@@ -1,201 +0,0 @@
1
- // Curve public REST API + RouterNG single-hop exact-input prepare. No key.
2
- import { Interface, getAddress, isAddress } from "ethers";
3
- import { httpJson } from "../http.mjs";
4
- import { rpcCall as defaultRpcCall } from "./evm-rpc.mjs";
5
- import { attachAutoSlippage, bindAutoSlippageGuardToCall } from "../../auto-slippage.mjs";
6
- import { stampPrepared } from "../../prepare-envelope.mjs";
7
-
8
- export const CURVE_API = "https://api.curve.finance/v1";
9
- const base = (o = {}) => (o.baseUrl || process.env.CURVE_API_URL || CURVE_API).replace(/\/$/, "");
10
-
11
- // Official Curve RouterNG deployments from docs.curve.finance router/zaps +
12
- // CurveRouterNG docs. Bytecode is checked before allowlisting.
13
- export const CURVE_ROUTER_NG_BY_CHAIN = Object.freeze({
14
- 1: "0x45312ea0eFf7E09C83CBE249fa1d7598c4C8cd4e",
15
- 10: "0x0DCDED3545D565bA3B19E683431381007245d983",
16
- 56: "0xA72C85C258A81761433B4e8da60505Fe3Dd551CC",
17
- 137: "0x0DCDED3545D565bA3B19E683431381007245d983",
18
- 988: "0xFF5Cb29241F002fFeD2eAa224e3e996D24A6E8d1",
19
- 999: "0xd2002373543Ce3527023C75e7518C274A51ce712",
20
- 4663: "0xFF5Cb29241F002fFeD2eAa224e3e996D24A6E8d1",
21
- 8453: "0x4f37A9d177470499A2dD084621020b023fcffc1F",
22
- 42161: "0x2191718CD32d02B8E60BAdFFeA33E4B5DD9A0A0D",
23
- 43114: "0x0DCDED3545D565bA3B19E683431381007245d983",
24
- });
25
-
26
- const ZERO = "0x0000000000000000000000000000000000000000";
27
- const ROUTER_IFACE = new Interface([
28
- "function get_dy(address[11] route,uint256[5][5] swap_params,uint256 amount,address[5] pools) view returns (uint256)",
29
- "function exchange(address[11] route,uint256[5][5] swap_params,uint256 amount,uint256 expected,address[5] pools,address receiver) payable returns (uint256)",
30
- ]);
31
- const POOL_IFACE = new Interface(["function coins(uint256) view returns (address)"]);
32
-
33
- function routerFor(chainId) {
34
- const router = CURVE_ROUTER_NG_BY_CHAIN[Number(chainId)];
35
- if (!router) throw new Error(`curve-router-ng: unsupported chainId ${chainId}`);
36
- return router;
37
- }
38
-
39
- function normalizeAddress(value, label) {
40
- if (!isAddress(value)) throw new Error(`${label} must be a valid EVM address`);
41
- return getAddress(value);
42
- }
43
-
44
- function positiveAmount(value, label) {
45
- let amount;
46
- try {
47
- amount = BigInt(String(value));
48
- } catch {
49
- throw new Error(`${label} must be an integer string`);
50
- }
51
- if (amount <= 0n) throw new Error(`${label} must be positive`);
52
- return amount;
53
- }
54
-
55
- function integer(value, label, min, max) {
56
- const n = Number(value);
57
- if (!Number.isInteger(n) || n < min || n > max) throw new Error(`${label} must be an integer ${min}..${max}`);
58
- return n;
59
- }
60
-
61
- function routeArray(tokenIn, pool, tokenOut) {
62
- return [tokenIn, pool, tokenOut, ...Array(8).fill(ZERO)];
63
- }
64
-
65
- function swapParams(i, j, poolType, nCoins) {
66
- return [[BigInt(i), BigInt(j), 1n, BigInt(poolType), BigInt(nCoins)], ...Array.from({ length: 4 }, () => [0n, 0n, 0n, 0n, 0n])];
67
- }
68
-
69
- function poolsArray(pool) {
70
- return [pool, ...Array(4).fill(ZERO)];
71
- }
72
-
73
- async function poolCoins({ chainId, pool, nCoins, rpcCall, opts }) {
74
- const coins = [];
75
- for (let i = 0; i < nCoins; i++) {
76
- const data = POOL_IFACE.encodeFunctionData("coins", [i]);
77
- const raw = await rpcCall(chainId, "eth_call", [{ to: pool, data }, opts.blockTag || "latest"], opts);
78
- const decoded = POOL_IFACE.decodeFunctionResult("coins", raw);
79
- coins.push(getAddress(decoded[0]));
80
- }
81
- return coins;
82
- }
83
-
84
- function findIndex(coins, token, label) {
85
- const target = token.toLowerCase();
86
- const idx = coins.findIndex((coin) => coin.toLowerCase() === target);
87
- if (idx < 0) throw new Error(`Curve pool does not contain ${label}`);
88
- return idx;
89
- }
90
-
91
- export async function curveOpenApi(opts = {}) {
92
- return httpJson(`${base(opts)}/openapi.json`, { fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs });
93
- }
94
-
95
- export async function curvePools(args = {}, opts = {}) {
96
- const chain = String(args.chain || args.network || "ethereum").toLowerCase();
97
- const registry = String(args.registry || "main").toLowerCase();
98
- if (!/^[a-z0-9-]+$/.test(chain) || !/^[a-z0-9-]+$/.test(registry)) throw new Error("invalid Curve chain or registry");
99
- return httpJson(`${base(opts)}/getPools/${chain}/${registry}`, { fetchImpl: opts.fetchImpl, timeoutMs: opts.timeoutMs ?? 20_000 });
100
- }
101
-
102
- export async function curveHealth(opts = {}) {
103
- const data = await curvePools({ chain: "ethereum", registry: "main" }, opts);
104
- const count = data?.data?.poolData?.length || 0;
105
- return { ok: data?.success === true && count > 0, poolSample: count };
106
- }
107
-
108
- export async function curveQuote(q = {}, opts = {}) {
109
- const chainId = Number(q.chainId ?? 8453);
110
- const router = routerFor(chainId);
111
- const pool = normalizeAddress(q.pool, "curve pool");
112
- const tokenIn = normalizeAddress(q.tokenIn, "curve tokenIn");
113
- const tokenOut = normalizeAddress(q.tokenOut, "curve tokenOut");
114
- const amountIn = positiveAmount(q.amountIn, "curve amountIn");
115
- const nCoins = integer(q.nCoins ?? 2, "curve nCoins", 2, 8);
116
- const poolType = integer(q.poolType, "curve poolType", 1, 4);
117
- const rpcCall = opts.rpcCall || defaultRpcCall;
118
- const coins = await poolCoins({ chainId, pool, nCoins, rpcCall, opts });
119
- const i = findIndex(coins, tokenIn, "tokenIn");
120
- const j = findIndex(coins, tokenOut, "tokenOut");
121
- if (i === j) throw new Error("Curve token indexes must differ");
122
- const route = routeArray(tokenIn, pool, tokenOut);
123
- const params = swapParams(i, j, poolType, nCoins);
124
- const pools = poolsArray(pool);
125
- const data = ROUTER_IFACE.encodeFunctionData("get_dy", [route, params, amountIn, pools]);
126
- const raw = await rpcCall(chainId, "eth_call", [{ to: router, data }, q.blockTag || "latest"], opts);
127
- const decoded = ROUTER_IFACE.decodeFunctionResult("get_dy", raw);
128
- const amountOut = BigInt(decoded[0]);
129
- if (amountOut <= 0n) throw new Error("curve quote returned zero output");
130
- return attachAutoSlippage({
131
- venue: "curve",
132
- router,
133
- chainId,
134
- pool,
135
- tokenIn,
136
- tokenOut,
137
- amountIn: amountIn.toString(),
138
- amountOut: amountOut.toString(),
139
- nCoins,
140
- poolType,
141
- swapType: 1,
142
- i,
143
- j,
144
- route,
145
- swapParams: params.map((row) => row.map((x) => x.toString())),
146
- pools,
147
- }, {
148
- chainId,
149
- venue: router,
150
- amountOut: amountOut.toString(),
151
- liquidityUsd: q.liquidityUsd,
152
- priceChange5m: q.priceChange5m,
153
- requestedCapBps: q.maxSlippageBps ?? q.slippageBps,
154
- });
155
- }
156
-
157
- export async function curvePrepare(q = {}, opts = {}) {
158
- const chainId = Number(q.chainId ?? 8453);
159
- const router = routerFor(chainId);
160
- const sender = normalizeAddress(q.sender || q.from || q.fromAddress || q.receiver, "curve sender");
161
- const receiver = normalizeAddress(q.receiver || q.recipient || sender, "curve receiver");
162
- const quote = await curveQuote({ ...q, sender }, opts);
163
- const route = routeArray(quote.tokenIn, quote.pool, quote.tokenOut);
164
- const params = swapParams(quote.i, quote.j, quote.poolType, quote.nCoins);
165
- const pools = poolsArray(quote.pool);
166
- const data = ROUTER_IFACE.encodeFunctionData("exchange", [
167
- route,
168
- params,
169
- BigInt(quote.amountIn),
170
- BigInt(quote.amountOutMinimum),
171
- pools,
172
- receiver,
173
- ]);
174
- return stampPrepared({
175
- provider: "curve",
176
- calldataReady: true,
177
- // NOT executable authority. The bytes are assembled but nothing is signed:
178
- // the user's wallet is still the only thing that can authorize this. The
179
- // previous `executionReady: true` read as "cleared to execute" and trained
180
- // agents to treat a quote as permission.
181
- requiresUserSignature: true,
182
- signingReady: false,
183
- broadcastReady: false,
184
- chainId,
185
- quote,
186
- autoSlippage: quote.autoSlippage,
187
- requiresApproval: {
188
- token: quote.tokenIn,
189
- spender: router,
190
- amount: quote.amountIn,
191
- },
192
- transaction: {
193
- chainId,
194
- from: sender,
195
- to: router,
196
- data,
197
- value: "0",
198
- slippageGuard: bindAutoSlippageGuardToCall(quote.autoSlippage, { chainId, venue: router, data }),
199
- },
200
- }, { provider: "curve", kind: "curve-tx" });
201
- }