Skip to content

Commit

Permalink
Version 2.1.0 (RGT liquidity mining)
Browse files Browse the repository at this point in the history
Implemented liquidity mining of RGT (Rari Governance Token) distributions.
Removed account balance limit functions.
Moved dApp to `rari-dapp-legacy`.
Gave `RariFundManager` permission to burn RSPT on withdrawals without the need for approval transactions.
Various minor improvements to `RariFundManager`.
  • Loading branch information
davidlucid committed Oct 13, 2020
1 parent 2bab5ed commit 2d29bf6
Show file tree
Hide file tree
Showing 67 changed files with 1,595 additions and 114,874 deletions.
468 changes: 468 additions & 0 deletions .openzeppelin/mainnet.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## `v2.1.0` (contracts not yet deployed; all code not yet pushed)

* Implemented liquidity mining of RGT (Rari Governance Token) distributions.
* Removed account balance limit functions.
* Moved dApp to `rari-dapp-legacy`.
* Gave `RariFundManager` permission to burn RSPT on withdrawals without the need for approval transactions.
* Various minor improvements to `RariFundManager` (e.g., replaced `disableFund` and `enableFund` with `setFundDisabled`).

## `v2.0.0` (contracts deployed 2020-09-21; all code pushed 2020-10-05)

* Rebranded to Rari Stable Pool and Rari Stable Pool Token (RSPT).
Expand Down
6 changes: 4 additions & 2 deletions DEPLOYED.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ As follows are all deployments of our smart contracts on the Ethereum mainnet. S

`RariFundManager` is the Rari Stable Pool's main contract: it handles deposits, withdrawals, USD balances, interest, fees, etc.

**v2.0.0**: `0xC6BF8C8A55f77686720E0a88e2Fd1fEEF58ddf4a`
**v2.1.0**: (to be deployed)

### `RariFundToken`

The Rari Stable Pool Token (RSPT) is an ERC20 token used to internally account for the ownership of funds supplied to the Rari Stable Pool.

**v2.0.0**: `0x016bf078ABcaCB987f0589a6d3BEAdD4316922B0`
**v2.1.0**: (to be deployed)

### `RariFundPriceConsumer`

Expand All @@ -42,11 +42,13 @@ The Rari Stable Pool Token (RSPT) is an ERC20 token used to internally account f

### `RariFundManager`

* **v2.0.0**: `0xC6BF8C8A55f77686720E0a88e2Fd1fEEF58ddf4a`
* **v1.1.0**: `0x6bdaf490c5b6bb58564b3e79c8d18e8dfd270464`
* **v1.0.0**: `0x686ac9d046418416d3ed9ea9206f3dace4943027`

### `RariFundToken`

* **v2.0.0**: `0x016bf078ABcaCB987f0589a6d3BEAdD4316922B0`
* **v1.0.0**: `0x9366B7C00894c3555c7590b0384e5F6a9D55659f`

### `RariFundProxy`
Expand Down
2 changes: 1 addition & 1 deletion METRICS.html

Large diffs are not rendered by default.

50 changes: 18 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Rari Stable Pool: Smart Contracts & dApp
# Rari Stable Pool: Smart Contracts

Welcome to `rari-stable-pool-contracts`, the central repository for the Solidity source code behind the Rari Stable Pool's Ethereum-based smart contracts (with automated tests), web-based dApp, and documentation.
Welcome to `rari-stable-pool-contracts`, the central repository for the Solidity source code behind the Rari Stable Pool's Ethereum-based smart contracts (with automated tests and documentation).

## How it works

Expand All @@ -10,10 +10,6 @@ The Rari Stable Pool is a decentralized and fully-audited stablecoin lending agg

Documentation on common usage of the contracts is available in [`USAGE.md`](USAGE.md). Detailed API documentation for our smart contracts' public methods is available in [`API.md`](API.md). Smart contract ABIs are available in the `abi` properties of the JSON files in the `build` folder. For easy implementation, see the [Rari JavaScript SDK](https://github.com/Rari-Capital/rari-sdk).

## dApp usage

