💡Architecture

Lighter protocol consists of four main parts; Frontend Application, Contracts, Lighter API, and Python SDK.

Lighter.xyz offers an easy-to-use Frontend that delivers a decentralized trading experience. Simply connect your preferred web3 wallet and begin trading. It's the top choice for those seeking the best rates for their tokens. Set up orders at your desired price or go for quick swaps.

Lighter contracts are deployed to different L2s and L1s. In order to interact with the contacts, users will need to have respective assets bridged into any supported blockchain.

The Lighter API collects useful data from on-chain smart contracts and offers an interface similar to what users expect from a centralized exchange. It gives real-time updates through web sockets for market updates.

All of the data provided from Lighter API also is available on chain. The API simply provides an easy to use way of fetching that data by offering real-time updates and a fast way to query historical information.

The Python SDK offers a comprehensive tool to interact the Lighter. It uses Lighter API to store and update state of order books. It also provides functions to interact with smart contracts.

Contracts Overview

Lighter contracts are divided into two parts: Lighter Core and Lighter Periphery. The Core has the Factory and Order Book contracts that make up the Lighter Exchange's foundation. The Periphery, on the other hand, has the Router. This Router is like a one-stop-shop for users, giving them direct access without the need to set up extra contracts. It's designed to be user-friendly right from their Wallet.

Factory

The Factory contract handles creating Order Books. Users can tap into the Factory contract to find out about different order books or to grab the order book for a specific token pair. Just so you know, in Lighter v2, users can't set up their own order books.

Order Book

Each supported pair gets its own Order Book contract. This contract holds the money for open orders and takes care of pairing up and finishing trades. Users can work directly with an order book, but they have to go through a smart contract that uses a payment interface. Plus, going straight to the order book lets users do flash-loans.

Router

The Router contract sets up the payment interface for the Order Book contracts, making it easy for users to connect with the Lighter exchange. It sends order actions and swaps to the right order books and helps save on gas costs when interacting with the exchange.

Last updated