mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
updated new event emitting in comp.sol
This commit is contained in:
parent
279452e845
commit
e392dd6262
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { TokenInterface } from "./interfaces.sol";
|
import { TokenInterface } from "./interfaces.sol";
|
||||||
import { Stores } from "./stores.sol";
|
import { Stores } from "./stores.sol";
|
||||||
|
@ -23,4 +23,8 @@ abstract contract Basic is DSMath, Stores {
|
||||||
sellDec = address(sellAddr) == getEthAddr() ? 18 : sellAddr.decimals();
|
sellDec = address(sellAddr) == getEthAddr() ? 18 : sellAddr.decimals();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function encodeEvent(string eventName, bytes eventParam) internal pure returns (bytes memory) {
|
||||||
|
return abi.encode(eventName, eventParam);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
interface TokenInterface {
|
interface TokenInterface {
|
||||||
function approve(address, uint256) external;
|
function approve(address, uint256) external;
|
||||||
|
@ -15,40 +15,6 @@ interface MemoryInterface {
|
||||||
function setUint(uint id, uint val) external;
|
function setUint(uint id, uint val) external;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EventInterface {
|
|
||||||
function emitEvent(uint connectorType, uint connectorID, bytes32 eventCode, bytes calldata eventData) external;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InstaMapping {
|
interface InstaMapping {
|
||||||
function cTokenMapping(address) external view returns (address);
|
function cTokenMapping(address) external view returns (address);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct OneProtoData {
|
|
||||||
TokenInterface sellToken;
|
|
||||||
TokenInterface buyToken;
|
|
||||||
uint _sellAmt;
|
|
||||||
uint _buyAmt;
|
|
||||||
uint unitAmt;
|
|
||||||
uint[] distribution;
|
|
||||||
uint disableDexes;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OneProtoMultiData {
|
|
||||||
address[] tokens;
|
|
||||||
TokenInterface sellToken;
|
|
||||||
TokenInterface buyToken;
|
|
||||||
uint _sellAmt;
|
|
||||||
uint _buyAmt;
|
|
||||||
uint unitAmt;
|
|
||||||
uint[] distribution;
|
|
||||||
uint[] disableDexes;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct OneInchData {
|
|
||||||
TokenInterface sellToken;
|
|
||||||
TokenInterface buyToken;
|
|
||||||
uint _sellAmt;
|
|
||||||
uint _buyAmt;
|
|
||||||
uint unitAmt;
|
|
||||||
bytes callData;
|
|
||||||
}
|
|
|
@ -1,16 +1,10 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { MemoryInterface, EventInterface} from "./interfaces.sol";
|
import { MemoryInterface } from "./interfaces.sol";
|
||||||
|
|
||||||
|
|
||||||
abstract contract Stores {
|
abstract contract Stores {
|
||||||
|
|
||||||
uint256 internal immutable _id;
|
|
||||||
|
|
||||||
constructor(uint256 id) public {
|
|
||||||
_id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Return ethereum address
|
* @dev Return ethereum address
|
||||||
*/
|
*/
|
||||||
|
@ -25,13 +19,6 @@ abstract contract Stores {
|
||||||
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address
|
return 0x8a5419CfC711B2343c17a6ABf4B2bAFaBb06957F; // InstaMemory Address
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Return InstaEvent Address.
|
|
||||||
*/
|
|
||||||
function getEventAddr() internal pure returns (address) {
|
|
||||||
return 0x2af7ea6Cb911035f3eb1ED895Cb6692C39ecbA97; // InstaEvent Address
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Return InstaDApp Mapping Addresses
|
* @dev Return InstaDApp Mapping Addresses
|
||||||
*/
|
*/
|
||||||
|
@ -53,19 +40,4 @@ abstract contract Stores {
|
||||||
if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val);
|
if (setId != 0) MemoryInterface(getMemoryAddr()).setUint(setId, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev emit event on event contract
|
|
||||||
*/
|
|
||||||
function emitEvent(bytes32 eventCode, bytes memory eventData) virtual internal {
|
|
||||||
(uint model, uint id) = connectorID();
|
|
||||||
EventInterface(getEventAddr()).emitEvent(model, id, eventCode, eventData);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dev Connector Details - needs to be changed before deployment
|
|
||||||
*/
|
|
||||||
function connectorID() public view returns(uint model, uint id) {
|
|
||||||
(model, id) = (0, _id);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { TokenInterface } from "../../common/interfaces.sol";
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
|
|
||||||
|
@ -56,3 +56,33 @@ interface OneProtoInterface {
|
||||||
interface OneProtoMappingInterface {
|
interface OneProtoMappingInterface {
|
||||||
function oneProtoAddress() external view returns(address);
|
function oneProtoAddress() external view returns(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct OneProtoData {
|
||||||
|
TokenInterface sellToken;
|
||||||
|
TokenInterface buyToken;
|
||||||
|
uint _sellAmt;
|
||||||
|
uint _buyAmt;
|
||||||
|
uint unitAmt;
|
||||||
|
uint[] distribution;
|
||||||
|
uint disableDexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OneProtoMultiData {
|
||||||
|
address[] tokens;
|
||||||
|
TokenInterface sellToken;
|
||||||
|
TokenInterface buyToken;
|
||||||
|
uint _sellAmt;
|
||||||
|
uint _buyAmt;
|
||||||
|
uint unitAmt;
|
||||||
|
uint[] distribution;
|
||||||
|
uint[] disableDexes;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct OneInchData {
|
||||||
|
TokenInterface sellToken;
|
||||||
|
TokenInterface buyToken;
|
||||||
|
uint _sellAmt;
|
||||||
|
uint _buyAmt;
|
||||||
|
uint unitAmt;
|
||||||
|
bytes callData;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { InstaMapping } from "../../common/interfaces.sol";
|
import { InstaMapping } from "../../common/interfaces.sol";
|
||||||
import { DSMath } from "../../common/math.sol";
|
import { DSMath } from "../../common/math.sol";
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.5;
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
import { TokenInterface , MemoryInterface, EventInterface, InstaMapping } from "../../common/interfaces.sol";
|
import { TokenInterface , MemoryInterface, EventInterface, InstaMapping } from "../../common/interfaces.sol";
|
||||||
import { Stores } from "../../common/stores.sol";
|
import { Stores } from "../../common/stores.sol";
|
||||||
|
@ -12,7 +12,7 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
* @dev Claim Accrued COMP Token.
|
* @dev Claim Accrued COMP Token.
|
||||||
* @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 {
|
function ClaimComp(uint setId) external payable returns (bytes calldata) {
|
||||||
TokenInterface compToken = TokenInterface(getCompTokenAddress());
|
TokenInterface compToken = TokenInterface(getCompTokenAddress());
|
||||||
uint intialBal = compToken.balanceOf(address(this));
|
uint intialBal = compToken.balanceOf(address(this));
|
||||||
ComptrollerInterface(getComptrollerAddress()).claimComp(address(this));
|
ComptrollerInterface(getComptrollerAddress()).claimComp(address(this));
|
||||||
|
@ -21,11 +21,7 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
|
||||||
emit LogClaimedComp(amt, setId);
|
return encodeEvent("LogClaimedComp(uint256,uint256)", abi.encode(amt, setId));
|
||||||
bytes32 _eventCode = keccak256("LogClaimedComp(uint256,uint256)");
|
|
||||||
bytes memory _eventParam = abi.encode(amt, setId);
|
|
||||||
(uint _type, uint _id) = connectorID();
|
|
||||||
EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,7 +29,7 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
* @param tokens Array of tokens supplied and borrowed.
|
* @param tokens Array of tokens supplied and borrowed.
|
||||||
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
||||||
*/
|
*/
|
||||||
function ClaimCompTwo(address[] calldata tokens, uint setId) external payable {
|
function ClaimCompTwo(address[] calldata tokens, uint setId) external payable returns (bytes calldata) {
|
||||||
uint _len = tokens.length;
|
uint _len = tokens.length;
|
||||||
address[] memory ctokens = new address[](_len);
|
address[] memory ctokens = new address[](_len);
|
||||||
for (uint i = 0; i < _len; i++) {
|
for (uint i = 0; i < _len; i++) {
|
||||||
|
@ -48,11 +44,7 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
|
||||||
emit LogClaimedComp(amt, setId);
|
return encodeEvent("LogClaimedComp(uint256,uint256)", abi.encode(amt, setId));
|
||||||
bytes32 _eventCode = keccak256("LogClaimedComp(uint256,uint256)");
|
|
||||||
bytes memory _eventParam = abi.encode(amt, setId);
|
|
||||||
(uint _type, uint _id) = connectorID();
|
|
||||||
EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,7 +53,7 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
* @param borrowTokens Array of tokens borrowed.
|
* @param borrowTokens Array of tokens borrowed.
|
||||||
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
* @param setId Set ctoken amount at this ID in `InstaMemory` Contract.
|
||||||
*/
|
*/
|
||||||
function ClaimCompThree(address[] calldata supplyTokens, address[] calldata borrowTokens, uint setId) external payable {
|
function ClaimCompThree(address[] calldata supplyTokens, address[] calldata borrowTokens, uint setId) external payable returns (bytes calldata) {
|
||||||
(address[] memory ctokens, bool isBorrow, bool isSupply) = mergeTokenArr(supplyTokens, borrowTokens);
|
(address[] memory ctokens, bool isBorrow, bool isSupply) = mergeTokenArr(supplyTokens, borrowTokens);
|
||||||
|
|
||||||
address[] memory holders = new address[](1);
|
address[] memory holders = new address[](1);
|
||||||
|
@ -75,33 +67,23 @@ abstract contract CompResolver is Events, Helpers {
|
||||||
|
|
||||||
setUint(setId, amt);
|
setUint(setId, amt);
|
||||||
|
|
||||||
emit LogClaimedComp(amt, setId);
|
return encodeEvent("LogClaimedComp(uint256,uint256)", abi.encode(amt, setId));
|
||||||
bytes32 _eventCode = keccak256("LogClaimedComp(uint256,uint256)");
|
|
||||||
bytes memory _eventParam = abi.encode(amt, setId);
|
|
||||||
(uint _type, uint _id) = connectorID();
|
|
||||||
EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Delegate votes.
|
* @dev Delegate votes.
|
||||||
* @param delegatee The address to delegate votes to.
|
* @param delegatee The address to delegate votes to.
|
||||||
*/
|
*/
|
||||||
function delegate(address delegatee) external payable {
|
function delegate(address delegatee) external payable returns (bytes calldata) {
|
||||||
COMPInterface compToken = COMPInterface(getCompTokenAddress());
|
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);
|
||||||
|
|
||||||
emit LogDelegate(delegatee);
|
return encodeEvent("LogDelegate(address)", abi.encode(delegatee));
|
||||||
bytes32 _eventCode = keccak256("LogDelegate(address)");
|
|
||||||
bytes memory _eventParam = abi.encode(delegatee);
|
|
||||||
(uint _type, uint _id) = connectorID();
|
|
||||||
EventInterface(getEventAddr()).emitEvent(_type, _id, _eventCode, _eventParam);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectCOMP is CompResolver {
|
contract ConnectCOMP is CompResolver {
|
||||||
string public name = "COMP-v1";
|
string public name = "COMP-v1";
|
||||||
|
|
||||||
constructor(uint256 _id) Stores(_id) public {}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
pragma solidity ^0.6.0;
|
pragma solidity ^0.7.0;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
// import files from common directory
|
// import files from common directory
|
||||||
|
|
Loading…
Reference in New Issue
Block a user