Skip to main content
sauce actions converts a JSON actions document to a SauceScript program for one chain and prints the program, main’s parameters and the bytecode.

Synopsis

Description

An actions document is JSON, { "version": 1, "actions": [ … ] }, where each action is one protocol operation: a swap, a lending supply, a bridge, a token approval. The document’s tokens are registry symbols ("USDC") or addresses, and its contracts are namespace references ("UniswapV3.Factory") or addresses. A pool may be given by its factory’s key (factory and fee) instead of its address; the program then reads the pool from the factory when it runs. A recipient, onBehalfOf or owner is an address, or "pot" for the executing Pot. sauce actions compiles the document for the chain --chain names, else for the document’s chainId. Each name becomes the program’s global of that name on that chain, so a document with no chainId compiles for every chain where its names exist. A name the chain lacks is refused with its path in the document (actions[1].tokenIn). An action of type argument becomes a parameter of main, in the order the document declares it. Give its value with --args when you simulate, build or run the document. sauce compile, sauce simulate, sauce tx and sauce run take an actions document wherever they take a .sauce.ts file, with the same flags. Its cook runs on the Pot that --owner or --pot names. sauce actions shows what those commands compile.

Options

Output

Without --json, stdout carries the SauceScript the document lowers to, then a comment with main’s signature and a comment with the bytecode and its size. With --json, stdout carries the object sauce compile --json prints (bytecode, size, entryParams, defines, contracts, compiler, engine), plus: Exit codes: 0 when the document compiles, 1 when it is refused for the chain, 2 for a usage error, such as a document with no chainId and no --chain.

Examples

Lower a swap for Base

swap.json
The document takes the amount to sell as an input, swaps that much USDC for WETH in the Uniswap V3 pool the factory keys at a 0.05% fee, and keeps the WETH in the Pot.
The argument action became main’s parameter a_amount. The swap is a call into @sauce/router.
The output is trimmed: returnType, compiler and engine are left out.

Simulate the document

The simulation needs the release’s engine deployed on the chain: sauce pot --chain base --owner <address> reports whether it is.
Simulated on Base at block 53157167 through a public endpoint. Nothing was signed or sent:
--args 1000000000 is 1,000 USDC in base units. sauce simulate describes the rest of the report.

A name the chain lacks

The command exits 1 and lists every refused name with its path.

Next steps