From 3f42b38aa563426f0c0b6e320ea9b397f511343c Mon Sep 17 00:00:00 2001 From: sendra Date: Thu, 4 Apr 2024 18:10:12 +0200 Subject: [PATCH] feat: add payloads to update native aDI bridge adapters (#273) * feat: add payloads to update native aDI bridge adapters * fix: fixed tests * fix: updated readme * fix: correct path to diffs * fix: use address(0) instead of old adapter, as it will not be removed * Update src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md Co-authored-by: Ernesto Boado * Update src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md Co-authored-by: Ernesto Boado * fix: added discussion link * Update src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md --------- Co-authored-by: Ernesto Boado --- ...um_NativeBridgeAdaptersUpdate_20240322.sol | 47 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...se_NativeBridgeAdaptersUpdate_20240322.sol | 46 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...um_NativeBridgeAdaptersUpdate_20240322.sol | 142 ++++++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...is_NativeBridgeAdaptersUpdate_20240322.sol | 35 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...is_NativeBridgeAdaptersUpdate_20240322.sol | 47 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...sm_NativeBridgeAdaptersUpdate_20240322.sol | 47 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...on_NativeBridgeAdaptersUpdate_20240322.sol | 41 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + ...ll_NativeBridgeAdaptersUpdate_20240322.sol | 47 ++ ..._NativeBridgeAdaptersUpdate_20240322.t.sol | 22 + .../BaseAdaptersUpdatePayload.sol | 159 +++++++ .../BaseTest.sol | 403 ++++++++++++++++++ .../NativeBridgeAdaptersUpdate.md | 41 ++ .../NativeBridgeAdaptersUpdate_20240322.s.sol | 268 ++++++++++++ .../config.ts | 31 ++ 21 files changed, 1530 insertions(+) create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.t.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseAdaptersUpdatePayload.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseTest.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol create mode 100644 src/20240322_Multi_NativeBridgeAdaptersUpdate/config.ts diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..ac084cc63 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, + newAdapter: 0xc8a2ADC4261c6b669CdFf69E717E77C9cFeB420d, + adapterToRemove: address(0) // @dev We dont remove old adapter so that system can be rescued by just re adding sender on Ethereum aDI + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } + + // @dev in this AIP we are not removing old adapter, in case connection gets broken. This way, we would just need to + // re enable old adapter on origin, and we would have reestablished the connection + function getReceiverBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..aeec4b349 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Arbitrum} from 'aave-address-book/GovernanceV3Arbitrum.sol'; +import {AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER, + type(AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'arbitrum', + 193049277, + 'Arbitrum native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..7b9b3c4fd --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,46 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Base_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Base.CROSS_CHAIN_CONTROLLER, + newAdapter: 0x7120b1f8e5b73c0C0DC99C6e52Fe4937E7EA11e0, + adapterToRemove: address(0) // @dev We dont remove old adapter so that system can be rescued by just re adding sender on Ethereum aDI + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } + + // @dev in this AIP we are not removing old adapter, in case connection gets broken. This way, we would just need to + // re enable old adapter on origin, and we would have reestablished the connection + function getReceiverBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..bbca7bf68 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Base} from 'aave-address-book/GovernanceV3Base.sol'; +import {AaveV3Base_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Base_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Base_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Base_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Base.CROSS_CHAIN_CONTROLLER, + type(AaveV3Base_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'base', + 12163947, + 'Base native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..a164c7b21 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,142 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + newAdapter: 0x1562F1b2487F892BBA8Ef325aF054Fd157510a71, // POLYGON native bridge adapter + adapterToRemove: 0xb13712De579E1f9943502FFCf72eab6ec348cF79 // POLYGON native bridge adapter + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.POLYGON; + return chains; + } + + function getForwarderBridgeAdaptersToEnable() + public + pure + override + returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + 8 + ); + + bridgeAdaptersToEnable[0] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x88d6D01e08d3e64513b15fD46528dBbA7d755883, + destinationBridgeAdapter: 0xc8a2ADC4261c6b669CdFf69E717E77C9cFeB420d, + destinationChainId: ChainIds.ARBITRUM + }); + bridgeAdaptersToEnable[1] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x1562F1b2487F892BBA8Ef325aF054Fd157510a71, + destinationBridgeAdapter: 0x853649f897383f89d8441346Cf26a9ed02720B02, + destinationChainId: ChainIds.POLYGON + }); + bridgeAdaptersToEnable[2] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x0e24524778fdc67f53eEf144b8cbf50261E930B3, + destinationBridgeAdapter: 0xAE93BEa44dcbE52B625169588574d31e36fb3A67, + destinationChainId: ChainIds.OPTIMISM + }); + bridgeAdaptersToEnable[3] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x7238d75fD75bb936E83b75854c653F104Ce9c9d8, + destinationBridgeAdapter: 0x3C06dce358add17aAf230f2234bCCC4afd50d090, + destinationChainId: ChainIds.GNOSIS + }); + bridgeAdaptersToEnable[4] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0xA4dC3F123e1c601A19B3DC8382BB9311F678cafA, + destinationBridgeAdapter: 0x3C06dce358add17aAf230f2234bCCC4afd50d090, + destinationChainId: ChainIds.SCROLL + }); + bridgeAdaptersToEnable[5] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0xa5948b0ac79f72966dFFC5C13E44f6dfDD3D58A0, + destinationBridgeAdapter: 0x7120b1f8e5b73c0C0DC99C6e52Fe4937E7EA11e0, + destinationChainId: ChainIds.BASE + }); + bridgeAdaptersToEnable[6] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x6B3Dc800E7c813Db3fe8D0F30fDCaE636935dC14, + destinationBridgeAdapter: 0xf41193E25408F652AF878c47E4401A01B5E4B682, + destinationChainId: ChainIds.METIS + }); + bridgeAdaptersToEnable[7] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: 0x6cfbd2aA4691fc18B9C209bDd43DC3943C228FCf, + destinationBridgeAdapter: 0x6cfbd2aA4691fc18B9C209bDd43DC3943C228FCf, + destinationChainId: ChainIds.MAINNET + }); + + return bridgeAdaptersToEnable; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + ICrossChainForwarder.BridgeAdapterToDisable[] + memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](8); + + forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0xE2a33403eaD139873820da597531f07f65ED0E3c, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[0].chainIds[0] = ChainIds.ARBITRUM; + + forwarderAdaptersToRemove[1] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0xb13712De579E1f9943502FFCf72eab6ec348cF79, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[1].chainIds[0] = ChainIds.POLYGON; + + forwarderAdaptersToRemove[2] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0x2ecC4F6CDbe6ea77107dd131Af81ec82Db330d6b, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[2].chainIds[0] = ChainIds.OPTIMISM; + + forwarderAdaptersToRemove[3] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0xe95B40b2CF5fA2F56AAEf9E52f5Bd1e70C059858, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[3].chainIds[0] = ChainIds.GNOSIS; + + forwarderAdaptersToRemove[4] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0xb29F03cbCc646201eC83E9F2C164747beA84b162, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[4].chainIds[0] = ChainIds.SCROLL; + + forwarderAdaptersToRemove[5] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0xEB442296880a3FC7C00FFe695c40B09d970fb936, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[5].chainIds[0] = ChainIds.BASE; + + forwarderAdaptersToRemove[6] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0x619643b346E3389062527cdb60C8720415B39860, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[6].chainIds[0] = ChainIds.METIS; + + forwarderAdaptersToRemove[7] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: 0x118DFD5418890c0332042ab05173Db4A2C1d283c, + chainIds: new uint256[](1) + }); + forwarderAdaptersToRemove[7].chainIds[0] = ChainIds.MAINNET; + + return forwarderAdaptersToRemove; + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..f52c5d08a --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER, + type(AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'mainnet', + 19490720, + 'Polygon native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..6b81a8d07 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,35 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, + newAdapter: 0x3C06dce358add17aAf230f2234bCCC4afd50d090, + adapterToRemove: 0x889c0cc3283DB588A34E89Ad1E8F25B0fc827b4b + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..c95dfb11d --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Gnosis} from 'aave-address-book/GovernanceV3Gnosis.sol'; +import {AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER, + type(AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'gnosis', + 33108913, + 'Gnosis native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..b241e17f7 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Metis_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, + newAdapter: 0xf41193E25408F652AF878c47E4401A01B5E4B682, + adapterToRemove: address(0) // @dev We dont remove old adapter so that system can be rescued by just re adding sender on Ethereum aDI + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } + + // @dev in this AIP we are not removing old adapter, in case connection gets broken. This way, we would just need to + // re enable old adapter on origin, and we would have reestablished the connection + function getReceiverBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..3cda3e731 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol'; +import {AaveV3Metis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Metis_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Metis_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Metis_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Metis.CROSS_CHAIN_CONTROLLER, + type(AaveV3Metis_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'metis', + 15632608, + 'Metis native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..64f7712ef --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, + newAdapter: 0xAE93BEa44dcbE52B625169588574d31e36fb3A67, + adapterToRemove: address(0) // @dev We dont remove old adapter so that system can be rescued by just re adding sender on Ethereum aDI + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } + + // @dev in this AIP we are not removing old adapter, in case connection gets broken. This way, we would just need to + // re enable old adapter on origin, and we would have reestablished the connection + function getReceiverBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..7170262b8 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol'; +import {AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER, + type(AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'optimism', + 117759224, + 'Optimism native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..8bb02828f --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + newAdapter: 0x853649f897383f89d8441346Cf26a9ed02720B02, + adapterToRemove: 0xb13712De579E1f9943502FFCf72eab6ec348cF79 + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getDestinationAdapters() + public + pure + override + returns (DestinationAdaptersInput[] memory) + { + DestinationAdaptersInput[] memory destinationAdapters = new DestinationAdaptersInput[](1); + + destinationAdapters[0].adapter = 0x1562F1b2487F892BBA8Ef325aF054Fd157510a71; + destinationAdapters[0].chainId = ChainIds.MAINNET; + + return destinationAdapters; + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..e46c4e4f0 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER, + type(AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'polygon', + 54954005, + 'Polygon native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol new file mode 100644 index 000000000..71878d1f7 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {BaseAdaptersUpdatePayload, ICrossChainReceiver, ICrossChainForwarder} from './BaseAdaptersUpdatePayload.sol'; +import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; + +/** + * @title Native bridge adapters update + * @author BGD Labs @bgdlabs + * - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26 + */ +contract AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322 is + BaseAdaptersUpdatePayload( + BaseAdaptersUpdatePayload.ConstructorInput({ + ccc: GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER, + newAdapter: 0x3C06dce358add17aAf230f2234bCCC4afd50d090, + adapterToRemove: address(0) // @dev We dont remove old adapter so that system can be rescued by just re adding sender on Ethereum aDI + }) + ) +{ + function getChainsToReceive() public pure override returns (uint256[] memory) { + uint256[] memory chains = new uint256[](1); + chains[0] = ChainIds.MAINNET; + return chains; + } + + function getForwarderBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + return new ICrossChainForwarder.BridgeAdapterToDisable[](0); + } + + // @dev in this AIP we are not removing old adapter, in case connection gets broken. This way, we would just need to + // re enable old adapter on origin, and we would have reestablished the connection + function getReceiverBridgeAdaptersToRemove() + public + pure + override + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + return new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](0); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.t.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.t.sol new file mode 100644 index 000000000..8225662b1 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.t.sol @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import './BaseTest.sol'; +import {GovernanceV3Scroll} from 'aave-address-book/GovernanceV3Scroll.sol'; +import {AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Test for AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322 + * command: make test-contract filter=AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322 + */ +contract AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322_Test is BaseTest { + constructor() + BaseTest( + GovernanceV3Scroll.CROSS_CHAIN_CONTROLLER, + type(AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322).creationCode, + 'scroll', + 4339218, + 'Scroll native adapter' + ) + {} +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseAdaptersUpdatePayload.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseAdaptersUpdatePayload.sol new file mode 100644 index 000000000..fafac8fc6 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseAdaptersUpdatePayload.sol @@ -0,0 +1,159 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; +import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol'; + +/** + * @title Base payload aDI and bridge adapters update + * @author BGD Labs @bgdlabs + */ +abstract contract BaseAdaptersUpdatePayload is IProposalGenericExecutor { + struct ConstructorInput { + address ccc; + address adapterToRemove; + address newAdapter; + } + struct DestinationAdaptersInput { + address adapter; + uint256 chainId; + } + + address public immutable CROSS_CHAIN_CONTROLLER; + address public immutable ADAPTER_TO_REMOVE; + address public immutable NEW_ADAPTER; + + constructor(ConstructorInput memory constructorInput) { + CROSS_CHAIN_CONTROLLER = constructorInput.ccc; + ADAPTER_TO_REMOVE = constructorInput.adapterToRemove; + NEW_ADAPTER = constructorInput.newAdapter; + } + + function execute() public override { + // remove old Receiver bridge adapter + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receiversToRemove = getReceiverBridgeAdaptersToRemove(); + if (receiversToRemove.length != 0) { + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(receiversToRemove); + } + + // remove forwarding adapters + ICrossChainForwarder.BridgeAdapterToDisable[] + memory forwardersToRemove = getForwarderBridgeAdaptersToRemove(); + if (forwardersToRemove.length != 0) { + ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).disableBridgeAdapters(forwardersToRemove); + } + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receiversToAllow = getReceiverBridgeAdaptersToAllow(); + if (receiversToAllow.length != 0) { + // add receiver adapters + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(receiversToAllow); + } + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory forwardersToEnable = getForwarderBridgeAdaptersToEnable(); + if (forwardersToEnable.length != 0) { + // add forwarding adapters + ICrossChainForwarder(CROSS_CHAIN_CONTROLLER).enableBridgeAdapters(forwardersToEnable); + } + } + + function getDestinationAdapters() + public + pure + virtual + returns (DestinationAdaptersInput[] memory) + { + DestinationAdaptersInput[] memory destinationAdapters; + return destinationAdapters; + } + + function getChainsToReceive() public pure virtual returns (uint256[] memory) { + return new uint256[](0); + } + + function getChainsToSend() public pure virtual returns (uint256[] memory) { + DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); + uint256[] memory chainsToSend = new uint256[](destinationAdapters.length); + for (uint256 i = 0; i < destinationAdapters.length; i++) { + chainsToSend[i] = destinationAdapters[i].chainId; + } + return chainsToSend; + } + + function getReceiverBridgeAdaptersToRemove() + public + view + virtual + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + // remove old Receiver bridge adapter + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory bridgeAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); + + bridgeAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ + bridgeAdapter: ADAPTER_TO_REMOVE, + chainIds: getChainsToReceive() + }); + + return bridgeAdaptersToRemove; + } + + function getForwarderBridgeAdaptersToRemove() + public + view + virtual + returns (ICrossChainForwarder.BridgeAdapterToDisable[] memory) + { + ICrossChainForwarder.BridgeAdapterToDisable[] + memory forwarderAdaptersToRemove = new ICrossChainForwarder.BridgeAdapterToDisable[](1); + + forwarderAdaptersToRemove[0] = ICrossChainForwarder.BridgeAdapterToDisable({ + bridgeAdapter: ADAPTER_TO_REMOVE, + chainIds: getChainsToSend() + }); + + return forwarderAdaptersToRemove; + } + + function getReceiverBridgeAdaptersToAllow() + public + view + virtual + returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory) + { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory bridgeAdapterConfig = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](1); + + bridgeAdapterConfig[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({ + bridgeAdapter: NEW_ADAPTER, + chainIds: getChainsToReceive() + }); + + return bridgeAdapterConfig; + } + + function getForwarderBridgeAdaptersToEnable() + public + view + virtual + returns (ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] memory) + { + DestinationAdaptersInput[] memory destinationAdapters = getDestinationAdapters(); + + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory bridgeAdaptersToEnable = new ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[]( + destinationAdapters.length + ); + + for (uint256 i = 0; i < destinationAdapters.length; i++) { + bridgeAdaptersToEnable[i] = ICrossChainForwarder.ForwarderBridgeAdapterConfigInput({ + currentChainBridgeAdapter: NEW_ADAPTER, + destinationBridgeAdapter: destinationAdapters[i].adapter, + destinationChainId: destinationAdapters[i].chainId + }); + } + + return bridgeAdaptersToEnable; + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseTest.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseTest.sol new file mode 100644 index 000000000..72628a6e5 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/BaseTest.sol @@ -0,0 +1,403 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import 'forge-std/console.sol'; +import 'aave-helpers/ProtocolV3TestBase.sol'; + +import {GovV3Helpers} from 'aave-helpers/GovV3Helpers.sol'; +import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol'; +import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol'; +import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-proxy/TransparentUpgradeableProxy.sol'; +import {ChainIds} from 'aave-helpers/ChainIds.sol'; +import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol'; +import {IBaseAdapter} from 'aave-address-book/common/IBaseAdapter.sol'; + +import {GovernanceV3Ethereum} from 'aave-address-book/GovernanceV3Ethereum.sol'; +import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol'; +import {GovernanceV3Avalanche} from 'aave-address-book/GovernanceV3Avalanche.sol'; + +import {AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol'; +import {BaseAdaptersUpdatePayload} from './BaseAdaptersUpdatePayload.sol'; +import {AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Base_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Metis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol'; + +struct AdapterName { + address adapter; + string name; +} + +struct TrustedRemote { + address adapter; + address expectedRemote; + uint256 remoteChainId; +} + +struct AdapterAllowed { + address adapter; + uint256 chainId; + bool allowed; +} + +struct AdaptersByChain { + address[] adapters; + uint256 chainId; +} + +struct ForwarderAdapters { + ICrossChainForwarder.ChainIdBridgeConfig[] adapters; + uint256 chainId; +} + +interface Payload { + function CROSS_CHAIN_CONTROLLER_IMPLEMENTATION() external returns (address); +} + +abstract contract BaseTest is ProtocolV3TestBase { + address public immutable CROSS_CHAIN_CONTROLLER; + + bytes public payloadCode; + address public payloadAddress; + string public network; + uint256 public blockNumber; + string public adapterName; + + BaseAdaptersUpdatePayload internal ethereumPayload; + BaseAdaptersUpdatePayload internal polygonPayload; + BaseAdaptersUpdatePayload internal arbitrumPayload; + BaseAdaptersUpdatePayload internal basePayload; + BaseAdaptersUpdatePayload internal gnosisPayload; + BaseAdaptersUpdatePayload internal metisPayload; + BaseAdaptersUpdatePayload internal scrollPayload; + BaseAdaptersUpdatePayload internal optimismPayload; + + constructor( + address ccc, + bytes memory _payloadCode, + string memory _network, + uint256 _blockNumber, + string memory _adapterName + ) { + CROSS_CHAIN_CONTROLLER = ccc; + network = _network; + blockNumber = _blockNumber; + payloadCode = _payloadCode; + adapterName = _adapterName; + } + + function setUp() public { + vm.createSelectFork(vm.rpcUrl(network), blockNumber); + payloadAddress = GovV3Helpers.deployDeterministic(payloadCode); + + ethereumPayload = new AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322(); + polygonPayload = new AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322(); + arbitrumPayload = new AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322(); + basePayload = new AaveV3Base_NativeBridgeAdaptersUpdate_20240322(); + gnosisPayload = new AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322(); + metisPayload = new AaveV3Metis_NativeBridgeAdaptersUpdate_20240322(); + optimismPayload = new AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322(); + scrollPayload = new AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322(); + } + + function getPayloadByChainId(uint256 chainId) public view returns (BaseAdaptersUpdatePayload) { + if (chainId == ChainIds.MAINNET) { + return ethereumPayload; + } else if (chainId == ChainIds.POLYGON) { + return polygonPayload; + } else if (chainId == ChainIds.GNOSIS) { + return gnosisPayload; + } else if (chainId == ChainIds.ARBITRUM) { + return arbitrumPayload; + } else if (chainId == ChainIds.OPTIMISM) { + return optimismPayload; + } else if (chainId == ChainIds.METIS) { + return metisPayload; + } else if (chainId == ChainIds.BASE) { + return basePayload; + } else if (chainId == ChainIds.SCROLL) { + return scrollPayload; + } + revert(); + } + + function getTrustedRemoteByChainId(uint256 chainId) public pure returns (address) { + if (chainId == ChainIds.MAINNET) { + return GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER; + } else if (chainId == ChainIds.POLYGON) { + return GovernanceV3Polygon.CROSS_CHAIN_CONTROLLER; + } else if (chainId == ChainIds.AVALANCHE) { + return GovernanceV3Avalanche.CROSS_CHAIN_CONTROLLER; + } + revert(); + } + + function test_trustedRemotes() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < receivers.length; i++) { + for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { + assertEq( + getTrustedRemoteByChainId(receivers[i].chainIds[j]), + IBaseAdapter(receivers[i].bridgeAdapter).getTrustedRemoteByChainId( + receivers[i].chainIds[j] + ) + ); + } + } + } + + function test_correctPathConfiguration() public { + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory destinationConfigs = BaseAdaptersUpdatePayload(payloadAddress) + .getForwarderBridgeAdaptersToEnable(); + + for (uint256 i = 0; i < destinationConfigs.length; i++) { + if (destinationConfigs[i].destinationChainId == block.chainid) { + assertEq( + destinationConfigs[i].currentChainBridgeAdapter, + destinationConfigs[i].destinationBridgeAdapter + ); + } else { + assertEq( + getPayloadByChainId(destinationConfigs[i].destinationChainId).NEW_ADAPTER(), + destinationConfigs[i].destinationBridgeAdapter + ); + } + } + } + + function test_correctAdapterNames() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < receivers.length; i++) { + string memory contractAdapterName = IBaseAdapter(receivers[i].bridgeAdapter).adapterName(); + assertEq(keccak256(abi.encode(contractAdapterName)), keccak256(abi.encode(adapterName))); + } + } + + function test_receiversAreCorrectlySetAfterExecution() public { + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory beforeReceivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < beforeReceivers.length; i++) { + for (uint256 j = 0; j < beforeReceivers[i].chainIds.length; j++) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + beforeReceivers[i].bridgeAdapter, + beforeReceivers[i].chainIds[j] + ), + false + ); + } + } + + executePayload(vm, payloadAddress); + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory receivers = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToAllow(); + + for (uint256 i = 0; i < receivers.length; i++) { + for (uint256 j = 0; j < receivers[i].chainIds.length; j++) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + receivers[i].bridgeAdapter, + receivers[i].chainIds[j] + ), + true + ); + } + } + } + + function test_onlyUpdatedNeededAdapter() public { + uint256[] memory supportedChainsBefore = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getSupportedChains(); + AdaptersByChain[] memory adaptersBefore = _getCurrentReceiverAdaptersByChain(); + + executePayload(vm, payloadAddress); + + uint256[] memory supportedChainsAfter = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getSupportedChains(); + + assertEq(supportedChainsBefore, supportedChainsAfter); + for (uint256 i = 0; i < supportedChainsBefore.length; i++) { + assertEq(supportedChainsAfter[i], supportedChainsBefore[i]); + } + + ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] + memory adaptersToRemove = BaseAdaptersUpdatePayload(payloadAddress) + .getReceiverBridgeAdaptersToRemove(); + + for (uint256 i = 0; i < adaptersBefore.length; i++) { + for (uint256 j = 0; j < adaptersToRemove.length; j++) { + for (uint256 x = 0; x < adaptersToRemove[j].chainIds.length; x++) { + if (adaptersToRemove[j].chainIds[x] == adaptersBefore[i].chainId) { + for (uint256 k = 0; k < adaptersBefore[i].adapters.length; k++) { + if (adaptersBefore[i].adapters[k] == adaptersToRemove[j].bridgeAdapter) { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + adaptersToRemove[j].bridgeAdapter, + adaptersBefore[i].chainId + ), + false + ); + } else { + assertEq( + ICrossChainReceiver(CROSS_CHAIN_CONTROLLER).isReceiverBridgeAdapterAllowed( + adaptersBefore[i].adapters[k], + adaptersBefore[i].chainId + ), + true + ); + } + } + } + } + } + } + } + + function test_forwarderAdaptersAreSet() public { + executePayload(vm, payloadAddress); + + ICrossChainForwarder.ForwarderBridgeAdapterConfigInput[] + memory forwarders = BaseAdaptersUpdatePayload(payloadAddress) + .getForwarderBridgeAdaptersToEnable(); + + for (uint256 i = 0; i < forwarders.length; i++) { + ICrossChainForwarder.ChainIdBridgeConfig[] + memory forwardersBridgeAdaptersByChain = ICrossChainForwarder(CROSS_CHAIN_CONTROLLER) + .getForwarderBridgeAdaptersByChain(forwarders[i].destinationChainId); + bool newAdapterFound; + for (uint256 j = 0; j < forwardersBridgeAdaptersByChain.length; j++) { + if ( + forwardersBridgeAdaptersByChain[j].destinationBridgeAdapter == + forwarders[i].destinationBridgeAdapter && + forwardersBridgeAdaptersByChain[j].currentChainBridgeAdapter == + forwarders[i].currentChainBridgeAdapter + ) { + newAdapterFound = true; + } + } + assertEq(newAdapterFound, true); + } + } + + function test_onlyChangedNeededForwarders() public { + ForwarderAdapters[] + memory forwardersBridgeAdaptersByChainBefore = _getCurrentForwarderAdaptersByChain(); + + ICrossChainForwarder.BridgeAdapterToDisable[] + memory adaptersToRemove = BaseAdaptersUpdatePayload(payloadAddress) + .getForwarderBridgeAdaptersToRemove(); + + executePayload(vm, payloadAddress); + + ForwarderAdapters[] + memory forwardersBridgeAdaptersByChainAfter = _getCurrentForwarderAdaptersByChain(); + + assertEq( + forwardersBridgeAdaptersByChainAfter.length, + forwardersBridgeAdaptersByChainBefore.length + ); + + for (uint256 l = 0; l < forwardersBridgeAdaptersByChainBefore.length; l++) { + for (uint256 j = 0; j < forwardersBridgeAdaptersByChainAfter.length; j++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].chainId == + forwardersBridgeAdaptersByChainAfter[j].chainId + ) { + for (uint256 i = 0; i < forwardersBridgeAdaptersByChainBefore[l].adapters.length; i++) { + bool forwarderFound; + for (uint256 m = 0; m < forwardersBridgeAdaptersByChainAfter[j].adapters.length; m++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].adapters[i].destinationBridgeAdapter == + forwardersBridgeAdaptersByChainAfter[j].adapters[m].destinationBridgeAdapter && + forwardersBridgeAdaptersByChainBefore[l].adapters[i].currentChainBridgeAdapter == + forwardersBridgeAdaptersByChainAfter[j].adapters[m].currentChainBridgeAdapter + ) { + forwarderFound = true; + break; + } + } + if (!forwarderFound) { + bool isAdapterToBeRemoved; + for (uint256 k = 0; k < adaptersToRemove.length; k++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].adapters[i].currentChainBridgeAdapter == + adaptersToRemove[k].bridgeAdapter + ) { + for (uint256 n = 0; n < adaptersToRemove[k].chainIds.length; n++) { + if ( + forwardersBridgeAdaptersByChainBefore[l].chainId == + adaptersToRemove[k].chainIds[n] + ) { + isAdapterToBeRemoved = true; + break; + } + } + } + } + assertEq(isAdapterToBeRemoved, true); + } + } + } + } + } + } + + function _getCurrentForwarderAdaptersByChain() + internal + view + returns (ForwarderAdapters[] memory) + { + uint256[] memory supportedChains = new uint256[](10); + supportedChains[0] = ChainIds.POLYGON; + supportedChains[1] = ChainIds.AVALANCHE; + supportedChains[2] = ChainIds.BNB; + supportedChains[3] = ChainIds.GNOSIS; + supportedChains[4] = ChainIds.ARBITRUM; + supportedChains[5] = ChainIds.OPTIMISM; + supportedChains[6] = ChainIds.METIS; + supportedChains[7] = ChainIds.BASE; + supportedChains[8] = ChainIds.SCROLL; + supportedChains[9] = ChainIds.MAINNET; + + ForwarderAdapters[] memory forwarderAdapters = new ForwarderAdapters[](supportedChains.length); + + for (uint256 i = 0; i < supportedChains.length; i++) { + ICrossChainForwarder.ChainIdBridgeConfig[] memory forwarders = ICrossChainForwarder( + CROSS_CHAIN_CONTROLLER + ).getForwarderBridgeAdaptersByChain(supportedChains[i]); + + forwarderAdapters[i] = ForwarderAdapters({adapters: forwarders, chainId: supportedChains[i]}); + } + return forwarderAdapters; + } + + function _getCurrentReceiverAdaptersByChain() internal view returns (AdaptersByChain[] memory) { + uint256[] memory supportedChains = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getSupportedChains(); + + AdaptersByChain[] memory receiverAdapters = new AdaptersByChain[](supportedChains.length); + + for (uint256 i = 0; i < supportedChains.length; i++) { + address[] memory receivers = ICrossChainReceiver(CROSS_CHAIN_CONTROLLER) + .getReceiverBridgeAdaptersByChain(supportedChains[i]); + + receiverAdapters[i] = AdaptersByChain({adapters: receivers, chainId: supportedChains[i]}); + } + + return receiverAdapters; + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md b/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md new file mode 100644 index 000000000..70099978a --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md @@ -0,0 +1,41 @@ +--- +title: "Native bridge adapters update" +author: "BGD Labs @bgdlabs" +discussions: "https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26" +--- + +## Simple Summary + +This proposal updates the Native bridge adapters used on a.DI, to add extra naming metadata and make the gas limit configurations more granular. + +## Motivation + +For the past month with a.DI in production, we have noticed small improvements due to the specific mechanics of each bridge provider. Additionally, as we improve the off-chain systems (e.g. monitoring) surrounding a.DI, sometimes it is simply better to add features to the smart contracts to facilitate this off-chain infrastructure. + +## Specification + +Updates the Native bridge adapters used to connect between networks to add Adapter Name to the contracts and provider specific gasLimit configuration + +| Network | Polygon Native | Gnosis Native | Metis Native | Arbitrum Native | Optimism Native | Base Native | Scroll Native | Same Chain | +| -------- | ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | +| Ethereum | [0x1562F1b2487F892BBA8Ef325aF054Fd157510a71](https://etherscan.io/address/0x1562F1b2487F892BBA8Ef325aF054Fd157510a71) | [0x7238d75fD75bb936E83b75854c653F104Ce9c9d8](https://etherscan.io/address/0x7238d75fD75bb936E83b75854c653F104Ce9c9d8) | [0x6B3Dc800E7c813Db3fe8D0F30fDCaE636935dC14](https://etherscan.io/address/0x6B3Dc800E7c813Db3fe8D0F30fDCaE636935dC14) | [0x88d6D01e08d3e64513b15fD46528dBbA7d755883](https://etherscan.io/address/0x88d6D01e08d3e64513b15fD46528dBbA7d755883) | [0x0e24524778fdc67f53eEf144b8cbf50261E930B3](https://etherscan.io/address/0x0e24524778fdc67f53eEf144b8cbf50261E930B3) | [0xa5948b0ac79f72966dFFC5C13E44f6dfDD3D58A0](https://etherscan.io/address/0xa5948b0ac79f72966dFFC5C13E44f6dfDD3D58A0) | [0xA4dC3F123e1c601A19B3DC8382BB9311F678cafA](https://etherscan.io/address/0xA4dC3F123e1c601A19B3DC8382BB9311F678cafA) | [0x6cfbd2aA4691fc18B9C209bDd43DC3943C228FCf](https://etherscan.io/address/0x6cfbd2aA4691fc18B9C209bDd43DC3943C228FCf) | +| Polygon | [0x853649f897383f89d8441346Cf26a9ed02720B02](https://polygonscan.com/address/0x853649f897383f89d8441346Cf26a9ed02720B02) | - | - | - | - | - | - | - | +| Gnosis | | [0x3C06dce358add17aAf230f2234bCCC4afd50d090](https://gnosisscan.io/address/0x3C06dce358add17aAf230f2234bCCC4afd50d090) | - | - | - | - | - | - | +| Metis | | - | [0xf41193E25408F652AF878c47E4401A01B5E4B682](https://andromeda-explorer.metis.io/address/0xf41193E25408F652AF878c47E4401A01B5E4B682) | - | - | - | - | - | +| Arbitrum | | - | - | [0xc8a2ADC4261c6b669CdFf69E717E77C9cFeB420d](https://arbiscan.io/address/0xc8a2ADC4261c6b669CdFf69E717E77C9cFeB420d) | - | - | - | - | +| Optimism | | - | - | - | [0xa5cc218513305221201f196760E9e64e9D49d98A](https://optimistic.etherscan.io/address/0xa5cc218513305221201f196760E9e64e9D49d98A) | - | - | - | +| Base | | - | - | - | - | [0x7120b1f8e5b73c0C0DC99C6e52Fe4937E7EA11e0](https://basescan.org/address/0x7120b1f8e5b73c0C0DC99C6e52Fe4937E7EA11e0) | - | - | +| Scroll | | - | - | - | - | - | [0x3C06dce358add17aAf230f2234bCCC4afd50d090](https://scrollscan.com/address/0x3C06dce358add17aAf230f2234bCCC4afd50d090) | - | + +Code diffs for the different networks can be checked on a.DI diff repository for [revision 2](https://github.com/bgd-labs/aDI-diffs/tree/main/diffs/rev2). +Adapter diffs: [Native Adapters](https://github.com/bgd-labs/aDI-diffs/tree/main/diffs/rev2/native), [BaseAdapter](https://github.com/bgd-labs/aDI-diffs/tree/main/diffs/rev2/base_adapter), [IBaseAdapter](https://github.com/bgd-labs/aDI-diffs/tree/main/diffs/rev2/i_base_adapter) + +## References + +- Implementation: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol) +- Tests: [AaveV3Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Polygon](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Optimism](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Arbitrum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Metis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Base](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Base_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Gnosis](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.t.sol), [AaveV3Scroll](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20240322_Multi_NativeBridgeAdaptersUpdate/AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.t.sol) +- [Discussion](https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/26) + +## Copyright + +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol b/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol new file mode 100644 index 000000000..61a8b203d --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol @@ -0,0 +1,268 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.0; + +import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol'; +import {EthereumScript, PolygonScript, OptimismScript, ArbitrumScript, MetisScript, BaseScript, GnosisScript, ScrollScript} from 'aave-helpers/ScriptUtils.sol'; +import {AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Metis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Metis_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Base_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Base_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322.sol'; +import {AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322} from './AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322.sol'; + +/** + * @dev Deploy Ethereum + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployEthereum chain=mainnet + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/1/run-latest.json + */ +contract DeployEthereum is EthereumScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Polygon + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployPolygon chain=polygon + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/137/run-latest.json + */ +contract DeployPolygon is PolygonScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Optimism + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployOptimism chain=optimism + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/10/run-latest.json + */ +contract DeployOptimism is OptimismScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Arbitrum + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployArbitrum chain=arbitrum + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/42161/run-latest.json + */ +contract DeployArbitrum is ArbitrumScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Metis + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployMetis chain=metis + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/1088/run-latest.json + */ +contract DeployMetis is MetisScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Metis_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Base + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployBase chain=base + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/8453/run-latest.json + */ +contract DeployBase is BaseScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Base_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Gnosis + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployGnosis chain=gnosis + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/100/run-latest.json + */ +contract DeployGnosis is GnosisScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Deploy Scroll + * deploy-command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:DeployScroll chain=scroll + * verify-command: npx catapulta-verify -b broadcast/NativeBridgeAdaptersUpdate_20240322.s.sol/534352/run-latest.json + */ +contract DeployScroll is ScrollScript { + function run() external broadcast { + // deploy payloads + address payload0 = GovV3Helpers.deployDeterministic( + type(AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + + // compose action + IPayloadsControllerCore.ExecutionAction[] + memory actions = new IPayloadsControllerCore.ExecutionAction[](1); + actions[0] = GovV3Helpers.buildAction(payload0); + + // register action at payloadsController + GovV3Helpers.createPayload(actions); + } +} + +/** + * @dev Create Proposal + * command: make deploy-ledger contract=src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate_20240322.s.sol:CreateProposal chain=mainnet + */ +contract CreateProposal is EthereumScript { + function run() external { + // create payloads + PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](8); + + // compose actions for validation + IPayloadsControllerCore.ExecutionAction[] + memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsEthereum[0] = GovV3Helpers.buildAction( + type(AaveV3Ethereum_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsPolygon = new IPayloadsControllerCore.ExecutionAction[](1); + actionsPolygon[0] = GovV3Helpers.buildAction( + type(AaveV3Polygon_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[1] = GovV3Helpers.buildPolygonPayload(vm, actionsPolygon); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsOptimism = new IPayloadsControllerCore.ExecutionAction[](1); + actionsOptimism[0] = GovV3Helpers.buildAction( + type(AaveV3Optimism_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[2] = GovV3Helpers.buildOptimismPayload(vm, actionsOptimism); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsArbitrum = new IPayloadsControllerCore.ExecutionAction[](1); + actionsArbitrum[0] = GovV3Helpers.buildAction( + type(AaveV3Arbitrum_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[3] = GovV3Helpers.buildArbitrumPayload(vm, actionsArbitrum); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsMetis = new IPayloadsControllerCore.ExecutionAction[](1); + actionsMetis[0] = GovV3Helpers.buildAction( + type(AaveV3Metis_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[4] = GovV3Helpers.buildMetisPayload(vm, actionsMetis); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsBase = new IPayloadsControllerCore.ExecutionAction[](1); + actionsBase[0] = GovV3Helpers.buildAction( + type(AaveV3Base_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[5] = GovV3Helpers.buildBasePayload(vm, actionsBase); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsGnosis = new IPayloadsControllerCore.ExecutionAction[](1); + actionsGnosis[0] = GovV3Helpers.buildAction( + type(AaveV3Gnosis_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[6] = GovV3Helpers.buildGnosisPayload(vm, actionsGnosis); + + IPayloadsControllerCore.ExecutionAction[] + memory actionsScroll = new IPayloadsControllerCore.ExecutionAction[](1); + actionsScroll[0] = GovV3Helpers.buildAction( + type(AaveV3Scroll_NativeBridgeAdaptersUpdate_20240322).creationCode + ); + payloads[7] = GovV3Helpers.buildScrollPayload(vm, actionsScroll); + + // create proposal + vm.startBroadcast(); + GovV3Helpers.createProposal( + vm, + payloads, + GovV3Helpers.ipfsHashFile( + vm, + 'src/20240322_Multi_NativeBridgeAdaptersUpdate/NativeBridgeAdaptersUpdate.md' + ) + ); + } +} diff --git a/src/20240322_Multi_NativeBridgeAdaptersUpdate/config.ts b/src/20240322_Multi_NativeBridgeAdaptersUpdate/config.ts new file mode 100644 index 000000000..cda8c9de4 --- /dev/null +++ b/src/20240322_Multi_NativeBridgeAdaptersUpdate/config.ts @@ -0,0 +1,31 @@ +import {ConfigFile} from '../../generator/types'; +export const config: ConfigFile = { + rootOptions: { + author: 'BGD Labs @bgdlabs', + pools: [ + 'AaveV3Ethereum', + 'AaveV3Polygon', + 'AaveV3Optimism', + 'AaveV3Arbitrum', + 'AaveV3Metis', + 'AaveV3Base', + 'AaveV3Gnosis', + 'AaveV3Scroll', + ], + title: 'Native bridge adapters update', + shortName: 'NativeBridgeAdaptersUpdate', + date: '20240322', + discussion: '', + snapshot: '', + }, + poolOptions: { + AaveV3Ethereum: {configs: {OTHERS: {}}, cache: {blockNumber: 19490720}}, + AaveV3Polygon: {configs: {OTHERS: {}}, cache: {blockNumber: 54954005}}, + AaveV3Optimism: {configs: {OTHERS: {}}, cache: {blockNumber: 117759224}}, + AaveV3Arbitrum: {configs: {OTHERS: {}}, cache: {blockNumber: 193049277}}, + AaveV3Metis: {configs: {OTHERS: {}}, cache: {blockNumber: 15632608}}, + AaveV3Base: {configs: {OTHERS: {}}, cache: {blockNumber: 12163947}}, + AaveV3Gnosis: {configs: {OTHERS: {}}, cache: {blockNumber: 33059583}}, + AaveV3Scroll: {configs: {OTHERS: {}}, cache: {blockNumber: 4339218}}, + }, +};