Skip to content
This repository was archived by the owner on May 7, 2025. It is now read-only.

Commit dc99365

Browse files
committed
Merge branch 'release/v1.1.0'
2 parents 49bf335 + 0956691 commit dc99365

38 files changed

+27920
-14120
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ node_modules
44
cache
55
artifacts
66

7+
.env
8+
79
# IDE files
810
.idea/
911
.code/

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"semi": false,
3+
"printWidth": 120,
4+
"singleQuote": false
5+
}

.solhint.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "solhint:recommended",
3+
"plugins": ["prettier"],
4+
"rules": {
5+
"prettier/prettier": "error",
6+
"avoid-throw": "off",
7+
"avoid-suicide": "error",
8+
"avoid-sha3": "warn",
9+
"compiler-version": ["error", "^0.8.10"],
10+
"reason-string": "off"
11+
}
12+
}

.solhintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
scripts/
3+
test/

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# synchronizer smart contracts
22

3-
Deus ecosystem synthetic tokens' market maker
3+
DEUS Ecosystem AMM for Registrars
44

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

17-
### Pre Requisites
17+
### Prerequisites
1818

1919
You will need the following software on your machine:
2020

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

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

contracts/Conductor.sol

Lines changed: 58 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,69 @@
11
// Be name Khoda
22
// Bime Abolfazl
3-
43
// SPDX-License-Identifier: MIT
54

6-
pragma solidity ^0.8.3;
5+
// =================================================================================================================
6+
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| |
7+
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| |
8+
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| |
9+
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| |
10+
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| |
11+
// =================================================================================================================
12+
// ================== DEUS Conductor ======================
13+
// ========================================================
14+
// DEUS Finance: https://github.com/deusfinance
15+
16+
// Primary Author(s)
17+
// Vahid: https://github.com/vahid-dev
718

8-
import "@openzeppelin/contracts/access/AccessControl.sol";
19+
pragma solidity ^0.8.11;
20+
21+
import "@openzeppelin/contracts/access/Ownable.sol";
22+
import "./interfaces/IConductor.sol";
23+
import "./interfaces/IRegistrar.sol";
924
import "./Registrar.sol";
1025

