Smart contract architecture
The principles of simplicity, decentralization, and scalability underlie this system design that is resistant to protocol updates and token standards modifications.
Each token standard has its own contract set that implements the common logic.
The solution consists of a single factory and many pairs. The factory is responsible for creating and indexing. Each pair is represented as a token of the standard it addresses for exchange. If the pair is used for FA1.2-XTZ exchanges, then it implements the FA1.2 interface and if it is designed for FA2-XTZ token exchanges, then the pair is the FA2 token itself. As FA standards require a token to have metadata, a separate contract is used to manage the information and allow upgrade opportunities.
The token to token exchanges is managed by the singleton that implements the FA2 token standard for pool shares. Each exchange pair is represented by the separate LP asset of this multi-asset.
Each FA1.2-XTZ exchange can delegate its XTZ to the baker that is chosen through the voting process. The users propose candidates, where it is required to check whether the Baker Registry is needed to avoid redelegation.
Smart contracts architecture

Factory

The factory holds the code template for Token-XTZ pair contracts. Anyone can use it to deploy the pair for any token that hasn't been added yet.

Dex

The pair fully implements a FA1.2/FA2 token interface, serves as an automated market maker, and pools token shares.

TTDex

This fully implements a multi-asset FA2 token interface and serves as an automated market maker for a variety of TokenX-TokenY pairs.

Token FA

These are arbitrary tokens that implement a FA1.2 or FA2 interface and that can be added and exchanged via QuipuSwap. More information regarding these standards can be found in the official repo.

Metadata Storage

The metadata is stored in a separate contract to allow for upgrades and to overcome Tezos protocol limits. As the token standards are still under discussion and tend to change over time, the metadata storage is centralized and can be updated by developers.

Baker Registry

The contract serves as the Baker Registry to avoid switching the delegate of the DEX, however, it can still check whether the candidate is a registered baker.
Last modified 5mo ago