removed userIndex from variabledebttoken

This commit is contained in:
The3D 2020-09-21 16:11:14 +02:00
parent 8ed9b88163
commit 2ebe34a051
2 changed files with 26 additions and 24 deletions

View File

@ -115,7 +115,6 @@ contract AToken is VersionedInitializable, IncentivizedERC20, IAToken {
//transfer event to track balances //transfer event to track balances
emit Transfer(user, address(0), amount); emit Transfer(user, address(0), amount);
emit Burn(msg.sender, receiverOfUnderlying, amount, index); emit Burn(msg.sender, receiverOfUnderlying, amount, index);
} }

View File

@ -17,7 +17,6 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
using WadRayMath for uint256; using WadRayMath for uint256;
uint256 public constant DEBT_TOKEN_REVISION = 0x1; uint256 public constant DEBT_TOKEN_REVISION = 0x1;
mapping(address => uint256) _userIndexes;
constructor( constructor(
address pool, address pool,
@ -46,9 +45,7 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
return 0; return 0;
} }
return return scaledBalance.rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET));
scaledBalance
.rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET));
} }
/** /**
@ -57,8 +54,11 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
* @param amount the amount of debt being minted * @param amount the amount of debt being minted
* @param index the variable debt index of the reserve * @param index the variable debt index of the reserve
**/ **/
function mint(address user, uint256 amount, uint256 index) external override onlyLendingPool { function mint(
address user,
uint256 amount,
uint256 index
) external override onlyLendingPool {
_mint(user, amount.rayDiv(index)); _mint(user, amount.rayDiv(index));
emit Transfer(address(0), user, amount); emit Transfer(address(0), user, amount);
@ -70,35 +70,38 @@ contract VariableDebtToken is DebtTokenBase, IVariableDebtToken {
* @param user the user which debt is burnt * @param user the user which debt is burnt
* @param index the variable debt index of the reserve * @param index the variable debt index of the reserve
**/ **/
function burn(address user, uint256 amount, uint256 index) external override onlyLendingPool { function burn(
address user,
uint256 amount,
uint256 index
) external override onlyLendingPool {
_burn(user, amount.rayDiv(index)); _burn(user, amount.rayDiv(index));
_userIndexes[user] = index;
emit Transfer(user, address(0), amount); emit Transfer(user, address(0), amount);
emit BurnDebt(user, amount, index); emit BurnDebt(user, amount, index);
} }
/** /**
* @dev Returns the principal debt balance of the user from * @dev Returns the principal debt balance of the user from
* @return The debt balance of the user since the last burn/mint action * @return The debt balance of the user since the last burn/mint action
**/ **/
function scaledBalanceOf(address user) public virtual override view returns (uint256) { function scaledBalanceOf(address user) public virtual override view returns (uint256) {
return super.balanceOf(user); return super.balanceOf(user);
} }
/** /**
* @dev Returns the total supply of the variable debt token. Represents the total debt accrued by the users * @dev Returns the total supply of the variable debt token. Represents the total debt accrued by the users
* @return the total supply * @return the total supply
**/ **/
function totalSupply() public virtual override view returns(uint256) { function totalSupply() public virtual override view returns (uint256) {
return super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET)); return super.totalSupply().rayMul(POOL.getReserveNormalizedVariableDebt(UNDERLYING_ASSET));
} }
/** /**
* @dev Returns the scaled total supply of the variable debt token. Represents sum(borrows/index) * @dev Returns the scaled total supply of the variable debt token. Represents sum(borrows/index)
* @return the scaled total supply * @return the scaled total supply
**/ **/
function scaledTotalSupply() public virtual override view returns(uint256) { function scaledTotalSupply() public virtual override view returns (uint256) {
return super.totalSupply(); return super.totalSupply();
} }
} }