@gooddollar/goodprotocol 1.0.3-beta.1 → 1.0.3
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/CompoundVotingMachine.sol/CompoundVotingMachine.json +14 -2
- 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/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/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
- 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/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/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
- 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/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
- package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
- package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.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/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
- package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
- package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
- 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/unaudited-foundation/InvitesV1.sol/InvitesV1.json +2 -2
- 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/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
- package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
- package/contracts/governance/CompoundVotingMachine.sol +8 -2
- package/contracts/unaudited-foundation/InvitesV1.sol +29 -24
- package/hardhat.config.ts +3 -1
- package/package.json +1 -1
- package/releases/deployment.json +24 -24
- package/scripts/deployFullDAO.ts +159 -125
- package/scripts/keeper/fishInactive.ts +57 -0
- package/scripts/upgradeToV2/upgradeToV2.ts +13 -4
- package/test/governance/CompoundVotingMachine.delegate.test.ts +0 -4
- package/test/governance/CompoundVotingMachine.guardian.test.ts +2 -2
- package/test/helpers.ts +3 -10
- package/test/reserve/GoodReserveCDai.cap.test.ts +1 -1
- package/test/reserve/GoodReserveCDai.test.ts +11 -109
- package/test/utils/ProtocolUpgrade.test.ts +8 -0
|
@@ -134,13 +134,12 @@ contract InvitesV1 is Initializable {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
function canCollectBountyFor(address _invitee) public view returns (bool) {
|
|
137
|
-
User
|
|
138
|
-
User
|
|
139
|
-
|
|
137
|
+
User storage user = users[_invitee];
|
|
138
|
+
User storage inviter = users[user.invitedBy];
|
|
139
|
+
uint256 daysToComplete = levels[inviter.level].daysToComplete;
|
|
140
140
|
bool isLevelExpired = levelExpirationEnabled == true &&
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
user.joinedAt.sub(inviter.levelStarted).div(1 days);
|
|
141
|
+
daysToComplete > 0 &&
|
|
142
|
+
daysToComplete < user.joinedAt.sub(inviter.levelStarted).div(1 days);
|
|
144
143
|
|
|
145
144
|
return
|
|
146
145
|
!user.bountyPaid &&
|
|
@@ -201,41 +200,44 @@ contract InvitesV1 is Initializable {
|
|
|
201
200
|
*/
|
|
202
201
|
function bountyFor(address _invitee) public isActive {
|
|
203
202
|
require(canCollectBountyFor(_invitee), "user not elligble for bounty yet");
|
|
203
|
+
return _bountyFor(_invitee);
|
|
204
|
+
}
|
|
204
205
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
function _bountyFor(address _invitee) internal {
|
|
207
|
+
address invitedBy = users[_invitee].invitedBy;
|
|
208
|
+
uint256 joinedAt = users[_invitee].joinedAt;
|
|
209
|
+
Level memory level = levels[users[invitedBy].level];
|
|
208
210
|
|
|
209
211
|
bool isLevelExpired = level.daysToComplete > 0 &&
|
|
210
|
-
|
|
212
|
+
joinedAt > users[invitedBy].levelStarted && //prevent overflow in subtraction
|
|
211
213
|
level.daysToComplete <
|
|
212
|
-
|
|
214
|
+
joinedAt.sub(users[invitedBy].levelStarted).div(1 days); //how long after level started did invitee join
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
216
|
+
users[_invitee].bountyPaid = true;
|
|
217
|
+
users[invitedBy].totalApprovedInvites += 1;
|
|
218
|
+
users[invitedBy].totalEarned += level.bounty;
|
|
217
219
|
stats.totalApprovedInvites += 1;
|
|
218
220
|
stats.totalBountiesPaid += level.bounty;
|
|
219
221
|
|
|
220
222
|
bool earnedLevel = false;
|
|
221
223
|
if (
|
|
222
224
|
level.toNext > 0 &&
|
|
223
|
-
|
|
225
|
+
users[invitedBy].totalApprovedInvites >= level.toNext &&
|
|
224
226
|
isLevelExpired == false
|
|
225
227
|
) {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
+
users[invitedBy].level += 1;
|
|
229
|
+
users[invitedBy].levelStarted = block.timestamp;
|
|
228
230
|
earnedLevel = true;
|
|
229
231
|
}
|
|
230
232
|
|
|
231
|
-
goodDollar.transfer(
|
|
233
|
+
goodDollar.transfer(invitedBy, level.bounty);
|
|
232
234
|
goodDollar.transfer(_invitee, level.bounty.div(2)); //pay invitee half the bounty
|
|
233
235
|
|
|
234
236
|
emit InviterBounty(
|
|
235
|
-
|
|
237
|
+
invitedBy,
|
|
236
238
|
_invitee,
|
|
237
239
|
level.bounty,
|
|
238
|
-
|
|
240
|
+
users[invitedBy].level,
|
|
239
241
|
earnedLevel
|
|
240
242
|
);
|
|
241
243
|
}
|
|
@@ -247,10 +249,12 @@ contract InvitesV1 is Initializable {
|
|
|
247
249
|
User storage inviter = users[msg.sender];
|
|
248
250
|
|
|
249
251
|
for (uint256 i = 0; i < inviter.pending.length; i++) {
|
|
250
|
-
if (
|
|
251
|
-
|
|
252
|
+
if (gasleft() < 340000) return;
|
|
253
|
+
address pending = inviter.pending[i];
|
|
254
|
+
if (canCollectBountyFor(pending)) {
|
|
255
|
+
_bountyFor(pending);
|
|
252
256
|
}
|
|
253
|
-
if (users[
|
|
257
|
+
if (users[pending].bountyPaid) {
|
|
254
258
|
//if still elements in array move last item to current position
|
|
255
259
|
if (inviter.pending.length - 1 > i) {
|
|
256
260
|
inviter.pending[i] = inviter.pending[inviter.pending.length - 1];
|
|
@@ -292,8 +296,9 @@ contract InvitesV1 is Initializable {
|
|
|
292
296
|
* @dev
|
|
293
297
|
* 1.2.0 - final changes before release
|
|
294
298
|
* 1.3.0 - allow to set inviter later
|
|
299
|
+
* 1.4.0 - improve gas for bounty collection
|
|
295
300
|
*/
|
|
296
301
|
function version() public pure returns (string memory) {
|
|
297
|
-
return "1.
|
|
302
|
+
return "1.4.0";
|
|
298
303
|
}
|
|
299
304
|
}
|
package/hardhat.config.ts
CHANGED
package/package.json
CHANGED
package/releases/deployment.json
CHANGED
|
@@ -120,30 +120,30 @@
|
|
|
120
120
|
"UniswapV2SwapHelper": "0x7D7200b2b049BB3d91bCbdf95eC0EE6c2b5f8b7E"
|
|
121
121
|
},
|
|
122
122
|
"fuse": {
|
|
123
|
-
"NameService": "
|
|
124
|
-
"GReputation": "
|
|
125
|
-
"FirstClaimPool": "
|
|
126
|
-
"CompoundVotingMachine": "
|
|
127
|
-
"ClaimersDistribution": "
|
|
128
|
-
"GovernanceStaking": "
|
|
129
|
-
"UBIScheme": "
|
|
130
|
-
"ProtocolUpgradeFuse": "
|
|
131
|
-
"Identity": "
|
|
132
|
-
"GoodDollar": "
|
|
133
|
-
"Controller": "
|
|
134
|
-
"Avatar": "
|
|
135
|
-
"HomeBridge": "
|
|
136
|
-
"FuseFaucet": "
|
|
137
|
-
"
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"UBI": "0xCC9B1382b0Ae9D80E81eCB1863DcE8685a044603",
|
|
141
|
-
"SignupBonus": "0xcdC704D3dEA0FcFD1Cae95dfdCB7883632E171b2",
|
|
142
|
-
"OneTimePayments": "0x94079dF920115c5296Cc06AE6D8F29E077906246",
|
|
143
|
-
"AdminWallet": "0xf61e08a98B446856eE3fbD6597D3698a1a138565",
|
|
123
|
+
"NameService": "0x27E3B64C671a25c191535743d63Bd06CB9B93E37",
|
|
124
|
+
"GReputation": "0xdFF4cE07253b2c3fa9dCEC8B918f91d150AC26a4",
|
|
125
|
+
"FirstClaimPool": "0x5E8732889f2d84c3D834223c38361B38D7D4B9bc",
|
|
126
|
+
"CompoundVotingMachine": "0xb9978C071f2F64016A2f8515BC03bd25684201aF",
|
|
127
|
+
"ClaimersDistribution": "0xEaDa76013C87C22843b907Ce0110ea55C8E7E2a0",
|
|
128
|
+
"GovernanceStaking": "0xe3E75Ee6895F8b30d8eC3260dAa20ec1aba6DA77",
|
|
129
|
+
"UBIScheme": "0x3bdeB796950301FfC9568fAF89B7370f8B217321",
|
|
130
|
+
"ProtocolUpgradeFuse": "0x4dB8602482576321F829baa593150393f7595439",
|
|
131
|
+
"Identity": "0x7ccF1011610138b484fCc921858e7971342d213c",
|
|
132
|
+
"GoodDollar": "0x79BeecC4b165Ccf547662cB4f7C0e83b3796E5b3",
|
|
133
|
+
"Controller": "0xb453024495525908E6cC1e3C115f4B6B30cc56b9",
|
|
134
|
+
"Avatar": "0x71ddE7b8362724bd65D88Fe29d42636a9F8f9064",
|
|
135
|
+
"HomeBridge": "0xb0aD96B62567Ebcb1660e2Af5755A11B42b3Ade5",
|
|
136
|
+
"FuseFaucet": "0x09Ad3430D146aa662eA8c20cBEBceBC0bbB3FB0a",
|
|
137
|
+
"Invites": "0x187fc9fB37DF0fbf75149913a97B17c968Fc90d0",
|
|
138
|
+
"OneTimePayments": "0x184C1F83b3eB75a2dac483D4a6b9FBD59Df961f8",
|
|
139
|
+
"AdminWallet": "0x14204288286823042263156146334B1a4d61227c",
|
|
144
140
|
"network": "fuse",
|
|
145
141
|
"networkId": 122,
|
|
146
|
-
"ProxyFactory": "
|
|
142
|
+
"ProxyFactory": "0x4136dfD47F47792fC820E2354e9F0ce8e9c586A6",
|
|
143
|
+
"BancorFormula": "0x88e111b2A42457655A34896E5B929a75E7B82F88",
|
|
144
|
+
"DAI": "0x0000000000000000000000000000000000000000",
|
|
145
|
+
"cDAI": "0x0000000000000000000000000000000000000000",
|
|
146
|
+
"COMP": "0x0000000000000000000000000000000000000000"
|
|
147
147
|
},
|
|
148
148
|
"fuse-mainnet": {
|
|
149
149
|
"NameService": "0x5e8bF25c75787e9fa17e2321266b0cbE95c830d0",
|
|
@@ -365,7 +365,7 @@
|
|
|
365
365
|
"ProxyFactory": "0x4659176E962763e7C8A4eF965ecfD0fdf9f52057",
|
|
366
366
|
"NameService": "0xe26867DDd22F9342d9F0D566D182f2c960683971",
|
|
367
367
|
"GReputation": "0x3A9299BE789ac3730e4E4c49d6d2Ad1b8BC34DFf",
|
|
368
|
-
"CompoundVotingMachine": "
|
|
368
|
+
"CompoundVotingMachine": "0xc2Ff55b896e3c42f9e1c2f7467C51b93F1C23dFD",
|
|
369
369
|
"ClaimersDistribution": "0xF34552F1583c0B981dbB09611128c3375b47182e",
|
|
370
370
|
"GovernanceStaking": "0xFAF457Fb4A978Be059506F6CD41f9B30fCa753b0",
|
|
371
371
|
"UBIScheme": "0x87d77A30a6819860eB8332D293810ed7b510035A",
|
|
@@ -390,7 +390,7 @@
|
|
|
390
390
|
"ProxyFactory": "0x4659176E962763e7C8A4eF965ecfD0fdf9f52057",
|
|
391
391
|
"NameService": "0xe26867DDd22F9342d9F0D566D182f2c960683971",
|
|
392
392
|
"GReputation": "0x3A9299BE789ac3730e4E4c49d6d2Ad1b8BC34DFf",
|
|
393
|
-
"CompoundVotingMachine": "
|
|
393
|
+
"CompoundVotingMachine": "0xc2Ff55b896e3c42f9e1c2f7467C51b93F1C23dFD",
|
|
394
394
|
"GoodMarketMaker": "0x30D37B05cF73Edd8c59ce8450F093f6C06dA9272",
|
|
395
395
|
"GoodReserveCDai": "0x6C35677206ae7FF1bf753877649cF57cC30D1c42",
|
|
396
396
|
"ExchangeHelper": "0x0a8c6bB832801454F6CC21761D0A293Caa003296",
|
package/scripts/deployFullDAO.ts
CHANGED
|
@@ -21,10 +21,21 @@ import releaser from "../scripts/releaser";
|
|
|
21
21
|
import ProtocolSettings from "../releases/deploy-settings.json";
|
|
22
22
|
import dao from "../releases/deployment.json";
|
|
23
23
|
import { main as deployV2 } from "./upgradeToV2/upgradeToV2";
|
|
24
|
+
import { TransactionResponse } from "@ethersproject/providers";
|
|
25
|
+
|
|
24
26
|
const { name } = network;
|
|
25
27
|
|
|
26
|
-
const printDeploy = (
|
|
27
|
-
|
|
28
|
+
const printDeploy = async (
|
|
29
|
+
c: Contract | TransactionResponse
|
|
30
|
+
): Promise<Contract | TransactionResponse> => {
|
|
31
|
+
if (c instanceof Contract) {
|
|
32
|
+
await c.deployed();
|
|
33
|
+
console.log("deployed to: ", c.address);
|
|
34
|
+
}
|
|
35
|
+
if (c.wait) {
|
|
36
|
+
await c.wait();
|
|
37
|
+
console.log("tx done:", c.hash);
|
|
38
|
+
}
|
|
28
39
|
return c;
|
|
29
40
|
};
|
|
30
41
|
|
|
@@ -44,7 +55,6 @@ export const createDAO = async () => {
|
|
|
44
55
|
.then(_ => _.toString())
|
|
45
56
|
});
|
|
46
57
|
|
|
47
|
-
console.log("deployed erc20 tokens");
|
|
48
58
|
const DAOCreatorFactory = new ethers.ContractFactory(
|
|
49
59
|
DAOCreatorABI.abi,
|
|
50
60
|
DAOCreatorABI.bytecode,
|
|
@@ -67,48 +77,49 @@ export const createDAO = async () => {
|
|
|
67
77
|
root
|
|
68
78
|
);
|
|
69
79
|
|
|
70
|
-
const BancorFormula = await (
|
|
80
|
+
const BancorFormula = (await (
|
|
71
81
|
await ethers.getContractFactory("BancorFormula")
|
|
72
|
-
).deploy();
|
|
82
|
+
).deploy()) as Contract;
|
|
73
83
|
|
|
74
|
-
const AddFounders = await AddFoundersFactory.deploy().then(
|
|
84
|
+
const AddFounders = (await AddFoundersFactory.deploy().then(
|
|
85
|
+
printDeploy
|
|
86
|
+
)) as Contract;
|
|
75
87
|
// const AddFounders = await ethers.getContractAt(
|
|
76
88
|
// AddFoundersABI.abi,
|
|
77
89
|
// "0x6F1BAbfF5E119d61F0c6d8653d84E8B284B87091"
|
|
78
90
|
// );
|
|
79
91
|
|
|
80
|
-
const Identity = await IdentityFactory.deploy().then(
|
|
92
|
+
const Identity = (await IdentityFactory.deploy().then(
|
|
93
|
+
printDeploy
|
|
94
|
+
)) as Contract;
|
|
81
95
|
// const Identity = await ethers.getContractAt(
|
|
82
96
|
// IdentityABI.abi,
|
|
83
97
|
// "0x77Bd4D825F4df162BDdda73a7E295c27e09E289f"
|
|
84
98
|
// );
|
|
85
99
|
|
|
86
|
-
const daoCreator = await DAOCreatorFactory.deploy(AddFounders.address).then(
|
|
100
|
+
const daoCreator = (await DAOCreatorFactory.deploy(AddFounders.address).then(
|
|
87
101
|
printDeploy
|
|
88
|
-
);
|
|
89
|
-
// const daoCreator = await ethers.getContractAt(
|
|
90
|
-
// DAOCreatorABI.abi,
|
|
91
|
-
// "0xfD1eFFDed0EE8739dF61B580F24bCd6585d0c6B4"
|
|
92
|
-
// );
|
|
93
|
-
|
|
94
|
-
const FeeFormula = await FeeFormulaFactory.deploy(0).then(printDeploy);
|
|
95
|
-
// const FeeFormula = await ethers.getContractAt(
|
|
96
|
-
// FeeFormulaABI.abi,
|
|
97
|
-
// "0x85b146AAa910aF4ab1D64cD81ab6f804aDf3053c"
|
|
98
|
-
// );
|
|
99
|
-
|
|
100
|
-
await Identity.setAuthenticationPeriod(365);
|
|
101
|
-
await daoCreator.forgeOrg(
|
|
102
|
-
"GoodDollar",
|
|
103
|
-
"G$",
|
|
104
|
-
0,
|
|
105
|
-
FeeFormula.address,
|
|
106
|
-
Identity.address,
|
|
107
|
-
[root.address, signers[0].address, signers[1].address],
|
|
108
|
-
1000,
|
|
109
|
-
[100000, 100000, 100000]
|
|
110
|
-
);
|
|
102
|
+
)) as Contract;
|
|
111
103
|
|
|
104
|
+
const FeeFormula = (await FeeFormulaFactory.deploy(0).then(
|
|
105
|
+
printDeploy
|
|
106
|
+
)) as Contract;
|
|
107
|
+
|
|
108
|
+
await Identity.setAuthenticationPeriod(365).then(printDeploy);
|
|
109
|
+
console.log("setAuthPeriod");
|
|
110
|
+
await daoCreator
|
|
111
|
+
.forgeOrg(
|
|
112
|
+
"GoodDollar",
|
|
113
|
+
"G$",
|
|
114
|
+
0,
|
|
115
|
+
FeeFormula.address,
|
|
116
|
+
Identity.address,
|
|
117
|
+
[root.address, signers[0].address, signers[1].address],
|
|
118
|
+
1000,
|
|
119
|
+
[100000, 100000, 100000]
|
|
120
|
+
)
|
|
121
|
+
.then(printDeploy);
|
|
122
|
+
console.log("forgeOrg done ");
|
|
112
123
|
const Avatar = new ethers.Contract(
|
|
113
124
|
await daoCreator.avatar(),
|
|
114
125
|
[
|
|
@@ -118,7 +129,7 @@ export const createDAO = async () => {
|
|
|
118
129
|
root
|
|
119
130
|
);
|
|
120
131
|
|
|
121
|
-
await Identity.setAvatar(Avatar.address);
|
|
132
|
+
await Identity.setAvatar(Avatar.address).then(printDeploy);
|
|
122
133
|
|
|
123
134
|
console.log("Done deploying DAO, setting schemes permissions");
|
|
124
135
|
|
|
@@ -130,13 +141,15 @@ export const createDAO = async () => {
|
|
|
130
141
|
|
|
131
142
|
console.log("setting schemes", schemes);
|
|
132
143
|
|
|
133
|
-
await daoCreator
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
await daoCreator
|
|
145
|
+
.setSchemes(
|
|
146
|
+
Avatar.address,
|
|
147
|
+
schemes,
|
|
148
|
+
schemes.map(_ => ethers.constants.HashZero),
|
|
149
|
+
["0x0000001F", "0x00000001"],
|
|
150
|
+
""
|
|
151
|
+
)
|
|
152
|
+
.then(printDeploy);
|
|
140
153
|
|
|
141
154
|
let { setSchemes, genericCall, addWhitelisted } = await getHelperFunctions(
|
|
142
155
|
Identity,
|
|
@@ -162,10 +175,12 @@ export const createDAO = async () => {
|
|
|
162
175
|
);
|
|
163
176
|
schemes.push(sidechain.OneTimePayments.address);
|
|
164
177
|
const adminWallet = await deployAdminWallet(Identity.address);
|
|
165
|
-
await root
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
178
|
+
await root
|
|
179
|
+
.sendTransaction({
|
|
180
|
+
to: adminWallet.address,
|
|
181
|
+
value: ethers.utils.parseUnits("0.1", "ether")
|
|
182
|
+
})
|
|
183
|
+
.then(printDeploy);
|
|
169
184
|
Object.entries(sidechain).forEach(([k, v]) => (release[k] = v.address));
|
|
170
185
|
release["AdminWallet"] = adminWallet.address;
|
|
171
186
|
}
|
|
@@ -198,7 +213,7 @@ export const createDAO = async () => {
|
|
|
198
213
|
SchemeRegistrar: ethers.constants.AddressZero,
|
|
199
214
|
UpgradeScheme: ethers.constants.AddressZero
|
|
200
215
|
});
|
|
201
|
-
release = { ...
|
|
216
|
+
release = { ...v2, ...release };
|
|
202
217
|
|
|
203
218
|
if (isMainnet) {
|
|
204
219
|
await setSchemes([release.ProtocolUpgrade]);
|
|
@@ -261,18 +276,19 @@ const deployBridge = async (Avatar, gd, setSchemes, isMainnet) => {
|
|
|
261
276
|
isMainnet,
|
|
262
277
|
isAlreadyMinter
|
|
263
278
|
});
|
|
264
|
-
const scheme = await bridgeFactory
|
|
265
|
-
Avatar.address,
|
|
266
|
-
|
|
267
|
-
);
|
|
279
|
+
const scheme = (await bridgeFactory
|
|
280
|
+
.deploy(Avatar.address, BridgeFactoryContract)
|
|
281
|
+
.then(printDeploy)) as Contract;
|
|
268
282
|
await setSchemes([scheme.address]);
|
|
269
283
|
|
|
270
284
|
if (network.name.includes("develop")) {
|
|
271
|
-
const mockBridge = await new ethers.ContractFactory(
|
|
285
|
+
const mockBridge = (await new ethers.ContractFactory(
|
|
272
286
|
BridgeMock.abi,
|
|
273
287
|
BridgeMock.bytecode,
|
|
274
288
|
root
|
|
275
|
-
)
|
|
289
|
+
)
|
|
290
|
+
.deploy()
|
|
291
|
+
.then(printDeploy)) as Contract;
|
|
276
292
|
console.log("deployed mock bridge for develop mode:", mockBridge.address);
|
|
277
293
|
return isMainnet
|
|
278
294
|
? { ForeignBridge: mockBridge.address }
|
|
@@ -284,11 +300,12 @@ const deployBridge = async (Avatar, gd, setSchemes, isMainnet) => {
|
|
|
284
300
|
? scheme.setBridge()
|
|
285
301
|
: scheme.setBridge(isAlreadyMinter === false))
|
|
286
302
|
).wait();
|
|
287
|
-
|
|
303
|
+
const bridgeEvent = tx.events.find(_ => _.event?.includes("Bridge"));
|
|
304
|
+
console.log("deployed bridge:", bridgeEvent);
|
|
288
305
|
console.log(tx.events, tx);
|
|
289
306
|
return isMainnet
|
|
290
|
-
? { ForeignBridge:
|
|
291
|
-
: { HomeBridge:
|
|
307
|
+
? { ForeignBridge: bridgeEvent.args._foreignBridge }
|
|
308
|
+
: { HomeBridge: bridgeEvent.args._homeBridge };
|
|
292
309
|
};
|
|
293
310
|
|
|
294
311
|
const deployMainnet = async (Avatar, Identity) => {
|
|
@@ -303,15 +320,15 @@ const deployMainnet = async (Avatar, Identity) => {
|
|
|
303
320
|
|
|
304
321
|
let dai = daiAddr
|
|
305
322
|
? await ethers.getContractAt("DAIMock", daiAddr)
|
|
306
|
-
: await daiFactory.deploy();
|
|
323
|
+
: ((await daiFactory.deploy().then(printDeploy)) as Contract);
|
|
307
324
|
|
|
308
325
|
let COMP = COMPAddr
|
|
309
326
|
? await ethers.getContractAt("DAIMock", COMPAddr)
|
|
310
|
-
: await daiFactory.deploy();
|
|
327
|
+
: ((await daiFactory.deploy().then(printDeploy)) as Contract);
|
|
311
328
|
|
|
312
329
|
let cDAI = cdaiAddr
|
|
313
330
|
? await ethers.getContractAt("DAIMock", cdaiAddr)
|
|
314
|
-
: await cdaiFactory.deploy(dai.address);
|
|
331
|
+
: ((await cdaiFactory.deploy(dai.address).then(printDeploy)) as Contract);
|
|
315
332
|
|
|
316
333
|
const ccFactory = new ethers.ContractFactory(
|
|
317
334
|
ContributionCalculation.abi,
|
|
@@ -319,9 +336,9 @@ const deployMainnet = async (Avatar, Identity) => {
|
|
|
319
336
|
root
|
|
320
337
|
);
|
|
321
338
|
|
|
322
|
-
const contribution = await ccFactory
|
|
339
|
+
const contribution = (await ccFactory
|
|
323
340
|
.deploy(Avatar.address, 0, 1e15)
|
|
324
|
-
.then(printDeploy);
|
|
341
|
+
.then(printDeploy)) as Contract;
|
|
325
342
|
// const contribution = await ethers.getContractAt(
|
|
326
343
|
// ContributionCalculation.abi,
|
|
327
344
|
// "0xc3171409dB6827A68294B3A0D40a31310E83eD6B"
|
|
@@ -374,7 +391,9 @@ export const deploySidechain = async (
|
|
|
374
391
|
identity
|
|
375
392
|
});
|
|
376
393
|
|
|
377
|
-
const firstClaim = await fcFactory
|
|
394
|
+
const firstClaim = (await fcFactory
|
|
395
|
+
.deploy(avatar, identity, 1000)
|
|
396
|
+
.then(printDeploy)) as Contract;
|
|
378
397
|
|
|
379
398
|
let encoded = (
|
|
380
399
|
await ethers.getContractAt("IGoodDollar", gd)
|
|
@@ -384,21 +403,22 @@ export const deploySidechain = async (
|
|
|
384
403
|
|
|
385
404
|
console.log("deploying OneTimePayments");
|
|
386
405
|
|
|
387
|
-
const otp = await otpf
|
|
406
|
+
const otp = (await otpf
|
|
407
|
+
.deploy(avatar, identity)
|
|
408
|
+
.then(printDeploy)) as Contract;
|
|
388
409
|
|
|
389
410
|
console.log("deploying OneTimePayments invites");
|
|
390
|
-
const invites = await upgrades
|
|
391
|
-
avatar,
|
|
392
|
-
|
|
393
|
-
gd,
|
|
394
|
-
10000
|
|
395
|
-
]);
|
|
411
|
+
const invites = (await upgrades
|
|
412
|
+
.deployProxy(invitesf, [avatar, identity, gd, 10000])
|
|
413
|
+
.then(printDeploy)) as Contract;
|
|
396
414
|
|
|
397
|
-
const faucet = await upgrades
|
|
415
|
+
const faucet = (await upgrades
|
|
416
|
+
.deployProxy(faucetf, [identity])
|
|
417
|
+
.then(printDeploy)) as Contract;
|
|
398
418
|
|
|
399
419
|
console.log("setting firstclaim and otp schemes...");
|
|
400
420
|
await setSchemes([firstClaim.address, otp.address]);
|
|
401
|
-
|
|
421
|
+
await firstClaim.start().then(printDeploy);
|
|
402
422
|
|
|
403
423
|
return {
|
|
404
424
|
FirstClaimPool: firstClaim,
|
|
@@ -415,24 +435,28 @@ const deployAdminWallet = async identity => {
|
|
|
415
435
|
hdNode.derivePath(`m/44'/60'/0'/0/${i + 1}`)
|
|
416
436
|
);
|
|
417
437
|
|
|
418
|
-
const adminWallet = await new ethers.ContractFactory(
|
|
438
|
+
const adminWallet = (await new ethers.ContractFactory(
|
|
419
439
|
AdminWalletABI.abi,
|
|
420
440
|
AdminWalletABI.bytecode,
|
|
421
441
|
root
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
442
|
+
)
|
|
443
|
+
.deploy(
|
|
444
|
+
admins.slice(0, 20).map(_ => _.address),
|
|
445
|
+
ethers.utils.parseUnits("1000000", "gwei"),
|
|
446
|
+
4,
|
|
447
|
+
identity
|
|
448
|
+
)
|
|
449
|
+
.then(printDeploy)) as Contract;
|
|
428
450
|
|
|
429
451
|
const id = await ethers.getContractAt("IIdentity", identity);
|
|
430
|
-
await id.addIdentityAdmin(adminWallet.address);
|
|
431
|
-
await root
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
452
|
+
await id.addIdentityAdmin(adminWallet.address).then(printDeploy);
|
|
453
|
+
await root
|
|
454
|
+
.sendTransaction({
|
|
455
|
+
to: adminWallet.address,
|
|
456
|
+
value: ethers.utils.parseEther("1")
|
|
457
|
+
})
|
|
458
|
+
.then(printDeploy);
|
|
459
|
+
await adminWallet["topAdmins(uint256)"](0).then(printDeploy);
|
|
436
460
|
console.log(
|
|
437
461
|
"deployAdminWallet admins:",
|
|
438
462
|
admins.map(_ => _.address),
|
|
@@ -457,17 +481,19 @@ const getHelperFunctions = async (Identity, Avatar, schemeMock) => {
|
|
|
457
481
|
params[i] || ethers.constants.HashZero,
|
|
458
482
|
"0x0000001F",
|
|
459
483
|
Avatar.address
|
|
460
|
-
);
|
|
484
|
+
).then(printDeploy);
|
|
461
485
|
}
|
|
462
486
|
};
|
|
463
487
|
|
|
464
488
|
const genericCall = (target, encodedFunc) => {
|
|
465
|
-
return Controller.genericCall(target, encodedFunc, Avatar.address, 0)
|
|
489
|
+
return Controller.genericCall(target, encodedFunc, Avatar.address, 0).then(
|
|
490
|
+
printDeploy
|
|
491
|
+
);
|
|
466
492
|
};
|
|
467
493
|
|
|
468
494
|
const addWhitelisted = (addr, did, isContract = false) => {
|
|
469
495
|
if (isContract) return Identity.addContract(addr);
|
|
470
|
-
return Identity.addWhitelistedWithDID(addr, did);
|
|
496
|
+
return Identity.addWhitelistedWithDID(addr, did).then(printDeploy);
|
|
471
497
|
};
|
|
472
498
|
|
|
473
499
|
return { setSchemes, addWhitelisted, genericCall };
|
|
@@ -480,39 +506,43 @@ const performUpgradeFuse = async release => {
|
|
|
480
506
|
);
|
|
481
507
|
|
|
482
508
|
console.log("performing protocol v2 upgrade on Fuse...", { release });
|
|
483
|
-
await upgrade
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
[
|
|
494
|
-
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("REPUTATION")),
|
|
495
|
-
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("BRIDGE_CONTRACT")),
|
|
496
|
-
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("UBISCHEME")),
|
|
497
|
-
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_STAKING")),
|
|
498
|
-
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_CLAIMERS"))
|
|
499
|
-
],
|
|
500
|
-
[
|
|
501
|
-
release.GReputation,
|
|
502
|
-
release.HomeBridge || ethers.constants.AddressZero,
|
|
509
|
+
await upgrade
|
|
510
|
+
.upgrade(
|
|
511
|
+
release.NameService,
|
|
512
|
+
//old contracts
|
|
513
|
+
[
|
|
514
|
+
ethers.constants.AddressZero,
|
|
515
|
+
ethers.constants.AddressZero,
|
|
516
|
+
ethers.constants.AddressZero,
|
|
517
|
+
release.FirstClaimPool
|
|
518
|
+
],
|
|
503
519
|
release.UBIScheme,
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
520
|
+
[
|
|
521
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("REPUTATION")),
|
|
522
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("BRIDGE_CONTRACT")),
|
|
523
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("UBISCHEME")),
|
|
524
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_STAKING")),
|
|
525
|
+
ethers.utils.keccak256(ethers.utils.toUtf8Bytes("GDAO_CLAIMERS"))
|
|
526
|
+
],
|
|
527
|
+
[
|
|
528
|
+
release.GReputation,
|
|
529
|
+
release.HomeBridge || ethers.constants.AddressZero,
|
|
530
|
+
release.UBIScheme,
|
|
531
|
+
release.GovernanceStaking,
|
|
532
|
+
release.ClaimersDistribution
|
|
533
|
+
]
|
|
534
|
+
)
|
|
535
|
+
.then(printDeploy);
|
|
508
536
|
|
|
509
537
|
console.log("upgrading governance...");
|
|
510
538
|
|
|
511
|
-
await upgrade
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
539
|
+
await upgrade
|
|
540
|
+
.upgradeGovernance(
|
|
541
|
+
ethers.constants.AddressZero,
|
|
542
|
+
ethers.constants.AddressZero,
|
|
543
|
+
release.CompoundVotingMachine
|
|
544
|
+
)
|
|
545
|
+
.then(printDeploy);
|
|
516
546
|
};
|
|
517
547
|
|
|
518
548
|
const performUpgrade = async (release, ubiScheme) => {
|
|
@@ -563,21 +593,25 @@ const performUpgrade = async (release, ubiScheme) => {
|
|
|
563
593
|
release.COMP
|
|
564
594
|
]
|
|
565
595
|
});
|
|
566
|
-
tx = await upgrade
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
596
|
+
tx = await upgrade
|
|
597
|
+
.upgradeReserve(
|
|
598
|
+
release.NameService,
|
|
599
|
+
ethers.constants.AddressZero,
|
|
600
|
+
ethers.constants.AddressZero,
|
|
601
|
+
ethers.constants.AddressZero,
|
|
602
|
+
release.COMP
|
|
603
|
+
)
|
|
604
|
+
.then(printDeploy);
|
|
573
605
|
|
|
574
606
|
console.log("upgrading governance...");
|
|
575
607
|
|
|
576
|
-
tx = await upgrade
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
608
|
+
tx = await upgrade
|
|
609
|
+
.upgradeGovernance(
|
|
610
|
+
ethers.constants.AddressZero,
|
|
611
|
+
ethers.constants.AddressZero,
|
|
612
|
+
release.CompoundVotingMachine
|
|
613
|
+
)
|
|
614
|
+
.then(printDeploy);
|
|
581
615
|
};
|
|
582
616
|
|
|
583
617
|
const main = async () => {
|