From a64edb3011e481a0f71193ba01d2ed44c87e2ee9 Mon Sep 17 00:00:00 2001 From: The3D Date: Mon, 14 Sep 2020 11:13:53 +0200 Subject: [PATCH] Removed interest redirection leftovers --- contracts/libraries/helpers/Errors.sol | 3 --- contracts/tokenization/AToken.sol | 7 +------ contracts/tokenization/interfaces/IAToken.sol | 2 +- helpers/types.ts | 6 ------ test/atoken-transfer.spec.ts | 4 ---- test/helpers/utils/calculations.ts | 11 ----------- 6 files changed, 2 insertions(+), 31 deletions(-) diff --git a/contracts/libraries/helpers/Errors.sol b/contracts/libraries/helpers/Errors.sol index 60fd2da3..ee9feac9 100644 --- a/contracts/libraries/helpers/Errors.sol +++ b/contracts/libraries/helpers/Errors.sol @@ -43,11 +43,8 @@ library Errors { // require error messages - aToken string public constant CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool' - string public constant INTEREST_REDIRECTION_NOT_ALLOWED = '29'; // 'Caller is not allowed to redirect the interest of the user' string public constant CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30'; // 'User cannot give allowance to himself' string public constant TRANSFER_AMOUNT_NOT_GT_0 = '31'; // 'Transferred amount needs to be greater than zero' - string public constant INTEREST_ALREADY_REDIRECTED = '32'; // 'Interest is already redirected to the user' - string public constant NO_VALID_BALANCE_FOR_REDIRECTION = '33'; // 'Interest stream can only be redirected if there is a valid balance' string public constant INVALID_ATOKEN_BALANCE = '52'; // balance on burning is invalid // require error messages - ReserveLogic diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index c0126c18..d4558836 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -23,14 +23,9 @@ contract AToken is VersionedInitializable, ERC20, IAToken { using SafeERC20 for ERC20; uint256 public constant UINT_MAX_VALUE = uint256(-1); - address public immutable UNDERLYING_ASSET_ADDRESS; - LendingPool public immutable POOL; - - mapping(address => uint256) private _scaledRedirectedBalances; - - uint256 public constant ATOKEN_REVISION = 0x1; + LendingPool public immutable POOL; modifier onlyLendingPool { require(msg.sender == address(POOL), Errors.CALLER_MUST_BE_LENDING_POOL); diff --git a/contracts/tokenization/interfaces/IAToken.sol b/contracts/tokenization/interfaces/IAToken.sol index 3aa5e83d..873860a9 100644 --- a/contracts/tokenization/interfaces/IAToken.sol +++ b/contracts/tokenization/interfaces/IAToken.sol @@ -94,7 +94,7 @@ interface IAToken is IERC20 { * @dev transfer the amount of the underlying asset to the user * @param user address of the user * @param amount the amount to transfer - * @return the redirected balance index + * @return the amount transferred **/ function transferUnderlyingTo(address user, uint256 amount) external returns (uint256); diff --git a/helpers/types.ts b/helpers/types.ts index 79a810c2..083d043e 100644 --- a/helpers/types.ts +++ b/helpers/types.ts @@ -78,11 +78,8 @@ export enum ProtocolErrors { // require error messages - aToken CALLER_MUST_BE_LENDING_POOL = '28', // 'The caller of this function must be a lending pool' - INTEREST_REDIRECTION_NOT_ALLOWED = '29', // 'Caller is not allowed to redirect the interest of the user' CANNOT_GIVE_ALLOWANCE_TO_HIMSELF = '30', // 'User cannot give allowance to himself' TRANSFER_AMOUNT_NOT_GT_0 = '31', // 'Transferred amount needs to be greater than zero' - INTEREST_ALREADY_REDIRECTED = '32', // 'Interest is already redirected to the user' - NO_VALID_BALANCE_FOR_REDIRECTION = '33', // 'Interest stream can only be redirected if there is a valid balance' // require error messages - ReserveLogic RESERVE_ALREADY_INITIALIZED = '34', // 'Reserve has already been initialized' @@ -107,9 +104,6 @@ export enum ProtocolErrors { INVALID_FROM_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer', INVALID_TO_BALANCE_AFTER_TRANSFER = 'Invalid from balance after transfer', INVALID_OWNER_REVERT_MSG = 'Ownable: caller is not the owner', - INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER = 'Invalid redirected balance before transfer', - INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER = 'Invalid redirected balance after transfer', - INVALID_REDIRECTION_ADDRESS = 'Invalid redirection address', INVALID_HF = 'Invalid health factor', TRANSFER_AMOUNT_EXCEEDS_BALANCE = 'ERC20: transfer amount exceeds balance', SAFEERC20_LOWLEVEL_CALL = 'SafeERC20: low-level call failed', diff --git a/test/atoken-transfer.spec.ts b/test/atoken-transfer.spec.ts index b75db650..73c299ad 100644 --- a/test/atoken-transfer.spec.ts +++ b/test/atoken-transfer.spec.ts @@ -14,11 +14,7 @@ makeSuite('AToken: Transfer', (testEnv: TestEnv) => { const { INVALID_FROM_BALANCE_AFTER_TRANSFER, INVALID_TO_BALANCE_AFTER_TRANSFER, - INVALID_REDIRECTED_BALANCE_BEFORE_TRANSFER, - INVALID_REDIRECTED_BALANCE_AFTER_TRANSFER, - INVALID_REDIRECTION_ADDRESS, // ZERO_COLLATERAL, - TRANSFER_AMOUNT_NOT_GT_0, COLLATERAL_BALANCE_IS_0, TRANSFER_NOT_ALLOWED, } = ProtocolErrors; diff --git a/test/helpers/utils/calculations.ts b/test/helpers/utils/calculations.ts index ff4c64be..23f2a374 100644 --- a/test/helpers/utils/calculations.ts +++ b/test/helpers/utils/calculations.ts @@ -933,17 +933,6 @@ const calcExpectedATokenBalance = ( return scaledBalanceBeforeAction.rayMul(index); }; -const calcExpectedRedirectedBalance = ( - expectedUserDataAfterAction: UserReserveData, - index: BigNumber, - redirectedBalanceBefore: BigNumber, - amountToAdd: BigNumber, - amountToSubstract: BigNumber -): BigNumber => { - return expectedUserDataAfterAction.interestRedirectionAddress !== ZERO_ADDRESS - ? redirectedBalanceBefore.plus(amountToAdd.rayDiv(index)).minus(amountToSubstract.rayDiv(index)) - : new BigNumber('0'); -}; const calcExpectedAverageStableBorrowRate = ( avgStableRateBefore: BigNumber, totalBorrowsStableBefore: BigNumber,