Skip to content

nanthanwa/ethers-synthetic

Repository files navigation

Dopple Synthetic

DISCLAIMER: This project is work by assuming the price of $DOLLY is EQUAL USD only.

Installation

  • git clone https://github.com/nanmcpe/dopple-synthetic.git
  • cd dopple-synthetic
  • yarn install

Requirements

  • Dolly address (to deploy, run hh deploy --tags Dolly)
  • Synthetic asset address (to deploy, run hh deploy --tags DoppleSyntheticTokenFactory)
  • Band oracle reference address click here for more details
  • Create .secret file and provide credential following
{
    "infuraProjectId": "",
    "alchemyProjectId": "",
    "privateKey": [
        DEPLOYER_PRIVATE_KEY,
        MINTER_PRIVATE_KEY,
        LIQUIDATOR_PRIVATE_KEY,
        DEVELOPER_PRIVATE_KEY
        ],
    "etherApiKey": "",
    "bscApiKey": ""
}

Deployment

  • Run hh deploy

Runing the unit tests

  • Run hh test (some tests are required "Kovan network forked" to get Oracle price).

Features

  • Can mint synthetic asset by provide 150% of collateral (adjustable). (e.g. provide $DOLLY -> receive $dTSLA)
  • Can redeem (fully or partial) of synthetic asset to get collateral back. (e.g. repay $DOLLY -> burn $dTSLA)
  • Can add more collateral by provide backed asset ($DOLLY) for extend liquidation ratio.
  • Can remove some collateral whereas the collateral ratio still satisfy.
  • Can liquidate open contract that hit the liquidation ratio.
  • Liquidation fee will be transfered to dev address (optional).
  • Can adjust some parameters e.g. collateralRatio, liquidationRatio, liquidatorRewardRatio, platfromFeeRatio, remainingToMinterRatio.

TODO

  • ✅ Add reentrancy guard.
  • ✅ Use factory pattern for synthetic asset contracts. From this issue.
  • ✅ Fix this issue.
  • ✅ Add function addSynthetic() and removeSynthetic() corresponding of user's collateral ratio.
  • ✅ Use SafeERC20 for transfer tokens.
  • ⏰ Add more unit test!!
  • ⏰ Gathering and monitor liquidation of minted asset (for liquidate bot).
  • ⏰ Make simple UI.
  • ⏰ Use Chainlink oracle for standby (or combine) mode.

Breakdown the deployments

  1. Get deploayed Dolly instance
  2. Deploy Synthetic contract by giving Dolly address and Band oracle reference
  3. Verify Synthetic contract
  4. Get deploayed Synthetic Token instance
  5. call function setPairsToAddress(string <Pairs>, address syntheticAsset) to Synthetic contract.
  6. call function setAddressToPairs(address syntheticAsset, string <Pairs>) to Synthetic contract.
  7. call function setPairsToQuote(string pairs, string[2] pairs) to Synthetic contract. TSLA/USD', ['TSLA', 'USD']
  8. call function approve(address synthetic, uint256 amount) to Dolly contract. for minting purpose.
  9. call function approve(address synthetic, uint256 amount) to Synthetic Asset contract. for redeeming purpose (burned by synthetic contract).
  10. call function setSyntheticAddress(address synthetic) to Synthetic Asset contract. for only Synthetic contract can mint synthetic asset.

Deployed contract (Kovan Testnet)

Miscellaneous

Diagrams

About

dopple-synthetic

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published