InstaContract/contracts/MoatResolver.sol

70 lines
1.5 KiB
Solidity
Raw Normal View History

pragma solidity ^0.4.24;
2018-10-26 20:55:26 +00:00
interface token {
2018-10-27 11:11:57 +00:00
function transfer(address receiver, uint amount) external returns (bool);
}
2018-10-27 11:11:57 +00:00
interface AddressRegistry {
function getAddr(string name) external returns(address);
2018-10-26 20:55:26 +00:00
}
contract Registry {
2018-10-26 20:55:26 +00:00
address public registryAddress;
modifier onlyAdmin() {
require(
msg.sender == getAddress("admin"),
"Permission Denied"
);
_;
}
2018-10-26 20:55:26 +00:00
function getAddress(string name) internal view returns(address addr) {
AddressRegistry aRegistry = AddressRegistry(registryAddress);
addr = aRegistry.getAddr(name);
require(addr != address(0), "Invalid Address");
}
2018-10-26 20:55:26 +00:00
}
2018-10-27 11:11:57 +00:00
contract FeeDetail is Registry {
uint public fees;
2018-10-27 11:11:57 +00:00
bool public feeBool;
2018-10-26 20:55:26 +00:00
function getFees() public view returns(uint, bool) {
2018-10-27 11:11:57 +00:00
return (fees, feeBool);
2018-10-26 20:55:26 +00:00
}
2018-10-27 11:11:57 +00:00
function enableFees() public onlyAdmin {
feeBool = true;
2018-10-26 20:55:26 +00:00
}
2018-10-27 11:11:57 +00:00
function disableFees() public onlyAdmin {
feeBool = false;
}
}
2018-10-27 11:11:57 +00:00
contract MoatResolver is FeeDetail {
function () public payable {}
constructor(address rAddr, uint cut) public { // 200 means 0.5%
2018-10-26 20:55:26 +00:00
registryAddress = rAddr;
fees = cut;
}
2018-10-27 12:07:21 +00:00
function collectToken(address tokenAddress, uint amount) public onlyAdmin {
2018-10-27 11:11:57 +00:00
if (tokenAddress == 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee) {
2018-10-26 20:55:26 +00:00
msg.sender.transfer(amount);
} else {
token tokenFunctions = token(tokenAddress);
tokenFunctions.transfer(msg.sender, amount);
}
}
}