Sail is at its core a protocol that enables exchanging anything that can be locked in a predicate. (currently only UTXOs) This is done through the use of predicates, something unique to the FuelVM. Sail Exchange is built on top of this core to allow the trading of fungible assets.

Predicates

According to Fuel, “predicates are programs that return a Boolean value and which represent ownership of some resource upon execution to true. They have no access to contract storage.”

Another way of thinking of predicates is as a programmatic lock box for your UTXOs. You can outline any condition under which your UTXOs can be spent and if that condition is met by a transaction then the transaction has access to your UTXOs.

Here is a trivial predicate, which always evaluates to true:

simple_predicate.sw
predicate;

    // All predicates require a main function which returns a Boolean value.
    fn main() -> bool {
        true
    }

The predicate above would allow a UTXO to be spent by any transaction.

predicate.sw
predicate;

    use std::{
        auth::msg_sender
    };

    // All predicates require a main function which returns a Boolean value.
    fn main() -> bool {
        let test_address = Address::from(0xbc2340bf7a3639c88c88700a636b5304ff9d34c565da69c8658464bcdb3298cc);
        let test_identity = Identity::Address(test_address);

        if msg_sender().unwrap() = test_identity{
            true
        }

        false
    }

In the predicate above if the person who sent the transaction doesn’t own the wallet with the public key “0xbc2340bf7a3639c88c88700a636b5304ff9d34c565da69c8658464bcdb3298cc” then the predicate won’t evaluate to true. Maybe a nice way to leave gifts for friends 🤷🏾‍♂️.

Predicates are pure allowing for them to be stateless. Sail uses predicates as the base for Limit Order allowing for a low state order book.

Warning: Predicates should be created using a client on your local machine to ensure the conditons you set are actually in a predicate

This video gives more information about predicates and how they work.

UTXO

An unspent transaction output (UTXO) is the term for the amount of digital currency that remains after a cryptocurrency transaction. It is the change you receive after the completion of a transaction. It is an alternative to the account model(Ethereum) of recording state. The UTXO model is used in Bitcoin, Litecoin, and Fuel. The UTXO model means there are no accounts at the protocol level. There is a list of UTXOs, each UTXO has permissions for who can spend it. Under this model, transactions are created by consuming existing UTXOs and producing new ones in their place. UTXOs are commonly compared to cash.

For example, imagine that you have 1 ETH UTXO that you can spend. You decide to pay a friend 0.5 ETH. The 1 ETH UTXO you have would be spent (destroyed by the protocol) and two new UTXOs would be created. Both are worth 0.5 ETH, one belonging to your friend and the other belonging to you. Note that the 0.5 ETH UTXO you now have is not a remnant of the 1 ETH UTXO you initially had but an entirely new UTXO.

RFQ

A request for quote (RFQ), is a process in which a user gets Makers to submit price quotes and bids for the chance to fulfill an order. Sail uses RFQs combined with Dutch Auctions to give users the best price before forwarding the order to the order book. Users can request to be placed directly on the book.

Dutch Auction

A Dutch auction (also called a descending price auction) refers to a type of auction in which an auctioneer starts with a very high price, incrementally lowering the price until someone places a bid. That first bid wins the auction (assuming the price is above the reserve price), avoiding bidding wars. In the case of Sail Market Makers compete for order flow filling an order at whatever price is worth it for them.

FuelVM

Fuel is the fastest modular execution layer, delivering maximum security and the highest flexible throughput. To learn more about Fuel here are some resources:
-Fuel Intro Blog Post

-Fuel Documentation Portal

-Fuel Github

-Fuel Discord