Skip to content

Commit

Permalink
feat: QoL cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Jan 3, 2025
1 parent e7c651e commit 7c6f9da
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ contract AaveV3Arbitrum_GHOBaseLaunch_20241223_Test is ProtocolV3TestBase {
assertEq(abi.encode(_tokenBucketToConfig(bucket)), abi.encode(config));
}

function test_BasePoolConfig() public view {
function test_basePoolConfig() public view {
assertEq(NEW_TOKEN_POOL.getSupportedChains().length, 2);
assertEq(NEW_TOKEN_POOL.getSupportedChains()[0], ETH_CHAIN_SELECTOR);
assertEq(NEW_TOKEN_POOL.getSupportedChains()[1], BASE_CHAIN_SELECTOR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,30 +60,26 @@ contract AaveV3Base_GHOBaseLaunch_20241223 is IProposalGenericExecutor {

function execute() external {
_acceptOwnership();

if (_deployAndInitializeGhoToken() != address(GHO_TOKEN_PROXY)) revert();

_deployAndInitializeGhoToken();
_setupStewardsAndTokenPoolOnGho();

_setupRemoteTokenPools(); // eth & arb

TOKEN_ADMIN_REGISTRY.setPool(address(GHO_TOKEN_PROXY), address(TOKEN_POOL));
_setupRemoteAndRegisterTokenPool();
}

function _acceptOwnership() internal {
TOKEN_ADMIN_REGISTRY.acceptAdminRole(address(GHO_TOKEN_PROXY));
TOKEN_POOL.acceptOwnership();
}

function _deployAndInitializeGhoToken() internal returns (address) {
return
address(
new TransparentUpgradeableProxy{salt: keccak256('based-GHO')}(
GHO_TOKEN_IMPL,
ProxyAdmin(MiscBase.PROXY_ADMIN),
abi.encodeCall(IGhoToken.initialize, (GovernanceV3Base.EXECUTOR_LVL_1))
)
);
function _deployAndInitializeGhoToken() internal {
address ghoTokenProxy = address(
new TransparentUpgradeableProxy{salt: keccak256('based-GHO')}(
GHO_TOKEN_IMPL,
ProxyAdmin(MiscBase.PROXY_ADMIN),
abi.encodeCall(IGhoToken.initialize, (GovernanceV3Base.EXECUTOR_LVL_1))
)
);
// burn all gas, assert predicted address match
assert(ghoTokenProxy == address(GHO_TOKEN_PROXY));
}

function _setupStewardsAndTokenPoolOnGho() internal {
Expand Down Expand Up @@ -119,7 +115,7 @@ contract AaveV3Base_GHOBaseLaunch_20241223 is IProposalGenericExecutor {
TOKEN_POOL.setRateLimitAdmin(GHO_CCIP_STEWARD);
}

function _setupRemoteTokenPools() internal {
function _setupRemoteAndRegisterTokenPool() internal {
IRateLimiter.Config memory rateLimiterConfig = IRateLimiter.Config({
isEnabled: true,
capacity: CCIP_RATE_LIMIT_CAPACITY,
Expand Down Expand Up @@ -153,9 +149,13 @@ contract AaveV3Base_GHOBaseLaunch_20241223 is IProposalGenericExecutor {
});
}

// setup remote token pools
TOKEN_POOL.applyChainUpdates({
remoteChainSelectorsToRemove: new uint64[](0),
chainsToAdd: chainsToAdd
});

// register token pool
TOKEN_ADMIN_REGISTRY.setPool(address(GHO_TOKEN_PROXY), address(TOKEN_POOL));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ contract AaveV3Base_GHOBaseListing_20241223 is AaveV3PayloadBase {
address public constant GHO_TOKEN = 0x6F2216CB3Ca97b8756C5fD99bE27986f04CBd81D;
uint256 public constant GHO_SEED_AMOUNT = 1e18;

function _preExecute() internal override {
// robot should simulate and only execute if seed amount has been bridged
assert(IERC20(GHO_TOKEN).balanceOf(address(this)) >= GHO_SEED_AMOUNT);
}

function _postExecute() internal override {
IERC20(GHO_TOKEN).forceApprove(address(AaveV3Base.POOL), GHO_SEED_AMOUNT);
AaveV3Base.POOL.supply(GHO_TOKEN, GHO_SEED_AMOUNT, address(0), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ contract AaveV3Base_GHOBaseListing_20241223_ListingPreRequisites is

(, , , , , , , , bool isActive, ) = AaveV3Base
.AAVE_PROTOCOL_DATA_PROVIDER
.getReserveConfigurationData(address(GHO_TOKEN));
.getReserveConfigurationData(proposal.GHO_TOKEN());
assertTrue(isActive);
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ contract AaveV3Base_GHOBaseListing_20241223_Listing is AaveV3Base_GHOBaseListing
assertEq(priceOracle.decimals(), 8);
}

function test_GhoAdmin() public {
function test_ghoAdmin() public {
GovV3Helpers.executePayload(vm, address(proposal));
(address aGhoToken, , ) = AaveV3Base.AAVE_PROTOCOL_DATA_PROVIDER.getReserveTokensAddresses(
proposal.GHO_TOKEN()
Expand Down Expand Up @@ -215,7 +215,7 @@ contract AaveV3Base_GHOBaseListing_20241223_Stewards is AaveV3Base_GHOBaseListin

function test_aaveStewardCanUpdateBorrowCap(uint256 newBorrowCap) public {
uint256 currentBorrowCap = AaveV3Base.POOL.getConfiguration(address(GHO_TOKEN)).getBorrowCap();
assertEq(currentBorrowCap, 2_250_000, 'currentBorrowCap');
assertEq(currentBorrowCap, 2_250_000);
vm.assume(
newBorrowCap != currentBorrowCap &&
_isDifferenceLowerThanMax(currentBorrowCap, newBorrowCap, currentBorrowCap)
Expand All @@ -229,7 +229,7 @@ contract AaveV3Base_GHOBaseListing_20241223_Stewards is AaveV3Base_GHOBaseListin

function test_aaveStewardCanUpdateSupplyCap(uint256 newSupplyCap) public {
uint256 currentSupplyCap = AaveV3Base.POOL.getConfiguration(address(GHO_TOKEN)).getSupplyCap();
assertEq(currentSupplyCap, 2_500_000, 'currentSupplyCap');
assertEq(currentSupplyCap, 2_500_000);

vm.assume(
currentSupplyCap != newSupplyCap &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ contract AaveV3Ethereum_GHOBaseLaunch_20241223_Test is ProtocolV3TestBase {
assertEq(abi.encode(_tokenBucketToConfig(bucket)), abi.encode(config));
}

function test_BasePoolConfig() public view {
function test_basePoolConfig() public view {
assertEq(NEW_TOKEN_POOL.getSupportedChains().length, 2);
assertEq(NEW_TOKEN_POOL.getSupportedChains()[0], ARB_CHAIN_SELECTOR);
assertEq(NEW_TOKEN_POOL.getSupportedChains()[1], BASE_CHAIN_SELECTOR);
Expand Down

0 comments on commit 7c6f9da

Please sign in to comment.