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

47 lines
1.3 KiB
Solidity
Raw Normal View History

2020-08-06 07:52:15 +00:00
// SPDX-License-Identifier: agpl-3.0
pragma solidity ^0.6.8;
2020-08-20 07:51:21 +00:00
import {DebtTokenBase} from '../../tokenization/base/DebtTokenBase.sol';
import {ReserveLogic} from '../logic/ReserveLogic.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
* @param _user the user
* @param _reserve the reserve object
* @return the stable and variable debt balance
**/
function getUserCurrentDebt(address _user, ReserveLogic.ReserveData storage _reserve)
internal
view
returns (uint256, uint256)
{
return (
2020-08-20 07:51:21 +00:00
DebtTokenBase(_reserve.stableDebtTokenAddress).balanceOf(_user),
DebtTokenBase(_reserve.variableDebtTokenAddress).balanceOf(_user)
2020-08-06 07:52:15 +00:00
);
}
/**
* @dev fetches the user principal stable and variable debt balances
* @param _user the user
* @param _reserve the reserve object
* @return the stable and variable debt balance
**/
function getUserPrincipalDebt(address _user, ReserveLogic.ReserveData storage _reserve)
internal
view
returns (uint256, uint256)
{
return (
DebtTokenBase(_reserve.stableDebtTokenAddress).principalBalanceOf(_user),
DebtTokenBase(_reserve.variableDebtTokenAddress).principalBalanceOf(_user)
);
}
}