RateX is a decentralized interest rate swap (IRS) product that offers synthetic exposure to interest rates. The RateX protocol supports up to 40x leverage trading, and the trades will have expiry.
Note: synthetic means you need only provide margin to trade.
For an interest rate market, suppose the underlying's variable interest rate is
Fixed rate receivers look to exchange variable interest rate for fixed interest rate.
Variable rate receivers look to exchange fixed interest rate for variable interest rate.
Liquidators play the role of triggering the liquidation accounts that has insufficient margin through partial liquidation or total liquidation. They can earn certain rewards from doing so. Currently RateX uses Chainlink Keepers as liquidators.
You need to provide margin in order to trade. The minimum amount of margin required by a position is calculated by the maximum leverage of the pool and the position size.
Suppose the notional value is
-
For Fixed Rate Receivers, the PnL of a position at time
$T~ (T \leq T_e)$ is $$ \text{PnL} = N \cdot \big((T - T_b) \cdot r_s - \int_{T_b}^{T} r_v \mathrm{d}t\big) = N \cdot (T - T_b)\cdot (r_s - \overline{r_v}) $$ -
For Variable Rate Receivers, the PnL of a position at time
$T~(T\leq T_e)$ is $$ \text{PnL} = N \cdot \big(-(T - T_b) \cdot r_s + \int_{T_b}^{T} r_v \mathrm{d}t\big) = N \cdot (T - T_b)\cdot ( -r_s + \overline{r_v}) $$
The average variable interest rate
The margin ratio
RateX supports leverage trading, the maximum leverage
When the loss of a position is high, and the margin ratio falls behind a certain ratio, the maintenance margin ratio, the liquidators will be allowed to liquidate the position. The maintenance margin ratio
When a position's margin ratio is below the maintenance ratio, the liquidators can liquidate his position. The liquidation process goes as follows.
The liquidator takes over the position owned by the user, and a portion of the user's margin goes into the liquidator's account. Then the liquidator will supplement for the position's margin to ensure that the counterparties can continue to earn profit.
When a liquidator liquidates, he will take over ALL the positions that have insufficient margin ratio. By doing so, he will also be rewarded by funds in the insurance fund if no one liquidates within a certain time.
The matching engine will match the orders that appears on the orderbook.
The market orders will be automatically filled by being matched with limit orders. The limit orders will appear on the orderbook and wait to be matched. Currently all the limit orders follows a good-till-date manner. The pool will collect
By closing a position, the trader posts a liquidation order to the liquidators. Then the liquidator can take over your position even if your margin left is above of maintenance margin. The remain margin the trader can receive is calculated in the same way as the that of positions being liquidated.
The pool will have estimation of lower and upper bounds of interest rate of the underlying, which are denoted by
Suppose that the time after the creation of the pool is
We set the minimum margin needed in order to avoid liquidation from happening while maximizing capital efficiency. Still in severe cases liquidations can happen, so we define the following.
The position can be liquidated when the margin plus PnL (suppose that value is
Example setting for aUSDC supply rate:
r_l = 0.5%
r_u = 20%
T_e = 30 (days)
leverage_max = 40x (on genesis)
Suggestion: leverage be <= 20x if you do not check your margin ratio often.
The pool is the place where trade can take place. A pool specifies the underlying interest rate / debt rate to speculate, provide the PnL oracle, the term length and transaction parameters such as max leverage, maintenance ratio, and exit fee (fee to pay when one party exists in advance).
The order book module lists, matches and executes the orders. There are two kinds of orders in total, market order and limit order. Also, the order book collect fees from trades and send parts of them into the insurance fund.
The position manager manages all users' position and margin. It records each position after an order is (fully or partially) filled, each position's PnL / Margin Ratio. Also, it allows users to increase / decrease margin for their position, and it will allow liquidators to execute liquidation orders when one position's margin ratio is below maintenance ratio.
The insurance fund will collect parts of the transaction fees. When a liquidation is to happen, the insurance fund will compensate the liquidator with parts of its vault's storage.
The oracle will record the interest rate from Aave or Compound or Yearn by Chainlink Keepers constantly. The PositionManager will use the oracle to calculate PnL of each position, and to decide whether a position is liquidable.
Example:
Alice Market price 10000 aUSDC to trade fixed rate, she places 100 aUSDC as margin
2%: 5000
1.99%: 15000 (6000 B, 5000 C, 4000 D) -> in FCFS order
90 / 365 * 0.02%