description |
---|
Overview of the REX Version 2.0 Contracts |
{% hint style="warning" %} This technical documentation is for Ricochet Exchange's Version 2.0 contracts which are currently under development. Find the work in progress on these contracts here: https://github.com/Ricochet-Exchange/ricochet-protocol {% endhint %}
Ricochet Exchange (REX) contracts power the backend of Ricochet's products and services. This page gives an overview of the contract architecture. This is written for blockchain engineers interested in integrating with REX as well as strategists interested in extending the base contracts to create new strategies for how exchanges work.
REX Markets support Ricochet Exchanges (i.e. stream exchange). They contain these basic methods which are triggered by keeper:
distribute
- converts tokens and distributes them to holdersclaim
- accumulated fees can be claimed by the DAOharvest
(optional)- aggregates yield, called separately fromdistribute
to save gas
Internally, REX Market Contract keeps track of oracle price feeds and the output tokens. A REX Market may support many output tokens (subsidy tokens, tokens acquired from yield aggregation). Below is a topology diagram highlighting the internal structures within a REX Market:
REXMarketBase
contains two internal structures:OracleInfo
,OutputPool
Oracles
is amapping(token => OracleInfo)
, each oracle price is updated independentlyOutputPools
is amapping(uint => OutputPool)
(probably needs to become linked list)- If
feeRate != 0
then output token - If
emissionRate != 0
then subsidy token
- If
REX contracts follow a similar pattern to Yearn or Pickle finance where a base contract is extended and customized for each new strategy. REX has the following hierachy:
REXMarket
- Contains the basic functionality shared by all marketsREXSushiFarmMarket
- Extends basic functionality to support yield aggregating from Sushiswap FarmsREXStakeDAOFarmMarket
- Extends basic functionality to support yield aggregating from StakeDAO LP FarmsREXLaunchpad
- Supports streaming ICOs where the input is sent to a benificiary in exchange for a token that is held by the contract
Below is a graphical representation of the hierarchy: