forked from aave-dao/aave-v3-origin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
before munging the new storage. Currently it's NOT compiling
- Loading branch information
1 parent
ea9d815
commit 843f6e4
Showing
7 changed files
with
184 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {SafeERC20, IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol'; | ||
import {RewardIndexCache, UserRewardsData} from 'aave-v3-periphery/contracts/static-a-token/interfaces/IERC20AaveLM.sol'; | ||
|
||
|
||
contract ERC20AaveLMStorage_Harness { | ||
address _referenceAsset; // a/v token to track rewards on INCENTIVES_CONTROLLER | ||
address[] _rewardTokens; | ||
mapping(address user => IERC20AaveLM.RewardIndexCache cache) _startIndex; | ||
mapping(address user => mapping(address reward => IERC20AaveLM.UserRewardsData cache)) _userRewardsData; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {SafeERC20, IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol'; | ||
|
||
|
||
contract ERC4626StataTokenStorage_Harness { | ||
IERC20 _aToken; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import {SafeERC20, IERC20} from 'openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol'; | ||
import {ERC4626Upgradeable} from 'openzeppelin-contracts-upgradeable/contracts/token/ERC20/extensions/ERC4626Upgradeable.sol'; | ||
|
||
contract ERC4626Storage_Harness { | ||
IERC20 _asset; | ||
uint8 _underlyingDecimals; | ||
|
||
ERC4626Upgradeable.ERC4626Storage the_storage; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
// SPDX-License-Identifier: agpl-3.0 | ||
pragma solidity ^0.8.10; | ||
|
||
import {IERC20} from 'openzeppelin-contracts/contracts/interfaces/IERC20.sol'; | ||
import {StataTokenV2, IPool, IRewardsController} from 'aave-v3-periphery/contracts/static-a-token/StataTokenV2.sol'; | ||
import {SymbolicLendingPool} from './pool/SymbolicLendingPool.sol'; | ||
|
||
|
||
|
||
contract StataTokenV2Harness is StataTokenV2 { | ||
address internal _reward_A; | ||
address internal _reward_B; | ||
|
||
ERC4626Storage the_storage; | ||
|
||
function get_the_storage() public view returns (ERC4626Storage storage ret) { | ||
ret = the_storage; | ||
} | ||
|
||
|
||
constructor( | ||
IPool pool, | ||
IRewardsController rewardsController | ||
) StataTokenV2(pool, rewardsController) {} | ||
|
||
function rate() external view returns (uint256) { | ||
return _rate(); | ||
} | ||
|
||
/* | ||
// returns the address of the underlying asset of the static aToken | ||
function getStaticATokenUnderlying() public view returns (address) { | ||
//return _aTokenUnderlying; | ||
return asset(); | ||
} | ||
// returns the address of the i-th reward token in the reward tokens list maintained by the static aToken | ||
function getRewardToken(uint256 i) external view returns (address) { | ||
return _rewardTokens[i]; | ||
} | ||
// returns the length of the reward tokens list maintained by the static aToken | ||
function getRewardTokensLength() external view returns (uint256) { | ||
return _rewardTokens.length; | ||
} | ||
// returns a user's reward index on last interaction for a given reward | ||
function getRewardsIndexOnLastInteraction(address user, address reward) | ||
external view returns (uint128) { | ||
UserRewardsData memory currentUserRewardsData = _userRewardsData[user][reward]; | ||
return currentUserRewardsData.rewardsIndexOnLastInteraction; | ||
} | ||
// claims rewards for a user on the static aToken. | ||
// the method builds the rewards array with a single reward and calls the internal claim function with it | ||
function claimSingleRewardOnBehalf( | ||
address onBehalfOf, | ||
address receiver, | ||
address reward | ||
) external | ||
{ | ||
require (reward == _reward_A); | ||
address[] memory rewards = new address[](1); | ||
rewards[0] = _reward_A; | ||
// @MM - think of the best way to get rid of this require | ||
require( | ||
msg.sender == onBehalfOf || | ||
msg.sender == INCENTIVES_CONTROLLER.getClaimer(onBehalfOf) | ||
); | ||
_claimRewardsOnBehalf(onBehalfOf, receiver, rewards); | ||
} | ||
// claims rewards for a user on the static aToken. | ||
// the method builds the rewards array with 2 identical rewards and calls the internal claim function with it | ||
function claimDoubleRewardOnBehalfSame( | ||
address onBehalfOf, | ||
address receiver, | ||
address reward | ||
) external | ||
{ | ||
require (reward == _reward_A); | ||
address[] memory rewards = new address[](2); | ||
rewards[0] = _reward_A; | ||
rewards[1] = _reward_A; | ||
require( | ||
msg.sender == onBehalfOf || | ||
msg.sender == INCENTIVES_CONTROLLER.getClaimer(onBehalfOf) | ||
); | ||
_claimRewardsOnBehalf(onBehalfOf, receiver, rewards); | ||
} | ||
*/ | ||
// wrapper function for the erc20 _mint function. Used to reduce running times | ||
function _mintWrapper(address to, uint256 amount) external { | ||
_mint(to, amount); | ||
} | ||
/* | ||
function getUserRewardsData(address user, address reward) | ||
external view | ||
returns (uint128) { | ||
UserRewardsData memory currentUserRewardsData = _userRewardsData[user][ | ||
reward | ||
]; | ||
return currentUserRewardsData.rewardsIndexOnLastInteraction; | ||
} | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#CMN="--compilation_steps_only" | ||
CMN="--compilation_steps_only" | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters