Skip to content

Latest commit

 

History

History
187 lines (120 loc) · 4.93 KB

README.md

File metadata and controls

187 lines (120 loc) · 4.93 KB

Rari Capital's local fork

This project eases the process of setting up a hardhat localfork with Rari Capital's products.

Setup
  1. You first run

     npm install 
    
  2. The next step is compilation but one contract needs to be modified before because of incompatible solidity compilator versions

    Go to node_modules/@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol

    in Line 2 you'll find: pragma solidity >=0.7.0;

    change it to: pragma solidity 0.6.12;

    please let me know if theres a better way to do this I couldn't find it :)

  3. Run

     npx hardhat compile
    
  4. Start hardhat node

     npx hardhat node
    

    This will start a mainnet fork pinned at block: 14167154

  5. Open a second terminal and run:

     npx hardhat deploy-fuse --network localhost 
    

    This will deploy a clean instance of fuse in your localnode.

Fuse
    Interacion
      Go through the setup before using any task below.
      Deploy an empty pool
      	npx hardhat deploy-pool --network localhost
      
      This task will output the deployed pool's comptroller address which you will need to run the tasks below:
      Deploy a cToken/market
      	npx hardhat deploy-market --comptroller 0x00...0000 --underlying 0x00...0000 --cfactor 5 --rfactor 0.5 --adminfee 0.05 --network localhost 
      
      - comptroller is the comptroller address where ctoken/market will be listed.
      - underlying is the underlying token of the market.
      - cfactor is the collateral factor of the market. optional
      - rfactor is the reserve factor. optional.
      - adminfee is the admin fee. optional.
      Deploy a rewards distributor to a given pool
      npx hardhat deploy-rd-to-pool --underlying 0x00...0000 --comptroller 0x00...0000 --network localhost
      
      - underlying is the address of token to distribute.
      - comptroller is the comptroller address to add rd.
      Deploy Uniswap V2 Twap Oracle
      npx hardhat deploy-unitwap-v2
      
      task not complete yet, it'll deploy an oracle but will not add it to the comptroller.
      Market Interaction
        Supply
        npx hardhat supply --underlying 0x00...0000 --market 0x00...0000 --comptroller 0x00...0000 --amount 1000 --collateralize true --user 0x00...0000
        
        - underlying is the market's underlying asset.
        - market is the address of the market.
        - comptroller is the address where market is listed.
        - amount is the amount of tokens to supply.
        - collateralize is optional. If true you will enter the market.
        - user is address of supplier. optional. default to hardhat's first address.
        Borrow
        npx hardhat borrow --market 0x00...0000 --amount 1000 --token 0x00..0000
        
        - market is the address of the market.
        - amount is the amount of tokens to supply.
        - token is the market's underlying asset.
        Repay
        npx hardhat repay --market 0x00...0000 --amount 1000 --token 0x00..0000
        
        - market is the address of the market.
        - amount is the amount of tokens to supply.
        - token is the market's underlying asset.
        Withdraw
        npx hardhat withdraw --market 0x00...0000 --amount 1000 --token 0x00..0000
        
        - market is the address of the market.
        - amount is the amount of tokens to supply.
        - token is the market's underlying asset.
    Fetching info
      Go through the setup, and deploy a pool before using tasks below.
      To get the pool's information
      npx hardhat get-pool-info --comptroller 0x00...0000 --network localhost
      
      - comptroller is the address of the comptroller that will be used to get information.
Misc
    Get a token
    npx hardhat sendToken --to 0x00...0000 --amount 1000 --token DAI
    
    - to is the recepient address.
    - amount is the amount of tokens to send
    - token is the tokens symbol. Currently supports DAI and USDC.