mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Merge pull request #19 from Instadapp/reward-emission
Compound & Aave Reward emission
This commit is contained in:
commit
abfb28d253
|
@ -58,6 +58,10 @@ interface AaveLendingPool {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TokenInterface {
|
||||||
|
function totalSupply() external view returns (uint);
|
||||||
|
}
|
||||||
|
|
||||||
interface AaveAddressProvider {
|
interface AaveAddressProvider {
|
||||||
function getLendingPool() external view returns (address);
|
function getLendingPool() external view returns (address);
|
||||||
function getPriceOracle() external view returns (address);
|
function getPriceOracle() external view returns (address);
|
||||||
|
@ -71,10 +75,20 @@ interface AavePriceOracle {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AaveIncentivesInterface {
|
interface AaveIncentivesInterface {
|
||||||
|
struct AssetData {
|
||||||
|
uint128 emissionPerSecond;
|
||||||
|
uint128 lastUpdateTimestamp;
|
||||||
|
uint256 index;
|
||||||
|
}
|
||||||
|
|
||||||
function getRewardsBalance(
|
function getRewardsBalance(
|
||||||
address[] calldata assets,
|
address[] calldata assets,
|
||||||
address user
|
address user
|
||||||
) external view returns (uint256);
|
) external view returns (uint256);
|
||||||
|
|
||||||
|
function assets(
|
||||||
|
address asset
|
||||||
|
) external view returns (AssetData memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChainLinkInterface {
|
interface ChainLinkInterface {
|
||||||
|
@ -198,9 +212,12 @@ contract AaveHelpers is DSMath {
|
||||||
bool stableBorrowEnabled;
|
bool stableBorrowEnabled;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
bool isFrozen;
|
bool isFrozen;
|
||||||
|
uint totalSupply;
|
||||||
uint availableLiquidity;
|
uint availableLiquidity;
|
||||||
uint totalStableDebt;
|
uint totalStableDebt;
|
||||||
uint totalVariableDebt;
|
uint totalVariableDebt;
|
||||||
|
uint collateralEmission;
|
||||||
|
uint debtEmission;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TokenPrice {
|
struct TokenPrice {
|
||||||
|
@ -237,6 +254,21 @@ contract AaveHelpers is DSMath {
|
||||||
aaveTokenData.isActive,
|
aaveTokenData.isActive,
|
||||||
aaveTokenData.isFrozen
|
aaveTokenData.isFrozen
|
||||||
) = aaveData.getReserveConfigurationData(token);
|
) = 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(
|
function getTokenData(
|
||||||
|
@ -337,5 +369,5 @@ contract Resolver is AaveHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
contract InstaAaveV2Resolver is Resolver {
|
contract InstaAaveV2Resolver is Resolver {
|
||||||
string public constant name = "AaveV2-Resolver-v1.5";
|
string public constant name = "AaveV2-Resolver-v1.6";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ interface CTokenInterface {
|
||||||
|
|
||||||
function underlying() external view returns (address);
|
function underlying() external view returns (address);
|
||||||
function balanceOf(address) external view returns (uint);
|
function balanceOf(address) external view returns (uint);
|
||||||
|
function getCash() external view returns (uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TokenInterface {
|
interface TokenInterface {
|
||||||
|
@ -30,6 +31,7 @@ interface ComptrollerLensInterface {
|
||||||
function borrowCaps(address) external view returns (uint);
|
function borrowCaps(address) external view returns (uint);
|
||||||
function borrowGuardianPaused(address) external view returns (bool);
|
function borrowGuardianPaused(address) external view returns (bool);
|
||||||
function oracle() external view returns (address);
|
function oracle() external view returns (address);
|
||||||
|
function compSpeeds(address) external view returns (uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface CompReadInterface {
|
interface CompReadInterface {
|
||||||
|
@ -117,10 +119,12 @@ contract Helpers is DSMath {
|
||||||
uint balanceOfUser;
|
uint balanceOfUser;
|
||||||
uint borrowBalanceStoredUser;
|
uint borrowBalanceStoredUser;
|
||||||
uint totalBorrows;
|
uint totalBorrows;
|
||||||
|
uint totalSupplied;
|
||||||
uint borrowCap;
|
uint borrowCap;
|
||||||
uint supplyRatePerBlock;
|
uint supplyRatePerBlock;
|
||||||
uint borrowRatePerBlock;
|
uint borrowRatePerBlock;
|
||||||
uint collateralFactor;
|
uint collateralFactor;
|
||||||
|
uint compSpeed;
|
||||||
bool isComped;
|
bool isComped;
|
||||||
bool isBorrowPaused;
|
bool isBorrowPaused;
|
||||||
}
|
}
|
||||||
|
@ -144,17 +148,20 @@ contract Resolver is Helpers {
|
||||||
CTokenInterface cToken = CTokenInterface(cAddress[i]);
|
CTokenInterface cToken = CTokenInterface(cAddress[i]);
|
||||||
(uint priceInETH, uint priceInUSD) = getPriceInEth(cToken);
|
(uint priceInETH, uint priceInUSD) = getPriceInEth(cToken);
|
||||||
(,uint collateralFactor, bool isComped) = troller.markets(address(cToken));
|
(,uint collateralFactor, bool isComped) = troller.markets(address(cToken));
|
||||||
|
uint _totalBorrowed = cToken.totalBorrows();
|
||||||
tokensData[i] = CompData(
|
tokensData[i] = CompData(
|
||||||
priceInETH,
|
priceInETH,
|
||||||
priceInUSD,
|
priceInUSD,
|
||||||
cToken.exchangeRateStored(),
|
cToken.exchangeRateStored(),
|
||||||
cToken.balanceOf(owner),
|
cToken.balanceOf(owner),
|
||||||
cToken.borrowBalanceStored(owner),
|
cToken.borrowBalanceStored(owner),
|
||||||
cToken.totalBorrows(),
|
_totalBorrowed,
|
||||||
|
add(_totalBorrowed, cToken.getCash()),
|
||||||
troller.borrowCaps(cAddress[i]),
|
troller.borrowCaps(cAddress[i]),
|
||||||
cToken.supplyRatePerBlock(),
|
cToken.supplyRatePerBlock(),
|
||||||
cToken.borrowRatePerBlock(),
|
cToken.borrowRatePerBlock(),
|
||||||
collateralFactor,
|
collateralFactor,
|
||||||
|
troller.compSpeeds(cAddress[i]),
|
||||||
isComped,
|
isComped,
|
||||||
troller.borrowGuardianPaused(cAddress[i])
|
troller.borrowGuardianPaused(cAddress[i])
|
||||||
);
|
);
|
||||||
|
@ -184,5 +191,5 @@ contract Resolver is Helpers {
|
||||||
|
|
||||||
|
|
||||||
contract InstaCompoundResolver is Resolver {
|
contract InstaCompoundResolver is Resolver {
|
||||||
string public constant name = "Compound-Resolver-v1.3";
|
string public constant name = "Compound-Resolver-v1.4";
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,10 @@ interface AaveLendingPool {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TokenInterface {
|
||||||
|
function totalSupply() external view returns (uint);
|
||||||
|
}
|
||||||
|
|
||||||
interface AaveAddressProvider {
|
interface AaveAddressProvider {
|
||||||
function getLendingPool() external view returns (address);
|
function getLendingPool() external view returns (address);
|
||||||
function getPriceOracle() external view returns (address);
|
function getPriceOracle() external view returns (address);
|
||||||
|
@ -71,10 +75,20 @@ interface AavePriceOracle {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface AaveIncentivesInterface {
|
interface AaveIncentivesInterface {
|
||||||
|
struct AssetData {
|
||||||
|
uint128 emissionPerSecond;
|
||||||
|
uint128 lastUpdateTimestamp;
|
||||||
|
uint256 index;
|
||||||
|
}
|
||||||
|
|
||||||
function getRewardsBalance(
|
function getRewardsBalance(
|
||||||
address[] calldata assets,
|
address[] calldata assets,
|
||||||
address user
|
address user
|
||||||
) external view returns (uint256);
|
) external view returns (uint256);
|
||||||
|
|
||||||
|
function assets(
|
||||||
|
address asset
|
||||||
|
) external view returns (AssetData memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChainLinkInterface {
|
interface ChainLinkInterface {
|
||||||
|
@ -194,9 +208,12 @@ contract AaveHelpers is DSMath {
|
||||||
bool stableBorrowEnabled;
|
bool stableBorrowEnabled;
|
||||||
bool isActive;
|
bool isActive;
|
||||||
bool isFrozen;
|
bool isFrozen;
|
||||||
|
uint totalSupply;
|
||||||
uint availableLiquidity;
|
uint availableLiquidity;
|
||||||
uint totalStableDebt;
|
uint totalStableDebt;
|
||||||
uint totalVariableDebt;
|
uint totalVariableDebt;
|
||||||
|
uint collateralEmission;
|
||||||
|
uint debtEmission;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TokenPrice {
|
struct TokenPrice {
|
||||||
|
@ -233,6 +250,21 @@ contract AaveHelpers is DSMath {
|
||||||
aaveTokenData.isActive,
|
aaveTokenData.isActive,
|
||||||
aaveTokenData.isFrozen
|
aaveTokenData.isFrozen
|
||||||
) = aaveData.getReserveConfigurationData(token);
|
) = 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(
|
function getTokenData(
|
||||||
|
@ -333,5 +365,5 @@ contract Resolver is AaveHelpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
contract InstaAaveV2Resolver is Resolver {
|
contract InstaAaveV2Resolver is Resolver {
|
||||||
string public constant name = "AaveV2-Resolver-v1.5";
|
string public constant name = "AaveV2-Resolver-v1.6";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user