Skip to content

Commit

Permalink
Changes to make stata more consistent with using ERC20 extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
eboadom committed Aug 14, 2024
1 parent 66b8fec commit 4035b6f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 2 additions & 7 deletions src/periphery/contracts/static-a-token/StataTokenV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit 4035b6f

Please sign in to comment.