@gooddollar/goodprotocol 1.0.13-beta.0 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
- package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
- package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
- package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
- package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
- package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
- package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
- package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
- package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.json +2 -2
- package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.json +2 -2
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.json +2 -2
- package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
- package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.json +2 -2
- package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
- package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
- package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
- package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
- package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.json +2 -2
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.json +7 -2
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
- package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.json +15 -2
- package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/BaseShareFieldV2.sol/BaseShareFieldV2.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.json +6 -6
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.json +2 -2
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStakingV2.sol/SimpleStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.json +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.json +2 -2
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/aave/GoodAaveStakingV2.sol/GoodAaveStakingV2.json +2 -2
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.json +2 -2
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStakingV2.sol/GoodCompoundStakingV2.json +2 -2
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +60 -2
- package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
- package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
- package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
- package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
- package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
- package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.json +2 -2
- package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.dbg.json +4 -0
- package/artifacts/contracts/utils/ProtocolUpgradeFuseRecover.sol/ProtocolUpgradeFuseRecover.json +83 -0
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.dbg.json +4 -0
- package/artifacts/contracts/utils/ProtocolUpgradeRecover.sol/ProtocolUpgradeRecover.json +121 -0
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
- package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.json +2 -2
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/contracts/reserve/GoodMarketMaker.sol +3 -2
- package/contracts/reserve/GoodReserveCDai.sol +25 -21
- package/contracts/staking/DonationsStaking.sol +1 -0
- package/contracts/ubi/UBIScheme.sol +32 -4
- package/contracts/utils/ProtocolUpgrade.sol +3 -2
- package/contracts/utils/ProtocolUpgradeFuseRecover.sol +116 -0
- package/contracts/utils/ProtocolUpgradeRecover.sol +198 -0
- package/contracts/utils/ProxyFactory1967.sol +1 -0
- package/package.json +1 -1
- package/releases/deployment.json +65 -2
- package/scripts/deployFullDAO.ts +2 -1
- package/scripts/upgradeToV2/upgradeToV2Recover.ts +947 -0
- package/test/helpers.ts +1 -1
- package/test/reserve/GoodMarketMaker.test.ts +6 -5
- package/test/staking/DonationsStaking.test.ts +32 -19
- package/test/ubi/UBIScheme.e2e.test.ts +1 -1
- package/test/ubi/UBIScheme.test.ts +4 -4
- package/test/utils/ProxyFactory.test.ts +31 -0
|
@@ -0,0 +1,947 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mainnet:
|
|
3
|
+
* 0. deploy nameService
|
|
4
|
+
* 1. deploy votingmachine + reputation
|
|
5
|
+
* 2. deploy Reserve, MarketMaker
|
|
6
|
+
* 3. deploy FundManager
|
|
7
|
+
* 4. deploy ubi staking contracts
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { network, ethers, upgrades, run } from "hardhat";
|
|
11
|
+
import { networkNames } from "@openzeppelin/upgrades-core";
|
|
12
|
+
import { isFunction, get, omitBy } from "lodash";
|
|
13
|
+
import { getImplementationAddress } from "@openzeppelin/upgrades-core";
|
|
14
|
+
|
|
15
|
+
import pressAnyKey from "press-any-key";
|
|
16
|
+
import {
|
|
17
|
+
AaveStakingFactory,
|
|
18
|
+
CompoundStakingFactory,
|
|
19
|
+
ProxyFactory1967
|
|
20
|
+
} from "../../types";
|
|
21
|
+
import SchemeRegistrarABI from "@gooddollar/goodcontracts/build/contracts/SchemeRegistrar.json";
|
|
22
|
+
import releaser from "../releaser";
|
|
23
|
+
import {
|
|
24
|
+
GReputation,
|
|
25
|
+
SchemeRegistrar,
|
|
26
|
+
CompoundVotingMachine,
|
|
27
|
+
ProtocolUpgradeRecover,
|
|
28
|
+
ProtocolUpgradeFuseRecover,
|
|
29
|
+
NameService
|
|
30
|
+
} from "../../types";
|
|
31
|
+
import OldDAO from "../../releases/olddao.json";
|
|
32
|
+
|
|
33
|
+
import ProtocolSettings from "../../releases/deploy-settings.json";
|
|
34
|
+
import { keccak256 } from "@ethersproject/keccak256";
|
|
35
|
+
|
|
36
|
+
let GAS_SETTINGS: any = {
|
|
37
|
+
maxPriorityFeePerGas: ethers.utils.parseUnits("1", "gwei"),
|
|
38
|
+
maxFeePerGas: ethers.utils.parseUnits("50", "gwei"),
|
|
39
|
+
gasLimit: 30000000
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
let totalGas = 0;
|
|
43
|
+
const gasUsage = {};
|
|
44
|
+
const countTotalGas = async (tx, name) => {
|
|
45
|
+
let res = tx;
|
|
46
|
+
if (tx.deployTransaction) tx = tx.deployTransaction;
|
|
47
|
+
if (tx.wait) res = await tx.wait();
|
|
48
|
+
if (res.gasUsed) {
|
|
49
|
+
totalGas += parseInt(res.gasUsed);
|
|
50
|
+
gasUsage[name] = gasUsage[name] || 0;
|
|
51
|
+
gasUsage[name] += parseInt(res.gasUsed);
|
|
52
|
+
} else console.log("no gas data", { res, tx });
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
console.log({
|
|
56
|
+
networkNames,
|
|
57
|
+
network: network.name,
|
|
58
|
+
upgrade: process.env.UPGRADE
|
|
59
|
+
});
|
|
60
|
+
const { name } = network;
|
|
61
|
+
|
|
62
|
+
export const main = async (
|
|
63
|
+
networkName = name,
|
|
64
|
+
isPerformUpgrade = true,
|
|
65
|
+
olddao?
|
|
66
|
+
): Promise<{ [key: string]: any }> => {
|
|
67
|
+
if (networkName.startsWith("dapptest") === false) {
|
|
68
|
+
networkNames[1] = networkName;
|
|
69
|
+
networkNames[122] = networkName;
|
|
70
|
+
networkNames[3] = networkName;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const isProduction = networkName.startsWith("production");
|
|
74
|
+
if (isProduction && networkName.includes("mainnet")) {
|
|
75
|
+
GAS_SETTINGS.gasLimit = 6000000;
|
|
76
|
+
GAS_SETTINGS.maxFeePerGas = ethers.utils.parseUnits("80", "gwei");
|
|
77
|
+
} else if (network.config.chainId === 122) {
|
|
78
|
+
//case we are on fusefuse
|
|
79
|
+
GAS_SETTINGS = {
|
|
80
|
+
gasLimit: 6000000,
|
|
81
|
+
gasPrice: ethers.utils.parseUnits("1", "gwei")
|
|
82
|
+
};
|
|
83
|
+
} else if (network.config.chainId === 3 || network.config.chainId === 42) {
|
|
84
|
+
GAS_SETTINGS = {
|
|
85
|
+
maxPriorityFeePerGas: ethers.utils.parseUnits("1", "gwei"),
|
|
86
|
+
maxFeePerGas: ethers.utils.parseUnits("10", "gwei"),
|
|
87
|
+
gasLimit: 6000000
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const isBackendTest = networkName.startsWith("dapptest");
|
|
92
|
+
const isTest = network.name === "hardhat" || isBackendTest;
|
|
93
|
+
const isCoverage = process.env.CODE_COVERAGE;
|
|
94
|
+
const isDevelop = !isProduction;
|
|
95
|
+
const isMainnet = networkName.includes("mainnet");
|
|
96
|
+
let protocolSettings = {
|
|
97
|
+
...ProtocolSettings["default"],
|
|
98
|
+
...ProtocolSettings[networkName]
|
|
99
|
+
};
|
|
100
|
+
console.log(`networkName ${networkName}`, {
|
|
101
|
+
isTest,
|
|
102
|
+
isBackendTest,
|
|
103
|
+
isCoverage,
|
|
104
|
+
isMainnet,
|
|
105
|
+
isDevelop
|
|
106
|
+
});
|
|
107
|
+
const dao = olddao || OldDAO[networkName];
|
|
108
|
+
const fse = require("fs-extra");
|
|
109
|
+
const ProtocolAddresses = await fse.readJson("releases/deployment.json");
|
|
110
|
+
const newfusedao = await ProtocolAddresses[
|
|
111
|
+
networkName.replace(/\-mainnet/, "")
|
|
112
|
+
];
|
|
113
|
+
const newdao = ProtocolAddresses[networkName] || {};
|
|
114
|
+
|
|
115
|
+
let [root, proxyDeployer] = await ethers.getSigners();
|
|
116
|
+
|
|
117
|
+
let avatar = dao.Avatar;
|
|
118
|
+
let controller = dao.Controller;
|
|
119
|
+
let repStateId = isMainnet ? "fuse" : "rootState";
|
|
120
|
+
|
|
121
|
+
const compoundTokens = [
|
|
122
|
+
{
|
|
123
|
+
name: "cdai",
|
|
124
|
+
address:
|
|
125
|
+
(protocolSettings.compound != undefined &&
|
|
126
|
+
protocolSettings.compound.cdai) ||
|
|
127
|
+
dao.cDAI,
|
|
128
|
+
usdOracle:
|
|
129
|
+
(protocolSettings.compound != undefined &&
|
|
130
|
+
protocolSettings.compound.daiUsdOracle) ||
|
|
131
|
+
dao.DAIUsdOracle,
|
|
132
|
+
compUsdOracle:
|
|
133
|
+
(protocolSettings.compound != undefined &&
|
|
134
|
+
protocolSettings.compound.compUsdOracle) ||
|
|
135
|
+
dao.COMPUsdOracle,
|
|
136
|
+
swapPath: []
|
|
137
|
+
}
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
const aaveTokens = [
|
|
141
|
+
{
|
|
142
|
+
name: "usdc",
|
|
143
|
+
address: protocolSettings.aave.usdc || dao.USDC,
|
|
144
|
+
usdOracle: protocolSettings.aave.usdcUsdOracle || dao.USDCUsdOracle,
|
|
145
|
+
aaveUsdOracle: protocolSettings.aave.aaveUsdOracle || dao.AAVEUsdOracle,
|
|
146
|
+
swapPath: [
|
|
147
|
+
get(protocolSettings, "aave.usdc", dao.USDC),
|
|
148
|
+
get(protocolSettings, "compound.dai", dao.DAI)
|
|
149
|
+
]
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
let release: { [key: string]: any } = newdao;
|
|
154
|
+
|
|
155
|
+
const toDeployUpgradable = [
|
|
156
|
+
{
|
|
157
|
+
network: "mainnet",
|
|
158
|
+
name: "NameService",
|
|
159
|
+
skip: true,
|
|
160
|
+
args: [
|
|
161
|
+
controller,
|
|
162
|
+
[
|
|
163
|
+
"CONTROLLER",
|
|
164
|
+
"AVATAR",
|
|
165
|
+
"IDENTITY",
|
|
166
|
+
"GOODDOLLAR",
|
|
167
|
+
"CONTRIBUTION_CALCULATION",
|
|
168
|
+
"BANCOR_FORMULA",
|
|
169
|
+
"DAI",
|
|
170
|
+
"CDAI",
|
|
171
|
+
"COMP",
|
|
172
|
+
"BRIDGE_CONTRACT",
|
|
173
|
+
"UNISWAP_ROUTER",
|
|
174
|
+
"GAS_PRICE_ORACLE",
|
|
175
|
+
"DAI_ETH_ORACLE",
|
|
176
|
+
"ETH_USD_ORACLE"
|
|
177
|
+
].map(_ => ethers.utils.keccak256(ethers.utils.toUtf8Bytes(_))),
|
|
178
|
+
[
|
|
179
|
+
controller,
|
|
180
|
+
avatar,
|
|
181
|
+
dao.Identity,
|
|
182
|
+
dao.GoodDollar,
|
|
183
|
+
dao.Contribution,
|
|
184
|
+
protocolSettings.bancor || dao.BancorFormula,
|
|
185
|
+
get(protocolSettings, "compound.dai", dao.DAI),
|
|
186
|
+
get(protocolSettings, "compound.cdai", dao.cDAI),
|
|
187
|
+
get(protocolSettings, "compound.comp", dao.COMP),
|
|
188
|
+
dao.ForeignBridge,
|
|
189
|
+
protocolSettings.uniswapRouter || dao.UniswapRouter,
|
|
190
|
+
!isMainnet ||
|
|
191
|
+
dao.GasPriceOracle ||
|
|
192
|
+
protocolSettings.chainlink.gasPrice, //should fail if missing only on mainnet
|
|
193
|
+
!isMainnet || dao.DAIEthOracle || protocolSettings.chainlink.dai_eth,
|
|
194
|
+
!isMainnet || dao.ETHUsdOracle || protocolSettings.chainlink.eth_usd
|
|
195
|
+
]
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
network: "fuse",
|
|
200
|
+
name: "NameService",
|
|
201
|
+
skip: true,
|
|
202
|
+
args: [
|
|
203
|
+
controller,
|
|
204
|
+
[
|
|
205
|
+
"CONTROLLER",
|
|
206
|
+
"AVATAR",
|
|
207
|
+
"IDENTITY",
|
|
208
|
+
"GOODDOLLAR",
|
|
209
|
+
"BRIDGE_CONTRACT"
|
|
210
|
+
].map(_ => ethers.utils.keccak256(ethers.utils.toUtf8Bytes(_))),
|
|
211
|
+
[controller, avatar, dao.Identity, dao.GoodDollar, dao.HomeBridge]
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
network: "both",
|
|
216
|
+
name: "GReputation",
|
|
217
|
+
skip: true,
|
|
218
|
+
initializer: "initialize(address, string, bytes32, uint256)",
|
|
219
|
+
args: [
|
|
220
|
+
() => get(release, "NameService", newdao.NameService),
|
|
221
|
+
"",
|
|
222
|
+
ethers.constants.HashZero, //should fail on real deploy if not set
|
|
223
|
+
0 //should fail on real deploy if not set
|
|
224
|
+
]
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
network: "both",
|
|
228
|
+
name: "CompoundVotingMachine",
|
|
229
|
+
skip: true,
|
|
230
|
+
args: [
|
|
231
|
+
() => get(release, "NameService", newdao.NameService),
|
|
232
|
+
protocolSettings.governance.proposalVotingPeriod,
|
|
233
|
+
protocolSettings.governance.guardian || root.address,
|
|
234
|
+
() => get(release, "GReputation", newdao.GReputation)
|
|
235
|
+
]
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
network: "mainnet",
|
|
239
|
+
name: "GoodMarketMaker",
|
|
240
|
+
skip: true,
|
|
241
|
+
args: [
|
|
242
|
+
() => get(release, "NameService", newdao.NameService),
|
|
243
|
+
protocolSettings.expansionRatio.nom,
|
|
244
|
+
protocolSettings.expansionRatio.denom
|
|
245
|
+
]
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
network: "mainnet",
|
|
249
|
+
name: "GoodReserveCDai",
|
|
250
|
+
skip: true,
|
|
251
|
+
initializer: "initialize(address, bytes32)",
|
|
252
|
+
args: [
|
|
253
|
+
() => get(release, "NameService", newdao.NameService),
|
|
254
|
+
ethers.constants.HashZero
|
|
255
|
+
]
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
network: "mainnet",
|
|
259
|
+
name: "ExchangeHelper",
|
|
260
|
+
skip: true,
|
|
261
|
+
initializer: "initialize(address)",
|
|
262
|
+
args: [() => get(release, "NameService", newdao.NameService)]
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
network: "mainnet",
|
|
266
|
+
skip: true,
|
|
267
|
+
name: "GoodFundManager",
|
|
268
|
+
args: [() => get(release, "NameService", newdao.NameService)]
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
network: "mainnet",
|
|
272
|
+
skip: true,
|
|
273
|
+
name: "StakersDistribution",
|
|
274
|
+
args: [() => get(release, "NameService", newdao.NameService)]
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
network: "fuse",
|
|
278
|
+
name: "ClaimersDistribution",
|
|
279
|
+
skip: true,
|
|
280
|
+
args: [() => get(release, "NameService", newdao.NameService)]
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
network: "fuse",
|
|
284
|
+
skip: true,
|
|
285
|
+
name: "GovernanceStaking",
|
|
286
|
+
args: [() => get(release, "NameService", newdao.NameService)],
|
|
287
|
+
isUpgradable: false
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
network: "fuse",
|
|
291
|
+
name: "UBIScheme",
|
|
292
|
+
skip: true,
|
|
293
|
+
initializer: "initialize(address, address, uint256)",
|
|
294
|
+
args: [
|
|
295
|
+
() => get(release, "NameService", newdao.NameService),
|
|
296
|
+
dao.FirstClaimPool,
|
|
297
|
+
14
|
|
298
|
+
]
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
network: "mainnet",
|
|
302
|
+
skip: true,
|
|
303
|
+
name: "ProtocolUpgradeRecover",
|
|
304
|
+
args: [dao.Controller, root.address],
|
|
305
|
+
isUpgradable: false,
|
|
306
|
+
initializer: null
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
network: "fuse",
|
|
310
|
+
skip: true,
|
|
311
|
+
name: "ProtocolUpgradeFuseRecover",
|
|
312
|
+
args: [dao.Controller, root.address],
|
|
313
|
+
isUpgradable: false
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
network: "mainnet",
|
|
317
|
+
skip: true,
|
|
318
|
+
name: "UniswapV2SwapHelper",
|
|
319
|
+
args: [],
|
|
320
|
+
isUpgradable: false
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
network: "mainnet",
|
|
324
|
+
skip: true,
|
|
325
|
+
name: "CompoundStakingFactory",
|
|
326
|
+
args: [],
|
|
327
|
+
isUpgradable: false,
|
|
328
|
+
libraries: ["UniswapV2SwapHelper"]
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
network: "mainnet",
|
|
332
|
+
skip: true,
|
|
333
|
+
name: "AaveStakingFactory",
|
|
334
|
+
args: [],
|
|
335
|
+
isUpgradable: false,
|
|
336
|
+
libraries: ["UniswapV2SwapHelper"]
|
|
337
|
+
}
|
|
338
|
+
];
|
|
339
|
+
|
|
340
|
+
let proxyFactory: ProxyFactory1967;
|
|
341
|
+
const getProxyFactory = async () => {
|
|
342
|
+
return (proxyFactory = (await ethers.getContractAt(
|
|
343
|
+
"ProxyFactory1967",
|
|
344
|
+
"0xDa85fceD9Bd193526b7667F2AD1fD4A0F900d3A7"
|
|
345
|
+
)) as unknown as ProxyFactory1967);
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
const deployDeterministic = async (
|
|
349
|
+
contract,
|
|
350
|
+
args: any[],
|
|
351
|
+
factoryOpts = {}
|
|
352
|
+
) => {
|
|
353
|
+
try {
|
|
354
|
+
const Contract = await ethers.getContractFactory(
|
|
355
|
+
contract.name,
|
|
356
|
+
factoryOpts
|
|
357
|
+
);
|
|
358
|
+
|
|
359
|
+
const salt = ethers.BigNumber.from(
|
|
360
|
+
keccak256(ethers.utils.toUtf8Bytes(contract.name))
|
|
361
|
+
);
|
|
362
|
+
|
|
363
|
+
if (contract.isUpgradable !== false) {
|
|
364
|
+
if (isCoverage) {
|
|
365
|
+
console.log("Deploying:", contract.name, "using proxy");
|
|
366
|
+
await pressAnyKey();
|
|
367
|
+
//coverage has large contracts doesnt work with proxy factory
|
|
368
|
+
const tx = await upgrades.deployProxy(Contract, args, {
|
|
369
|
+
initializer: contract.initializer,
|
|
370
|
+
kind: "uups",
|
|
371
|
+
unsafeAllowLinkedLibraries: true
|
|
372
|
+
});
|
|
373
|
+
await countTotalGas(tx, contract.name);
|
|
374
|
+
return tx;
|
|
375
|
+
}
|
|
376
|
+
console.log("Deploying:", contract.name, "using proxyfactory");
|
|
377
|
+
const encoded = Contract.interface.encodeFunctionData(
|
|
378
|
+
contract.initializer || "initialize",
|
|
379
|
+
args
|
|
380
|
+
);
|
|
381
|
+
await pressAnyKey();
|
|
382
|
+
const tx = await Contract.deploy(GAS_SETTINGS);
|
|
383
|
+
const impl = await tx.deployed();
|
|
384
|
+
await countTotalGas(tx, contract.name);
|
|
385
|
+
|
|
386
|
+
const tx2 = await proxyFactory.deployProxy(
|
|
387
|
+
salt,
|
|
388
|
+
impl.address,
|
|
389
|
+
encoded,
|
|
390
|
+
GAS_SETTINGS
|
|
391
|
+
);
|
|
392
|
+
await countTotalGas(tx2, contract.name);
|
|
393
|
+
const deployTx = await tx2
|
|
394
|
+
.wait()
|
|
395
|
+
.catch(e =>
|
|
396
|
+
console.error("failed to deploy proxy, assuming it exists...", e)
|
|
397
|
+
);
|
|
398
|
+
return ethers.getContractAt(
|
|
399
|
+
contract.name,
|
|
400
|
+
await proxyFactory["getDeploymentAddress(uint256,address)"](
|
|
401
|
+
salt,
|
|
402
|
+
root.address
|
|
403
|
+
)
|
|
404
|
+
);
|
|
405
|
+
} else {
|
|
406
|
+
//for some reason deploying with link library via proxy doesnt work on hardhat test env
|
|
407
|
+
if (isTest === false) {
|
|
408
|
+
console.log("Deploying:", contract.name, "using proxyfactory code");
|
|
409
|
+
await pressAnyKey();
|
|
410
|
+
const constructor = Contract.interface.encodeDeploy(args);
|
|
411
|
+
const bytecode = ethers.utils.solidityPack(
|
|
412
|
+
["bytes", "bytes"],
|
|
413
|
+
[Contract.bytecode, constructor]
|
|
414
|
+
);
|
|
415
|
+
const deployTx = await (
|
|
416
|
+
await proxyFactory.deployCode(salt, bytecode, GAS_SETTINGS)
|
|
417
|
+
).wait();
|
|
418
|
+
return ethers.getContractAt(
|
|
419
|
+
contract.name,
|
|
420
|
+
await proxyFactory["getDeploymentAddress(uint256,address,bytes32)"](
|
|
421
|
+
salt,
|
|
422
|
+
root.address,
|
|
423
|
+
keccak256(bytecode)
|
|
424
|
+
)
|
|
425
|
+
);
|
|
426
|
+
} else {
|
|
427
|
+
console.log("Deploying:", contract.name, "using regular");
|
|
428
|
+
await pressAnyKey();
|
|
429
|
+
const tx = await Contract.deploy(...args, GAS_SETTINGS);
|
|
430
|
+
await countTotalGas(tx, contract.name);
|
|
431
|
+
const impl = await tx.deployed();
|
|
432
|
+
return impl;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
} catch (e) {
|
|
436
|
+
console.log("Failed deploying contract:", { contract });
|
|
437
|
+
throw e;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const deployContracts = async () => {
|
|
442
|
+
console.log({ dao, newdao, protocolSettings });
|
|
443
|
+
|
|
444
|
+
await getProxyFactory();
|
|
445
|
+
console.info("got proxyfactory at:", proxyFactory.address);
|
|
446
|
+
for (let contract of toDeployUpgradable) {
|
|
447
|
+
if (
|
|
448
|
+
contract.skip ||
|
|
449
|
+
(contract.network !== "both" &&
|
|
450
|
+
(contract.network === "mainnet") !== isMainnet)
|
|
451
|
+
) {
|
|
452
|
+
console.log(
|
|
453
|
+
contract,
|
|
454
|
+
" Skipping non mainnet/sidechain contract:",
|
|
455
|
+
contract.network,
|
|
456
|
+
contract.name
|
|
457
|
+
);
|
|
458
|
+
continue;
|
|
459
|
+
}
|
|
460
|
+
if (isDevelop === false && newdao[contract.name]) {
|
|
461
|
+
console.log(
|
|
462
|
+
contract.name,
|
|
463
|
+
" Skipping deployed contract at:",
|
|
464
|
+
newdao[contract.name],
|
|
465
|
+
"upgrading:",
|
|
466
|
+
!!process.env.UPGRADE
|
|
467
|
+
);
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const args = await Promise.all(
|
|
472
|
+
contract.args.map(async _ => await (isFunction(_) ? _() : _))
|
|
473
|
+
);
|
|
474
|
+
|
|
475
|
+
console.log(`deploying contract upgrade ${contract.name}`, {
|
|
476
|
+
args
|
|
477
|
+
// release
|
|
478
|
+
// pf: ProxyFactory.factory.address
|
|
479
|
+
});
|
|
480
|
+
let opts = {};
|
|
481
|
+
if (contract.libraries) {
|
|
482
|
+
let libraries = {};
|
|
483
|
+
contract.libraries.forEach(l => (libraries[l] = release[l]));
|
|
484
|
+
opts = { libraries };
|
|
485
|
+
}
|
|
486
|
+
const Contract = await ethers.getContractFactory(contract.name, opts);
|
|
487
|
+
|
|
488
|
+
let deployed = await deployDeterministic(contract, args, opts);
|
|
489
|
+
|
|
490
|
+
console.log(`${contract.name} deployed to: ${deployed.address}`);
|
|
491
|
+
release[contract.name] = deployed.address;
|
|
492
|
+
await releaser(release, networkName, "deployment", false);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// if (!isProduction || get(release, "StakingContracts", []).length == 0) {
|
|
496
|
+
// const { DonationsStaking, StakingContracts } =
|
|
497
|
+
// isMainnet && (await deployStakingContracts(release));
|
|
498
|
+
// release["StakingContracts"] = StakingContracts;
|
|
499
|
+
// release["DonationsStaking"] = DonationsStaking;
|
|
500
|
+
// console.log("staking contracts result:", {
|
|
501
|
+
// StakingContracts,
|
|
502
|
+
// DonationsStaking
|
|
503
|
+
// });
|
|
504
|
+
// }
|
|
505
|
+
|
|
506
|
+
release["network"] = networkName;
|
|
507
|
+
release["networkId"] = network.config.chainId || 4447;
|
|
508
|
+
if (!isMainnet) {
|
|
509
|
+
release["HomeBridge"] = dao.HomeBridge;
|
|
510
|
+
release["SignupBonus"] = dao.SignupBonus;
|
|
511
|
+
release["OneTimePayments"] = dao.OneTimePayments;
|
|
512
|
+
release["Invites"] = dao.Invites;
|
|
513
|
+
release["AdminWallet"] = dao.AdminWallet;
|
|
514
|
+
} else {
|
|
515
|
+
release["ForeignBridge"] = dao.ForeignBridge;
|
|
516
|
+
release["Contribution"] = dao.Contribution;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
release["Identity"] = dao.Identity;
|
|
520
|
+
release["GoodDollar"] = dao.GoodDollar;
|
|
521
|
+
release["Controller"] = dao.Controller;
|
|
522
|
+
release["Avatar"] = avatar;
|
|
523
|
+
release["FirstClaimPool"] = dao.FirstClaimPool;
|
|
524
|
+
release["ProxyAdmin"] = dao.ProxyAdmin;
|
|
525
|
+
release["BancorFormula"] = protocolSettings.bancor || dao.BancorFormula;
|
|
526
|
+
|
|
527
|
+
release["DAI"] = get(protocolSettings, "compound.dai", dao.DAI);
|
|
528
|
+
release["cDAI"] = get(protocolSettings, "compound.cdai", dao.cDAI);
|
|
529
|
+
release["COMP"] = get(protocolSettings, "compound.comp", dao.COMP);
|
|
530
|
+
|
|
531
|
+
release = omitBy(release, _ => _ === undefined);
|
|
532
|
+
let res = Object.assign(newdao, release);
|
|
533
|
+
await releaser(release, networkName);
|
|
534
|
+
return release;
|
|
535
|
+
};
|
|
536
|
+
|
|
537
|
+
// const proveNewRep = async () => {
|
|
538
|
+
// console.log("prooving new rep...");
|
|
539
|
+
// if (networkName.includes("production") === false) {
|
|
540
|
+
// const proofs = [
|
|
541
|
+
// [
|
|
542
|
+
// "0x23d8bd1cdfa398986bb91927d3011fb1ded1425b6ae3ff794e497235481fe57f",
|
|
543
|
+
// "0xe4ac4e67088f036e8dc535fee10a3ad42065e444d2b0bd3668e0df21e1590db3",
|
|
544
|
+
// ],
|
|
545
|
+
// ["0x4c01c2c86a047dc65fc8ff0a1d9ac11842597af9a363711e4db7dcabcfda307b"],
|
|
546
|
+
// [
|
|
547
|
+
// "0x235dc3126b01e763befb96ead059e3f19d0380e65e477e6ebb95c1d9fc90e0b7",
|
|
548
|
+
// "0xe4ac4e67088f036e8dc535fee10a3ad42065e444d2b0bd3668e0df21e1590db3",
|
|
549
|
+
// ],
|
|
550
|
+
// ];
|
|
551
|
+
// let proofResults = await Promise.all(
|
|
552
|
+
// founders.map((f, idx) =>
|
|
553
|
+
// grep
|
|
554
|
+
// .connect(f)
|
|
555
|
+
// .proveBalanceOfAtBlockchain(repStateId, f.address, 100, proofs[idx])
|
|
556
|
+
// .then((_) => _.wait())
|
|
557
|
+
// )
|
|
558
|
+
// );
|
|
559
|
+
// console.log(
|
|
560
|
+
// "proofs:",
|
|
561
|
+
// proofResults.map((_) => _.events)
|
|
562
|
+
// );
|
|
563
|
+
// } else {
|
|
564
|
+
// //prove foundation multi sig account
|
|
565
|
+
// const proof = [];
|
|
566
|
+
// const foundationAddress = protocolSettings.governance.foundationAddress;
|
|
567
|
+
// let proofResult = await grep
|
|
568
|
+
// .proveBalanceOfAtBlockchain(
|
|
569
|
+
// repStateId,
|
|
570
|
+
// foundationAddress,
|
|
571
|
+
// 12000000,
|
|
572
|
+
// proof
|
|
573
|
+
// )
|
|
574
|
+
// .then((_) => _.wait());
|
|
575
|
+
|
|
576
|
+
// console.log("proofs:", proofResult.events);
|
|
577
|
+
// }
|
|
578
|
+
// };
|
|
579
|
+
|
|
580
|
+
const performUpgrade = async release => {
|
|
581
|
+
const gasSettings = {
|
|
582
|
+
...GAS_SETTINGS,
|
|
583
|
+
maxFeePerGas: ethers.utils.parseUnits("70", "gwei"),
|
|
584
|
+
gasLimit: 600000
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
const isKovan = networkName.includes("kovan");
|
|
588
|
+
const upgrade: ProtocolUpgradeRecover = (await ethers.getContractAt(
|
|
589
|
+
"ProtocolUpgradeRecover",
|
|
590
|
+
release.ProtocolUpgradeRecover
|
|
591
|
+
)) as unknown as ProtocolUpgradeRecover;
|
|
592
|
+
|
|
593
|
+
console.log("performing protocol v2 recovery on Mainnet...", {
|
|
594
|
+
release,
|
|
595
|
+
dao
|
|
596
|
+
});
|
|
597
|
+
const basicArgs: [any, any, any] = [
|
|
598
|
+
release.NameService,
|
|
599
|
+
[
|
|
600
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("RESERVE")),
|
|
601
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("MARKET_MAKER")),
|
|
602
|
+
// ethers.utils.keccak256(ethers.utils.toUtf8Bytes("FUND_MANAGER")),
|
|
603
|
+
// ethers.utils.keccak256(ethers.utils.toUtf8Bytes("REPUTATION")),
|
|
604
|
+
// ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_STAKERS")),
|
|
605
|
+
// ethers.utils.keccak256(ethers.utils.toUtf8Bytes("UBI_RECIPIENT")),
|
|
606
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("BRIDGE_CONTRACT")),
|
|
607
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("EXCHANGE_HELPER"))
|
|
608
|
+
],
|
|
609
|
+
[
|
|
610
|
+
release.GoodReserveCDai,
|
|
611
|
+
release.GoodMarketMaker,
|
|
612
|
+
// release.GoodFundManager,
|
|
613
|
+
// release.GReputation,
|
|
614
|
+
// release.StakersDistribution,
|
|
615
|
+
// isKovan ? root.address : newfusedao.UBIScheme, //fake for kovan
|
|
616
|
+
dao.ForeignBridge,
|
|
617
|
+
release.ExchangeHelper
|
|
618
|
+
]
|
|
619
|
+
];
|
|
620
|
+
console.log("upgrading nameservice + staking rewards...", { basicArgs });
|
|
621
|
+
let tx;
|
|
622
|
+
await pressAnyKey();
|
|
623
|
+
|
|
624
|
+
tx = await (await upgrade.upgradeBasic(...basicArgs, gasSettings)).wait();
|
|
625
|
+
await countTotalGas(tx, "call upgrade basic");
|
|
626
|
+
|
|
627
|
+
const reserveArgs: [any] = [release.NameService];
|
|
628
|
+
console.log("upgrading reserve...", {
|
|
629
|
+
reserveArgs
|
|
630
|
+
});
|
|
631
|
+
await pressAnyKey();
|
|
632
|
+
tx = await upgrade.upgradeReserve(...reserveArgs, gasSettings);
|
|
633
|
+
await countTotalGas(tx, "call upgrade reserve");
|
|
634
|
+
console.log("upgrading donationstaking...", {
|
|
635
|
+
params: [
|
|
636
|
+
release.NameService,
|
|
637
|
+
dao.DonationsStaking, //old
|
|
638
|
+
release.DonationsStaking
|
|
639
|
+
]
|
|
640
|
+
});
|
|
641
|
+
// tx = await upgrade.upgradeDonationStaking(
|
|
642
|
+
// release.NameService,
|
|
643
|
+
// dao.DonationsStaking, //old
|
|
644
|
+
// release.DonationsStaking, //new
|
|
645
|
+
// dao.DAIStaking,
|
|
646
|
+
// GAS_SETTINGS
|
|
647
|
+
// );
|
|
648
|
+
// await countTotalGas(tx, "call upgrade donations");
|
|
649
|
+
// console.log("Donation staking upgraded");
|
|
650
|
+
//extract just the addresses without the rewards
|
|
651
|
+
// release.StakingContracts = release.StakingContracts.map((_) => _[0]);
|
|
652
|
+
|
|
653
|
+
if (isProduction) {
|
|
654
|
+
console.log(
|
|
655
|
+
"SKIPPING GOVERNANCE UPGRADE FOR PRODUCTION. RUN IT MANUALLY"
|
|
656
|
+
);
|
|
657
|
+
} else {
|
|
658
|
+
console.log("upgrading governance...");
|
|
659
|
+
|
|
660
|
+
tx = await upgrade.upgradeGovernance(release.CompoundVotingMachine);
|
|
661
|
+
await countTotalGas(tx, "call upgrade gov");
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
const performUpgradeFuse = async release => {
|
|
666
|
+
const upgrade: ProtocolUpgradeFuseRecover = (await ethers.getContractAt(
|
|
667
|
+
"ProtocolUpgradeFuseRecover",
|
|
668
|
+
release.ProtocolUpgradeFuseRecover
|
|
669
|
+
)) as unknown as ProtocolUpgradeFuseRecover;
|
|
670
|
+
|
|
671
|
+
console.log("performing protocol v2 upgrade on Fuse...", { release, dao });
|
|
672
|
+
await upgrade
|
|
673
|
+
.upgrade(
|
|
674
|
+
release.NameService,
|
|
675
|
+
dao.FirstClaimPool,
|
|
676
|
+
release.UBIScheme,
|
|
677
|
+
[
|
|
678
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("REPUTATION")),
|
|
679
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("BRIDGE_CONTRACT")),
|
|
680
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("UBISCHEME")),
|
|
681
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_STAKING")),
|
|
682
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_CLAIMERS"))
|
|
683
|
+
],
|
|
684
|
+
[
|
|
685
|
+
release.GReputation,
|
|
686
|
+
dao.HomeBridge,
|
|
687
|
+
release.UBIScheme,
|
|
688
|
+
release.GovernanceStaking,
|
|
689
|
+
release.ClaimersDistribution
|
|
690
|
+
],
|
|
691
|
+
GAS_SETTINGS
|
|
692
|
+
)
|
|
693
|
+
.then(_ => countTotalGas(_, "fuse basic upgrade"));
|
|
694
|
+
|
|
695
|
+
if (isProduction) {
|
|
696
|
+
console.log(
|
|
697
|
+
"SKIPPING GOVERNANCE UPGRADE FOR PRODUCTION. RUN IT MANUALLY"
|
|
698
|
+
);
|
|
699
|
+
} else {
|
|
700
|
+
console.log("upgrading governance...");
|
|
701
|
+
|
|
702
|
+
await upgrade.upgradeGovernance(
|
|
703
|
+
dao.SchemeRegistrar,
|
|
704
|
+
dao.UpgradeScheme,
|
|
705
|
+
release.CompoundVotingMachine,
|
|
706
|
+
GAS_SETTINGS
|
|
707
|
+
);
|
|
708
|
+
}
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
//give Avatar permissions to the upgrade process contract
|
|
712
|
+
const voteProtocolUpgrade = async release => {
|
|
713
|
+
const Upgrade =
|
|
714
|
+
release.ProtocolUpgradeRecover || release.ProtocolUpgradeFuseRecover;
|
|
715
|
+
const ctrl = await ethers.getContractAt("Controller", controller);
|
|
716
|
+
const tx = await ctrl.registerScheme(
|
|
717
|
+
Upgrade,
|
|
718
|
+
ethers.constants.HashZero,
|
|
719
|
+
"0x0000001f",
|
|
720
|
+
avatar,
|
|
721
|
+
{
|
|
722
|
+
...GAS_SETTINGS,
|
|
723
|
+
gasLimit: 300000
|
|
724
|
+
}
|
|
725
|
+
);
|
|
726
|
+
await countTotalGas(tx, "registerScheme voteProtocolUpgrade");
|
|
727
|
+
console.log("registerScheme recovery scheme in dao...", Upgrade);
|
|
728
|
+
};
|
|
729
|
+
|
|
730
|
+
const deployStakingContracts = async release => {
|
|
731
|
+
const isRopsten =
|
|
732
|
+
networkName === "fuse-mainnet" || networkName === "staging-mainnet";
|
|
733
|
+
console.log("deployStakingContracts", {
|
|
734
|
+
factory: release.CompoundStakingFactory,
|
|
735
|
+
ns: release.NameService
|
|
736
|
+
});
|
|
737
|
+
const compfactory = await ethers.getContractAt(
|
|
738
|
+
"CompoundStakingFactory",
|
|
739
|
+
release.CompoundStakingFactory
|
|
740
|
+
);
|
|
741
|
+
const aavefactory = await ethers.getContractAt(
|
|
742
|
+
"AaveStakingFactory",
|
|
743
|
+
release.AaveStakingFactory
|
|
744
|
+
);
|
|
745
|
+
const compps = compoundTokens.map(async token => {
|
|
746
|
+
let rewardsPerBlock = protocolSettings.staking.rewardsPerBlock;
|
|
747
|
+
console.log("deployStakingContracts", {
|
|
748
|
+
token,
|
|
749
|
+
settings: protocolSettings.staking,
|
|
750
|
+
rewardsPerBlock,
|
|
751
|
+
factory: compfactory.address,
|
|
752
|
+
params: [
|
|
753
|
+
token.address,
|
|
754
|
+
release.NameService,
|
|
755
|
+
protocolSettings.staking.fullRewardsThreshold, //blocks before switching for 0.5x rewards to 1x multiplier
|
|
756
|
+
token.usdOracle,
|
|
757
|
+
token.compUsdOracle
|
|
758
|
+
]
|
|
759
|
+
});
|
|
760
|
+
const tx = await (
|
|
761
|
+
await compfactory[
|
|
762
|
+
"cloneAndInit(address,address,uint64,address,address,address[])"
|
|
763
|
+
](
|
|
764
|
+
token.address,
|
|
765
|
+
release.NameService,
|
|
766
|
+
protocolSettings.staking.fullRewardsThreshold, //blocks before switching for 0.5x rewards to 1x multiplier
|
|
767
|
+
token.usdOracle,
|
|
768
|
+
token.compUsdOracle,
|
|
769
|
+
token.swapPath,
|
|
770
|
+
GAS_SETTINGS
|
|
771
|
+
)
|
|
772
|
+
).wait();
|
|
773
|
+
await countTotalGas(tx, "deploy comp staking");
|
|
774
|
+
const log = tx.events.find(_ => _.event === "Deployed");
|
|
775
|
+
if (!log.args.proxy)
|
|
776
|
+
throw new Error(`staking contract deploy failed ${token}`);
|
|
777
|
+
return [log.args.proxy, rewardsPerBlock];
|
|
778
|
+
});
|
|
779
|
+
|
|
780
|
+
await Promise.all(compps);
|
|
781
|
+
// const compps = [
|
|
782
|
+
// Promise.resolve(["0x9999c40c8b88c740076b15d2e708db6a7a071b53", 13888])
|
|
783
|
+
// ];
|
|
784
|
+
let deployed;
|
|
785
|
+
if (!isRopsten || isTest) {
|
|
786
|
+
const aaveps = aaveTokens.map(async token => {
|
|
787
|
+
let rewardsPerBlock = (protocolSettings.staking.rewardsPerBlock / 2) //aave gets half of the rewards
|
|
788
|
+
.toFixed(0);
|
|
789
|
+
console.log("deployStakingContracts", {
|
|
790
|
+
token,
|
|
791
|
+
settings: protocolSettings.staking,
|
|
792
|
+
rewardsPerBlock
|
|
793
|
+
});
|
|
794
|
+
const tx = await (
|
|
795
|
+
await aavefactory[
|
|
796
|
+
"cloneAndInit(address,address,address,uint64,address,address,address,address[])"
|
|
797
|
+
](
|
|
798
|
+
token.address,
|
|
799
|
+
get(protocolSettings, "aave.lendingPool", dao.AaveLendingPool),
|
|
800
|
+
release.NameService,
|
|
801
|
+
protocolSettings.staking.fullRewardsThreshold, //blocks before switching for 0.5x rewards to 1x multiplier
|
|
802
|
+
token.usdOracle,
|
|
803
|
+
|
|
804
|
+
get(
|
|
805
|
+
protocolSettings,
|
|
806
|
+
"aave.incentiveController",
|
|
807
|
+
dao.AaveIncentiveController
|
|
808
|
+
),
|
|
809
|
+
token.aaveUsdOracle,
|
|
810
|
+
token.swapPath,
|
|
811
|
+
GAS_SETTINGS
|
|
812
|
+
)
|
|
813
|
+
).wait();
|
|
814
|
+
await countTotalGas(tx, "deploy aave staking");
|
|
815
|
+
const log = tx.events.find(_ => _.event === "Deployed");
|
|
816
|
+
if (!log.args.proxy)
|
|
817
|
+
throw new Error(`staking contract deploy failed ${token}`);
|
|
818
|
+
return [log.args.proxy, rewardsPerBlock];
|
|
819
|
+
});
|
|
820
|
+
|
|
821
|
+
// const aaveps = [
|
|
822
|
+
// Promise.resolve(["0x8f0c4f59b4c593193e5b5e0224d848ac803ad1a2", 13888 / 2])
|
|
823
|
+
// ];
|
|
824
|
+
await Promise.all(aaveps);
|
|
825
|
+
deployed = await Promise.all(compps.concat(aaveps));
|
|
826
|
+
} else {
|
|
827
|
+
deployed = await Promise.all(compps);
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
console.log("deploying donation staking");
|
|
831
|
+
console.log(`release ${release}`);
|
|
832
|
+
const deployedDonationsStaking = await deployDeterministic(
|
|
833
|
+
{
|
|
834
|
+
network: "mainnet",
|
|
835
|
+
name: "DonationsStaking",
|
|
836
|
+
isUpgradable: true
|
|
837
|
+
},
|
|
838
|
+
[
|
|
839
|
+
release.NameService,
|
|
840
|
+
deployed[0][0],
|
|
841
|
+
[
|
|
842
|
+
"0x0000000000000000000000000000000000000000",
|
|
843
|
+
get(protocolSettings, "compound.dai", dao.DAI)
|
|
844
|
+
],
|
|
845
|
+
[
|
|
846
|
+
get(protocolSettings, "compound.dai", dao.DAI),
|
|
847
|
+
"0x0000000000000000000000000000000000000000"
|
|
848
|
+
]
|
|
849
|
+
],
|
|
850
|
+
{
|
|
851
|
+
libraries: {
|
|
852
|
+
UniswapV2SwapHelper: "0x62305662fA7c4BC442803b940d9192DbDC92D710"
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
);
|
|
856
|
+
// await countTotalGas(deployedDonationsStaking);
|
|
857
|
+
|
|
858
|
+
console.log(
|
|
859
|
+
`DonationsStaking deployed to: ${deployedDonationsStaking.address}`
|
|
860
|
+
);
|
|
861
|
+
|
|
862
|
+
return {
|
|
863
|
+
DonationsStaking: deployedDonationsStaking.address,
|
|
864
|
+
StakingContracts: deployed
|
|
865
|
+
};
|
|
866
|
+
};
|
|
867
|
+
const verifyContracts = async release => {
|
|
868
|
+
for (let contract of toDeployUpgradable) {
|
|
869
|
+
if (
|
|
870
|
+
contract.network !== "both" &&
|
|
871
|
+
(contract.network === "mainnet") !== isMainnet
|
|
872
|
+
) {
|
|
873
|
+
console.log(
|
|
874
|
+
contract,
|
|
875
|
+
" Skipping verification non mainnet/sidechain contract:",
|
|
876
|
+
contract.network,
|
|
877
|
+
contract.name
|
|
878
|
+
);
|
|
879
|
+
continue;
|
|
880
|
+
}
|
|
881
|
+
console.log(
|
|
882
|
+
"Running contract verification:",
|
|
883
|
+
{ contract },
|
|
884
|
+
release[contract.name]
|
|
885
|
+
);
|
|
886
|
+
if (contract.isUpgradable !== false) {
|
|
887
|
+
const implementationAddress = await getImplementationAddress(
|
|
888
|
+
network.provider,
|
|
889
|
+
release[contract.name]
|
|
890
|
+
);
|
|
891
|
+
try {
|
|
892
|
+
await run("verify:verify", {
|
|
893
|
+
address: implementationAddress
|
|
894
|
+
});
|
|
895
|
+
} catch (err) {
|
|
896
|
+
console.log("err", err);
|
|
897
|
+
}
|
|
898
|
+
} else {
|
|
899
|
+
try {
|
|
900
|
+
await run("verify:verify", {
|
|
901
|
+
address: release[contract.name],
|
|
902
|
+
constructorArguments: contract.args,
|
|
903
|
+
libraries: {
|
|
904
|
+
UniswapV2SwapHelper: "0x62305662fA7c4BC442803b940d9192DbDC92D710"
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
} catch (err) {
|
|
908
|
+
console.log("err", err);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
};
|
|
913
|
+
|
|
914
|
+
await deployContracts();
|
|
915
|
+
|
|
916
|
+
if (isPerformUpgrade) {
|
|
917
|
+
console.log("deployed contracts", { totalGas, dao, release });
|
|
918
|
+
console.log("registering updrade scheme...");
|
|
919
|
+
await pressAnyKey();
|
|
920
|
+
await voteProtocolUpgrade(release);
|
|
921
|
+
await pressAnyKey();
|
|
922
|
+
console.log("voted contracts", { totalGas });
|
|
923
|
+
isMainnet && (await performUpgrade(release));
|
|
924
|
+
!isMainnet && (await performUpgradeFuse(release));
|
|
925
|
+
console.log("upgraded contracts", { totalGas });
|
|
926
|
+
}
|
|
927
|
+
if (isMainnet && !isTest && !isCoverage) {
|
|
928
|
+
await verifyContracts(release);
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
await releaser(release, networkName);
|
|
932
|
+
return release;
|
|
933
|
+
// await proveNewRep();
|
|
934
|
+
};
|
|
935
|
+
if (
|
|
936
|
+
network.name !== "hardhat" &&
|
|
937
|
+
process.argv[1].includes("upgradeToV2Recover.ts")
|
|
938
|
+
) {
|
|
939
|
+
main(name, true)
|
|
940
|
+
.catch(e => {
|
|
941
|
+
console.log(e);
|
|
942
|
+
throw e;
|
|
943
|
+
})
|
|
944
|
+
.finally(() => {
|
|
945
|
+
console.log({ totalGas, gasUsage });
|
|
946
|
+
});
|
|
947
|
+
}
|