Anyone can use the dApp for the Rari Stable Pool right now at [app.rari.capital](https://app.rari.capital). However, to be extra safe, you should download or clone this repository and use the web client (located in the `src` folder) locally simply by opening `src/index.html` in your web browser, but be mindful of updates!

## Installation (for development and deployment)

We, as well as others, had success using Truffle on Node.js `v12.18.2` with the latest version of NPM.
Expand All @@ -32,21 +28,23 @@ To install all our dependencies: `npm install`

In `.env`, set `DEVELOPMENT_ADDRESS=0x45D54B22582c79c8Fb8f4c4F2663ef54944f397a` to test deployment and also set `DEVELOPMENT_ADDRESS_SECONDARY=0x1Eeb75CFad36EDb6C996f7809f30952B0CA0B5B9` to run automated tests.

If you are upgrading from `v1.2.0`, set `UPGRADE_FROM_LAST_VERSION=1` to enable upgrading and configure the following:
If you are upgrading from `v2.0.0`, set `UPGRADE_FROM_LAST_VERSION=1` to enable upgrading and configure the following:

UPGRADE_OLD_FUND_CONTROLLER=0x15c4ae284fbb3a6ceb41fa8eb5f3408ac485fabb
UPGRADE_OLD_FUND_MANAGER=0x6bdaf490c5b6bb58564b3e79c8d18e8dfd270464
UPGRADE_OLD_FUND_PROXY=0xb6b79D857858004BF475e4A57D4A446DA4884866
UPGRADE_OLD_FUND_TOKEN=0x9366B7C00894c3555c7590b0384e5F6a9D55659f
UPGRADE_FUND_OWNER_ADDRESS=0xb568a7a185305e1cc027e13a27db7c5bf99e81d8
UPGRADE_FUND_MANAGER_ADDRESS=0xC6BF8C8A55f77686720E0a88e2Fd1fEEF58ddf4a
UPGRADE_FUND_TOKEN_ADDRESS=0x016bf078ABcaCB987f0589a6d3BEAdD4316922B0
UPGRADE_FUND_OWNER_ADDRESS=0x10dB6Bce3F2AE1589ec91A872213DAE59697967a

Also, set `GANACHE_UPGRADE_FUND_TOKEN_HOLDERS` to a comma-separated list of all current RSPT holders (because `getPastEvents` does not work with Ganache).
Then, copy the OpenZeppelin artifacts for the official deployed `v2.0.0` contracts from `.openzeppelin/mainnet.json` to `.openzeppelin/unknown-1337.json`. If you decide to disable upgrading by setting restoring `UPGRADE_FROM_LAST_VERSION=0`, make sure to delete `.openzeppelin/unknown-1337.json`.

First, fork the Ethereum mainnet (tested on Node.js `v10.21.0`). To start the fork, configure `DEVELOPMENT_WEB3_PROVIDER_URL_TO_BE_FORKED` (set to any mainnet Web3 HTTP provider JSON-RPC URL; we use a local `geth` instance, specifically a light client started with `geth --syncmode light --rpc --rpcapi eth,web3,debug,net`; Infura works too, but beware of latency and rate limiting) in `.env` and run `npm run ganache`. *If you would like to change the port, make sure to configure `scripts/ganache.js`, `scripts/test.sh`, and the `development` network in `truffle-config.js`.* Note that you will likely have to regularly restart your fork, especially when forking from a node without archive data or when using live 0x API responses to make currency exchanges.
To test the contracts, first fork the Ethereum mainnet. Begin by configuring `DEVELOPMENT_WEB3_PROVIDER_URL_TO_BE_FORKED` in `.env` (set to any mainnet Web3 HTTP provider JSON-RPC URL; we use a local `geth` instance, specifically a light client started with `geth --syncmode light --rpc --rpcapi eth,web3,debug,net`; Infura works too, but beware of latency and rate limiting). To start the fork, run `npm run ganache`. *If you would like to change the port, make sure to configure `scripts/ganache.js`, `scripts/test.sh`, `scripts/migrate-dev.sh`, and the `development` network in `truffle-config.js`.* Note that you will likely have to regularly restart your fork, especially when forking from a node without archive data or when using live 0x API responses to make currency exchanges.

To deploy the contracts to your private mainnet fork: `truffle migrate --network development --skip-dry-run --reset`

To run automated tests on the contracts on your private mainnet fork, run `npm test` (which runs `npm run ganache` in the background for you).
To run automated tests on the contracts on your private mainnet fork, run `npm test` (which runs `npm run ganache` in the background for you). If you are upgrading from `v2.0.0`, you must also set the following variables in `.env`:

UPGRADE_FUND_CONTROLLER_ADDRESS=0xEe7162bB5191E8EC803F7635dE9A920159F1F40C
UPGRADE_FUND_PRICE_CONSUMER_ADDRESS=0x77a817077cd7Cf0c6e0d4d2c4464648FF6C3fdB8
UPGRADE_FUND_PROXY_ADDRESS=0xD4be7E211680e12c08bbE9054F0dA0D646c45228

If you'd like to test gasless deposits via `RariFundProxy.deposit` via the Gas Station Network:

Expand All @@ -60,17 +58,13 @@ If you'd like to test gasless deposits via `RariFundProxy.deposit` via the Gas S

In `.env`, configure `LIVE_DEPLOYER_ADDRESS`, `LIVE_DEPLOYER_PRIVATE_KEY`, `LIVE_WEB3_PROVIDER_URL`, `LIVE_GAS_PRICE` (ideally, use the "fast" price listed by [ETH Gas Station](https://www.ethgasstation.info/)), `LIVE_FUND_OWNER`, `LIVE_FUND_REBALANCER`, `LIVE_FUND_INTEREST_FEE_MASTER_BENEFICIARY`, and `LIVE_FUND_GSN_TRUSTED_SIGNER` to deploy to the mainnet.

If you are upgrading from `v1.2.0`, set `UPGRADE_FROM_LAST_VERSION=1` to enable upgrading and configure the following:

UPGRADE_OLD_FUND_CONTROLLER=0x15c4ae284fbb3a6ceb41fa8eb5f3408ac485fabb
UPGRADE_OLD_FUND_MANAGER=0x6bdaf490c5b6bb58564b3e79c8d18e8dfd270464
UPGRADE_OLD_FUND_PROXY=0xb6b79D857858004BF475e4A57D4A446DA4884866
UPGRADE_OLD_FUND_TOKEN=0x9366B7C00894c3555c7590b0384e5F6a9D55659f
UPGRADE_FUND_OWNER_ADDRESS=0xb568a7a185305e1cc027e13a27db7c5bf99e81d8
If you are upgrading from `v2.0.0`, set `UPGRADE_FROM_LAST_VERSION=1` to enable upgrading and configure the following:

You must also set `UPGRADE_FUND_OWNER_PRIVATE_KEY` and `UPGRADE_TIMESTAMP_COMP_CLAIMED_AND_EXCHANGED` (set to current timestamp after claiming and exchanging COMP via rebalancer; you must run migrations within 1 hour of this timestamp).
UPGRADE_FUND_MANAGER_ADDRESS=0xC6BF8C8A55f77686720E0a88e2Fd1fEEF58ddf4a
UPGRADE_FUND_TOKEN_ADDRESS=0x016bf078ABcaCB987f0589a6d3BEAdD4316922B0
UPGRADE_FUND_OWNER_ADDRESS=0x10dB6Bce3F2AE1589ec91A872213DAE59697967a

Furthermore, if you plan to migrate without the `--skip-dry-run` flag, set `GANACHE_UPGRADE_FUND_TOKEN_HOLDERS` to a comma-separated list of all current RSPT holders (because `getPastEvents` does not work with the Ganache fork used by the dry run).
You must also set `LIVE_UPGRADE_FUND_OWNER_PRIVATE_KEY`.

Then, migrate: `truffle migrate --network live`

Expand All @@ -80,14 +74,6 @@ If you'd like to provide gasless deposits via `RariFundProxy.deposit` via the Ga
* Run `rari-gsn-signer` with `pm2 start ecosystem.config.js --env production` after configuring `ecosystem.config.js`.
* *Please note that as of now, the web client and the GSN signer are configured so that gas is paid only for deposits of least 250 DAI/USDC/USDT by first-time users.*

## Building the dApp

`npm run build-dapp`

## Testing the dApp

`npm run dev-dapp`

## License

See `LICENSE`.
Expand Down
Loading

0 comments on commit 2d29bf6

Please sign in to comment.