@sauce/* libraries for token operations and swaps. Import them inside a SauceScript program; the compiler includes the required code in your program. You do not install or deploy these libraries separately.
Use these imports in .sauce.ts programs. For application code that compiles and submits programs, use the TypeScript SDK.
Importing a library
A program imports a library’s functions by name, like any module. This one imports@sauce/router’s uniswapV3 and calls @sauce/token’s transfer with no import:
swap-and-pay.sauce.ts
routes.compileSauceProgram and actions compiler resolve bundled @sauce/* imports automatically. When you use the raw compiler, configure a resolver with the package’s resolveSdkModule and resolveSdkPackage (Compiling programs).
@sauce/token with no import
The @sauce/token functions are in scope in every program the sauce command or routes.compileSauceProgram compiles, with the token as the first argument, as in transfer(USDC, to, received) above. The token methods, USDC.transfer(to, amount), Token(token).approve(spender, amount) and pot.USDC, compile to calls into the same functions (Names). A name the program declares or imports itself takes precedence over the library’s.
EVM and Solana implementations
Each library has an EVM implementation and a Solana implementation. The compiler selects the implementation for your target chain:@sauce/tokenhas the same reads and writes on both, with Solana’s taking the accounts they read or move through.ownerOf,transferCheckedandapproveCheckedare Solana only;permitandpermitTransferFromare EVM only.@sauce/routerhas a different set of functions on each target: the EVM venues on EVM chains, the Solana venues on Solana.
router-on-solana.sauce.ts
@sauce/token function the target does not support fails with “permit is called but never declared” (here permit on Solana). A @sauce/router function needs its import on every chain: without one it fails with “uniswapV3 is called but never declared”.
Next steps
- @sauce/token: every token function, what it checks and what it refuses.
- @sauce/router: the swap functions, the venues and the try forms.
- Layout of a program: imports, scripts and
main. - Sauce SDK quickstarts: complete programs that swap, lend and pay.
