@eco-incorp/sauce 0.99.1 → 0.99.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/LICENSE.md +29 -0
  2. package/README.md +69 -249
  3. package/actions/dist/to-sauce.d.ts.map +1 -1
  4. package/actions/dist/to-sauce.js +4 -5
  5. package/dev-tools/README.md +11 -170
  6. package/docs/README.md +39 -0
  7. package/docs/api/README.md +71 -0
  8. package/docs/api/compiler.md +234 -0
  9. package/docs/api/coverage.md +117 -0
  10. package/docs/api/routes.md +110 -0
  11. package/docs/concepts/architecture.md +134 -0
  12. package/docs/concepts/saucescript.md +172 -0
  13. package/docs/examples/README.md +34 -0
  14. package/docs/examples/compile-program.ts +20 -0
  15. package/docs/examples/evm-execution.ts +59 -0
  16. package/docs/examples/first-intent.ts +56 -0
  17. package/docs/examples/protocol-approval.ts +33 -0
  18. package/docs/guides/builders-and-actions.md +108 -0
  19. package/docs/guides/compiling.md +264 -0
  20. package/docs/guides/intents.md +158 -0
  21. package/docs/guides/nested-intents.md +79 -0
  22. package/docs/guides/protocols-and-tokens.md +116 -0
  23. package/docs/guides/quick-start.md +64 -0
  24. package/docs/guides/solana.md +196 -0
  25. package/docs/guides/verification.md +253 -0
  26. package/package.json +9 -4
  27. package/sdk/dist/artifacts/V12Deployments.json +23 -5
  28. package/sdk/dist/artifacts/V12RuntimeBytecode.json +1 -1
  29. package/sdk/dist/artifacts/svm/engine-devnet.so +0 -0
  30. package/sdk/dist/artifacts/svm/engine-mainnet.so +0 -0
  31. package/sdk/dist/artifacts/svm/engine-wire-devnet.json +3 -3
  32. package/sdk/dist/artifacts/svm/engine-wire-mainnet.json +3 -3
  33. package/sdk/dist/deployments/index.d.ts +14 -46
  34. package/sdk/dist/deployments/index.d.ts.map +1 -1
  35. package/sdk/dist/deployments/index.js +22 -47
  36. package/sdk/dist/deployments/index.js.map +1 -1
  37. package/sdk/dist/deployments/v12-addresses.d.ts +9 -5
  38. package/sdk/dist/deployments/v12-addresses.d.ts.map +1 -1
  39. package/sdk/dist/deployments/v12-addresses.js +5 -6
  40. package/sdk/dist/deployments/v12-addresses.js.map +1 -1
  41. package/sdk/dist/deployments/v12.generated.d.ts +3 -3
  42. package/sdk/dist/deployments/v12.generated.d.ts.map +1 -1
  43. package/sdk/dist/deployments/v12.generated.js +3 -3
  44. package/sdk/dist/deployments/v12.generated.js.map +1 -1
  45. package/sdk/dist/deposit/index.d.ts +28 -102
  46. package/sdk/dist/deposit/index.d.ts.map +1 -1
  47. package/sdk/dist/deposit/index.js.map +1 -1
  48. package/sdk/dist/deposit/params.d.ts +1 -1
  49. package/sdk/dist/deposit/params.js +2 -2
  50. package/sdk/dist/deposit/params.js.map +1 -1
  51. package/sdk/dist/deposit/source.d.ts +1 -1
  52. package/sdk/dist/deposit/source.d.ts.map +1 -1
  53. package/sdk/dist/deposit/source.js +18 -33
  54. package/sdk/dist/deposit/source.js.map +1 -1
  55. package/sdk/dist/deposit/types.d.ts +5 -4
  56. package/sdk/dist/deposit/types.d.ts.map +1 -1
  57. package/sdk/dist/evm/engine.d.ts +32 -0
  58. package/sdk/dist/evm/engine.d.ts.map +1 -1
  59. package/sdk/dist/evm/engine.js +2 -0
  60. package/sdk/dist/evm/engine.js.map +1 -1
  61. package/sdk/dist/index.d.ts +1 -0
  62. package/sdk/dist/index.d.ts.map +1 -1
  63. package/sdk/dist/index.js +2 -0
  64. package/sdk/dist/index.js.map +1 -1
  65. package/sdk/dist/plugin/index.d.ts +16 -41
  66. package/sdk/dist/plugin/index.d.ts.map +1 -1
  67. package/sdk/dist/plugin/index.js +2 -6
  68. package/sdk/dist/plugin/index.js.map +1 -1
  69. package/sdk/dist/recipes/index.js +2 -2
  70. package/sdk/dist/recipes/settle.sauce.ts +1 -1
  71. package/sdk/dist/routes/index.d.ts +3 -3
  72. package/sdk/dist/routes/index.js +3 -3
  73. package/sdk/dist/routes/intent-dsl.d.ts +23 -10
  74. package/sdk/dist/routes/intent-dsl.d.ts.map +1 -1
  75. package/sdk/dist/routes/intent-dsl.js +19 -2
  76. package/sdk/dist/routes/intent-dsl.js.map +1 -1
  77. package/sdk/dist/routes/nest.d.ts +23 -0
  78. package/sdk/dist/routes/nest.d.ts.map +1 -1
  79. package/sdk/dist/routes/nest.js +2 -4
  80. package/sdk/dist/routes/nest.js.map +1 -1
  81. package/sdk/dist/routes/protocol-rewrite.d.ts +2 -2
  82. package/sdk/dist/routes/protocol-rewrite.d.ts.map +1 -1
  83. package/sdk/dist/routes/protocol-rewrite.js +19 -35
  84. package/sdk/dist/routes/protocol-rewrite.js.map +1 -1
  85. package/sdk/dist/routes/sauce-calls.d.ts +7 -13
  86. package/sdk/dist/routes/sauce-calls.d.ts.map +1 -1
  87. package/sdk/dist/routes/sauce-calls.js +6 -11
  88. package/sdk/dist/routes/sauce-calls.js.map +1 -1
  89. package/sdk/dist/routes/sauce-route.d.ts +24 -53
  90. package/sdk/dist/routes/sauce-route.d.ts.map +1 -1
  91. package/sdk/dist/routes/sauce-route.js +5 -6
  92. package/sdk/dist/routes/sauce-route.js.map +1 -1
  93. package/sdk/dist/routes/source-globals.generated.d.ts +931 -0
  94. package/sdk/dist/routes/source-globals.generated.d.ts.map +1 -0
  95. package/sdk/dist/routes/source-globals.generated.js +7 -0
  96. package/sdk/dist/routes/source-globals.generated.js.map +1 -0
  97. package/sdk/dist/std/token/token.svm.js +19 -14
  98. package/sdk/dist/svm/cpi-probe.d.ts +1 -1
  99. package/sdk/dist/svm/cpi-probe.d.ts.map +1 -1
  100. package/sdk/dist/svm/cpi-probe.js +5 -2
  101. package/sdk/dist/svm/cpi-probe.js.map +1 -1
  102. package/sdk/dist/svm/intent.d.ts +12 -40
  103. package/sdk/dist/svm/intent.d.ts.map +1 -1
  104. package/sdk/dist/svm/intent.js +22 -66
  105. package/sdk/dist/svm/intent.js.map +1 -1
  106. package/sdk/dist/svm/venues/byreal/index.d.ts.map +1 -1
  107. package/sdk/dist/svm/venues/byreal/index.js +4 -1
  108. package/sdk/dist/svm/venues/byreal/index.js.map +1 -1
  109. package/sdk/dist/svm/venues/carrot/index.d.ts.map +1 -1
  110. package/sdk/dist/svm/venues/carrot/index.js +4 -0
  111. package/sdk/dist/svm/venues/carrot/index.js.map +1 -1
  112. package/sdk/dist/svm/venues/cropper/index.d.ts +1 -1
  113. package/sdk/dist/svm/venues/cropper/index.js +1 -1
  114. package/sdk/dist/svm/venues/huma/index.d.ts.map +1 -1
  115. package/sdk/dist/svm/venues/huma/index.js +4 -1
  116. package/sdk/dist/svm/venues/huma/index.js.map +1 -1
  117. package/sdk/dist/svm/venues/index.d.ts +1 -0
  118. package/sdk/dist/svm/venues/index.d.ts.map +1 -1
  119. package/sdk/dist/svm/venues/index.js +1 -0
  120. package/sdk/dist/svm/venues/index.js.map +1 -1
  121. package/sdk/dist/svm/venues/math.d.ts +4 -1
  122. package/sdk/dist/svm/venues/math.d.ts.map +1 -1
  123. package/sdk/dist/svm/venues/math.js +4 -1
  124. package/sdk/dist/svm/venues/math.js.map +1 -1
  125. package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.d.ts.map +1 -1
  126. package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.js +4 -1
  127. package/sdk/dist/svm/venues/meteora-damm-v1-stable/index.js.map +1 -1
  128. package/sdk/dist/svm/venues/meteora-damm-v2/index.d.ts.map +1 -1
  129. package/sdk/dist/svm/venues/meteora-damm-v2/index.js +5 -2
  130. package/sdk/dist/svm/venues/meteora-damm-v2/index.js.map +1 -1
  131. package/sdk/dist/svm/venues/obric-v2/index.d.ts.map +1 -1
  132. package/sdk/dist/svm/venues/obric-v2/index.js +16 -5
  133. package/sdk/dist/svm/venues/obric-v2/index.js.map +1 -1
  134. package/sdk/dist/svm/venues/oracle-exponent.d.ts +82 -0
  135. package/sdk/dist/svm/venues/oracle-exponent.d.ts.map +1 -0
  136. package/sdk/dist/svm/venues/oracle-exponent.js +97 -0
  137. package/sdk/dist/svm/venues/oracle-exponent.js.map +1 -0
  138. package/sdk/dist/svm/venues/orca-legacy-token-swap/index.d.ts.map +1 -1
  139. package/sdk/dist/svm/venues/orca-legacy-token-swap/index.js +4 -1
  140. package/sdk/dist/svm/venues/orca-legacy-token-swap/index.js.map +1 -1
  141. package/sdk/dist/svm/venues/pumpswap/index.d.ts.map +1 -1
  142. package/sdk/dist/svm/venues/pumpswap/index.js +19 -13
  143. package/sdk/dist/svm/venues/pumpswap/index.js.map +1 -1
  144. package/sdk/dist/svm/venues/raydium-amm-v4/index.d.ts.map +1 -1
  145. package/sdk/dist/svm/venues/raydium-amm-v4/index.js +4 -1
  146. package/sdk/dist/svm/venues/raydium-amm-v4/index.js.map +1 -1
  147. package/sdk/dist/svm/venues/raydium-clmm/index.d.ts.map +1 -1
  148. package/sdk/dist/svm/venues/raydium-clmm/index.js +4 -1
  149. package/sdk/dist/svm/venues/raydium-clmm/index.js.map +1 -1
  150. package/sdk/dist/svm/venues/raydium-cp-swap/index.d.ts.map +1 -1
  151. package/sdk/dist/svm/venues/raydium-cp-swap/index.js +4 -1
  152. package/sdk/dist/svm/venues/raydium-cp-swap/index.js.map +1 -1
  153. package/sdk/dist/svm/venues/scorch/index.d.ts.map +1 -1
  154. package/sdk/dist/svm/venues/scorch/index.js +4 -1
  155. package/sdk/dist/svm/venues/scorch/index.js.map +1 -1
  156. package/sdk/dist/svm/venues/stabble-common.d.ts +1 -1
  157. package/sdk/dist/svm/venues/stabble-common.js +1 -1
  158. package/sdk/dist/svm/venues/types.d.ts +4 -1
  159. package/sdk/dist/svm/venues/types.d.ts.map +1 -1
  160. package/sdk/dist/svm/venues/woofi/index.d.ts.map +1 -1
  161. package/sdk/dist/svm/venues/woofi/index.js +4 -0
  162. package/sdk/dist/svm/venues/woofi/index.js.map +1 -1
  163. package/sdk/dist/svm/verify.d.ts +27 -133
  164. package/sdk/dist/svm/verify.d.ts.map +1 -1
  165. package/sdk/dist/svm/verify.js +72 -139
  166. package/sdk/dist/svm/verify.js.map +1 -1
  167. package/sdk/dist/swap/index.d.ts +16 -59
  168. package/sdk/dist/swap/index.d.ts.map +1 -1
  169. package/sdk/dist/swap/index.js +16 -59
  170. package/sdk/dist/swap/index.js.map +1 -1
  171. package/sdk/dist/token/source.d.ts.map +1 -1
  172. package/sdk/dist/token/source.js +4 -1
  173. package/sdk/dist/token/source.js.map +1 -1
  174. package/sdk/dist/verify/decode.d.ts +6 -6
  175. package/sdk/dist/verify/decode.js +7 -7
  176. package/sdk/dist/verify/index.js +2 -2
  177. package/sdk/dist/verify/intent.js +2 -2
  178. package/sdk/dist/verify/vectors.d.ts +1 -1
  179. package/sdk/dist/verify/vectors.d.ts.map +1 -1
  180. package/sdk/dist/verify/vectors.js +2 -2
  181. package/sdk/dist/verify/vectors.js.map +1 -1
  182. package/sdk/dist/verify/wire.d.ts +5 -4
  183. package/sdk/dist/verify/wire.d.ts.map +1 -1
  184. package/sdk/dist/verify/wire.js +5 -4
  185. package/sdk/dist/verify/wire.js.map +1 -1
