Skip to content

Smart contracts for defi.money. Based on Curve Finance's crvUSD.

License

Notifications You must be signed in to change notification settings

defidotmoney/dfm-contracts

Repository files navigation

dfm-contracts

Smart contracts used within the Defi.Money protocol.

Core protocol based on Curve Finance's crvUSD.

Organization

Smart Contracts

  • contracts/base/: Shared libraries and abstract bases, and the core protocol ownership logic.
  • contracts/bridge/: Contracts related to cross-chain functionality (powered by LayerZero).
  • contracts/cdp/: Core protocol functionality, based on Curve Finance's crvUSD.
  • contracts/periphery/: Periphery contracts such as hooks, zaps and combined views.
  • contracts/testing/: Contracts used for unit testing. Not a part of the protocol.

Deployment

Scripts

Tests

Setup

Requirements

  • python version 3.10 or later, python3-venv, python3-dev
  • npm version 7 or later

Installation

  1. Install the node.js dependencies ( Hardhat and LayerZero contracts ). This should be done in the dfm-contracts root directory.

    npm install
  2. Within the dfm-contracts root directory, create a venv and install the python dependencies:

    python3 -m venv venv
    source venv/bin/activate
    pip install -r requirements.txt
  3. Initialize the virtual environment to interact with the project. This must be done at the start of each new terminal session.

    source venv/bin/activate

Deployment

To a Local Network

To run scripts/deploy/local.py and deploy all contracts on a local hardhat network:

brownie run deploy/local -i

The brownie console will open once deployment has finished. The hardhat session will persist as long as brownie remains open.

To Mainnet

Mainnet deployment configurations are handled by YAML files within deployments/config. Common settings are first loaded from default.yaml, and then network-specific settings are loaded over top. Each network's configuration filename is the same as it's brownie network name, e.g. for Fantom the filename would be ftm-main.yaml.

Before the actual deployment it is recommended to do a test run on a forked mainnet. If you deploy to a network ending in -fork, the related mainnet deploy config is used.

To run scripts/deploy/mainnet.py:

brownie run deploy/mainnet --network [network name] -i

The brownie console will open once deployment has finished.

Addresses of the core smart contracts will be written to a YAML file within deployments/logs. If this is the final deployment, remember to commit this log file to git.

Note that the script does not verify source codes with Etherscan (API source verification is not supported for Vyper). You must manually verify once deployment is finished.

Tests

Unit testing is done with a mix of brownie and titanoboa.

To run the brownie tests:

brownie test

To run the titanoboa tests:

pytest tests/titanoboa

Note that brownie and titanoboa do not play nicely together - attempting to run all tests at once will result in unexpected failures.

Audits

Components of this codebase have undergone multiple audits by different firms. Audit reports are published on our Github audit repo as they are completed.

License

Unless otherwise noted, code in this repository is copyrighted (c) by Curve.Fi, 2020-2024 - All rights reserved. Used by Defi.Money with permission.