forked from liquity/dev
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from Threshold-USD/feat/proxy-contract-for-au…
…tomated-revoke-of-mint-capability feat: thusd owner contract for revoking deprecated thusd contracts
- Loading branch information
Showing
5 changed files
with
190 additions
and
4 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
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,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.17; | ||
|
||
import "./THUSDToken.sol"; | ||
import "./Dependencies/CheckContract.sol"; | ||
import "./Dependencies/Ownable.sol"; | ||
|
||
contract THUSDOwner is Ownable, CheckContract { | ||
THUSDToken public immutable thusdToken; | ||
|
||
address public immutable governorBravoAddress; | ||
|
||
constructor( | ||
address _governorBravoAddress, | ||
address _thusdTokenAddress, | ||
address _integrationsGuild | ||
) { | ||
checkContract(_thusdTokenAddress); | ||
thusdToken = THUSDToken(_thusdTokenAddress); | ||
|
||
require(_integrationsGuild != address(0), "Integrations Guild address must be specified"); | ||
require(_governorBravoAddress != address(0), "Governor Bravo address must be specified"); | ||
|
||
governorBravoAddress = _governorBravoAddress; | ||
|
||
_transferOwnership(_integrationsGuild); | ||
} | ||
|
||
function startRevokeMintList(address _account) external onlyOwner { | ||
thusdToken.startRevokeMintList(_account); | ||
} | ||
|
||
function finalizeRevokeMintList() external onlyOwner { | ||
thusdToken.finalizeRevokeMintList(); | ||
} | ||
|
||
function transferThusdOwnershipToGovernorBravo() external onlyOwner { | ||
thusdToken.transferOwnership(governorBravoAddress); | ||
} | ||
} |
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,134 @@ | ||
const deploymentHelper = require("../utils/deploymentHelpers.js") | ||
const testHelpers = require("../utils/testHelpers.js") | ||
|
||
const { | ||
assertRevert, | ||
ZERO_ADDRESS, | ||
getLatestBlockTimestamp, | ||
fastForwardTime, | ||
} = testHelpers.TestHelper | ||
|
||
contract('THUSDOwner', async accounts => { | ||
const [owner, integrationsGuild, governorBravo] = accounts; | ||
|
||
let thusdOwner | ||
let thusdToken | ||
let borrowerOperations | ||
|
||
let delay | ||
|
||
beforeEach(async () => { | ||
const contracts = await deploymentHelper.deployTesterContractsHardhat(accounts) | ||
await deploymentHelper.connectCoreContracts(contracts) | ||
|
||
thusdOwner = contracts.thusdOwner | ||
thusdToken = contracts.thusdToken | ||
borrowerOperations = contracts.borrowerOperations | ||
|
||
await thusdToken.transferOwnership( | ||
thusdOwner.address, | ||
{ from: owner } | ||
) | ||
|
||
delay = (await thusdToken.governanceTimeDelay()).toNumber() | ||
}) | ||
|
||
it('owner(): owner is integrations guild', async () => { | ||
await assert.equal(await thusdOwner.owner(), integrationsGuild) | ||
}) | ||
|
||
it('startRevokeMintList(): reverts when caller is not owner', async () => { | ||
await assertRevert( | ||
thusdOwner.startRevokeMintList( | ||
borrowerOperations.address, | ||
{ from: governorBravo }), | ||
"Ownable: caller is not the owner") | ||
}) | ||
|
||
it('startRevokeMintList(): reverts when account has no minting role', async () => { | ||
await assertRevert( | ||
thusdOwner.startRevokeMintList( | ||
integrationsGuild, | ||
{ from: integrationsGuild }), | ||
"Incorrect address to revoke") | ||
}) | ||
|
||
it('startRevokeMintList(): puts account to pending list', async () => { | ||
await thusdOwner.startRevokeMintList(borrowerOperations.address, { from: integrationsGuild }) | ||
|
||
const timeNow = await getLatestBlockTimestamp(web3) | ||
assert.equal(await thusdToken.pendingRevokedMintAddress(), borrowerOperations.address) | ||
assert.equal(await thusdToken.revokeMintListInitiated(), timeNow) | ||
|
||
assert.isTrue(await thusdToken.mintList(borrowerOperations.address)) | ||
}) | ||
|
||
it('finalizeRevokeMintList(): reverts when caller is not owner', async () => { | ||
await assertRevert( | ||
thusdOwner.finalizeRevokeMintList( | ||
{ from: owner }), | ||
"Ownable: caller is not the owner") | ||
}) | ||
|
||
it('finalizeRevokeMintList(): reverts when change is not initiated', async () => { | ||
await assertRevert( | ||
thusdOwner.finalizeRevokeMintList( | ||
{ from: integrationsGuild }), | ||
"Change not initiated") | ||
}) | ||
|
||
it('finalizeRevokeMintList(): reverts when passed not enough time', async () => { | ||
await thusdOwner.startRevokeMintList( | ||
borrowerOperations.address, | ||
{ from: integrationsGuild } | ||
) | ||
await assertRevert( | ||
thusdOwner.finalizeRevokeMintList( | ||
{ from: integrationsGuild }), | ||
"Governance delay has not elapsed") | ||
}) | ||
|
||
it('finalizeRevokeMintList(): removes account from minting list', async () => { | ||
await thusdOwner.startRevokeMintList( | ||
borrowerOperations.address, | ||
{ from: integrationsGuild } | ||
) | ||
await fastForwardTime(delay, web3.currentProvider) | ||
|
||
await thusdOwner.finalizeRevokeMintList({ from: integrationsGuild }) | ||
|
||
assert.equal(await thusdToken.pendingRevokedMintAddress(), ZERO_ADDRESS) | ||
assert.equal(await thusdToken.revokeMintListInitiated(), 0) | ||
|
||
assert.isFalse(await thusdToken.mintList(borrowerOperations.address)) | ||
}) | ||
|
||
it('finalizeRevokeMintList(): removes account from minting list', async () => { | ||
await thusdOwner.startRevokeMintList( | ||
borrowerOperations.address, | ||
{ from: integrationsGuild } | ||
) | ||
await fastForwardTime(delay, web3.currentProvider) | ||
|
||
await thusdOwner.finalizeRevokeMintList({ from: integrationsGuild }) | ||
|
||
assert.equal(await thusdToken.pendingRevokedMintAddress(), ZERO_ADDRESS) | ||
assert.equal(await thusdToken.revokeMintListInitiated(), 0) | ||
|
||
assert.isFalse(await thusdToken.mintList(borrowerOperations.address)) | ||
}) | ||
|
||
it('transferThusdOwnershipToGovernorBravo(): reverts when caller is not owner', async () => { | ||
await assertRevert(thusdOwner.transferThusdOwnershipToGovernorBravo( | ||
{ from: owner }), | ||
"Ownable: caller is not the owner" | ||
) | ||
}) | ||
|
||
it('transferThusdOwnershipToGovernorBravo(): transfer thusd ownership to governor bravo', async () => { | ||
await thusdOwner.transferThusdOwnershipToGovernorBravo( | ||
{ from: integrationsGuild } | ||
) | ||
await assert.equal(await thusdToken.owner(), governorBravo) | ||
}) | ||
}) |
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