@eco-incorp/sauce 0.99.5 → 0.99.7

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 (1197) hide show
  1. package/README.md +58 -16
  2. package/actions/action-program.schema.json +480 -379
  3. package/actions/dist/abis.d.ts +19 -18
  4. package/actions/dist/abis.d.ts.map +1 -1
  5. package/actions/dist/abis.js +29 -29
  6. package/actions/dist/compile.d.ts +4 -4
  7. package/actions/dist/compile.d.ts.map +1 -1
  8. package/actions/dist/compile.js +3 -1
  9. package/actions/dist/compose.d.ts +63 -6
  10. package/actions/dist/compose.d.ts.map +1 -1
  11. package/actions/dist/compose.js +100 -16
  12. package/actions/dist/index.d.ts +1 -1
  13. package/actions/dist/index.d.ts.map +1 -1
  14. package/actions/dist/names.d.ts +88 -0
  15. package/actions/dist/names.d.ts.map +1 -0
  16. package/actions/dist/names.js +324 -0
  17. package/actions/dist/program.d.ts.map +1 -1
  18. package/actions/dist/program.js +115 -5
  19. package/actions/dist/registry.d.ts +10 -8
  20. package/actions/dist/registry.d.ts.map +1 -1
  21. package/actions/dist/registry.js +10 -8
  22. package/actions/dist/schema.d.ts.map +1 -1
  23. package/actions/dist/schema.js +99 -12
  24. package/actions/dist/semantics.d.ts +12 -2
  25. package/actions/dist/semantics.d.ts.map +1 -1
  26. package/actions/dist/semantics.js +78 -8
  27. package/actions/dist/spec.d.ts +30 -0
  28. package/actions/dist/spec.d.ts.map +1 -1
  29. package/actions/dist/spec.js +151 -138
  30. package/actions/dist/split-swap.d.ts +10 -5
  31. package/actions/dist/split-swap.d.ts.map +1 -1
  32. package/actions/dist/split-swap.js +48 -7
  33. package/actions/dist/to-quote.d.ts +14 -5
  34. package/actions/dist/to-quote.d.ts.map +1 -1
  35. package/actions/dist/to-quote.js +210 -244
  36. package/actions/dist/to-sauce.d.ts +18 -4
  37. package/actions/dist/to-sauce.d.ts.map +1 -1
  38. package/actions/dist/to-sauce.js +232 -205
  39. package/actions/dist/types.d.ts +245 -147
  40. package/actions/dist/types.d.ts.map +1 -1
  41. package/actions/dist/types.js +4 -0
  42. package/docs/README.md +38 -0
  43. package/docs/api/README.md +37 -23
  44. package/docs/api/compiler.md +53 -12
  45. package/docs/api/contracts.md +105 -0
  46. package/docs/api/coverage.md +80 -57
  47. package/docs/api/router.md +238 -0
  48. package/docs/api/routes.md +31 -22
  49. package/docs/concepts/architecture.md +30 -5
  50. package/docs/concepts/saucescript.md +53 -56
  51. package/docs/examples/README.md +21 -14
  52. package/docs/examples/action-program.ts +51 -35
  53. package/docs/examples/cross-chain-cascade.sauce.ts +4 -0
  54. package/docs/examples/cross-chain-intent.sauce.ts +2 -1
  55. package/docs/examples/evm-execution.ts +2 -4
  56. package/docs/examples/first-intent.ts +7 -2
  57. package/docs/examples/pot-router.ts +19 -0
  58. package/docs/examples/registry-names.ts +52 -0
  59. package/docs/examples/router-route.sauce.ts +31 -0
  60. package/docs/examples/router-route.ts +72 -0
  61. package/docs/examples/router-swap.sauce.ts +16 -0
  62. package/docs/examples/router-swap.ts +47 -0
  63. package/docs/examples/venue-where-deployed.sauce.ts +14 -0
  64. package/docs/guides/actions.md +230 -120
  65. package/docs/guides/builders-and-actions.md +24 -15
  66. package/docs/guides/cli.md +1442 -0
  67. package/docs/guides/compiling.md +24 -10
  68. package/docs/guides/intents.md +260 -17
  69. package/docs/guides/mcp.md +539 -0
  70. package/docs/guides/nested-intents.md +21 -6
  71. package/docs/guides/protocols-and-tokens.md +235 -36
  72. package/docs/guides/quick-start.md +5 -0
  73. package/docs/guides/solana.md +199 -52
  74. package/docs/guides/verification.md +2 -2
  75. package/mcp/dist/config.js +78 -0
  76. package/mcp/dist/config.js.map +1 -0
  77. package/mcp/dist/entry.js +112 -0
  78. package/mcp/dist/entry.js.map +1 -0
  79. package/mcp/dist/files.js +64 -0
  80. package/mcp/dist/files.js.map +1 -0
  81. package/mcp/dist/guard.js +262 -0
  82. package/mcp/dist/guard.js.map +1 -0
  83. package/mcp/dist/http.js +111 -0
  84. package/mcp/dist/http.js.map +1 -0
  85. package/mcp/dist/intents.js +579 -0
  86. package/mcp/dist/intents.js.map +1 -0
  87. package/mcp/dist/prompts.js +153 -0
  88. package/mcp/dist/prompts.js.map +1 -0
  89. package/mcp/dist/reach.js +98 -0
  90. package/mcp/dist/reach.js.map +1 -0
  91. package/mcp/dist/resources.js +154 -0
  92. package/mcp/dist/resources.js.map +1 -0
  93. package/mcp/dist/sdk.js +34 -0
  94. package/mcp/dist/sdk.js.map +1 -0
  95. package/mcp/dist/server.js +119 -0
  96. package/mcp/dist/server.js.map +1 -0
  97. package/mcp/dist/setup.js +189 -0
  98. package/mcp/dist/setup.js.map +1 -0
  99. package/mcp/dist/skilltools.js +520 -0
  100. package/mcp/dist/skilltools.js.map +1 -0
  101. package/mcp/dist/terms.js +93 -0
  102. package/mcp/dist/terms.js.map +1 -0
  103. package/mcp/dist/tools.js +1497 -0
  104. package/mcp/dist/tools.js.map +1 -0
  105. package/mcp/dist/wallets.js +168 -0
  106. package/mcp/dist/wallets.js.map +1 -0
  107. package/package.json +18 -13
  108. package/sdk/dist/artifacts/V12Deployments.json +3 -1
  109. package/sdk/dist/artifacts/V12EngineGate.json +1 -2
  110. package/sdk/dist/artifacts/V12KitchenProxy.json +1 -0
  111. package/sdk/dist/chains/canonical.d.ts +15 -24
  112. package/sdk/dist/chains/canonical.d.ts.map +1 -1
  113. package/sdk/dist/chains/canonical.js +18 -29
  114. package/sdk/dist/chains/canonical.js.map +1 -1
  115. package/sdk/dist/cli/actions.d.ts +29 -0
  116. package/sdk/dist/cli/actions.d.ts.map +1 -0
  117. package/sdk/dist/cli/actions.js +122 -0
  118. package/sdk/dist/cli/actions.js.map +1 -0
  119. package/sdk/dist/cli/args.d.ts +118 -0
  120. package/sdk/dist/cli/args.d.ts.map +1 -0
  121. package/sdk/dist/cli/args.js +354 -0
  122. package/sdk/dist/cli/args.js.map +1 -0
  123. package/sdk/dist/cli/assume.d.ts +51 -0
  124. package/sdk/dist/cli/assume.d.ts.map +1 -0
  125. package/sdk/dist/cli/assume.js +207 -0
  126. package/sdk/dist/cli/assume.js.map +1 -0
  127. package/sdk/dist/cli/chain.d.ts +170 -0
  128. package/sdk/dist/cli/chain.d.ts.map +1 -0
  129. package/sdk/dist/cli/chain.js +457 -0
  130. package/sdk/dist/cli/chain.js.map +1 -0
  131. package/sdk/dist/cli/commands.d.ts +226 -0
  132. package/sdk/dist/cli/commands.d.ts.map +1 -0
  133. package/sdk/dist/cli/commands.js +637 -0
  134. package/sdk/dist/cli/commands.js.map +1 -0
  135. package/sdk/dist/cli/create.d.ts +70 -0
  136. package/sdk/dist/cli/create.d.ts.map +1 -0
  137. package/sdk/dist/cli/create.js +483 -0
  138. package/sdk/dist/cli/create.js.map +1 -0
  139. package/sdk/dist/cli/diagnostics.d.ts +12 -0
  140. package/sdk/dist/cli/diagnostics.d.ts.map +1 -0
  141. package/sdk/dist/cli/diagnostics.js +200 -0
  142. package/sdk/dist/cli/diagnostics.js.map +1 -0
  143. package/sdk/dist/cli/effects.d.ts +71 -0
  144. package/sdk/dist/cli/effects.d.ts.map +1 -0
  145. package/sdk/dist/cli/effects.js +279 -0
  146. package/sdk/dist/cli/effects.js.map +1 -0
  147. package/sdk/dist/cli/fill.d.ts +83 -0
  148. package/sdk/dist/cli/fill.d.ts.map +1 -0
  149. package/sdk/dist/cli/fill.js +734 -0
  150. package/sdk/dist/cli/fill.js.map +1 -0
  151. package/sdk/dist/cli/funding.d.ts +126 -0
  152. package/sdk/dist/cli/funding.d.ts.map +1 -0
  153. package/sdk/dist/cli/funding.js +514 -0
  154. package/sdk/dist/cli/funding.js.map +1 -0
  155. package/sdk/dist/cli/globals.d.ts +16 -0
  156. package/sdk/dist/cli/globals.d.ts.map +1 -0
  157. package/sdk/dist/cli/globals.js +197 -0
  158. package/sdk/dist/cli/globals.js.map +1 -0
  159. package/sdk/dist/cli/init.d.ts +34 -0
  160. package/sdk/dist/cli/init.d.ts.map +1 -0
  161. package/sdk/dist/cli/init.js +181 -0
  162. package/sdk/dist/cli/init.js.map +1 -0
  163. package/sdk/dist/cli/inputs.d.ts +72 -0
  164. package/sdk/dist/cli/inputs.d.ts.map +1 -0
  165. package/sdk/dist/cli/inputs.js +152 -0
  166. package/sdk/dist/cli/inputs.js.map +1 -0
  167. package/sdk/dist/cli/inspect.d.ts +48 -0
  168. package/sdk/dist/cli/inspect.d.ts.map +1 -0
  169. package/sdk/dist/cli/inspect.js +536 -0
  170. package/sdk/dist/cli/inspect.js.map +1 -0
  171. package/sdk/dist/cli/intent-commands.d.ts +71 -0
  172. package/sdk/dist/cli/intent-commands.d.ts.map +1 -0
  173. package/sdk/dist/cli/intent-commands.js +698 -0
  174. package/sdk/dist/cli/intent-commands.js.map +1 -0
  175. package/sdk/dist/cli/intent-svm.d.ts +15 -0
  176. package/sdk/dist/cli/intent-svm.d.ts.map +1 -0
  177. package/sdk/dist/cli/intent-svm.js +222 -0
  178. package/sdk/dist/cli/intent-svm.js.map +1 -0
  179. package/sdk/dist/cli/intents.d.ts +43 -0
  180. package/sdk/dist/cli/intents.d.ts.map +1 -0
  181. package/sdk/dist/cli/intents.js +89 -0
  182. package/sdk/dist/cli/intents.js.map +1 -0
  183. package/sdk/dist/cli/interactive.d.ts +11 -0
  184. package/sdk/dist/cli/interactive.d.ts.map +1 -0
  185. package/sdk/dist/cli/interactive.js +161 -0
  186. package/sdk/dist/cli/interactive.js.map +1 -0
  187. package/sdk/dist/cli/lifecycle-svm.d.ts +109 -0
  188. package/sdk/dist/cli/lifecycle-svm.d.ts.map +1 -0
  189. package/sdk/dist/cli/lifecycle-svm.js +299 -0
  190. package/sdk/dist/cli/lifecycle-svm.js.map +1 -0
  191. package/sdk/dist/cli/lifecycle.d.ts +439 -0
  192. package/sdk/dist/cli/lifecycle.d.ts.map +1 -0
  193. package/sdk/dist/cli/lifecycle.js +1721 -0
  194. package/sdk/dist/cli/lifecycle.js.map +1 -0
  195. package/sdk/dist/cli/main.d.ts +3 -0
  196. package/sdk/dist/cli/main.d.ts.map +1 -0
  197. package/sdk/dist/cli/main.js +8 -0
  198. package/sdk/dist/cli/main.js.map +1 -0
  199. package/sdk/dist/cli/mcp.d.ts +66 -0
  200. package/sdk/dist/cli/mcp.d.ts.map +1 -0
  201. package/sdk/dist/cli/mcp.js +169 -0
  202. package/sdk/dist/cli/mcp.js.map +1 -0
  203. package/sdk/dist/cli/password.d.ts +54 -0
  204. package/sdk/dist/cli/password.d.ts.map +1 -0
  205. package/sdk/dist/cli/password.js +148 -0
  206. package/sdk/dist/cli/password.js.map +1 -0
  207. package/sdk/dist/cli/policy.d.ts +130 -0
  208. package/sdk/dist/cli/policy.d.ts.map +1 -0
  209. package/sdk/dist/cli/policy.js +702 -0
  210. package/sdk/dist/cli/policy.js.map +1 -0
  211. package/sdk/dist/cli/pools.d.ts +140 -0
  212. package/sdk/dist/cli/pools.d.ts.map +1 -0
  213. package/sdk/dist/cli/pools.js +658 -0
  214. package/sdk/dist/cli/pools.js.map +1 -0
  215. package/sdk/dist/cli/price.d.ts +74 -0
  216. package/sdk/dist/cli/price.d.ts.map +1 -0
  217. package/sdk/dist/cli/price.js +321 -0
  218. package/sdk/dist/cli/price.js.map +1 -0
  219. package/sdk/dist/cli/prompt.d.ts +30 -0
  220. package/sdk/dist/cli/prompt.d.ts.map +1 -0
  221. package/sdk/dist/cli/prompt.js +53 -0
  222. package/sdk/dist/cli/prompt.js.map +1 -0
  223. package/sdk/dist/cli/publish.d.ts +48 -0
  224. package/sdk/dist/cli/publish.d.ts.map +1 -0
  225. package/sdk/dist/cli/publish.js +480 -0
  226. package/sdk/dist/cli/publish.js.map +1 -0
  227. package/sdk/dist/cli/receipt.d.ts +35 -0
  228. package/sdk/dist/cli/receipt.d.ts.map +1 -0
  229. package/sdk/dist/cli/receipt.js +63 -0
  230. package/sdk/dist/cli/receipt.js.map +1 -0
  231. package/sdk/dist/cli/rehearse.d.ts +80 -0
  232. package/sdk/dist/cli/rehearse.d.ts.map +1 -0
  233. package/sdk/dist/cli/rehearse.js +265 -0
  234. package/sdk/dist/cli/rehearse.js.map +1 -0
  235. package/sdk/dist/cli/report.d.ts +69 -0
  236. package/sdk/dist/cli/report.d.ts.map +1 -0
  237. package/sdk/dist/cli/report.js +206 -0
  238. package/sdk/dist/cli/report.js.map +1 -0
  239. package/sdk/dist/cli/returned.d.ts +16 -0
  240. package/sdk/dist/cli/returned.d.ts.map +1 -0
  241. package/sdk/dist/cli/returned.js +111 -0
  242. package/sdk/dist/cli/returned.js.map +1 -0
  243. package/sdk/dist/cli/run.d.ts +40 -0
  244. package/sdk/dist/cli/run.d.ts.map +1 -0
  245. package/sdk/dist/cli/run.js +3162 -0
  246. package/sdk/dist/cli/run.js.map +1 -0
  247. package/sdk/dist/cli/signer.d.ts +72 -0
  248. package/sdk/dist/cli/signer.d.ts.map +1 -0
  249. package/sdk/dist/cli/signer.js +243 -0
  250. package/sdk/dist/cli/signer.js.map +1 -0
  251. package/sdk/dist/cli/simulate.d.ts +11 -0
  252. package/sdk/dist/cli/simulate.d.ts.map +1 -0
  253. package/sdk/dist/cli/simulate.js +246 -0
  254. package/sdk/dist/cli/simulate.js.map +1 -0
  255. package/sdk/dist/cli/skills.d.ts +77 -0
  256. package/sdk/dist/cli/skills.d.ts.map +1 -0
  257. package/sdk/dist/cli/skills.js +527 -0
  258. package/sdk/dist/cli/skills.js.map +1 -0
  259. package/sdk/dist/cli/solana.d.ts +183 -0
  260. package/sdk/dist/cli/solana.d.ts.map +1 -0
  261. package/sdk/dist/cli/solana.js +1360 -0
  262. package/sdk/dist/cli/solana.js.map +1 -0
  263. package/sdk/dist/cli/store.d.ts +60 -0
  264. package/sdk/dist/cli/store.d.ts.map +1 -0
  265. package/sdk/dist/cli/store.js +196 -0
  266. package/sdk/dist/cli/store.js.map +1 -0
  267. package/sdk/dist/cli/support.d.ts +144 -0
  268. package/sdk/dist/cli/support.d.ts.map +1 -0
  269. package/sdk/dist/cli/support.js +217 -0
  270. package/sdk/dist/cli/support.js.map +1 -0
  271. package/sdk/dist/cli/svm-effects.d.ts +50 -0
  272. package/sdk/dist/cli/svm-effects.d.ts.map +1 -0
  273. package/sdk/dist/cli/svm-effects.js +196 -0
  274. package/sdk/dist/cli/svm-effects.js.map +1 -0
  275. package/sdk/dist/cli/terminal.d.ts +42 -0
  276. package/sdk/dist/cli/terminal.d.ts.map +1 -0
  277. package/sdk/dist/cli/terminal.js +136 -0
  278. package/sdk/dist/cli/terminal.js.map +1 -0
  279. package/sdk/dist/cli/verify.d.ts +32 -0
  280. package/sdk/dist/cli/verify.d.ts.map +1 -0
  281. package/sdk/dist/cli/verify.js +185 -0
  282. package/sdk/dist/cli/verify.js.map +1 -0
  283. package/sdk/dist/cli/wallet-commands.d.ts +59 -0
  284. package/sdk/dist/cli/wallet-commands.d.ts.map +1 -0
  285. package/sdk/dist/cli/wallet-commands.js +222 -0
  286. package/sdk/dist/cli/wallet-commands.js.map +1 -0
  287. package/sdk/dist/cli/wallet-send.d.ts +38 -0
  288. package/sdk/dist/cli/wallet-send.d.ts.map +1 -0
  289. package/sdk/dist/cli/wallet-send.js +303 -0
  290. package/sdk/dist/cli/wallet-send.js.map +1 -0
  291. package/sdk/dist/cli/wallets.d.ts +79 -0
  292. package/sdk/dist/cli/wallets.d.ts.map +1 -0
  293. package/sdk/dist/cli/wallets.js +297 -0
  294. package/sdk/dist/cli/wallets.js.map +1 -0
  295. package/sdk/dist/deployments/index.d.ts +4 -62
  296. package/sdk/dist/deployments/index.d.ts.map +1 -1
  297. package/sdk/dist/deployments/index.js +4 -84
  298. package/sdk/dist/deployments/index.js.map +1 -1
  299. package/sdk/dist/deployments/pot.d.ts +17 -7
  300. package/sdk/dist/deployments/pot.d.ts.map +1 -1
  301. package/sdk/dist/deployments/pot.js +25 -10
  302. package/sdk/dist/deployments/pot.js.map +1 -1
  303. package/sdk/dist/deployments/releases.d.ts +36 -0
  304. package/sdk/dist/deployments/releases.d.ts.map +1 -0
  305. package/sdk/dist/deployments/releases.js +61 -0
  306. package/sdk/dist/deployments/releases.js.map +1 -0
  307. package/sdk/dist/deployments/releases.json +76 -0
  308. package/sdk/dist/deployments/v12-addresses.d.ts +13 -0
  309. package/sdk/dist/deployments/v12-addresses.d.ts.map +1 -1
  310. package/sdk/dist/deployments/v12-addresses.js +16 -3
  311. package/sdk/dist/deployments/v12-addresses.js.map +1 -1
  312. package/sdk/dist/deposit/index.d.ts +6 -6
  313. package/sdk/dist/deposit/index.d.ts.map +1 -1
  314. package/sdk/dist/deposit/index.js +1 -1
  315. package/sdk/dist/deposit/index.js.map +1 -1
  316. package/sdk/dist/deposit/params.d.ts +4 -4
  317. package/sdk/dist/deposit/params.d.ts.map +1 -1
  318. package/sdk/dist/deposit/params.js +7 -4
  319. package/sdk/dist/deposit/params.js.map +1 -1
  320. package/sdk/dist/deposit/source.d.ts +3 -30
  321. package/sdk/dist/deposit/source.d.ts.map +1 -1
  322. package/sdk/dist/deposit/source.js +7 -83
  323. package/sdk/dist/deposit/source.js.map +1 -1
  324. package/sdk/dist/deposit/templates.d.ts +1 -2
  325. package/sdk/dist/deposit/templates.d.ts.map +1 -1
  326. package/sdk/dist/deposit/templates.js +10 -2
  327. package/sdk/dist/deposit/templates.js.map +1 -1
  328. package/sdk/dist/deposit/types.d.ts +14 -12
  329. package/sdk/dist/deposit/types.d.ts.map +1 -1
  330. package/sdk/dist/deposit/types.js +6 -0
  331. package/sdk/dist/deposit/types.js.map +1 -1
  332. package/sdk/dist/descriptors/accessors.d.ts +38 -35
  333. package/sdk/dist/descriptors/accessors.d.ts.map +1 -1
  334. package/sdk/dist/descriptors/accessors.js +16 -0
  335. package/sdk/dist/descriptors/accessors.js.map +1 -1
  336. package/sdk/dist/descriptors/call.d.ts +66 -14
  337. package/sdk/dist/descriptors/call.d.ts.map +1 -1
  338. package/sdk/dist/descriptors/call.js +94 -13
  339. package/sdk/dist/descriptors/call.js.map +1 -1
  340. package/sdk/dist/descriptors/contracts.generated.d.ts +3393 -0
  341. package/sdk/dist/descriptors/contracts.generated.d.ts.map +1 -0
  342. package/sdk/dist/descriptors/contracts.generated.js +728 -0
  343. package/sdk/dist/descriptors/contracts.generated.js.map +1 -0
  344. package/sdk/dist/descriptors/derive.d.ts +20 -11
  345. package/sdk/dist/descriptors/derive.d.ts.map +1 -1
  346. package/sdk/dist/descriptors/derive.js +68 -30
  347. package/sdk/dist/descriptors/derive.js.map +1 -1
  348. package/sdk/dist/descriptors/index.d.ts +6 -7
  349. package/sdk/dist/descriptors/index.d.ts.map +1 -1
  350. package/sdk/dist/descriptors/index.js +2 -2
  351. package/sdk/dist/descriptors/index.js.map +1 -1
  352. package/sdk/dist/descriptors/links.d.ts +23 -214
  353. package/sdk/dist/descriptors/links.d.ts.map +1 -1
  354. package/sdk/dist/descriptors/links.js +1 -232
  355. package/sdk/dist/descriptors/links.js.map +1 -1
  356. package/sdk/dist/descriptors/query.d.ts +1 -1
  357. package/sdk/dist/descriptors/query.d.ts.map +1 -1
  358. package/sdk/dist/descriptors/query.js +1 -1
  359. package/sdk/dist/descriptors/query.js.map +1 -1
  360. package/sdk/dist/descriptors/registry.d.ts +2 -5
  361. package/sdk/dist/descriptors/registry.d.ts.map +1 -1
  362. package/sdk/dist/descriptors/registry.js +11 -66
  363. package/sdk/dist/descriptors/registry.js.map +1 -1
  364. package/sdk/dist/embedded/resolve.d.ts +4 -4
  365. package/sdk/dist/embedded/resolve.d.ts.map +1 -1
  366. package/sdk/dist/embedded/resolve.js +12 -8
  367. package/sdk/dist/embedded/resolve.js.map +1 -1
  368. package/sdk/dist/embedded/skills.generated.d.ts +1 -1
  369. package/sdk/dist/embedded/skills.generated.d.ts.map +1 -1
  370. package/sdk/dist/embedded/skills.generated.js +137 -136
  371. package/sdk/dist/embedded/skills.generated.js.map +1 -1
  372. package/sdk/dist/embedded/sources.generated.d.ts.map +1 -1
  373. package/sdk/dist/embedded/sources.generated.js +40 -6
  374. package/sdk/dist/embedded/sources.generated.js.map +1 -1
  375. package/sdk/dist/evm/engine.d.ts +813 -10
  376. package/sdk/dist/evm/engine.d.ts.map +1 -1
  377. package/sdk/dist/evm/engine.js +127 -8
  378. package/sdk/dist/evm/engine.js.map +1 -1
  379. package/sdk/dist/index.d.ts +3 -2
  380. package/sdk/dist/index.d.ts.map +1 -1
  381. package/sdk/dist/index.js +6 -2
  382. package/sdk/dist/index.js.map +1 -1
  383. package/sdk/dist/plugin/index.d.ts +3 -2
  384. package/sdk/dist/plugin/index.d.ts.map +1 -1
  385. package/sdk/dist/plugin/index.js.map +1 -1
  386. package/sdk/dist/price.d.ts +40 -0
  387. package/sdk/dist/price.d.ts.map +1 -0
  388. package/sdk/dist/price.js +101 -0
  389. package/sdk/dist/price.js.map +1 -0
  390. package/sdk/dist/protocols/aerodrome/abis.d.ts +76 -0
  391. package/sdk/dist/protocols/aerodrome/abis.d.ts.map +1 -1
  392. package/sdk/dist/protocols/aerodrome/abis.js +61 -0
  393. package/sdk/dist/protocols/aerodrome/abis.js.map +1 -1
  394. package/sdk/dist/protocols/aerodrome-slipstream/abis.d.ts +70 -0
  395. package/sdk/dist/protocols/aerodrome-slipstream/abis.d.ts.map +1 -1
  396. package/sdk/dist/protocols/aerodrome-slipstream/abis.js +54 -0
  397. package/sdk/dist/protocols/aerodrome-slipstream/abis.js.map +1 -1
  398. package/sdk/dist/protocols/camelot/abis.d.ts +178 -0
  399. package/sdk/dist/protocols/camelot/abis.d.ts.map +1 -1
  400. package/sdk/dist/protocols/camelot/abis.js +139 -0
  401. package/sdk/dist/protocols/camelot/abis.js.map +1 -1
  402. package/sdk/dist/protocols/cbeth/functions.d.ts +2 -2
  403. package/sdk/dist/protocols/cbeth/functions.d.ts.map +1 -1
  404. package/sdk/dist/protocols/cbeth/functions.js +4 -6
  405. package/sdk/dist/protocols/cbeth/functions.js.map +1 -1
  406. package/sdk/dist/protocols/crvusd/functions.d.ts +2 -2
  407. package/sdk/dist/protocols/crvusd/functions.d.ts.map +1 -1
  408. package/sdk/dist/protocols/crvusd/functions.js +6 -6
  409. package/sdk/dist/protocols/eco-routes/abis.d.ts +792 -50
  410. package/sdk/dist/protocols/eco-routes/abis.d.ts.map +1 -1
  411. package/sdk/dist/protocols/eco-routes/abis.js +1058 -49
  412. package/sdk/dist/protocols/eco-routes/abis.js.map +1 -1
  413. package/sdk/dist/protocols/eco-routes/addresses.generated.d.ts +44 -61
  414. package/sdk/dist/protocols/eco-routes/addresses.generated.d.ts.map +1 -1
  415. package/sdk/dist/protocols/eco-routes/addresses.generated.js +45 -62
  416. package/sdk/dist/protocols/eco-routes/addresses.generated.js.map +1 -1
  417. package/sdk/dist/protocols/eco-routes/lookup.d.ts +10 -0
  418. package/sdk/dist/protocols/eco-routes/lookup.d.ts.map +1 -1
  419. package/sdk/dist/protocols/eco-routes/lookup.js +16 -0
  420. package/sdk/dist/protocols/eco-routes/lookup.js.map +1 -1
  421. package/sdk/dist/protocols/erc20/functions.d.ts +3 -3
  422. package/sdk/dist/protocols/erc20/functions.d.ts.map +1 -1
  423. package/sdk/dist/protocols/erc20/functions.js +6 -9
  424. package/sdk/dist/protocols/erc20/functions.js.map +1 -1
  425. package/sdk/dist/protocols/frax/functions.d.ts +2 -2
  426. package/sdk/dist/protocols/frax/functions.d.ts.map +1 -1
  427. package/sdk/dist/protocols/frax/functions.js +6 -6
  428. package/sdk/dist/protocols/gho/functions.d.ts +2 -2
  429. package/sdk/dist/protocols/gho/functions.d.ts.map +1 -1
  430. package/sdk/dist/protocols/gho/functions.js +4 -6
  431. package/sdk/dist/protocols/gho/functions.js.map +1 -1
  432. package/sdk/dist/protocols/liquity-v2/functions.d.ts +2 -2
  433. package/sdk/dist/protocols/liquity-v2/functions.d.ts.map +1 -1
  434. package/sdk/dist/protocols/liquity-v2/functions.js +4 -6
  435. package/sdk/dist/protocols/liquity-v2/functions.js.map +1 -1
  436. package/sdk/dist/protocols/maverick/abis.d.ts +77 -0
  437. package/sdk/dist/protocols/maverick/abis.d.ts.map +1 -1
  438. package/sdk/dist/protocols/maverick/abis.js +58 -0
  439. package/sdk/dist/protocols/maverick/abis.js.map +1 -1
  440. package/sdk/dist/protocols/maverick/addresses.d.ts.map +1 -1
  441. package/sdk/dist/protocols/maverick/addresses.js +4 -0
  442. package/sdk/dist/protocols/maverick/addresses.js.map +1 -1
  443. package/sdk/dist/protocols/pancakeswap-v2/abis.d.ts +52 -0
  444. package/sdk/dist/protocols/pancakeswap-v2/abis.d.ts.map +1 -1
  445. package/sdk/dist/protocols/pancakeswap-v2/abis.js +43 -0
  446. package/sdk/dist/protocols/pancakeswap-v2/abis.js.map +1 -1
  447. package/sdk/dist/protocols/pancakeswap-v3/abis.d.ts +73 -0
  448. package/sdk/dist/protocols/pancakeswap-v3/abis.d.ts.map +1 -1
  449. package/sdk/dist/protocols/pancakeswap-v3/abis.js +56 -0
  450. package/sdk/dist/protocols/pancakeswap-v3/abis.js.map +1 -1
  451. package/sdk/dist/protocols/permit2/abis.d.ts +113 -0
  452. package/sdk/dist/protocols/permit2/abis.d.ts.map +1 -1
  453. package/sdk/dist/protocols/permit2/abis.js +63 -0
  454. package/sdk/dist/protocols/permit2/abis.js.map +1 -1
  455. package/sdk/dist/protocols/quickswap/abis.d.ts +148 -0
  456. package/sdk/dist/protocols/quickswap/abis.d.ts.map +1 -1
  457. package/sdk/dist/protocols/quickswap/abis.js +119 -0
  458. package/sdk/dist/protocols/quickswap/abis.js.map +1 -1
  459. package/sdk/dist/protocols/sushiswap-v2/abis.d.ts +52 -0
  460. package/sdk/dist/protocols/sushiswap-v2/abis.d.ts.map +1 -1
  461. package/sdk/dist/protocols/sushiswap-v2/abis.js +42 -0
  462. package/sdk/dist/protocols/sushiswap-v2/abis.js.map +1 -1
  463. package/sdk/dist/protocols/synthra-v3/abis.d.ts +73 -0
  464. package/sdk/dist/protocols/synthra-v3/abis.d.ts.map +1 -1
  465. package/sdk/dist/protocols/synthra-v3/abis.js +55 -0
  466. package/sdk/dist/protocols/synthra-v3/abis.js.map +1 -1
  467. package/sdk/dist/protocols/trader-joe/abis.d.ts +133 -0
  468. package/sdk/dist/protocols/trader-joe/abis.d.ts.map +1 -1
  469. package/sdk/dist/protocols/trader-joe/abis.js +101 -0
  470. package/sdk/dist/protocols/trader-joe/abis.js.map +1 -1
  471. package/sdk/dist/protocols/trader-joe/addresses.d.ts.map +1 -1
  472. package/sdk/dist/protocols/trader-joe/addresses.js +5 -0
  473. package/sdk/dist/protocols/trader-joe/addresses.js.map +1 -1
  474. package/sdk/dist/protocols/uniswap-v2/abis.d.ts +52 -0
  475. package/sdk/dist/protocols/uniswap-v2/abis.d.ts.map +1 -1
  476. package/sdk/dist/protocols/uniswap-v2/abis.js +44 -0
  477. package/sdk/dist/protocols/uniswap-v2/abis.js.map +1 -1
  478. package/sdk/dist/protocols/uniswap-v3/abis.d.ts +73 -0
  479. package/sdk/dist/protocols/uniswap-v3/abis.d.ts.map +1 -1
  480. package/sdk/dist/protocols/uniswap-v3/abis.js +55 -0
  481. package/sdk/dist/protocols/uniswap-v3/abis.js.map +1 -1
  482. package/sdk/dist/protocols/uniswap-v4/abis.d.ts +247 -0
  483. package/sdk/dist/protocols/uniswap-v4/abis.d.ts.map +1 -1
  484. package/sdk/dist/protocols/uniswap-v4/abis.js +167 -0
  485. package/sdk/dist/protocols/uniswap-v4/abis.js.map +1 -1
  486. package/sdk/dist/protocols/uniswap-v4/addresses.d.ts.map +1 -1
  487. package/sdk/dist/protocols/uniswap-v4/addresses.js +50 -0
  488. package/sdk/dist/protocols/uniswap-v4/addresses.js.map +1 -1
  489. package/sdk/dist/protocols/unitflow-v3/abis.d.ts +73 -0
  490. package/sdk/dist/protocols/unitflow-v3/abis.d.ts.map +1 -1
  491. package/sdk/dist/protocols/unitflow-v3/abis.js +56 -0
  492. package/sdk/dist/protocols/unitflow-v3/abis.js.map +1 -1
  493. package/sdk/dist/protocols/velodrome/abis.d.ts +76 -0
  494. package/sdk/dist/protocols/velodrome/abis.d.ts.map +1 -1
  495. package/sdk/dist/protocols/velodrome/abis.js +61 -0
  496. package/sdk/dist/protocols/velodrome/abis.js.map +1 -1
  497. package/sdk/dist/recipes/cctp-split.sauce.ts +5 -3
  498. package/sdk/dist/recipes/plain-transfer.sauce.ts +5 -2
  499. package/sdk/dist/routes/accessor-index.d.ts +2 -2
  500. package/sdk/dist/routes/accessor-index.d.ts.map +1 -1
  501. package/sdk/dist/routes/accessor-index.js +4 -3
  502. package/sdk/dist/routes/accessor-index.js.map +1 -1
  503. package/sdk/dist/routes/ambient.d.ts +5 -0
  504. package/sdk/dist/routes/ambient.d.ts.map +1 -1
  505. package/sdk/dist/routes/ambient.js +20 -0
  506. package/sdk/dist/routes/ambient.js.map +1 -1
  507. package/sdk/dist/routes/ast-walk.d.ts +21 -3
  508. package/sdk/dist/routes/ast-walk.d.ts.map +1 -1
  509. package/sdk/dist/routes/ast-walk.js +33 -4
  510. package/sdk/dist/routes/ast-walk.js.map +1 -1
  511. package/sdk/dist/routes/available.d.ts +43 -0
  512. package/sdk/dist/routes/available.d.ts.map +1 -0
  513. package/sdk/dist/routes/available.js +230 -0
  514. package/sdk/dist/routes/available.js.map +1 -0
  515. package/sdk/dist/routes/builtins.generated.d.ts +180 -0
  516. package/sdk/dist/routes/builtins.generated.d.ts.map +1 -0
  517. package/sdk/dist/routes/builtins.generated.js +2 -0
  518. package/sdk/dist/routes/builtins.generated.js.map +1 -0
  519. package/sdk/dist/routes/chain-exports.generated.d.ts +13 -8
  520. package/sdk/dist/routes/chain-exports.generated.d.ts.map +1 -1
  521. package/sdk/dist/routes/chain-exports.generated.js.map +1 -1
  522. package/sdk/dist/routes/closure.d.ts.map +1 -1
  523. package/sdk/dist/routes/closure.js +13 -26
  524. package/sdk/dist/routes/closure.js.map +1 -1
  525. package/sdk/dist/routes/composed.d.ts.map +1 -1
  526. package/sdk/dist/routes/composed.js +20 -8
  527. package/sdk/dist/routes/composed.js.map +1 -1
  528. package/sdk/dist/routes/encode.d.ts +17 -0
  529. package/sdk/dist/routes/encode.d.ts.map +1 -1
  530. package/sdk/dist/routes/encode.js +14 -11
  531. package/sdk/dist/routes/encode.js.map +1 -1
  532. package/sdk/dist/routes/entry.d.ts +76 -0
  533. package/sdk/dist/routes/entry.d.ts.map +1 -0
  534. package/sdk/dist/routes/entry.js +478 -0
  535. package/sdk/dist/routes/entry.js.map +1 -0
  536. package/sdk/dist/routes/index.d.ts +21 -14
  537. package/sdk/dist/routes/index.d.ts.map +1 -1
  538. package/sdk/dist/routes/index.js +12 -9
  539. package/sdk/dist/routes/index.js.map +1 -1
  540. package/sdk/dist/routes/intent-body.d.ts +97 -0
  541. package/sdk/dist/routes/intent-body.d.ts.map +1 -0
  542. package/sdk/dist/routes/intent-body.js +441 -0
  543. package/sdk/dist/routes/intent-body.js.map +1 -0
  544. package/sdk/dist/routes/intent-dsl.d.ts +21 -6
  545. package/sdk/dist/routes/intent-dsl.d.ts.map +1 -1
  546. package/sdk/dist/routes/intent-dsl.js +34 -17
  547. package/sdk/dist/routes/intent-dsl.js.map +1 -1
  548. package/sdk/dist/routes/intent-sugar.d.ts +77 -4
  549. package/sdk/dist/routes/intent-sugar.d.ts.map +1 -1
  550. package/sdk/dist/routes/intent-sugar.js +358 -152
  551. package/sdk/dist/routes/intent-sugar.js.map +1 -1
  552. package/sdk/dist/routes/intent.d.ts +13 -1
  553. package/sdk/dist/routes/intent.d.ts.map +1 -1
  554. package/sdk/dist/routes/intent.js +37 -1
  555. package/sdk/dist/routes/intent.js.map +1 -1
  556. package/sdk/dist/routes/nest.d.ts +3 -2
  557. package/sdk/dist/routes/nest.d.ts.map +1 -1
  558. package/sdk/dist/routes/nest.js +5 -3
  559. package/sdk/dist/routes/nest.js.map +1 -1
  560. package/sdk/dist/routes/parse.d.ts +6 -0
  561. package/sdk/dist/routes/parse.d.ts.map +1 -0
  562. package/sdk/dist/routes/parse.js +39 -0
  563. package/sdk/dist/routes/parse.js.map +1 -0
  564. package/sdk/dist/routes/portal.d.ts +258 -4
  565. package/sdk/dist/routes/portal.d.ts.map +1 -1
  566. package/sdk/dist/routes/portal.js +588 -9
  567. package/sdk/dist/routes/portal.js.map +1 -1
  568. package/sdk/dist/routes/protocol-rewrite.d.ts +71 -1
  569. package/sdk/dist/routes/protocol-rewrite.d.ts.map +1 -1
  570. package/sdk/dist/routes/protocol-rewrite.js +178 -54
  571. package/sdk/dist/routes/protocol-rewrite.js.map +1 -1
  572. package/sdk/dist/routes/rs-compile.d.ts +25 -22
  573. package/sdk/dist/routes/rs-compile.d.ts.map +1 -1
  574. package/sdk/dist/routes/rs-compile.js +55 -49
  575. package/sdk/dist/routes/rs-compile.js.map +1 -1
  576. package/sdk/dist/routes/sauce-calls.d.ts +26 -12
  577. package/sdk/dist/routes/sauce-calls.d.ts.map +1 -1
  578. package/sdk/dist/routes/sauce-calls.js +16 -23
  579. package/sdk/dist/routes/sauce-calls.js.map +1 -1
  580. package/sdk/dist/routes/sauce-route.d.ts +74 -7
  581. package/sdk/dist/routes/sauce-route.d.ts.map +1 -1
  582. package/sdk/dist/routes/sauce-route.js +249 -96
  583. package/sdk/dist/routes/sauce-route.js.map +1 -1
  584. package/sdk/dist/routes/source-globals.d.ts +107 -0
  585. package/sdk/dist/routes/source-globals.d.ts.map +1 -0
  586. package/sdk/dist/routes/source-globals.generated.d.ts +5530 -936
  587. package/sdk/dist/routes/source-globals.generated.d.ts.map +1 -1
  588. package/sdk/dist/routes/source-globals.generated.js +3 -4
  589. package/sdk/dist/routes/source-globals.generated.js.map +1 -1
  590. package/sdk/dist/routes/source-globals.js +174 -0
  591. package/sdk/dist/routes/source-globals.js.map +1 -0
  592. package/sdk/dist/routes/stock-tokens.d.ts +69 -0
  593. package/sdk/dist/routes/stock-tokens.d.ts.map +1 -0
  594. package/sdk/dist/routes/stock-tokens.generated.d.ts +4 -0
  595. package/sdk/dist/routes/stock-tokens.generated.d.ts.map +1 -0
  596. package/sdk/dist/routes/stock-tokens.generated.js +1836 -0
  597. package/sdk/dist/routes/stock-tokens.generated.js.map +1 -0
  598. package/sdk/dist/routes/stock-tokens.js +65 -0
  599. package/sdk/dist/routes/stock-tokens.js.map +1 -0
  600. package/sdk/dist/routes/token-registry.d.ts +64 -8
  601. package/sdk/dist/routes/token-registry.d.ts.map +1 -1
  602. package/sdk/dist/routes/token-registry.js +208 -33
  603. package/sdk/dist/routes/token-registry.js.map +1 -1
  604. package/sdk/dist/routes/token-rewrite.d.ts +63 -28
  605. package/sdk/dist/routes/token-rewrite.d.ts.map +1 -1
  606. package/sdk/dist/routes/token-rewrite.js +387 -123
  607. package/sdk/dist/routes/token-rewrite.js.map +1 -1
  608. package/sdk/dist/routes/unknown-global.d.ts +32 -0
  609. package/sdk/dist/routes/unknown-global.d.ts.map +1 -0
  610. package/sdk/dist/routes/unknown-global.js +106 -0
  611. package/sdk/dist/routes/unknown-global.js.map +1 -0
  612. package/sdk/dist/routes/vault.d.ts +38 -8
  613. package/sdk/dist/routes/vault.d.ts.map +1 -1
  614. package/sdk/dist/routes/vault.js +47 -8
  615. package/sdk/dist/routes/vault.js.map +1 -1
  616. package/sdk/dist/sauce-script/builtins.d.ts +309 -0
  617. package/sdk/dist/sauce-script/declarations.d.ts +3 -0
  618. package/sdk/dist/sauce-script/declarations.d.ts.map +1 -0
  619. package/sdk/dist/sauce-script/declarations.js +229 -0
  620. package/sdk/dist/sauce-script/declarations.js.map +1 -0
  621. package/sdk/dist/sauce-script/index.d.ts +2714 -0
  622. package/sdk/dist/sauce-script/ts-plugin.cjs +85 -0
  623. package/sdk/dist/skills/loader.d.ts.map +1 -1
  624. package/sdk/dist/skills/loader.js +4 -3
  625. package/sdk/dist/skills/loader.js.map +1 -1
  626. package/sdk/dist/std/router/balancer-v2-vault.abi.json +78 -0
  627. package/sdk/dist/std/router/curve-cryptoswap.abi.json +29 -0
  628. package/sdk/dist/std/router/curve-stableswap.abi.json +29 -0
  629. package/sdk/dist/std/router/dodo-v2-pool.abi.json +39 -0
  630. package/sdk/dist/std/router/lb-pair.abi.json +55 -0
  631. package/sdk/dist/std/router/package.json +7 -0
  632. package/sdk/dist/std/router/router.evm.js +567 -0
  633. package/sdk/dist/std/router/sauce-router.abi.json +202 -0
  634. package/sdk/dist/std/router/uniswap-v2-pair.abi.json +49 -0
  635. package/sdk/dist/std/router/woo-pp-v2.abi.json +42 -0
  636. package/sdk/dist/std/token/permit2.abi.json +226 -0
  637. package/sdk/dist/std/token/token.evm.js +73 -0
  638. package/sdk/dist/std/token/token.svm.js +194 -41
  639. package/sdk/dist/svm/client.d.ts +62 -15
  640. package/sdk/dist/svm/client.d.ts.map +1 -1
  641. package/sdk/dist/svm/client.js +103 -42
  642. package/sdk/dist/svm/client.js.map +1 -1
  643. package/sdk/dist/svm/engine.d.ts +66 -5
  644. package/sdk/dist/svm/engine.d.ts.map +1 -1
  645. package/sdk/dist/svm/engine.js +73 -5
  646. package/sdk/dist/svm/engine.js.map +1 -1
  647. package/sdk/dist/svm/index.d.ts +2 -0
  648. package/sdk/dist/svm/index.d.ts.map +1 -1
  649. package/sdk/dist/svm/index.js +2 -0
  650. package/sdk/dist/svm/index.js.map +1 -1
  651. package/sdk/dist/svm/instructions.d.ts +72 -1
  652. package/sdk/dist/svm/instructions.d.ts.map +1 -1
  653. package/sdk/dist/svm/instructions.js +81 -2
  654. package/sdk/dist/svm/instructions.js.map +1 -1
  655. package/sdk/dist/svm/kitchen.d.ts +20 -1
  656. package/sdk/dist/svm/kitchen.d.ts.map +1 -1
  657. package/sdk/dist/svm/kitchen.js +47 -1
  658. package/sdk/dist/svm/kitchen.js.map +1 -1
  659. package/sdk/dist/svm/portal.d.ts +250 -0
  660. package/sdk/dist/svm/portal.d.ts.map +1 -0
  661. package/sdk/dist/svm/portal.js +462 -0
  662. package/sdk/dist/svm/portal.js.map +1 -0
  663. package/sdk/dist/svm/send.d.ts +18 -2
  664. package/sdk/dist/svm/send.d.ts.map +1 -1
  665. package/sdk/dist/svm/send.js +28 -3
  666. package/sdk/dist/svm/send.js.map +1 -1
  667. package/sdk/dist/svm/token-accounts.d.ts +49 -0
  668. package/sdk/dist/svm/token-accounts.d.ts.map +1 -0
  669. package/sdk/dist/svm/token-accounts.js +58 -0
  670. package/sdk/dist/svm/token-accounts.js.map +1 -0
  671. package/sdk/dist/svm/token-extensions.d.ts +18 -7
  672. package/sdk/dist/svm/token-extensions.d.ts.map +1 -1
  673. package/sdk/dist/svm/token-extensions.js +58 -5
  674. package/sdk/dist/svm/token-extensions.js.map +1 -1
  675. package/sdk/dist/token/api.d.ts +7 -4
  676. package/sdk/dist/token/api.d.ts.map +1 -1
  677. package/sdk/dist/token/api.js.map +1 -1
  678. package/sdk/dist/token/evm.js +2 -2
  679. package/sdk/dist/token/index.d.ts +4 -4
  680. package/sdk/dist/token/index.js +4 -4
  681. package/sdk/dist/token/params.js +1 -1
  682. package/sdk/dist/token/source.js +3 -3
  683. package/sdk/dist/token/source.js.map +1 -1
  684. package/sdk/dist/token/types.d.ts +2 -2
  685. package/sdk/dist/token/types.js +2 -2
  686. package/sdk/src/protocols/aerodrome/AerodromePoolABI.json +105 -0
  687. package/sdk/src/protocols/aerodrome/abis.ts +62 -0
  688. package/sdk/src/protocols/aerodrome-slipstream/AerodromeSlipstreamPoolABI.json +96 -0
  689. package/sdk/src/protocols/aerodrome-slipstream/abis.ts +55 -0
  690. package/sdk/src/protocols/camelot/CamelotV2FactoryABI.json +25 -0
  691. package/sdk/src/protocols/camelot/CamelotV2PairABI.json +109 -0
  692. package/sdk/src/protocols/camelot/CamelotV3FactoryABI.json +25 -0
  693. package/sdk/src/protocols/camelot/CamelotV3PoolABI.json +92 -0
  694. package/sdk/src/protocols/camelot/abis.ts +143 -0
  695. package/sdk/src/protocols/cbeth/functions.ts +4 -6
  696. package/sdk/src/protocols/crvusd/functions.ts +6 -6
  697. package/sdk/src/protocols/eco-routes/PortalABI.json +1448 -0
  698. package/sdk/src/protocols/eco-routes/ProverABI.json +162 -0
  699. package/sdk/src/protocols/eco-routes/abis.ts +1060 -51
  700. package/sdk/src/protocols/eco-routes/addresses.generated.ts +45 -62
  701. package/sdk/src/protocols/eco-routes/lookup.ts +18 -0
  702. package/sdk/src/protocols/erc20/functions.ts +6 -9
  703. package/sdk/src/protocols/frax/functions.ts +6 -6
  704. package/sdk/src/protocols/gho/functions.ts +4 -6
  705. package/sdk/src/protocols/liquity-v2/functions.ts +4 -6
  706. package/sdk/src/protocols/maverick/MaverickV2PoolABI.json +107 -0
  707. package/sdk/src/protocols/maverick/abis.ts +59 -0
  708. package/sdk/src/protocols/maverick/addresses.ts +4 -0
  709. package/sdk/src/protocols/pancakeswap-v2/PancakeSwapV2PairABI.json +72 -0
  710. package/sdk/src/protocols/pancakeswap-v2/abis.ts +44 -0
  711. package/sdk/src/protocols/pancakeswap-v3/PancakeSwapV3PoolABI.json +100 -0
  712. package/sdk/src/protocols/pancakeswap-v3/abis.ts +57 -0
  713. package/sdk/src/protocols/permit2/Permit2ABI.json +154 -0
  714. package/sdk/src/protocols/permit2/abis.ts +63 -0
  715. package/sdk/src/protocols/quickswap/QuickSwapV2FactoryABI.json +25 -0
  716. package/sdk/src/protocols/quickswap/QuickSwapV2PairABI.json +72 -0
  717. package/sdk/src/protocols/quickswap/QuickSwapV3FactoryABI.json +25 -0
  718. package/sdk/src/protocols/quickswap/QuickSwapV3PoolABI.json +88 -0
  719. package/sdk/src/protocols/quickswap/abis.ts +123 -0
  720. package/sdk/src/protocols/sushiswap-v2/SushiSwapV2PairABI.json +72 -0
  721. package/sdk/src/protocols/sushiswap-v2/abis.ts +43 -0
  722. package/sdk/src/protocols/synthra-v3/SynthraV3PoolABI.json +100 -0
  723. package/sdk/src/protocols/synthra-v3/abis.ts +56 -0
  724. package/sdk/src/protocols/trader-joe/LBPairABI.json +185 -0
  725. package/sdk/src/protocols/trader-joe/abis.ts +102 -0
  726. package/sdk/src/protocols/trader-joe/addresses.ts +5 -0
  727. package/sdk/src/protocols/uniswap-v2/UniswapV2PairABI.json +72 -0
  728. package/sdk/src/protocols/uniswap-v2/abis.ts +45 -0
  729. package/sdk/src/protocols/uniswap-v3/UniswapV3PoolABI.json +100 -0
  730. package/sdk/src/protocols/uniswap-v3/abis.ts +56 -0
  731. package/sdk/src/protocols/uniswap-v4/UniswapV4PoolManagerABI.json +38 -0
  732. package/sdk/src/protocols/uniswap-v4/UniswapV4StateViewABI.json +307 -0
  733. package/sdk/src/protocols/uniswap-v4/abis.ts +168 -0
  734. package/sdk/src/protocols/uniswap-v4/addresses.ts +50 -0
  735. package/sdk/src/protocols/unitflow-v3/UnitFlowV3PoolABI.json +100 -0
  736. package/sdk/src/protocols/unitflow-v3/abis.ts +57 -0
  737. package/sdk/src/protocols/velodrome/VelodromePoolABI.json +105 -0
  738. package/sdk/src/protocols/velodrome/abis.ts +62 -0
  739. package/skills/sauce-actions/SKILL.md +166 -0
  740. package/skills/sauce-actions/examples/swap-and-supply.json +24 -0
  741. package/skills/sauce-actions/examples/swap-by-key.json +15 -0
  742. package/skills/sauce-actions/references/actions.md +731 -0
  743. package/skills/sauce-chains/SKILL.md +137 -0
  744. package/skills/sauce-chains/examples/chains.sauce.ts +25 -0
  745. package/skills/sauce-chains/references/arbitrum.md +158 -0
  746. package/skills/sauce-chains/references/arc.md +107 -0
  747. package/skills/sauce-chains/references/aurora.md +33 -0
  748. package/skills/sauce-chains/references/avalanche.md +106 -0
  749. package/skills/sauce-chains/references/base-stocks.md +77 -0
  750. package/skills/sauce-chains/references/base.md +141 -0
  751. package/skills/sauce-chains/references/berachain.md +33 -0
  752. package/skills/sauce-chains/references/blast.md +60 -0
  753. package/skills/sauce-chains/references/boba.md +33 -0
  754. package/skills/sauce-chains/references/bsc.md +97 -0
  755. package/skills/sauce-chains/references/celo.md +57 -0
  756. package/skills/sauce-chains/references/core.md +33 -0
  757. package/skills/sauce-chains/references/cronos.md +33 -0
  758. package/skills/sauce-chains/references/ethereum-stocks.md +1741 -0
  759. package/skills/sauce-chains/references/ethereum.md +255 -0
  760. package/skills/sauce-chains/references/evmos.md +33 -0
  761. package/skills/sauce-chains/references/fantom.md +61 -0
  762. package/skills/sauce-chains/references/fuse.md +33 -0
  763. package/skills/sauce-chains/references/gnosis.md +57 -0
  764. package/skills/sauce-chains/references/index.md +58 -0
  765. package/skills/sauce-chains/references/ink.md +55 -0
  766. package/skills/sauce-chains/references/kava.md +33 -0
  767. package/skills/sauce-chains/references/klaytn.md +33 -0
  768. package/skills/sauce-chains/references/linea.md +65 -0
  769. package/skills/sauce-chains/references/manta.md +33 -0
  770. package/skills/sauce-chains/references/mantle.md +33 -0
  771. package/skills/sauce-chains/references/metis.md +54 -0
  772. package/skills/sauce-chains/references/mode.md +55 -0
  773. package/skills/sauce-chains/references/monad.md +79 -0
  774. package/skills/sauce-chains/references/moonbeam.md +33 -0
  775. package/skills/sauce-chains/references/opbnb.md +55 -0
  776. package/skills/sauce-chains/references/optimism.md +123 -0
  777. package/skills/sauce-chains/references/plasma.md +35 -0
  778. package/skills/sauce-chains/references/polygon.md +123 -0
  779. package/skills/sauce-chains/references/pulsechain.md +33 -0
  780. package/skills/sauce-chains/references/ronin.md +35 -0
  781. package/skills/sauce-chains/references/scroll.md +62 -0
  782. package/skills/sauce-chains/references/sei.md +55 -0
  783. package/skills/sauce-chains/references/solana.md +53 -0
  784. package/skills/sauce-chains/references/sonic.md +57 -0
  785. package/skills/sauce-chains/references/unichain.md +61 -0
  786. package/skills/sauce-chains/references/zetachain.md +33 -0
  787. package/skills/sauce-chains/references/zksync.md +59 -0
  788. package/skills/sauce-chains/references/zora.md +57 -0
  789. package/skills/sauce-cli/SKILL.md +366 -0
  790. package/skills/sauce-cli/examples/pay.sauce.ts +23 -0
  791. package/skills/sauce-cli/examples/split.sauce.ts +30 -0
  792. package/skills/sauce-distributed-swap/SKILL.md +392 -0
  793. package/skills/sauce-distributed-swap/examples/distributed-swap.mts +251 -0
  794. package/skills/sauce-distributed-swap/examples/distributed-swap.sauce.ts +115 -0
  795. package/skills/sauce-examples/SKILL.md +96 -0
  796. package/skills/sauce-globals/SKILL.md +175 -0
  797. package/skills/sauce-globals/examples/globals.mts +111 -0
  798. package/skills/sauce-globals/examples/globals.sauce.ts +47 -0
  799. package/skills/sauce-globals/references/chains.md +53 -0
  800. package/skills/sauce-globals/references/protocols.md +405 -0
  801. package/skills/sauce-globals/references/stocks.md +1824 -0
  802. package/skills/sauce-globals/references/tokens.md +53 -0
  803. package/skills/sauce-intents/SKILL.md +505 -0
  804. package/skills/sauce-intents/examples/cross-chain.sauce.ts +37 -0
  805. package/skills/sauce-intents/examples/fund-by-transfer.sauce.ts +54 -0
  806. package/skills/sauce-intents/examples/intents.mts +343 -0
  807. package/skills/sauce-intents/examples/swap-on-base.sauce.ts +135 -0
  808. package/skills/sauce-intents/references/portal.md +77 -0
  809. package/skills/sauce-overview/SKILL.md +161 -0
  810. package/skills/sauce-protocols/SKILL.md +118 -0
  811. package/skills/sauce-protocols/examples/protocols.mts +77 -0
  812. package/skills/sauce-protocols/examples/protocols.sauce.ts +27 -0
  813. package/{sdk/src/skills → skills/sauce-protocols/references}/aave-v2.md +35 -17
  814. package/skills/sauce-protocols/references/aave-v3.md +144 -0
  815. package/skills/sauce-protocols/references/aave-v4.md +50 -0
  816. package/skills/sauce-protocols/references/abracadabra.md +72 -0
  817. package/skills/sauce-protocols/references/across.md +73 -0
  818. package/skills/sauce-protocols/references/aerodrome-slipstream.md +50 -0
  819. package/{sdk/src/skills → skills/sauce-protocols/references}/aerodrome.md +43 -24
  820. package/skills/sauce-protocols/references/aevo.md +49 -0
  821. package/{sdk/src/skills → skills/sauce-protocols/references}/alchemix.md +10 -25
  822. package/{sdk/src/skills → skills/sauce-protocols/references}/ambient.md +14 -21
  823. package/{sdk/src/skills → skills/sauce-protocols/references}/arbitrum-bridge.md +11 -14
  824. package/{sdk/src/skills → skills/sauce-protocols/references}/arrakis.md +10 -26
  825. package/skills/sauce-protocols/references/axelar.md +56 -0
  826. package/{sdk/src/skills → skills/sauce-protocols/references}/balancer-v2.md +13 -29
  827. package/{sdk/src/skills → skills/sauce-protocols/references}/base-bridge.md +11 -16
  828. package/{sdk/src/skills → skills/sauce-protocols/references}/baseswap.md +12 -19
  829. package/{sdk/src/skills → skills/sauce-protocols/references}/beefy.md +10 -30
  830. package/{sdk/src/skills → skills/sauce-protocols/references}/benqi.md +11 -21
  831. package/{sdk/src/skills → skills/sauce-protocols/references}/camelot.md +13 -27
  832. package/skills/sauce-protocols/references/cbeth.md +48 -0
  833. package/skills/sauce-protocols/references/cctp.md +47 -0
  834. package/{sdk/src/skills → skills/sauce-protocols/references}/celer.md +11 -18
  835. package/{sdk/src/skills → skills/sauce-protocols/references}/chainlink-ccip.md +11 -21
  836. package/skills/sauce-protocols/references/chainlink.md +47 -0
  837. package/{sdk/src/skills → skills/sauce-protocols/references}/circle-gateway.md +12 -38
  838. package/{sdk/src/skills → skills/sauce-protocols/references}/compound-v2.md +11 -25
  839. package/{sdk/src/skills → skills/sauce-protocols/references}/compound-v3.md +43 -27
  840. package/{sdk/src/skills → skills/sauce-protocols/references}/connext.md +11 -15
  841. package/{sdk/src/skills → skills/sauce-protocols/references}/convex.md +10 -28
  842. package/{sdk/src/skills → skills/sauce-protocols/references}/cowswap.md +12 -19
  843. package/skills/sauce-protocols/references/crvusd.md +49 -0
  844. package/skills/sauce-protocols/references/curve.md +98 -0
  845. package/{sdk/src/skills → skills/sauce-protocols/references}/debridge.md +11 -33
  846. package/{sdk/src/skills → skills/sauce-protocols/references}/dodo.md +13 -18
  847. package/skills/sauce-protocols/references/eigenlayer.md +48 -0
  848. package/{sdk/src/skills → skills/sauce-protocols/references}/ens.md +10 -26
  849. package/{sdk/src/skills → skills/sauce-protocols/references}/erc20.md +18 -34
  850. package/{sdk/src/skills → skills/sauce-protocols/references}/erc3156.md +10 -13
  851. package/{sdk/src/skills → skills/sauce-protocols/references}/erc4626.md +11 -27
  852. package/{sdk/src/skills → skills/sauce-protocols/references}/ethena.md +10 -27
  853. package/{sdk/src/skills → skills/sauce-protocols/references}/etherfi.md +10 -32
  854. package/{sdk/src/skills → skills/sauce-protocols/references}/euler-v2.md +11 -21
  855. package/{sdk/src/skills → skills/sauce-protocols/references}/fenix.md +12 -18
  856. package/{sdk/src/skills → skills/sauce-protocols/references}/fluid.md +11 -20
  857. package/{sdk/src/skills → skills/sauce-protocols/references}/frax-ether.md +10 -26
  858. package/skills/sauce-protocols/references/frax.md +48 -0
  859. package/{sdk/src/skills → skills/sauce-protocols/references}/gains-network.md +11 -28
  860. package/skills/sauce-protocols/references/gamma.md +57 -0
  861. package/{sdk/src/skills → skills/sauce-protocols/references}/gelato.md +12 -20
  862. package/skills/sauce-protocols/references/gho.md +50 -0
  863. package/{sdk/src/skills → skills/sauce-protocols/references}/gmx-v1.md +12 -34
  864. package/{sdk/src/skills → skills/sauce-protocols/references}/gmx-v2.md +15 -28
  865. package/skills/sauce-protocols/references/harvest.md +41 -0
  866. package/{sdk/src/skills → skills/sauce-protocols/references}/hegic.md +10 -18
  867. package/{sdk/src/skills → skills/sauce-protocols/references}/hop.md +11 -21
  868. package/{sdk/src/skills → skills/sauce-protocols/references}/hyperlane.md +11 -21
  869. package/skills/sauce-protocols/references/index.md +355 -0
  870. package/{sdk/src/skills → skills/sauce-protocols/references}/instadapp.md +10 -18
  871. package/skills/sauce-protocols/references/kelp.md +46 -0
  872. package/{sdk/src/skills → skills/sauce-protocols/references}/kim.md +12 -18
  873. package/{sdk/src/skills → skills/sauce-protocols/references}/kyberswap-aggregator.md +12 -35
  874. package/skills/sauce-protocols/references/kyberswap.md +72 -0
  875. package/{sdk/src/skills → skills/sauce-protocols/references}/layerbank.md +11 -26
  876. package/{sdk/src/skills → skills/sauce-protocols/references}/layerzero.md +11 -25
  877. package/{sdk/src/skills → skills/sauce-protocols/references}/level-finance.md +10 -24
  878. package/{sdk/src/skills → skills/sauce-protocols/references}/lido.md +10 -28
  879. package/{sdk/src/skills → skills/sauce-protocols/references}/lifi.md +11 -25
  880. package/{sdk/src/skills → skills/sauce-protocols/references}/linea-bridge.md +11 -14
  881. package/{sdk/src/skills → skills/sauce-protocols/references}/liquity-v1.md +10 -21
  882. package/skills/sauce-protocols/references/liquity-v2.md +48 -0
  883. package/{sdk/src/skills → skills/sauce-protocols/references}/lynex.md +12 -18
  884. package/skills/sauce-protocols/references/maker.md +57 -0
  885. package/skills/sauce-protocols/references/mantle-meth.md +43 -0
  886. package/{sdk/src/skills → skills/sauce-protocols/references}/maverick.md +13 -25
  887. package/{sdk/src/skills → skills/sauce-protocols/references}/moonwell.md +11 -21
  888. package/{sdk/src/skills → skills/sauce-protocols/references}/morpho-blue.md +44 -21
  889. package/{sdk/src/skills → skills/sauce-protocols/references}/mux-protocol.md +10 -30
  890. package/skills/sauce-protocols/references/olympus.md +39 -0
  891. package/skills/sauce-protocols/references/oneinch.md +81 -0
  892. package/skills/sauce-protocols/references/openocean.md +69 -0
  893. package/{sdk/src/skills → skills/sauce-protocols/references}/optimism-bridge.md +11 -16
  894. package/{sdk/src/skills → skills/sauce-protocols/references}/opyn.md +10 -21
  895. package/{sdk/src/skills → skills/sauce-protocols/references}/pancakeswap-v2.md +39 -41
  896. package/skills/sauce-protocols/references/pancakeswap-v3.md +72 -0
  897. package/skills/sauce-protocols/references/paraswap.md +39 -0
  898. package/{sdk/src/skills → skills/sauce-protocols/references}/pendle.md +47 -29
  899. package/skills/sauce-protocols/references/permit2.md +101 -0
  900. package/skills/sauce-protocols/references/perpetual-protocol.md +53 -0
  901. package/{sdk/src/skills → skills/sauce-protocols/references}/polygon-bridge.md +11 -17
  902. package/{sdk/src/skills → skills/sauce-protocols/references}/premia.md +10 -19
  903. package/{sdk/src/skills → skills/sauce-protocols/references}/puffer.md +10 -21
  904. package/skills/sauce-protocols/references/pyth.md +45 -0
  905. package/{sdk/src/skills → skills/sauce-protocols/references}/quickswap.md +13 -27
  906. package/{sdk/src/skills → skills/sauce-protocols/references}/radiant.md +11 -15
  907. package/{sdk/src/skills → skills/sauce-protocols/references}/ramses.md +12 -18
  908. package/skills/sauce-protocols/references/reflexer.md +52 -0
  909. package/skills/sauce-protocols/references/registry/aave-v2.md +43 -0
  910. package/skills/sauce-protocols/references/registry/aave-v3.md +62 -0
  911. package/skills/sauce-protocols/references/registry/aave-v4.md +80 -0
  912. package/skills/sauce-protocols/references/registry/abracadabra.md +54 -0
  913. package/skills/sauce-protocols/references/registry/across.md +57 -0
  914. package/skills/sauce-protocols/references/registry/aerodrome-slipstream.md +72 -0
  915. package/skills/sauce-protocols/references/registry/aerodrome.md +58 -0
  916. package/skills/sauce-protocols/references/registry/aevo.md +39 -0
  917. package/skills/sauce-protocols/references/registry/alchemix.md +46 -0
  918. package/skills/sauce-protocols/references/registry/ambient.md +40 -0
  919. package/skills/sauce-protocols/references/registry/arbitrum-bridge.md +40 -0
  920. package/skills/sauce-protocols/references/registry/arrakis.md +49 -0
  921. package/skills/sauce-protocols/references/registry/axelar.md +65 -0
  922. package/skills/sauce-protocols/references/registry/balancer-v2.md +50 -0
  923. package/skills/sauce-protocols/references/registry/base-bridge.md +42 -0
  924. package/skills/sauce-protocols/references/registry/baseswap.md +40 -0
  925. package/skills/sauce-protocols/references/registry/beefy.md +51 -0
  926. package/skills/sauce-protocols/references/registry/benqi.md +49 -0
  927. package/skills/sauce-protocols/references/registry/camelot.md +82 -0
  928. package/skills/sauce-protocols/references/registry/cbeth.md +43 -0
  929. package/skills/sauce-protocols/references/registry/cctp.md +48 -0
  930. package/skills/sauce-protocols/references/registry/celer.md +44 -0
  931. package/skills/sauce-protocols/references/registry/chainlink-ccip.md +45 -0
  932. package/skills/sauce-protocols/references/registry/chainlink.md +49 -0
  933. package/skills/sauce-protocols/references/registry/circle-gateway.md +70 -0
  934. package/skills/sauce-protocols/references/registry/compound-v2.md +53 -0
  935. package/skills/sauce-protocols/references/registry/compound-v3.md +52 -0
  936. package/skills/sauce-protocols/references/registry/connext.md +41 -0
  937. package/skills/sauce-protocols/references/registry/convex.md +51 -0
  938. package/skills/sauce-protocols/references/registry/cowswap.md +40 -0
  939. package/skills/sauce-protocols/references/registry/crvusd.md +40 -0
  940. package/skills/sauce-protocols/references/registry/curve.md +81 -0
  941. package/skills/sauce-protocols/references/registry/debridge.md +59 -0
  942. package/skills/sauce-protocols/references/registry/dodo.md +39 -0
  943. package/skills/sauce-protocols/references/registry/eco-routes.md +65 -0
  944. package/skills/sauce-protocols/references/registry/eigenlayer.md +58 -0
  945. package/skills/sauce-protocols/references/registry/ens.md +49 -0
  946. package/skills/sauce-protocols/references/registry/erc20.md +44 -0
  947. package/skills/sauce-protocols/references/registry/erc3156.md +38 -0
  948. package/skills/sauce-protocols/references/registry/erc4626.md +51 -0
  949. package/skills/sauce-protocols/references/registry/ethena.md +50 -0
  950. package/skills/sauce-protocols/references/registry/etherfi.md +57 -0
  951. package/skills/sauce-protocols/references/registry/euler-v2.md +49 -0
  952. package/skills/sauce-protocols/references/registry/fenix.md +39 -0
  953. package/skills/sauce-protocols/references/registry/fluid.md +48 -0
  954. package/skills/sauce-protocols/references/registry/frax-ether.md +49 -0
  955. package/skills/sauce-protocols/references/registry/frax.md +40 -0
  956. package/skills/sauce-protocols/references/registry/gains-network.md +43 -0
  957. package/skills/sauce-protocols/references/registry/gamma.md +56 -0
  958. package/skills/sauce-protocols/references/registry/gelato.md +45 -0
  959. package/skills/sauce-protocols/references/registry/gho.md +40 -0
  960. package/skills/sauce-protocols/references/registry/gmx-v1.md +59 -0
  961. package/skills/sauce-protocols/references/registry/gmx-v2.md +41 -0
  962. package/skills/sauce-protocols/references/registry/harvest.md +44 -0
  963. package/skills/sauce-protocols/references/registry/hegic.md +39 -0
  964. package/skills/sauce-protocols/references/registry/hop.md +49 -0
  965. package/skills/sauce-protocols/references/registry/hyperlane.md +48 -0
  966. package/skills/sauce-protocols/references/registry/instadapp.md +39 -0
  967. package/skills/sauce-protocols/references/registry/kelp.md +47 -0
  968. package/skills/sauce-protocols/references/registry/kim.md +39 -0
  969. package/skills/sauce-protocols/references/registry/kyberswap-aggregator.md +49 -0
  970. package/skills/sauce-protocols/references/registry/kyberswap.md +63 -0
  971. package/skills/sauce-protocols/references/registry/layerbank.md +54 -0
  972. package/skills/sauce-protocols/references/registry/layerzero.md +49 -0
  973. package/skills/sauce-protocols/references/registry/level-finance.md +41 -0
  974. package/skills/sauce-protocols/references/registry/lido.md +51 -0
  975. package/skills/sauce-protocols/references/registry/lifi.md +48 -0
  976. package/skills/sauce-protocols/references/registry/linea-bridge.md +40 -0
  977. package/skills/sauce-protocols/references/registry/liquity-v1.md +42 -0
  978. package/skills/sauce-protocols/references/registry/liquity-v2.md +40 -0
  979. package/skills/sauce-protocols/references/registry/lynex.md +39 -0
  980. package/skills/sauce-protocols/references/registry/maker.md +55 -0
  981. package/skills/sauce-protocols/references/registry/mantle-meth.md +48 -0
  982. package/skills/sauce-protocols/references/registry/maverick.md +60 -0
  983. package/skills/sauce-protocols/references/registry/moonwell.md +49 -0
  984. package/skills/sauce-protocols/references/registry/morpho-blue.md +47 -0
  985. package/skills/sauce-protocols/references/registry/mux-protocol.md +49 -0
  986. package/skills/sauce-protocols/references/registry/olympus.md +42 -0
  987. package/skills/sauce-protocols/references/registry/oneinch.md +45 -0
  988. package/skills/sauce-protocols/references/registry/openocean.md +44 -0
  989. package/skills/sauce-protocols/references/registry/optimism-bridge.md +42 -0
  990. package/skills/sauce-protocols/references/registry/opyn.md +42 -0
  991. package/skills/sauce-protocols/references/registry/pancakeswap-v2.md +71 -0
  992. package/skills/sauce-protocols/references/registry/pancakeswap-v3.md +76 -0
  993. package/skills/sauce-protocols/references/registry/paraswap.md +51 -0
  994. package/skills/sauce-protocols/references/registry/pendle.md +43 -0
  995. package/skills/sauce-protocols/references/registry/permit2.md +50 -0
  996. package/skills/sauce-protocols/references/registry/perpetual-protocol.md +49 -0
  997. package/skills/sauce-protocols/references/registry/polygon-bridge.md +43 -0
  998. package/skills/sauce-protocols/references/registry/premia.md +40 -0
  999. package/skills/sauce-protocols/references/registry/puffer.md +43 -0
  1000. package/skills/sauce-protocols/references/registry/pyth.md +40 -0
  1001. package/skills/sauce-protocols/references/registry/quickswap.md +80 -0
  1002. package/skills/sauce-protocols/references/registry/radiant.md +41 -0
  1003. package/skills/sauce-protocols/references/registry/ramses.md +39 -0
  1004. package/skills/sauce-protocols/references/registry/reflexer.md +56 -0
  1005. package/skills/sauce-protocols/references/registry/renzo.md +47 -0
  1006. package/skills/sauce-protocols/references/registry/rocket-pool.md +49 -0
  1007. package/skills/sauce-protocols/references/registry/sablier.md +40 -0
  1008. package/skills/sauce-protocols/references/registry/safe.md +47 -0
  1009. package/skills/sauce-protocols/references/registry/scroll-bridge.md +48 -0
  1010. package/skills/sauce-protocols/references/registry/seamless.md +42 -0
  1011. package/skills/sauce-protocols/references/registry/seaport.md +44 -0
  1012. package/skills/sauce-protocols/references/registry/silo.md +48 -0
  1013. package/skills/sauce-protocols/references/registry/socket.md +44 -0
  1014. package/skills/sauce-protocols/references/registry/sommelier.md +43 -0
  1015. package/skills/sauce-protocols/references/registry/spark.md +42 -0
  1016. package/skills/sauce-protocols/references/registry/spookyswap.md +40 -0
  1017. package/skills/sauce-protocols/references/registry/squid.md +45 -0
  1018. package/skills/sauce-protocols/references/registry/stader.md +47 -0
  1019. package/skills/sauce-protocols/references/registry/stargate.md +45 -0
  1020. package/skills/sauce-protocols/references/registry/superfluid.md +49 -0
  1021. package/skills/sauce-protocols/references/registry/sushiswap-v2.md +71 -0
  1022. package/skills/sauce-protocols/references/registry/swell.md +49 -0
  1023. package/skills/sauce-protocols/references/registry/synapse.md +46 -0
  1024. package/skills/sauce-protocols/references/registry/syncswap.md +38 -0
  1025. package/skills/sauce-protocols/references/registry/synthetix-v3.md +48 -0
  1026. package/skills/sauce-protocols/references/registry/synthra-v3.md +77 -0
  1027. package/skills/sauce-protocols/references/registry/thales.md +51 -0
  1028. package/skills/sauce-protocols/references/registry/thena.md +39 -0
  1029. package/skills/sauce-protocols/references/registry/thruster.md +38 -0
  1030. package/skills/sauce-protocols/references/registry/tokemak.md +45 -0
  1031. package/skills/sauce-protocols/references/registry/trader-joe.md +66 -0
  1032. package/skills/sauce-protocols/references/registry/uniswap-v2.md +77 -0
  1033. package/skills/sauce-protocols/references/registry/uniswap-v3.md +113 -0
  1034. package/skills/sauce-protocols/references/registry/uniswap-v4.md +117 -0
  1035. package/skills/sauce-protocols/references/registry/unitflow-v3.md +65 -0
  1036. package/skills/sauce-protocols/references/registry/velodrome.md +58 -0
  1037. package/skills/sauce-protocols/references/registry/venus.md +62 -0
  1038. package/skills/sauce-protocols/references/registry/vertex.md +46 -0
  1039. package/skills/sauce-protocols/references/registry/wormhole.md +59 -0
  1040. package/skills/sauce-protocols/references/registry/yearn-v3.md +46 -0
  1041. package/skills/sauce-protocols/references/registry/zerolend.md +41 -0
  1042. package/skills/sauce-protocols/references/registry/zerox.md +44 -0
  1043. package/skills/sauce-protocols/references/registry/zksync-bridge.md +40 -0
  1044. package/{sdk/src/skills → skills/sauce-protocols/references}/renzo.md +10 -24
  1045. package/{sdk/src/skills → skills/sauce-protocols/references}/rocket-pool.md +10 -26
  1046. package/{sdk/src/skills → skills/sauce-protocols/references}/sablier.md +10 -27
  1047. package/skills/sauce-protocols/references/safe.md +42 -0
  1048. package/{sdk/src/skills → skills/sauce-protocols/references}/scroll-bridge.md +11 -20
  1049. package/{sdk/src/skills → skills/sauce-protocols/references}/seamless.md +11 -16
  1050. package/skills/sauce-protocols/references/seaport.md +38 -0
  1051. package/{sdk/src/skills → skills/sauce-protocols/references}/silo.md +11 -20
  1052. package/{sdk/src/skills → skills/sauce-protocols/references}/socket.md +11 -18
  1053. package/skills/sauce-protocols/references/sommelier.md +40 -0
  1054. package/{sdk/src/skills → skills/sauce-protocols/references}/spark.md +11 -16
  1055. package/{sdk/src/skills → skills/sauce-protocols/references}/spookyswap.md +12 -19
  1056. package/{sdk/src/skills → skills/sauce-protocols/references}/squid.md +11 -21
  1057. package/skills/sauce-protocols/references/stader.md +39 -0
  1058. package/{sdk/src/skills → skills/sauce-protocols/references}/stargate.md +11 -22
  1059. package/{sdk/src/skills → skills/sauce-protocols/references}/superfluid.md +10 -28
  1060. package/{sdk/src/skills → skills/sauce-protocols/references}/sushiswap-v2.md +38 -43
  1061. package/skills/sauce-protocols/references/swell.md +49 -0
  1062. package/skills/sauce-protocols/references/synapse.md +54 -0
  1063. package/{sdk/src/skills → skills/sauce-protocols/references}/syncswap.md +12 -17
  1064. package/{sdk/src/skills → skills/sauce-protocols/references}/synthetix-v3.md +10 -29
  1065. package/skills/sauce-protocols/references/synthra-v3.md +63 -0
  1066. package/skills/sauce-protocols/references/thales.md +58 -0
  1067. package/{sdk/src/skills → skills/sauce-protocols/references}/thena.md +12 -18
  1068. package/{sdk/src/skills → skills/sauce-protocols/references}/thruster.md +13 -18
  1069. package/skills/sauce-protocols/references/tokemak.md +40 -0
  1070. package/{sdk/src/skills → skills/sauce-protocols/references}/trader-joe.md +13 -26
  1071. package/{sdk/src/skills → skills/sauce-protocols/references}/uniswap-v2.md +46 -44
  1072. package/skills/sauce-protocols/references/uniswap-v3.md +188 -0
  1073. package/skills/sauce-protocols/references/uniswap-v4.md +155 -0
  1074. package/skills/sauce-protocols/references/unitflow-v3.md +63 -0
  1075. package/{sdk/src/skills → skills/sauce-protocols/references}/velodrome.md +12 -24
  1076. package/{sdk/src/skills → skills/sauce-protocols/references}/venus.md +12 -31
  1077. package/skills/sauce-protocols/references/vertex.md +42 -0
  1078. package/skills/sauce-protocols/references/wormhole.md +57 -0
  1079. package/{sdk/src/skills → skills/sauce-protocols/references}/yearn-v3.md +10 -25
  1080. package/{sdk/src/skills → skills/sauce-protocols/references}/zerolend.md +11 -15
  1081. package/skills/sauce-protocols/references/zerox.md +39 -0
  1082. package/{sdk/src/skills → skills/sauce-protocols/references}/zksync-bridge.md +11 -14
  1083. package/skills/sauce-script/SKILL.md +407 -0
  1084. package/skills/sauce-script/examples/IOracle.json +12 -0
  1085. package/skills/sauce-script/examples/saucescript.mts +167 -0
  1086. package/skills/sauce-script/examples/twap.sauce.ts +29 -0
  1087. package/skills/sauce-script/references/builtins.json +823 -0
  1088. package/skills/sauce-script/references/builtins.md +674 -0
  1089. package/skills/sauce-solana/SKILL.md +322 -0
  1090. package/skills/sauce-solana/examples/solana.mts +166 -0
  1091. package/skills/sauce-solana/examples/solana.sauce.ts +45 -0
  1092. package/skills/sauce-solana/examples/token-2022.sauce.ts +38 -0
  1093. package/skills/sauce-swaps/SKILL.md +200 -0
  1094. package/skills/sauce-swaps/examples/swap-leg.sauce.ts +50 -0
  1095. package/skills/sauce-swaps/examples/swaps.mts +124 -0
  1096. package/skills/sauce-typescript/SKILL.md +178 -0
  1097. package/skills/sauce-typescript/examples/actions.mts +100 -0
  1098. package/skills/sauce-typescript/examples/compiler.mts +69 -0
  1099. package/skills/sauce-typescript/examples/cook.mts +65 -0
  1100. package/skills/sauce-typescript/examples/verify.mts +104 -0
  1101. package/dev-tools/README.md +0 -16
  1102. package/dev-tools/artifacts/IERC20.json +0 -1
  1103. package/dev-tools/artifacts/ISauceRouter.json +0 -1
  1104. package/dev-tools/artifacts/IUniswapV3Pool.json +0 -1
  1105. package/dev-tools/artifacts/Router.json +0 -1
  1106. package/dev-tools/hardhat.config.cjs +0 -18
  1107. package/dev-tools/sauce/js/add.js +0 -4
  1108. package/dev-tools/sauce/js/call.js +0 -8
  1109. package/dev-tools/sauce/js/erc20.js +0 -18
  1110. package/dev-tools/sauce/js/example.js +0 -6
  1111. package/dev-tools/sauce/js/fibonacci.js +0 -13
  1112. package/dev-tools/sauce/ts/add.ts +0 -4
  1113. package/dev-tools/sauce/ts/call.ts +0 -8
  1114. package/dev-tools/sauce/ts/erc20.ts +0 -18
  1115. package/dev-tools/sauce/ts/example.ts +0 -6
  1116. package/dev-tools/sauce/ts/fibonacci.ts +0 -13
  1117. package/dev-tools/sauce/ts/saucescript.d.ts +0 -1
  1118. package/dev-tools/sauce/ts/tsconfig.json +0 -12
  1119. package/dev-tools/scripts/deploy.ts +0 -107
  1120. package/dev-tools/scripts/init.js +0 -132
  1121. package/dev-tools/scripts/run.ts +0 -67
  1122. package/dev-tools/scripts/start-fork.sh +0 -92
  1123. package/dev-tools/scripts/start-local.sh +0 -120
  1124. package/dev-tools/scripts/stop-local.sh +0 -40
  1125. package/dev-tools/scripts/sync-artifacts.js +0 -46
  1126. package/dev-tools/scripts/sync-price.ts +0 -58
  1127. package/dev-tools/src/contracts.ts +0 -59
  1128. package/dev-tools/src/runner.ts +0 -355
  1129. package/dev-tools/src/svm-local.ts +0 -305
  1130. package/dev-tools/src/sync-price.ts +0 -217
  1131. package/sdk/dist/deployments/v12.generated.d.ts +0 -95
  1132. package/sdk/dist/deployments/v12.generated.d.ts.map +0 -1
  1133. package/sdk/dist/deployments/v12.generated.js +0 -50
  1134. package/sdk/dist/deployments/v12.generated.js.map +0 -1
  1135. package/sdk/dist/swap/index.d.ts +0 -29
  1136. package/sdk/dist/swap/index.d.ts.map +0 -1
  1137. package/sdk/dist/swap/index.js +0 -27
  1138. package/sdk/dist/swap/index.js.map +0 -1
  1139. package/sdk/dist/swap/params.d.ts +0 -29
  1140. package/sdk/dist/swap/params.d.ts.map +0 -1
  1141. package/sdk/dist/swap/params.js +0 -123
  1142. package/sdk/dist/swap/params.js.map +0 -1
  1143. package/sdk/dist/swap/source.d.ts +0 -30
  1144. package/sdk/dist/swap/source.d.ts.map +0 -1
  1145. package/sdk/dist/swap/source.js +0 -101
  1146. package/sdk/dist/swap/source.js.map +0 -1
  1147. package/sdk/dist/swap/types.d.ts +0 -160
  1148. package/sdk/dist/swap/types.d.ts.map +0 -1
  1149. package/sdk/dist/swap/types.js +0 -106
  1150. package/sdk/dist/swap/types.js.map +0 -1
  1151. package/sdk/src/skills/aave-v3.md +0 -134
  1152. package/sdk/src/skills/aave-v4.md +0 -91
  1153. package/sdk/src/skills/abracadabra.md +0 -93
  1154. package/sdk/src/skills/across.md +0 -90
  1155. package/sdk/src/skills/aerodrome-slipstream.md +0 -57
  1156. package/sdk/src/skills/aevo.md +0 -58
  1157. package/sdk/src/skills/axelar.md +0 -80
  1158. package/sdk/src/skills/cbeth.md +0 -62
  1159. package/sdk/src/skills/chainlink.md +0 -62
  1160. package/sdk/src/skills/crvusd.md +0 -58
  1161. package/sdk/src/skills/curve.md +0 -141
  1162. package/sdk/src/skills/eigenlayer.md +0 -71
  1163. package/sdk/src/skills/frax.md +0 -57
  1164. package/sdk/src/skills/gamma.md +0 -79
  1165. package/sdk/src/skills/gho.md +0 -61
  1166. package/sdk/src/skills/harvest.md +0 -49
  1167. package/sdk/src/skills/index.md +0 -299
  1168. package/sdk/src/skills/kelp.md +0 -60
  1169. package/sdk/src/skills/kyberswap.md +0 -100
  1170. package/sdk/src/skills/liquity-v2.md +0 -59
  1171. package/sdk/src/skills/loader.ts +0 -46
  1172. package/sdk/src/skills/maker.md +0 -79
  1173. package/sdk/src/skills/mantle-meth.md +0 -60
  1174. package/sdk/src/skills/olympus.md +0 -46
  1175. package/sdk/src/skills/oneinch.md +0 -64
  1176. package/sdk/src/skills/openocean.md +0 -86
  1177. package/sdk/src/skills/pancakeswap-v3.md +0 -104
  1178. package/sdk/src/skills/paraswap.md +0 -67
  1179. package/sdk/src/skills/permit2.md +0 -73
  1180. package/sdk/src/skills/perpetual-protocol.md +0 -73
  1181. package/sdk/src/skills/pyth.md +0 -58
  1182. package/sdk/src/skills/reflexer.md +0 -73
  1183. package/sdk/src/skills/safe.md +0 -56
  1184. package/sdk/src/skills/seaport.md +0 -65
  1185. package/sdk/src/skills/sommelier.md +0 -47
  1186. package/sdk/src/skills/stader.md +0 -53
  1187. package/sdk/src/skills/swell.md +0 -65
  1188. package/sdk/src/skills/synapse.md +0 -63
  1189. package/sdk/src/skills/synthra-v3.md +0 -57
  1190. package/sdk/src/skills/thales.md +0 -74
  1191. package/sdk/src/skills/tokemak.md +0 -48
  1192. package/sdk/src/skills/uniswap-v3.md +0 -202
  1193. package/sdk/src/skills/uniswap-v4.md +0 -125
  1194. package/sdk/src/skills/unitflow-v3.md +0 -62
  1195. package/sdk/src/skills/vertex.md +0 -55
  1196. package/sdk/src/skills/wormhole.md +0 -76
  1197. package/sdk/src/skills/zerox.md +0 -51
