Skip to content

Commit

Permalink
Merge pull request #106 from curvefi/chore/housekeeping
Browse files Browse the repository at this point in the history
Repo Housekeeping
  • Loading branch information
iamdefinitelyahuman authored Jun 12, 2021
2 parents bed289d + 1ba3ac5 commit f6681bd
Show file tree
Hide file tree
Showing 100 changed files with 288 additions and 353 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 20.8b1
hooks:
- id: black
- repo: https://gitlab.com/pycqa/flake8
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ Vyper contracts used in the [Curve](https://www.curve.fi/) Governance DAO.

Curve DAO consists of multiple smart contracts connected by [Aragon](https://github.com/aragon/aragonOS). Interaction with Aragon occurs through a [modified implementation](https://github.com/curvefi/curve-aragon-voting) of the [Aragon Voting App](https://github.com/aragon/aragon-apps/tree/master/apps/voting). Aragon's standard one token, one vote method is replaced with a weighting system based on locking tokens. Curve DAO has a token (CRV) which is used for both governance and value accrual.

View the [documentation](doc/readme.pdf) for a more in-depth explanation of how Curve DAO works.
View the [documentation](https://curve.readthedocs.io/dao-overview.html) for a more in-depth explanation of how Curve DAO works.

## Testing and Development

### Dependencies

- [python3](https://www.python.org/downloads/release/python-368/) version 3.6 or greater, python3-dev
- [vyper](https://github.com/vyperlang/vyper) version [0.2.4](https://github.com/vyperlang/vyper/releases/tag/v0.2.4)
- [brownie](https://github.com/iamdefinitelyahuman/brownie) - tested with version [1.13.0](https://github.com/eth-brownie/brownie/releases/tag/v1.13.0)
- [brownie-token-tester](https://github.com/iamdefinitelyahuman/brownie-token-tester) - tested with version [0.1.0](https://github.com/iamdefinitelyahuman/brownie-token-tester/releases/tag/v0.1.0)
- [brownie](https://github.com/iamdefinitelyahuman/brownie) - tested with version [1.14.6](https://github.com/eth-brownie/brownie/releases/tag/v1.14.6)
- [brownie-token-tester](https://github.com/iamdefinitelyahuman/brownie-token-tester) - tested with version [0.2.2](https://github.com/iamdefinitelyahuman/brownie-token-tester/releases/tag/v0.2.2)
- [ganache-cli](https://github.com/trufflesuite/ganache-cli) - tested with version [6.12.1](https://github.com/trufflesuite/ganache-cli/releases/tag/v6.12.1)

### Setup
Expand Down
4 changes: 3 additions & 1 deletion contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ All contract sources are within this directory.

## Subdirectories

* [`gauges`](gauges): Contracts used for measuring provided liquidity
* [`burners`](burners): Contracts used to convert admin fees into 3CRV prior to distribution to the DAO.
* [`gauges`](gauges): Contracts used for measuring provided liquidity.
* [`testing`](testing): Contracts used exclusively for testing. Not considered to be a core part of this project.
* [`vests`](vests): Contracts for vesting CRV.

## Contracts

Expand Down
5 changes: 5 additions & 0 deletions contracts/burners/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# curve-dao-contracts/contracts/burners/deprecated

Contracts used to convert admin fees into 3CRV prior to distribution to the DAO.

View the [documentation](https://curve.readthedocs.io/dao-fees.html#the-burn-process) to learn more about the fee burning process and how to interact with these contracts.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions contracts/burners/deprecated/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# curve-dao-contracts/contracts/burners/deprecated

Fee burner contracts which are no longer in use.
17 changes: 6 additions & 11 deletions contracts/gauges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@

Contracts used for measuring provided liquidity within Curve pools.

## Contracts
You can read the [documentation](https://curve.readthedocs.io/dao-gauges.html) to learn more about Curve gauges.

### Gauges
## Contracts

* [`LiquidityGaugeV3`](LiquidityGaugeV3.vy): Tokenized liquidity gauge further optimized for gas efficiency.
* [`LiquidityGaugeV2`](LiquidityGaugeV2.vy): Tokenized liquidity gauge with generalized onward staking and support for multiple reward tokens.
* [`LiquidityGauge`](LiquidityGauge.vy): Measures the amount of liquidity provided by each user
* [`LiquidityGaugeReward`](LiquidityGaugeReward.vy): Measures provided liquidity and stakes using [Synthetix rewards contract](https://github.com/Synthetixio/synthetix/blob/master/contracts/StakingRewards.sol)

### Wrappers

Wrappers are used to tokenize deposits in first-gen gauges.

* [`LiquidityGaugeRewardWrapper`](LiquidityGaugeRewardWrapper.vy): ERC20 wrapper for depositing into[`LiquidityGaugeReward`](LiquidityGaugeReward.vy)
* [`LiquidityGaugeWrapper`](LiquidityGaugeWrapper.vy): ERC20 wrapper for depositing into [`LiquidityGauge`](LiquidityGauge.vy)
* [`LiquidityGauge`](LiquidityGauge.vy): Measures the amount of liquidity provided by each user.
* [`LiquidityGaugeReward`](LiquidityGaugeReward.vy): Measures provided liquidity and stakes using the [Synthetix rewards contract](https://github.com/curvefi/unipool-fork).
* [`RewardsOnlyGauge`](RewardsOnlyGauge.vy): Handles distribution of 3rd-party incentives without receiving CRV emissions. Typically used on sidechains.
File renamed without changes.
9 changes: 9 additions & 0 deletions contracts/gauges/wrappers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# curve-dao-contracts/contracts/gauges/wrappers

Wrappers are used to tokenize deposits in first-gen gauges.

## Contracts

* [`LiquidityGaugeRewardWrapper`](LiquidityGaugeRewardWrapper.vy): ERC20 wrapper for depositing into[`LiquidityGaugeReward`](LiquidityGaugeReward.vy)
* [`LiquidityGaugeWrapper`](LiquidityGaugeWrapper.vy): ERC20 wrapper for depositing into [`LiquidityGauge`](LiquidityGauge.vy)
* [`LiquidityGaugeWrapperUnit`](LiquidityGaugeWrapper.vy): Tokenizes gauge deposits to allow claiming of CRV when deposited as a collateral within the [unit.xyz](https://unit.xyz/) vault.
73 changes: 0 additions & 73 deletions contracts/testing/ERC20.vy

This file was deleted.

8 changes: 4 additions & 4 deletions contracts/testing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contracts used exclusively for testing. These are not considered part of Curve D

## Contracts

* [`CurvePool`](CurvePool.vy): Curve [pool contract](https://github.com/curvefi/curve-contract) for two plain coins
* [`CurveRewards`](CurveRewards.sol): Synthetix [LP Rewards](https://etherscan.io/address/0xdcb6a51ea3ca5d3fd898fd6564757c7aaec3ca92#code) contract
* [`ERC20`](ERC20.vy): Mintable mock ERC20
* [`ERC20LP`](ERC20LP.vy): Curve LP ERC20
* [`CurvePool`](CurvePool.vy): Curve [pool contract](https://github.com/curvefi/curve-contract) for two plain coins.
* [`CurveRewards`](CurveRewards.sol): Synthetix [LP Rewards](https://etherscan.io/address/0xdcb6a51ea3ca5d3fd898fd6564757c7aaec3ca92#code) contract.
* [`ERC20LP`](ERC20LP.vy): Curve LP ERC20.
* [`UnitVault`](UnitVault.vy): Minimal mock of [unit.xyz](https://unit.xyz/) [`Vault`](https://github.com/unitprotocol/core/blob/master/contracts/Vault.sol) contract.
9 changes: 9 additions & 0 deletions contracts/vests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# curve-dao-contracts/contracts/vests

Contracts for vesting CRV.

## Contracts

* [`VestingEscrow`](VestingEscrow.vy): Vests CRV tokens for multiple addresses over multiple vesting periods
* [`VestingEscrowFactory`](VestingEscrowFactory.vy): Factory to store CRV and deploy many simplified vesting contracts
* [`VestingEscrowSimple`](VestingEscrowSimple.vy): Simplified vesting contract that holds CRV for a single address
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
black==19.10b0
eth-brownie>=1.13.0,<2.0.0
black==20.8b1
eth-brownie>=1.14.6,<2.0.0
flake8==3.8.4
isort==5.7.0
brownie-token-tester>=0.1.0
brownie-token-tester>=0.2.2
2 changes: 1 addition & 1 deletion scripts/burners/deploy_burners_fee_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def main(deployer=DEPLOYER):

# approve USDN burner to donate to USDN pool
proxy.set_donate_approval(
"0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1", usdn_burner, True, {"from": deployer},
"0x0f9cb53Ebe405d49A0bbdBD291A65Ff571bC83e1", usdn_burner, True, {"from": deployer}
)

# set PoolProxy ownership
Expand Down
2 changes: 1 addition & 1 deletion scripts/burners/simulate_fee_distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def main():

# transfer 2m USD of 3CRV
fee_token.mint(
distributor, 2000000 * 10 ** 18, {"from": "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"},
distributor, 2000000 * 10 ** 18, {"from": "0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7"}
)

distributor.checkpoint_token()
Expand Down
6 changes: 3 additions & 3 deletions scripts/deployment/deploy_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def live_part_two():
voting_escrow = VotingEscrow.at(deployments["VotingEscrow"])

deploy_part_two(
admin, token, voting_escrow, config.REQUIRED_CONFIRMATIONS, config.DEPLOYMENTS_JSON,
admin, token, voting_escrow, config.REQUIRED_CONFIRMATIONS, config.DEPLOYMENTS_JSON
)


Expand Down Expand Up @@ -116,9 +116,9 @@ def deploy_part_two(admin, token, voting_escrow, confs=1, deployments_json=None)
gauge_controller.add_gauge(gauge, 0, weight, {"from": admin, "required_confs": confs})
deployments["LiquidityGauge"][name] = gauge.address

for (name, (lp_token, reward_claim, reward_token, weight),) in REWARD_POOL_TOKENS.items():
for (name, (lp_token, reward_claim, reward_token, weight)) in REWARD_POOL_TOKENS.items():
gauge = LiquidityGaugeReward.deploy(
lp_token, minter, reward_claim, reward_token, {"from": admin, "required_confs": confs},
lp_token, minter, reward_claim, reward_token, {"from": admin, "required_confs": confs}
)
gauge_controller.add_gauge(gauge, 0, weight, {"from": admin, "required_confs": confs})
deployments["LiquidityGaugeReward"][name] = gauge.address
Expand Down
61 changes: 22 additions & 39 deletions scripts/deployment/deploy_testnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ def save_abi(contract, name):
def deploy_erc20s_and_pool(deployer):
coin_a = repeat(ERC20.deploy, "Coin A", "USDA", 18, {"from": deployer, "required_confs": CONFS})
repeat(
coin_a._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS},
coin_a._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS}
)
coin_b = repeat(ERC20.deploy, "Coin B", "USDB", 18, {"from": deployer, "required_confs": CONFS})
repeat(
coin_b._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS},
coin_b._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS}
)

lp_token = repeat(
ERC20LP.deploy, "Some pool", "cPool", 18, 0, {"from": deployer, "required_confs": CONFS},
ERC20LP.deploy, "Some pool", "cPool", 18, 0, {"from": deployer, "required_confs": CONFS}
)
save_abi(lp_token, "lp_token")
pool = repeat(
Expand Down Expand Up @@ -101,17 +101,10 @@ def deploy_erc20s_and_pool(deployer):
)

repeat(
pool.commit_transfer_ownership, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS},
pool.commit_transfer_ownership, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS}
)
repeat(pool.apply_transfer_ownership, {"from": deployer, "required_confs": CONFS})

# repeat(
# registry.commit_transfer_ownership,
# ARAGON_AGENT,
# {"from": deployer, "required_confs": CONFS},
# )
# repeat(registry.apply_transfer_ownership, {"from": deployer, "required_confs": CONFS})

return [lp_token, coin_a]


Expand All @@ -130,15 +123,15 @@ def main():

coin_a = repeat(ERC20.deploy, "Coin A", "USDA", 18, {"from": deployer, "required_confs": CONFS})
repeat(
coin_a._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS},
coin_a._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS}
)
coin_b = repeat(ERC20.deploy, "Coin B", "USDB", 18, {"from": deployer, "required_confs": CONFS})
repeat(
coin_b._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS},
coin_b._mint_for_testing, 10 ** 9 * 10 ** 18, {"from": deployer, "required_confs": CONFS}
)

lp_token = repeat(
ERC20LP.deploy, "Some pool", "cPool", 18, 0, {"from": deployer, "required_confs": CONFS},
ERC20LP.deploy, "Some pool", "cPool", 18, 0, {"from": deployer, "required_confs": CONFS}
)
save_abi(lp_token, "lp_token")
pool = repeat(
Expand Down Expand Up @@ -166,14 +159,12 @@ def main():
)

contract = repeat(
CurveRewards.deploy, lp_token, coin_a, {"from": accounts[0], "required_confs": CONFS},
)
repeat(
contract.setRewardDistribution, accounts[0], {"from": accounts[0], "required_confs": CONFS},
CurveRewards.deploy, lp_token, coin_a, {"from": accounts[0], "required_confs": CONFS}
)
repeat(
coin_a.transfer, contract, 100e18, {"from": accounts[0], "required_confs": CONFS},
contract.setRewardDistribution, accounts[0], {"from": accounts[0], "required_confs": CONFS}
)
repeat(coin_a.transfer, contract, 100e18, {"from": accounts[0], "required_confs": CONFS})

liquidity_gauge_rewards = repeat(
LiquidityGaugeReward.deploy,
Expand All @@ -190,7 +181,7 @@ def main():
coin_a = coins[1]

token = repeat(
ERC20CRV.deploy, "Curve DAO Token", "CRV", 18, {"from": deployer, "required_confs": CONFS},
ERC20CRV.deploy, "Curve DAO Token", "CRV", 18, {"from": deployer, "required_confs": CONFS}
)
save_abi(token, "token_crv")

Expand All @@ -204,9 +195,7 @@ def main():
)
save_abi(escrow, "voting_escrow")

repeat(
escrow.changeController, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS},
)
repeat(escrow.changeController, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS})

for account in DISTRIBUTION_ADDRESSES:
repeat(
Expand All @@ -217,29 +206,27 @@ def main():
)

gauge_controller = repeat(
GaugeController.deploy, token, escrow, {"from": deployer, "required_confs": CONFS},
GaugeController.deploy, token, escrow, {"from": deployer, "required_confs": CONFS}
)
save_abi(gauge_controller, "gauge_controller")

minter = repeat(
Minter.deploy, token, gauge_controller, {"from": deployer, "required_confs": CONFS},
Minter.deploy, token, gauge_controller, {"from": deployer, "required_confs": CONFS}
)
save_abi(minter, "minter")

liquidity_gauge = repeat(
LiquidityGauge.deploy, lp_token, minter, {"from": deployer, "required_confs": CONFS},
LiquidityGauge.deploy, lp_token, minter, {"from": deployer, "required_confs": CONFS}
)
save_abi(liquidity_gauge, "liquidity_gauge")

contract = repeat(
CurveRewards.deploy, lp_token, coin_a, {"from": accounts[0], "required_confs": CONFS},
CurveRewards.deploy, lp_token, coin_a, {"from": accounts[0], "required_confs": CONFS}
)
repeat(
contract.setRewardDistribution, accounts[0], {"from": accounts[0], "required_confs": CONFS},
)
repeat(
coin_a.transfer, contract, 100e18, {"from": accounts[0], "required_confs": CONFS},
contract.setRewardDistribution, accounts[0], {"from": accounts[0], "required_confs": CONFS}
)
repeat(coin_a.transfer, contract, 100e18, {"from": accounts[0], "required_confs": CONFS})

liquidity_gauge_rewards = repeat(
LiquidityGaugeReward.deploy,
Expand All @@ -251,9 +238,7 @@ def main():
)

repeat(token.set_minter, minter, {"from": deployer, "required_confs": CONFS})
repeat(
gauge_controller.add_type, b"Liquidity", {"from": deployer, "required_confs": CONFS},
)
repeat(gauge_controller.add_type, b"Liquidity", {"from": deployer, "required_confs": CONFS})
repeat(
gauge_controller.change_type_weight,
0,
Expand All @@ -269,7 +254,7 @@ def main():
)

repeat(
gauge_controller.add_type, b"LiquidityRewards", {"from": deployer, "required_confs": CONFS},
gauge_controller.add_type, b"LiquidityRewards", {"from": deployer, "required_confs": CONFS}
)
repeat(
gauge_controller.change_type_weight,
Expand All @@ -290,11 +275,9 @@ def main():
ARAGON_AGENT,
{"from": deployer, "required_confs": CONFS},
)
repeat(gauge_controller.apply_transfer_ownership, {"from": deployer, "required_confs": CONFS})
repeat(
gauge_controller.apply_transfer_ownership, {"from": deployer, "required_confs": CONFS},
)
repeat(
escrow.commit_transfer_ownership, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS},
escrow.commit_transfer_ownership, ARAGON_AGENT, {"from": deployer, "required_confs": CONFS}
)
repeat(escrow.apply_transfer_ownership, {"from": deployer, "required_confs": CONFS})

Expand Down
Loading

0 comments on commit f6681bd

Please sign in to comment.