Skip to content

Commit

Permalink
Merge pull request #16 from pooltogether/fix/update-optimism
Browse files Browse the repository at this point in the history
feat(deploy): add Optimism deploy script 1.6.1
  • Loading branch information
PierrickGT authored Jul 7, 2022
2 parents cc0b54b + 62bfadd commit 52f7de0
Show file tree
Hide file tree
Showing 26 changed files with 1,231 additions and 456 deletions.
2 changes: 1 addition & 1 deletion contracts.json

Large diffs are not rendered by default.

222 changes: 222 additions & 0 deletions deploy/v1.6.1/optimism.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
import { dim } from 'chalk';
import { HardhatRuntimeEnvironment } from 'hardhat/types';
import {
DRAW_BUFFER_CARDINALITY,
PRIZE_DISTRIBUTION_BUFFER_CARDINALITY,
PRIZE_DISTRIBUTION_FACTORY_MINIMUM_PICK_COST,
TOKEN_DECIMALS,
} from '../../src/constants';
import { deployAndLog } from '../../src/deployAndLog';
import { setPrizeStrategy } from '../../src/setPrizeStrategy';
import { setTicket } from '../../src/setTicket';
import { transferOwnership } from '../../src/transferOwnership';
import { setManager } from '../../src/setManager';
import { initPrizeSplit } from '../../src/initPrizeSplit';
import { pushDraw266 } from '../../src/v1.6.1/pushDraw266';
import { setTimelock } from '../../src/setTimelock';

