-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
27,920 additions
and
14,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ node_modules | |
cache | ||
artifacts | ||
|
||
.env | ||
|
||
# IDE files | ||
.idea/ | ||
.code/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"printWidth": 120, | ||
"singleQuote": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "solhint:recommended", | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": "error", | ||
"avoid-throw": "off", | ||
"avoid-suicide": "error", | ||
"avoid-sha3": "warn", | ||
"compiler-version": ["error", "^0.8.10"], | ||
"reason-string": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
scripts/ | ||
test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,69 @@ | ||
// Be name Khoda | ||
// Bime Abolfazl | ||
|
||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity ^0.8.3; | ||
// ================================================================================================================= | ||
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| | | ||
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| | | ||
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| | | ||
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| | | ||
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| | | ||
// ================================================================================================================= | ||
// ================== DEUS Conductor ====================== | ||
// ======================================================== | ||
// DEUS Finance: https://github.com/deusfinance | ||
|
||
// Primary Author(s) | ||
// Vahid: https://github.com/vahid-dev | ||
|
||
import "@openzeppelin/contracts/access/AccessControl.sol"; | ||
pragma solidity ^0.8.11; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./interfaces/IConductor.sol"; | ||
import "./interfaces/IRegistrar.sol"; | ||
import "./Registrar.sol"; | ||
|
||
contract Conductor is AccessControl { | ||
mapping(string => address) public registrars; | ||
|
||
address public synchronizer; | ||
address public admin; | ||
address public liquidator; | ||
|
||
event Conduct(string _id, address short, address long); | ||
|
||
constructor(address _synchronizer, address _admin, address _liquidator) { | ||
synchronizer = _synchronizer; | ||
admin = _admin; | ||
liquidator = _liquidator; | ||
_setupRole(DEFAULT_ADMIN_ROLE, _admin); | ||
} | ||
|
||
function setAddresses(address _synchronizer, address _admin, address _liquidator) public{ | ||
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); | ||
liquidator = _liquidator; | ||
synchronizer = _synchronizer; | ||
admin = _admin; | ||
} | ||
|
||
function adminConduct( | ||
string memory _id, | ||
string memory shortName, | ||
string memory shortSymbol, | ||
string memory longName, | ||
string memory longSymbol | ||
)external{ | ||
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin"); | ||
Registrar short = new Registrar(admin, synchronizer, liquidator, shortName, shortSymbol); | ||
Registrar long = new Registrar(admin, synchronizer, liquidator, longName, longSymbol); | ||
|
||
registrars[_id] = address(long); | ||
|
||
emit conduct(_id, address(short), address(long)); | ||
} | ||
contract Conductor is IConductor, Ownable { | ||
address public roleChecker; | ||
|
||
constructor(address roleChecker_) { | ||
roleChecker = roleChecker_; | ||
} | ||
|
||
function setRoleChecker(address roleChecker_) external onlyOwner { | ||
roleChecker = roleChecker_; | ||
} | ||
|
||
function conduct( | ||
string memory _id, | ||
string memory shortName, | ||
string memory shortSymbol, | ||
string memory longName, | ||
string memory longSymbol, | ||
string memory version, | ||
uint256 registrarType | ||
) external returns (address, address) { | ||
Registrar short = new Registrar(roleChecker, shortName, shortSymbol, version, registrarType); | ||
Registrar long = new Registrar(roleChecker, longName, longSymbol, version, registrarType); | ||
|
||
emit Conducted(_id, address(short), address(long)); | ||
|
||
return (address(short), address(long)); | ||
} | ||
|
||
function liquidate( | ||
address registrar, | ||
string memory liquidatedName, | ||
string memory liquidatedSymbol, | ||
string memory version | ||
) external onlyOwner { | ||
string memory name = IRegistrar(registrar).name(); | ||
string memory symbol = IRegistrar(registrar).symbol(); | ||
uint256 registrarType = IRegistrar(registrar).registrarType(); | ||
IRegistrar(registrar).rename(liquidatedName, liquidatedSymbol); | ||
Registrar newRegistrar = new Registrar(roleChecker, name, symbol, version, registrarType); | ||
emit Liquidated(registrar, address(newRegistrar)); | ||
} | ||
} | ||
|
||
//Dar panah khoda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Be name Khoda | ||
// Bime Abolfazl | ||
// SPDX-License-Identifier: MIT | ||
|
||
// ================================================================================================================= | ||
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| | | ||
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| | | ||
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| | | ||
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| | | ||
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| | | ||
// ================================================================================================================= | ||
// ================== DEUS Partner Manager ================ | ||
// ======================================================== | ||
// DEUS Finance: https://github.com/deusfinance | ||
|
||
// Primary Author(s) | ||
// Vahid: https://github.com/vahid-dev | ||
// M.R.M: https://github.com/mrmousavi78 | ||
|
||
pragma solidity ^0.8.11; | ||
|
||
import "./interfaces/IPartnerManager.sol"; | ||
|
||
/// @title Partner Manager | ||
/// @author DEUS Finance | ||
/// @notice Partner manager for the Synchronizer | ||
contract PartnerManager is IPartnerManager { | ||
uint256[3] public platformFee; // trading fee set by DEUS DAO | ||
mapping(address => uint256[3]) public partnerFee; // partnerId => [stockFee, cryptoFee, forexFee] | ||
address public platform; // platform multisig address | ||
uint256 public scale = 1e18; // used for math | ||
mapping(address => bool) public isPartner; // partnership of address | ||
|
||
constructor(address platform_, uint256[3] memory platformFee_) { | ||
platform = platform_; | ||
platformFee = platformFee_; | ||
} | ||
|
||
/// @notice become a partner of DEUS DAO | ||
/// @dev fees (18 decimals) are expressed as multipliers, e.g. 1% should be inserted as 0.01 | ||
/// @param owner address of partner | ||
/// @param stockFee fee charged for stocks (e.g. 0.1%) | ||
/// @param cryptoFee fee charged for crypto (e.g. 0.1%) | ||
/// @param forexFee fee charged for forex (e.g. 0.1%) | ||
function addPartner( | ||
address owner, | ||
uint256 stockFee, | ||
uint256 cryptoFee, | ||
uint256 forexFee | ||
) external { | ||
require(!isPartner[owner], "PartnerManager: partner already exists"); | ||
require( | ||
stockFee < scale - platformFee[0] && | ||
cryptoFee < scale - platformFee[1] && | ||
forexFee < scale - platformFee[2], | ||
"PartnerManager: the total fee can not be GTE 100%" | ||
); | ||
isPartner[owner] = true; | ||
partnerFee[owner] = [stockFee, cryptoFee, forexFee]; | ||
emit PartnerAdded(owner, partnerFee[owner]); | ||
} | ||
} | ||
|
||
//Dar panah khoda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,61 @@ | ||
//Be name khoda | ||
//Bime Abolfazl | ||
|
||
// Be name Khoda | ||
// Bime Abolfazl | ||
// SPDX-License-Identifier: MIT | ||
|
||
// ================================================================================================================= | ||
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| | | ||
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| | | ||
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| | | ||
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| | | ||
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| | | ||
// ================================================================================================================= | ||
// ==================== DEUS Registrar ====================== | ||
// ========================================================== | ||
// DEUS Finance: https://github.com/deusfinance | ||
|
||
// Primary Author(s) | ||
// Vahid: https://github.com/vahid-dev | ||
|
||
pragma solidity ^0.8.3; | ||
|
||
import "@openzeppelin/contracts/access/AccessControl.sol"; | ||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./interfaces/IRoleChecker.sol"; | ||
import "./dERC20.sol"; | ||
|
||
contract Registrar is dERC20, AccessControl { | ||
|
||
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); | ||
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE"); | ||
bytes32 public constant LIQUIDATOR_ROLE = keccak256("LIQUIDATOR_ROLE"); | ||
contract Registrar is dERC20, Ownable { | ||
address public roleChecker; | ||
string public version; | ||
uint256 public registrarType; | ||
|
||
constructor( | ||
address roleChecker_, | ||
string memory name, | ||
string memory symbol, | ||
string memory version_, | ||
uint256 registrarType_ | ||
) dERC20(name, symbol) { | ||
roleChecker = roleChecker_; | ||
version = version_; | ||
registrarType = registrarType_; | ||
} | ||
|
||
constructor(address admin, address synchronizer, address liquidator, string memory name, string memory symbol) dERC20(name, symbol) { | ||
_setupRole(DEFAULT_ADMIN_ROLE, admin); | ||
_setupRole(MINTER_ROLE, synchronizer); | ||
_setupRole(BURNER_ROLE, synchronizer); | ||
_setupRole(LIQUIDATOR_ROLE, liquidator); | ||
} | ||
modifier hasRole() { | ||
require(IRoleChecker(roleChecker).verify(msg.sender), "Registrar: role is not verified"); | ||
_; | ||
} | ||
|
||
function rename(string memory name, string memory symbol) external { | ||
require(hasRole(LIQUIDATOR_ROLE, msg.sender), "Caller is not a liquidator"); | ||
_name = name; | ||
_symbol = symbol; | ||
} | ||
function rename(string memory name, string memory symbol) external hasRole { | ||
_name = name; | ||
_symbol = symbol; | ||
} | ||
|
||
function mint(address to, uint256 amount) external { | ||
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter"); | ||
function mint(address to, uint256 amount) external hasRole { | ||
_mint(to, amount); | ||
} | ||
|
||
function burn(address from, uint256 amount) external { | ||
require(hasRole(BURNER_ROLE, msg.sender), "Caller is not a burner"); | ||
function burn(address from, uint256 amount) external hasRole { | ||
_burn(from, amount); | ||
} | ||
|
||
} | ||
|
||
//Dar panah khoda |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Be name Khoda | ||
// Bime Abolfazl | ||
// SPDX-License-Identifier: MIT | ||
|
||
// ================================================================================================================= | ||
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| | | ||
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| | | ||
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| | | ||
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| | | ||
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| | | ||
// ================================================================================================================= | ||
// ==================== DEUS Role Checker =================== | ||
// ========================================================== | ||
// DEUS Finance: https://github.com/deusfinance | ||
|
||
// Primary Author(s) | ||
// Vahid: https://github.com/vahid-dev | ||
|
||
pragma solidity ^0.8.11; | ||
|
||
import "@openzeppelin/contracts/access/Ownable.sol"; | ||
import "./interfaces/IRoleChecker.sol"; | ||
|
||
contract RoleChecker is IRoleChecker, Ownable { | ||
mapping(address => bool) private hasRole; | ||
|
||
function verify(address caller) public view returns (bool) { | ||
return hasRole[caller]; | ||
} | ||
|
||
function grant(address user) external onlyOwner { | ||
hasRole[user] = true; | ||
} | ||
|
||
function revoke(address user) external onlyOwner { | ||
delete hasRole[user]; | ||
} | ||
} | ||
|
||
//Dar panah khoda |
Oops, something went wrong.