@@ -0,0 +1,1360 @@
1
+ /**
2
+ * The `sauce` command on Solana: a Pot is a Kitchen PDA, a cook is a Kitchen `cook` the released
3
+ * engine runs — or, `--via engine`, the engine's own paid `cookAndPay`, with no Kitchen and no Pot —
4
+ * and both go through the SDK's own pieces — `createSauceSvmClient` (with the RPC URL the user gave
5
+ * and the program ids `/deployments` records) builds, signs and simulates every cook;
6
+ * `derivePotPda`/`buildCreatePotInstruction` are the Pot; the code-buffer builders stage a program
7
+ * too large for one transaction. Nothing here encodes an instruction of its own.
8
+ *
9
+ * What this adds is the transport a command line needs and the SDK leaves to its caller: sending
10
+ * a transaction and confirming it by polling (no websocket endpoint to configure), reading the
11
+ * Kitchen's fee and a Pot's existence, mapping the manifest's account slots from `--account`
12
+ * flags, and a keypair file as the signer. A keypair is read from the path given, never from the
13
+ * environment, and its bytes are dropped once the signer holds the key.
14
+ */
15
+ import { createHash, randomBytes } from "node:crypto";
16
+ import { readFileSync } from "node:fs";
17
+ import { address, createKeyPairSignerFromBytes, createSolanaRpc, getAddressEncoder, getBase58Decoder, getBase58Encoder, getBase64EncodedWireTransaction, getBase64Encoder, getCompiledTransactionMessageDecoder, getSignatureFromTransaction, getTransactionDecoder, getTransactionSize, isAddress, signTransaction, TRANSACTION_SIZE_LIMIT, } from "@solana/kit";
18
+ import { bytesToHex, formatUnits, hexToBytes } from "viem";
19
+ import { requireChain } from "../chains/canonical.js";
20
+ import { v12SvmEngineProgramId, v12SvmKitchenProgramId } from "../deployments/index.js";
21
+ import { mainReturnType, parseEntryType, } from "../routes/entry.js";
22
+ import { svmTokenRows } from "../routes/token-registry.js";
23
+ import { svmKitchenIdlPath } from "../svm/engine-artifacts.js";
24
+ import { verifySvmSettleExecution } from "../svm/verify.js";
25
+ import { buildCloseCodeBufferInstruction, buildComputeBudgetPrepend, buildCookAndPayInstruction, buildCookInstruction, buildCreateCodeBufferInstruction, buildCreatePotInstruction, buildExecuteTransaction, buildFinalizeCodeBufferInstruction, buildGrowCodeBufferInstruction, buildHeapFramePrepend, buildWriteCodeBufferInstruction, createSauceSvmClient, decodeExecutionFeeConfig, deriveCodeBufferPda, deriveCodePda, deriveExecutionFeeConfigPda, derivePotPda, engineFaultName, GROWTH_STEP, MAX_POT_LEN, resolveAccounts, resolveTokenProgramByOwner, svmTokenAccount, TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, } from "../svm/index.js";
26
+ import { CliError, UsageError } from "./args.js";
27
+ import { compileProgram, payloadOf, refusePastDeadline, unapproved, } from "./commands.js";
28
+ import { decodeReturned, returnedLine } from "./returned.js";
29
+ import { guardOf } from "./policy.js";
30
+ import { secret } from "./signer.js";
31
+ import { requireSupported } from "./support.js";
32
+ import { accountsNow, movedBy, svmMovedJson, svmMovedLines, writableAccounts, } from "./svm-effects.js";
33
+ /** The released programs, from the release record the SDK ships. */
34
+ const kitchen = () => address(v12SvmKitchenProgramId());
35
+ const engine = () => address(v12SvmEngineProgramId());
36
+ /** A Solana public key from a flag, or a usage error naming the flag. */
37
+ export function parsePubkey(flag, raw) {
38
+ if (!isAddress(raw)) {
39
+ throw new UsageError(`--${flag}: '${raw}' is not a Solana address (a base58 public key)`);
40
+ }
41
+ return address(raw);
42
+ }
43
+ /**
44
+ * `--keypair <path>`: the standard Solana keypair file, a JSON array of the 64 secret-key bytes.
45
+ * The file's text is registered as a secret before anything can fail and print it.
46
+ */
47
+ export async function loadKeypair(path, files) {
48
+ let text;
49
+ try {
50
+ text = files.readText(path);
51
+ }
52
+ catch (error) {
53
+ const code = error.code;
54
+ throw new CliError(`--keypair ${path}: ${code === "ENOENT" ? "no such file" : "unreadable"}`);
55
+ }
56
+ secret(text.trim());
57
+ let bytes;
58
+ try {
59
+ const parsed = JSON.parse(text);
60
+ if (Array.isArray(parsed) &&
61
+ parsed.length === 64 &&
62
+ parsed.every((byte) => Number.isInteger(byte) && byte >= 0 && byte <= 255)) {
63
+ bytes = Uint8Array.from(parsed);
64
+ }
65
+ }
66
+ catch {
67
+ // Reported below, without the text.
68
+ }
69
+ if (bytes === undefined) {
70
+ throw new UsageError(`--keypair ${path}: not a Solana keypair file (a JSON array of 64 bytes, as solana-keygen writes)`);
71
+ }
72
+ try {
73
+ return await createKeyPairSignerFromBytes(bytes);
74
+ }
75
+ catch {
76
+ throw new UsageError(`--keypair ${path}: its 64 bytes are not an ed25519 keypair`);
77
+ }
78
+ finally {
79
+ bytes.fill(0);
80
+ }
81
+ }
82
+ /** A signer that signs nothing: an all-zero signature, which a simulation (`sigVerify: false`)
83
+ * ignores and a wallet replaces. What `simulate` and `tx` build with, having no key. */
84
+ function unsignedSigner(owner) {
85
+ return {
86
+ address: owner,
87
+ signTransactions: async (transactions) => transactions.map(() => ({ [owner]: new Uint8Array(64) })),
88
+ };
89
+ }
90
+ /** An RPC request, failing with what was asked and never the URL (a provider URL holds a key). */
91
+ async function ask(url, what, request) {
92
+ try {
93
+ return await request();
94
+ }
95
+ catch (error) {
96
+ const message = error.message ?? String(error);
97
+ throw new CliError(`reading ${what} failed: ${message.split(url).join("<RPC_URL>")}`);
98
+ }
99
+ }
100
+ /**
101
+ * The execution fee in lamports, from the Kitchen's fee config account: what a cook pays, through
102
+ * the Kitchen or direct to the engine, which reads the same account.
103
+ */
104
+ async function kitchenFee(rpc, url) {
105
+ const { address: config } = await deriveExecutionFeeConfigPda(kitchen());
106
+ const { value } = await ask(url, "the Kitchen's fee config", () => rpc.getAccountInfo(config, { encoding: "base64" }).send());
107
+ try {
108
+ if (value === null || value.owner !== kitchen())
109
+ throw new Error("absent");
110
+ return decodeExecutionFeeConfig(new Uint8Array(getBase64Encoder().encode(value.data[0])));
111
+ }
112
+ catch {
113
+ throw new CliError(`the released Kitchen (${kitchen()}) has no execution-fee config on this cluster: is it ` +
114
+ "deployed there? Every cook is refused without one, through the Kitchen or direct.");
115
+ }
116
+ }
117
+ async function exists(rpc, url, account, what) {
118
+ const { value } = await ask(url, what, () => rpc.getAccountInfo(account, { encoding: "base64" }).send());
119
+ return value !== null;
120
+ }
121
+ /** How long {@link awaitAccount} waits for an account to show, and how often it asks. */
122
+ export const ACCOUNT_WAIT = { tries: 60, delayMs: 1000 };
123
+ /**
124
+ * Waits until the cluster shows `account`, just created in a confirmed transaction. A read with no
125
+ * commitment is a finalized read, which trails a confirmation by several seconds, and the cook's
126
+ * simulation reads the same way: cooking straight after creating its Pot would fail on a Pot that
127
+ * is there.
128
+ */
129
+ export async function awaitAccount(rpc, url, account, what, wait = ACCOUNT_WAIT) {
130
+ for (let attempt = 0; attempt < wait.tries; attempt++) {
131
+ if (await exists(rpc, url, account, what).catch(() => false))
132
+ return;
133
+ await new Promise((resolve) => setTimeout(resolve, wait.delayMs));
134
+ }
135
+ throw new CliError(`${what} ${account} was created, but the cluster still does not show it after ` +
136
+ `${(wait.tries * wait.delayMs) / 1000}s: run the command again once it has caught up; the ` +
137
+ "creation is not repeated.");
138
+ }
139
+ /** The Kitchen's error names, from the release IDL that ships beside its binary. */
140
+ function kitchenErrors() {
141
+ try {
142
+ const idl = JSON.parse(readFileSync(svmKitchenIdlPath(), "utf8"));
143
+ return new Map((idl.errors ?? []).map((e) => [e.code, `${e.name}: ${e.msg}`]));
144
+ }
145
+ catch {
146
+ return new Map();
147
+ }
148
+ }
149
+ /**
150
+ * The program whose own instruction failed. A transaction error names only the top-level
151
+ * instruction, whose program may merely have passed on a failure from deep in a CPI; the logs say
152
+ * where it began — a callee's `failed` line comes before each of its callers'.
153
+ */
154
+ function failedProgram(logs) {
155
+ for (const line of logs) {
156
+ const failed = /^Program (\w+) failed: /.exec(line);
157
+ if (failed !== null)
158
+ return failed[1];
159
+ }
160
+ return undefined;
161
+ }
162
+ /** The return data the engine logged (`Program return: <engine> <base64>`), the last it set. */
163
+ function engineReturn(logs) {
164
+ let found;
165
+ for (const line of logs) {
166
+ const match = /^Program return: (\w+) ([A-Za-z0-9+/=]*)$/.exec(line);
167
+ if (match !== null && match[1] === engine()) {
168
+ found = new Uint8Array(getBase64Encoder().encode(match[2]));
169
+ }
170
+ }
171
+ return found;
172
+ }
173
+ /** The two token programs, whose refusals a program's token writes meet, by the name a person reads. */
174
+ const TOKEN_PROGRAMS = new Map([
175
+ [TOKEN_PROGRAM_ID, "SPL Token"],
176
+ [TOKEN_2022_PROGRAM_ID, "Token-2022"],
177
+ ]);
178
+ /**
179
+ * Why a token program refused, in its own words: the last `Program log:` line it wrote before it
180
+ * failed, other than the instruction's name. Token-2022 states each refusal so — a paused mint
181
+ * ("Transferring, minting, and burning is paused on this mint"), a frozen account ("Account is
182
+ * frozen") — where its error code alone is a number shared with every other program's.
183
+ */
184
+ function tokenProgramMessage(logs, program) {
185
+ let message;
186
+ for (const line of logs) {
187
+ if (line.startsWith(`Program ${program} invoke`))
188
+ message = undefined;
189
+ else if (line.startsWith(`Program ${program} failed`))
190
+ return message;
191
+ else {
192
+ const log = /^Program log: (?:Error: )?(.+)$/.exec(line);
193
+ if (log !== null && !log[1].startsWith("Instruction: "))
194
+ message = log[1];
195
+ }
196
+ }
197
+ return undefined;
198
+ }
199
+ /** What a few of the engine's refusals mean for the cook that met them. */
200
+ const ENGINE_FAULT_HINTS = {
201
+ ExecutionFeeExceedsMaximum: "the execution fee is above the max_execution_fee the cook signed (it rose since it was read): run it again",
202
+ ExecutionFeeNotPaid: "the fee payer holds less than the execution fee",
203
+ InvalidFeePayer: "the fee payer must be a System-owned account that holds no data",
204
+ InvalidFeeConfig: "the fee config is not the released Kitchen's",
205
+ CodeHashMismatch: "the staged program is not the bytes the cook was pinned to",
206
+ NotCookedByKitchen: "the engine's legacy instructions run only from a Kitchen cook",
207
+ AccountNotSigner: "the program wrote an account that did not sign — directly to the engine, nothing signs for a Pot",
208
+ };
209
+ /**
210
+ * A transaction error, read: the Sauce program's thrown text when the ENGINE failed with its revert
211
+ * code, the engine's or the Kitchen's error by name when either refused, a token program's refusal
212
+ * in the words it logged, and otherwise the code and the program it came from. Custom codes collide across programs (every Anchor program numbers from
213
+ * 6000; System and SPL Token both use 0), so a code is named only for the program the logs show
214
+ * failing.
215
+ */
216
+ export function failureReason(err, logs, returnData) {
217
+ const detail = err?.InstructionError;
218
+ const custom = detail?.[1]?.Custom;
219
+ const program = failedProgram(logs);
220
+ if (custom !== undefined) {
221
+ const code = Number(custom);
222
+ if (program === engine() && code === 0) {
223
+ // A revert's payload is the engine's return data, which the node may leave out of a failed
224
+ // simulation's answer; its log line carries it too.
225
+ const payload = returnData?.length ? returnData : engineReturn(logs);
226
+ const text = payload === undefined || payload.length === 0
227
+ ? ""
228
+ : new TextDecoder("utf-8", { fatal: false }).decode(payload);
229
+ return /^[\x20-\x7e]+$/.test(text)
230
+ ? `the program threw "${text}"`
231
+ : `the program reverted${payload?.length ? ` with ${bytesToHex(payload)}` : ""}`;
232
+ }
233
+ const named = program === kitchen() ? kitchenErrors().get(code) : undefined;
234
+ if (named !== undefined)
235
+ return `the Kitchen refused: ${named}`;
236
+ const tokenProgram = program === undefined ? undefined : TOKEN_PROGRAMS.get(program);
237
+ const said = tokenProgram === undefined ? undefined : tokenProgramMessage(logs, program);
238
+ if (said !== undefined) {
239
+ return `${tokenProgram} refused: ${said} (custom program error ${code})`;
240
+ }
241
+ const fault = program === engine() ? engineFaultName(code) : undefined;
242
+ if (fault !== undefined) {
243
+ const hint = ENGINE_FAULT_HINTS[fault];
244
+ return `the engine refused: ${fault} (custom program error ${code})${hint === undefined ? "" : `: ${hint}`}`;
245
+ }
246
+ return (`${program === undefined ? `instruction ${detail[0]}` : `program ${program}`} failed with ` +
247
+ `custom program error ${code} (0x${code.toString(16)}); the logs say why`);
248
+ }
249
+ if (detail !== undefined) {
250
+ return `${program === undefined ? `instruction ${detail[0]}` : `program ${program}`} failed: ${String(detail[1])}`;
251
+ }
252
+ return JSON.stringify(err, (_key, value) => typeof value === "bigint" ? value.toString() : value);
253
+ }
254
+ /** Polls until `signature` is confirmed (or a minute passes); its error, or null, and its slot. */
255
+ async function confirmed(rpc, url, signature) {
256
+ for (let tries = 0; tries < 120; tries++) {
257
+ const { value } = await ask(url, "the transaction's status", () => rpc.getSignatureStatuses([signature]).send());
258
+ const status = value[0];
259
+ if (status !== null && status !== undefined && status.confirmationStatus !== "processed") {
260
+ return { err: status.err, slot: BigInt(status.slot) };
261
+ }
262
+ await new Promise((resolve) => setTimeout(resolve, 500));
263
+ }
264
+ throw new CliError(`transaction ${signature} was not confirmed within a minute`);
265
+ }
266
+ /**
267
+ * Sends `transaction` and polls until it is confirmed (or fails, or a minute passes). From a wallet
268
+ * (`--wallet`), the fee payer's, it is held to the wallet's policy first (`policy.ts`).
269
+ */
270
+ async function sendAndConfirm(rpc, url, transaction) {
271
+ const signature = getSignatureFromTransaction(transaction);
272
+ const payer = getCompiledTransactionMessageDecoder().decode(transaction.messageBytes)
273
+ .staticAccounts[0];
274
+ const reservation = payer === undefined ? undefined : await guardOf(payer)?.svm(rpc, transaction);
275
+ try {
276
+ await ask(url, "sending the transaction", () => rpc
277
+ .sendTransaction(getBase64EncodedWireTransaction(transaction), {
278
+ encoding: "base64",
279
+ // Every transaction here was simulated first; the node need not do it again.
280
+ skipPreflight: true,
281
+ })
282
+ .send());
283
+ }
284
+ catch (error) {
285
+ reservation?.released("sending failed");
286
+ throw error;
287
+ }
288
+ // The status is the verdict: it is what confirmed, and it carries the error.
289
+ const { err: statusErr, slot } = await confirmed(rpc, url, signature);
290
+ if (statusErr === null)
291
+ reservation?.sent(signature);
292
+ else
293
+ reservation?.released(`${signature} failed`);
294
+ // The transaction itself — its logs, units and return data — can lag its status on a node.
295
+ let response;
296
+ for (let tries = 0;; tries++) {
297
+ response = await ask(url, "the confirmed transaction", () => rpc
298
+ .getTransaction(signature, {
299
+ commitment: "confirmed",
300
+ encoding: "base64",
301
+ maxSupportedTransactionVersion: 0,
302
+ })
303
+ .send());
304
+ if (response !== null || tries >= 20)
305
+ break;
306
+ await new Promise((resolve) => setTimeout(resolve, 500));
307
+ }
308
+ const meta = response?.meta;
309
+ const returnData = meta?.returnData === undefined || meta.returnData === null
310
+ ? undefined
311
+ : new Uint8Array(getBase64Encoder().encode(meta.returnData.data[0]));
312
+ const err = statusErr ?? meta?.err ?? null;
313
+ const logs = meta?.logMessages ?? [];
314
+ return {
315
+ signature,
316
+ ok: err === null,
317
+ ...(err === null ? {} : { reason: failureReason(err, logs, returnData) }),
318
+ ...(meta?.computeUnitsConsumed === undefined
319
+ ? {}
320
+ : { computeUnits: meta.computeUnitsConsumed }),
321
+ logs,
322
+ slot,
323
+ ...(meta?.fee === undefined ? {} : { fee: BigInt(meta.fee) }),
324
+ };
325
+ }
326
+ /**
327
+ * Signs a plan's Solana transaction (`lifecycle-svm.ts`: base64, its fresh keys' signatures in, the
328
+ * fee payer's out) with `signer`, the fee payer, rehearses it as signed and refuses it if it would
329
+ * fail, then sends it and waits until it is confirmed.
330
+ */
331
+ export async function sendPlannedSvm(url, signer, tx) {
332
+ if (tx.feePayer !== signer.address) {
333
+ throw new CliError(`${tx.what} is paid by ${tx.feePayer}, and the signer is ${signer.address}: build it for the signer`);
334
+ }
335
+ const rpc = createSolanaRpc(url);
336
+ const decoded = getTransactionDecoder().decode(new Uint8Array(getBase64Encoder().encode(tx.transaction)));
337
+ const signed = await signTransaction([signer.keyPair], decoded);
338
+ const wire = getBase64EncodedWireTransaction(signed);
339
+ const { value } = await ask(url, `a simulation of ${tx.what}`, () => rpc.simulateTransaction(wire, { encoding: "base64", sigVerify: true }).send());
340
+ if (value.err !== null) {
341
+ const logs = value.logs ?? [];
342
+ throw new CliError(`${tx.what} would fail, so nothing was sent: ${failureReason(value.err, logs)}\n${logs.join("\n")}`);
343
+ }
344
+ return sendAndConfirm(rpc, url, signed);
345
+ }
346
+ /** Builds, rehearses and sends `instructions` from `signer`, failing with the logs if the
347
+ * rehearsal fails. */
348
+ async function sendInstructions(rpc, url, signer, instructions, what) {
349
+ const { value: latestBlockhash } = await ask(url, "the latest blockhash", () => rpc.getLatestBlockhash().send());
350
+ const transaction = await buildExecuteTransaction({
351
+ payer: signer,
352
+ instructions,
353
+ latestBlockhash,
354
+ });
355
+ const { value } = await ask(url, `a simulation of ${what}`, () => rpc
356
+ .simulateTransaction(getBase64EncodedWireTransaction(transaction), {
357
+ encoding: "base64",
358
+ replaceRecentBlockhash: true,
359
+ })
360
+ .send());
361
+ if (value.err !== null) {
362
+ const logs = value.logs ?? [];
363
+ throw new CliError(`${what} would fail, so nothing was sent: ${failureReason(value.err, logs)}\n${logs.join("\n")}`);
364
+ }
365
+ return sendAndConfirm(rpc, url, transaction);
366
+ }
367
+ // ---------------------------------------------------------------------------------------------
368
+ // Accounts, the Pot, the cook
369
+ // ---------------------------------------------------------------------------------------------
370
+ /**
371
+ * A value that names an account by its token: `pot:<token>` or `owner:<token>`, that one's
372
+ * associated token account for the mint; `mint:<token>`, the mint itself; `program:<token>`, the
373
+ * token program that owns the mint. The token is a registered symbol (`USDC`) or a mint's base58
374
+ * address.
375
+ */
376
+ const TOKEN_NAMED = /^(pot|owner|mint|program):([A-Za-z0-9]+)$/;
377
+ /** `--account name=<pubkey | pot | owner | pot:<token> | owner:<token> | mint:<token> | program:<token>>`, parsed. */
378
+ export function parseAccounts(raws) {
379
+ const accounts = {};
380
+ for (const raw of raws) {
381
+ const at = raw.indexOf("=");
382
+ const name = raw.slice(0, at).trim();
383
+ const value = raw.slice(at + 1).trim();
384
+ if (at <= 0 || value === "") {
385
+ throw new UsageError(`--account: expected NAME=<address | pot | owner | pot:<token>>, got '${raw}'`);
386
+ }
387
+ if (Object.hasOwn(accounts, name))
388
+ throw new UsageError(`--account: ${name} given twice`);
389
+ if (value !== "pot" && value !== "owner" && !isAddress(value) && !TOKEN_NAMED.test(value)) {
390
+ throw new UsageError(`--account ${name}: '${value}' is not an address, pot, owner, or a token's account: ` +
391
+ "pot:USDC is the Pot's own USDC account (pot:<mint> for any mint), owner:USDC the " +
392
+ "owner's, mint:USDC the mint and program:USDC its token program");
393
+ }
394
+ accounts[name] = value;
395
+ }
396
+ return accounts;
397
+ }
398
+ /**
399
+ * A mint's token program read from the account's owner on the cluster `rpcUrl` serves: legacy SPL
400
+ * Token or Token-2022, and nothing else (`token-program.ts`).
401
+ */
402
+ const mintProgramOn = (rpc, url) => (mint) => resolveTokenProgramByOwner(mint, async (key) => {
403
+ const { value } = await ask(url, `the mint ${key}`, () => rpc.getAccountInfo(key, { encoding: "base64" }).send());
404
+ return value === null ? null : value.owner;
405
+ });
406
+ /** The name a person reads for a token program. */
407
+ const programName = (program) => program === TOKEN_2022_PROGRAM_ID ? "Token-2022" : "SPL Token";
408
+ /**
409
+ * Each `--account` value that names an account by its token as that account: `pot:USDC` and
410
+ * `owner:<mint>` the associated token account of the Pot (or the owner) for the mint, under the
411
+ * token program that owns the mint; `mint:USDC` the mint; `program:USDC` that token program — the
412
+ * accounts `@sauce/token`'s writes take. A symbol is one of the cluster's registered mints, whose
413
+ * row records its program; any other mint is given by its base58 address, and its program is read
414
+ * with `programOf`. Every other value is left as it is.
415
+ */
416
+ export async function resolveTokenAccounts(given, owner, pot, chain, via = "kitchen", programOf = async () => TOKEN_PROGRAM_ID) {
417
+ const accounts = {};
418
+ const named = new Map();
419
+ const rows = svmTokenRows(chain);
420
+ for (const [name, value] of Object.entries(given)) {
421
+ const match = TOKEN_NAMED.exec(value);
422
+ if (match === null) {
423
+ accounts[name] = value;
424
+ continue;
425
+ }
426
+ const [, whose, token] = match;
427
+ if (whose === "pot" && via === "engine") {
428
+ throw new UsageError(`--account ${name}=${value}: --via engine cooks with no Pot, so there is no Pot's token ` +
429
+ `account to pass: give the account the program reads by its address (owner:${token} ` +
430
+ "for the owner's), or cook through the Kitchen");
431
+ }
432
+ const row = rows.find((candidate) => candidate.symbol === token);
433
+ if (row === undefined && !isAddress(token)) {
434
+ throw new UsageError(`--account ${name}=${value}: ${token} is not a mint ${chain.slug} registers ` +
435
+ `(${rows.map((candidate) => candidate.symbol).join(", ") || "none"}): give the mint's ` +
436
+ `base58 address, ${whose}:<mint>`);
437
+ }
438
+ const mint = address(row?.mint ?? token);
439
+ const what = row?.symbol ?? `mint ${mint}`;
440
+ if (whose === "mint") {
441
+ accounts[name] = mint;
442
+ named.set(name, { address: mint, label: `the ${what} mint`, kind: "mint" });
443
+ continue;
444
+ }
445
+ const tokenProgram = row?.tokenProgram ?? (await programOf(mint));
446
+ if (whose === "program") {
447
+ accounts[name] = tokenProgram;
448
+ named.set(name, {
449
+ address: tokenProgram,
450
+ label: `${what}'s token program, ${programName(tokenProgram)}`,
451
+ kind: "program",
452
+ });
453
+ continue;
454
+ }
455
+ const account = await svmTokenAccount({ mint, tokenProgram }, whose === "pot" ? pot : owner);
456
+ accounts[name] = account;
457
+ named.set(name, {
458
+ address: account,
459
+ label: `${whose === "pot" ? "the Pot" : "the owner"}'s ${what} account`,
460
+ kind: "account",
461
+ });
462
+ }
463
+ return { accounts, named };
464
+ }
465
+ /**
466
+ * Each slot of the manifest resolved from `--account`. The Pot goes in unsigned: the Kitchen signs
467
+ * for it — and, cooked directly (`via` engine), nothing does, so a slot that must sign cannot be
468
+ * the Pot. The owner signs when the slot asks for a signer — with `signer` when there is one.
469
+ */
470
+ function resolution(manifest, given, owner, pot, signer, via = "kitchen") {
471
+ const slots = manifest.accounts.filter((entry) => entry.kind === "slot");
472
+ if (manifest.accounts.some((entry) => entry.kind === "remaining")) {
473
+ throw new UsageError("the program takes a variable list of accounts after its named ones, which the CLI cannot " +
474
+ "attach yet: build that cook with the SDK's Solana client");
475
+ }
476
+ const names = slots.map((slot) => slot.name);
477
+ const unknown = Object.keys(given).filter((name) => !names.includes(name));
478
+ if (unknown.length > 0) {
479
+ throw new UsageError(`--account ${unknown[0]}: the program has no account by that name` +
480
+ (names.length === 0 ? "" : `; it takes ${names.join(", ")}`));
481
+ }
482
+ const missing = slots.filter((slot) => !Object.hasOwn(given, slot.name));
483
+ if (missing.length > 0) {
484
+ throw new UsageError(`missing --account for ${missing.map((slot) => `${slot.name} (${slot.requires})`).join(", ")}: ` +
485
+ "pass --account NAME=<address | pot | owner> for each");
486
+ }
487
+ const resolved = {};
488
+ for (const slot of slots) {
489
+ const value = given[slot.name];
490
+ if (via === "engine" && value === "pot" && /signer/.test(slot.requires)) {
491
+ throw new UsageError(`--account ${slot.name}=pot: ${slot.name} must sign (${slot.requires}), and cooked ` +
492
+ "directly to the engine (--via engine) nothing signs for the Pot — only a Kitchen cook " +
493
+ `does. Give ${slot.name} a signer (owner), or cook --via kitchen.`);
494
+ }
495
+ const at = value === "pot" ? pot : value === "owner" ? owner : address(value);
496
+ resolved[slot.name] =
497
+ at === pot ? { address: pot, signer: false } : at === owner ? { address: owner, signer } : at;
498
+ }
499
+ return resolved;
500
+ }
501
+ const saltBytes = (salt) => hexToBytes(salt);
502
+ const potOf = async (target) => (await derivePotPda(kitchen(), target.owner, saltBytes(target.salt))).address;
503
+ /** Whether the Kitchen has created `target`'s Pot on the cluster `rpcUrl` serves. */
504
+ export async function svmPotExists(target, rpcUrl) {
505
+ return exists(createSolanaRpc(rpcUrl), rpcUrl, await potOf(target), "the Pot");
506
+ }
507
+ /**
508
+ * The Pot's associated token account for every mint the chain's cluster registers — each under the
509
+ * token program its row records — whether it exists, and its balance.
510
+ */
511
+ export async function svmPotTokenAccounts(target, rpcUrl, chain) {
512
+ const pot = await potOf(target);
513
+ const rpc = createSolanaRpc(rpcUrl);
514
+ return Promise.all(svmTokenRows(chain).map(async (row) => {
515
+ const mint = address(row.mint);
516
+ const account = await svmTokenAccount({ mint, tokenProgram: row.tokenProgram }, pot);
517
+ const base = {
518
+ symbol: row.symbol,
519
+ mint: row.mint,
520
+ decimals: row.decimals,
521
+ tokenProgram: row.tokenProgram,
522
+ account,
523
+ };
524
+ if (!(await exists(rpc, rpcUrl, account, `the Pot's ${row.symbol} account`))) {
525
+ return { ...base, exists: false, balance: null };
526
+ }
527
+ const { value } = await ask(rpcUrl, `the Pot's ${row.symbol} balance`, () => rpc.getTokenAccountBalance(account).send());
528
+ return { ...base, exists: true, balance: value.amount };
529
+ }));
530
+ }
531
+ /** Names for the accounts a cook writes: the owner, the Pot, the Kitchen's fee config (where its
532
+ * fee goes), and each `--account` by its name (a token account named `pot:USDC` as what it is). */
533
+ async function accountLabels(input, pot, given) {
534
+ const labels = new Map();
535
+ const add = (account, name) => labels.set(account, [...(labels.get(account) ?? []), name]);
536
+ add(input.owner, "the owner");
537
+ add(pot, "the Pot");
538
+ add((await deriveExecutionFeeConfigPda(kitchen())).address, "the Kitchen's fee config");
539
+ for (const [name, value] of Object.entries(given.accounts)) {
540
+ const token = given.named.get(name);
541
+ if (value !== "pot" && value !== "owner")
542
+ add(value, token === undefined ? name : `${name}, ${token.label}`);
543
+ }
544
+ return new Map([...labels].map(([account, names]) => [account, names.join(", ")]));
545
+ }
546
+ /**
547
+ * A note for each account `--account` names that the cluster does not have: a program reading it
548
+ * fails, and SVM guards fail with no message, so this says which. A token account the Pot or the
549
+ * owner has not had created yet says how one comes to be.
550
+ */
551
+ async function missingAccounts(rpc, url, given) {
552
+ const named = Object.entries(given.accounts).filter(([, value]) => value !== "pot" && value !== "owner");
553
+ const there = await Promise.all(named.map(([name, value]) => exists(rpc, url, address(value), `the account ${name}`)));
554
+ return named.flatMap(([name, value], index) => {
555
+ if (there[index])
556
+ return [];
557
+ const token = given.named.get(name);
558
+ return [
559
+ `--account ${name}: ${value} does not exist on solana` +
560
+ (token === undefined
561
+ ? ""
562
+ : token.kind !== "account"
563
+ ? ` (${token.label})`
564
+ : ` (${token.label}: nothing has created it yet; a wallet's SPL transfer to the ` +
565
+ "account's owner creates it, or create it with an associated-token-account " +
566
+ "instruction)"),
567
+ ];
568
+ });
569
+ }
570
+ /** The `sauce pot` that creates `target`'s Pot. */
571
+ const createHint = (target) => `sauce pot --deploy --chain solana --keypair <the owner's keypair>${target.flag === undefined ? "" : ` ${target.flag}`}`;
572
+ const createPotInstruction = (target, pot) => buildCreatePotInstruction({
573
+ kitchen: kitchen(),
574
+ owner: target.owner,
575
+ engineProgram: engine(),
576
+ pot,
577
+ salt: saltBytes(target.salt),
578
+ space: MAX_POT_LEN,
579
+ });
580
+ /**
581
+ * A value of `type` with every `Address` in it as the word the engine reads on Solana: the public
582
+ * key's 32 bytes, whole. A key is given in base58, or as 32 bytes of hex.
583
+ */
584
+ function keyWords(type, value, at) {
585
+ switch (type.kind) {
586
+ case "address": {
587
+ if (typeof value === "string" && isAddress(value)) {
588
+ return bytesToHex(new Uint8Array(getAddressEncoder().encode(address(value))));
589
+ }
590
+ if (typeof value === "string" && /^0x[0-9a-fA-F]{64}$/.test(value))
591
+ return value;
592
+ throw new TypeError(`${at}: ${JSON.stringify(value)} is not a Solana public key (base58, or 32 bytes of hex)`);
593
+ }
594
+ case "array":
595
+ return Array.isArray(value)
596
+ ? value.map((item, index) => keyWords(type.of, item, `${at}[${index}]`))
597
+ : value;
598
+ case "tuple": {
599
+ if (Array.isArray(value)) {
600
+ return value.map((item, index) => index < type.fields.length
601
+ ? keyWords(type.fields[index].type, item, `${at}.${type.fields[index].name}`)
602
+ : item);
603
+ }
604
+ if (value === null || typeof value !== "object" || value instanceof Uint8Array)
605
+ return value;
606
+ const record = value;
607
+ return Object.fromEntries(Object.entries(record).map(([name, item]) => {
608
+ const field = type.fields.find((candidate) => candidate.name === name);
609
+ return [name, field === undefined ? item : keyWords(field.type, item, `${at}.${name}`)];
610
+ }));
611
+ }
612
+ default:
613
+ return value;
614
+ }
615
+ }
616
+ /**
617
+ * The program and its arguments. On Solana the engine reads an `Address` argument as a whole
618
+ * 32-byte word, a public key, where the EVM's ABI encoding keeps 20 bytes: each is encoded as that
619
+ * word, from base58 (or 32 bytes of hex).
620
+ */
621
+ function svmPayload(program, args) {
622
+ const keyed = program.entryParams.some((param) => /\bAddress\b/.test(param.type));
623
+ if (keyed && program.entryEncoding === "compact-v1") {
624
+ throw new UsageError("--compact-args: an Address argument on Solana is encoded as an ABI-v1 word only; compile " +
625
+ "without --compact-args, or take the key as an Account parameter or a define");
626
+ }
627
+ return hexToBytes(payloadOf(program, args, keyed
628
+ ? (compiled, values) => ({
629
+ program: {
630
+ ...compiled,
631
+ entryParams: compiled.entryParams.map((param) => ({
632
+ ...param,
633
+ type: param.type.replace(/\bAddress\b/g, "Uint256"),
634
+ })),
635
+ },
636
+ values: values.map((value, index) => {
637
+ const param = compiled.entryParams[index];
638
+ return param === undefined
639
+ ? value
640
+ : keyWords(parseEntryType(param.type), value, `${param.name}`);
641
+ }),
642
+ })
643
+ : undefined));
644
+ }
645
+ /** Compiles the file, reads the fee, and builds the SDK client that cooks it as `signer`. */
646
+ async function prepare(input, files, signer) {
647
+ refusePastDeadline(input);
648
+ const via = input.via ?? "kitchen";
649
+ const program = compileProgram(input, files);
650
+ const bytecode = svmPayload(program, input.args);
651
+ const manifest = program.manifest ?? { accounts: [] };
652
+ const rpc = createSolanaRpc(input.rpcUrl);
653
+ const pot = await potOf(input);
654
+ const given = await resolveTokenAccounts(input.accounts, input.owner, pot, input.chain, via, mintProgramOn(rpc, input.rpcUrl));
655
+ const accounts = resolution(manifest, given.accounts, input.owner, pot, signer, via);
656
+ const fee = await kitchenFee(rpc, input.rpcUrl);
657
+ if (input.maxExecutionFee !== undefined && fee > input.maxExecutionFee) {
658
+ throw new CliError(`the execution fee is ${fee} lamports, above --max-execution-fee ${input.maxExecutionFee}: ` +
659
+ "nothing was signed or sent");
660
+ }
661
+ // The cap the cook signs is the fee just read: it pays what is shown here, or fails.
662
+ const client = await createSauceSvmClient({
663
+ rpcUrl: input.rpcUrl,
664
+ programId: engine(),
665
+ kitchen: kitchen(),
666
+ payer: signer,
667
+ potSalt: saltBytes(input.salt),
668
+ maxExecutionFee: fee,
669
+ via,
670
+ });
671
+ return { rpc, via, pot, fee, program, bytecode, client, accounts, manifest, given };
672
+ }
673
+ /** A staged cook's options: directly to the engine it is pinned to the staged bytes' digest. */
674
+ const stagedPin = (prepared, staged) => prepared.via === "engine" ? { expectedSha256: staged.sha256 } : {};
675
+ /** What a direct cook is called in what a command prints. */
676
+ const DIRECT_COOK = "the engine's direct cook (cookAndPay)";
677
+ /**
678
+ * Whether the cook carrying `bytecode` fits in one transaction — measured as `run` sends it, with
679
+ * the SetComputeUnitLimit instruction its rehearsal adds (any limit encodes to the same size).
680
+ */
681
+ async function fits(prepared, prepends = []) {
682
+ const transaction = await prepared.client.cookTransaction(prepared.bytecode, prepared.manifest, prepared.accounts, { computeUnitLimit: 1_400_000, prepends });
683
+ const size = getTransactionSize(transaction);
684
+ return { fits: size <= TRANSACTION_SIZE_LIMIT, size, transaction };
685
+ }
686
+ /** A placeholder key, distinct per `index`, for an account a size estimate has no address for. */
687
+ const placeholderKey = (index) => getBase58Decoder().decode(new Uint8Array(32).fill(index + 1));
688
+ /**
689
+ * The size of the cook that carries `bytecode` inline, offline: the transaction `run` sends (heap
690
+ * frame, compute-unit limit, the Kitchen's `cook` — or `via` engine, the engine's `cookAndPay`) for
691
+ * `manifest`, with each account `--account` gives where it is given — `pot` and `owner` are the
692
+ * cook's own — and a distinct account for every other slot, so a size is the most those slots can
693
+ * make it. The blockhash and signature are fixed widths, so a placeholder of each measures the same.
694
+ */
695
+ export async function svmCookSize(bytecode, manifest, given, via = "kitchen") {
696
+ const owner = placeholderKey(0);
697
+ const target = { owner, salt: `0x${"00".repeat(32)}` };
698
+ const pot = await potOf(target);
699
+ // A token account (`pot:USDC`) is a distinct account of its own, as it is in a real cook. With no
700
+ // cluster, an unregistered mint's program is taken as legacy SPL Token: a key is a key to the size.
701
+ const accountsGiven = (await resolveTokenAccounts(given, owner, pot, requireChain("solana")))
702
+ .accounts;
703
+ const slots = manifest.accounts.filter((entry) => entry.kind === "slot");
704
+ const assumed = slots.filter((slot) => !Object.hasOwn(given, slot.name)).map((s) => s.name);
705
+ const named = { accounts: slots };
706
+ const signer = unsignedSigner(owner);
707
+ // The accounts given, as a cook resolves them; every other slot a distinct account, which signs
708
+ // for itself where the slot asks for a signer.
709
+ const resolved = resolution(named, Object.fromEntries(slots.map((slot) => [slot.name, accountsGiven[slot.name] ?? "pot"])), owner, pot, signer);
710
+ slots.forEach((slot, index) => {
711
+ if (Object.hasOwn(given, slot.name))
712
+ return;
713
+ const at = placeholderKey(index + 1);
714
+ resolved[slot.name] = /signer/.test(slot.requires)
715
+ ? { address: at, signer: unsignedSigner(at) }
716
+ : at;
717
+ });
718
+ const { address: feeConfig } = await deriveExecutionFeeConfigPda(kitchen());
719
+ const tail = resolveAccounts(named, resolved, owner);
720
+ const cook = via === "engine"
721
+ ? buildCookAndPayInstruction({
722
+ engineProgram: engine(),
723
+ feeConfig,
724
+ feePayer: owner,
725
+ maxExecutionFee: 0n,
726
+ bytecode,
727
+ tail,
728
+ })
729
+ : buildCookInstruction({
730
+ kitchen: kitchen(),
731
+ owner,
732
+ engineProgram: engine(),
733
+ potSalt: saltBytes(target.salt),
734
+ pot,
735
+ feeConfig,
736
+ bytecode,
737
+ maxExecutionFee: 0n,
738
+ tail,
739
+ });
740
+ const transaction = await buildExecuteTransaction({
741
+ payer: signer,
742
+ instructions: [
743
+ buildHeapFramePrepend(),
744
+ ...buildComputeBudgetPrepend({ unitLimit: 1_400_000 }),
745
+ cook,
746
+ ],
747
+ latestBlockhash: {
748
+ blockhash: placeholderKey(254),
749
+ lastValidBlockHeight: 0n,
750
+ },
751
+ });
752
+ const size = getTransactionSize(transaction);
753
+ return {
754
+ via,
755
+ size,
756
+ limit: TRANSACTION_SIZE_LIMIT,
757
+ fits: size <= TRANSACTION_SIZE_LIMIT,
758
+ assumed,
759
+ remaining: manifest.accounts.some((entry) => entry.kind === "remaining"),
760
+ };
761
+ }
762
+ /** The payload a cook carries — the program, and the arguments appended to it — in bytes. */
763
+ const payloadSize = (prepared) => {
764
+ const program = prepared.program.bytecode.length;
765
+ const payload = prepared.bytecode.length;
766
+ return payload === program
767
+ ? `the payload (the program, with no arguments) is ${payload} bytes`
768
+ : `the payload (the program's ${program} bytes and its arguments' ${payload - program}) is ` +
769
+ `${payload} bytes`;
770
+ };
771
+ /** A cook too large for one transaction, for `what` (a simulation, an unsigned transaction). */
772
+ const tooLarge = (prepared, size, what) => {
773
+ const over = size - TRANSACTION_SIZE_LIMIT;
774
+ return new CliError(`${payloadSize(prepared)}, so its cook is a ${size}-byte transaction, ${over} past Solana's ` +
775
+ `${TRANSACTION_SIZE_LIMIT}. A cook that large runs from a code buffer the program is staged ` +
776
+ `into first, in transactions the owner signs and sends, which ${what} cannot do. Shrink the ` +
777
+ `payload by at least ${over} bytes to fit, or let \`sauce run\` stage it (with the owner's ` +
778
+ "--keypair; it rehearses the staged cook before sending it).");
779
+ };
780
+ const simulated = (result) => failureReason(result.err, result.logs, result.revert?.payload);
781
+ /** The lamports a cook takes from its owner, and what the owner holds, when it holds less. */
782
+ async function ownerShort(prepared, input, creating) {
783
+ try {
784
+ const [held, rent] = await Promise.all([
785
+ prepared.rpc.getBalance(input.owner).send(),
786
+ creating
787
+ ? prepared.rpc.getMinimumBalanceForRentExemption(BigInt(MAX_POT_LEN)).send()
788
+ : Promise.resolve(0n),
789
+ ]);
790
+ // One signature's fee on top: the owner pays the transaction's too.
791
+ const needed = BigInt(rent) + prepared.fee + 5000n;
792
+ if (BigInt(held.value) >= needed)
793
+ return undefined;
794
+ return (`${input.owner} holds ${held.value} lamports, and the cook takes ${needed}: ` +
795
+ (creating ? `${rent} in rent for the Pot, ` : "") +
796
+ `the execution fee of ${prepared.fee} and the transaction's. Solana's simulateTransaction ` +
797
+ "takes no balance overrides, so the owner must hold them for a rehearsal too");
798
+ }
799
+ catch {
800
+ return undefined;
801
+ }
802
+ }
803
+ /**
804
+ * `sauce simulate` on Solana: the cook, simulated from the Pot's owner with no key — and, for a
805
+ * Pot the Kitchen has not created yet, its `create_pot` first, in the same transaction. Directly to
806
+ * the engine (`via` engine) there is no Pot to create: the owner is the signer, and pays.
807
+ */
808
+ export async function svmSimulateCommand(input, files) {
809
+ const prepared = await prepare(input, files, unsignedSigner(input.owner));
810
+ const direct = prepared.via === "engine";
811
+ // The size first: it is the program's own, whatever the cluster holds.
812
+ const alone = await fits(prepared);
813
+ if (!alone.fits)
814
+ throw tooLarge(prepared, alone.size, "a simulation, which sends nothing,");
815
+ const created = direct || (await exists(prepared.rpc, input.rpcUrl, prepared.pot, "the Pot"));
816
+ const prepends = created ? [] : [createPotInstruction(input, prepared.pot)];
817
+ let built = alone.transaction;
818
+ if (!created) {
819
+ const together = await fits(prepared, prepends);
820
+ built = together.transaction;
821
+ if (!together.fits) {
822
+ const over = together.size - TRANSACTION_SIZE_LIMIT;
823
+ throw new CliError(`Pot ${prepared.pot} is not created on solana yet, and its create_pot ahead of the cook ` +
824
+ `makes a ${together.size}-byte transaction, ${over} past Solana's ` +
825
+ `${TRANSACTION_SIZE_LIMIT}: create the Pot first (${createHint(input)}), or shrink the ` +
826
+ `payload by at least ${over} bytes`);
827
+ }
828
+ }
829
+ // What the cook moved: every account it may write, read now and as the simulation leaves it.
830
+ const tracked = writableAccounts(built);
831
+ const before = await ask(input.rpcUrl, "the accounts the cook writes", () => accountsNow(prepared.rpc, tracked));
832
+ const result = await prepared.client.simulate(prepared.bytecode, prepared.manifest, prepared.accounts, { prepends, accounts: tracked });
833
+ const moved = result.ok && result.accounts !== undefined
834
+ ? await movedBy(prepared.rpc, input.chain, tracked, before, result.accounts, await accountLabels(input, prepared.pot, prepared.given), input.owner)
835
+ : undefined;
836
+ const missing = await missingAccounts(prepared.rpc, input.rpcUrl, prepared.given);
837
+ // What main returned: the engine's return data, read as the type main declares.
838
+ const returns = result.ok ? bytesToHex(result.returnData ?? new Uint8Array()) : undefined;
839
+ const returnType = mainReturnType(input.text);
840
+ const json = {
841
+ ok: result.ok,
842
+ chain: "solana",
843
+ via: prepared.via,
844
+ owner: input.owner,
845
+ ...(direct ? {} : { pot: prepared.pot }),
846
+ fee: prepared.fee.toString(),
847
+ maxExecutionFee: prepared.fee.toString(),
848
+ path: "simulateTransaction",
849
+ ...(returns === undefined ? {} : { returns }),
850
+ ...(returns === undefined || returnType === undefined
851
+ ? {}
852
+ : { returnType, returned: decodeReturned(returnType, returns, input.chain) ?? null }),
853
+ ...(missing.length === 0 ? {} : { missingAccounts: missing }),
854
+ ...(direct
855
+ ? {}
856
+ : {
857
+ createPot: created ? null : { kitchen: kitchen(), owner: input.owner, salt: input.salt },
858
+ }),
859
+ ...(result.unitsConsumed === undefined
860
+ ? {}
861
+ : { computeUnits: result.unitsConsumed.toString() }),
862
+ ...(result.ok ? {} : { reason: simulated(result) }),
863
+ ...(result.ok ? (moved === undefined ? { moved: null } : svmMovedJson(moved)) : {}),
864
+ logs: result.logs,
865
+ };
866
+ const how = [
867
+ "Rehearsed with simulateTransaction, signatures unchecked; nothing was signed or sent:",
868
+ ...(created
869
+ ? []
870
+ : [
871
+ ` 1. Kitchen create_pot: Pot ${prepared.pot} is not created on solana yet, so the ` +
872
+ "transaction creates it first, the owner signing and paying its rent",
873
+ ]),
874
+ direct
875
+ ? ` ${DIRECT_COOK}, from ${input.owner}, which signs for the program and pays ` +
876
+ `the execution fee of ${prepared.fee} lamports: no Kitchen and no Pot`
877
+ : ` ${created ? "" : "2. "}the cook, from the owner ${input.owner}, which pays the ` +
878
+ `Kitchen's execution fee of ${prepared.fee} lamports`,
879
+ ];
880
+ if (result.ok) {
881
+ return {
882
+ text: [
883
+ `The cook succeeds from ${input.owner}: ${result.unitsConsumed ?? "?"} compute units` +
884
+ (returns === undefined || returns === "0x" ? "" : `, returns ${returns}`),
885
+ ...(returns === undefined || returnType === undefined
886
+ ? []
887
+ : [returnedLine(returnType, returns, input.chain)]),
888
+ ...how,
889
+ ...(moved === undefined ? [] : svmMovedLines(moved)),
890
+ ].join("\n"),
891
+ json,
892
+ ...(moved === undefined || missing.length > 0
893
+ ? {
894
+ notes: [
895
+ ...missing,
896
+ ...(moved === undefined
897
+ ? [
898
+ "the endpoint returned no account states from simulateTransaction, so what " +
899
+ "the cook moved is not shown",
900
+ ]
901
+ : []),
902
+ ],
903
+ }
904
+ : {}),
905
+ };
906
+ }
907
+ const short = await ownerShort(prepared, input, !created);
908
+ return {
909
+ text: [
910
+ `The cook fails: ${simulated(result)}`,
911
+ ...how,
912
+ "Program logs:",
913
+ ...result.logs.map((l) => ` ${l}`),
914
+ ].join("\n"),
915
+ json,
916
+ ...(short === undefined && missing.length === 0
917
+ ? {}
918
+ : { notes: [...missing, ...(short === undefined ? [] : [short])] }),
919
+ exitCode: 1,
920
+ };
921
+ }
922
+ /** `sauce tx` on Solana: the cook as an unsigned, serialized transaction for a wallet. */
923
+ export async function svmTxCommand(input, files) {
924
+ requireSupported("building the cook transaction", [input.chain]);
925
+ const prepared = await prepare(input, files, unsignedSigner(input.owner));
926
+ const direct = prepared.via === "engine";
927
+ const size = await fits(prepared);
928
+ if (!size.fits)
929
+ throw tooLarge(prepared, size.size, "one unsigned transaction");
930
+ const deployed = direct || (await exists(prepared.rpc, input.rpcUrl, prepared.pot, "the Pot"));
931
+ const transaction = await prepared.client.cookTransaction(prepared.bytecode, prepared.manifest, prepared.accounts, {});
932
+ const json = {
933
+ chain: "solana",
934
+ via: prepared.via,
935
+ feePayer: input.owner,
936
+ ...(direct ? {} : { pot: prepared.pot }),
937
+ fee: prepared.fee.toString(),
938
+ maxExecutionFee: prepared.fee.toString(),
939
+ transaction: getBase64EncodedWireTransaction(transaction),
940
+ };
941
+ return {
942
+ text: JSON.stringify(json, null, 2),
943
+ json,
944
+ notes: [
945
+ direct
946
+ ? `${DIRECT_COOK}: no Kitchen and no Pot. ${input.owner} is the authority ` +
947
+ "the program acts with, so the accounts it spends from are the signer's own."
948
+ : `Pot ${prepared.pot} belongs to ${input.owner} (salt ${input.salt}). ` +
949
+ (deployed
950
+ ? "It is created. Fund its accounts with what the program spends."
951
+ : `It is NOT created yet: ${createHint(input)}.`),
952
+ `The transaction is base64, signed by no one; ${input.owner} signs it and pays the ` +
953
+ `execution fee of ${prepared.fee} lamports (its max_execution_fee). Its blockhash ` +
954
+ "expires in about a minute.",
955
+ ],
956
+ };
957
+ }
958
+ /**
959
+ * Closes a code buffer, returning its rent. Never throws: a failure is the reason it stays open,
960
+ * which the caller reports with the buffer's address.
961
+ */
962
+ async function closeBuffer(rpc, url, signer, buffer) {
963
+ try {
964
+ const sent = await sendInstructions(rpc, url, signer, [
965
+ buildCloseCodeBufferInstruction({
966
+ kitchen: kitchen(),
967
+ owner: signer.address,
968
+ codeBuffer: buffer.codeBuffer,
969
+ code: buffer.code,
970
+ }),
971
+ ], "closing the code buffer");
972
+ if (sent.ok)
973
+ return { sent };
974
+ return {
975
+ sent,
976
+ open: `the code buffer ${buffer.codeBuffer} is still open (closing it failed in ${sent.signature}: ${sent.reason}); its rent stays there until it is closed`,
977
+ };
978
+ }
979
+ catch (error) {
980
+ return {
981
+ open: `the code buffer ${buffer.codeBuffer} is still open (closing it failed: ${error.message.split("\n")[0]}); its rent stays there until it is closed`,
982
+ };
983
+ }
984
+ }
985
+ /**
986
+ * Stages `bytecode` in a fresh code buffer: create, grow, write in chunks, finalize. A failure
987
+ * after the buffer exists closes it again, and says so — or names it, when that fails too.
988
+ */
989
+ async function stage(rpc, url, signer, bytecode) {
990
+ const nonce = randomBytes(8).readBigUInt64LE(0);
991
+ const { address: codeBuffer } = await deriveCodeBufferPda(kitchen(), signer.address, nonce);
992
+ const { address: code } = await deriveCodePda(kitchen(), codeBuffer);
993
+ const accounts = { kitchen: kitchen(), owner: signer.address, codeBuffer, code };
994
+ const sent = [];
995
+ const step = async (instructions, what) => {
996
+ const result = await sendInstructions(rpc, url, signer, instructions, what);
997
+ sent.push(result);
998
+ if (!result.ok) {
999
+ throw new CliError(`${what} failed in ${result.signature}: ${result.reason}`);
1000
+ }
1001
+ };
1002
+ const grows = Math.ceil(bytecode.length / GROWTH_STEP) - 1;
1003
+ try {
1004
+ await step([
1005
+ buildCreateCodeBufferInstruction({ ...accounts, nonce, capacity: bytecode.length }),
1006
+ ...Array.from({ length: grows }, () => buildGrowCodeBufferInstruction(accounts)),
1007
+ ], "creating the code buffer");
1008
+ }
1009
+ catch (error) {
1010
+ throw new CliError(`staging the program failed: ${error.message}`);
1011
+ }
1012
+ const sha256 = new Uint8Array(createHash("sha256").update(bytecode).digest());
1013
+ try {
1014
+ // A write carries its chunk plus ~200 bytes of signature, header and accounts.
1015
+ const CHUNK = 900;
1016
+ for (let offset = 0; offset < bytecode.length; offset += CHUNK) {
1017
+ await step([
1018
+ buildWriteCodeBufferInstruction({
1019
+ ...accounts,
1020
+ offset,
1021
+ chunk: bytecode.subarray(offset, offset + CHUNK),
1022
+ }),
1023
+ ], `writing bytes ${offset}… of the program`);
1024
+ }
1025
+ await step([
1026
+ buildFinalizeCodeBufferInstruction({
1027
+ ...accounts,
1028
+ len: bytecode.length,
1029
+ expectedSha256: sha256,
1030
+ }),
1031
+ ], "finalizing the code buffer");
1032
+ }
1033
+ catch (error) {
1034
+ const closed = await closeBuffer(rpc, url, signer, { codeBuffer, code });
1035
+ throw new CliError(`staging the program failed: ${error.message}\n` +
1036
+ (closed.open ?? `The code buffer ${codeBuffer} was closed again.`));
1037
+ }
1038
+ return { codeBuffer, code, sha256, sent };
1039
+ }
1040
+ const sentLine = (what, sent) => `${what} ${sent.signature}: ${sent.ok ? "success" : "failed"}` +
1041
+ (sent.computeUnits === undefined ? "" : `, ${sent.computeUnits} compute units`) +
1042
+ (sent.reason === undefined ? "" : `, ${sent.reason}`);
1043
+ const sentJson = (sent) => ({
1044
+ signature: sent.signature,
1045
+ status: sent.ok ? "success" : "failed",
1046
+ ...(sent.computeUnits === undefined ? {} : { computeUnits: sent.computeUnits.toString() }),
1047
+ ...(sent.reason === undefined ? {} : { reason: sent.reason, logs: sent.logs }),
1048
+ });
1049
+ /** Creates the Pot when it is missing and the user agrees; what was sent, if anything. */
1050
+ async function ensurePot(input, rpc, pot) {
1051
+ if (await exists(rpc, input.rpcUrl, pot, "the Pot"))
1052
+ return undefined;
1053
+ const missing = `Pot ${pot} is not deployed on solana`;
1054
+ const action = `create Pot ${pot}`;
1055
+ // With no one to ask, creating it is the one approval a Solana run needs: named before it sends.
1056
+ if (!input.approver.auto && !input.approver.canAsk)
1057
+ throw unapproved([action]);
1058
+ const agreed = await input.approver.approve(action, `Pot ${pot} (owner ${input.owner}, salt ${input.salt}) is not deployed on solana. ` +
1059
+ "Deploy it now? [y/N] ");
1060
+ if (agreed !== true) {
1061
+ throw new CliError(agreed === undefined
1062
+ ? `${missing}. Create it first (${createHint(input)}), or pass --auto-approve to create ` +
1063
+ "it before the cook"
1064
+ : `${missing}, so nothing was sent. Create it with: ${createHint(input)}`);
1065
+ }
1066
+ const created = await sendInstructions(rpc, input.rpcUrl, input.signer, [createPotInstruction(input, pot)], "creating the Pot");
1067
+ if (!created.ok)
1068
+ throw new CliError(sentLine("creating the Pot", created));
1069
+ await awaitAccount(rpc, input.rpcUrl, pot, "the Pot");
1070
+ return created;
1071
+ }
1072
+ /** `sauce run` on Solana: compile, create the Pot if agreed, stage if needed, cook, confirm. */
1073
+ export async function svmRunCommand(input, files) {
1074
+ requireSupported("sending the cook", [input.chain]);
1075
+ const prepared = await prepare(input, files, input.signer);
1076
+ const direct = prepared.via === "engine";
1077
+ // Directly to the engine the program runs as no Pot: there is none to create.
1078
+ const created = direct ? undefined : await ensurePot(input, prepared.rpc, prepared.pot);
1079
+ const size = await fits(prepared);
1080
+ // The cook's rehearsal failing: `computeUnitLimit: "auto"` simulates first, and its failure
1081
+ // carries the reason — read again, with the logs, to report it.
1082
+ const wouldFail = async (error, staged) => {
1083
+ const logs = await rehearsalLogs(prepared, staged);
1084
+ const closed = staged === undefined
1085
+ ? undefined
1086
+ : await closeBuffer(prepared.rpc, input.rpcUrl, input.signer, staged);
1087
+ throw new CliError(`the cook would fail, so it was not sent: ${logs.reason ?? error.message}` +
1088
+ (logs.lines.length === 0
1089
+ ? ""
1090
+ : `\nProgram logs:\n${logs.lines.map((l) => ` ${l}`).join("\n")}`) +
1091
+ (closed === undefined
1092
+ ? ""
1093
+ : `\n${closed.open ?? `The code buffer ${staged.codeBuffer} was closed again.`}`));
1094
+ };
1095
+ let staged;
1096
+ let transaction;
1097
+ if (size.fits) {
1098
+ try {
1099
+ transaction = await prepared.client.cookTransaction(prepared.bytecode, prepared.manifest, prepared.accounts, { computeUnitLimit: "auto" });
1100
+ }
1101
+ catch (error) {
1102
+ return wouldFail(error);
1103
+ }
1104
+ }
1105
+ else {
1106
+ staged = await stage(prepared.rpc, input.rpcUrl, input.signer, prepared.bytecode);
1107
+ try {
1108
+ transaction = await prepared.client.stagedCookTransaction(staged.codeBuffer, prepared.manifest, prepared.accounts, { computeUnitLimit: "auto", ...stagedPin(prepared, staged) });
1109
+ }
1110
+ catch (error) {
1111
+ return wouldFail(error, staged);
1112
+ }
1113
+ }
1114
+ const cook = await sendAndConfirm(prepared.rpc, input.rpcUrl, transaction);
1115
+ // The cook has landed (or failed) by now: whatever happens to the buffer, it is reported.
1116
+ const closed = staged === undefined
1117
+ ? undefined
1118
+ : await closeBuffer(prepared.rpc, input.rpcUrl, input.signer, staged);
1119
+ return {
1120
+ text: [
1121
+ ...(created === undefined ? [] : [sentLine(`created Pot ${prepared.pot} in`, created)]),
1122
+ ...(staged === undefined
1123
+ ? []
1124
+ : [
1125
+ `staged the ${prepared.bytecode.length}-byte program in ${staged.sent.length} transactions`,
1126
+ ]),
1127
+ sentLine(direct ? "cook (direct to the engine)" : "cook", cook),
1128
+ ...(cook.ok ? [`execution fee: ${prepared.fee} lamports`] : []),
1129
+ ...(cook.ok ? [] : ["Program logs:", ...cook.logs.map((line) => ` ${line}`)]),
1130
+ ...(closed?.sent === undefined || closed.open !== undefined
1131
+ ? []
1132
+ : [sentLine("closed the code buffer in", closed.sent)]),
1133
+ ].join("\n"),
1134
+ ...(closed?.open === undefined ? {} : { notes: [`warning: ${closed.open}`] }),
1135
+ json: {
1136
+ chain: "solana",
1137
+ via: prepared.via,
1138
+ owner: input.owner,
1139
+ ...(direct ? {} : { pot: prepared.pot }),
1140
+ fee: prepared.fee.toString(),
1141
+ maxExecutionFee: prepared.fee.toString(),
1142
+ ...(created === undefined ? {} : { createPot: sentJson(created) }),
1143
+ ...(staged === undefined
1144
+ ? {}
1145
+ : {
1146
+ staged: {
1147
+ codeBuffer: staged.codeBuffer,
1148
+ sha256: bytesToHex(staged.sha256),
1149
+ transactions: staged.sent.map((step) => step.signature),
1150
+ },
1151
+ }),
1152
+ cook: sentJson(cook),
1153
+ ...(closed?.sent === undefined ? {} : { closeCodeBuffer: sentJson(closed.sent) }),
1154
+ ...(closed?.open === undefined ? {} : { warning: closed.open }),
1155
+ },
1156
+ ...(cook.ok ? {} : { exitCode: 1 }),
1157
+ };
1158
+ }
1159
+ /** The reason and logs of the cook's rehearsal, for a run that stops before sending. */
1160
+ async function rehearsalLogs(prepared, staged) {
1161
+ try {
1162
+ const result = staged === undefined
1163
+ ? await prepared.client.simulate(prepared.bytecode, prepared.manifest, prepared.accounts)
1164
+ : await prepared.client.simulateStaged(staged.codeBuffer, prepared.manifest, prepared.accounts, stagedPin(prepared, staged));
1165
+ return result.ok ? { lines: result.logs } : { reason: simulated(result), lines: result.logs };
1166
+ }
1167
+ catch {
1168
+ return { lines: [] };
1169
+ }
1170
+ }
1171
+ /**
1172
+ * `sauce verify --chain solana <signature>`: the engine invocation a cook made, checked by the
1173
+ * SDK's `verifySvmSettleExecution` against the settle program recompiled for `minOut` and
1174
+ * `splCount`. A rejection exits 1: `TX_FAILED` when the transaction failed, `NO_SETTLE` when it
1175
+ * invokes no released engine or not with a settle's accounts, `NOT_GENUINE` with the SDK's reason
1176
+ * otherwise.
1177
+ */
1178
+ export async function svmVerifyCommand(input) {
1179
+ const rpc = createSolanaRpc(input.rpcUrl);
1180
+ const response = await ask(input.rpcUrl, "the transaction", () => rpc
1181
+ .getTransaction(input.signature, {
1182
+ commitment: "confirmed",
1183
+ encoding: "json",
1184
+ maxSupportedTransactionVersion: 0,
1185
+ })
1186
+ .send());
1187
+ if (response === null)
1188
+ throw new CliError(`no transaction ${input.signature} on solana`);
1189
+ const loaded = response.meta?.loadedAddresses;
1190
+ const keys = [
1191
+ ...response.transaction.message.accountKeys,
1192
+ ...(loaded?.writable ?? []),
1193
+ ...(loaded?.readonly ?? []),
1194
+ ];
1195
+ const invocation = (response.meta?.innerInstructions ?? [])
1196
+ .flatMap((group) => group.instructions)
1197
+ .find((inner) => keys[inner.programIdIndex] === engine());
1198
+ const rejected = (code, message) => ({
1199
+ text: `rejected (${code}): ${message}`,
1200
+ json: { signature: input.signature, chain: "solana", valid: false, code, message },
1201
+ exitCode: 1,
1202
+ });
1203
+ // A transaction that failed settled nothing, whatever its instructions carry.
1204
+ const failed = response.meta?.err ?? null;
1205
+ if (failed !== null) {
1206
+ return rejected("TX_FAILED", `the transaction failed (${failureReason(failed, response.meta?.logMessages ?? [])}), so it settled nothing`);
1207
+ }
1208
+ if (invocation === undefined) {
1209
+ return rejected("NO_SETTLE", `the transaction does not invoke the released engine (${engine()})`);
1210
+ }
1211
+ let verified;
1212
+ try {
1213
+ verified = verifySvmSettleExecution({
1214
+ instructionData: new Uint8Array(getBase58Encoder().encode(invocation.data)),
1215
+ accounts: invocation.accounts.map((index) => keys[index]),
1216
+ minOut: input.minOut,
1217
+ splCount: input.splCount,
1218
+ });
1219
+ }
1220
+ catch (error) {
1221
+ return rejected("NO_SETTLE", error.message);
1222
+ }
1223
+ if (!verified.genuine)
1224
+ return rejected("NOT_GENUINE", verified.mismatch ?? "not the settle program");
1225
+ const accounts = Object.entries(verified.accounts).map(([ref, at]) => `${ref} ${at}`);
1226
+ return {
1227
+ text: [
1228
+ `valid: the settle program, sweeping ${verified.escrowCount} escrow${verified.escrowCount === 1 ? "" : "s"} ` +
1229
+ `(minOut ${input.minOut}, splCount ${input.splCount})`,
1230
+ ...(verified.gate === undefined
1231
+ ? []
1232
+ : [` Pot ${verified.gate.pot}, owner ${verified.gate.owner}`]),
1233
+ ...accounts.map((line) => ` ${line}`),
1234
+ ` verified by ${verified.verifiedBy}`,
1235
+ ].join("\n"),
1236
+ json: {
1237
+ signature: input.signature,
1238
+ chain: "solana",
1239
+ valid: true,
1240
+ escrowCount: verified.escrowCount,
1241
+ minOut: input.minOut.toString(),
1242
+ splCount: input.splCount.toString(),
1243
+ accounts: verified.accounts,
1244
+ ...(verified.gate === undefined
1245
+ ? {}
1246
+ : { pot: verified.gate.pot, owner: verified.gate.owner }),
1247
+ verifiedBy: verified.verifiedBy,
1248
+ },
1249
+ };
1250
+ }
1251
+ // ---------------------------------------------------------------------------------------------
1252
+ // `sauce pot` on Solana
1253
+ // ---------------------------------------------------------------------------------------------
1254
+ const ROLE_NAMES = ["readonly", "writable", "readonly signer", "writable signer"];
1255
+ /** `sauce pot --chain solana`: the Pot PDA an owner and salt give, and its create instruction. */
1256
+ export async function svmPotCommand(target) {
1257
+ const pot = await potOf(target);
1258
+ const instruction = createPotInstruction(target, pot);
1259
+ const json = {
1260
+ chain: "solana",
1261
+ pot,
1262
+ owner: target.owner,
1263
+ salt: target.salt,
1264
+ kitchen: kitchen(),
1265
+ engine: engine(),
1266
+ instruction: {
1267
+ programAddress: instruction.programAddress,
1268
+ accounts: (instruction.accounts ?? []).map((meta) => ({
1269
+ address: meta.address,
1270
+ role: ROLE_NAMES[meta.role],
1271
+ })),
1272
+ data: getBase58Decoder().decode(instruction.data ?? new Uint8Array()),
1273
+ },
1274
+ };
1275
+ return {
1276
+ text: JSON.stringify(json, null, 2),
1277
+ json,
1278
+ notes: [
1279
+ `Kitchen create_pot on the released Kitchen. ${target.owner} signs it and pays the rent; ` +
1280
+ "it creates the Pot once.",
1281
+ ],
1282
+ };
1283
+ }
1284
+ /** The released programs on the cluster, and the Pot: what a cook there needs. */
1285
+ async function deployment(rpc, url, pot) {
1286
+ const program = async (at, what) => {
1287
+ const { value } = await ask(url, what, () => rpc.getAccountInfo(at, { encoding: "base64" }).send());
1288
+ return value !== null && value.executable;
1289
+ };
1290
+ const [engineThere, kitchenThere, potThere] = await Promise.all([
1291
+ program(engine(), "the engine program"),
1292
+ program(kitchen(), "the Kitchen program"),
1293
+ exists(rpc, url, pot, "the Pot"),
1294
+ ]);
1295
+ const fee = kitchenThere ? await kitchenFee(rpc, url).catch(() => undefined) : undefined;
1296
+ const there = (deployed) => (deployed ? "deployed" : "NOT deployed");
1297
+ return {
1298
+ json: {
1299
+ engine: { address: engine(), deployed: engineThere },
1300
+ kitchen: {
1301
+ address: kitchen(),
1302
+ deployed: kitchenThere,
1303
+ ...(fee === undefined ? {} : { executionFee: fee.toString() }),
1304
+ },
1305
+ pot: { address: pot, deployed: potThere },
1306
+ },
1307
+ notes: [
1308
+ `On the cluster: the engine ${engine()} is ${there(engineThere)}; the Kitchen ${kitchen()} ` +
1309
+ `is ${there(kitchenThere)}` +
1310
+ (fee === undefined ? "" : `, its execution fee ${fee} lamports`) +
1311
+ `; the Pot ${pot} is ${there(potThere)}.`,
1312
+ ...(kitchenThere && fee === undefined
1313
+ ? ["The Kitchen has no execution-fee config on this cluster: a cook there is refused."]
1314
+ : []),
1315
+ ],
1316
+ };
1317
+ }
1318
+ /** `sauce pot --chain solana` with an endpoint: the prediction, and what the cluster has. */
1319
+ export async function svmPotStatusCommand(target) {
1320
+ const predicted = await svmPotCommand(target);
1321
+ const pot = predicted.json.pot;
1322
+ const found = await deployment(createSolanaRpc(target.rpcUrl), target.rpcUrl, pot);
1323
+ const tokenAccounts = await svmPotTokenAccounts(target, target.rpcUrl, requireChain("solana"));
1324
+ const json = { ...predicted.json, deployment: found.json, tokenAccounts };
1325
+ const accountNotes = tokenAccounts.map((one) => `The Pot's ${one.symbol} account, --account NAME=pot:${one.symbol}: ${one.account}, ` +
1326
+ (one.balance === null
1327
+ ? "not created yet (a wallet's SPL transfer to the Pot creates it)"
1328
+ : `holding ${formatUnits(BigInt(one.balance), one.decimals)} ${one.symbol}`));
1329
+ return {
1330
+ text: JSON.stringify(json, null, 2),
1331
+ json,
1332
+ notes: [...found.notes, ...accountNotes],
1333
+ };
1334
+ }
1335
+ /** `sauce pot --deploy --chain solana`: creates the signer's Pot unless it is already there. */
1336
+ export async function svmPotDeployCommand(target) {
1337
+ requireSupported("creating a Pot", [requireChain("solana")]);
1338
+ const predicted = await svmPotCommand(target);
1339
+ const pot = predicted.json.pot;
1340
+ const rpc = createSolanaRpc(target.rpcUrl);
1341
+ if (await exists(rpc, target.rpcUrl, pot, "the Pot")) {
1342
+ const json = { ...predicted.json, deployed: true };
1343
+ return {
1344
+ text: JSON.stringify(json, null, 2),
1345
+ json,
1346
+ notes: [`Pot ${pot} is already created on solana.`],
1347
+ };
1348
+ }
1349
+ const sent = await sendInstructions(rpc, target.rpcUrl, target.signer, [createPotInstruction(target, pot)], "creating the Pot");
1350
+ if (sent.ok)
1351
+ await awaitAccount(rpc, target.rpcUrl, pot, "the Pot");
1352
+ const json = { ...predicted.json, deployed: sent.ok, createPot: sentJson(sent) };
1353
+ return {
1354
+ text: JSON.stringify(json, null, 2),
1355
+ json,
1356
+ notes: [sentLine(`created Pot ${pot} in`, sent)],
1357
+ ...(sent.ok ? {} : { exitCode: 1 }),
1358
+ };
1359
+ }
1360
+ //# sourceMappingURL=solana.js.map