Skip to content

Commit

Permalink
Merge branch 'release/v1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
xaero-coder committed Feb 13, 2022
2 parents 49bf335 + 0956691 commit dc99365
Show file tree
Hide file tree
Showing 38 changed files with 27,920 additions and 14,120 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ node_modules
cache
artifacts

.env

# IDE files
.idea/
.code/
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"semi": false,
"printWidth": 120,
"singleQuote": false
}
12 changes: 12 additions & 0 deletions .solhint.json
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"
}
}
3 changes: 3 additions & 0 deletions .solhintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
scripts/
test/
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# synchronizer smart contracts

Deus ecosystem synthetic tokens' market maker
DEUS Ecosystem AMM for Registrars

<p align="center">
<img width="200" height="200" src="https://legacy.deus.finance/tokens/sync5.png">
Expand All @@ -14,7 +14,7 @@ BSC | 0x3b62F3820e0B035cc4aD602dECe6d796BC325325
xDai | 0xc2fB644cd18325C58889Cf8BB0573e4a8774BCD2
Heco | 0xe82aa18b107aaf8D3829111C91CD0D133E0773DC

### Pre Requisites
### Prerequisites

You will need the following software on your machine:

Expand Down Expand Up @@ -52,4 +52,3 @@ For security concerns, please email [admin@deus.finance](mailto:admin@deus.finan
## License

[MIT](./LICENSE.md) © Mainframe Group Inc.

99 changes: 58 additions & 41 deletions contracts/Conductor.sol
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
64 changes: 64 additions & 0 deletions contracts/PartnerManager.sol
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
70 changes: 45 additions & 25 deletions contracts/Registrar.sol
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
40 changes: 40 additions & 0 deletions contracts/RoleChecker.sol
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
Loading

0 comments on commit dc99365

Please sign in to comment.