Skip to content

Commit

Permalink
Merge pull request #265 from fei-protocol/feat/rollback
Browse files Browse the repository at this point in the history
Add Roll changes to FIP-34
  • Loading branch information
Joeysantoro committed Oct 25, 2021
2 parents 1901f0e + 22a0ffe commit 137ccbc
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 73 deletions.
16 changes: 13 additions & 3 deletions proposals/dao/fip_34.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {
TeardownUpgradeFunc,
ValidateUpgradeFunc
} from '../../types/types';
import { FeiDAOTimelock } from '@custom-types/contracts';
import { getImpersonatedSigner } from '@test/helpers';

chai.use(CBN(ethers.BigNumber));

Expand All @@ -26,6 +28,7 @@ DEPLOY ACTIONS:
DAO ACTIONS:
1. Make OwnableTimedMinter a minter
2. Mint initial 100M FEI
*/

export const deploy: DeployUpgradeFunc = async (deployAddress, addresses, logging = false) => {
Expand All @@ -49,18 +52,25 @@ export const deploy: DeployUpgradeFunc = async (deployAddress, addresses, loggin
};

export const setup: SetupUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
logging && console.log('No setup for FIP-35');
const timelock: FeiDAOTimelock = contracts.feiDAOTimelock as FeiDAOTimelock;
await (await timelock.connect(await getImpersonatedSigner(addresses.multisig)).rollback()).wait();
};

export const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
logging && console.log('No teardown for FIP-35');
logging && console.log('No teardown for FIP-34');
};

export const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts) => {
const { fei, optimisticMinter, optimisticTimelock } = contracts;
const { fei, optimisticMinter, optimisticTimelock, feiDAOTimelock, feiDAO, timelock, tribe } = contracts;

expect(await fei.balanceOf(optimisticTimelock.address)).to.be.bignumber.greaterThan(
ethers.constants.WeiPerEther.mul(100_000_000)
);

expect(await optimisticMinter.owner()).to.be.equal(optimisticTimelock.address);
expect(await optimisticMinter.isTimeStarted()).to.be.true;
expect(await timelock.admin()).to.be.equal(feiDAO.address);
expect(await feiDAOTimelock.admin()).to.be.equal(feiDAO.address);
expect(await feiDAO.timelock()).to.be.equal(feiDAOTimelock.address);
expect(await tribe.minter()).to.be.equal(feiDAOTimelock.address);
};
4 changes: 2 additions & 2 deletions proposals/dao/fip_37.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ export const deploy: DeployUpgradeFunc = async (deployAddress, addresses, loggin
};

export const setup: SetupUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
logging && console.log('No setup for FIP-33');
logging && console.log('No setup for FIP-37');
};

export const teardown: TeardownUpgradeFunc = async (addresses, oldContracts, contracts, logging) => {
logging && console.log('No teardown for FIP-33');
logging && console.log('No teardown for FIP-37');
};

export const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts) => {
Expand Down
34 changes: 31 additions & 3 deletions proposals/description/fip_34.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
{
"proposal_title": "FIP-35: Optimistic Minter",
"proposal_title": "FIP-34: Optimistic Minter",
"proposal_commands": [
{
"target": "core",
"values": "0",
"method": "grantMinter(address)",
"arguments": ["{optimisticMinter}"],
"description": "Grant Minter optimistic Minter"
"description": "Grant FEI Minter role to optimistic Minter"
},
{
"target": "core",
"values": "0",
"method": "grantMinter(address)",
"arguments": ["{timelock}"],
"description": "Grant FEI Minter to timelock"
},
{
"target": "fei",
"values": "0",
"method": "mint(address,uint256)",
"arguments": ["{optimisticTimelock}", "100000000000000000000000000"],
"description": "Mint 100M FEI to OA timelock"
}
},
{
"target": "core",
"values": "0",
"method": "revokeMinter(address)",
"arguments": ["{timelock}"],
"description": "Revoke FEI Minter from timelock"
},
{
"target": "tribe",
"values": "0",
"method": "setMinter(address)",
"arguments": ["{feiDAOTimelock}"],
"description": "Set TRIBE minter to FEI DAO timelock"
},
{
"target": "feiDAO",
"values": "0",
"method": "updateTimelock(address)",
"arguments": ["{feiDAOTimelock}"],
"description": "Restore FEI DAO timelock"
}
]
}
4 changes: 4 additions & 0 deletions proposals/description/fip_34.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ Summary:
Grant optimistic approval the rate limited ability to mint FEI, to continue to fund DAO operations like FIP-13 lending deployments and potentially Liquidity-as-a-Service.
Additionally mint an initial 100M FEI to the timelock.

