dsa-connectors/contracts/connectors/aave/v1/helpers.sol

45 lines
1.7 KiB
Solidity
Raw Normal View History

2021-02-08 13:58:28 +00:00
pragma solidity ^0.7.0;
2021-02-08 14:31:55 +00:00
import { DSMath } from "../../../common/math.sol";
import { Basic } from "../../../common/basic.sol";
2021-02-08 13:58:28 +00:00
import { AaveProviderInterface, AaveInterface } from "./interface.sol";
abstract contract Helpers is DSMath, Basic {
/**
* @dev Aave Provider
*/
AaveProviderInterface constant internal aaveProvider = AaveProviderInterface(0x24a42fD28C976A61Df5D00D0599C34c4f90748c8);
/**
* @dev Aave Referral Code
*/
uint16 constant internal referralCode = 3228;
/**
* @dev Checks if collateral is enabled for an asset
2021-02-08 14:31:55 +00:00
* @param aave Aave Interface
* @param token token address of the asset.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
2021-02-08 13:58:28 +00:00
*/
function getIsColl(AaveInterface aave, address token) internal view returns (bool isCol) {
(, , , , , , , , , isCol) = aave.getUserReserveData(token, address(this));
}
/**
* @dev Get total collateral balance for an asset
* @param aave Aave Interface
* @param token token address of the collateral.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
*/
2021-02-08 14:31:55 +00:00
function getCollateralBalance(AaveInterface aave, address token) internal view returns (uint bal) {
2021-02-08 13:58:28 +00:00
(bal, , , , , , , , , ) = aave.getUserReserveData(token, address(this));
}
/**
* @dev Get total debt balance & fee for an asset
* @param aave Aave Interface
* @param token token address of the debt.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
*/
function getPaybackBalance(AaveInterface aave, address token) internal view returns (uint bal, uint fee) {
(, bal, , , , , fee, , , ) = aave.getUserReserveData(token, address(this));
}
}