Skip to content

Commit

Permalink
feat: governance scripts for agToken renaming (#31)
Browse files Browse the repository at this point in the history
* 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
0xtekgrinder authored Jul 13, 2024
1 parent 34c344e commit 73191e7
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
4 changes: 4 additions & 0 deletions scripts/Interfaces.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ interface IVaultManagerGovernance {
function interestRate() external view returns (uint64);
}

interface INameable {
function setNameAndSymbol(string memory name, string memory symbol) external;
}

interface ISavings {
function setRate(uint208 newRate) external;

Expand Down
51 changes: 51 additions & 0 deletions scripts/proposals/nameable/UpgradeAgTokenNameable.s.sol
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);
}
}
38 changes: 38 additions & 0 deletions test/scripts/nameable/UpgradeAgTokenNameable.t.sol
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);
}
}
}

0 comments on commit 73191e7

Please sign in to comment.