From 4035b6f581749771d367765cbc87f2a884f6a460 Mon Sep 17 00:00:00 2001 From: eboado Date: Wed, 14 Aug 2024 17:21:09 +0200 Subject: [PATCH] Changes to make stata more consistent with using ERC20 extensions --- .../static-a-token/ERC20AaveLMUpgradeable.sol | 10 +++------- .../static-a-token/ERC4626StataTokenUpgradeable.sol | 12 ++---------- .../contracts/static-a-token/StataTokenV2.sol | 9 ++------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/periphery/contracts/static-a-token/ERC20AaveLMUpgradeable.sol b/src/periphery/contracts/static-a-token/ERC20AaveLMUpgradeable.sol index 3b3b0fd0..651c2fa0 100644 --- a/src/periphery/contracts/static-a-token/ERC20AaveLMUpgradeable.sol +++ b/src/periphery/contracts/static-a-token/ERC20AaveLMUpgradeable.sol @@ -11,7 +11,8 @@ import {IERC20AaveLM} from './interfaces/IERC20AaveLM.sol'; /** * @title ERC20AaveLMUpgradeable.sol - * @notice Wrapper smart contract that supports tracking and claiming liquidity mining rewards from the Aave system. + * @notice Wrapper smart contract that supports tracking and claiming liquidity mining rewards from the Aave system + * @dev ERC20 extension, so ERC20 initialization should be done by the children contract/s * @author BGD labs */ abstract contract ERC20AaveLMUpgradeable is ERC20Upgradeable, IERC20AaveLM { @@ -41,13 +42,8 @@ abstract contract ERC20AaveLMUpgradeable is ERC20Upgradeable, IERC20AaveLM { INCENTIVES_CONTROLLER = rewardsController; } - function __ERC20AaveLM_init( - address referenceAsset_, - string calldata staticATokenName, - string calldata staticATokenSymbol - ) internal onlyInitializing { + function __ERC20AaveLM_init(address referenceAsset_) internal onlyInitializing { __ERC20AaveLM_init_unchained(referenceAsset_); - __ERC20_init_unchained(staticATokenName, staticATokenSymbol); } function __ERC20AaveLM_init_unchained(address referenceAsset_) internal onlyInitializing { ERC20AaveLMStorage storage $ = _getERC20AaveLMStorage(); diff --git a/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradeable.sol b/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradeable.sol index 36f36e9b..2710a6b4 100644 --- a/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradeable.sol +++ b/src/periphery/contracts/static-a-token/ERC4626StataTokenUpgradeable.sol @@ -16,6 +16,7 @@ import {IERC4626StataToken} from './interfaces/IERC4626StataToken.sol'; * @title ERC4626StataTokenUpgradeable.sol.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. + * @dev ERC20 extension, so ERC20 initialization should be done by the children contract/s * @author BGD labs */ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626StataToken { @@ -50,18 +51,9 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St POOL_ADDRESSES_PROVIDER = pool.ADDRESSES_PROVIDER(); } - function __ERC4626StataToken_init( - address newAToken, - string calldata staticATokenName, - string calldata staticATokenSymbol - ) internal onlyInitializing { + function __ERC4626StataToken_init(address newAToken) internal onlyInitializing { IERC20 aTokenUnderlying = __ERC4626StataToken_init_unchained(newAToken); - - /// @notice __ERC4626_init doesn't init the ERC20Upgradeable, but following the init - /// procedures, this function should initialize everything required for this contract - /// to be completely initialized, including the inheritance chain __ERC4626_init_unchained(aTokenUnderlying); - __ERC20_init_unchained(staticATokenName, staticATokenSymbol); } function __ERC4626StataToken_init_unchained( diff --git a/src/periphery/contracts/static-a-token/StataTokenV2.sol b/src/periphery/contracts/static-a-token/StataTokenV2.sol index 4939bd1c..baa1ac32 100644 --- a/src/periphery/contracts/static-a-token/StataTokenV2.sol +++ b/src/periphery/contracts/static-a-token/StataTokenV2.sol @@ -34,15 +34,10 @@ contract StataTokenV2 is string calldata staticATokenName, string calldata staticATokenSymbol ) external initializer { - /// @notice __ERC4626StataToken_init will also init ERC20 - __ERC4626StataToken_init(aToken, staticATokenName, staticATokenSymbol); - + __ERC20_init(staticATokenName, staticATokenSymbol); __ERC20Permit_init(staticATokenName); - - /// @notice using init_unchained because we have already initialized ERC20 - /// with __ERC4626StataToken_init, so we want only to init ERC20AaveLM __ERC20AaveLM_init_unchained(aToken); - + __ERC4626StataToken_init(aToken); __Pausable_init(); }