Skip to content

Commit

Permalink
refactor files
Browse files Browse the repository at this point in the history
  • Loading branch information
crisgarner committed Aug 12, 2021
1 parent 973ff36 commit 6707924
Show file tree
Hide file tree
Showing 14 changed files with 1,042 additions and 30 deletions.
1 change: 1 addition & 0 deletions hevm.libs.I6fvF
Submodule hevm.libs.I6fvF added at bae462
1 change: 1 addition & 0 deletions hevm.libs.TfyzQ
Submodule hevm.libs.TfyzQ added at 0b537f
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"hardhat-deploy": "^0.8.11",
"prettier": "^2.3.2",
"prettier-plugin-solidity": "^1.0.0-beta.17",
"pretty-quick": "^3.1.1",
"typescript": "^4.3.5"
}
}
4 changes: 2 additions & 2 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ds-test/=lib/ds-test/src/
ds-test=lib/ds-test/src/index.sol
openzeppelin/=lib/openzeppelin-contracts/contracts/
openzeppelin=lib/openzeppelin-contracts/contracts/index.sol
@openzeppelin/=lib/openzeppelin-contracts/contracts/
@openzeppelin=lib/openzeppelin-contracts/contracts/index.sol
24 changes: 24 additions & 0 deletions src/Delegator.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import "@openzeppelin/access/Ownable.sol";
import "./interfaces/IGovernanceToken.sol";

/**
* @title Delegator Contract
* @author Cryptex.Finance
* @notice Contract in charge of handling delegations.
*/

contract Delegator is Ownable {
address public immutable token;

constructor(address delegatee_, address token_) {
token = token_;
IGovernanceToken(token_).delegate(delegatee_);
}

function delegatee() public returns (address) {
return IGovernanceToken(token).delegates(address(this));
}
}
35 changes: 35 additions & 0 deletions src/DelegatorFactory.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

import "@openzeppelin/access/Ownable.sol";
import "./interfaces/IGovernanceToken.sol";
import "./Delegator.sol";

/**
* @title Delegator Contract Factory
* @author Cryptex.Finance
* @notice Contract in charge of generating Delegator contracts, handling delegations and CTX balance map, rewards.
*/

contract DelegatorFactory is Ownable {
address public immutable token;
mapping(address => address) public delegatorToDelegatee;
mapping(address => address) public delegateeToDelegator;

constructor(address token_) {
token = token_;
}

function createDelegator(address delegatee_) public {
require(delegatee_ != address(0), "Delegatee can't be 0");
require(
delegateeToDelegator[delegatee_] == address(0),
"Delegator already created"
);
Delegator delegator = new Delegator(delegatee_, token);
delegateeToDelegator[delegatee_] = address(delegator);
delegatorToDelegatee[address(delegator)] = delegatee_;
}

// function stake(uint256 amount_) public onlyOwner {}
}
4 changes: 0 additions & 4 deletions src/GovernanceStaking.sol

This file was deleted.

21 changes: 0 additions & 21 deletions src/GovernanceStaking.t.sol

This file was deleted.

8 changes: 8 additions & 0 deletions src/interfaces/IGovernanceToken.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.6;

interface IGovernanceToken {
function delegate(address delegatee) external;

function delegates(address delegator) external returns (address);
}
Loading

0 comments on commit 6707924

Please sign in to comment.