Skip to content

Commit

Permalink
fix: Remove intermediary utils contract
Browse files Browse the repository at this point in the history
  • Loading branch information
CheyenneAtapour committed Nov 8, 2024
1 parent c0dfe64 commit 5e07b5a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,6 @@ import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol';
import {MiscArbitrum} from 'aave-address-book/MiscArbitrum.sol';
import {IGhoToken} from 'gho-core/gho/interfaces/IGhoToken.sol';

library Utils {
address public constant CCIP_RMN_PROXY = 0xC311a21e6fEf769344EB1515588B9d535662a145;
address public constant CCIP_ROUTER = 0x141fa059441E0ca23ce184B6A78bafD2A517DdE8;
// TODO: Wait for token admin registry to be deployed, and get proper address
address public constant CCIP_TOKEN_ADMIN_REGISTRY = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
uint256 public constant CCIP_BUCKET_CAPACITY = 1_000_000e18; // 1M
uint64 public constant CCIP_ETH_CHAIN_SELECTOR = 5009297550715157269;
uint64 public constant CCIP_AVAX_CHAIN_SELECTOR = 6433500567565415381;

function deployCcipTokenPool() external returns (address) {
address imple = address(
new UpgradeableBurnMintTokenPool(AaveV3ArbitrumAssets.GHO_UNDERLYING, CCIP_RMN_PROXY, false)
);

bytes memory tokenPoolInitParams = abi.encodeWithSignature(
'initialize(address,address[],address)',
GovernanceV3Arbitrum.EXECUTOR_LVL_1, // owner
new address[](0), // allowList
CCIP_ROUTER // router
);
return
address(
new TransparentUpgradeableProxy(
imple, // logic
MiscArbitrum.PROXY_ADMIN, // proxy admin
tokenPoolInitParams // data
)
);
}
}

