mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
Updated Compound Resolver
This commit is contained in:
parent
911f692e8c
commit
22eea514ba
|
@ -10,17 +10,45 @@ interface CTokenInterface {
|
||||||
function balanceOf(address) external view returns (uint);
|
function balanceOf(address) external view returns (uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface TokenInterface {
|
||||||
|
function balanceOf(address) external view returns (uint);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
interface OrcaleComp {
|
interface OrcaleComp {
|
||||||
function getUnderlyingPrice(address) external view returns (uint);
|
function getUnderlyingPrice(address) external view returns (uint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ComptrollerLensInterface {
|
||||||
|
function markets(address) external view returns (bool, uint);
|
||||||
|
function getAccountLiquidity(address) external view returns (uint, uint, uint);
|
||||||
|
function claimComp(address) external;
|
||||||
|
function compAccrued(address) external view returns (uint);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface CompReadInterface {
|
||||||
|
struct CompBalanceMetadataExt {
|
||||||
|
uint balance;
|
||||||
|
uint votes;
|
||||||
|
address delegate;
|
||||||
|
uint allocated;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCompBalanceMetadataExt(
|
||||||
|
TokenInterface comp,
|
||||||
|
ComptrollerLensInterface comptroller,
|
||||||
|
address account
|
||||||
|
) external returns (CompBalanceMetadataExt memory);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
contract Helpers {
|
contract Helpers {
|
||||||
/**
|
/**
|
||||||
* @dev get Compound Comptroller Address
|
* @dev get Compound Comptroller
|
||||||
*/
|
*/
|
||||||
function getComptrollerAddress() public pure returns (address) {
|
function getComptroller() public pure returns (ComptrollerLensInterface) {
|
||||||
return 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B;
|
return ComptrollerLensInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,6 +58,21 @@ contract Helpers {
|
||||||
return 0xDDc46a3B076aec7ab3Fc37420A8eDd2959764Ec4;
|
return 0xDDc46a3B076aec7ab3Fc37420A8eDd2959764Ec4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev get Comp Read Address
|
||||||
|
*/
|
||||||
|
function getCompReadAddress() public pure returns (address) {
|
||||||
|
return 0xd513d22422a3062Bd342Ae374b4b9c20E0a9a074;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev get Comp Token Address
|
||||||
|
*/
|
||||||
|
function getCompToken() public pure returns (TokenInterface) {
|
||||||
|
return TokenInterface(0xc00e94Cb662C3520282E6f5717214004A7f26888);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
struct CompData {
|
struct CompData {
|
||||||
uint tokenPrice;
|
uint tokenPrice;
|
||||||
uint exchangeRateStored;
|
uint exchangeRateStored;
|
||||||
|
@ -43,7 +86,7 @@ contract Helpers {
|
||||||
|
|
||||||
contract Resolver is Helpers {
|
contract Resolver is Helpers {
|
||||||
|
|
||||||
function getPosition(address owner, address[] memory cAddress) public view returns (CompData[] memory) {
|
function getCompoundData(address owner, address[] memory cAddress) public view returns (CompData[] memory) {
|
||||||
CompData[] memory tokensData = new CompData[](cAddress.length);
|
CompData[] memory tokensData = new CompData[](cAddress.length);
|
||||||
for (uint i = 0; i < cAddress.length; i++) {
|
for (uint i = 0; i < cAddress.length; i++) {
|
||||||
CTokenInterface cToken = CTokenInterface(cAddress[i]);
|
CTokenInterface cToken = CTokenInterface(cAddress[i]);
|
||||||
|
@ -56,9 +99,27 @@ contract Resolver is Helpers {
|
||||||
cToken.borrowRatePerBlock()
|
cToken.borrowRatePerBlock()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tokensData;
|
return tokensData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPosition(
|
||||||
|
address owner,
|
||||||
|
address[] memory cAddress
|
||||||
|
)
|
||||||
|
public
|
||||||
|
returns (CompData[] memory, CompReadInterface.CompBalanceMetadataExt memory)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
getCompoundData(owner, cAddress),
|
||||||
|
CompReadInterface(getCompReadAddress()).getCompBalanceMetadataExt(
|
||||||
|
getCompToken(),
|
||||||
|
getComptroller(),
|
||||||
|
owner
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user