Skip to content

T0 Lang documentation

The language the terminal's scripts are written in: its specification, standard library, host API and tooling, with example programs from pure calculations to strategies.

A whole program

Exact money, with no binary rounding anywhere. A program like this one needs no permission at all.

// Category: pure
// Permissions: none
// Exact money: what a fill costs, with no binary rounding anywhere.
// Runs anywhere: `t0 run examples/01_exact_fees.tz`.

lang ">=0.1.1, <0.2.0";
import std.decimal;

fn main() {
    let fill = price(64000.50, USDT);
    let size = qty(0.25);
    let notional = fill * size;
    print("notional " + to_string(notional));
    let taker = notional * bps(5);
    let maker = notional * bps(2);
    print("taker fee " + to_string(taker) + ", maker fee " + to_string(maker));
    // 0.1 + 0.2 is 0.3 here: decimals are exact.
    print(0.1 + 0.2 == 0.3);
    // Rounding is always written down, and the mode is in the name.
    print(round(2.25, 1));
    print(decimal.round_half_up(2.25, 1));
    print(decimal.floor(taker.amount(), 2));
}
// expect-output: notional 16000.1250 USDT
// expect-output: taker fee 8.00006250 USDT, maker fee 3.20002500 USDT
// expect-output: true
// expect-output: 2.2
// expect-output: 2.3
// expect-output: 8.00

01_exact_fees.tz

Language

Host API

Tooling

Runtime and security

Versioning

How it is built

Examples

Programs that go through the real compiler and runtime. Each says which permissions it needs and what it does to the terminal.

Examples