done with my changes

This commit is contained in:
Sowmay Jain 2020-09-07 14:51:20 +10:00
parent 9a99f87368
commit 051ba623e9
3 changed files with 36 additions and 10 deletions

View File

@ -3,13 +3,13 @@ pragma solidity ^0.6.8;
contract Deployer {
mapping (address => bool) public isFlusher;
mapping (address => bool) public flushers;
event LogNewProxy(address indexed owner, address indexed logic);
event LogNewFlusher(address indexed owner, address indexed flusher, address indexed logic);
// deploy create2 + minimal proxy
function deployLogic(address owner, address logic) public returns (address proxy) {
require(!(isFlusherDeployed(getAddress(owner, logic))), "Flusher-already-deployed");
require(!(isFlusherDeployed(getAddress(owner, logic))), "flusher-already-deployed");
bytes32 salt = keccak256(abi.encodePacked(owner));
bytes20 targetBytes = bytes20(logic);
// solium-disable-next-line security/no-inline-assembly
@ -26,8 +26,8 @@ contract Deployer {
)
proxy := create2(0, clone, 0x37, salt)
}
isFlusher[proxy] = true;
emit LogNewProxy(owner, logic);
flushers[proxy] = true;
emit LogNewFlusher(owner, proxy, logic);
}
function isFlusherDeployed(address _address) public view returns (bool) {

View File

@ -14,7 +14,7 @@ contract Flusher {
string constant public name = "Flusher-v1";
uint constant version = 1;
RegistryInterface public constant registry = RegistryInterface(address(0)); // TODO - Change while deploying.
RegistryInterface public constant registry = RegistryInterface(address(0)); // TODO - Change while deploying
function spell(address _target, bytes memory _data) internal {
require(_target != address(0), "target-invalid");

View File

@ -117,7 +117,7 @@ contract Registry {
/**
* @dev update pool rate logic
* @param _token pool address
* @param _token token address
* @param _newLogic new rate logic address
*/
function updatePoolLogic(address _token, address _newLogic) external isMaster {
@ -131,7 +131,7 @@ contract Registry {
/**
* @dev update flusher logic
* @param _token pool address
* @param _token token address
* @param _newLogic new flusher logic address
*/
function updateFlusherLogic(address _token, address _newLogic) external isMaster {
@ -145,7 +145,7 @@ contract Registry {
/**
* @dev update pool fee
* @param _token pool address
* @param _token token address
* @param _newFee new fee amount
*/
function updateFee(address _token, uint _newFee) external isMaster {
@ -159,7 +159,7 @@ contract Registry {
/**
* @dev update pool fee
* @param _token pool address
* @param _token token address
* @param _newCap new fee amount
*/
function updateCap(address _token, uint _newCap) external isMaster {
@ -169,6 +169,11 @@ contract Registry {
emit LogUpdateCap(_pool, _newCap);
}
/**
* @dev adding settlement logic
* @param _token token address
* @param _logic logic proxy
*/
function addSettleLogic(address _token, address _logic) external isMaster {
address _pool = poolToken[_token];
require(_pool != address(0), "invalid-pool");
@ -176,6 +181,11 @@ contract Registry {
emit LogAddSettleLogic(_pool, _logic);
}
/**
* @dev removing settlement logic
* @param _token token address
* @param _logic logic proxy
*/
function removeSettleLogic(address _token, address _logic) external isMaster {
address _pool = poolToken[_token];
require(_pool != address(0), "invalid-pool");
@ -183,6 +193,10 @@ contract Registry {
emit LogRemoveSettleLogic(_pool, _logic);
}
/**
* @dev enable pool connector
* @param _connector logic proxy
*/
function enableConnector(address _connector) external isChief {
require(!connectors[_connector], "already-enabled");
require(_connector != address(0), "invalid-connector");
@ -190,12 +204,20 @@ contract Registry {
emit LogConnectorEnable(_connector);
}
/**
* @dev disable pool connector
* @param _connector logic proxy
*/
function disableConnector(address _connector) external isChief {
require(connectors[_connector], "already-disabled");
delete connectors[_connector];
emit LogConnectorDisable(_connector);
}
/**
* @dev disable pool connector
* @param _connector logic proxy
*/
function checkSettleLogics(address _pool, address[] calldata _logics) external view returns(bool isOk) {
isOk = true;
for (uint i = 0; i < _logics.length; i++) {
@ -206,6 +228,10 @@ contract Registry {
}
}
/**
* @dev check if connectors are enabled
* @param _connectors array of logic proxy
*/
function isConnector(address[] calldata _connectors) external view returns (bool isOk) {
isOk = true;
for (uint i = 0; i < _connectors.length; i++) {