diff --git a/contracts/protocols/mainnet/aave_v2.sol b/contracts/protocols/mainnet/aave_v2.sol index a67b6ea..b2e145d 100644 --- a/contracts/protocols/mainnet/aave_v2.sol +++ b/contracts/protocols/mainnet/aave_v2.sol @@ -58,6 +58,10 @@ interface AaveLendingPool { ); } +interface TokenInterface { + function totalSupply() external view returns (uint); +} + interface AaveAddressProvider { function getLendingPool() external view returns (address); function getPriceOracle() external view returns (address); @@ -71,10 +75,20 @@ interface AavePriceOracle { } interface AaveIncentivesInterface { + struct AssetData { + uint128 emissionPerSecond; + uint128 lastUpdateTimestamp; + uint256 index; + } + function getRewardsBalance( address[] calldata assets, address user ) external view returns (uint256); + + function assets( + address asset + ) external view returns (AssetData memory); } interface ChainLinkInterface { @@ -198,9 +212,12 @@ contract AaveHelpers is DSMath { bool stableBorrowEnabled; bool isActive; bool isFrozen; + uint totalSupply; uint availableLiquidity; uint totalStableDebt; uint totalVariableDebt; + uint collateralEmission; + uint debtEmission; } struct TokenPrice { @@ -237,6 +254,21 @@ contract AaveHelpers is DSMath { aaveTokenData.isActive, aaveTokenData.isFrozen ) = aaveData.getReserveConfigurationData(token); + + ( + address aToken, + , + address debtToken + ) = aaveData.getReserveTokensAddresses(token); + + AaveIncentivesInterface.AssetData memory _data; + AaveIncentivesInterface incentives = AaveIncentivesInterface(getAaveIncentivesAddress()); + + _data = incentives.assets(aToken); + aaveTokenData.collateralEmission = _data.emissionPerSecond; + _data = incentives.assets(debtToken); + aaveTokenData.debtEmission = _data.emissionPerSecond; + aaveTokenData.totalSupply = TokenInterface(aToken).totalSupply(); } function getTokenData( @@ -337,5 +369,5 @@ contract Resolver is AaveHelpers { } contract InstaAaveV2Resolver is Resolver { - string public constant name = "AaveV2-Resolver-v1.5"; + string public constant name = "AaveV2-Resolver-v1.6"; } diff --git a/contracts/protocols/mainnet/compound.sol b/contracts/protocols/mainnet/compound.sol index 0227f88..8e4b1e8 100644 --- a/contracts/protocols/mainnet/compound.sol +++ b/contracts/protocols/mainnet/compound.sol @@ -10,6 +10,7 @@ interface CTokenInterface { function underlying() external view returns (address); function balanceOf(address) external view returns (uint); + function getCash() external view returns (uint); } interface TokenInterface { @@ -30,6 +31,7 @@ interface ComptrollerLensInterface { function borrowCaps(address) external view returns (uint); function borrowGuardianPaused(address) external view returns (bool); function oracle() external view returns (address); + function compSpeeds(address) external view returns (uint); } interface CompReadInterface { @@ -117,10 +119,12 @@ contract Helpers is DSMath { uint balanceOfUser; uint borrowBalanceStoredUser; uint totalBorrows; + uint totalSupplied; uint borrowCap; uint supplyRatePerBlock; uint borrowRatePerBlock; uint collateralFactor; + uint compSpeed; bool isComped; bool isBorrowPaused; } @@ -144,17 +148,20 @@ contract Resolver is Helpers { CTokenInterface cToken = CTokenInterface(cAddress[i]); (uint priceInETH, uint priceInUSD) = getPriceInEth(cToken); (,uint collateralFactor, bool isComped) = troller.markets(address(cToken)); + uint _totalBorrowed = cToken.totalBorrows(); tokensData[i] = CompData( priceInETH, priceInUSD, cToken.exchangeRateStored(), cToken.balanceOf(owner), cToken.borrowBalanceStored(owner), - cToken.totalBorrows(), + _totalBorrowed, + add(_totalBorrowed, cToken.getCash()), troller.borrowCaps(cAddress[i]), cToken.supplyRatePerBlock(), cToken.borrowRatePerBlock(), collateralFactor, + troller.compSpeeds(cAddress[i]), isComped, troller.borrowGuardianPaused(cAddress[i]) ); @@ -184,5 +191,5 @@ contract Resolver is Helpers { contract InstaCompoundResolver is Resolver { - string public constant name = "Compound-Resolver-v1.3"; + string public constant name = "Compound-Resolver-v1.4"; } diff --git a/contracts/protocols/polygon/aave_v2.sol b/contracts/protocols/polygon/aave_v2.sol index b05f8c3..c48c282 100644 --- a/contracts/protocols/polygon/aave_v2.sol +++ b/contracts/protocols/polygon/aave_v2.sol @@ -58,6 +58,10 @@ interface AaveLendingPool { ); } +interface TokenInterface { + function totalSupply() external view returns (uint); +} + interface AaveAddressProvider { function getLendingPool() external view returns (address); function getPriceOracle() external view returns (address); @@ -71,10 +75,20 @@ interface AavePriceOracle { } interface AaveIncentivesInterface { + struct AssetData { + uint128 emissionPerSecond; + uint128 lastUpdateTimestamp; + uint256 index; + } + function getRewardsBalance( address[] calldata assets, address user ) external view returns (uint256); + + function assets( + address asset + ) external view returns (AssetData memory); } interface ChainLinkInterface { @@ -194,9 +208,12 @@ contract AaveHelpers is DSMath { bool stableBorrowEnabled; bool isActive; bool isFrozen; + uint totalSupply; uint availableLiquidity; uint totalStableDebt; uint totalVariableDebt; + uint collateralEmission; + uint debtEmission; } struct TokenPrice { @@ -233,6 +250,21 @@ contract AaveHelpers is DSMath { aaveTokenData.isActive, aaveTokenData.isFrozen ) = aaveData.getReserveConfigurationData(token); + + ( + address aToken, + , + address debtToken + ) = aaveData.getReserveTokensAddresses(token); + + AaveIncentivesInterface.AssetData memory _data; + AaveIncentivesInterface incentives = AaveIncentivesInterface(getAaveIncentivesAddress()); + + _data = incentives.assets(aToken); + aaveTokenData.collateralEmission = _data.emissionPerSecond; + _data = incentives.assets(debtToken); + aaveTokenData.debtEmission = _data.emissionPerSecond; + aaveTokenData.totalSupply = TokenInterface(aToken).totalSupply(); } function getTokenData( @@ -333,5 +365,5 @@ contract Resolver is AaveHelpers { } contract InstaAaveV2Resolver is Resolver { - string public constant name = "AaveV2-Resolver-v1.5"; + string public constant name = "AaveV2-Resolver-v1.6"; }