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 aiโto 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โโpiโciโ
Here piโis 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:
Heret0โis the initial time,tis the current time, andriโis 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:
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.