11-
contract Conductor is AccessControl {
12-
mapping(string => address) public registrars;
13-
14-
address public synchronizer;
15-
address public admin;
16-
address public liquidator;
17-
18-
event Conduct(string _id, address short, address long);
19-
20-
constructor(address _synchronizer, address _admin, address _liquidator) {
21-
synchronizer = _synchronizer;
22-
admin = _admin;
23-
liquidator = _liquidator;
24-
_setupRole(DEFAULT_ADMIN_ROLE, _admin);
25-
}
26-
27-
function setAddresses(address _synchronizer, address _admin, address _liquidator) public{
28-
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin");
29-
liquidator = _liquidator;
30-
synchronizer = _synchronizer;
31-
admin = _admin;
32-
}
33-
34-
function adminConduct(
35-
string memory _id,
36-
string memory shortName,
37-
string memory shortSymbol,
38-
string memory longName,
39-
string memory longSymbol
40-
)external{
41-
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Caller is not an admin");
42-
Registrar short = new Registrar(admin, synchronizer, liquidator, shortName, shortSymbol);
43-
Registrar long = new Registrar(admin, synchronizer, liquidator, longName, longSymbol);
44-
45-
registrars[_id] = address(long);
46-
47-
emit conduct(_id, address(short), address(long));
48-
}
26+
contract Conductor is IConductor, Ownable {
27+
address public roleChecker;
28+
29+
constructor(address roleChecker_) {
30+
roleChecker = roleChecker_;
31+
}
32+
33+
function setRoleChecker(address roleChecker_) external onlyOwner {
34+
roleChecker = roleChecker_;
35+
}
36+
37+
function conduct(
38+
string memory _id,
39+
string memory shortName,
40+
string memory shortSymbol,
41+
string memory longName,
42+
string memory longSymbol,
43+
string memory version,
44+
uint256 registrarType
45+
) external returns (address, address) {
46+
Registrar short = new Registrar(roleChecker, shortName, shortSymbol, version, registrarType);
47+
Registrar long = new Registrar(roleChecker, longName, longSymbol, version, registrarType);
48+
49+
emit Conducted(_id, address(short), address(long));
50+
51+
return (address(short), address(long));
52+
}
4953

54+
function liquidate(
55+
address registrar,
56+
string memory liquidatedName,
57+
string memory liquidatedSymbol,
58+
string memory version
59+
) external onlyOwner {
60+
string memory name = IRegistrar(registrar).name();
61+
string memory symbol = IRegistrar(registrar).symbol();
62+
uint256 registrarType = IRegistrar(registrar).registrarType();
63+
IRegistrar(registrar).rename(liquidatedName, liquidatedSymbol);
64+
Registrar newRegistrar = new Registrar(roleChecker, name, symbol, version, registrarType);
65+
emit Liquidated(registrar, address(newRegistrar));
66+
}
5067
}
5168

5269
//Dar panah khoda

contracts/PartnerManager.sol

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Be name Khoda
2+
// Bime Abolfazl
3+
// SPDX-License-Identifier: MIT
4+
5+
// =================================================================================================================
6+
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| |
7+
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| |
8+
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| |
9+
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| |
10+
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| |
11+
// =================================================================================================================
12+
// ================== DEUS Partner Manager ================
13+
// ========================================================
14+
// DEUS Finance: https://github.com/deusfinance
15+
16+
// Primary Author(s)
17+
// Vahid: https://github.com/vahid-dev
18+
// M.R.M: https://github.com/mrmousavi78
19+
20+
pragma solidity ^0.8.11;
21+
22+
import "./interfaces/IPartnerManager.sol";
23+
24+
/// @title Partner Manager
25+
/// @author DEUS Finance
26+
/// @notice Partner manager for the Synchronizer
27+
contract PartnerManager is IPartnerManager {
28+
uint256[3] public platformFee; // trading fee set by DEUS DAO
29+
mapping(address => uint256[3]) public partnerFee; // partnerId => [stockFee, cryptoFee, forexFee]
30+
address public platform; // platform multisig address
31+
uint256 public scale = 1e18; // used for math
32+
mapping(address => bool) public isPartner; // partnership of address
33+
34+
constructor(address platform_, uint256[3] memory platformFee_) {
35+
platform = platform_;
36+
platformFee = platformFee_;
37+
}
38+
39+
/// @notice become a partner of DEUS DAO
40+
/// @dev fees (18 decimals) are expressed as multipliers, e.g. 1% should be inserted as 0.01
41+
/// @param owner address of partner
42+
/// @param stockFee fee charged for stocks (e.g. 0.1%)
43+
/// @param cryptoFee fee charged for crypto (e.g. 0.1%)
44+
/// @param forexFee fee charged for forex (e.g. 0.1%)
45+
function addPartner(
46+
address owner,
47+
uint256 stockFee,
48+
uint256 cryptoFee,
49+
uint256 forexFee
50+
) external {
51+
require(!isPartner[owner], "PartnerManager: partner already exists");
52+
require(
53+
stockFee < scale - platformFee[0] &&
54+
cryptoFee < scale - platformFee[1] &&
55+
forexFee < scale - platformFee[2],
56+
"PartnerManager: the total fee can not be GTE 100%"
57+
);
58+
isPartner[owner] = true;
59+
partnerFee[owner] = [stockFee, cryptoFee, forexFee];
60+
emit PartnerAdded(owner, partnerFee[owner]);
61+
}
62+
}
63+
64+
//Dar panah khoda

contracts/Registrar.sol

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,61 @@
1-
//Be name khoda
2-
//Bime Abolfazl
3-
1+
// Be name Khoda
2+
// Bime Abolfazl
43
// SPDX-License-Identifier: MIT
54

5+
// =================================================================================================================
6+
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| |
7+
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| |
8+
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| |
9+
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| |
10+
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| |
11+
// =================================================================================================================
12+
// ==================== DEUS Registrar ======================
13+
// ==========================================================
14+
// DEUS Finance: https://github.com/deusfinance
15+
16+
// Primary Author(s)
17+
// Vahid: https://github.com/vahid-dev
18+
619
pragma solidity ^0.8.3;
720

8-
import "@openzeppelin/contracts/access/AccessControl.sol";
21+
import "@openzeppelin/contracts/access/Ownable.sol";
22+
import "./interfaces/IRoleChecker.sol";
923
import "./dERC20.sol";
1024

11-
contract Registrar is dERC20, AccessControl {
12-
13-
bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");
14-
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
15-
bytes32 public constant LIQUIDATOR_ROLE = keccak256("LIQUIDATOR_ROLE");
25+
contract Registrar is dERC20, Ownable {
26+
address public roleChecker;
27+
string public version;
28+
uint256 public registrarType;
29+
30+
constructor(
31+
address roleChecker_,
32+
string memory name,
33+
string memory symbol,
34+
string memory version_,
35+
uint256 registrarType_
36+
) dERC20(name, symbol) {
37+
roleChecker = roleChecker_;
38+
version = version_;
39+
registrarType = registrarType_;
40+
}
1641

17-
constructor(address admin, address synchronizer, address liquidator, string memory name, string memory symbol) dERC20(name, symbol) {
18-
_setupRole(DEFAULT_ADMIN_ROLE, admin);
19-
_setupRole(MINTER_ROLE, synchronizer);
20-
_setupRole(BURNER_ROLE, synchronizer);
21-
_setupRole(LIQUIDATOR_ROLE, liquidator);
22-
}
42+
modifier hasRole() {
43+
require(IRoleChecker(roleChecker).verify(msg.sender), "Registrar: role is not verified");
44+
_;
45+
}
2346

24-
function rename(string memory name, string memory symbol) external {
25-
require(hasRole(LIQUIDATOR_ROLE, msg.sender), "Caller is not a liquidator");
26-
_name = name;
27-
_symbol = symbol;
28-
}
47+
function rename(string memory name, string memory symbol) external hasRole {
48+
_name = name;
49+
_symbol = symbol;
50+
}
2951

30-
function mint(address to, uint256 amount) external {
31-
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter");
52+
function mint(address to, uint256 amount) external hasRole {
3253
_mint(to, amount);
3354
}
3455

35-
function burn(address from, uint256 amount) external {
36-
require(hasRole(BURNER_ROLE, msg.sender), "Caller is not a burner");
56+
function burn(address from, uint256 amount) external hasRole {
3757
_burn(from, amount);
3858
}
39-
4059
}
60+
4161
//Dar panah khoda

contracts/RoleChecker.sol

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Be name Khoda
2+
// Bime Abolfazl
3+
// SPDX-License-Identifier: MIT
4+
5+
// =================================================================================================================
6+
// _|_|_| _|_|_|_| _| _| _|_|_| _|_|_|_| _| |
7+
// _| _| _| _| _| _| _| _|_|_| _|_|_| _|_|_| _|_|_| _|_| |
8+
// _| _| _|_|_| _| _| _|_| _|_|_| _| _| _| _| _| _| _| _| _|_|_|_| |
9+
// _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| _| |
10+
// _|_|_| _|_|_|_| _|_| _|_|_| _| _| _| _| _|_|_| _| _| _|_|_| _|_|_| |
11+
// =================================================================================================================
12+
// ==================== DEUS Role Checker ===================
13+
// ==========================================================
14+
// DEUS Finance: https://github.com/deusfinance
15+
16+
// Primary Author(s)
17+
// Vahid: https://github.com/vahid-dev
18+
19+
pragma solidity ^0.8.11;
20+
21+
import "@openzeppelin/contracts/access/Ownable.sol";
22+
import "./interfaces/IRoleChecker.sol";
23+
24+
contract RoleChecker is IRoleChecker, Ownable {
25+
mapping(address => bool) private hasRole;
26+
27+
function verify(address caller) public view returns (bool) {
28+
return hasRole[caller];
29+
}
30+
31+
function grant(address user) external onlyOwner {
32+
hasRole[user] = true;
33+
}
34+
35+
function revoke(address user) external onlyOwner {
36+
delete hasRole[user];
37+
}
38+
}
39+
40+
//Dar panah khoda

0 commit comments

Comments
 (0)