Key Functions
Overview
Trading Dapp that allows you to leverage your spot position up to 5x.
A low risk way to provide liquidity and get a good provider rate.
For maximum liquidity 0x protocol has been selected for trading.
Global credit pool
In order to trade first, traders have to deposit funds to a global credit pool of capital, which is essentially a smart contract that tracks who is holding what asset.
This smart contract also contains the funds provided by liquidity providers, as shown in this diagram below.
Borrowing fee
There is also a "Borrow Fee" that is deducted at the start of every hour. This is the fee paid to the counter-party of your trade. The fee per hour will vary based on utilization, it is calculated as (assets borrowed) / (total assets in pool) * 0.01%. The "Borrow Fee" for longing or shorting is shown below the swap box.
Trading platforms
0x has been selected for trading interactions - 0x protocol. The user can interact only with whitelisted smart contracts and assets.
Limit orders, automatic stop losses and automatic profit taking
The 0x protocol has its own order book API that allows for limit order execution. This allows us to also create stop losses and take profit orders based on the order book API.
Liquidity Pools
Build from ground up based on Gearbox liquidity pools.
Pool interactions
Mint(address minter, uint mintAmount, uint mintTokens)
Redeem(address redeemer, uint redeemAmount, uint redeemTokens)
Borrow(address borrower, uint borrowAmount, uint accountBorrows, uint totalBorrows)
RepayBorrow(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows)
LiquidateBorrow(address liquidator, address borrower, uint repayAmount, address mTokenCollateral, uint seizeTokens)
Pools should have similar parameters that the one described in Rari Pools. Parameters (in detail described here)
Pools can have only 4 types of assets (WETH, WBTC, USDT, USDC)
MVP is with only one pair ETH - USDC
Possible interest rate curve solutions
Interest rates for each market update on any block in which the ratio of borrowed assets to supplied assets in the market has changed. The amount interest rates are changed depends on the interest rate model smart contract implemented for the market, and the amount of change in the ratio of borrowed assets to supplied assets in the market.
Gearbox pool interest rate - https://drive.google.com/file/d/1cEHhsHZFF2rgQCnHyFOvi-FweGqh5nbJ/view - 3.1 Interest rate model
AAVE interest rate formula: https://docs.aave.com/risk/liquidity-risk/borrow-interest-rate
Liquidity providers have to be whitelisted
Liquidity providers have a limit on how much liquidity they can provide
Reserve Fund (Platform Treasury)
Is setup in order to mitigate unexpected situations, like liquidations not working, high gas prices etc.
Should be setup with a initial deposit
Similar to Fuse's Reserve Factor function reserveFactorMantissa() returns (uint)
Uses 1bps of every trade - this needs to be adjustable
Liquidations and health factor
Health factor
We can't use the Fuse collateral factor, because it's not designed for products that are lending more than they are supplying. That's why I recommend using something similar to the Gearboxes health factor and combining it with Fuse's Comptroller
Traders should be able to see at what price they are going to get liquidated
Last updated