Coder Social home page Coder Social logo

jkehrbaum / stablecoin-evm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from circlefin/stablecoin-evm

0.0 0.0 0.0 2.42 MB

Source repository for smart contracts used by Circle's stablecoins on EVM-compatible blockchains

License: Apache License 2.0

Shell 0.62% JavaScript 40.34% TypeScript 31.97% Solidity 27.07%

stablecoin-evm's Introduction

Circle's Stablecoin Smart Contracts on EVM-compatible blockchains

This repository contains the smart contracts used by Circle's stablecoins on EVM-compatible blockchains. All contracts are written in Solidity and managed by the Hardhat framework.

Table of contents

Setup

Development Environment

Requirements:

$ git clone [email protected]:circlefin/stablecoin-evm.git
$ cd stablecoin-evm
$ nvm use
$ npm i -g [email protected] # Install yarn if you don't already have it
$ yarn install          # Install npm packages and other dependencies listed in setup.sh

IDE

We recommend using VSCode for the project here with these extensions installed.

Development

TypeScript type definition files for the contracts

Types are automatically generated as a part of contract compilation:

$ yarn compile

To generate typing without re-compiling, run

$ yarn hardhat typechain

Linting and Formatting

To check code for problems:

$ yarn static-check   # Runs a static check on the repo.

or run the checks individually:

$ yarn typecheck      # Type-check TypeScript code
$ yarn lint           # Check JavaScript and TypeScript code
$ yarn lint --fix     # Fix problems where possible
$ yarn solhint        # Check Solidity code

To auto-format code:

$ yarn fmt

Testing

Run all tests:

$ yarn test

To run tests in a specific file, run:

$ yarn test [path/to/file]

To run tests and generate test coverage, run:

$ yarn coverage

To check the size of contracts in the repo, run the following command.

$ yarn contract-size # Ignores tests

Deployment

  1. Create a copy of the file .env.example, and name it .env. Fill in appropriate values in the .env file. This file must not be checked into the repository.
cp .env.example .env
  1. Create a blacklist.remote.json file and populate it with a list of addresses to be blacklisted. This file must not be checked into the repository.
echo "[]" > blacklist.remote.json
  1. Simulate a deployment by running the following command
yarn forge:simulate scripts/deploy/deploy-fiat-token.s.sol --rpc-url <testnet OR mainnet>
  1. Validate that all transactions to be broadcasted are filled in with the correct values
  2. Deploy the contracts by running the following command
yarn forge:broadcast scripts/deploy/deploy-fiat-token.s.sol --rpc-url <testnet OR mainnet>
  1. Verify the contracts on an Etherscan flavored block explorer by running the following command. Ensure that ETHERSCAN_KEY is set in the .env file.
yarn forge:verify scripts/deploy/deploy-fiat-token.s.sol --rpc-url <testnet OR mainnet>

Contracts

The FiatToken contracts adheres to OpenZeppelin's Proxy Upgrade Pattern (permalink). There are 2 main contracts - an implementation contract (FiatTokenV2_2.sol) that contains the main logic for FiatToken's functionalities, and a proxy contract (FiatTokenProxy.sol) that redirects function calls to the implementation contract. This allows upgrading FiatToken's functionalities, as a new implementation contact can be deployed and the Proxy can be updated to point to it.

FiatToken features

The FiatToken offers a number of capabilities, which briefly are described below. There are more detailed design docs in the doc directory.

ERC20 compatible

The FiatToken implements the ERC20 interface.

Pausable

The entire contract can be frozen, in case a serious bug is found or there is a serious key compromise. No transfers can take place while the contract is paused. Access to the pause functionality is controlled by the pauser address.

Upgradable

A new implementation contract can be deployed, and the proxy contract will forward calls to the new contract. Access to the upgrade functionality is guarded by a proxyOwner address. Only the proxyOwner address can change the proxyOwner address.

Blacklist

The contract can blacklist certain addresses which will prevent those addresses from transferring or receiving tokens. Access to the blacklist functionality is controlled by the blacklister address.

Minting/Burning

Tokens can be minted or burned on demand. The contract supports having multiple minters simultaneously. There is a masterMinter address which controls the list of minters and how much each is allowed to mint. The mint allowance is similar to the ERC20 allowance - as each minter mints new tokens their allowance decreases. When it gets too low they will need the allowance increased again by the masterMinter.

Ownable

The contract has an Owner, who can change the owner, pauser, blacklister, or masterMinter addresses. The owner can not change the proxyOwner address.

Additional Documentations

stablecoin-evm's People

Contributors

o-a-hudson avatar eztierney avatar mirathewhite avatar walkerq avatar petejkim avatar circle-aloychan avatar yvonnezhangc avatar dependabot[bot] avatar tjbaker avatar ams9198 avatar 0xj0hnny avatar blincf avatar gin avatar cgst avatar mgrissa avatar anders94 avatar dmdque avatar jscaltreto avatar petetronic avatar zhenghui-w avatar huaweigu 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.