Skip to content

Commit

Permalink
Merge with new CCIP version
Browse files Browse the repository at this point in the history
  • Loading branch information
nisnislevi committed May 26, 2024
2 parents c36ccde + e2eac9f commit 8596bf8
Show file tree
Hide file tree
Showing 22 changed files with 768 additions and 133 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
> ❗️ Forked repository of CCIP contracts ([version 2.8.0 release](https://github.com/smartcontractkit/ccip/tree/v2.8.0-ccip1.4.0-release)) that includes modifications for developing custom TokenPool contracts tailored for the [GHO cross-chain strategy](https://governance.aave.com/t/arfc-gho-cross-chain-launch/17616). All relevant code and tests are located in the [GHO pools directory](./contracts/v0.8/ccip/pools/GHO).
<br/>
<p align="center">
<a href="https://chain.link" target="_blank">
Expand Down Expand Up @@ -232,9 +234,11 @@ flowchart RL
github.com/smartcontractkit/chainlink/core/scripts --> github.com/smartcontractkit/chainlink/v2
```

The `integration-tests` and `core/scripts` modules import the root module using a relative replace in their `go.mod` files,
so dependency changes in the root `go.mod` often require changes in those modules as well. After making a change, `go mod tidy`
can be run on all three modules using:

```
make gomodtidy
```
Expand All @@ -254,6 +258,7 @@ pnpm i
```bash
pnpm test
```

NOTE: Chainlink is currently in the process of migrating to Foundry and contains both Foundry and Hardhat tests in some versions. More information can be found here: [Chainlink Foundry Documentation](https://github.com/smartcontractkit/chainlink/blob/develop/contracts/foundry.md).
Any 't.sol' files associated with Foundry tests, contained within the src directories will be ignored by Hardhat.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol";
import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol";
import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol";

import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";
import {UpgradeableBurnMintTokenPoolAbstract} from "./UpgradeableBurnMintTokenPoolAbstract.sol";

import {IRouter} from "../interfaces/IRouter.sol";
import {IRouter} from "../../interfaces/IRouter.sol";
import {VersionedInitializable} from "./VersionedInitializable.sol";

/// @title UpgradeableBurnMintTokenPool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol";
import {IBurnMintERC20} from "../../../shared/token/ERC20/IBurnMintERC20.sol";

import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {ILiquidityContainer} from "../../rebalancer/interfaces/ILiquidityContainer.sol";
import {ITypeAndVersion} from "../../../shared/interfaces/ITypeAndVersion.sol";
import {ILiquidityContainer} from "../../../rebalancer/interfaces/ILiquidityContainer.sol";

import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {RateLimiter} from "../../libraries/RateLimiter.sol";

import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/utils/SafeERC20.sol";

import {IRouter} from "../interfaces/IRouter.sol";
import {IRouter} from "../../interfaces/IRouter.sol";
import {VersionedInitializable} from "./VersionedInitializable.sol";

/// @title UpgradeableLockReleaseTokenPool
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.0;

import {IPool} from "../interfaces/pools/IPool.sol";
import {IARM} from "../interfaces/IARM.sol";
import {IRouter} from "../interfaces/IRouter.sol";
import {IPool} from "../../interfaces/pools/IPool.sol";
import {IARM} from "../../interfaces/IARM.sol";
import {IRouter} from "../../interfaces/IRouter.sol";

import {OwnerIsCreator} from "../../shared/access/OwnerIsCreator.sol";
import {RateLimiter} from "../libraries/RateLimiter.sol";
import {OwnerIsCreator} from "../../../shared/access/OwnerIsCreator.sol";
import {RateLimiter} from "../../libraries/RateLimiter.sol";

import {IERC20} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IERC165} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/introspection/IERC165.sol";
import {EnumerableSet} from "../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/structs/EnumerableSet.sol";
import {IERC20} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/token/ERC20/IERC20.sol";
import {IERC165} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/introspection/IERC165.sol";
import {EnumerableSet} from "../../../vendor/openzeppelin-solidity/v4.8.3/contracts/utils/structs/EnumerableSet.sol";

/// @notice Base abstract class with common functions for all token pools.
/// A token pool serves as isolated place for holding tokens and token specific logic
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```diff
diff --git a/src/v0.8/ccip/pools/BurnMintTokenPoolAbstract.sol b/src/v0.8/ccip/pools/UpgradeableBurnMintTokenPoolAbstract.sol
index f5eb135186..651965e40b 100644
--- a/src/v0.8/ccip/pools/BurnMintTokenPoolAbstract.sol
+++ b/src/v0.8/ccip/pools/UpgradeableBurnMintTokenPoolAbstract.sol
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.19;
+pragma solidity ^0.8.0;

import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol";

-import {TokenPool} from "./TokenPool.sol";
+import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";

-abstract contract BurnMintTokenPoolAbstract is TokenPool {
+abstract contract UpgradeableBurnMintTokenPoolAbstract is UpgradeableTokenPool {
/// @notice Contains the specific burn call for a pool.
/// @dev overriding this method allows us to create pools with different burn signatures
/// without duplicating the underlying logic.
```
87 changes: 87 additions & 0 deletions contracts/src/v0.8/ccip/pools/GHO/diffs/BurnMintTokenPool_diff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
```diff
diff --git a/src/v0.8/ccip/pools/BurnMintTokenPool.sol b/src/v0.8/ccip/pools/UpgradeableBurnMintTokenPool.sol
index 9af0f22f4c..f07f8c3a28 100644
--- a/src/v0.8/ccip/pools/BurnMintTokenPool.sol
+++ b/src/v0.8/ccip/pools/UpgradeableBurnMintTokenPool.sol
@@ -1,29 +1,66 @@
// SPDX-License-Identifier: BUSL-1.1
-pragma solidity 0.8.19;
+pragma solidity ^0.8.0;

import {ITypeAndVersion} from "../../shared/interfaces/ITypeAndVersion.sol";
import {IBurnMintERC20} from "../../shared/token/ERC20/IBurnMintERC20.sol";

-import {TokenPool} from "./TokenPool.sol";
-import {BurnMintTokenPoolAbstract} from "./BurnMintTokenPoolAbstract.sol";
+import {UpgradeableTokenPool} from "./UpgradeableTokenPool.sol";
+import {UpgradeableBurnMintTokenPoolAbstract} from "./UpgradeableBurnMintTokenPoolAbstract.sol";

-/// @notice This pool mints and burns a 3rd-party token.
-/// @dev Pool whitelisting mode is set in the constructor and cannot be modified later.
-/// It either accepts any address as originalSender, or only accepts whitelisted originalSender.
-/// The only way to change whitelisting mode is to deploy a new pool.
-/// If that is expected, please make sure the token's burner/minter roles are adjustable.
-contract BurnMintTokenPool is BurnMintTokenPoolAbstract, ITypeAndVersion {
+import {IRouter} from "../interfaces/IRouter.sol";
+import {VersionedInitializable} from "./VersionedInitializable.sol";
+
+/// @title UpgradeableBurnMintTokenPool
+/// @author Aave Labs
+/// @notice Upgradeable version of Chainlink's CCIP BurnMintTokenPool
+/// @dev Contract adaptations:
+/// - Implementation of VersionedInitializable to allow upgrades
+/// - Move of allowlist and router definition to initialization stage
+contract UpgradeableBurnMintTokenPool is VersionedInitializable, UpgradeableBurnMintTokenPoolAbstract, ITypeAndVersion {
string public constant override typeAndVersion = "BurnMintTokenPool 1.4.0";

+ /// @dev Constructor
+ /// @param token The bridgeable token that is managed by this pool.
+ /// @param armProxy The address of the arm proxy
+ /// @param allowlistEnabled True if pool is set to access-controlled mode, false otherwise
constructor(
- IBurnMintERC20 token,
- address[] memory allowlist,
+ address token,
address armProxy,
- address router
- ) TokenPool(token, allowlist, armProxy, router) {}
+ bool allowlistEnabled
+ ) UpgradeableTokenPool(IBurnMintERC20(token), armProxy, allowlistEnabled) {}

- /// @inheritdoc BurnMintTokenPoolAbstract
+ /// @dev Initializer
+ /// @dev The address passed as `owner` must accept ownership after initialization.
+ /// @dev The `allowlist` is only effective if pool is set to access-controlled mode
+ /// @param owner The address of the owner
+ /// @param allowlist A set of addresses allowed to trigger lockOrBurn as original senders
+ /// @param router The address of the router
+ function initialize(address owner, address[] memory allowlist, address router) public virtual initializer {
+ if (owner == address(0)) revert ZeroAddressNotAllowed();
+ if (router == address(0)) revert ZeroAddressNotAllowed();
+ _transferOwnership(owner);
+
+ s_router = IRouter(router);
+
+ // Pool can be set as permissioned or permissionless at deployment time only to save hot-path gas.
+ if (i_allowlistEnabled) {
+ _applyAllowListUpdates(new address[](0), allowlist);
+ }
+ }
+
+ /// @inheritdoc UpgradeableBurnMintTokenPoolAbstract
function _burn(uint256 amount) internal virtual override {
IBurnMintERC20(address(i_token)).burn(amount);
}
+
+ /// @notice Returns the revision number
+ /// @return The revision number
+ function REVISION() public pure virtual returns (uint256) {
+ return 1;
+ }
+
+ /// @inheritdoc VersionedInitializable
+ function getRevision() internal pure virtual override returns (uint256) {
+ return REVISION();
+ }
}
```
Loading

0 comments on commit 8596bf8

Please sign in to comment.