@@ -0,0 +1,71 @@
1
+ # API reference
2
+
3
+ Install `@eco-incorp/sauce` and import through the package's public entry points. All paths below
4
+ are suffixes of that package name; `.` means `@eco-incorp/sauce` itself.
5
+
6
+ | Import | Contents |
7
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
8
+ | `.` | `routes`, `token`, `swap`, `deposit`, `contracts`, `svmVenues`; protocol and chain queries; installation of chain globals |
9
+ | `/compiler` | `compile`, compiler types, `encodeCompactArguments`, and `decodeCompactArguments` |
10
+ | `/actions` | Action primitives and `actionsToSauce` composition |
11
+ | `/protocols/*` | One protocol's `protocolInfo`, `deployments`, ABI exports, and named SauceScript templates |
12
+ | `/chains` | Canonical chain identities and EVM chain metadata |
13
+ | `/deployments` | Sauce engine/Kitchen addresses, Pot derivation inputs, and recorded deployment coverage |
14
+ | `/recipes` | EVM settlement source and CCTP/plain-transfer recipe builders and sources |
15
+ | `/recipes/settle.sauce.ts` | EVM settlement source asset |
16
+ | `/svm` | SVM clients, account plans, resolution, staging, Kitchen instructions, recipes, and transactions |
17
+ | `/svm/engine` | SVM engine wire format and instruction builders |
18
+ | `/svm/engine-artifacts` | Node helpers locating packaged SVM engine/Kitchen binaries and IDL |
19
+ | `/svm/verify` | SVM program and gated engine CPI verification; separate Kitchen decoding is required |
20
+ | `/svm/recipes/settle.sauce.ts` | SVM settlement source asset |
21
+ | `/evm/engine` | EVM Pot and Kitchen ABIs and call encoders (`v12PotAbi`, `v12KitchenAbi`, `v12Pot`, `v12Kitchen`) |
22
+ | `/verify` | EVM settlement encoding, structural decoding, and validation against the pinned program |
23
+ | `/skills` | Protocol Markdown index and skill-file loaders |
24
+
25
+ The [`exports` map](../../package.json) defines this list. There is no `/routes`, `/token`,
26
+ `/swap`, `/deposit`, or `/contracts` subpath; import these namespaces from the root:
27
+
28
+ ```ts
29
+ import { routes, token, contracts } from "@eco-incorp/sauce";
30
+ import { compile } from "@eco-incorp/sauce/compiler";
31
+ ```
32
+
33
+ `Base`, `Solana`, `chain`, and `Token` are installed globals, rather than named root exports.
34
+ Bare protocol and token globals such as `Uniswap` and `USDC` describe compiled route source and
35
+ have no corresponding host JavaScript objects. See
36
+ [protocols and tokens](../guides/protocols-and-tokens.md).
37
+
38
+ ## Detailed references
39
+
40
+ - [Compiler](compiler.md): direct compilation, result metadata, compact argument encoding.
41
+ - [Routes](routes.md): compile options, intent construction, nested execution, and submission helpers.
42
+ - [Coverage](coverage.md): distinguish catalog entries, callable descriptors, and available deployments.
43
+
44
+ For structured program creation, see [builders and actions](../guides/builders-and-actions.md).
45
+ For account-based execution and settlement checks, see the [Solana](../guides/solana.md) and
46
+ [verification](../guides/verification.md) guides.
47
+
48
+ ## Protocol resources
49
+
50
+ ```ts
51
+ import { getProtocol, getProtocolsByChain, listProtocols } from "@eco-incorp/sauce";
52
+ import { PoolABI } from "@eco-incorp/sauce/protocols/aave-v3";
53
+ import { getProtocolIndex, getProtocolSkill, listSkillSlugs } from "@eco-incorp/sauce/skills";
54
+
55
+ const baseProtocols = getProtocolsByChain(8453);
56
+ const aave = getProtocol("aave-v3");
57
+ const protocols = listProtocols();
58
+ const indexMarkdown = getProtocolIndex();
59
+ const aaveMarkdown = getProtocolSkill("aave-v3");
60
+ const availableSkills = listSkillSlugs();
61
+ ```
62
+
63
+ Skill resources are documentation strings; loading one performs no protocol operation.
64
+ `getProtocolSkill` throws for a slug absent from `listSkillSlugs()`.
65
+
66
+ ## Runtime requirements
67
+
68
+ The root SDK, its route compiler integration, recipe source loaders, skill loaders, and artifact
69
+ resolvers use Node.js APIs. `/verify` has a `viem`-only dependency closure and can validate EVM
70
+ settlement payloads in a browser without loading the compiler. See the
71
+ [compiler reference](compiler.md) for the compiler dependency's separate browser entry point.
@@ -0,0 +1,234 @@
1
+ # Compiler API
2
+
3
+ [Documentation](../README.md) · [Compiling programs](../guides/compiling.md)
4
+
5
+ `@eco-incorp/sauce/compiler` exposes the published Rust/WASM compiler to Node
6
+ consumers and supplies the SDK's compact argument codec.
7
+
8
+ ```ts
9
+ import {
10
+ compile,
11
+ encodeCompactArguments,
12
+ decodeCompactArguments,
13
+ type CompileOptions,
14
+ type CompileResult,
15
+ } from "@eco-incorp/sauce/compiler";
16
+ ```
17
+
18
+ The compiler is installed with the SDK. This reference and its examples are
19
+ validated with `@eco-incorp/sauce-compiler` **2.3.0**.
20
+
21
+ ## `compile(options): CompileResult`
22
+
23
+ Compilation is synchronous. The host supplies source and dependency bytes through
24
+ callbacks; the compiler does not fetch a filesystem path or network URL itself.
25
+
26
+ ```ts
27
+ const source = new TextEncoder().encode(`
28
+ function main(amount: Uint256): Uint256 {
29
+ return amount + 1n;
30
+ }
31
+ `);
32
+
33
+ const artifact = compile({
34
+ target: "evm",
35
+ entry: "main.ts",
36
+ resolve: (path) => (path === "main.ts" ? source : undefined),
37
+ });
38
+
39
+ console.log(artifact.bytecode, artifact.isaRevision, artifact.entryEncoding);
40
+ ```
41
+
42
+ ### Options
43
+
44
+ | Field | Type | Meaning |
45
+ | ----------------- | ------------------------------------------------------ | ---------------------------------------------------------------------- |
46
+ | `target` | `"evm" \| "svm"` | Required target runtime |
47
+ | `resolve` | `(path: string) => Uint8Array \| undefined \| null` | Required synchronous module/JSON resolver |
48
+ | `entry` | `string` | Entry module; default `"main.js"` |
49
+ | `resolvePackage` | `(specifier, importer) => string \| undefined \| null` | Map a bare package specifier to a path understood by `resolve` |
50
+ | `contracts` | `[name, path][]` | Register entry-module ABI bindings by resolver path |
51
+ | `inlineContracts` | `[name, abiJson][]` | Register entry-module ABI bindings from JSON strings |
52
+ | `ambient` | `string[]` | Resolve libraries and broadcast their exports into every module |
53
+ | `defines` | `[name, value][]` | Program-wide scalar compile-time constants; values are integer strings |
54
+ | `optimize` | `boolean` | Enable compiler optimizations; default `true` |
55
+ | `compactArgs` | `boolean` | Use compact-v1 entry arguments; default `false` |
56
+ | `cache` | `boolean` | Enable the per-function lowering cache; default `true` |
57
+
58
+ `optimize: false` disables optimizations such as constant folding, loop unrolling,
59
+ common-subexpression elimination, and helper inlining. Validation still runs.
60
+
61
+ `defines` accepts decimal or `0x` integer strings, with supported literal
62
+ separators and an optional trailing `n`. Use strings so the JavaScript host does
63
+ not round 256-bit values. A repeated name is an error. A define replaces a
64
+ module's same-named `const`; incompatible declarations, such as a module-level
65
+ `let` or a function, are errors. Function-local declarations can shadow it.
66
+
67
+ An ambient export yields to a module's own declarations, imports, and bindings.
68
+ Two ambient modules exporting the same name are an error. Ambient libraries must
69
+ be resolvable SauceScript modules and cannot supply an entry `main`.
70
+
71
+ ### Resolver contract
72
+
73
+ Return bytes for an existing module. Return `undefined` or `null` for a missing
74
+ candidate; this lets resolution try a neutral module when a target-specific arm
75
+ does not exist. Throw when resolving an existing resource fails and compilation
76
+ must stop. The compiler propagates that failure rather than treating it as a
77
+ missing arm.
78
+
79
+ Paths can retain `./`, and dependencies are resolved in the importing module's
80
+ context. An in-memory map must serve the paths actually requested. A filesystem
81
+ resolver can resolve candidates relative to a known root. Serve JSON bytes as
82
+ well as source bytes: bare JSON imports denote ABIs, while
83
+ `with { type: "json" }` imports JSON data.
84
+
85
+ For a package with a neutral entry such as `token.js`, resolution can probe
86
+ `token.evm.js` or `token.svm.js` according to the target. Supply the neutral
87
+ specifier and let the compiler select the arm.
88
+
89
+ ### Result
90
+
91
+ ```ts
92
+ interface CompileResult {
93
+ bytecode: Uint8Array;
94
+ isaRevision: "stack-compact-v2";
95
+ entryEncoding: "abi-v1" | "compact-v1";
96
+ entrySchema?: Uint8Array;
97
+ manifest?: AccountManifest;
98
+ }
99
+ ```
100
+
101
+ - `bytecode` is one reusable program. Per-execution argument values have not been
102
+ appended.
103
+ - `isaRevision` identifies the compiler's instruction-set contract. It does not
104
+ check which runtime is deployed at an address.
105
+ - `entryEncoding` selects the argument encoder: ordinary ABI arguments by
106
+ default, compact arguments when `compactArgs: true`. It does not describe
107
+ [program return encoding](../guides/compiling.md#encode-evm-return-values).
108
+ - `entrySchema` describes compact argument structure. Pass this exact schema to
109
+ the compact codec; do not infer or rebuild it from example bytes.
110
+ - `manifest` is present for SVM and describes attached accounts. It is absent
111
+ for EVM.
112
+
113
+ Compilation and resolution failures throw a JavaScript `Error`. Source diagnostics
114
+ include a location and span; option, resolver, and target-capability errors may
115
+ have neither. A resolver callback's thrown message is preserved. There is no
116
+ success-with-error result or warning array in this API.
117
+
118
+ ### SVM account manifest
119
+
120
+ `AccountManifest.accounts` contains these entries:
121
+
122
+ ```ts
123
+ type AccountEntry =
124
+ | {
125
+ kind: "slot";
126
+ index: number;
127
+ name: string;
128
+ requires: "readonly" | "writable" | "readonly_signer" | "writable_signer";
129
+ }
130
+ | { kind: "remaining"; from: number };
131
+ ```
132
+
133
+ Slots correspond to `main`'s `Account` parameters. Their roles are declarations
134
+ made by the author, not permissions inferred by examining a CPI callee. A
135
+ `remaining` entry marks the start of the variable account tail when the source
136
+ uses it. SVM `Account` parameters do not occupy compact argument fields.
137
+
138
+ The subpath also exports `AccountEntry`, `AccountManifest`, `AccountRole`,
139
+ `CompileOptions`, `CompileResult`, `ResolveModule`, `ResolvePackage`, and
140
+ `SauceTarget` as types from the compiler package.
141
+
142
+ ## Compact argument codec
143
+
144
+ ```ts
145
+ encodeCompactArguments(schema: Uint8Array, value: CompactValue): Uint8Array;
146
+
147
+ decodeCompactArguments(
148
+ schema: Uint8Array,
149
+ data: Uint8Array,
150
+ options?: { maxValues?: number },
151
+ ): CompactValue;
152
+ ```
153
+
154
+ `CompactValue` accepts `bigint`, safe integer `number`, `boolean`, integer or hex
155
+ `string`, `Uint8Array`, and recursively nested positional arrays.
156
+
157
+ For a compiled entry, the root value is an array containing its arguments in
158
+ declaration order. Omit `Account` parameters only on SVM, where accounts are
159
+ attached separately; EVM `Account` parameters are encoded as scalars. For
160
+ `main(account: Account, amount: Uint256)`, pass `[account, amount]` on EVM and
161
+ `[amount]` on SVM. Nested records are positional arrays too.
162
+ `bytes` values accept a `Uint8Array` or an even-length `0x` hex string. Scalar
163
+ addresses/public keys are integers or hexadecimal integers; base58 public-key
164
+ text is not a scalar encoding.
165
+
166
+ The encoder emits compact-v1 data beginning with `53 41 01 00`, minimum-width
167
+ 256-bit scalars, canonical booleans, unpadded bytes, and big-endian collection
168
+ lengths. Negative integers preserve their 256-bit two's-complement bit pattern.
169
+ The decoder returns scalar words as unsigned `bigint`, booleans as `boolean`,
170
+ bytes as `Uint8Array`, and collections as arrays. It does not recover a signed
171
+ application type from a scalar word.
172
+
173
+ The decoder rejects non-minimal scalars, non-canonical booleans, malformed or
174
+ truncated lengths, and trailing data. `maxValues` bounds its decoded value graph
175
+ and defaults to `1_000_000`. Schemas are limited to 65,535 bytes and 32 nested
176
+ levels. The engine applies its own heap and execution limits as well; successful
177
+ host encoding does not establish that a payload fits a transaction or runtime.
178
+
179
+ Compact-v1 changes **program entry arguments**. EVM contract calls made by the
180
+ program still use their contract ABIs. The SDK's canonical EVM settlement verifier
181
+ currently expects its pinned ABI-v1 settlement payload, not a compact recompile.
182
+
183
+ ## Raw compiler versus route compilation
184
+
185
+ `routes.compileSauceRoute()` is a separate SDK API with a source string,
186
+ destination, execution settings, and `SauceCompileOptions`. It supplies registry
187
+ rewrites and call encoding. Its result is:
188
+
189
+ ```ts
190
+ {
191
+ calls: readonly CallInput[];
192
+ compiled: { bytecode: Uint8Array[]; warnings: string[] };
193
+ source: string;
194
+ }
195
+ ```
196
+
197
+ There is one compiled segment and one route call. `source` is the SDK-rewritten
198
+ program; the internal compiler adapter can additionally annotate a falling-through
199
+ `main` as `void`. `warnings` is currently empty: compilation failures throw.
200
+
201
+ The route adapter does not return the raw compiler's ISA metadata, entry schema,
202
+ or SVM manifest, and its options do not expose `compactArgs`, `cache`, or
203
+ `optimize`. Use raw `compile()` when you need those fields, explicit runtime
204
+ parameters, or the compiler's full resolver control. Route `target: "v1"` is a
205
+ compatibility spelling mapped to the same EVM backend as `"v12"`.
206
+
207
+ See [routes](routes.md) for the route-specific API.
208
+
209
+ ## Node, browsers, and compiler-only features
210
+
211
+ The SDK requires Node **24 or newer**. Its `/compiler` export loads the compiler
212
+ through Node's `createRequire`; SDK route compilation also uses filesystem and
213
+ path APIs. These integrations are Node APIs.
214
+
215
+ The underlying compiler package separately supplies Node and browser builds.
216
+ For a browser application, install `@eco-incorp/sauce-compiler` directly and use
217
+ its initialization API:
218
+
219
+ ```ts
220
+ import { ready } from "@eco-incorp/sauce-compiler/ready";
221
+
222
+ const { compile } = await ready();
223
+ // Supply source/dependencies through synchronous in-memory resolvers.
224
+ ```
225
+
226
+ `ready()` initializes the browser WASM build and is a no-op for the already
227
+ initialized Node build. Arrange for the compiler's WASM asset and dependency
228
+ bytes to be available before compiling. This does not provide the SDK's route
229
+ rewrites or registry resolver in a browser.
230
+
231
+ The compiler package also exports `clearFunctionCache()` and
232
+ `functionCacheStats()`. The SDK `/compiler` barrel does not re-export them or
233
+ `ready()`. Applications using these compiler-only exports should declare the
234
+ compiler as a direct dependency and import from its published package name.
@@ -0,0 +1,117 @@
1
+ # Registry and global namespace coverage
2
+
3
+ The SDK has several registries with different purposes. A protocol catalog entry does not
4
+ necessarily have a global contract accessor or a deployment on your selected chain.
5
+
6
+ | Registry | Current scope | Inspect it |
7
+ | -------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
8
+ | Protocol catalog | 129 protocols with metadata, deployments, ABI fragments, and program templates | `listProtocols()`, `getProtocol(slug)`, `getProtocolsByChain(id)` |
9
+ | Contract descriptors | 30 descriptors across 16 protocol/interface namespaces | `contracts.listDescriptors()`, `contracts.listContracts(slug)` |
10
+ | Compiled-source protocol globals | 26 singleton contract leaves across 14 protocol namespaces, plus 5 family aliases | TypeScript completion after importing `@eco-incorp/sauce`; names below |
11
+ | Token symbols | 5 symbols distributed across 6 EVM chains | `routes.TOKEN_REGISTRY`, `routes.knownTokenSymbols(chain)` |
12
+ | Canonical chain identities | 40 chains: 39 EVM and Solana | `CANONICAL_CHAINS`, `requireChain(ref)` |
13
+ | EVM chain metadata | 33 records with RPC and explorer information | `chains`, `getChain(id)`, `getAllChainIds()` |
14
+
15
+ The descriptor registry connects each supported address role to an ABI and a contract name.
16
+ Use `contracts.listDescriptors()` to inspect these curated associations; they cannot be
17
+ inferred reliably for every catalog entry.
18
+
19
+ ## Protocol globals
20
+
21
+ These names are available inside compiled EVM route bodies. Availability on the destination chain
22
+ is checked during compilation. The declarations describe the vendored ABI surface, which is a
23
+ subset of each protocol's complete API.
24
+
25
+ | Namespace | Contract leaves |
26
+ | --------------- | ------------------------------------------------------------------------------------- |
27
+ | `UniswapV2` | `Factory`, `Router` |
28
+ | `UniswapV3` | `Factory`†, `SwapRouter`†, `SwapRouter02`†, `QuoterV2`†, `NonfungiblePositionManager` |
29
+ | `UniswapV4` | `PoolManager`†, `UniversalRouter`, `PositionManager` |
30
+ | `SushiswapV2` | `Factory`, `Router` |
31
+ | `PancakeswapV2` | `Factory`, `Router` |
32
+ | `Aerodrome` | `Router`, `PoolFactory` |
33
+ | `Cctp` | `TokenMessenger` |
34
+ | `AaveV3` | `Pool` |
35
+ | `AaveV2` | `LendingPool` |
36
+ | `Permit2` | `Permit2` |
37
+ | `Oneinch` | `AggregationRouterV6` |
38
+ | `Pendle` | `Router` |
39
+ | `MorphoBlue` | `Morpho` |
40
+ | `CompoundV3` | `CometUSDC`, `CometWETH`, `CometUSDT` |
41
+
42
+ † These descriptors have **widened ABI types** whose selectors differ from the deployed contract.
43
+ Compilation refuses them by default, with an explanation in `descriptor.coverage.caveats`.
44
+ `compile.accessors.allowWidenedSelectors: true` only bypasses that check; it does not repair the
45
+ ABI or make the resulting call valid.
46
+
47
+ Family aliases are `Uniswap`, `Sushiswap`, `Pancakeswap`, `Aave`, and `Compound`. A family exposes
48
+ a contract only when exactly one member owns its name. Consequently:
49
+
50
+ - `Uniswap.UniversalRouter` resolves to `UniswapV4.UniversalRouter`.
51
+ - `Uniswap.Factory` is ambiguous; use a versioned namespace.
52
+ - `UniswapV3.UniversalRouter` is absent from this registry.
53
+ - A family always requires a contract name, even when it has one protocol member.
54
+
55
+ A protocol with exactly one callable contract also supports a shortcut such as
56
+ `Cctp.depositForBurn(...)` or `AaveV3.supply(...)`. See
57
+ [protocols and tokens](../guides/protocols-and-tokens.md) for argument conventions and examples.
58
+
59
+ The four remaining descriptors are available for host-side discovery: `AaveV3.PoolAddressesProvider`
60
+ and `MorphoBlue.Bundler3` have addresses but no vendored ABI; `Erc20.ERC20` and
61
+ `Erc4626.ERC4626Vault` are unbound interfaces. They are excluded from source globals. Use
62
+ `Token(address)` for route-body ERC-20 calls or supply a contract ABI directly to the compiler.
63
+
64
+ ## Tokens
65
+
66
+ The exported `routes.TOKEN_REGISTRY` contains:
67
+
68
+ | Chain | ID | Symbols |
69
+ | -------- | ----- | ---------------------- |
70
+ | Ethereum | 1 | `USDC`, `USDT`, `WETH` |
71
+ | Optimism | 10 | `USDC`, `USDT`, `WETH` |
72
+ | Polygon | 137 | `USDC`, `WETH`, `WPOL` |
73
+ | Monad | 143 | `USDC`, `WMON` |
74
+ | Base | 8453 | `USDC`, `WETH` |
75
+ | Arbitrum | 42161 | `USDC`, `WETH` |
76
+
77
+ A missing symbol means the registry has no verified row under that name. Token variants can have
78
+ different symbols and addresses. `IntentOptions.tokenDefines` or `SauceCompileOptions.tokens`
79
+ can override or add a chain-local mapping. Amounts are integer token units; the compiler does not
80
+ apply decimal scaling.
81
+
82
+ ```ts
83
+ import { requireChain, routes } from "@eco-incorp/sauce";
84
+
85
+ const base = requireChain("base");
86
+ routes.knownTokenSymbols(base); // ["USDC", "WETH"]
87
+ routes.registryTokenAddress(base, "USDC"); // bigint address, or undefined if absent
88
+ ```
89
+
90
+ These ERC-20 source globals target EVM. Use the [Solana account and token helpers](../guides/solana.md)
91
+ for SPL tokens.
92
+
93
+ ## Host discovery and chain coverage
94
+
95
+ ```ts
96
+ import { contracts } from "@eco-incorp/sauce";
97
+
98
+ const router = contracts.on("base").Uniswap.UniversalRouter;
99
+ router.available;
100
+ router.address;
101
+ router.methods;
102
+ router.coverage;
103
+
104
+ const resolved = contracts.describeContract("base", "uniswap-v4", "UniversalRouter");
105
+ const onBase = contracts.contractsOnChain("base");
106
+ ```
107
+
108
+ Host accessors such as `Base.Uniswap.UniversalRouter` and `contracts.on(...)` build inert
109
+ `ContractCall` objects when their methods are invoked. Their dynamic method properties are currently
110
+ typed `unknown`; TypeScript callers must narrow or cast a method before calling it. This is distinct
111
+ from the generated ABI method types on bare protocol names inside compiled source.
112
+
113
+ Use `requireChain` for route identities. The separate metadata lookup `getChain` does not currently
114
+ include Unichain, Monad, Sonic, Ronin, Plasma, or Ink, although they are canonical chains. Chain
115
+ identity, protocol availability, and Sauce engine deployment are separate checks. Deployment helpers
116
+ expose recorded addresses and coverage; applications still need a live deployment suitable for their
117
+ execution path.
@@ -0,0 +1,110 @@
1
+ # Routes API
2
+
3
+ [Documentation](../README.md) · [Create an intent](../guides/intents.md) · [Compiler](compiler.md)
4
+
5
+ Import the routes namespace from the package root:
6
+
7
+ ```ts
8
+ import { routes } from "@eco-incorp/sauce";
9
+
10
+ const destination = routes.chain("base");
11
+ ```
12
+
13
+ There is no published `/routes` subpath. Public route types are available as `routes.IntentOptions`, `routes.BuiltIntent`, and other members of this namespace.
14
+
15
+ ## Chain entry points
16
+
17
+ | Entry point | Result |
18
+ | -------------------------------------- | ------------------------------------------------- |
19
+ | `Base(body, options)` | Pending destination route awaiting `.reward(...)` |
20
+ | `Base.route(body, options)` | Same behavior as the callable chain |
21
+ | `routes.chain(ref)` | Chain route entry point for a chain reference |
22
+ | `routes.chainAccessors.Base` | Explicit access to the route chain entry point |
23
+ | `routes.openRoute(ref, body, options)` | Direct function behind chain entry points |
24
+
25
+ Chain references accept canonical slugs, names/aliases supported by the registry, numeric chain IDs, and canonical chain records. `.chain` exposes the canonical record. Root import installs the composed globals, which also expose host contract/venue accessors; `routes.chain(...)` is the route entry point.
26
+
27
+ `body` accepts a source string or a synchronous zero-argument callback. A string can contain a full `function main(...)` or a bare body. A callback supplies source text, with no JavaScript capture. See [callback semantics](../guides/intents.md#callbacks-are-compiled-source).
28
+
29
+ ## Intent options
30
+
31
+ | Option | Purpose |
32
+ | ----------------------------------------------- | ------------------------------------------------------------------------------------ |
33
+ | `execution` | EVM `{ pot, engine, value? }`; SVM route calls cannot execute on the released engine |
34
+ | `pot`, `engine` | EVM shorthand instead of `execution`; both are required together |
35
+ | `portal`, `deadline` | Required destination Portal and absolute route deadline |
36
+ | `salt` | Route salt; defaults to 32 zero bytes |
37
+ | `tokens`, `nativeAmount` | Solver-delivered destination assets |
38
+ | `precalls` | Calls before the compiled program and nested calls |
39
+ | `tokenDefines` | Token-symbol address overrides |
40
+ | `defines`, `compile` | Program specialization and compile options |
41
+ | `sourcePortal` | Default source Portal for submission/read requests |
42
+ | `source`, `creator`, `prover`, `rewardDeadline` | Fallback fields for `.reward(...)` |
43
+
44
+ The EVM shorthand sends zero `cook` value and only works with a fee-free Kitchen when the program needs no native input. For released deployments, use `execution: { pot, engine, value }` with the current Kitchen fee plus any native assets the program spends, and budget `nativeAmount` for all route call values. The direct route's Pot owner must equal the destination `Portal.executor()`. See [deployment and fee setup](../guides/intents.md#prepare-the-destination-pot).
45
+
46
+ `.reward(...)` accepts an object, a native amount as `bigint`, or an array of `{ token, amount }`. Object fields override option fallbacks. `source`, `creator`, and `prover` must resolve from one of those places. Reward deadline resolution is `reward.deadline`, then `options.rewardDeadline`, then `options.deadline`. Native and token amounts default to zero/empty where omitted.
47
+
48
+ The compiler needs no source reward to compile a destination program. Use `compileSauceRoute` when you only need destination calls.
49
+
50
+ ## Compile a destination route
51
+
52
+ ```ts
53
+ import { routes } from "@eco-incorp/sauce";
54
+
55
+ export function compileProgram(execution: routes.SauceEvmExecutionInput) {
56
+ return routes.compileSauceRoute("base", "return 7n;", execution);
57
+ }
58
+ ```
59
+
60
+ `compileSauceRoute(destination, source, execution, options?)` returns:
61
+
62
+ | Field | Contents |
63
+ | ---------- | --------------------------------------------------------------------- |
64
+ | `calls` | Destination call inputs, normally one call for one program |
65
+ | `compiled` | Route compatibility result with `bytecode: Uint8Array[]` and warnings |
66
+ | `source` | Source after wrapping and SDK token/protocol rewrites |
67
+
68
+ The route wrapper differs from the direct `/compiler` API, which returns one byte array plus compiler metadata and an optional SVM account manifest. Use the direct API when you need that metadata. The route target defaults to `"v12"` for EVM and `"svm"` for SVM; direct compiler targets are `"evm"` and `"svm"`.
69
+
70
+ `SauceCompileOptions` supports `baseDirs`, scalar `defines`, token-address `tokens`, ABI `contracts`, `ambient` module names, and `accessors`. Accessor rewriting defaults on; an options object can configure qualified-chain scope or other rewrite behavior. `openRoute` merges chain defaults and the default ambient token module. Direct `compileSauceRoute` performs token/protocol rewrites but does not automatically merge that ambient module.
71
+
72
+ The route wrapper has no runtime argument-payload parameter. Use compile-time defines here, or direct compilation and a suitable execution API for parameterized entry points; see [compiler integration](compiler.md).
73
+
74
+ ## Already compiled programs
75
+
76
+ `buildSauceEvmCall({ pot, engine, program, value? })` builds one Pot `cook` call; `program` is a hex string. `value` defaults to zero and must include the Kitchen fee. `buildSauceEvmCalls({ pot, engine, cooks, value? })` applies that value to **each** ordered cook. Multiple statements within one program need only one cook and fee.
77
+
78
+ ## Deployment addresses
79
+
80
+ `sauceEvmDeployPotCall({ owner, salt, kitchen })` encodes Pot deployment through the supplied Kitchen; direct intent routes use the destination `Portal.executor()` as owner. Its `chainId` alternative selects the pinned release Kitchen only for chains in the historical successful-deployment roster. `v12Deployment` and `requireV12Deployment` also return current release addresses under that historical filter; none of these helpers verifies current on-chain deployment. Prefer explicit `v12KitchenAddress()` after checking the target chain. `V12_EVM_CONTRACTS` and `v12SvmProgramId` are legacy addresses; use the current `/deployments` address functions. [evm-execution.ts](../examples/evm-execution.ts) demonstrates prediction, deployment, and owner/Kitchen checks.
81
+
82
+ `buildSauceSvmCall` and the SVM route path emit a legacy 8-byte staged-engine instruction, which is **incompatible with engine 1.0.1** even when supplied a code account and the current engine ID. They do not construct the required Kitchen call. Use the direct Kitchen client for Solana execution; see [the SVM intent limitation](../guides/solana.md#svm-destinations-in-eco-intents).
83
+
84
+ ## Built intents
85
+
86
+ | Member | Behavior |
87
+ | ------------------------------------------- | ------------------------------------------------------------------- |
88
+ | `intent`, `root()` | Normalized head intent |
89
+ | `source`, `destination` | Canonical chain records |
90
+ | `compiled` | Head destination program's compilation result |
91
+ | `children` | Direct nested children |
92
+ | `intents()` | Root-first preorder traversal of all intents |
93
+ | `hash()` | Intent, route, and reward hashes |
94
+ | `encodeEVM()`, `encodeSVM()` | Explicit codec serialization of route and reward |
95
+ | `approvals()` | EVM approval requests for the head reward |
96
+ | `publishCalldata()` | Source Portal publication request |
97
+ | `publishAndFundCalldata(allowPartial)` | Publication and funding request |
98
+ | `fundCalldata(allowPartial)` | Funding request |
99
+ | `vaultCall()`, `hashCall()`, `fundedCall()` | Source Portal read request plus result decoder |
100
+ | `predictVault(config)` | Offline CREATE2 prediction with caller-provided vault configuration |
101
+
102
+ Submission/read helpers accept an optional `{ portal }` override; otherwise `sourcePortal` is required. They generate EVM requests, require an EVM source, and never perform RPC. The codec can represent an SVM destination, but the built-in SVM Sauce route has the execution limitation above. Source/destination-selected encoding is used internally by hashing and Portal helpers; explicitly forcing a codec does not change an intent's chain kinds.
103
+
104
+ ## Composition and lower-level encoding
105
+
106
+ Call `.nest(childOrThunk, options?)` before `.reward(...)`. The fluent default is transfer funding after the parent program. [Nested intents](../guides/nested-intents.md) explains funding modes, deadlines, account custody, and execution ordering.
107
+
108
+ For callers building their own calls, `assembleIntent(source, destination, route, reward)` normalizes an intent without compiling a program. `encodeRoute`, `encodeReward`, `hashIntent`, and their explicit EVM/SVM variants expose encoding and hashing. `toUniversalAddress` normalizes addresses for the cross-chain intent model, while `denormalizeToEvm` converts an EVM-shaped universal address back to its 20-byte form.
109
+
110
+ The low-level `nestedChildCalls` helper builds approval/publication calls with explicit Portal and `allowPartial` settings. The fluent `.nest()` default is `"transfer"`; pass the current `executionFee` for its additional cook.