-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into reserve-hack-fix
- Loading branch information
Showing
9 changed files
with
671 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import "../utils/NameService.sol"; | ||
import "../Interfaces.sol"; | ||
import "../reserve/GoodReserveCDai.sol"; | ||
import "../identity/IdentityV2.sol"; | ||
import "hardhat/console.sol"; | ||
|
||
contract LastauthReduction { | ||
NameService ns; | ||
|
||
uint public reduceByDays = 90; | ||
uint public startingPeriodDays = 180 + 90 * 5; | ||
uint public finalPeriod = 180; | ||
address public manager; | ||
|
||
constructor(NameService _ns) { | ||
ns = _ns; | ||
manager = msg.sender; | ||
} | ||
|
||
function reduce() external { | ||
require(msg.sender == manager, "not manager"); | ||
|
||
address avatar = ns.dao().avatar(); | ||
|
||
IdentityV2 id = IdentityV2(ns.getAddress("IDENTITY")); | ||
|
||
Controller ctrl = Controller(ns.getAddress("CONTROLLER")); | ||
uint curPeriod = id.authenticationPeriod(); | ||
|
||
IIdentity oldId = id.oldIdentity(); | ||
|
||
if (curPeriod <= finalPeriod) { | ||
// prevent executing again | ||
require(ctrl.unregisterSelf(avatar), "unregistering failed"); | ||
return; | ||
} | ||
|
||
bool ok; | ||
if (curPeriod > startingPeriodDays) { | ||
(ok, ) = ctrl.genericCall( | ||
address(id), | ||
abi.encodeCall( | ||
IdentityV2.setAuthenticationPeriod, | ||
(startingPeriodDays) | ||
), | ||
address(avatar), | ||
0 | ||
); | ||
require(ok, "setAuthenticationPeriod failed"); | ||
|
||
if (address(oldId) != address(0)) { | ||
(ok, ) = ctrl.genericCall( | ||
address(oldId), | ||
abi.encodeCall( | ||
IdentityV2.setAuthenticationPeriod, | ||
(startingPeriodDays) | ||
), | ||
address(avatar), | ||
0 | ||
); | ||
require(ok, "setAuthenticationPeriod failed"); | ||
} | ||
} else { | ||
(ok, ) = ctrl.genericCall( | ||
address(id), | ||
abi.encodeCall( | ||
IdentityV2.setAuthenticationPeriod, | ||
(curPeriod - reduceByDays) | ||
), | ||
address(avatar), | ||
0 | ||
); | ||
require(ok, "setAuthenticationPeriod failed"); | ||
|
||
if (address(oldId) != address(0)) { | ||
(ok, ) = ctrl.genericCall( | ||
address(oldId), | ||
abi.encodeCall( | ||
IdentityV2.setAuthenticationPeriod, | ||
(curPeriod - reduceByDays) | ||
), | ||
address(avatar), | ||
0 | ||
); | ||
require(ok, "setAuthenticationPeriod failed"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { uniq } from "lodash"; | ||
import fs from "fs"; | ||
import { network, ethers } from "hardhat"; | ||
import { Contract, Provider, setMulticallAddress } from "ethers-multicall"; | ||
import release from "../../releases/deployment.json" | ||
import { SimpleStakingV2 } from "../../types"; | ||
|
||
setMulticallAddress(122, "0x3CE6158b7278Bf6792e014FA7B4f3c6c46fe9410"); | ||
|
||
setMulticallAddress(42220, "0x188C1bf697B66474dC3eaa119Ae691a8352537e3"); | ||
|
||
const main = async () => { | ||
|
||
const c1 = await ethers.getContractAt("SimpleStakingV2", release["production-mainnet"].StakingContractsV3[0][0]) as SimpleStakingV2 | ||
const c2 = await ethers.getContractAt("SimpleStakingV2", release["production-mainnet"].StakingContractsV3[1][0]) as SimpleStakingV2 | ||
const f = c1.filters.Staked() | ||
const events = await c1.queryFilter(f, 14338550) | ||
const events2 = await c2.queryFilter(f, 14338550) | ||
const stakers = uniq(events.concat(events2).map(_ => _.args[0])) | ||
console.log(stakers) | ||
const res = (await Promise.all(stakers.map(async s => [s, await c1.balanceOf(s), await c2.balanceOf(s)]))).filter(_ => _[1].gt(0) || _[2].gt(0)) | ||
console.log(events.length) | ||
console.log(res) | ||
} | ||
main() |
Oops, something went wrong.