masaun / watch-nft-based-cdp

This is a smart contract that allow a user to borrow the WatchSignals Token ($WST) by depositing a watch owned (Watch NFT) as a collateral. The watch prices are retrieved via chainlink oracle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Watch NFT-based CDP (Collateralized Debt Position)


【Introduction of the Luxury Watch NFT-based CDP (Collateralized Debt Position)】

  • This is a smart contract that allow a user to borrow the WatchSignals Token (WST) by depositing the own luxury watch (Watch NFT) as a collateral.
    • A user create a Watch NFT based on their own luxury watch and its luxury watch price.

      • Current luxury watch price is retrieved by the WatchSignals Luxury Watch Price Oracle via chainlink.
    • A user deposit a Watch NFT into the WatchCDP Pool.

    • By depositing a Watch NFT, a user can borrow the WatchSignals Token (WST) from the WatchCDP Pool.

      • A user can borrow WST until 60% of the watch price of the collateralized-watch NFT .
      • This depositing (collateral) and borrowing structure is simlar to MakerDAO's CDP (MCD).
    • When a user above repay, a user repay the WatchSignals Token (include principal + interest ) to the WatchCDP Pool.

      • Once a user finish to repay, a user can withdraw deposited-watch NFT from the WatchCDP Pool.

  • The WatchSignals Token (WST) is ERC20 token that is original token of the WatchSignals.

 


【Workflow】

  • Diagram of workflow (※ The WatchCDP contract is also the WatchCDP Pool) 【Diagram】Watch NFT-based CDP (Collateralized Debt Position)

 


【Versions】

  • Version for following the Chainlink (v0.6) smart contract
    • Solidity (Solc): v0.6.12
    • Truffle: v5.1.60
    • web3.js: v1.2.9
    • openzeppelin-solidity: v3.2.0
    • ganache-cli: v6.9.1 (ganache-core: 2.10.2)

 


【Setup】

③ Prepare for execution script


  • 2: Add .env to the root directory by referencing from .env.example You need to set 3 things below in your .env:
    • Mnemonic (MNEMONIC)
    • Infura key (INFURA_KEY)
    • Deployer address (DEPLOYER_ADDRESS)

② Install modules

  • Install npm modules in the root directory
$ npm install

③ Compile & migrate contracts (on Kovan testnet)

$ npm run migrate:kovan

④ Scripts (for testing whole process) on Kovan

  • 1: Process are that:
    • Creating a Watch NFT
    • Deposit a Watch NFT as a collateral into the WatchCDP Pool.
    • Borrow the WatchSignals Token (WST)
$ npm run script:WatchCDP-borrow

  • 2: Process are that:
    • Repay the WatchSignals Token (include principal + interest ) to the WatchCDP Pool.
    • Withdraw the deposited-watch NFT from the WatchCDP Pool.
$ npm run script:WatchCDP-repay

(※ In case you want to execute again after scripts above is executed, you must migrate (Process③) again. Then you need to execute Step 1~2 above)


【Video demo】


【Remarks】

  • Arbitrum verison
    • In progress.

  • The WatchCDP contract is also the WatchCDP Pool.

  • Another Scripts (Each parts)
    • Script for calling oracle by using the WatchSignals Luxury Watch Price Oracle via chainlink $ npm run script:WatchSignalsLuxuryWatchPriceOracle

    • Script for creating the Watch NFT $ npm run script:WatchNFTFactory



【References】

About

This is a smart contract that allow a user to borrow the WatchSignals Token ($WST) by depositing a watch owned (Watch NFT) as a collateral. The watch prices are retrieved via chainlink oracle.


Languages

Language:Solidity 88.6%Language:JavaScript 11.4%Language:Shell 0.1%