Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: address certora feedback #14

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St
}

///@inheritdoc IERC4626StataToken
function depositATokens(uint256 assets, address receiver) public returns (uint256) {
function depositATokens(uint256 assets, address receiver) external returns (uint256) {
uint256 shares = previewDeposit(assets);
_deposit(_msgSender(), receiver, assets, shares, false);

Expand All @@ -88,7 +88,7 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St
uint256 deadline,
SignatureParams memory sig,
bool depositToAave
) public returns (uint256) {
) external returns (uint256) {
IERC20Permit assetToDeposit = IERC20Permit(
depositToAave ? asset() : address(_getERC4626StataTokenStorage()._aToken)
);
Expand All @@ -103,15 +103,19 @@ abstract contract ERC4626StataTokenUpgradeable is ERC4626Upgradeable, IERC4626St
}

///@inheritdoc IERC4626StataToken
function redeemATokens(uint256 shares, address receiver, address owner) public returns (uint256) {
function redeemATokens(
uint256 shares,
address receiver,
address owner
) external returns (uint256) {
uint256 assets = previewRedeem(shares);
_withdraw(_msgSender(), receiver, owner, assets, shares, false);

return assets;
}

///@inheritdoc IERC4626StataToken
function aToken() public view returns (IERC20) {
function aToken() external view returns (IERC20) {
ERC4626StataTokenStorage storage $ = _getERC4626StataTokenStorage();
return $._aToken;
}
Expand Down
38 changes: 19 additions & 19 deletions src/periphery/contracts/static-a-token/StataTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,33 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
IPool public immutable POOL;
address public immutable PROXY_ADMIN;
ITransparentProxyFactory public immutable TRANSPARENT_PROXY_FACTORY;
address public immutable STATIC_A_TOKEN_IMPL;
address public immutable STATA_TOKEN_IMPL;

mapping(address => address) internal _underlyingToStaticAToken;
address[] internal _staticATokens;
mapping(address => address) internal _underlyingToStataToken;
address[] internal _stataTokens;

event StaticTokenCreated(address indexed staticAToken, address indexed underlying);
event StataTokenCreated(address indexed stataToken, address indexed underlying);

constructor(
IPool pool,
address proxyAdmin,
ITransparentProxyFactory transparentProxyFactory,
address staticATokenImpl
address stataTokenImpl
) {
POOL = pool;
PROXY_ADMIN = proxyAdmin;
TRANSPARENT_PROXY_FACTORY = transparentProxyFactory;
STATIC_A_TOKEN_IMPL = staticATokenImpl;
STATA_TOKEN_IMPL = stataTokenImpl;
}

function initialize() external initializer {}

///@inheritdoc IStataTokenFactory
function createStataTokens(address[] memory underlyings) external returns (address[] memory) {
address[] memory staticATokens = new address[](underlyings.length);
address[] memory stataTokens = new address[](underlyings.length);
for (uint256 i = 0; i < underlyings.length; i++) {
address cachedStaticAToken = _underlyingToStaticAToken[underlyings[i]];
if (cachedStaticAToken == address(0)) {
address cachedStataToken = _underlyingToStataToken[underlyings[i]];
if (cachedStataToken == address(0)) {
DataTypes.ReserveDataLegacy memory reserveData = POOL.getReserveData(underlyings[i]);
if (reserveData.aTokenAddress == address(0))
revert NotListedUnderlying(reserveData.aTokenAddress);
Expand All @@ -54,8 +54,8 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
IERC20Metadata(reserveData.aTokenAddress).symbol(),
'v2'
);
address staticAToken = TRANSPARENT_PROXY_FACTORY.createDeterministic(
STATIC_A_TOKEN_IMPL,
address stataToken = TRANSPARENT_PROXY_FACTORY.createDeterministic(
STATA_TOKEN_IMPL,
PROXY_ADMIN,
abi.encodeWithSelector(
StataTokenV2.initialize.selector,
Expand All @@ -68,24 +68,24 @@ contract StataTokenFactory is Initializable, IStataTokenFactory {
bytes32(uint256(uint160(underlyings[i])))
);

_underlyingToStaticAToken[underlyings[i]] = staticAToken;
staticATokens[i] = staticAToken;
_staticATokens.push(staticAToken);
emit StaticTokenCreated(staticAToken, underlyings[i]);
_underlyingToStataToken[underlyings[i]] = stataToken;
stataTokens[i] = stataToken;
_stataTokens.push(stataToken);
emit StataTokenCreated(stataToken, underlyings[i]);
} else {
staticATokens[i] = cachedStaticAToken;
stataTokens[i] = cachedStataToken;
}
}
return staticATokens;
return stataTokens;
}

///@inheritdoc IStataTokenFactory
function getStataTokens() external view returns (address[] memory) {
return _staticATokens;
return _stataTokens;
}

///@inheritdoc IStataTokenFactory
function getStataToken(address underlying) external view returns (address) {
return _underlyingToStaticAToken[underlying];
return _underlyingToStataToken[underlying];
}
}
2 changes: 1 addition & 1 deletion tests/periphery/static-a-token/StataTokenV2Getters.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {BaseTest} from './TestBase.sol';

contract StataTokenV2GettersTest is BaseTest {
function test_initializeShouldRevert() public {
address impl = factory.STATIC_A_TOKEN_IMPL();
address impl = factory.STATA_TOKEN_IMPL();
vm.expectRevert(Initializable.InvalidInitialization.selector);
StataTokenV2(impl).initialize(aToken, 'hey', 'ho');
}
Expand Down