From cef08a237d35d07be4217c2a055b00fb522505e3 Mon Sep 17 00:00:00 2001 From: Andrei Kozlov Date: Wed, 14 Aug 2024 10:31:52 +0300 Subject: [PATCH] rename merger and 4626 contracts --- .../procedures/AaveV3HelpersProcedureTwo.sol | 4 +-- ...le.sol => ERC4626StataTokenUpgradable.sol} | 30 +++++++++++-------- .../{StataMerger.sol => StataTokenV2.sol} | 16 +++++----- .../static-a-token/StaticATokenFactory.sol | 4 +-- .../{IStataMerger.sol => IStataTokenV2.sol} | 4 +-- .../static-a-token/Stata4626LM.t.sol | 6 ++-- .../static-a-token/StataOracle.t.sol | 6 ++-- tests/periphery/static-a-token/TestBase.sol | 6 ++-- 8 files changed, 40 insertions(+), 36 deletions(-) rename src/periphery/contracts/static-a-token/{Stata4626Upgradable.sol => ERC4626StataTokenUpgradable.sol} (90%) rename src/periphery/contracts/static-a-token/{StataMerger.sol => StataTokenV2.sol} (85%) rename src/periphery/contracts/static-a-token/interfaces/{IStataMerger.sol => IStataTokenV2.sol} (87%) diff --git a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol index 67539b95..01b456e1 100644 --- a/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol +++ b/src/deployments/contracts/procedures/AaveV3HelpersProcedureTwo.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import '../../interfaces/IMarketReportTypes.sol'; import {TransparentProxyFactory, ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; -import {StataMerger} from 'aave-v3-periphery/contracts/static-a-token/StataMerger.sol'; +import {StataTokenV2} from 'aave-v3-periphery/contracts/static-a-token/StataTokenV2.sol'; import {StaticATokenFactory} from 'aave-v3-periphery/contracts/static-a-token/StaticATokenFactory.sol'; import {IErrors} from '../../interfaces/IErrors.sol'; @@ -17,7 +17,7 @@ contract AaveV3HelpersProcedureTwo is IErrors { staticATokenReport.transparentProxyFactory = address(new TransparentProxyFactory()); staticATokenReport.staticATokenImplementation = address( - new StataMerger(IPool(pool), IRewardsController(rewardsController)) + new StataTokenV2(IPool(pool), IRewardsController(rewardsController)) ); staticATokenReport.staticATokenFactoryImplementation = address( new StaticATokenFactory( diff --git a/src/periphery/contracts/static-a-token/Stata4626Upgradable.sol b/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradable.sol similarity index 90% rename from src/periphery/contracts/static-a-token/Stata4626Upgradable.sol rename to src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradable.sol index b6d1300a..d242f97d 100644 --- a/src/periphery/contracts/static-a-token/Stata4626Upgradable.sol +++ b/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradable.sol @@ -13,26 +13,30 @@ import {IAToken} from './interfaces/IAToken.sol'; import {IStata4626} from './interfaces/IStata4626.sol'; /** - * @title Stata4626Upgradable + * @title ERC4626StataTokenUpgradable.sol * @notice Wrapper smart contract that allows to deposit tokens on the Aave protocol and receive * a token which balance doesn't increase automatically, but uses an ever-increasing exchange rate. * @author BGD labs */ -abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { +abstract contract ERC4626StataTokenUpgradable is ERC4626Upgradeable, IStata4626 { using Math for uint256; /// @custom:storage-location erc7201:aave-dao.storage.Stata4626 - struct Stata4626Storage { + struct ERC4626StataTokenStorage { IERC20 _aToken; } - // keccak256(abi.encode(uint256(keccak256("aave-dao.storage.Stata4626")) - 1)) & ~bytes32(uint256(0xff)) - bytes32 private constant Stata4626StorageLocation = - 0x4865e395e8f896b2ca01e8489fd809975f6c70c69fd3d1cf5d2263a21a649200; + // keccak256(abi.encode(uint256(keccak256("aave-dao.storage.ERC4626StataToken")) - 1)) & ~bytes32(uint256(0xff)) + bytes32 private constant ERC4626StataTokenStorageLocation = + 0x55029d3f54709e547ed74b2fc842d93107ab1490ab7555dd9dd0bf6451101900; - function _getStata4626Storage() private pure returns (Stata4626Storage storage $) { + function _getERC4626StataTokenStorage() + private + pure + returns (ERC4626StataTokenStorage storage $) + { assembly { - $.slot := Stata4626StorageLocation + $.slot := ERC4626StataTokenStorageLocation } } @@ -60,7 +64,7 @@ abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { IERC20 aTokenUnderlying = IERC20(IAToken(newAToken).UNDERLYING_ASSET_ADDRESS()); __ERC4626_init(aTokenUnderlying); - Stata4626Storage storage $ = _getStata4626Storage(); + ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage(); $._aToken = IERC20(newAToken); SafeERC20.forceApprove(aTokenUnderlying, address(POOL), type(uint256).max); @@ -83,7 +87,7 @@ abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { bool depositToAave ) public returns (uint256) { // TODO: add tests - Stata4626Storage storage $ = _getStata4626Storage(); + ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage(); IERC20Permit assetToDeposit = IERC20Permit(depositToAave ? asset() : address($._aToken)); try @@ -103,7 +107,7 @@ abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { ///@inheritdoc IStata4626 function aToken() public view returns (IERC20) { - Stata4626Storage storage $ = _getStata4626Storage(); + ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage(); return $._aToken; } @@ -195,7 +199,7 @@ abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { SafeERC20.safeTransferFrom(IERC20(cachedAsset), caller, address(this), assets); POOL.deposit(cachedAsset, assets, address(this), 0); } else { - Stata4626Storage storage $ = _getStata4626Storage(); + ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage(); SafeERC20.safeTransferFrom($._aToken, caller, address(this), assets); } _mint(receiver, shares); @@ -234,7 +238,7 @@ abstract contract Stata4626Upgradable is ERC4626Upgradeable, IStata4626 { if (withdrawFromAave) { POOL.withdraw(asset(), assets, receiver); } else { - Stata4626Storage storage $ = _getStata4626Storage(); + ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage(); SafeERC20.safeTransfer($._aToken, receiver, assets); } diff --git a/src/periphery/contracts/static-a-token/StataMerger.sol b/src/periphery/contracts/static-a-token/StataTokenV2.sol similarity index 85% rename from src/periphery/contracts/static-a-token/StataMerger.sol rename to src/periphery/contracts/static-a-token/StataTokenV2.sol index 18933f1e..111672e5 100644 --- a/src/periphery/contracts/static-a-token/StataMerger.sol +++ b/src/periphery/contracts/static-a-token/StataTokenV2.sol @@ -6,22 +6,22 @@ import {PausableUpgradeable} from 'openzeppelin-contracts-upgradeable/contracts/ import {IRescuable, Rescuable} from 'solidity-utils/contracts/utils/Rescuable.sol'; import {IACLManager} from '../../../core/contracts/interfaces/IACLManager.sol'; -import {ERC4626Upgradeable, Stata4626Upgradable, IPool} from './Stata4626Upgradable.sol'; +import {ERC4626Upgradeable, ERC4626StataTokenUpgradable, IPool} from './ERC4626StataTokenUpgradable.sol'; import {ERC20AaveLMUpgradable, IRewardsController} from './ERC20AaveLMUpgradable.sol'; -import {IStataMerger} from './interfaces/IStataMerger.sol'; +import {IStataTokenV2} from './interfaces/IStataTokenV2.sol'; -contract StataMerger is +contract StataTokenV2 is ERC20PermitUpgradeable, ERC20AaveLMUpgradable, - Stata4626Upgradable, + ERC4626StataTokenUpgradable, PausableUpgradeable, Rescuable, - IStataMerger + IStataTokenV2 { constructor( IPool pool, IRewardsController rewardsController - ) ERC20AaveLMUpgradable(rewardsController) Stata4626Upgradable(pool) {} + ) ERC20AaveLMUpgradable(rewardsController) ERC4626StataTokenUpgradable(pool) {} modifier onlyPauseGuardian() { if (!canPause(_msgSender())) revert OnlyPauseGuardian(_msgSender()); _; @@ -39,7 +39,7 @@ contract StataMerger is __Pausable_init(); } - ///@inheritdoc IStataMerger + ///@inheritdoc IStataTokenV2 function setPaused(bool paused) external onlyPauseGuardian { if (paused) _pause(); else _unpause(); @@ -50,7 +50,7 @@ contract StataMerger is return POOL_ADDRESSES_PROVIDER.getACLAdmin(); } - ///@inheritdoc IStataMerger + ///@inheritdoc IStataTokenV2 function canPause(address actor) public view returns (bool) { return IACLManager(POOL_ADDRESSES_PROVIDER.getACLManager()).isEmergencyAdmin(actor); } diff --git a/src/periphery/contracts/static-a-token/StaticATokenFactory.sol b/src/periphery/contracts/static-a-token/StaticATokenFactory.sol index dcf7b1a7..d5259eeb 100644 --- a/src/periphery/contracts/static-a-token/StaticATokenFactory.sol +++ b/src/periphery/contracts/static-a-token/StaticATokenFactory.sol @@ -5,7 +5,7 @@ import {IPool, DataTypes} from '../../../core/contracts/interfaces/IPool.sol'; import {IERC20Metadata} from 'solidity-utils/contracts/oz-common/interfaces/IERC20Metadata.sol'; import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/interfaces/ITransparentProxyFactory.sol'; import {Initializable} from 'solidity-utils/contracts/transparent-proxy/Initializable.sol'; -import {StataMerger} from './StataMerger.sol'; +import {StataTokenV2} from './StataTokenV2.sol'; import {IStaticATokenFactory} from './interfaces/IStaticATokenFactory.sol'; /** @@ -57,7 +57,7 @@ contract StaticATokenFactory is Initializable, IStaticATokenFactory { STATIC_A_TOKEN_IMPL, PROXY_ADMIN, abi.encodeWithSelector( - StataMerger.initialize.selector, + StataTokenV2.initialize.selector, reserveData.aTokenAddress, string(abi.encodePacked('Static ', IERC20Metadata(reserveData.aTokenAddress).name())), string(symbol) diff --git a/src/periphery/contracts/static-a-token/interfaces/IStataMerger.sol b/src/periphery/contracts/static-a-token/interfaces/IStataTokenV2.sol similarity index 87% rename from src/periphery/contracts/static-a-token/interfaces/IStataMerger.sol rename to src/periphery/contracts/static-a-token/interfaces/IStataTokenV2.sol index 28e8f3d2..ff88ea58 100644 --- a/src/periphery/contracts/static-a-token/interfaces/IStataMerger.sol +++ b/src/periphery/contracts/static-a-token/interfaces/IStataTokenV2.sol @@ -1,7 +1,7 @@ -// SPDX-License-Identifier: UNLICENSED +// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -interface IStataMerger { +interface IStataTokenV2 { /** * @notice Checks if the passed actor is permissioned emergency admin. * @param actor The reward to claim diff --git a/tests/periphery/static-a-token/Stata4626LM.t.sol b/tests/periphery/static-a-token/Stata4626LM.t.sol index 4b931809..093024d8 100644 --- a/tests/periphery/static-a-token/Stata4626LM.t.sol +++ b/tests/periphery/static-a-token/Stata4626LM.t.sol @@ -8,8 +8,8 @@ import {IERC20Metadata, IERC20} from 'openzeppelin-contracts/contracts/token/ERC import {AToken} from '../../../src/core/contracts/protocol/tokenization/AToken.sol'; import {DataTypes} from '../../../src/core/contracts/protocol/libraries/configuration/ReserveConfiguration.sol'; -import {Math} from '../../../src/periphery/contracts/static-a-token/Stata4626Upgradable.sol'; -import {StataMerger} from '../../../src/periphery/contracts/static-a-token/StataMerger.sol'; // TODO: change import to isolate to 4626 +import {Math} from '../../../src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradable.sol'; +import {StataTokenV2} from '../../../src/periphery/contracts/static-a-token/StataTokenV2.sol'; // TODO: change import to isolate to 4626 import {SigUtils} from '../../utils/SigUtils.sol'; import {BaseTest, TestnetERC20} from './TestBase.sol'; import {IPool} from '../../../src/core/contracts/interfaces/IPool.sol'; @@ -27,7 +27,7 @@ contract Stata4626LMTest is BaseTest { function test_initializeShouldRevert() public { address impl = factory.STATIC_A_TOKEN_IMPL(); vm.expectRevert(Initializable.InvalidInitialization.selector); - StataMerger(impl).initialize(A_TOKEN, 'hey', 'ho'); + StataTokenV2(impl).initialize(A_TOKEN, 'hey', 'ho'); } function test_getters() public view { diff --git a/tests/periphery/static-a-token/StataOracle.t.sol b/tests/periphery/static-a-token/StataOracle.t.sol index 3c342bee..206e625c 100644 --- a/tests/periphery/static-a-token/StataOracle.t.sol +++ b/tests/periphery/static-a-token/StataOracle.t.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.10; import {StataOracle} from '../../../src/periphery/contracts/static-a-token/StataOracle.sol'; -import {StataMerger} from '../../../src/periphery/contracts/static-a-token/StataMerger.sol'; +import {StataTokenV2} from '../../../src/periphery/contracts/static-a-token/StataTokenV2.sol'; import {BaseTest} from './TestBase.sol'; import {IPool} from '../../../src/core/contracts/interfaces/IPool.sol'; @@ -33,13 +33,13 @@ contract StataOracleTest is BaseTest { address staticAToken = staticATokens[i]; uint256 stataPrice = stataPrices[i]; - address underlying = StataMerger(staticAToken).asset(); + address underlying = StataTokenV2(staticAToken).asset(); uint256 underlyingPrice = contracts.aaveOracle.getAssetPrice(underlying); assertGe(stataPrice, underlyingPrice); assertEq( stataPrice, - (underlyingPrice * StataMerger(staticAToken).convertToAssets(1e18)) / 1e18 + (underlyingPrice * StataTokenV2(staticAToken).convertToAssets(1e18)) / 1e18 ); } } diff --git a/tests/periphery/static-a-token/TestBase.sol b/tests/periphery/static-a-token/TestBase.sol index d160f7f5..d5bbe659 100644 --- a/tests/periphery/static-a-token/TestBase.sol +++ b/tests/periphery/static-a-token/TestBase.sol @@ -11,7 +11,7 @@ import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent- import {ITransparentProxyFactory} from 'solidity-utils/contracts/transparent-proxy/TransparentProxyFactory.sol'; import {IPool} from '../../../src/core/contracts/interfaces/IPool.sol'; import {StaticATokenFactory} from '../../../src/periphery/contracts/static-a-token/StaticATokenFactory.sol'; -import {StataMerger} from '../../../src/periphery/contracts/static-a-token/StataMerger.sol'; +import {StataTokenV2} from '../../../src/periphery/contracts/static-a-token/StataTokenV2.sol'; import {IERC20AaveLM} from '../../../src/periphery/contracts/static-a-token/interfaces/IERC20AaveLM.sol'; import {IAToken} from '../../../src/core/contracts/interfaces/IAToken.sol'; import {TestnetProcedures, TestnetERC20} from '../../utils/TestnetProcedures.sol'; @@ -31,7 +31,7 @@ abstract contract BaseTest is TestnetProcedures { uint256 internal userPrivateKey; uint256 internal spenderPrivateKey; - StataMerger public staticATokenLM; + StataTokenV2 public staticATokenLM; address public proxyAdmin; ITransparentProxyFactory public proxyFactory; StaticATokenFactory public factory; @@ -68,7 +68,7 @@ abstract contract BaseTest is TestnetProcedures { factory = StaticATokenFactory(report.staticATokenFactoryProxy); factory.createStaticATokens(POOL.getReservesList()); - staticATokenLM = StataMerger(factory.getStaticAToken(UNDERLYING)); + staticATokenLM = StataTokenV2(factory.getStaticAToken(UNDERLYING)); } function _configureLM() internal {