/**
* @title GHOAvaxLaunch
* @author Aave Labs
Expand All @@ -58,20 +27,28 @@ library Utils {
* 7. Link token to pool on Chainlink token admin registry
*/
contract AaveV3Arbitrum_GHOAvaxLaunch_20241106 is IProposalGenericExecutor {
address public constant CCIP_RMN_PROXY = 0xC311a21e6fEf769344EB1515588B9d535662a145;
address public constant CCIP_ROUTER = 0x141fa059441E0ca23ce184B6A78bafD2A517DdE8;
// TODO: Wait for token admin registry to be deployed, and get proper address
address public constant CCIP_TOKEN_ADMIN_REGISTRY = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
uint256 public constant CCIP_BUCKET_CAPACITY = 1_000_000e18; // 1M
uint64 public constant CCIP_ETH_CHAIN_SELECTOR = 5009297550715157269;
uint64 public constant CCIP_AVAX_CHAIN_SELECTOR = 6433500567565415381;

function execute() external {
// 1. Deploy BurnMintTokenPool
address tokenPool = Utils.deployCcipTokenPool();
address tokenPool = _deployCcipTokenPool();

// 2. Accept TokenPool ownership
UpgradeableBurnMintTokenPool(tokenPool).acceptOwnership();

// 3. Configure CCIP TokenPool for Ethereum
// TODO: Set remote pool and token addresses after deployment?
_configureCcipTokenPool(tokenPool, Utils.CCIP_ETH_CHAIN_SELECTOR, address(0), address(0));
_configureCcipTokenPool(tokenPool, CCIP_ETH_CHAIN_SELECTOR, address(0), address(0));

// 4. Configure CCIP TokenPool for Avalanche
// TODO: Set remote pool and token addresses after deployment?
_configureCcipTokenPool(tokenPool, Utils.CCIP_AVAX_CHAIN_SELECTOR, address(0), address(0));
_configureCcipTokenPool(tokenPool, CCIP_AVAX_CHAIN_SELECTOR, address(0), address(0));

// 5. Add CCIP TokenPool as GHO Facilitator
IGhoToken(AaveV3ArbitrumAssets.GHO_UNDERLYING).grantRole(
Expand All @@ -85,21 +62,42 @@ contract AaveV3Arbitrum_GHOAvaxLaunch_20241106 is IProposalGenericExecutor {
IGhoToken(AaveV3ArbitrumAssets.GHO_UNDERLYING).addFacilitator(
tokenPool,
'CCIP TokenPool',
uint128(Utils.CCIP_BUCKET_CAPACITY)
uint128(CCIP_BUCKET_CAPACITY)
);

// 6. Accept administrator role from Chainlink token manager
TokenAdminRegistry(Utils.CCIP_TOKEN_ADMIN_REGISTRY).acceptAdminRole(
TokenAdminRegistry(CCIP_TOKEN_ADMIN_REGISTRY).acceptAdminRole(
AaveV3ArbitrumAssets.GHO_UNDERLYING
);

// 7. Link token to pool on Chainlink token admin registry
TokenAdminRegistry(Utils.CCIP_TOKEN_ADMIN_REGISTRY).setPool(
TokenAdminRegistry(CCIP_TOKEN_ADMIN_REGISTRY).setPool(
AaveV3ArbitrumAssets.GHO_UNDERLYING,
tokenPool
);
}

function _deployCcipTokenPool() internal returns (address) {
address imple = address(
new UpgradeableBurnMintTokenPool(AaveV3ArbitrumAssets.GHO_UNDERLYING, CCIP_RMN_PROXY, false)
);

bytes memory tokenPoolInitParams = abi.encodeWithSignature(
'initialize(address,address[],address)',
GovernanceV3Arbitrum.EXECUTOR_LVL_1, // owner
new address[](0), // allowList
CCIP_ROUTER // router
);
return
address(
new TransparentUpgradeableProxy(
imple, // logic
MiscArbitrum.PROXY_ADMIN, // proxy admin
tokenPoolInitParams // data
)
);
}

function _configureCcipTokenPool(
address tokenPool,
uint64 chainSelector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {UpgradeableBurnMintTokenPool} from 'ccip/pools/GHO/UpgradeableBurnMintTo
import {UpgradeableTokenPool} from 'ccip/pools/GHO/UpgradeableTokenPool.sol';
import {RateLimiter} from 'ccip/libraries/RateLimiter.sol';
import {TokenAdminRegistry} from 'ccip/tokenAdminRegistry/TokenAdminRegistry.sol';
import {IV3RateStrategyFactory} from 'lib/gho-core/lib/aave-stk-v1-5/lib/aave-helpers/src/v3-config-engine/IV3RateStrategyFactory.sol';
import {IProposalGenericExecutor} from 'aave-helpers/src/interfaces/IProposalGenericExecutor.sol';
import {AaveV3PayloadAvalanche} from 'aave-helpers/src/v3-config-engine/AaveV3PayloadAvalanche.sol';
import {AaveV3Avalanche, AaveV3AvalancheEModes} from 'aave-address-book/AaveV3Avalanche.sol';
Expand All @@ -19,48 +18,6 @@ import {IAaveV3ConfigEngine} from 'aave-v3-origin/contracts/extensions/v3-config
import {UpgradeableGhoToken} from 'gho-core/gho/UpgradeableGhoToken.sol';
import {IGhoToken} from 'gho-core/gho/interfaces/IGhoToken.sol';

library Utils {
address public constant CCIP_RMN_PROXY = 0xcBD48A8eB077381c3c4Eb36b402d7283aB2b11Bc;
address public constant CCIP_ROUTER = 0xF4c7E640EdA248ef95972845a62bdC74237805dB;
// TODO: Wait for token admin registry to be deployed, and get proper address
address public constant CCIP_TOKEN_ADMIN_REGISTRY = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
uint256 public constant CCIP_BUCKET_CAPACITY = 25_000_000e18; // 25M
uint64 public constant CCIP_ETH_CHAIN_SELECTOR = 5009297550715157269;
uint64 public constant CCIP_ARB_CHAIN_SELECTOR = 4949039107694359620;

function deployGhoToken() internal returns (address) {
address imple = address(new UpgradeableGhoToken());

bytes memory ghoTokenInitParams = abi.encodeWithSignature(
'initialize(address)',
GovernanceV3Avalanche.EXECUTOR_LVL_1 // owner
);
return
address(
new TransparentUpgradeableProxy(imple, MiscAvalanche.PROXY_ADMIN, ghoTokenInitParams)
);
}

function deployCcipTokenPool(address ghoToken) external returns (address) {
address imple = address(new UpgradeableBurnMintTokenPool(ghoToken, CCIP_RMN_PROXY, false));

bytes memory tokenPoolInitParams = abi.encodeWithSignature(
'initialize(address,address[],address)',
GovernanceV3Avalanche.EXECUTOR_LVL_1, // owner
new address[](0), // allowList
CCIP_ROUTER // router
);
return
address(
new TransparentUpgradeableProxy(
imple, // logic
MiscAvalanche.PROXY_ADMIN, // proxy admin
tokenPoolInitParams // data
)
);
}
}

/**
* @title GHO Avax Launch
* @author Aave Labs
Expand All @@ -77,23 +34,31 @@ library Utils {
* 8. Link token to pool on Chainlink token admin registry
*/
contract AaveV3Avalanche_GHOAvaxLaunch_20241106 is IProposalGenericExecutor {
address public constant CCIP_RMN_PROXY = 0xcBD48A8eB077381c3c4Eb36b402d7283aB2b11Bc;
address public constant CCIP_ROUTER = 0xF4c7E640EdA248ef95972845a62bdC74237805dB;
// TODO: Wait for token admin registry to be deployed, and get proper address
address public constant CCIP_TOKEN_ADMIN_REGISTRY = 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419;
uint256 public constant CCIP_BUCKET_CAPACITY = 25_000_000e18; // 25M
uint64 public constant CCIP_ETH_CHAIN_SELECTOR = 5009297550715157269;
uint64 public constant CCIP_ARB_CHAIN_SELECTOR = 4949039107694359620;

function execute() external {
// 1. Deploy GHO
address ghoToken = Utils.deployGhoToken();
address ghoToken = _deployGhoToken();

// 2. Deploy BurnMintTokenPool
address tokenPool = Utils.deployCcipTokenPool(ghoToken);
address tokenPool = _deployCcipTokenPool(ghoToken);

// 3. Accept TokenPool ownership
UpgradeableBurnMintTokenPool(tokenPool).acceptOwnership();

// 4. Configure CCIP TokenPool for Ethereum
// TODO: Set remote pool and token addresses after deployment?
_configureCcipTokenPool(tokenPool, Utils.CCIP_ETH_CHAIN_SELECTOR, address(0), address(0));
_configureCcipTokenPool(tokenPool, CCIP_ETH_CHAIN_SELECTOR, address(0), address(0));

// 5. Configure CCIP TokenPool for Arbitrum
// TODO: Set remote pool and token addresses after deployment?
_configureCcipTokenPool(tokenPool, Utils.CCIP_ARB_CHAIN_SELECTOR, address(0), address(0));
_configureCcipTokenPool(tokenPool, CCIP_ARB_CHAIN_SELECTOR, address(0), address(0));

// 6. Add CCIP TokenPool as GHO Facilitator
IGhoToken(ghoToken).grantRole(
Expand All @@ -104,17 +69,45 @@ contract AaveV3Avalanche_GHOAvaxLaunch_20241106 is IProposalGenericExecutor {
IGhoToken(ghoToken).BUCKET_MANAGER_ROLE(),
GovernanceV3Avalanche.EXECUTOR_LVL_1
);
IGhoToken(ghoToken).addFacilitator(
tokenPool,
'CCIP TokenPool',
uint128(Utils.CCIP_BUCKET_CAPACITY)
);
IGhoToken(ghoToken).addFacilitator(tokenPool, 'CCIP TokenPool', uint128(CCIP_BUCKET_CAPACITY));

// 7. Accept administrator role from Chainlink token manager
TokenAdminRegistry(Utils.CCIP_TOKEN_ADMIN_REGISTRY).acceptAdminRole(ghoToken);
TokenAdminRegistry(CCIP_TOKEN_ADMIN_REGISTRY).acceptAdminRole(ghoToken);

// 8. Link token to pool on Chainlink token admin registry
TokenAdminRegistry(Utils.CCIP_TOKEN_ADMIN_REGISTRY).setPool(ghoToken, tokenPool);
TokenAdminRegistry(CCIP_TOKEN_ADMIN_REGISTRY).setPool(ghoToken, tokenPool);
}

function _deployGhoToken() internal returns (address) {
address imple = address(new UpgradeableGhoToken());

bytes memory ghoTokenInitParams = abi.encodeWithSignature(
'initialize(address)',
GovernanceV3Avalanche.EXECUTOR_LVL_1 // owner
);
return
address(
new TransparentUpgradeableProxy(imple, MiscAvalanche.PROXY_ADMIN, ghoTokenInitParams)
);
}

function _deployCcipTokenPool(address ghoToken) internal returns (address) {
address imple = address(new UpgradeableBurnMintTokenPool(ghoToken, CCIP_RMN_PROXY, false));

bytes memory tokenPoolInitParams = abi.encodeWithSignature(
'initialize(address,address[],address)',
GovernanceV3Avalanche.EXECUTOR_LVL_1, // owner
new address[](0), // allowList
CCIP_ROUTER // router
);
return
address(
new TransparentUpgradeableProxy(
imple, // logic
MiscAvalanche.PROXY_ADMIN, // proxy admin
tokenPoolInitParams // data
)
);
}

function _configureCcipTokenPool(
Expand Down Expand Up @@ -152,8 +145,8 @@ contract AaveV3Avalanche_GHOAvaxLaunch_20241106 is IProposalGenericExecutor {
contract GhoAvaxListing is AaveV3PayloadAvalanche {
using SafeERC20 for IERC20;

uint256 constant GHO_SEED_AMOUNT = 1_000_000e18; // TODO: Determine appropriate seed amount
address ghoToken;
uint256 public constant GHO_SEED_AMOUNT = 1_000_000e18; // TODO: Determine appropriate seed amount
address public ghoToken;

constructor(address ghoToken) {
ghoToken = ghoToken;
Expand Down

0 comments on commit 5e07b5a

Please sign in to comment.