export default async function deployToOptimism(hardhat: HardhatRuntimeEnvironment) {
if (process.env.DEPLOY === 'v1.6.1.optimism') {
dim(`Deploying: Receiver Chain Optimism Mainnet`);
dim(`Version: 1.6.1`);
} else {
return;
}

const { getNamedAccounts, ethers, getChainId } = hardhat;

const {
deployer,
executiveTeam,
ptOperations,
aUSDC,
defenderRelayer,
aaveIncentivesController,
aaveLendingPoolAddressesProviderRegistry,
} = await getNamedAccounts();

const chainId = parseInt(await getChainId(), 10);

dim(`chainId ${chainId} `);
dim(`---------------------------------------------------`);
dim(`Named Accounts`);
dim(`---------------------------------------------------`);
dim(`deployer: ${deployer}`);
dim(`executiveTeam: ${executiveTeam}`);
dim(`ptOperations: ${ptOperations}`);
dim(`defenderRelayer: ${defenderRelayer}`);
dim(`aUSDC: ${aUSDC}`);
dim(`aaveIncentivesController: ${aaveIncentivesController}`);
dim(`aaveLendingPoolAddressesProviderRegistry: ${aaveLendingPoolAddressesProviderRegistry}`);
dim(`---------------------------------------------------\n`);
const startingBalance = await ethers.provider.getBalance((await ethers.getSigners())[0].address);

// ===================================================
// Deploy Contracts
// ===================================================

const aaveUsdcYieldSourceResult = await deployAndLog('AaveV3YieldSource', {
from: deployer,
args: [
aUSDC,
aaveIncentivesController,
aaveLendingPoolAddressesProviderRegistry,
'PoolTogether aOptUSDC Yield',
'PTaOptUSDCY',
TOKEN_DECIMALS,
executiveTeam,
],
skipIfAlreadyDeployed: true,
});

const yieldSourcePrizePoolResult = await deployAndLog('YieldSourcePrizePool', {
from: deployer,
args: [deployer, aaveUsdcYieldSourceResult.address],
skipIfAlreadyDeployed: true,
});

const ticketResult = await deployAndLog('Ticket', {
from: deployer,
args: [
'PoolTogether aOptUSDC Ticket',
'PTaOptUSDC',
TOKEN_DECIMALS,
yieldSourcePrizePoolResult.address,
],
skipIfAlreadyDeployed: true,
});

const prizeTierHistoryResult = await deployAndLog('PrizeTierHistory', {
from: deployer,
args: [deployer],
skipIfAlreadyDeployed: true,
});

const drawBufferResult = await deployAndLog('DrawBuffer', {
from: deployer,
args: [deployer, DRAW_BUFFER_CARDINALITY],
skipIfAlreadyDeployed: true,
});

const prizeDistributionBufferResult = await deployAndLog('PrizeDistributionBuffer', {
from: deployer,
args: [deployer, PRIZE_DISTRIBUTION_BUFFER_CARDINALITY],
skipIfAlreadyDeployed: true,
});

const drawCalculatorResult = await deployAndLog('DrawCalculator', {
from: deployer,
args: [ticketResult.address, drawBufferResult.address, prizeDistributionBufferResult.address],
skipIfAlreadyDeployed: true,
});

const prizeSplitStrategyResult = await deployAndLog('PrizeSplitStrategy', {
from: deployer,
args: [deployer, yieldSourcePrizePoolResult.address],
skipIfAlreadyDeployed: true,
});

const reserveResult = await deployAndLog('Reserve', {
from: deployer,
args: [deployer, ticketResult.address],
skipIfAlreadyDeployed: true,
});

const drawCalculatorTimelockResult = await deployAndLog('DrawCalculatorTimelock', {
from: deployer,
args: [deployer, drawCalculatorResult.address],
skipIfAlreadyDeployed: true,
});

const prizeDistributorResult = await deployAndLog('PrizeDistributor', {
from: deployer,
args: [executiveTeam, ticketResult.address, drawCalculatorTimelockResult.address],
skipIfAlreadyDeployed: true,
});

const prizeDistributionFactoryResult = await deployAndLog('PrizeDistributionFactory', {
from: deployer,
args: [
deployer,
prizeTierHistoryResult.address,
drawBufferResult.address,
prizeDistributionBufferResult.address,
ticketResult.address,
PRIZE_DISTRIBUTION_FACTORY_MINIMUM_PICK_COST, // 1 USDC
],
skipIfAlreadyDeployed: true,
});

await deployAndLog('EIP2612PermitAndDeposit', { from: deployer, skipIfAlreadyDeployed: true });

const prizeFlushResult = await deployAndLog('PrizeFlush', {
from: deployer,
args: [
deployer,
prizeDistributorResult.address,
prizeSplitStrategyResult.address,
reserveResult.address,
],
skipIfAlreadyDeployed: true,
});

const receiverTimelockTrigger = await deployAndLog('ReceiverTimelockTrigger', {
from: deployer,
args: [
deployer,
drawBufferResult.address,
prizeDistributionFactoryResult.address,
drawCalculatorTimelockResult.address,
],
skipIfAlreadyDeployed: true,
});

await deployAndLog('TwabRewards', {
from: deployer,
args: [ticketResult.address],
skipIfAlreadyDeployed: true,
});

await deployAndLog('TWABDelegator', {
from: deployer,
args: ['PoolTogether Staked aOptUSDC Ticket', 'stkPTaOptUSDC', ticketResult.address],
skipIfAlreadyDeployed: true,
});

// ===================================================
// Configure Contracts
// ===================================================

await pushDraw266();
await initPrizeSplit();
await setTicket(ticketResult.address);
await setPrizeStrategy(prizeSplitStrategyResult.address);
await setTimelock({ timestamp: 1657300000, drawId: 265 });

await setManager('ReceiverTimelockTrigger', null, defenderRelayer);
await setManager('DrawBuffer', null, receiverTimelockTrigger.address);
await setManager('PrizeFlush', null, defenderRelayer);
await setManager('Reserve', null, prizeFlushResult.address);
await setManager('DrawCalculatorTimelock', null, receiverTimelockTrigger.address);
await setManager('PrizeDistributionFactory', null, receiverTimelockTrigger.address);
await setManager('PrizeDistributionBuffer', null, prizeDistributionFactoryResult.address);
await setManager('PrizeTierHistory', null, executiveTeam);

await transferOwnership('PrizeDistributionFactory', null, executiveTeam);
await transferOwnership('DrawCalculatorTimelock', null, executiveTeam);
await transferOwnership('PrizeFlush', null, executiveTeam);
await transferOwnership('Reserve', null, executiveTeam);
await transferOwnership('YieldSourcePrizePool', null, executiveTeam);
await transferOwnership('PrizeTierHistory', null, executiveTeam);
await transferOwnership('PrizeSplitStrategy', null, executiveTeam);
await transferOwnership('DrawBuffer', null, executiveTeam);
await transferOwnership('PrizeDistributionBuffer', null, executiveTeam);
await transferOwnership('ReceiverTimelockTrigger', null, executiveTeam);

dim(`---------------------------------------------------`);
const costToDeploy = startingBalance.sub(
await ethers.provider.getBalance((await ethers.getSigners())[0].address),
);
dim(`Final balance of deployer ${deployer}: ${ethers.utils.formatEther(costToDeploy)} ETH`);
dim(`---------------------------------------------------`);
}
58 changes: 29 additions & 29 deletions deployments/optimism/AaveV3YieldSource.json

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions deployments/optimism/DrawBuffer.json

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions deployments/optimism/DrawCalculator.json

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions deployments/optimism/DrawCalculatorTimelock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions deployments/optimism/EIP2612PermitAndDeposit.json

Large diffs are not rendered by default.

84 changes: 42 additions & 42 deletions deployments/optimism/PrizeDistributionBuffer.json

Large diffs are not rendered by default.

