Merge pull request #5 from InstaDApp/aave-collateral

Add collateral enabled flag
This commit is contained in:
Thrilok kumar 2020-12-13 16:48:11 +05:30 committed by GitHub
commit c1ce69bae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 6 deletions

View File

@ -104,16 +104,16 @@ contract AaveHelpers is DSMath {
* @dev get Aave Provider Address * @dev get Aave Provider Address
*/ */
function getAaveProviderAddress() internal pure returns (address) { function getAaveProviderAddress() internal pure returns (address) {
// return 0x24a42fD28C976A61Df5D00D0599C34c4f90748c8; //mainnet return 0x24a42fD28C976A61Df5D00D0599C34c4f90748c8; //mainnet
return 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5; //kovan // return 0x506B0B2CF20FAA8f38a4E2B524EE43e1f4458Cc5; //kovan
} }
/** /**
* @dev get Chainlink ETH price feed Address * @dev get Chainlink ETH price feed Address
*/ */
function getChainlinkEthFeed() internal pure returns (address) { function getChainlinkEthFeed() internal pure returns (address) {
// return 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419; //mainnet return 0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419; //mainnet
return 0x9326BFA02ADD2366b30bacB125260Af641031331; //kovan // return 0x9326BFA02ADD2366b30bacB125260Af641031331; //kovan
} }
struct AaveUserTokenData { struct AaveUserTokenData {
@ -125,6 +125,7 @@ contract AaveHelpers is DSMath {
uint supplyRate; uint supplyRate;
uint borrowRate; uint borrowRate;
uint borrowModal; uint borrowModal;
bool isCollateral;
AaveTokenData aaveTokenData; AaveTokenData aaveTokenData;
} }
@ -200,6 +201,7 @@ contract AaveHelpers is DSMath {
, ,
uint fee, uint fee,
,, ,,
bool isCollateral
) = aave.getUserReserveData(token, user); ) = aave.getUserReserveData(token, user);
uint supplyRate = aaveCore.getReserveCurrentLiquidityRate(token); uint supplyRate = aaveCore.getReserveCurrentLiquidityRate(token);
@ -215,6 +217,7 @@ contract AaveHelpers is DSMath {
supplyRate, supplyRate,
borrowRate, borrowRate,
borrowModal, borrowModal,
isCollateral,
aaveTokenData aaveTokenData
); );
} }
@ -262,5 +265,5 @@ contract Resolver is AaveHelpers {
} }
contract InstaAaveResolver is Resolver { contract InstaAaveResolver is Resolver {
string public constant name = "Aave-Resolver-v1.1"; string public constant name = "Aave-Resolver-v1.2";
} }

View File

@ -153,6 +153,7 @@ contract AaveHelpers is DSMath {
uint supplyRate; uint supplyRate;
uint stableBorrowRate; uint stableBorrowRate;
uint variableBorrowRate; uint variableBorrowRate;
bool isCollateral;
AaveTokenData aaveTokenData; AaveTokenData aaveTokenData;
} }
@ -225,6 +226,7 @@ contract AaveHelpers is DSMath {
tokenData.stableBorrowBalance, tokenData.stableBorrowBalance,
tokenData.variableBorrowBalance, tokenData.variableBorrowBalance,
,,,,, ,,,,,
tokenData.isCollateral
) = aaveData.getUserReserveData(token, user); ) = aaveData.getUserReserveData(token, user);
( (
@ -293,5 +295,5 @@ contract Resolver is AaveHelpers {
} }
contract InstaAaveV2Resolver is Resolver { contract InstaAaveV2Resolver is Resolver {
string public constant name = "AaveV2-Resolver-v1.1"; string public constant name = "AaveV2-Resolver-v1.2";
} }

View File

@ -57,6 +57,7 @@ interface AavePriceInterface {
interface AaveCoreInterface { interface AaveCoreInterface {
function getReserveCurrentLiquidityRate(address _reserve) external view returns (uint256); function getReserveCurrentLiquidityRate(address _reserve) external view returns (uint256);
function getReserveCurrentVariableBorrowRate(address _reserve) external view returns (uint256); function getReserveCurrentVariableBorrowRate(address _reserve) external view returns (uint256);
function getReserveATokenAddress(address _reserve) external view returns (address);
} }
interface VatLike { interface VatLike {
@ -250,6 +251,9 @@ contract AaveHelpers is CompoundResolver {
public view returns (uint) { public view returns (uint) {
AaveProviderInterface AaveProvider = AaveProviderInterface(getAaveProviderAddress()); AaveProviderInterface AaveProvider = AaveProviderInterface(getAaveProviderAddress());
AaveInterface aave = AaveInterface(AaveProvider.getLendingPool()); AaveInterface aave = AaveInterface(AaveProvider.getLendingPool());
AaveCoreInterface aaveCore = AaveCoreInterface(AaveProvider.getLendingPoolCore());
if (aaveCore.getReserveATokenAddress(token) == address(0)) return 0;
AaveTokenData memory aaveToken = collateralData(aave, token); AaveTokenData memory aaveToken = collateralData(aave, token);
AaveTokenData memory aaveEthToken = collateralData(aave, getEthAddress()); AaveTokenData memory aaveEthToken = collateralData(aave, getEthAddress());
if (!aaveToken.borrowEnabled) return 0; if (!aaveToken.borrowEnabled) return 0;