Skip to content

Commit

Permalink
feat: ccip 1.5.1 upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
DhairyaSethi committed Dec 11, 2024
1 parent c64c0c1 commit 2ff2f26
Show file tree
Hide file tree
Showing 21 changed files with 2,544 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "lib/aave-helpers"]
path = lib/aave-helpers
url = https://github.com/bgd-labs/aave-helpers
[submodule "lib/ccip"]
path = lib/ccip
url = https://github.com/aave/ccip
branch = feat/1_5_1_token_pool
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Emodes changed

### EMode: ETH correlated(id: 1)



### EMode: sUSDe Stablecoins(id: 2)



### EMode: rsETH LST main(id: 3)



## Raw diff

```json
{}
```
1 change: 1 addition & 0 deletions lib/ccip
Submodule ccip added at 5f84e6
1 change: 1 addition & 0 deletions remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ aave-helpers/=lib/aave-helpers/
aave-v3-origin/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/src/
forge-std/=lib/aave-helpers/lib/forge-std/src/
solidity-utils/=lib/aave-helpers/lib/aave-address-book/lib/aave-v3-origin/lib/solidity-utils/src
aave-ccip/=lib/ccip/contracts/src/v0.8/ccip
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,116 @@
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/src/interfaces/IProposalGenericExecutor.sol';
import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol';
import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol';
import {MiscEthereum} from 'aave-address-book/MiscEthereum.sol';
import {MiscArbitrum} from 'aave-address-book/MiscArbitrum.sol';
import {AaveV3ArbitrumAssets} from 'aave-address-book/AaveV3Arbitrum.sol';
import {ITokenAdminRegistry} from 'src/interfaces/ccip/ITokenAdminRegistry.sol';
import {IUpgradeableBurnMintTokenPool_1_4, IUpgradeableBurnMintTokenPool_1_5_1} from 'src/interfaces/ccip/tokenPool/IUpgradeableBurnMintTokenPool.sol';
import {IGhoToken} from 'src/interfaces/IGhoToken.sol';
import {IRateLimiter} from 'src/interfaces/ccip/IRateLimiter.sol';

contract Burner {
function burn(address token, uint256 amount) external {
IGhoToken(token).burn(amount);
}
}

/**
* @title GHO CCIP 1.5.1 Upgrade
* @author Aave Labs
* - Snapshot: TODO
* - Discussion: TODO
*/
contract AaveV3Arbitrum_GHOCCIP151Upgrade_20241209 is IProposalGenericExecutor {
uint64 public constant ETH_CHAIN_SELECTOR = 5009297550715157269;

// https://arbiscan.io/address/0x39AE1032cF4B334a1Ed41cdD0833bdD7c7E7751E
ITokenAdminRegistry public constant TOKEN_ADMIN_REGISTRY =
ITokenAdminRegistry(0x39AE1032cF4B334a1Ed41cdD0833bdD7c7E7751E);

// https://arbiscan.io/address/0xF168B83598516A532a85995b52504a2Fa058C068
IUpgradeableBurnMintTokenPool_1_4 public constant EXISTING_TOKEN_POOL =
IUpgradeableBurnMintTokenPool_1_4(0xF168B83598516A532a85995b52504a2Fa058C068); // MiscArbitrum.GHO_CCIP_TOKEN_POOL; -> not using since this will be overwritten with new token pool address
IUpgradeableBurnMintTokenPool_1_5_1 public immutable NEW_TOKEN_POOL;

// https://etherscan.io/address/0x9Ec9F9804733df96D1641666818eFb5198eC50f0
address public constant EXISTING_REMOTE_POOL_ETH = 0x9Ec9F9804733df96D1641666818eFb5198eC50f0; // ProxyPool on ETH
address public immutable NEW_REMOTE_POOL_ETH;

ProxyAdmin public constant PROXY_ADMIN = ProxyAdmin(MiscArbitrum.PROXY_ADMIN);
IGhoToken public constant GHO = IGhoToken(AaveV3ArbitrumAssets.GHO_UNDERLYING);

constructor(address newTokenPoolArb, address newTokenPoolEth) {
NEW_TOKEN_POOL = IUpgradeableBurnMintTokenPool_1_5_1(newTokenPoolArb);
NEW_REMOTE_POOL_ETH = newTokenPoolEth;
}

function execute() external {
// custom code goes here
_acceptOwnership();
_migrateLiquidity();
_setupAndRegisterNewPool();
}

// pre-req - chainlink transfers gho token pool ownership on token admin registry
function _acceptOwnership() internal {
NEW_TOKEN_POOL.acceptOwnership();
TOKEN_ADMIN_REGISTRY.acceptAdminRole(AaveV3ArbitrumAssets.GHO_UNDERLYING);
}

function _migrateLiquidity() internal {
// bucketLevel === bridgedAmount
(uint256 bucketCapacity, uint256 bucketLevel) = GHO.getFacilitatorBucket(
address(EXISTING_TOKEN_POOL)
);

GHO.addFacilitator(address(NEW_TOKEN_POOL), 'CCIP v1.5.1 TokenPool', uint128(bucketCapacity));
NEW_TOKEN_POOL.transferLiquidity(address(EXISTING_TOKEN_POOL), bucketLevel);

address existingTokenPoolImpl = PROXY_ADMIN.getProxyImplementation(
TransparentUpgradeableProxy(payable(address(EXISTING_TOKEN_POOL)))
);
PROXY_ADMIN.upgrade(
TransparentUpgradeableProxy(payable(address(EXISTING_TOKEN_POOL))),
address(new Burner())
);
Burner(address(EXISTING_TOKEN_POOL)).burn(address(GHO), bucketLevel);
PROXY_ADMIN.upgrade(
TransparentUpgradeableProxy(payable(address(EXISTING_TOKEN_POOL))),
existingTokenPoolImpl
);

GHO.removeFacilitator(address(EXISTING_TOKEN_POOL));
}

function _setupAndRegisterNewPool() internal {
IRateLimiter.Config memory emptyRateLimiterConfig = IRateLimiter.Config({
isEnabled: false,
capacity: 0,
rate: 0
});

IUpgradeableBurnMintTokenPool_1_5_1.ChainUpdate[]
memory chains = new IUpgradeableBurnMintTokenPool_1_5_1.ChainUpdate[](1);

bytes[] memory remotePoolAddresses = new bytes[](2);
remotePoolAddresses[0] = abi.encode(EXISTING_REMOTE_POOL_ETH);
remotePoolAddresses[1] = abi.encode(NEW_REMOTE_POOL_ETH);

chains[0] = IUpgradeableBurnMintTokenPool_1_5_1.ChainUpdate({
remoteChainSelector: ETH_CHAIN_SELECTOR,
remotePoolAddresses: remotePoolAddresses,
remoteTokenAddress: abi.encode(MiscEthereum.GHO_TOKEN),
outboundRateLimiterConfig: emptyRateLimiterConfig,
inboundRateLimiterConfig: emptyRateLimiterConfig
});

// setup new pool
NEW_TOKEN_POOL.applyChainUpdates(new uint64[](0), chains);
NEW_TOKEN_POOL.setRateLimitAdmin(EXISTING_TOKEN_POOL.getRateLimitAdmin()); // GhoCcipSteward

// register new pool
TOKEN_ADMIN_REGISTRY.setPool(address(GHO), address(NEW_TOKEN_POOL));
}
}
Loading

0 comments on commit 2ff2f26

Please sign in to comment.