The main concepts of the TurboSwap marginal trading protocol.
Accounts and Positions
Every user of the TurbosSwap protocol has an account where positions are recorded. Accounts are identified by a unique address in the blockchain where the protocol operates, i.e. Ethereum, Binance Chain, capable of running smart contracts.
For each user asset, positions are either positive (long), negative (short), or zero (void). A positive position means that the protocol owes the asset to the user. A negative position means the user owes the asset to the protocol. In other words, positive positions reflect assets deposited by the users to the protocol, while negative positions reflect assets borrowed by the users from the protocol. A position is identified by an account ID (user's address) and an asset ID.
We will use vij to denote the position of thej-thuser in the i-thasset.
Reserves
The protocol itself may own assets by itself. The assets owned by the protocol are called reserves.
We will use aito denote the amount of i-thassets owned by the protocol.
The Capital
The capital is basically the net value of all the protocol assets. More formally it is the value of all the reserves minus the sum of all the positions. The contribution of the i-thasset into the capital (denoted as ci) is:
ci=ai−j∑vij
The capital value (denoted as C) denominated in the base currency is:
C=i∑pici
Here piis the current price of the i-thasset denominated in the base currency.
Borrow Interest
The protocol continuously collects interest on all the negative (short) positions opened by the users. The interest is collected by increasing the absolute value of a position according to the well known compound interest formula:
vij(t)=vij(t0)⋅(1+ri)t−t0, in case vij<0
Heret0is the initial time,tis the current time, andriis the borrowed interest rate for thei-thasset.
Deposit Interest
The protocol charges a small fee from all the collected borrow interest, and proportionally distributes the rest among those users whose positions in the corresponding assets are positive (long). The protocol ensures that the effective deposit interest rate for an asset never exceeds the borrow rate for this asset discounted by the fee.
Consider Vi−to be the sum of all the negative (short) positions in the i-thasset and Vi+to be the sum of all the positive (long) positions in the same asset. Note, that these two values could be calculated as:
Vi−Vi+==∑j2vij−∣vij∣∑j2vij+∣vij∣
The total interest collected during a period of time from t0till t1on all the negative (short) positions in i-thasset is:
Vi−(t0)⋅(1−(1+ri)t1−t0)
For the effective deposit rate being equal to the borrow rateri, the total deposit interest (before fee) is:
Vi+(t0)⋅((1+ri)t1−t0−1)
So the interest amount (before fee) to be distributed among deposit holders is:
When the total notional amount of all the long positions exceeds the total notional amount of all the short positions(Vi+>−Vi−), then the effective deposit rate depends on the borrow interest rateri, the interest rate feeϕr, and the short-to-long ratio Vi+Vi−. Otherwise, it depends only on the deposit rate and the fee.