Skip to content

Commit

Permalink
fix: address certora feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Sep 2, 2024
1 parent 3781bb6 commit 9274019
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 20 deletions.
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
30 changes: 15 additions & 15 deletions src/periphery/contracts/static-a-token/StataTokenFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,30 @@ 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;
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)) {
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,20 +68,20 @@ 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]);
_underlyingToStaticAToken[underlyings[i]] = stataToken;
stataTokens[i] = stataToken;
_stataTokens.push(stataToken);
emit StataTokenCreated(stataToken, underlyings[i]);
} else {
staticATokens[i] = cachedStaticAToken;
stataTokens[i] = cachedStaticAToken;
}
}
return staticATokens;
return stataTokens;
}

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

///@inheritdoc IStataTokenFactory
Expand Down
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

0 comments on commit 9274019

Please sign in to comment.