36 changes: 18 additions & 18 deletions deployments/optimism/PrizeDistributionFactory.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0xA843CFbf6549E3c93453A74e762f1af66575Ee89",
"address": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -571,43 +571,43 @@
"type": "function"
}
],
"transactionHash": "0xc41df3d0b30ffceacfe4653d8c2d5108d9372cdad7a44eefed0553de1c386cef",
"transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
"receipt": {
"to": null,
"from": "0xD7F73CbF2b6AC915976cC96706B76D6425fBC234",
"contractAddress": "0xA843CFbf6549E3c93453A74e762f1af66575Ee89",
"from": "0x4D40eb12430A57965cEe3015348d490C6156dF20",
"contractAddress": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
"transactionIndex": 0,
"gasUsed": "1398224",
"logsBloom": "0x00000000000000000004000000000000000000000000000000900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000020000000000080000000000000000000000000000001000000000000000000000000",
"blockHash": "0x1a48abf2b078e378009d92415f23bea2ba7e707c72ef8fb18bbe0ab04b2c32f9",
"transactionHash": "0xc41df3d0b30ffceacfe4653d8c2d5108d9372cdad7a44eefed0553de1c386cef",
"logsBloom": "0x00000000000000000000000000000000000000000000000000800000000000000000100000000000000000000040000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000020000000000000000000800000000000000000000000000000001400000000000000002000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000020000000000000000000000000000000000000000000000000000000000001000000",
"blockHash": "0xc0054414f5319987134a33eac6466e859fba32332504675ee909d44c13e1ee31",
"transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
"logs": [
{
"transactionIndex": 0,
"blockNumber": 13641404,
"transactionHash": "0xc41df3d0b30ffceacfe4653d8c2d5108d9372cdad7a44eefed0553de1c386cef",
"address": "0xA843CFbf6549E3c93453A74e762f1af66575Ee89",
"blockNumber": 14043055,
"transactionHash": "0x8b6c34d0ce2bff0eec08fce36be7102c06cde58757cc8f01b9c6a73c45d78d7e",
"address": "0x01A1F0699356afeB850f5A80226C35A9319CAf74",
"topics": [
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000d7f73cbf2b6ac915976cc96706b76d6425fbc234"
"0x0000000000000000000000004d40eb12430a57965cee3015348d490c6156df20"
],
"data": "0x",
"logIndex": 0,
"blockHash": "0x1a48abf2b078e378009d92415f23bea2ba7e707c72ef8fb18bbe0ab04b2c32f9"
"blockHash": "0xc0054414f5319987134a33eac6466e859fba32332504675ee909d44c13e1ee31"
}
],
"blockNumber": 13641404,
"blockNumber": 14043055,
"cumulativeGasUsed": "1398224",
"status": 1,
"byzantium": true
},
"args": [
"0xD7F73CbF2b6AC915976cC96706B76D6425fBC234",
"0x91A252E0bC6082e6cA0Fc554968177BC5dbd53f1",
"0xA2C882C66797b201788EEF25E3Ca3411204bf3D7",
"0x79ED98ef5561f1Ed3058acb5A30F05E8f64e560b",
"0x5E5b54cd73872ba3103cd95A58067A7079d0259b",
"0x4D40eb12430A57965cEe3015348d490C6156dF20",
"0xC88f04D5D00367Ecd016228302a1eACFaB164DBA",
"0x267DD4034830Bb4ba9314e0471C1dDFD79849777",
"0x8e4F3098192948E342fB11ED7C4a23CD5A306973",
"0x62BB4fc73094c83B5e952C2180B23fA7054954c4",
1000000
],
"numDeployments": 1,
Expand Down
62 changes: 31 additions & 31 deletions deployments/optimism/PrizeDistributor.json

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions deployments/optimism/PrizeFlush.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"address": "0xB47e3984B81298F10C0Ba75E26362E044B8488F9",
"address": "0x4c65F496B78b7E81c15723f56a43925E5dc3a0e1",
"abi": [
{
"inputs": [
Expand Down Expand Up @@ -356,57 +356,57 @@
"type": "function"
}
],
"transactionHash": "0xc47d6ebf362ce2737a3956956114804f2f5c49c11d125f56b90cac98f2f68cee",
"transactionHash": "0x3eb198671da2376d69de15c5f0005d7fd5ead3cfd20dde052eec2780f0496efd",
"receipt": {
"to": null,
"from": "0xD7F73CbF2b6AC915976cC96706B76D6425fBC234",
"contractAddress": "0xB47e3984B81298F10C0Ba75E26362E044B8488F9",
"from": "0x4D40eb12430A57965cEe3015348d490C6156dF20",
"contractAddress": "0x4c65F496B78b7E81c15723f56a43925E5dc3a0e1",
"transactionIndex": 0,
"gasUsed": "915560",
"logsBloom": "0x00000000000000000004000000000000000000000400800000800000000000000020000000000000000000000000000000000000000000000000000000000002000000000000000080001000000000000001000000000000000000000000000000000000120000000000000000000800200000000000000000000000000000400000000000000000000000000000000000000004000000000000000000000000000000200000000000000000000000000040000000000000200000000000000000800000000000000000400000000000000000000008000000000000000020000000000080000000000000000000000000000000000000100000000000000000",
"blockHash": "0xb3b55765f307cf5af75cb769494f8c1388c53ad8c423d79d751938d7681f0ee8",
"transactionHash": "0xc47d6ebf362ce2737a3956956114804f2f5c49c11d125f56b90cac98f2f68cee",
"gasUsed": "915548",
"logsBloom": "0x00000000000000000000000000020000100000000000800000800000000000100000000000000000000000000040000000000000010000000000000000000000000000000000000000000000000000000001000002000000000000000000000000000000020001000000000000000800200000000000000000000000000000400240000008000002000000000000000000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000400800000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000001000000",
"blockHash": "0x60048161aacbdd5f792aec968522e5497f078b42472dac11862eab8055c05cff",
"transactionHash": "0x3eb198671da2376d69de15c5f0005d7fd5ead3cfd20dde052eec2780f0496efd",
"logs": [
{
"transactionIndex": 0,
"blockNumber": 13641406,
"transactionHash": "0xc47d6ebf362ce2737a3956956114804f2f5c49c11d125f56b90cac98f2f68cee",
"address": "0xB47e3984B81298F10C0Ba75E26362E044B8488F9",
"blockNumber": 14043064,
"transactionHash": "0x3eb198671da2376d69de15c5f0005d7fd5ead3cfd20dde052eec2780f0496efd",
"address": "0x4c65F496B78b7E81c15723f56a43925E5dc3a0e1",
"topics": [
"0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0",
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x000000000000000000000000d7f73cbf2b6ac915976cc96706b76d6425fbc234"
"0x0000000000000000000000004d40eb12430a57965cee3015348d490c6156df20"
],
"data": "0x",
"logIndex": 0,
"blockHash": "0xb3b55765f307cf5af75cb769494f8c1388c53ad8c423d79d751938d7681f0ee8"
"blockHash": "0x60048161aacbdd5f792aec968522e5497f078b42472dac11862eab8055c05cff"
},
{
"transactionIndex": 0,
"blockNumber": 13641406,
"transactionHash": "0xc47d6ebf362ce2737a3956956114804f2f5c49c11d125f56b90cac98f2f68cee",
"address": "0xB47e3984B81298F10C0Ba75E26362E044B8488F9",
"blockNumber": 14043064,
"transactionHash": "0x3eb198671da2376d69de15c5f0005d7fd5ead3cfd20dde052eec2780f0496efd",
"address": "0x4c65F496B78b7E81c15723f56a43925E5dc3a0e1",
"topics": [
"0xc95935a66d15e0da5e412aca0ad27ae891d20b2fb91cf3994b6a3bf2b8178082",
"0x000000000000000000000000a365317291122b44a549c34a383ccd117b71941e",
"0x0000000000000000000000001bd4745df0b5286d410f22fe6d43e797c4d5ce98",
"0x000000000000000000000000a6ec73c91d0ae39a854bd50a6b1cf9aa7da46ba4"
"0x000000000000000000000000722e9bfc008358ac2d445a8d892cf7b62b550f3f",
"0x000000000000000000000000574834c934b3784aa8430a5b45724aaa2fcf2c7f",
"0x0000000000000000000000008d7355075b85b2add775e02ec581e0da66326e49"
],
"data": "0x",
"logIndex": 1,
"blockHash": "0xb3b55765f307cf5af75cb769494f8c1388c53ad8c423d79d751938d7681f0ee8"
"blockHash": "0x60048161aacbdd5f792aec968522e5497f078b42472dac11862eab8055c05cff"
}
],
"blockNumber": 13641406,
"cumulativeGasUsed": "915560",
"blockNumber": 14043064,
"cumulativeGasUsed": "915548",
"status": 1,
"byzantium": true
},
"args": [
"0xD7F73CbF2b6AC915976cC96706B76D6425fBC234",
"0xa365317291122b44a549C34a383CCd117b71941e",
"0xa6EC73C91D0aE39A854bd50A6b1cF9aA7da46Ba4",
"0x1bD4745df0b5286d410F22fE6d43E797C4d5ce98"
"0x4D40eb12430A57965cEe3015348d490C6156dF20",
"0x722e9BFC008358aC2d445a8d892cF7b62B550F3F",
"0x8d7355075B85B2aDD775E02ec581E0Da66326E49",
"0x574834c934B3784aa8430A5B45724aAa2FcF2c7f"
],
"numDeployments": 1,
"solcInputHash": "45c8f80dfd4edb590489bcbaf8232d24",
Expand Down
Loading

0 comments on commit 52f7de0

Please sign in to comment.