Quickstart

The quickstart program is an example usage of the SDK.

This program opens a Tycho stream, listen to it, build or update orderbooks each time states has changed, and prints out the formatted orderbooks.

If you provide a private key in the the environment variable, it will build the approve and swap transaction to build swap transaction and calldata.

By default, the script attempts to build the approval and swap transactions for 0.01 ETH to USDC on the Tycho router contract on mainnet.

For example, the .env.quickstart.ex file may contain:

TYCHO_API_KEY="sampletoken"
REAL_EXEC=false
SENDER="0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
NETWORK="ethereum"
PV_KEY="0x123"

Terminal

You'll find the quickstart code in the examples folder.

You must have Rust installed.

To run the program:

sh examples/quickstart.sh ethereum

Or directly with Cargo:

export RUST_LOG="off,tycho_orderbook=trace,quickstart=trace"
cargo run --bin quickstart

If activated, the logs show what's going on under the hood. Here's an extract.

Last updated

Was this helpful?