Skip to content

Commit

Permalink
Renamed ComptrollerV2 to TokenFaucet
Browse files Browse the repository at this point in the history
  • Loading branch information
asselstine committed Jan 28, 2021
1 parent 33ad8ed commit 5f82901
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
pragma solidity >=0.6.0 <0.7.0;
pragma experimental ABIEncoderV2;

import "../comptroller/ComptrollerV2.sol";
import "../token-faucet/TokenFaucet.sol";

/* solium-disable security/no-block-members */
contract ComptrollerV2Harness is ComptrollerV2 {
contract TokenFaucetHarness is TokenFaucet {

uint32 internal time;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "../token/TokenListener.sol";
/// @notice The tokens are dripped at a "drip rate per second". This is the number of tokens that
/// are dripped each second. A user's share of the dripped tokens is based on how many 'measure' tokens they hold.
/* solium-disable security/no-block-members */
contract ComptrollerV2 is OwnableUpgradeable, TokenListener {
contract TokenFaucet is OwnableUpgradeable, TokenListener {
using SafeMathUpgradeable for uint256;
using SafeCastUpgradeable for uint256;
using ExtendedSafeCast for uint256;
Expand Down Expand Up @@ -77,6 +77,7 @@ contract ComptrollerV2 is OwnableUpgradeable, TokenListener {
) public initializer {
__Ownable_init();
lastDripTimestamp = _currentTime();
require(_dripRatePerSecond > 0, "TokenFaucet/dripRate-gt-zero");
asset = _asset;
measure = _measure;
setDripRatePerSecond(_dripRatePerSecond);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

pragma solidity >=0.6.0 <0.7.0;

import "./ComptrollerV2.sol";
import "./TokenFaucet.sol";
import "../external/openzeppelin/ProxyFactory.sol";

/// @title Stake Prize Pool Proxy Factory
/// @notice Minimal proxy pattern for creating new ComptrollerV2 contracts
contract ComptrollerV2ProxyFactory is ProxyFactory {
/// @notice Minimal proxy pattern for creating new TokenFaucet contracts
contract TokenFaucetProxyFactory is ProxyFactory {

/// @notice Contract template for deploying proxied Comptrollers
ComptrollerV2 public instance;
TokenFaucet public instance;

/// @notice Initializes the Factory with an instance of the ComptrollerV2
/// @notice Initializes the Factory with an instance of the TokenFaucet
constructor () public {
instance = new ComptrollerV2();
instance = new TokenFaucet();
}

/// @notice Creates a new Comptroller V2
Expand All @@ -26,8 +26,8 @@ contract ComptrollerV2ProxyFactory is ProxyFactory {
IERC20Upgradeable _asset,
IERC20Upgradeable _measure,
uint256 _dripRatePerSecond
) external returns (ComptrollerV2) {
ComptrollerV2 comptroller = ComptrollerV2(deployMinimal(address(instance), ""));
) external returns (TokenFaucet) {
TokenFaucet comptroller = TokenFaucet(deployMinimal(address(instance), ""));
comptroller.initialize(
_asset, _measure, _dripRatePerSecond
);
Expand All @@ -38,7 +38,7 @@ contract ComptrollerV2ProxyFactory is ProxyFactory {
/// @notice Runs claim on all passed comptrollers for a user.
/// @param user The user to claim for
/// @param comptrollers The comptrollers to call claim on.
function claimAll(address user, ComptrollerV2[] calldata comptrollers) external {
function claimAll(address user, TokenFaucet[] calldata comptrollers) external {
for (uint256 i = 0; i < comptrollers.length; i++) {
comptrollers[i].claim(user);
}
Expand Down
4 changes: 2 additions & 2 deletions deploy/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ module.exports = async (buidler) => {
debug(` Using existing comptroller ${comptrollerAddress}`)
}

const comptrollerV2ProxyFactoryResult = await deploy("ComptrollerV2ProxyFactory", {
const comptrollerV2ProxyFactoryResult = await deploy("TokenFaucetProxyFactory", {
from: deployer,
skipIfAlreadyDeployed: true
})
Expand Down Expand Up @@ -289,7 +289,7 @@ module.exports = async (buidler) => {
debug(" - TicketProxyFactory: ", ticketProxyFactoryResult.address)
debug(" - Reserve Registry: ", reserveRegistry)
debug(" - Comptroller: ", comptrollerAddress)
debug(" - ComptrollerV2ProxyFactory: ", comptrollerV2ProxyFactoryResult.address)
debug(" - TokenFaucetProxyFactory: ", comptrollerV2ProxyFactoryResult.address)
debug(" - UnsafeTokenListenerDelegatorProxyFactory ", unsafeTokenListenerDelegatorProxyFactoryResult.address)
debug(" - CompoundPrizePoolProxyFactory: ", compoundPrizePoolProxyFactoryResult.address)
debug(" - StakePrizePoolProxyFactory: ", stakePrizePoolProxyFactoryResult.address)
Expand Down
8 changes: 4 additions & 4 deletions test/ComptrollerV2.test.js → test/TokenFaucet.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { expect } = require("chai");
const ComptrollerV2Harness = require('../build/ComptrollerV2Harness.json')
const TokenFaucetHarness = require('../build/TokenFaucetHarness.json')
const ERC20 = require('../build/ERC20Mintable.json')
const buidler = require('@nomiclabs/buidler')
const { deployContract } = require('ethereum-waffle')
Expand All @@ -9,9 +9,9 @@ const toWei = ethers.utils.parseEther

const overrides = { gasLimit: 20000000 }

const debug = require('debug')('ptv3:ComptrollerV2.test')
const debug = require('debug')('ptv3:TokenFaucet.test')

describe('ComptrollerV2', () => {
describe('TokenFaucet', () => {

let wallet, wallet2

Expand All @@ -25,7 +25,7 @@ describe('ComptrollerV2', () => {
dripToken = await deployContract(wallet, ERC20, ['DripToken', 'DRIP'])
dripRatePerSecond = ethers.utils.parseEther('0.1')

comptroller = await deployContract(wallet, ComptrollerV2Harness, [], overrides)
comptroller = await deployContract(wallet, TokenFaucetHarness, [], overrides)

await expect(comptroller.initialize(
dripToken.address,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const { expect } = require("chai");
const ERC20 = require('../build/ERC20Mintable.json')
const ComptrollerV2 = require('../build/ComptrollerV2.json')
const TokenFaucet = require('../build/TokenFaucet.json')
const buidler = require('@nomiclabs/buidler')
const { deployContract, deployMockContract } = require('ethereum-waffle')
const { deployments } = require("@nomiclabs/buidler")

let overrides = { gasLimit: 20000000 }

describe('ComptrollerV2ProxyFactory', () => {
describe('TokenFaucetProxyFactory', () => {

let wallet, wallet2

Expand All @@ -21,8 +21,8 @@ describe('ComptrollerV2ProxyFactory', () => {
measure = await deployContract(wallet, ERC20, ['Measure', 'MEAS'])
asset = await deployContract(wallet, ERC20, ['DripToken', 'DRIP'])
await deployments.fixture()
let comptrollerV2ProxyFactoryResult = await deployments.get("ComptrollerV2ProxyFactory")
comptrollerV2ProxyFactory = await buidler.ethers.getContractAt('ComptrollerV2ProxyFactory', comptrollerV2ProxyFactoryResult.address, wallet)
let comptrollerV2ProxyFactoryResult = await deployments.get("TokenFaucetProxyFactory")
comptrollerV2ProxyFactory = await buidler.ethers.getContractAt('TokenFaucetProxyFactory', comptrollerV2ProxyFactoryResult.address, wallet)
})

describe('create()', () => {
Expand All @@ -32,7 +32,7 @@ describe('ComptrollerV2ProxyFactory', () => {
let event = comptrollerV2ProxyFactory.interface.parseLog(receipt.logs[0])
expect(event.name).to.equal('ProxyCreated')

let comptrollerV2 = await buidler.ethers.getContractAt("ComptrollerV2", event.args.proxy, wallet)
let comptrollerV2 = await buidler.ethers.getContractAt("TokenFaucet", event.args.proxy, wallet)

expect(await comptrollerV2.asset()).to.equal(asset.address)
expect(await comptrollerV2.measure()).to.equal(measure.address)
Expand All @@ -44,7 +44,7 @@ describe('ComptrollerV2ProxyFactory', () => {

describe('claimAll', () => {
it('should call claim on comptrollers', async () => {
let comptroller = await deployMockContract(wallet, ComptrollerV2.abi, overrides)
let comptroller = await deployMockContract(wallet, TokenFaucet.abi, overrides)
await comptroller.mock.claim.withArgs(wallet._address).revertsWithReason("it was called!")

await expect(comptrollerV2ProxyFactory.claimAll(wallet._address, [comptroller.address]))
Expand Down

0 comments on commit 5f82901

Please sign in to comment.