generated from AngleProtocol/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: governance scripts for agToken renaming (#31)
* feat: governance scripts for agToken * doc: add previous name to upgrade script * refactor: use IERC20 in upgrade script * fix: make the upgrade of agTokens in two subcalls
- Loading branch information
1 parent
34c344e
commit 73191e7
Showing
3 changed files
with
93 additions
and
0 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,51 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.19; | ||
|
||
import { console } from "forge-std/console.sol"; | ||
import { Wrapper } from "../Wrapper.s.sol"; | ||
import "../../Constants.s.sol"; | ||
import { ProxyAdmin } from "oz/proxy/transparent/ProxyAdmin.sol"; | ||
|
||
contract UpgradeAgTokenNameable is Wrapper { | ||
SubCall[] private subCalls; | ||
mapping(uint256 => address) private _chainToToken; | ||
mapping(uint256 => address) private _chainToImplementation; | ||
|
||
function _upgradeAgToken(uint256 chainId, string memory name, string memory symbol, address proxy, address implementation, address proxyAdmin) private { | ||
vm.selectFork(forkIdentifier[chainId]); | ||
|
||
bytes memory nameAndSymbolData = abi.encodeWithSelector(INameable.setNameAndSymbol.selector, name, symbol); | ||
bytes memory data = abi.encodeWithSelector(ProxyAdmin.upgradeAndCall.selector, proxy, implementation, ""); | ||
|
||
subCalls.push(SubCall(chainId, proxyAdmin, 0, data)); | ||
subCalls.push(SubCall(chainId, proxy, 0, nameAndSymbolData)); | ||
} | ||
|
||
function run() external { | ||
uint256[] memory chainIds = vm.envUint("CHAIN_IDS", ","); | ||
string memory description = "ipfs://QmRSdyuXeemVEn97RPRSiit6UEUonvwVr9we7bEe2w8v2E"; | ||
|
||
/** TODO complete */ | ||
string memory name = "EURA"; // previously "agEUR" | ||
string memory symbol = "EURA"; // previously "agEUR" | ||
_chainToToken[CHAIN_ETHEREUM] = address(0); | ||
_chainToImplementation[CHAIN_ETHEREUM] = address(0); | ||
/** END complete */ | ||
|
||
for (uint256 i = 0; i < chainIds.length; i++) { | ||
address agToken = _chainToToken[chainIds[i]]; | ||
address implementation = _chainToImplementation[chainIds[i]]; | ||
address proxyAdmin = _chainToContract(chainIds[i], ContractType.ProxyAdmin); | ||
|
||
_upgradeAgToken(chainIds[i], name, symbol, agToken, implementation, proxyAdmin); | ||
} | ||
|
||
( | ||
address[] memory targets, | ||
uint256[] memory values, | ||
bytes[] memory calldatas, | ||
uint256[] memory chainIds2 | ||
) = _wrap(subCalls); | ||
_serializeJson(targets, values, calldatas, chainIds2, description); | ||
} | ||
} |
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,38 @@ | ||
// SPDX-License-Identifier: GPL-3.0 | ||
pragma solidity ^0.8.19; | ||
|
||
import { stdJson } from "forge-std/StdJson.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { ScriptHelpers } from "../ScriptHelpers.t.sol"; | ||
import "../../../scripts/Constants.s.sol"; | ||
import { TimelockControllerWithCounter } from "contracts/TimelockControllerWithCounter.sol"; | ||
import { ProposalSender } from "contracts/ProposalSender.sol"; | ||
import { IERC20Metadata } from "oz/token/ERC20/extensions/IERC20Metadata.sol"; | ||
|
||
contract SavingsSetRateTest is ScriptHelpers { | ||
using stdJson for string; | ||
mapping(uint256 => address) private _chainToToken; | ||
|
||
function setUp() public override { | ||
super.setUp(); | ||
} | ||
|
||
function testScript() external { | ||
uint256[] memory chainIds = _executeProposal(); | ||
|
||
/** TODO complete */ | ||
string memory name = "EURA"; | ||
string memory symbol = "EURA"; | ||
_chainToToken[CHAIN_ETHEREUM] = address(0); | ||
/** END complete */ | ||
|
||
// Now test that everything is as expected | ||
for (uint256 i; i < chainIds.length; i++) { | ||
uint256 chainId = chainIds[i]; | ||
IERC20Metadata agToken = IERC20Metadata(_chainToToken[chainId]); | ||
vm.selectFork(forkIdentifier[chainId]); | ||
assertEq(agToken.name(), name); | ||
assertEq(agToken.symbol(), symbol); | ||
} | ||
} | ||
} |