mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
Merge pull request #46 from Instadapp/feat/instadapp-governance-connector
Add Instadapp governance connector
This commit is contained in:
commit
e6be1f1c92
6
contracts/mainnet/connectors/INST/events.sol
Normal file
6
contracts/mainnet/connectors/INST/events.sol
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
contract Events {
|
||||||
|
event LogVoteCast(uint256 proposalId, uint256 support, string reason);
|
||||||
|
event LogDelegate(address delegatee);
|
||||||
|
}
|
18
contracts/mainnet/connectors/INST/helpers.sol
Normal file
18
contracts/mainnet/connectors/INST/helpers.sol
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
import { DSMath } from "../../common/math.sol";
|
||||||
|
import { Basic } from "../../common/basic.sol";
|
||||||
|
import { InstaTokenInterface, InstaGovernorInterface } from "./interface.sol";
|
||||||
|
|
||||||
|
abstract contract Helpers is DSMath, Basic {
|
||||||
|
/**
|
||||||
|
* @dev InstaGovernorBravo
|
||||||
|
*/
|
||||||
|
InstaGovernorInterface internal constant instaGovernor = InstaGovernorInterface(0x0204Cd037B2ec03605CFdFe482D8e257C765fA1B);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev INST Token
|
||||||
|
*/
|
||||||
|
InstaTokenInterface internal constant instToken = InstaTokenInterface(0x6f40d4A6237C257fff2dB00FA0510DeEECd303eb);
|
||||||
|
}
|
10
contracts/mainnet/connectors/INST/interface.sol
Normal file
10
contracts/mainnet/connectors/INST/interface.sol
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
|
||||||
|
interface InstaGovernorInterface {
|
||||||
|
function castVoteWithReason(uint proposalId, uint8 support, string calldata reason) external;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InstaTokenInterface {
|
||||||
|
function delegate(address delegatee) external;
|
||||||
|
function delegates(address) external view returns(address);
|
||||||
|
}
|
60
contracts/mainnet/connectors/INST/main.sol
Normal file
60
contracts/mainnet/connectors/INST/main.sol
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
pragma solidity ^0.7.0;
|
||||||
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @title Instadapp Governance.
|
||||||
|
* @dev Governance.
|
||||||
|
*/
|
||||||
|
import { TokenInterface } from "../../common/interfaces.sol";
|
||||||
|
import { Stores } from "../../common/stores.sol";
|
||||||
|
import { Helpers } from "./helpers.sol";
|
||||||
|
import { Events } from "./events.sol";
|
||||||
|
|
||||||
|
abstract contract Resolver is Events, Helpers {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Delegate votes.
|
||||||
|
* @notice Delegating votes to delegatee.
|
||||||
|
* @param delegatee The address to delegate the votes.
|
||||||
|
*/
|
||||||
|
function delegate(address delegatee) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
require(instToken.delegates(address(this)) != delegatee, "Already delegated to same delegatee.");
|
||||||
|
|
||||||
|
instToken.delegate(delegatee);
|
||||||
|
|
||||||
|
_eventName = "LogDelegate(address)";
|
||||||
|
_eventParam = abi.encode(delegatee);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Cast vote.
|
||||||
|
* @notice Casting vote for a proposal
|
||||||
|
* @param proposalId The id of the proposal to vote on
|
||||||
|
* @param support The support value for the vote. 0=against, 1=for, 2=abstain
|
||||||
|
*/
|
||||||
|
function voteCast(uint256 proposalId, uint256 support) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
instaGovernor.castVoteWithReason(proposalId, uint8(support), "");
|
||||||
|
|
||||||
|
_eventName = "LogVoteCast(uint256,uint256,string)";
|
||||||
|
_eventParam = abi.encode(proposalId, support, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev Cast vote with reason.
|
||||||
|
* @notice Casting vote for a proposal
|
||||||
|
* @param proposalId The id of the proposal to vote on
|
||||||
|
* @param support The support value for the vote. 0=against, 1=for, 2=abstain
|
||||||
|
* @param reason The reason given for the vote
|
||||||
|
*/
|
||||||
|
function voteCastWithReason(uint256 proposalId, uint256 support, string calldata reason) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
|
instaGovernor.castVoteWithReason(proposalId, uint8(support), reason);
|
||||||
|
|
||||||
|
_eventName = "LogVoteCast(uint256,uint256,string)";
|
||||||
|
_eventParam = abi.encode(proposalId, support, reason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
contract ConnectV2InstadappGovernanceBravo is Resolver {
|
||||||
|
string public constant name = "Instadapp-governance-bravo-v1";
|
||||||
|
}
|
|
@ -19,7 +19,8 @@
|
||||||
"COMPOUND-IMPORT-B": "0xdA101870ca6136539628F28041E1B55baf4EB6C0",
|
"COMPOUND-IMPORT-B": "0xdA101870ca6136539628F28041E1B55baf4EB6C0",
|
||||||
"INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2",
|
"INSTAPOOL-A": "0x5806Af7AB22E2916fA582Ff05731Bf7C682387B2",
|
||||||
"MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8",
|
"MAKERDAO-CLAIM-A": "0x2f8cBE650af98602a215b6482F2aD60893C5A4E8",
|
||||||
"WETH-A": "0x22075fa719eFb02Ca3cF298AFa9C974B7465E5D3"
|
"WETH-A": "0x22075fa719eFb02Ca3cF298AFa9C974B7465E5D3",
|
||||||
|
"INST-A": "0x52C2C4a0db049255fF345EB9D3Fb1f555b7a924A"
|
||||||
},
|
},
|
||||||
"137" : {
|
"137" : {
|
||||||
"AAVE-V2-A": "0xE84d8010Afc3663919F44685cB53ED88866da3eE",
|
"AAVE-V2-A": "0xE84d8010Afc3663919F44685cB53ED88866da3eE",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user