Skip to content

Commit

Permalink
fix: alter function ordering a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
sakulstra committed Aug 11, 2024
1 parent 68ee60b commit 06dfa9c
Showing 1 changed file with 88 additions and 88 deletions.
176 changes: 88 additions & 88 deletions src/periphery/contracts/static-a-token/StaticATokenLM.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,45 +104,60 @@ contract StaticATokenLM is
return POOL_ADDRESSES_PROVIDER.getACLAdmin();
}

/// @inheritdoc IERC20Metadata
function decimals() public view override(ERC20Upgradeable, ERC4626Upgradeable) returns (uint8) {
return _decimals;
///@inheritdoc IERC4626
function deposit(uint256 assets, address receiver) public override returns (uint256) {
(uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, 0, true);
return shares;
}

///@inheritdoc IStaticATokenLM
function setPaused(bool paused) external onlyPauseGuardian {
if (paused) _pause();
else _unpause();
function deposit(
uint256 assets,
address receiver,
uint16 referralCode,
bool depositToAave
) external returns (uint256) {
(uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, referralCode, depositToAave);
return shares;
}

///@inheritdoc IStaticATokenLM
function refreshRewardTokens() public override {
address[] memory rewards = INCENTIVES_CONTROLLER.getRewardsByAsset(address(_aToken));
for (uint256 i = 0; i < rewards.length; i++) {
_registerRewardToken(rewards[i]);
}
}
///@inheritdoc IERC4626
function mint(uint256 shares, address receiver) public override returns (uint256) {
(, uint256 assets) = _deposit(msg.sender, receiver, shares, 0, 0, true);

///@inheritdoc IStaticATokenLM
function isRegisteredRewardToken(address reward) public view override returns (bool) {
return _startIndex[reward].isRegistered;
return assets;
}

///@inheritdoc IStaticATokenLM
function rate() public view returns (uint256) {
return POOL.getReserveNormalizedIncome(_aTokenUnderlying);
///@inheritdoc IERC4626
function withdraw(
uint256 assets,
address receiver,
address owner
) public override returns (uint256) {
(uint256 shares, ) = _withdraw(owner, receiver, 0, assets, true);

return shares;
}

///@inheritdoc IStaticATokenLM
function collectAndUpdateRewards(address reward) public returns (uint256) {
if (reward == address(0)) {
return 0;
}
///@inheritdoc IERC4626
function redeem(
uint256 shares,
address receiver,
address owner
) public override returns (uint256) {
(, uint256 assets) = _withdraw(owner, receiver, shares, 0, true);

address[] memory assets = new address[](1);
assets[0] = address(_aToken);
return assets;
}

return INCENTIVES_CONTROLLER.claimRewards(assets, type(uint256).max, address(this), reward);
///@inheritdoc IStaticATokenLM
function redeem(
uint256 shares,
address receiver,
address owner,
bool withdrawFromAave
) external returns (uint256, uint256) {
return _withdraw(owner, receiver, shares, 0, withdrawFromAave);
}

///@inheritdoc IStaticATokenLM
Expand All @@ -168,6 +183,42 @@ contract StaticATokenLM is
_claimRewardsOnBehalf(msg.sender, msg.sender, rewards);
}

/// @inheritdoc IERC20Metadata
function decimals() public view override(ERC20Upgradeable, ERC4626Upgradeable) returns (uint8) {
return _decimals;
}

///@inheritdoc IStaticATokenLM
function setPaused(bool paused) external onlyPauseGuardian {
if (paused) _pause();
else _unpause();
}

///@inheritdoc IStaticATokenLM
function refreshRewardTokens() public override {
address[] memory rewards = INCENTIVES_CONTROLLER.getRewardsByAsset(address(_aToken));
for (uint256 i = 0; i < rewards.length; i++) {
_registerRewardToken(rewards[i]);
}
}

///@inheritdoc IStaticATokenLM
function collectAndUpdateRewards(address reward) public returns (uint256) {
if (reward == address(0)) {
return 0;
}

address[] memory assets = new address[](1);
assets[0] = address(_aToken);

return INCENTIVES_CONTROLLER.claimRewards(assets, type(uint256).max, address(this), reward);
}

///@inheritdoc IStaticATokenLM
function isRegisteredRewardToken(address reward) public view override returns (bool) {
return _startIndex[reward].isRegistered;
}

///@inheritdoc IStaticATokenLM
function getCurrentRewardsIndex(address reward) public view returns (uint256) {
if (address(reward) == address(0)) {
Expand Down Expand Up @@ -199,11 +250,21 @@ contract StaticATokenLM is
return _userRewardsData[user][reward].unclaimedRewards;
}

///@inheritdoc IStaticATokenLM
function rate() public view returns (uint256) {
return POOL.getReserveNormalizedIncome(_aTokenUnderlying);
}

///@inheritdoc IERC4626
function asset() public view override returns (address) {
return address(_aTokenUnderlying);
}

///@inheritdoc IERC4626
function totalAssets() public view override returns (uint256) {
return _aToken.balanceOf(address(this));
}

///@inheritdoc IStaticATokenLM
function aToken() external view returns (IERC20) {
return _aToken;
Expand All @@ -214,11 +275,6 @@ contract StaticATokenLM is
return _rewardTokens;
}

///@inheritdoc IERC4626
function totalAssets() public view override returns (uint256) {
return _aToken.balanceOf(address(this));
}

///@inheritdoc IERC4626
function convertToShares(uint256 assets) public view override returns (uint256) {
return _convertToShares(assets, Rounding.DOWN);
Expand Down Expand Up @@ -290,62 +346,6 @@ contract StaticATokenLM is
return currentSupply > supplyCap ? 0 : supplyCap - currentSupply;
}

///@inheritdoc IERC4626
function deposit(uint256 assets, address receiver) public override returns (uint256) {
(uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, 0, true);
return shares;
}

///@inheritdoc IStaticATokenLM
function deposit(
uint256 assets,
address receiver,
uint16 referralCode,
bool depositToAave
) external returns (uint256) {
(uint256 shares, ) = _deposit(msg.sender, receiver, 0, assets, referralCode, depositToAave);
return shares;
}

///@inheritdoc IERC4626
function mint(uint256 shares, address receiver) public override returns (uint256) {
(, uint256 assets) = _deposit(msg.sender, receiver, shares, 0, 0, true);

return assets;
}

///@inheritdoc IERC4626
function withdraw(
uint256 assets,
address receiver,
address owner
) public override returns (uint256) {
(uint256 shares, ) = _withdraw(owner, receiver, 0, assets, true);

return shares;
}

///@inheritdoc IERC4626
function redeem(
uint256 shares,
address receiver,
address owner
) public override returns (uint256) {
(, uint256 assets) = _withdraw(owner, receiver, shares, 0, true);

return assets;
}

///@inheritdoc IStaticATokenLM
function redeem(
uint256 shares,
address receiver,
address owner,
bool withdrawFromAave
) external returns (uint256, uint256) {
return _withdraw(owner, receiver, shares, 0, withdrawFromAave);
}

///@inheritdoc IStaticATokenLM
function latestAnswer() external view returns (int256) {
return
Expand Down

0 comments on commit 06dfa9c

Please sign in to comment.