aave-protocol-v2/contracts/protocol/libraries/helpers/Helpers.sol

41 lines
1.1 KiB
Solidity
Raw Normal View History

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
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
**/
function getUserCurrentDebt(address user, DataTypes.ReserveData storage reserve)
2020-08-06 07:52:15 +00:00
internal
view
returns (uint256, uint256)
{
return (
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
function getUserCurrentDebtMemory(address user, DataTypes.ReserveData memory reserve)
2020-10-28 14:41:31 +00:00
internal
view
returns (uint256, uint256)
{
return (
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
}