Skip to content

Commit

Permalink
feat: added tenderly proposal execution task
Browse files Browse the repository at this point in the history
  • Loading branch information
kartojal committed Apr 23, 2021
1 parent 1a363e7 commit 0ef0be1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tasks/migrations/incentives-submit-proposal-mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ task('incentives-submit-proposal:mainnet', 'Submit the incentives proposal to Aa
proposer = signer;
}

if (!AAVE_TOKEN || || !AAVE_GOVERNANCE_V2 || !AAVE_SHORT_EXECUTOR) {
if (!AAVE_TOKEN || !AAVE_GOVERNANCE_V2 || !AAVE_SHORT_EXECUTOR) {
throw new Error(
'You have not set correctly the .env file, make sure to read the README.md'
);
Expand Down
78 changes: 78 additions & 0 deletions tasks/migrations/tenderly-execute-proposal-fork.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { formatEther, parseEther } from 'ethers/lib/utils';
import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/dist/src/signer-with-address';
import { JsonRpcSigner } from '@ethersproject/providers';
import { task } from 'hardhat/config';
import { DRE, advanceBlockTo, latestBlock, increaseTime } from '../../helpers/misc-utils';
import { tEthereumAddress } from '../../helpers/types';
import { IERC20__factory, IGovernancePowerDelegationToken__factory } from '../../types';
import { IAaveGovernanceV2 } from '../../types/IAaveGovernanceV2';
import { logError } from '../../helpers/tenderly-utils';
import { getDefenderRelaySigner } from '../../helpers/defender-utils';
import { Signer } from 'ethers';

const {
AAVE_TOKEN = '0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9',
AAVE_GOVERNANCE_V2 = '0xEC568fffba86c094cf06b22134B23074DFE2252c',
} = process.env;

const VOTING_DURATION = 18200;

const AAVE_WHALE = '0x25f2226b597e8f9514b3f68f00f494cf4f286491';

const INCENTIVES_PROXY = '0xd784927Ff2f95ba542BfC824c8a8a98F3495f6b5';

task('execute-proposal:tenderly', 'Spin a tenderly fork with incentives activated')
.addParam('proposalId')
.setAction(async ({ proposalId }, localBRE) => {
let ethers;
let whale: JsonRpcSigner;
let proposer: Signer;
let gov: IAaveGovernanceV2;

await localBRE.run('set-DRE');

if (!localBRE.network.name.includes('tenderly')) {
console.error('You must connect to tenderly via --network tenderly to use this task.');
throw Error('tenderly-network-missing');
}

const [signer] = await DRE.ethers.getSigners();

proposer = signer;

const proposerAddress = await proposer.getAddress();

ethers = DRE.ethers;

// Impersonating holders
whale = ethers.provider.getSigner(AAVE_WHALE);

// Initialize contracts and tokens
gov = (await ethers.getContractAt(
'IAaveGovernanceV2',
AAVE_GOVERNANCE_V2,
whale
)) as IAaveGovernanceV2;

// Mine block due flash loan voting protection
await advanceBlockTo((await latestBlock()) + 100);

// Submit vote and advance block to Queue phase
await (await gov.submitVote(proposalId, true)).wait();

await advanceBlockTo((await latestBlock()) + VOTING_DURATION + 1);

try {
// Queue and advance block to Execution phase
await (await gov.queue(proposalId, { gasLimit: 3000000 })).wait();
} catch (error) {
logError();
throw error;
}

await increaseTime(86400 + 10);

// Execute payload
await (await gov.execute(proposalId)).wait();
console.log('Proposal executed');
});

0 comments on commit 0ef0be1

Please sign in to comment.