2021-02-07 15:31:36 +00:00
|
|
|
pragma solidity ^0.7.0;
|
2021-02-05 17:07:07 +00:00
|
|
|
|
2021-02-08 13:58:28 +00:00
|
|
|
import { TokenInterface } from "../../common/interfaces.sol";
|
2021-02-05 18:33:49 +00:00
|
|
|
import { Stores } from "../../common/stores.sol";
|
2021-02-05 17:07:07 +00:00
|
|
|
import { Helpers } from "./helpers.sol";
|
|
|
|
import { Events } from "./events.sol";
|
|
|
|
|
2021-02-05 18:33:49 +00:00
|
|
|
abstract contract CompResolver is Events, Helpers {
|
2021-02-05 17:07:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Claim Accrued COMP Token.
|
|
|
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
|
|
|
*/
|
2021-02-07 18:18:38 +00:00
|
|
|
function ClaimComp(uint setId) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
2021-02-08 15:27:45 +00:00
|
|
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
|
|
|
uint intialBal = _compToken.balanceOf(address(this));
|
|
|
|
troller.claimComp(address(this));
|
|
|
|
uint finalBal = _compToken.balanceOf(address(this));
|
2021-02-05 17:07:07 +00:00
|
|
|
uint amt = sub(finalBal, intialBal);
|
|
|
|
|
|
|
|
setUint(setId, amt);
|
|
|
|
|
2021-02-08 13:58:28 +00:00
|
|
|
_eventName = "LogClaimedComp(uint256,uint256)";
|
2021-02-07 18:18:38 +00:00
|
|
|
_eventParam = abi.encode(amt, setId);
|
2021-02-05 17:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Claim Accrued COMP Token.
|
|
|
|
* @param tokens Array of tokens supplied and borrowed.
|
|
|
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
|
|
|
*/
|
2021-02-07 18:18:38 +00:00
|
|
|
function ClaimCompTwo(address[] calldata tokens, uint setId) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
2021-02-05 17:07:07 +00:00
|
|
|
uint _len = tokens.length;
|
|
|
|
address[] memory ctokens = new address[](_len);
|
|
|
|
for (uint i = 0; i < _len; i++) {
|
2021-02-08 13:58:28 +00:00
|
|
|
ctokens[i] = instaMapping.cTokenMapping(tokens[i]);
|
2021-02-05 17:07:07 +00:00
|
|
|
}
|
|
|
|
|
2021-02-08 15:27:45 +00:00
|
|
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
|
|
|
uint intialBal = _compToken.balanceOf(address(this));
|
|
|
|
troller.claimComp(address(this), ctokens);
|
|
|
|
uint finalBal = _compToken.balanceOf(address(this));
|
2021-02-05 17:07:07 +00:00
|
|
|
uint amt = sub(finalBal, intialBal);
|
|
|
|
|
|
|
|
setUint(setId, amt);
|
|
|
|
|
2021-02-08 13:58:28 +00:00
|
|
|
_eventName = "LogClaimedComp(uint256,uint256)";
|
2021-02-07 18:18:38 +00:00
|
|
|
_eventParam = abi.encode(amt, setId);
|
2021-02-05 17:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Claim Accrued COMP Token.
|
|
|
|
* @param supplyTokens Array of tokens supplied.
|
|
|
|
* @param borrowTokens Array of tokens borrowed.
|
|
|
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
|
|
|
*/
|
2021-02-07 18:18:38 +00:00
|
|
|
function ClaimCompThree(address[] calldata supplyTokens, address[] calldata borrowTokens, uint setId) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
2021-02-05 17:07:07 +00:00
|
|
|
(address[] memory ctokens, bool isBorrow, bool isSupply) = mergeTokenArr(supplyTokens, borrowTokens);
|
|
|
|
|
|
|
|
address[] memory holders = new address[](1);
|
|
|
|
holders[0] = address(this);
|
|
|
|
|
2021-02-08 15:27:45 +00:00
|
|
|
TokenInterface _compToken = TokenInterface(address(compToken));
|
|
|
|
uint intialBal = _compToken.balanceOf(address(this));
|
|
|
|
troller.claimComp(holders, ctokens, isBorrow, isSupply);
|
|
|
|
uint finalBal = _compToken.balanceOf(address(this));
|
2021-02-05 17:07:07 +00:00
|
|
|
uint amt = sub(finalBal, intialBal);
|
|
|
|
|
|
|
|
setUint(setId, amt);
|
|
|
|
|
2021-02-08 13:58:28 +00:00
|
|
|
_eventName = "LogClaimedComp(uint256,uint256)";
|
2021-02-07 18:18:38 +00:00
|
|
|
_eventParam = abi.encode(amt, setId);
|
2021-02-05 17:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Delegate votes.
|
|
|
|
* @param delegatee The address to delegate votes to.
|
|
|
|
*/
|
2021-02-07 18:18:38 +00:00
|
|
|
function delegate(address delegatee) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
2021-02-05 17:07:07 +00:00
|
|
|
require(compToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee.");
|
|
|
|
|
|
|
|
compToken.delegate(delegatee);
|
|
|
|
|
2021-02-08 13:58:28 +00:00
|
|
|
_eventName = "LogDelegate(address)";
|
|
|
|
_eventParam = abi.encode(delegatee);
|
2021-02-05 17:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-15 12:26:22 +00:00
|
|
|
contract ConnectV2COMP is CompResolver {
|
2021-02-05 17:07:07 +00:00
|
|
|
string public name = "COMP-v1";
|
|
|
|
}
|