From ef37142af6c671ba3560136d3c91298df0ea5036 Mon Sep 17 00:00:00 2001 From: Kogaroshi <25688223+Kogaroshi@users.noreply.github.com> Date: Mon, 27 Apr 2026 09:46:32 +0100 Subject: [PATCH 1/2] fix : ConfigEngine redeploy for XLayer --- .DS_Store | Bin 0 -> 6148 bytes .gitmodules | 6 +- .../Deploy.s.sol/196/run-1777279791228.json | 64 ++ .../Deploy.s.sol/196/run-1777279876538.json | 64 ++ broadcast/Deploy.s.sol/196/run-latest.json | 64 ++ foundry.lock | 4 +- lib/aave-v3-origin | 1 + lib/aave-v3-origin-private | 1 - remappings.txt | 4 +- script/Deploy.s.sol | 631 +++--------------- test/.DS_Store | Bin 0 -> 6148 bytes test/Arbitrum.t.sol | 17 - test/Avalanche.t.sol | 17 - test/BNB.t.sol | 17 - test/Base.t.sol | 17 - test/Celo.t.sol | 17 - test/Gnosis.t.sol | 17 - test/Ink.t.sol | 26 - test/Linea.t.sol | 21 - test/MainnetCore.t.sol | 24 - test/MainnetEtherFi.t.sol | 21 - test/MainnetLido.t.sol | 21 - test/Mantle.t.sol | 17 - test/MegaEth.t.sol | 17 - test/Optimism.t.sol | 17 - test/Plasma.t.sol | 17 - test/Polygon.t.sol | 17 - test/Scroll.t.sol | 17 - test/Sonic.t.sol | 17 - test/UpgradeTest.t.sol | 259 ------- test/XLayer.t.sol | 17 - test/XLayerConfigEngine.t.sol | 45 ++ 32 files changed, 322 insertions(+), 1172 deletions(-) create mode 100644 .DS_Store create mode 100644 broadcast/Deploy.s.sol/196/run-1777279791228.json create mode 100644 broadcast/Deploy.s.sol/196/run-1777279876538.json create mode 100644 broadcast/Deploy.s.sol/196/run-latest.json create mode 160000 lib/aave-v3-origin delete mode 160000 lib/aave-v3-origin-private create mode 100644 test/.DS_Store delete mode 100644 test/Arbitrum.t.sol delete mode 100644 test/Avalanche.t.sol delete mode 100644 test/BNB.t.sol delete mode 100644 test/Base.t.sol delete mode 100644 test/Celo.t.sol delete mode 100644 test/Gnosis.t.sol delete mode 100644 test/Ink.t.sol delete mode 100644 test/Linea.t.sol delete mode 100644 test/MainnetCore.t.sol delete mode 100644 test/MainnetEtherFi.t.sol delete mode 100644 test/MainnetLido.t.sol delete mode 100644 test/Mantle.t.sol delete mode 100644 test/MegaEth.t.sol delete mode 100644 test/Optimism.t.sol delete mode 100644 test/Plasma.t.sol delete mode 100644 test/Polygon.t.sol delete mode 100644 test/Scroll.t.sol delete mode 100644 test/Sonic.t.sol delete mode 100644 test/UpgradeTest.t.sol delete mode 100644 test/XLayer.t.sol create mode 100644 test/XLayerConfigEngine.t.sol diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..04ce57ab20e4626ee2c8bd9397c1f2f162a1ff53 GIT binary patch literal 6148 zcmeHKPfrs;6rTrGwji=VtB5h#*oz4ywn8w*7;3>NF$O{jf`E0m9myR$(=|%)Ghu4Z4Ucf!Si|nVQNU9;U5q?&{6O z%672B_%lTz;E5xpUtU)|Lw61-1V^vSl9HKlv|&h(!hum^{R2Q!1&Z1&vw zkqe_2M=SQQ=T^7tp?KFB9`LXfH0fGB^lRmYTlHCeC8kf~vcFF&_RvqEi?sIm*tN9R zz?jUjLr!-$q?F0|<~KJZ8n1k3uU71Vs2cJhSm2Q#`<$(=N67SCOn2tkCdVi4BFpm) zF%&J+FhcCeSy^?%&}DU6+S>?Rj|TIs#N(LntoT*V)SC~;X|cNyQZZ$2`io*QSG=DX zSCnCsoHDQ$WD-jwwP@{+tFZ^%3Hk$fg! zp$BZZ3}Y|}w_qCX!5ln-Dr|udp_-s8`N)@4KhY4Ob@Y*U%OMLmtD`T8PXY~|zN_FE3>gLt1OF!j;(Tzh2`p-CE0jkEDtQG!Orcu}+Tt!DavY6CjctWEf&wZPQKf>u zVt`6VzoX-d8ruq0Istw80R3dpHx!Uh$N3!@PN1mJXv2VE;710;zdwpC>i-?w!@s%z z%OIl+1BQWrlL1K0mS;=2HeFjgRw-(&gY5}6AtJ7=P^O^Lg&_J&(_)9Qw%}S#zJObckVX3 zxnzoL7J&7Khf81wU`unx(cKz;-ED=F7BMo7_jtuK4tPSx)z9Fy=eT0sfX79BhZjs3 zZ^r3<7^i`G{*XPbdkb(SNC7Dz1*Cu!kOIF|zuqzoXq>QldVlC7N;{_ zA{|zf<)wfWSSoOu+nx9SYuY#S|FTFsDIf*@l>)Ze-|l<9QtPd&m-Aj*Xm_*^FgMca mq7{>)6?5aQ_~J`m@inj4#&dF%Galt+{Rp@&f)w}*1>OPgE*wh$ literal 0 HcmV?d00001 diff --git a/test/Arbitrum.t.sol b/test/Arbitrum.t.sol deleted file mode 100644 index 429b618a..00000000 --- a/test/Arbitrum.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract ArbitrumTest is UpgradeTest("arbitrum", 447500937) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployArbitrum(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.ARBITRUM; - } -} diff --git a/test/Avalanche.t.sol b/test/Avalanche.t.sol deleted file mode 100644 index 73fb72ff..00000000 --- a/test/Avalanche.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract AvalancheTest is UpgradeTest("avalanche", 81696272) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployAvalanche(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.AVALANCHE; - } -} diff --git a/test/BNB.t.sol b/test/BNB.t.sol deleted file mode 100644 index 5210ee08..00000000 --- a/test/BNB.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract BNBTest is UpgradeTest("bnb", 89682844) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployBNB(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.BNB; - } -} diff --git a/test/Base.t.sol b/test/Base.t.sol deleted file mode 100644 index 1ee3d41e..00000000 --- a/test/Base.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract BaseTest is UpgradeTest("base", 44057793) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployBase(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.BASE; - } -} diff --git a/test/Celo.t.sol b/test/Celo.t.sol deleted file mode 100644 index 8cd25595..00000000 --- a/test/Celo.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract CeloTest is UpgradeTest("celo", 63049772) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployCelo(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.CELO; - } -} diff --git a/test/Gnosis.t.sol b/test/Gnosis.t.sol deleted file mode 100644 index 172d6691..00000000 --- a/test/Gnosis.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract GnosisTest is UpgradeTest("gnosis", 45422377) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployGnosis(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.GNOSIS; - } -} diff --git a/test/Ink.t.sol b/test/Ink.t.sol deleted file mode 100644 index 6199ab6f..00000000 --- a/test/Ink.t.sol +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "forge-std/Test.sol"; -import {AaveV3InkWhitelabel, AaveV3InkWhitelabelAssets} from "aave-address-book/AaveV3InkWhitelabel.sol"; -import {GovV3Helpers} from "aave-helpers/src/GovV3Helpers.sol"; -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract InkTest is UpgradeTest("ink", 41446726) { - function executePayload(Vm vm, address payload) internal virtual override { - GovV3Helpers.executePayload( - vm, payload, address(GovV3Helpers.getPayloadsController(AaveV3InkWhitelabel.POOL, block.chainid)) - ); - } - - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployInk(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.INK; - } -} diff --git a/test/Linea.t.sol b/test/Linea.t.sol deleted file mode 100644 index 7503fcd3..00000000 --- a/test/Linea.t.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -/** - * @dev Test contract for Linea network needs to be run via: - * FORGE_PROFIE=linea forge test --mc LineaTest - */ -contract LineaTest is UpgradeTest("linea", 29989226) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployLinea(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.LINEA; - } -} diff --git a/test/MainnetCore.t.sol b/test/MainnetCore.t.sol deleted file mode 100644 index 6263ea0a..00000000 --- a/test/MainnetCore.t.sol +++ /dev/null @@ -1,24 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {AaveV3Ethereum, AaveV3EthereumAssets} from "aave-address-book/AaveV3Ethereum.sol"; -import {IATokenWithDelegation} from "aave-v3-origin/contracts/interfaces/IATokenWithDelegation.sol"; -import { - VariableDebtTokenMainnetInstanceGHO -} from "aave-v3-origin/contracts/instances/VariableDebtTokenMainnetInstanceGHO.sol"; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {Deployments} from "../src/Deployments.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; - -contract MainnetCoreTest is UpgradeTest("mainnet", 24776779) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployMainnetCore(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.MAINNET_CORE; - } -} diff --git a/test/MainnetEtherFi.t.sol b/test/MainnetEtherFi.t.sol deleted file mode 100644 index b407f8b2..00000000 --- a/test/MainnetEtherFi.t.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract MainnetEtherFiTest is UpgradeTest("mainnet", 24776779) { - constructor() { - NETWORK_SUB_NAME = "EtherFi"; - } - - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployMainnetEtherfi(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.MAINNET_ETHERFI; - } -} diff --git a/test/MainnetLido.t.sol b/test/MainnetLido.t.sol deleted file mode 100644 index 63ad7bb6..00000000 --- a/test/MainnetLido.t.sol +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract MainnetLidoTest is UpgradeTest("mainnet", 24776779) { - constructor() { - NETWORK_SUB_NAME = "Lido"; - } - - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployMainnetLido(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.MAINNET_LIDO; - } -} diff --git a/test/Mantle.t.sol b/test/Mantle.t.sol deleted file mode 100644 index 69033dd3..00000000 --- a/test/Mantle.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract MantleTest is UpgradeTest("mantle", 93410023) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployMantle(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.MANTLE; - } -} diff --git a/test/MegaEth.t.sol b/test/MegaEth.t.sol deleted file mode 100644 index 723cb1b8..00000000 --- a/test/MegaEth.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract MegaEthTest is UpgradeTest("megaeth", 12153362) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployMegaEth(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.MEGAETH; - } -} diff --git a/test/Optimism.t.sol b/test/Optimism.t.sol deleted file mode 100644 index 1ce18618..00000000 --- a/test/Optimism.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract OptimismTest is UpgradeTest("optimism", 149653628) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployOptimism(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.OPTIMISM; - } -} diff --git a/test/Plasma.t.sol b/test/Plasma.t.sol deleted file mode 100644 index 3f867d5a..00000000 --- a/test/Plasma.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract PlasmaTest is UpgradeTest("plasma", 18018522) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployPlasma(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.PLASMA; - } -} diff --git a/test/Polygon.t.sol b/test/Polygon.t.sol deleted file mode 100644 index 670d6fe8..00000000 --- a/test/Polygon.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract PolygonTest is UpgradeTest("polygon", 84892788) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployPolygon(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.POLYGON; - } -} diff --git a/test/Scroll.t.sol b/test/Scroll.t.sol deleted file mode 100644 index 50440265..00000000 --- a/test/Scroll.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract ScrollTest is UpgradeTest("scroll", 32844339) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployScroll(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.SCROLL; - } -} diff --git a/test/Sonic.t.sol b/test/Sonic.t.sol deleted file mode 100644 index 08bb64b5..00000000 --- a/test/Sonic.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract SonicTest is UpgradeTest("sonic", 66372534) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deploySonic(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.SONIC; - } -} diff --git a/test/UpgradeTest.t.sol b/test/UpgradeTest.t.sol deleted file mode 100644 index 69adfd1b..00000000 --- a/test/UpgradeTest.t.sol +++ /dev/null @@ -1,259 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import "forge-std/Test.sol"; - -import { - ProtocolV3TestBase, - IPool, - IPoolDataProvider, - IPoolAddressesProvider, - IERC20, - DataTypes, - SafeERC20, - ReserveConfiguration -} from "aave-helpers/src/ProtocolV3TestBase.sol"; -import {EModeConfiguration} from "aave-v3-origin/contracts/protocol/libraries/configuration/EModeConfiguration.sol"; -import { - ReserveConfiguration as ReserveConfiguration36, - DataTypes as DataTypes36 -} from "../src/3.6/ReserveConfiguration.sol"; -import {IPool as IPool36} from "../src/3.6/IPool.sol"; -import {IPoolAddressesProvider as IPoolAddressesProvider36} from "../src/3.6/IPoolAddressesProvider.sol"; -import {UpgradePayload} from "../src/UpgradePayload.sol"; - -interface NewPool { - function RESERVE_INTEREST_RATE_STRATEGY() external returns (address); -} - -interface MockExecute { - function execute() external; -} - -contract MockFlashReceiver { - using SafeERC20 for IERC20; - - function executeOperation( - address[] calldata assets, - uint256[] calldata amounts, - uint256[] calldata premiums, - address initiator, /* initiator */ - bytes calldata /* params */ - ) external returns (bool) { - for (uint256 i = 0; i < assets.length; i++) { - IERC20(assets[i]).forceApprove(msg.sender, amounts[i] + premiums[i]); - } - - MockExecute(initiator).execute(); - - return true; - } -} - -abstract contract UpgradeTest is ProtocolV3TestBase { - using SafeERC20 for IERC20; - using ReserveConfiguration for DataTypes.ReserveConfigurationMap; - using ReserveConfiguration36 for DataTypes36.ReserveConfigurationMap; - - string public NETWORK; - string public NETWORK_SUB_NAME; - uint256 public immutable BLOCK_NUMBER; - address immutable FLASH_RECEIVER; - - IPool public POOL; - IPoolAddressesProvider public ADDRESSES_PROVIDER; - - constructor(string memory network, uint256 blocknumber) { - NETWORK = network; - BLOCK_NUMBER = blocknumber; - FLASH_RECEIVER = address(new MockFlashReceiver()); - } - - function setUp() public virtual { - vm.createSelectFork(vm.rpcUrl(NETWORK), BLOCK_NUMBER); - } - - function test_execution() public virtual { - executePayload(vm, _getTestPayload()); - } - - // function to be called from the flashloan - function execute() external { - executePayload(vm, _getTestPayload()); - } - - function test_diff() external virtual { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - - defaultTest( - string(abi.encodePacked(vm.toString(block.chainid), "_", vm.toString(address(pool)))), pool, address(_payload) - ); - } - - /** - * On the upgrade we assume all interest rates are already the same. - * This test simply validates that assumption. - */ - function test_assumption_interestRates() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - address[] memory reserves = pool.getReservesList(); - address[] memory irs = new address[](reserves.length); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes.ReserveDataLegacy memory reserveData = pool.getReserveData(reserves[i]); - irs[i] = reserveData.interestRateStrategyAddress; - } - - executePayload(vm, address(_payload)); - - address commonIr = NewPool(address(pool)).RESERVE_INTEREST_RATE_STRATEGY(); - for (uint256 i = 0; i < reserves.length; i++) { - assertEq(irs[i], commonIr); - } - } - - function test_assumption_noSiloed() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - address[] memory reserves = pool.getReservesList(); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes36.ReserveDataLegacy memory reserveData = IPool36(address(pool)).getReserveData(reserves[i]); - assertEq(reserveData.configuration.getSiloedBorrowing(), false); - } - } - - function test_assumption_noDebtCeiling() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - executePayload(vm, address(_payload)); - - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - address[] memory reserves = pool.getReservesList(); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes36.ReserveDataLegacy memory reserveData = IPool36(address(pool)).getReserveData(reserves[i]); - assertEq(reserveData.configuration.getDebtCeiling(), 0); - } - } - - function test_assumption_noBorrowableInIsolation() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - executePayload(vm, address(_payload)); - - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - address[] memory reserves = pool.getReservesList(); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes36.ReserveDataLegacy memory reserveData = IPool36(address(pool)).getReserveData(reserves[i]); - assertEq(reserveData.configuration.getBorrowableInIsolation(), false); - } - } - - function test_assumption_isolatedAssetsAreLtv0() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - IPoolAddressesProvider addressesProvider = IPoolAddressesProvider(address(_payload.POOL_ADDRESSES_PROVIDER())); - IPool pool = IPool(addressesProvider.getPool()); - address[] memory reserves = pool.getReservesList(); - for (uint256 i = 0; i < reserves.length; i++) { - DataTypes36.ReserveDataLegacy memory reserveData = IPool36(address(pool)).getReserveData(reserves[i]); - if (reserveData.configuration.getDebtCeiling() != 0) { - assertEq(reserveData.configuration.getLtv(), 0); - } - } - } - - function test_assumption_noSequencerUptimeSentinel() external { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - executePayload(vm, address(_payload)); - - IPoolAddressesProvider36 addressesProvider36 = - IPoolAddressesProvider36(address(_payload.POOL_ADDRESSES_PROVIDER())); - assertEq(addressesProvider36.getPriceOracleSentinel(), address(0)); - } - - function test_upgrade() public virtual { - UpgradePayload _payload = UpgradePayload(_getTestPayload()); - - executePayload(vm, address(_payload)); - } - - function test_gas() external { - executePayload(vm, address(_getPayload())); - vm.snapshotGasLastCall("Execution", string.concat(NETWORK, NETWORK_SUB_NAME)); - } - - function test_flashloan_attack() public { - UpgradePayload payloadForFlashloan = UpgradePayload(_getTestPayload()); - - POOL = payloadForFlashloan.POOL(); - ADDRESSES_PROVIDER = payloadForFlashloan.POOL_ADDRESSES_PROVIDER(); - - address[] memory reserves = POOL.getReservesList(); - uint256[] memory oldVirtualUnderlyingBalances = new uint256[](reserves.length); - - uint256 length; - address[] memory filteredReserves = new address[](reserves.length); - uint256[] memory amounts = new uint256[](reserves.length); - uint256[] memory interestRateModes = new uint256[](reserves.length); - for (uint256 i = 0; i < reserves.length; i++) { - oldVirtualUnderlyingBalances[i] = POOL.getVirtualUnderlyingBalance(reserves[i]); - console.log(oldVirtualUnderlyingBalances[i]); - - DataTypes.ReserveConfigurationMap memory configuration = POOL.getConfiguration(reserves[i]); - - if (configuration.getPaused() || !configuration.getActive() || !configuration.getFlashLoanEnabled()) { - continue; - } - - filteredReserves[length] = reserves[i]; - // The amount flashed does not really matter. - // We're limiting it in the test because we know that the vBalanceDelta can sometimes be slightly negative, - // and for some assets, `deal` does not work. Therefore, we fall back to user transfers, which for most assets, - // do not provide enough funds to 'deal' the entire available VirtualUnderlyingBalance. - amounts[length] = oldVirtualUnderlyingBalances[i] / 2; - interestRateModes[length] = 0; - - ++length; - } - assembly { - mstore(filteredReserves, length) - mstore(amounts, length) - mstore(interestRateModes, length) - } - - // Using bytes("") to expect a revert without a reason string (an "empty" error, like EvmError: Revert). - vm.expectRevert(bytes("")); - POOL.flashLoan({ - receiverAddress: FLASH_RECEIVER, - assets: filteredReserves, - amounts: amounts, - interestRateModes: interestRateModes, - onBehalfOf: address(this), - params: "", - referralCode: 0 - }); - - for (uint256 i = 0; i < reserves.length; i++) { - assertEq(POOL.getVirtualUnderlyingBalance(reserves[i]), oldVirtualUnderlyingBalances[i]); - } - } - - function _getTestPayload() internal returns (address) { - address deployed = _getDeployedPayload(); - if (deployed == address(0)) return _getPayload(); - return deployed; - } - - function _getPayload() internal virtual returns (address); - - function _getDeployedPayload() internal virtual returns (address); -} diff --git a/test/XLayer.t.sol b/test/XLayer.t.sol deleted file mode 100644 index a58c9ee1..00000000 --- a/test/XLayer.t.sol +++ /dev/null @@ -1,17 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {DeploymentLibrary} from "../script/Deploy.s.sol"; - -import {UpgradeTest} from "./UpgradeTest.t.sol"; -import {Deployments} from "../src/Deployments.sol"; - -contract XLayerTest is UpgradeTest("xLayer", 56177297) { - function _getPayload() internal virtual override returns (address) { - return DeploymentLibrary._deployXLayer(); - } - - function _getDeployedPayload() internal virtual override returns (address) { - return Deployments.XLAYER; - } -} diff --git a/test/XLayerConfigEngine.t.sol b/test/XLayerConfigEngine.t.sol new file mode 100644 index 00000000..0d06c99d --- /dev/null +++ b/test/XLayerConfigEngine.t.sol @@ -0,0 +1,45 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {Test} from "forge-std/Test.sol"; +import { + IAaveV3ConfigEngine +} from "aave-v3-origin/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol"; + +import {DeploymentLibrary} from "../script/Deploy.s.sol"; + +contract XLayerConfigEngineParityTest is Test { + address constant LIVE_ENGINE = 0x2eb21BCE2C5D59a67C648BfD2e700AdDB752DD7B; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl("xLayer")); + } + + function test_newEngineMatchesLive() public { + IAaveV3ConfigEngine live = IAaveV3ConfigEngine(LIVE_ENGINE); + IAaveV3ConfigEngine fresh = IAaveV3ConfigEngine( + DeploymentLibrary._deployXLayer() + ); + + assertEq(address(fresh.POOL()), address(live.POOL()), "POOL"); + assertEq( + address(fresh.POOL_CONFIGURATOR()), + address(live.POOL_CONFIGURATOR()), + "POOL_CONFIGURATOR" + ); + assertEq(address(fresh.ORACLE()), address(live.ORACLE()), "ORACLE"); + assertEq( + fresh.DEFAULT_INTEREST_RATE_STRATEGY(), + live.DEFAULT_INTEREST_RATE_STRATEGY(), + "DEFAULT_INTEREST_RATE_STRATEGY" + ); + assertEq( + fresh.REWARDS_CONTROLLER(), + live.REWARDS_CONTROLLER(), + "REWARDS_CONTROLLER" + ); + assertEq(fresh.COLLECTOR(), live.COLLECTOR(), "COLLECTOR"); + assertEq(fresh.ATOKEN_IMPL(), live.ATOKEN_IMPL(), "ATOKEN_IMPL"); + assertEq(fresh.VTOKEN_IMPL(), live.VTOKEN_IMPL(), "VTOKEN_IMPL"); + } +} From 09355dd1e388af04ea8ee48668144b1868a469d9 Mon Sep 17 00:00:00 2001 From: Kogaroshi <25688223+Kogaroshi@users.noreply.github.com> Date: Mon, 27 Apr 2026 10:14:17 +0100 Subject: [PATCH 2/2] test : add test post-deployed matching --- test/fork/XLayerConfigEngine.t.sol | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 test/fork/XLayerConfigEngine.t.sol diff --git a/test/fork/XLayerConfigEngine.t.sol b/test/fork/XLayerConfigEngine.t.sol new file mode 100644 index 00000000..e330afcf --- /dev/null +++ b/test/fork/XLayerConfigEngine.t.sol @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.0; + +import {Test} from "forge-std/Test.sol"; +import { + IAaveV3ConfigEngine +} from "aave-v3-origin/contracts/extensions/v3-config-engine/IAaveV3ConfigEngine.sol"; + +contract XLayerConfigEngineParityTest is Test { + address constant OLD_ENGINE = 0x2eb21BCE2C5D59a67C648BfD2e700AdDB752DD7B; + address constant NEW_ENGINE = 0x29A9b0a13c81d59f13BA0f39DBDCAA1AB2adc95F; + + function setUp() public { + vm.createSelectFork(vm.rpcUrl("xLayer")); + } + + function test_newEngineMatchesLive() public view { + IAaveV3ConfigEngine oldEngine = IAaveV3ConfigEngine(OLD_ENGINE); + IAaveV3ConfigEngine newEngine = IAaveV3ConfigEngine(NEW_ENGINE); + + assertEq(address(newEngine.POOL()), address(oldEngine.POOL()), "POOL"); + assertEq( + address(newEngine.POOL_CONFIGURATOR()), + address(oldEngine.POOL_CONFIGURATOR()), + "POOL_CONFIGURATOR" + ); + assertEq(address(newEngine.ORACLE()), address(oldEngine.ORACLE()), "ORACLE"); + assertEq( + newEngine.DEFAULT_INTEREST_RATE_STRATEGY(), + oldEngine.DEFAULT_INTEREST_RATE_STRATEGY(), + "DEFAULT_INTEREST_RATE_STRATEGY" + ); + assertEq( + newEngine.REWARDS_CONTROLLER(), + oldEngine.REWARDS_CONTROLLER(), + "REWARDS_CONTROLLER" + ); + assertEq(newEngine.COLLECTOR(), oldEngine.COLLECTOR(), "COLLECTOR"); + assertEq(newEngine.ATOKEN_IMPL(), oldEngine.ATOKEN_IMPL(), "ATOKEN_IMPL"); + assertEq(newEngine.VTOKEN_IMPL(), oldEngine.VTOKEN_IMPL(), "VTOKEN_IMPL"); + } +}