Git Product home page Git Product logo

carbon-contracts's Introduction

Carbon

Carbon v1.0

Build Status

Overview

Carbon is a fully decentralized protocol for automating on-chain trading strategies.

Some examples of the advanced features Carbon offers:

  • Linked limit & ranged orders
  • Automated Strategies
  • Non-custodial and fully decentralized
  • Asymmetric & Irreversible Liquidity
  • All standard ERC-20 tokens supported (excluding rebase/fee-on-transfer tokens)
  • MEV Resistant

Security

The repository is part of the bug bounty program. See the details here.

The security policy is available here.

Security Audits

Setup

As a first step of contributing to the repo, you should install all the required dependencies via:

yarn install

You will also need to create and update the .env file if you’d like to interact or run the unit tests against mainnet forks (see .env.example)

Testing

Testing the protocol is possible via multiple approaches:

Unit Tests

You can run the full test suite via:

yarn test

You can also run the test suite with additional stress tests via:

yarn test:nightly

This suite is called “nightly” since it’s scheduled to run every day at midnight against the release and production branches (see nightly.yml).

Deployment Tests

You can test new deployments (and the health of the network) against a mainnet fork via:

yarn test:deploy

This will automatically be skipped on an already deployed and configured deployment scripts and will only test the additional changeset resulting by running any new/pending deployment scripts and perform an e2e test against the up to date state. This is especially useful to verify that any future deployments and upgrades, suggested by the DAO, work correctly and preserve the integrity of the system.

Test Coverage

Latest Test Coverage Report (2023-06-08)

  • 99.3% Statements 424/427
  • 92.55% Branches 298/322
  • 99.28% Functions 137/138
  • 99.28% Lines 548/552

Coverage Report

------------------------|----------|----------|----------|----------|----------------|
File                    |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
------------------------|----------|----------|----------|----------|----------------|
 carbon/                |    99.61 |    93.43 |    98.51 |     99.7 |                |
  CarbonController.sol  |    98.67 |    89.77 |    96.55 |    98.84 |             94 |
  Pairs.sol             |      100 |    85.71 |      100 |      100 |                |
  Strategies.sol        |      100 |    97.92 |      100 |      100 |                |
 carbon/interfaces/     |      100 |      100 |      100 |      100 |                |
  ICarbonController.sol |      100 |      100 |      100 |      100 |                |
 fees/                  |      100 |     87.5 |      100 |      100 |                |
  FeeBurner.sol         |      100 |     87.5 |      100 |      100 |                |
 fees/interfaces/       |      100 |      100 |      100 |      100 |                |
  IFeeBurner.sol        |      100 |      100 |      100 |      100 |                |
 token/                 |    94.12 |       90 |      100 |    94.12 |                |
  ERC20Burnable.sol     |      100 |      100 |      100 |      100 |                |
  Token.sol             |    93.55 |       90 |      100 |    93.55 |         92,142 |
 token/interfaces/      |      100 |      100 |      100 |      100 |                |
  IERC20Burnable.sol    |      100 |      100 |      100 |      100 |                |
 utility/               |      100 |    93.75 |      100 |      100 |                |
  Constants.sol         |      100 |      100 |      100 |      100 |                |
  MathEx.sol            |      100 |      100 |      100 |      100 |                |
  OnlyProxyDelegate.sol |      100 |      100 |      100 |      100 |                |
  Upgradeable.sol       |      100 |       75 |      100 |      100 |                |
  Utils.sol             |      100 |      100 |      100 |      100 |                |
 utility/interfaces/    |      100 |      100 |      100 |      100 |                |
  IUpgradeable.sol      |      100 |      100 |      100 |      100 |                |
  IVersioned.sol        |      100 |      100 |      100 |      100 |                |
 voucher/               |      100 |     92.5 |      100 |    97.96 |                |
  Voucher.sol           |      100 |     92.5 |      100 |    97.96 |            249 |
 voucher/interfaces/    |      100 |      100 |      100 |      100 |                |
  IVoucher.sol          |      100 |      100 |      100 |      100 |                |
------------------------|----------|----------|----------|----------|----------------|
All files               |     99.3 |    92.55 |    99.28 |    99.28 |                |
------------------------|----------|----------|----------|----------|----------------|

Instructions

In order to audit the test coverage of the full test suite, run:

yarn test:coverage

It’s also possible to audit the test coverage of the deployment unit-tests only (which is especially useful when verifying that any future deployments and upgrades are properly covered and tested before the DAO can consider to execute them):

yarn test:coverage:deploy

Similarly to the regular test suite, it’s also possible to audit the test coverage of the stress test suite via:

yarn test:coverage:nightly

Deployments

The contracts have built-in support for deployments on different chains and mainnet forks, powered by the awesome hardhat-deploy framework (tip of the hat to @wighawag for the crazy effort him and the rest of the contributors have put into the project).

You can deploy the fully configured Carbon protocol via:

yarn deploy

There’s also a special deployment mode which deploys the protocol to a mainnet fork. It can be run via:

yarn deploy:fork

Community

carbon-contracts's People

Contributors

ivanzhelyazkov avatar yarivbancor avatar yudilevi avatar barakman avatar

Stargazers

manijeh avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.