编译器
0.6.12+commit.27d51765
文件 1 的 17:AccessControl.sol
pragma solidity ^0.6.0;
import "../utils/EnumerableSet.sol";
import "../utils/Address.sol";
import "../GSN/Context.sol";
abstract contract AccessControl is Context {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
function hasRole(bytes32 role, address account) public view returns (bool) {
return _roles[role].members.contains(account);
}
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
function grantRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");
_grantRole(role, account);
}
function revokeRole(bytes32 role, address account) public virtual {
require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");
_revokeRole(role, account);
}
function renounceRole(bytes32 role, address account) public virtual {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, _msgSender());
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, _msgSender());
}
}
}
文件 2 的 17:Address.sol
pragma solidity ^0.6.2;
library Address {
function isContract(address account) internal view returns (bool) {
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{ value: amount }("");
require(success, "Address: unable to send value, recipient may have reverted");
}
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
return _functionCallWithValue(target, data, 0, errorMessage);
}
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
return _functionCallWithValue(target, data, value, errorMessage);
}
function _functionCallWithValue(address target, bytes memory data, uint256 weiValue, string memory errorMessage) private returns (bytes memory) {
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{ value: weiValue }(data);
if (success) {
return returndata;
} else {
if (returndata.length > 0) {
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
文件 3 的 17:BoringDAOV2.sol
pragma solidity ^0.6.12;
import "./interface/IBoringDAO.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/utils/Pausable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
import "./interface/IAddressResolver.sol";
import "./interface/ITunnel.sol";
import "./ParamBook.sol";
import "./lib/SafeDecimalMath.sol";
import "./interface/IMintProposal.sol";
import "./interface/IOracle.sol";
import "./interface/ITrusteeFeePool.sol";
contract BoringDAOV2 is AccessControl, IBoringDAO, Pausable {
using SafeDecimalMath for uint256;
using SafeMath for uint256;
uint256 public amountByMint=12250000e18;
bytes32 public constant MONITOR_ROLE = "MONITOR_ROLE ";
bytes32 public constant GOV_ROLE = "GOV_ROLE";
bytes32 public constant BOR = "BORING";
bytes32 public constant PARAM_BOOK = "ParamBook";
bytes32 public constant MINT_PROPOSAL = "MintProposal";
bytes32 public constant ORACLE = "Oracle";
bytes32 public constant TRUSTEE_FEE_POOL = "TrusteeFeePool";
bytes32 public constant OTOKEN = "oToken";
bytes32 public constant TUNNEL_MINT_FEE_RATE = "mint_fee";
bytes32 public constant NETWORK_FEE = "network_fee";
IAddressResolver public addrReso;
ITunnelV2[] public tunnels;
uint256 public mintCap;
address public mine;
mapping(string=>bool) public approveFlag;
uint public reductionAmount=100000000e18;
mapping(bytes32=>uint) public minMintAmount;
constructor(IAddressResolver _addrReso, uint _mintCap, address _mine) public {
addrReso = _addrReso;
mintCap = _mintCap;
mine = _mine;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setupRole(MONITOR_ROLE, msg.sender);
}
function tunnel(bytes32 tunnelKey) internal view returns (ITunnel) {
return ITunnel(addrReso.key2address(tunnelKey));
}
function otoken(bytes32 _tunnelKey) internal view returns (IERC20) {
return IERC20(addrReso.requireKKAddrs(_tunnelKey, OTOKEN, "oToken not exist"));
}
function borERC20() internal view returns (IERC20) {
return IERC20(addrReso.key2address(BOR));
}
function paramBook() internal view returns (ParamBook) {
return ParamBook(addrReso.key2address(PARAM_BOOK));
}
function mintProposal() internal view returns (IMintProposal) {
return IMintProposal(addrReso.key2address(MINT_PROPOSAL));
}
function oracle() internal view returns (IOracle) {
return IOracle(addrReso.key2address(ORACLE));
}
function trusteeFeePool(bytes32 _tunnelKey) internal view returns (ITrusteeFeePool) {
return ITrusteeFeePool(addrReso.requireKKAddrs(_tunnelKey, TRUSTEE_FEE_POOL, "BoringDAO::TrusteeFeePool is address(0)"));
}
function addTrustee(address account, bytes32 _tunnelKey) public onlyAdmin {
_setupRole(_tunnelKey, account);
trusteeFeePool(_tunnelKey).enter(account);
}
function addTrustees(address[] memory accounts, bytes32 _tunnelKey) external onlyAdmin{
for (uint256 i = 0; i < accounts.length; i++) {
addTrustee(accounts[i], _tunnelKey);
}
}
function removeTrustee(address account, bytes32 _tunnelKey) public onlyAdmin {
revokeRole(_tunnelKey, account);
trusteeFeePool(_tunnelKey).exit(account);
}
function setMine(address _mine) public onlyAdmin {
mine = _mine;
}
function setMintCap(uint256 amount) public onlyAdmin {
mintCap = amount;
}
function setMinMintAmount(bytes32 _tunnelKey, uint _amount) public onlyAdmin {
minMintAmount[_tunnelKey] = _amount;
}
function pledge(bytes32 _tunnelKey, uint256 _amount)
public
override
whenNotPaused
whenContractExist(_tunnelKey)
{
require(
borERC20().allowance(msg.sender, address(this)) >= _amount,
"not allow enough boring"
);
borERC20().transferFrom(
msg.sender,
address(tunnel(_tunnelKey)),
_amount
);
tunnel(_tunnelKey).pledge(msg.sender, _amount);
}
function redeem(bytes32 _tunnelKey, uint256 _amount)
public
override
whenNotPaused
whenContractExist(_tunnelKey)
{
tunnel(_tunnelKey).redeem(msg.sender, _amount);
}
function burnBToken(bytes32 _tunnelKey, uint256 amount, string memory assetAddress)
public
override
whenNotPaused
whenContractExist(_tunnelKey)
whenTunnelNotPause(_tunnelKey)
{
tunnel(_tunnelKey).burn(msg.sender, amount, assetAddress);
}
function approveMint(
bytes32 _tunnelKey,
string memory _txid,
uint256 _amount,
address to,
string memory assetAddress
) public override whenNotPaused whenTunnelNotPause(_tunnelKey) onlyTrustee(_tunnelKey) shouldMoreThan(_tunnelKey, _amount){
if(to == address(0)) {
if (approveFlag[_txid] == false) {
approveFlag[_txid] = true;
emit ETHAddressNotExist(_tunnelKey, _txid, _amount, to, msg.sender, assetAddress);
}
return;
}
uint256 trusteeCount = getRoleMemberCount(_tunnelKey);
bool shouldMint = mintProposal().approve(
_tunnelKey,
_txid,
_amount,
to,
msg.sender,
trusteeCount
);
if (!shouldMint) {
return;
}
uint256 canIssueAmount = tunnel(_tunnelKey).canIssueAmount();
if (_amount.add(otoken(_tunnelKey).totalSupply()) > canIssueAmount) {
emit NotEnoughPledgeValue(
_tunnelKey,
_txid,
_amount,
to,
msg.sender,
assetAddress
);
return;
}
tunnel(_tunnelKey).issue(to, _amount);
uint borMintAmount = calculateMintBORAmount(_tunnelKey, _amount);
if(borMintAmount != 0) {
amountByMint = amountByMint.add(borMintAmount);
borERC20().transferFrom(mine, to, borMintAmount);
}
emit ApproveMintSuccess(_tunnelKey, _txid, _amount, to, assetAddress);
}
function calculateMintBORAmount(bytes32 _tunnelKey, uint _amount) public view returns (uint) {
if (amountByMint >= mintCap || _amount == 0) {
return 0;
}
uint256 assetPrice = oracle().getPrice(_tunnelKey);
uint256 borPrice = oracle().getPrice(BOR);
uint256 reductionTimes = amountByMint.div(reductionAmount);
uint256 mintFeeRate = paramBook().params2(
_tunnelKey,
TUNNEL_MINT_FEE_RATE
);
uint256 reductionFactor = (4**reductionTimes).mul(1e18).div(5**reductionTimes);
uint networkFee = paramBook().params2(_tunnelKey, NETWORK_FEE);
uint baseAmount = _amount.multiplyDecimalRound(mintFeeRate).mul(2).add(networkFee);
uint borAmount = assetPrice.multiplyDecimalRound(baseAmount).multiplyDecimalRound(reductionFactor).divideDecimalRound(borPrice);
if (amountByMint.add(borAmount) >= mintCap) {
borAmount = mintCap.sub(amountByMint);
}
return borAmount;
}
function pause() public onlyMonitor{
_pause();
}
function unpause() public onlyMonitor{
_unpause();
}
modifier onlyTrustee(bytes32 _tunnelKey) {
require(hasRole(_tunnelKey, msg.sender), "Caller is not trustee");
_;
}
modifier onlyAdmin {
require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "BoringDAO::caller is not admin");
_;
}
modifier onlyMonitor {
require(
hasRole(MONITOR_ROLE, msg.sender),
"Caller is not monitor"
);
_;
}
modifier whenContractExist(bytes32 key) {
require(
addrReso.key2address(key) != address(0),
"Contract not exist"
);
_;
}
modifier whenTunnelNotPause(bytes32 _tunnelKey) {
address tunnelAddress = addrReso.requireAndKey2Address(_tunnelKey, "tunnel not exist");
require(IPaused(tunnelAddress).paused() == false, "tunnel is paused");
_;
}
modifier shouldMoreThan(bytes32 _tunnelKey, uint amount) {
require(amount >= minMintAmount[_tunnelKey], "Mint Amount should more than min amount");
_;
}
event NotEnoughPledgeValue(
bytes32 indexed _tunnelKey,
string indexed _txid,
uint256 _amount,
address to,
address trustee,
string assetAddress
);
event ApproveMintSuccess(
bytes32 _tunnelKey,
string _txid,
uint256 _amount,
address to,
string assetAddress
);
event ETHAddressNotExist(
bytes32 _tunnelKey,
string _txid,
uint256 _amount,
address to,
address trustee,
string assetAddress
);
event NotEnoughMintAmount(
bytes32 indexed _tunnelKey,
string indexed _txid,
uint256 _amount,
address to,
address trustee,
string assetAddress
);
}
interface IPaused {
function paused() external view returns (bool);
}
文件 4 的 17:Context.sol
pragma solidity ^0.6.0;
abstract contract Context {
function _msgSender() internal view virtual returns (address payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this;
return msg.data;
}
}
文件 5 的 17:EnumerableSet.sol
pragma solidity ^0.6.0;
library EnumerableSet {
struct Set {
bytes32[] _values;
mapping (bytes32 => uint256) _indexes;
}
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
function _remove(Set storage set, bytes32 value) private returns (bool) {
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) {
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
bytes32 lastvalue = set._values[lastIndex];
set._values[toDeleteIndex] = lastvalue;
set._indexes[lastvalue] = toDeleteIndex + 1;
set._values.pop();
delete set._indexes[value];
return true;
} else {
return false;
}
}
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
struct AddressSet {
Set _inner;
}
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(value)));
}
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(value)));
}
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(value)));
}
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint256(_at(set._inner, index)));
}
struct UintSet {
Set _inner;
}
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
文件 6 的 17:IAddressResolver.sol
pragma solidity ^0.6.12;
interface IAddressResolver {
function key2address(bytes32 key) external view returns(address);
function address2key(address addr) external view returns(bytes32);
function requireAndKey2Address(bytes32 name, string calldata reason) external view returns(address);
function setAddress(bytes32 key, address addr) external;
function setMultiAddress(bytes32[] memory keys, address[] memory addrs) external;
function setKkAddr(bytes32 k1, bytes32 k2, address addr) external;
function setMultiKKAddr(bytes32[] memory k1s, bytes32[] memory k2s, address[] memory addrs) external;
function kk2addr(bytes32 k1, bytes32 k2) external view returns(address);
function requireKKAddrs(bytes32 k1, bytes32 k2, string calldata reason) external view returns(address);
}
文件 7 的 17:IBoringDAO.sol
pragma solidity ^0.6.12;
interface IBoringDAO {
function pledge(bytes32 tunnelKey, uint _amount) external;
function redeem(bytes32 tunnelKey, uint _amount) external;
function approveMint(bytes32 tunnelKey, string memory _txid, uint _amount, address account, string memory assetAddress) external;
function burnBToken(bytes32 _tunnelKey, uint _amount, string memory assetAddress) external;
}
文件 8 的 17:IERC20.sol
pragma solidity ^0.6.0;
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
文件 9 的 17:IMintProposal.sol
pragma solidity ^0.6.12;
interface IMintProposal {
function approve(
bytes32 _tunnelKey,
string memory _txid,
uint256 _amount,
address to,
address trustee,
uint256 trusteeCount
) external returns (bool);
}
文件 10 的 17:IOracle.sol
pragma solidity ^0.6.12;
interface IOracle {
function setPrice(bytes32 _symbol, uint _price) external;
function getPrice(bytes32 _symbol) external view returns (uint);
}
文件 11 的 17:ITrusteeFeePool.sol
pragma solidity ^0.6.12;
interface ITrusteeFeePool {
function exit(address account) external;
function enter(address account) external;
function notifyReward(uint reward) external;
}
文件 12 的 17:ITunnel.sol
pragma solidity ^0.6.12;
interface ITunnel {
function pledge(address account, uint amount) external;
function redeem(address account, uint amount) external;
function issue(address account, uint amount) external;
function burn(address account, uint amount, string memory assetAddress) external;
function totalValuePledge() external view returns(uint);
function canIssueAmount() external view returns(uint);
function oTokenKey() external view returns(bytes32);
}
interface ITunnelV2 {
function pledge(address account, uint amount) external;
function redeem(address account, uint amount) external;
function issue(address account, uint amount) external;
function burn(address account, uint amount, string memory assetAddress) external;
function totalValuePledge() external view returns(uint);
function canIssueAmount() external view returns(uint);
}
interface ITunnelTVL {
function totalTVL() external view returns(uint);
}
文件 13 的 17:Ownable.sol
pragma solidity ^0.6.0;
import "../GSN/Context.sol";
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor () internal {
address msgSender = _msgSender();
_owner = msgSender;
emit OwnershipTransferred(address(0), msgSender);
}
function owner() public view returns (address) {
return _owner;
}
modifier onlyOwner() {
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
文件 14 的 17:ParamBook.sol
pragma solidity ^0.6.12;
import "@openzeppelin/contracts/access/Ownable.sol";
contract ParamBook is Ownable {
mapping(bytes32 => uint256) public params;
mapping(bytes32 => mapping(bytes32 => uint256)) public params2;
function setParams(bytes32 name, uint256 value) public onlyOwner {
params[name] = value;
}
function setMultiParams(bytes32[] memory names, uint[] memory values) public onlyOwner {
require(names.length == values.length, "ParamBook::setMultiParams:param length not match");
for (uint i=0; i < names.length; i++ ) {
params[names[i]] = values[i];
}
}
function setParams2(
bytes32 name1,
bytes32 name2,
uint256 value
) public onlyOwner {
params2[name1][name2] = value;
}
function setMultiParams2(bytes32[] memory names1, bytes32[] memory names2, uint[] memory values) public onlyOwner {
require(names1.length == names2.length, "ParamBook::setMultiParams2:param length not match");
require(names1.length == values.length, "ParamBook::setMultiParams2:param length not match");
for(uint i=0; i < names1.length; i++) {
params2[names1[i]][names2[i]] = values[i];
}
}
}
文件 15 的 17:Pausable.sol
pragma solidity ^0.6.0;
import "../GSN/Context.sol";
contract Pausable is Context {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor () internal {
_paused = false;
}
function paused() public view returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!_paused, "Pausable: paused");
_;
}
modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
文件 16 的 17:SafeDecimalMath.sol
pragma solidity ^0.6.8;
import "@openzeppelin/contracts/math/SafeMath.sol";
library SafeDecimalMath {
using SafeMath for uint;
uint8 public constant decimals = 18;
uint8 public constant highPrecisionDecimals = 27;
uint public constant UNIT = 10**uint(decimals);
uint public constant PRECISE_UNIT = 10**uint(highPrecisionDecimals);
uint private constant UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR = 10**uint(highPrecisionDecimals - decimals);
function unit() external pure returns (uint) {
return UNIT;
}
function preciseUnit() external pure returns (uint) {
return PRECISE_UNIT;
}
function multiplyDecimal(uint x, uint y) internal pure returns (uint) {
return x.mul(y) / UNIT;
}
function _multiplyDecimalRound(
uint x,
uint y,
uint precisionUnit
) private pure returns (uint) {
uint quotientTimesTen = x.mul(y) / (precisionUnit / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
function multiplyDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
return _multiplyDecimalRound(x, y, PRECISE_UNIT);
}
function multiplyDecimalRound(uint x, uint y) internal pure returns (uint) {
return _multiplyDecimalRound(x, y, UNIT);
}
function divideDecimal(uint x, uint y) internal pure returns (uint) {
return x.mul(UNIT).div(y);
}
function _divideDecimalRound(
uint x,
uint y,
uint precisionUnit
) private pure returns (uint) {
uint resultTimesTen = x.mul(precisionUnit * 10).div(y);
if (resultTimesTen % 10 >= 5) {
resultTimesTen += 10;
}
return resultTimesTen / 10;
}
function divideDecimalRound(uint x, uint y) internal pure returns (uint) {
return _divideDecimalRound(x, y, UNIT);
}
function divideDecimalRoundPrecise(uint x, uint y) internal pure returns (uint) {
return _divideDecimalRound(x, y, PRECISE_UNIT);
}
function decimalToPreciseDecimal(uint i) internal pure returns (uint) {
return i.mul(UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR);
}
function preciseDecimalToDecimal(uint i) internal pure returns (uint) {
uint quotientTimesTen = i / (UNIT_TO_HIGH_PRECISION_CONVERSION_FACTOR / 10);
if (quotientTimesTen % 10 >= 5) {
quotientTimesTen += 10;
}
return quotientTimesTen / 10;
}
}
文件 17 的 17:SafeMath.sol
pragma solidity ^0.6.0;
library SafeMath {
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return sub(a, b, "SafeMath: subtraction overflow");
}
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
uint256 c = a - b;
return c;
}
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return div(a, b, "SafeMath: division by zero");
}
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
uint256 c = a / b;
return c;
}
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return mod(a, b, "SafeMath: modulo by zero");
}
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b != 0, errorMessage);
return a % b;
}
}
{
"compilationTarget": {
"contracts/BoringDAOV2.sol": "BoringDAOV2"
},
"evmVersion": "istanbul",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"contract IAddressResolver","name":"_addrReso","type":"address"},{"internalType":"uint256","name":"_mintCap","type":"uint256"},{"internalType":"address","name":"_mine","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"indexed":false,"internalType":"string","name":"_txid","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"string","name":"assetAddress","type":"string"}],"name":"ApproveMintSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"indexed":false,"internalType":"string","name":"_txid","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"trustee","type":"address"},{"indexed":false,"internalType":"string","name":"assetAddress","type":"string"}],"name":"ETHAddressNotExist","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"indexed":true,"internalType":"string","name":"_txid","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"trustee","type":"address"},{"indexed":false,"internalType":"string","name":"assetAddress","type":"string"}],"name":"NotEnoughMintAmount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"indexed":true,"internalType":"string","name":"_txid","type":"string"},{"indexed":false,"internalType":"uint256","name":"_amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"address","name":"trustee","type":"address"},{"indexed":false,"internalType":"string","name":"assetAddress","type":"string"}],"name":"NotEnoughPledgeValue","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"BOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOV_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_PROPOSAL","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MONITOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NETWORK_FEE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ORACLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OTOKEN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PARAM_BOOK","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TRUSTEE_FEE_POOL","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TUNNEL_MINT_FEE_RATE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"}],"name":"addTrustee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"accounts","type":"address[]"},{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"}],"name":"addTrustees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"addrReso","outputs":[{"internalType":"contract IAddressResolver","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountByMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"","type":"string"}],"name":"approveFlag","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"string","name":"_txid","type":"string"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"string","name":"assetAddress","type":"string"}],"name":"approveMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"string","name":"assetAddress","type":"string"}],"name":"burnBToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"calculateMintBORAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"minMintAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mine","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"pledge","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"reductionAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"}],"name":"removeTrustee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_tunnelKey","type":"bytes32"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"setMinMintAmount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_mine","type":"address"}],"name":"setMine","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"setMintCap","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"tunnels","outputs":[{"internalType":"contract ITunnelV2","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]