2020-08-22 03:07:55 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
pragma solidity ^0.6.8;
|
|
|
|
pragma experimental ABIEncoderV2;
|
|
|
|
|
|
|
|
interface IndexInterface {
|
|
|
|
function master() external view returns (address);
|
|
|
|
}
|
|
|
|
|
|
|
|
contract Registry {
|
|
|
|
|
|
|
|
event LogAddChief(address indexed chief);
|
|
|
|
event LogRemoveChief(address indexed chief);
|
2020-09-12 20:38:43 +00:00
|
|
|
event LogUpdatePoolLogic(address pool, address newLogic);
|
|
|
|
event LogUpdateFee(address pool, uint newFee);
|
|
|
|
event LogUpdateCap(address pool, uint newCap);
|
|
|
|
event LogAddSettleLogic(address indexed pool, address indexed logic);
|
|
|
|
event LogRemoveSettleLogic(address indexed pool, address indexed logic);
|
2020-08-22 03:07:55 +00:00
|
|
|
|
2020-08-24 00:40:01 +00:00
|
|
|
IndexInterface public constant instaIndex = IndexInterface(0x2971AdFa57b20E5a416aE5a708A8655A9c74f723);
|
2020-08-22 03:07:55 +00:00
|
|
|
|
|
|
|
mapping (address => bool) public chief;
|
2020-08-24 00:40:01 +00:00
|
|
|
mapping (address => address) public poolLogic;
|
|
|
|
mapping (address => uint) public poolCap;
|
2020-09-06 15:19:39 +00:00
|
|
|
mapping (address => uint) public fee;
|
2020-09-06 12:08:29 +00:00
|
|
|
mapping (address => mapping(address => bool)) public settleLogic;
|
2020-08-22 03:07:55 +00:00
|
|
|
|
|
|
|
modifier isMaster() {
|
|
|
|
require(msg.sender == instaIndex.master(), "not-master");
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2020-08-24 00:40:01 +00:00
|
|
|
modifier isChief() {
|
2020-08-22 03:07:55 +00:00
|
|
|
require(chief[msg.sender] || msg.sender == instaIndex.master(), "not-chief");
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Enable New Chief.
|
|
|
|
* @param _chief Address of the new chief.
|
|
|
|
*/
|
|
|
|
function enableChief(address _chief) external isMaster {
|
2020-08-24 00:40:01 +00:00
|
|
|
require(_chief != address(0), "address-not-valid");
|
|
|
|
require(!chief[_chief], "chief-already-enabled");
|
|
|
|
chief[_chief] = true;
|
|
|
|
emit LogAddChief(_chief);
|
2020-08-22 03:07:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dev Disable Chief.
|
|
|
|
* @param _chief Address of the existing chief.
|
|
|
|
*/
|
|
|
|
function disableChief(address _chief) external isMaster {
|
2020-08-24 00:40:01 +00:00
|
|
|
require(_chief != address(0), "address-not-valid");
|
|
|
|
require(chief[_chief], "chief-already-disabled");
|
|
|
|
delete chief[_chief];
|
|
|
|
emit LogRemoveChief(_chief);
|
|
|
|
}
|
|
|
|
|
2020-08-30 19:12:23 +00:00
|
|
|
/**
|
|
|
|
* @dev update pool rate logic
|
2020-09-10 17:47:19 +00:00
|
|
|
* @param _pool pool address
|
2020-08-30 19:12:23 +00:00
|
|
|
* @param _newLogic new rate logic address
|
|
|
|
*/
|
2020-09-10 17:47:19 +00:00
|
|
|
function updatePoolLogic(address _pool, address _newLogic) external isMaster {
|
2020-09-06 15:19:39 +00:00
|
|
|
require(_pool != address(0), "invalid-pool");
|
2020-08-24 17:33:44 +00:00
|
|
|
require(_newLogic != address(0), "invalid-address");
|
2020-09-06 16:01:27 +00:00
|
|
|
require(poolLogic[_pool] != _newLogic, "same-pool-logic");
|
2020-08-24 00:40:01 +00:00
|
|
|
poolLogic[_pool] = _newLogic;
|
|
|
|
emit LogUpdatePoolLogic(_pool, _newLogic);
|
|
|
|
}
|
|
|
|
|
2020-08-30 19:12:23 +00:00
|
|
|
/**
|
2020-09-06 15:19:39 +00:00
|
|
|
* @dev update pool fee
|
2020-09-10 17:47:19 +00:00
|
|
|
* @param _pool pool address
|
2020-09-06 15:19:39 +00:00
|
|
|
* @param _newFee new fee amount
|
2020-08-30 19:12:23 +00:00
|
|
|
*/
|
2020-09-10 17:47:19 +00:00
|
|
|
function updateFee(address _pool, uint _newFee) external isMaster {
|
2020-09-06 15:19:39 +00:00
|
|
|
require(_pool != address(0), "invalid-pool");
|
|
|
|
require(_newFee < 3 * 10 ** 17, "insure-fee-limit-reached");
|
|
|
|
require(fee[_pool] != _newFee, "same-pool-fee");
|
|
|
|
fee[_pool] = _newFee;
|
|
|
|
emit LogUpdateFee(_pool, _newFee);
|
|
|
|
}
|
|
|
|
|
2020-09-06 16:01:27 +00:00
|
|
|
/**
|
2020-09-12 20:42:28 +00:00
|
|
|
* @dev update pool cap
|
2020-09-10 17:47:19 +00:00
|
|
|
* @param _pool pool address
|
2020-09-12 20:42:28 +00:00
|
|
|
* @param _newCap new cap amount
|
2020-09-06 16:01:27 +00:00
|
|
|
*/
|
2020-09-10 17:47:19 +00:00
|
|
|
function updateCap(address _pool, uint _newCap) external isMaster {
|
2020-09-06 16:01:27 +00:00
|
|
|
require(_pool != address(0), "invalid-pool");
|
|
|
|
poolCap[_pool] = _newCap;
|
|
|
|
emit LogUpdateCap(_pool, _newCap);
|
|
|
|
}
|
|
|
|
|
2020-09-07 04:51:20 +00:00
|
|
|
/**
|
|
|
|
* @dev adding settlement logic
|
2020-09-10 17:47:19 +00:00
|
|
|
* @param _pool pool address
|
2020-09-07 04:51:20 +00:00
|
|
|
* @param _logic logic proxy
|
|
|
|
*/
|
2020-09-10 17:47:19 +00:00
|
|
|
function addSettleLogic(address _pool, address _logic) external isMaster {
|
2020-09-06 15:19:39 +00:00
|
|
|
require(_pool != address(0), "invalid-pool");
|
2020-09-12 20:42:28 +00:00
|
|
|
require(!settleLogic[_pool][_logic], "already-settle-added");
|
2020-09-06 12:08:29 +00:00
|
|
|
settleLogic[_pool][_logic] = true;
|
|
|
|
emit LogAddSettleLogic(_pool, _logic);
|
|
|
|
}
|
|
|
|
|
2020-09-07 04:51:20 +00:00
|
|
|
/**
|
|
|
|
* @dev removing settlement logic
|
2020-09-10 17:47:19 +00:00
|
|
|
* @param _pool pool address
|
2020-09-07 04:51:20 +00:00
|
|
|
* @param _logic logic proxy
|
|
|
|
*/
|
2020-09-10 17:47:19 +00:00
|
|
|
function removeSettleLogic(address _pool, address _logic) external isMaster {
|
2020-09-06 15:19:39 +00:00
|
|
|
require(_pool != address(0), "invalid-pool");
|
2020-09-12 20:42:28 +00:00
|
|
|
require(settleLogic[_pool][_logic], "already-settle-removed");
|
2020-09-06 12:08:29 +00:00
|
|
|
delete settleLogic[_pool][_logic];
|
|
|
|
emit LogRemoveSettleLogic(_pool, _logic);
|
|
|
|
}
|
|
|
|
|
2020-09-07 04:51:20 +00:00
|
|
|
/**
|
2020-09-07 10:09:51 +00:00
|
|
|
* @dev check if settle logics are enabled
|
|
|
|
* @param _pool token pool address
|
|
|
|
* @param _logics array of logic proxy
|
2020-09-07 04:51:20 +00:00
|
|
|
*/
|
2020-09-06 22:05:09 +00:00
|
|
|
function checkSettleLogics(address _pool, address[] calldata _logics) external view returns(bool isOk) {
|
|
|
|
isOk = true;
|
2020-09-06 12:08:29 +00:00
|
|
|
for (uint i = 0; i < _logics.length; i++) {
|
|
|
|
if (!settleLogic[_pool][_logics[i]]) {
|
2020-09-06 22:05:09 +00:00
|
|
|
isOk = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-24 00:40:01 +00:00
|
|
|
constructor(address _chief) public {
|
|
|
|
chief[_chief] = true;
|
|
|
|
emit LogAddChief(_chief);
|
2020-09-12 10:05:49 +00:00
|
|
|
}
|
2020-08-22 03:07:55 +00:00
|
|
|
}
|