Also transitions remaining roles from FIP-31.

Motivation:
Instead of continually going back to the DAO to ask for more funding, Fei Protocol can deploy a contract which allows the OA timelock to mint FEI periodically.
This minter will have a hard rate limit on the amount minted. These mintings will still be subject to the 4 day timelock, but would not require governance intervention.

Unrelated to the main proposal, this proposal also transitions the Tribe minter role from the old DAO timelock to the new DAO timelock.

Forum discussion: https://tribe.fei.money/t/fip-34-fei-minting-for-optimistic-approval/3565
Code: https://github.com/fei-protocol/fei-protocol-core/pull/259
2 changes: 1 addition & 1 deletion proposals/description/fip_37.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"proposal_title": "FIP-33: TRIBE buybacks",
"proposal_title": "FIP-37: TRIBE buybacks",
"proposal_commands": [
{
"target": "core",
Expand Down
34 changes: 19 additions & 15 deletions scripts/utils/checkProposal.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { getAllContracts } from '../../test/integration/setup/loadContracts';
import hre, { ethers } from 'hardhat';
import { time } from '@openzeppelin/test-helpers';
import { NamedContracts, namedContractsToNamedAddresses, UpgradeFuncs } from '../../types/types';
import { getAllContracts, getAllContractAddresses } from '@test/integration/setup/loadContracts';
import { getImpersonatedSigner, time } from '@test/helpers';
import { NamedContracts, UpgradeFuncs } from '@custom-types/types';

import * as dotenv from 'dotenv';

Expand All @@ -22,16 +21,26 @@ async function checkProposal() {
throw new Error('DEPLOY_FILE or PROPOSAL_NUMBER env variable not set');
}

// Get the upgrade setup, run and teardown scripts
const proposalFuncs: UpgradeFuncs = await import(`@proposals/dao/${proposalName}`);

const contracts = (await getAllContracts()) as NamedContracts;

const { feiDAO } = contracts;
const contractAddresses = await getAllContractAddresses();

await hre.network.provider.request({
method: 'hardhat_impersonateAccount',
params: [voterAddress]
});
if (process.env.DO_SETUP) {
console.log('Setup');
await proposalFuncs.setup(
contractAddresses,
contracts as unknown as NamedContracts,
contracts as unknown as NamedContracts,
true
);
}

const voterSigner = await ethers.getSigner(voterAddress);
const { feiDAO } = contracts;

const voterSigner = await getImpersonatedSigner(voterAddress);

console.log(`Proposal Number: ${proposalNo}`);

Expand Down Expand Up @@ -76,11 +85,6 @@ async function checkProposal() {
await feiDAO['execute(uint256)'](proposalNo);
console.log('Success');

// Get the upgrade setup, run and teardown scripts
const proposalFuncs: UpgradeFuncs = await import(`../../proposals/dao/${proposalName}`);

const contractAddresses = namedContractsToNamedAddresses(contracts);

console.log('Teardown');
await proposalFuncs.teardown(
contractAddresses,
Expand Down
39 changes: 39 additions & 0 deletions scripts/utils/constructProposalCalldata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import constructProposal from './constructProposal';
import { BigNumber } from 'ethers';
import { Interface } from '@ethersproject/abi';
import { utils } from 'ethers';

type ExtendedAlphaProposal = {
targets: string[];
values: BigNumber[];
signatures: string[];
calldatas: string[];
description: string;
};

/**
* Take in a hardhat proposal object and output the proposal calldatas
* See `proposals/utils/getProposalCalldata.js` on how to construct the proposal calldata
*/
export async function constructProposalCalldata(proposalName: string): Promise<string> {
const proposal = (await constructProposal(proposalName)) as ExtendedAlphaProposal;

const proposeFuncFrag = new Interface([
'function propose(address[] memory targets,uint256[] memory values,bytes[] memory calldatas,string memory description) public returns (uint256)'
]);

const combinedCalldatas = [];
for (let i = 0; i < proposal.targets.length; i++) {
const sighash = utils.id(proposal.signatures[i]).slice(0, 10);
combinedCalldatas.push(`${sighash}${proposal.calldatas[i].slice(2)}`);
}

const calldata = proposeFuncFrag.encodeFunctionData('propose', [
proposal.targets,
proposal.values,
combinedCalldatas,
proposal.description
]);

return calldata;
}
2 changes: 1 addition & 1 deletion scripts/utils/exec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hre, { ethers } from 'hardhat';
import { time } from '@openzeppelin/test-helpers';
import { time } from '@test/helpers';

import * as dotenv from 'dotenv';

Expand Down
36 changes: 2 additions & 34 deletions scripts/utils/getProposalCalldata.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
import constructProposal from './constructProposal';
import * as dotenv from 'dotenv';
import { BigNumber } from 'ethers';
import { Interface } from '@ethersproject/abi';
import { utils } from 'ethers';
import { constructProposalCalldata } from './constructProposalCalldata';

dotenv.config();

type ExtendedAlphaProposal = {
targets: string[];
values: BigNumber[];
signatures: string[];
calldatas: string[];
description: string;
};

/**
* Take in a hardhat proposal object and output the proposal calldatas
* See `proposals/utils/getProposalCalldata.js` on how to construct the proposal calldata
Expand All @@ -25,28 +14,7 @@ async function getProposalCalldata() {
throw new Error('DEPLOY_FILE env variable not set');
}

const proposal = (await constructProposal(proposalName)) as ExtendedAlphaProposal;

const proposeFuncFrag = new Interface([
'function propose(address[] memory targets,uint256[] memory values,bytes[] memory calldatas,string memory description) public returns (uint256)'
]);

const combinedCalldatas = [];
for (let i = 0; i < proposal.targets.length; i++) {
const sighash = utils.id(proposal.signatures[i]).slice(0, 10);
combinedCalldatas.push(`${sighash}${proposal.calldatas[i].slice(2)}`);
}

console.log(combinedCalldatas);

const calldata = proposeFuncFrag.encodeFunctionData('propose', [
proposal.targets,
proposal.values,
combinedCalldatas,
proposal.description
]);

console.log(calldata);
console.log(await constructProposalCalldata(proposalName));
}

getProposalCalldata()
Expand Down
4 changes: 2 additions & 2 deletions test/integration/proposals_config.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"fip_33" : {
"fip_34" : {
"deploy" : false
},
"fip_35" : {
"fip_37" : {
"deploy" : false
}
}
5 changes: 4 additions & 1 deletion test/integration/tests/bondingcurve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { expectApprox, resetFork, time } from '@test/helpers';
import proposals from '@test/integration/proposals_config.json';
import { TestEndtoEndCoordinator } from '@test/integration/setup';
import { forceEth } from '@test/integration/setup/utils';
import { UniswapPCVDeposit } from '@custom-types/contracts';

const toBN = ethers.BigNumber.from;

Expand Down Expand Up @@ -193,9 +194,11 @@ describe('e2e-bondingcurve', function () {

it('should transfer allocation from dpi bonding curve to the uniswap deposit and Fuse', async function () {
const bondingCurve = contracts.dpiBondingCurve;
const uniswapPCVDeposit = contracts.dpiUniswapPCVDeposit;
const uniswapPCVDeposit: UniswapPCVDeposit = contracts.dpiUniswapPCVDeposit as UniswapPCVDeposit;
const fusePCVDeposit = contracts.indexCoopFusePoolDpiPCVDeposit;

await uniswapPCVDeposit.setMaxBasisPointsFromPegLP(10_000);

const pcvAllocations = await bondingCurve.getAllocation();
expect(pcvAllocations[0].length).to.be.equal(2);

Expand Down
4 changes: 1 addition & 3 deletions test/integration/tests/dao.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,10 @@ describe('e2e-dao', function () {
}
}

/*
doLogging && console.log(`Testing tribe minter address...`);
const tribe = contracts.tribe;
const tribeMinter = await tribe.minter();
expect(tribeMinter).to.equal(contractAddresses.tribeReserveStabilizer);
*/ // TODO re-enable after tribe reserve stabilizer is deployed
expect(tribeMinter).to.equal(contractAddresses.feiDAOTimelock);
});
});
});
Loading

0 comments on commit 137ccbc

Please sign in to comment.