Modules and imports
A strategy's uses line names what it reads and does. Every module (market data, books, venues, protocols, std contracts and your own libraries) with the line that imports it and a working example.
The uses line#
A strategy's first line says what it reads and does:
uses { bars: "^1", funding: "^1", perp: "^1" }
import "std/vwap";
import "mylib";With no uses line a strategy gets bars and paper, which covers spot on one market. A name the line doesn't declare is refused with the line to add, and a mistyped one with the module it probably means.
What there is#
| Kind | Modules |
|---|---|
| Market data | bars, pool, feed, funding, book, liq, sources, input |
| Orders and books | paper, perp, lp, wallet, funds, husher, poll |
| Lending | aave, spark, compound, kamino, marginfi |
| Vaults | morpho, euler, yearn, fluid, gearbox, sky, ethena, maple, spark_savings, kamino_earn, jupiter_lend, jito |
| Fixed rates and options | pendle, derive |
| Routing | earn |
| Std contracts | std/erc20, std/erc4626, std/vwap |
Browse them#
Developers → Modules in the app lists every module with what it reads, what it does, which markets it covers, the series to backtest it on and how far back its history goes. Each has an example that compiles; New strategy from this saves it as a strategy.
From an AI or the API, list_modules and get_module give the same, with everything to write a strategy on one in a single call.
Your own libraries#
Save functions you reuse as a library and import them by name. A library can also hold contract interfaces.
Contract calls#
A program can declare any contract's functions and call them by name:
uses { bars: "^1", usdc: ERC20("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48") }
import "std/erc20";
const allowed = usdc.allowance("0x…owner", "0x…spender");
when (allowed < tokenUnits(100, 6)) { usdc.approve({ spender: "0x…spender", amount: tokenUnits(1000, 6) }); }A contract call compiles, and a backtest or a test records each call with its arguments. A running strategy doesn't send contract calls from project wallets yet: it carries out paper, perp, liquidity, funds and protocol orders.