aave-protocol-v2/contracts/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:41:58 +00:00
pragma solidity ^0.6.12;
2020-08-06 07:52:15 +00:00
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
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-08-21 12:54:07 +00:00
function getUserCurrentDebt(address user, ReserveLogic.ReserveData storage reserve)
2020-08-06 07:52:15 +00:00
internal
view
returns (uint256, uint256)
{
return (
2020-08-21 12:54:07 +00:00
DebtTokenBase(reserve.stableDebtTokenAddress).balanceOf(user),
DebtTokenBase(reserve.variableDebtTokenAddress).balanceOf(user)
2020-08-06 07:52:15 +00:00
);
}
2020-10-28 14:41:31 +00:00
function getUserCurrentDebtMemory(address user, ReserveLogic.ReserveData memory reserve)
2020-10-28 14:41:31 +00:00
internal
view
returns (uint256, uint256)
{
return (
DebtTokenBase(reserve.stableDebtTokenAddress).balanceOf(user),
DebtTokenBase(reserve.variableDebtTokenAddress).balanceOf(user)
);
}
2020-08-06 07:52:15 +00:00
}