mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Update COMP
This commit is contained in:
parent
7e69631620
commit
fb0c7ff62f
|
@ -2,21 +2,18 @@ pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { DSMath } from "../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
import { Basic } from "../../common/basic.sol";
|
import { Basic } from "../../common/basic.sol";
|
||||||
|
import { ComptrollerInterface, COMPInterface } from "./interface.sol";
|
||||||
|
|
||||||
abstract contract Helpers is DSMath, Basic {
|
abstract contract Helpers is DSMath, Basic {
|
||||||
/**
|
/**
|
||||||
* @dev Return Compound Comptroller Address
|
* @dev Compound Comptroller
|
||||||
*/
|
*/
|
||||||
function getComptrollerAddress() internal pure returns (address) {
|
ComptrollerInterface internal constant troller = ComptrollerInterface(0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B);
|
||||||
return 0x3d9819210A31b4961b30EF54bE2aeD79B9c9Cd3B;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Return COMP Token Address.
|
* @dev COMP Token
|
||||||
*/
|
*/
|
||||||
function getCompTokenAddress() internal pure returns (address) {
|
COMPInterface internal constant compToken = COMPInterface(0xc00e94Cb662C3520282E6f5717214004A7f26888);
|
||||||
return 0xc00e94Cb662C3520282E6f5717214004A7f26888;
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeTokenArr(address[] memory supplyTokens, address[] memory borrowTokens)
|
function mergeTokenArr(address[] memory supplyTokens, address[] memory borrowTokens)
|
||||||
internal
|
internal
|
||||||
|
|
|
@ -2,7 +2,6 @@ pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { TokenInterface } from "../../common/interfaces.sol";
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
import { Stores } from "../../common/stores.sol";
|
import { Stores } from "../../common/stores.sol";
|
||||||
import { ComptrollerInterface, COMPInterface } from "./interface.sol";
|
|
||||||
import { Helpers } from "./helpers.sol";
|
import { Helpers } from "./helpers.sol";
|
||||||
import { Events } from "./events.sol";
|
import { Events } from "./events.sol";
|
||||||
|
|
||||||
|
@ -13,10 +12,10 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
||||||
*/
|
*/
|
||||||
function ClaimComp(uint setId) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
function ClaimComp(uint setId) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
TokenInterface compToken = TokenInterface(getCompTokenAddress());
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
||||||
uint intialBal = compToken.balanceOf(address(this));
|
uint intialBal = _compToken.balanceOf(address(this));
|
||||||
ComptrollerInterface(getComptrollerAddress()).claimComp(address(this));
|
troller.claimComp(address(this));
|
||||||
uint finalBal = compToken.balanceOf(address(this));
|
uint finalBal = _compToken.balanceOf(address(this));
|
||||||
uint amt = sub(finalBal, intialBal);
|
uint amt = sub(finalBal, intialBal);
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
@ -37,10 +36,10 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
ctokens[i] = instaMapping.cTokenMapping(tokens[i]);
|
ctokens[i] = instaMapping.cTokenMapping(tokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
TokenInterface compToken = TokenInterface(getCompTokenAddress());
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
||||||
uint intialBal = compToken.balanceOf(address(this));
|
uint intialBal = _compToken.balanceOf(address(this));
|
||||||
ComptrollerInterface(getComptrollerAddress()).claimComp(address(this), ctokens);
|
troller.claimComp(address(this), ctokens);
|
||||||
uint finalBal = compToken.balanceOf(address(this));
|
uint finalBal = _compToken.balanceOf(address(this));
|
||||||
uint amt = sub(finalBal, intialBal);
|
uint amt = sub(finalBal, intialBal);
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
@ -61,10 +60,10 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
address[] memory holders = new address[](1);
|
address[] memory holders = new address[](1);
|
||||||
holders[0] = address(this);
|
holders[0] = address(this);
|
||||||
|
|
||||||
TokenInterface compToken = TokenInterface(getCompTokenAddress());
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
||||||
uint intialBal = compToken.balanceOf(address(this));
|
uint intialBal = _compToken.balanceOf(address(this));
|
||||||
ComptrollerInterface(getComptrollerAddress()).claimComp(holders, ctokens, isBorrow, isSupply);
|
troller.claimComp(holders, ctokens, isBorrow, isSupply);
|
||||||
uint finalBal = compToken.balanceOf(address(this));
|
uint finalBal = _compToken.balanceOf(address(this));
|
||||||
uint amt = sub(finalBal, intialBal);
|
uint amt = sub(finalBal, intialBal);
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
@ -78,7 +77,6 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
* @param delegatee The address to delegate votes to.
|
* @param delegatee The address to delegate votes to.
|
||||||
*/
|
*/
|
||||||
function delegate(address delegatee) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
function delegate(address delegatee) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
COMPInterface compToken = COMPInterface(getCompTokenAddress());
|
|
||||||
require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee.");
|
require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee.");
|
||||||
|
|
||||||
compToken.delegate(delegatee);
|
compToken.delegate(delegatee);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user