project screenshot 1
project screenshot 2
project screenshot 3

Sail

Sail is a central limit order book built on Fuel. It uses predicates to keep state bloat minimal.

Sail

Created At

ETHSanFrancisco 2022

Winner of

🥈 Fuel — Best Use

Project Description

The project is a central limit order book. It uses the state-less nature of predicates to keep state bloat minimal but has the features of an on-chain DEX like 0x. The two main functions are called make_order and take_order. Make_order takes a maker and a limit order and uses this to create a predicate based on the entered limit order parameters. Buy and sell orders are all predicates. Take_order takes a taker_address and a limit order and creates a transaction that is a script. This script transfers funds to both the maker and taker if the predicate evaluates to true. Once this script transaction is submitted on-chain if the taker's order matches the maker's order the predicate evaluates to true unlocking funds, fulfilling the order.

How it's Made

The project is written in sway, the language for the FUEL VM, and rust. The project is split into three parts.

The first is a client that generates predicates and interacts with the script and contract when someone wants to make or take an order.

The second is a set of three contract folders. The first is a library, which holds the Limit Order struct. The second is a contract that logs the activity in fuel so an indexer can view it. The third is a script that can be customized to have any behavior, in our case it calls the contract so that the orders are logged when a swap happens.

The final piece is the indexer stated above that can be used to keep track of the different make-and-take order requests and fills.

We realized that if we used the predicates that Fuel introduced we could create an OrderBook that combined the best features of a lot of current DEXES, and this would only be possible using Fuels technology.

background image mobile

Join the mailing list

Get the latest news and updates