Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIP-55: PCV Guardian #353

Merged
merged 8 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions contract-addresses/permissions.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@
"feiDAOTimelock",
"ratioPCVController",
"aaveEthPCVDripController",
"compoundEthPCVDripController"
"compoundEthPCVDripController",
"pcvGuardian"
],
"GUARDIAN_ROLE": [
"multisig"
"multisig",
"pcvGuardian"
],
"ORACLE_ADMIN_ROLE" : [
"collateralizationOracleGuardian",
Expand Down
62 changes: 62 additions & 0 deletions proposals/dao/fip_55.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ethers } from 'hardhat';
import chai, { expect } from 'chai';
import CBN from 'chai-bn';
import {
DeployUpgradeFunc,
NamedContracts,
SetupUpgradeFunc,
TeardownUpgradeFunc,
ValidateUpgradeFunc
} from '../../types/types';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use shorthand

import { PCVGuardian } from '@custom-types/contracts';

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

/*
PCV Guardian

DEPLOY ACTIONS:

1. Deploy PCV Guardian

DAO ACTIONS:
1. Grant PCV Guardian GUARDIAN_ROLE
2. Grant PCV Guardian PCV_CONTROLLER_ROLE

*/

export const deploy: DeployUpgradeFunc = async (deployAddress, addresses, logging = false) => {
const { core, feiDAOTimelock, compoundEthPCVDeposit, ethReserveStabilizer, aaveEthPCVDeposit } = addresses;

if (!core) {
throw new Error('An environment variable contract address is not set');
}

// 1. Deploy PCV Guardian
const factory = await ethers.getContractFactory('PCVGuardian');
const safeAddresses = [feiDAOTimelock, compoundEthPCVDeposit, ethReserveStabilizer, aaveEthPCVDeposit];
const pcvGuardian = await factory.deploy(core, safeAddresses);

await pcvGuardian.deployTransaction.wait();

logging && console.log('pcvGuardian: ', pcvGuardian.address);

return {
pcvGuardian
} as NamedContracts;
};

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

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

export const validate: ValidateUpgradeFunc = async (addresses, oldContracts, contracts) => {
const pcvGuardian: PCVGuardian = contracts.pcvGuardian as PCVGuardian;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't need to cast to type of PCVGuardian as the artifact that is loaded from contracts should be correct.


const safeAddresses = await pcvGuardian.getSafeAddresses();
expect(safeAddresses.length).to.be.equal(4);
};
31 changes: 31 additions & 0 deletions proposals/description/fip_55.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ProposalDescription } from '@custom-types/types';

const fip_55: ProposalDescription = {
title: 'FIP-55: PCV Guardian',
commands: [
{
target: 'core',
values: '0',
method: 'grantGuardian(address)',
arguments: ['{pcvGuardian}'],
description: 'Grant PCV Guardian GUARDIAN_ROLE'
},
{
target: 'core',
values: '0',
method: 'grantPCVController(address)',
arguments: ['{pcvGuardian}'],
description: 'Grant PCV Guardian PCV_CONTROLLER_ROLE'
}
],
description: `
Create a PCV Guardian which can move PCV only to safe locations, namely other PCV deposits that are particularly low risk.

This would help save assets in the event of a hack or extreme market conditions if Fei Protocol has a heads up.

Code: https://github.com/fei-protocol/fei-protocol-core/pull/353
Discussion: https://tribe.fei.money/t/fip-55-pcv-guardian/3744
`
};

export default fip_55;
6 changes: 3 additions & 3 deletions test/integration/proposals_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ProposalsConfigMap } from '@custom-types/types';

// import fip_xx_proposal from '@proposals/description/fip_xx';

import permanently_revoke_burner_proposal from '@proposals/description/permanently_revoke_burner';
import fip_55_proposal from '@proposals/description/fip_55';

const proposals: ProposalsConfigMap = {
/*
Expand All @@ -13,11 +13,11 @@ const proposals: ProposalsConfigMap = {
proposal: fip_xx_proposal // full proposal file, imported from '@proposals/description/fip_xx.ts'
}
*/
permanently_revoke_burner: {
fip_55: {
deploy: true,
skipDAO: false,
totalValue: 0,
proposal: permanently_revoke_burner_proposal
proposal: fip_55_proposal
}
};

Expand Down