2020-08-06 07:52:15 +00:00
|
|
|
// SPDX-License-Identifier: agpl-3.0
|
2020-11-20 10:45:20 +00:00
|
|
|
pragma solidity 0.6.12;
|
2020-08-06 07:52:15 +00:00
|
|
|
|
2020-11-24 13:53:34 +00:00
|
|
|
import {IERC20} from '../../../dependencies/openzeppelin/contracts/IERC20.sol';
|
|
|
|
import {DataTypes} from '../types/DataTypes.sol';
|
2020-08-06 07:52:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @title Helpers library
|
|
|
|
* @author Aave
|
|
|
|
* @notice Implements calculation helpers.
|
|
|
|
*/
|
|
|
|
library Helpers {
|
|
|
|
/**
|
|
|
|
* @dev fetches the user current stable and variable debt balances
|
2020-08-21 12:54:07 +00:00
|
|
|
* @param user the user
|
|
|
|
* @param reserve the reserve object
|
2020-08-06 07:52:15 +00:00
|
|
|
* @return the stable and variable debt balance
|
|
|
|
**/
|
2020-11-24 13:53:34 +00:00
|
|
|
function getUserCurrentDebt(address user, DataTypes.ReserveData storage reserve)
|
2020-08-06 07:52:15 +00:00
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint256, uint256)
|
|
|
|
{
|
|
|
|
return (
|
2020-11-24 13:53:34 +00:00
|
|
|
IERC20(reserve.stableDebtTokenAddress).balanceOf(user),
|
|
|
|
IERC20(reserve.variableDebtTokenAddress).balanceOf(user)
|
2020-08-06 07:52:15 +00:00
|
|
|
);
|
|
|
|
}
|
2020-10-28 14:41:31 +00:00
|
|
|
|
2020-11-24 13:53:34 +00:00
|
|
|
function getUserCurrentDebtMemory(address user, DataTypes.ReserveData memory reserve)
|
2020-10-28 14:41:31 +00:00
|
|
|
internal
|
|
|
|
view
|
|
|
|
returns (uint256, uint256)
|
|
|
|
{
|
|
|
|
return (
|
2020-11-24 13:53:34 +00:00
|
|
|
IERC20(reserve.stableDebtTokenAddress).balanceOf(user),
|
|
|
|
IERC20(reserve.variableDebtTokenAddress).balanceOf(user)
|
2020-10-28 14:41:31 +00:00
|
|
|
);
|
|
|
|
}
|
2020-08-06 07:52:15 +00:00
|
|
|
}
|