MANTRA Dex
Last updated
Last updated
MANTRA DEX is a decentralized exchange (DEX) protocol that allows for permissionless pool and farm creation. The protocol is built around singleton contracts, which makes it easier to manage and integrate with other protocols. MANTRA DEX is based on White Whale V2.
The following is the architecture of MANTRA DEX, and a general description of each contract:
The direction of the arrows represents the dependencies between the contracts.
The Pool Manager is the contract that manages the pools in the DEX. It is responsible for creating pool and handling swaps. Pool creation is permisionless, meaning anyone can create a pool if the fee is paid. The Pool Manager depends on the Farm Manager and the Fee Collector.
The Farm Manager is the contract that manages the farms in the protocol. It is responsible for creating and distributing farms on pools. Farm creation is permissionless, meaning anyone can create a farm if the fee is paid. The Farm Manager depends on the Epoch Manager, as farm rewards are distributed based on epochs.
The Fee Collector collects the fees accrued by the protocol. Whenever a pool or a farm is created, a fee is sent to the Fee Collector. As of now, the Fee Collector does not have any other function.
The Epoch Manager is the contract that manages the epochs in the protocol. Its single responsibility is to be the clock of the system, which is used by the Farm Manager for distributing farm rewards.
Based on the dependencies between the contracts, the instantiation of the contracts follows the following order:
Epoch Manager
Fee Collector
Farm Manager
Pool Manager
Note: Since there's a circular dependency between the Farm Manager and the Pool Manager, instantiate the Farm Manager by passing an empty address as the pool manager and once the contract is instantiated, invoke the UpdateConfig message with the right value (unless created with instantiate2).