Margin Trade
Search…
⌃K

Key Functions

Overview

  1. 1.
    Trading Dapp that allows you to leverage your spot position up to 5x.
  2. 2.
    A low risk way to provide liquidity and get a good provider rate.
  3. 3.
    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
  • 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