This contract's source code is verified! Compiler
0.7.5+commit.eb77ed08
File 1 of 11: Counters.sol
pragma solidity ^0.7.5;
import "./SafeMath.sol" ;
library Counters {
using SafeMath for uint256 ;
struct Counter {
uint256 _value;
}
function current (Counter storage counter ) internal view returns (uint256 ) {
return counter._value;
}
function increment (Counter storage counter ) internal {
counter._value + = 1 ;
}
function decrement (Counter storage counter ) internal {
counter._value = counter._value.sub(1 );
}
}
File 2 of 11: ERC20.sol
pragma solidity ^0.7.5;
import "../libraries/SafeMath.sol" ;
import "../interfaces/IERC20.sol" ;
abstract contract ERC20 is IERC20 {
using SafeMath for uint256 ;
bytes32 private constant ERC20TOKEN_ERC1820_INTERFACE_ID = keccak256 ("ERC20Token" );
mapping (address = > uint256 ) internal _balances;
mapping (address = > mapping (address = > uint256 )) internal _allowances;
uint256 internal _totalSupply;
string internal _name;
string internal _symbol;
uint8 internal immutable _decimals;
constructor (
string memory name_,
string memory symbol_,
uint8 decimals_
) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
}
function name ( ) public view returns (string memory ) {
return _name;
}
function symbol ( ) public view returns (string memory ) {
return _symbol;
}
function decimals ( ) public view override returns (uint8 ) {
return _decimals;
}
function totalSupply ( ) public view override returns (uint256 ) {
return _totalSupply;
}
function balanceOf (address account ) public view virtual override returns (uint256 ) {
return _balances[account];
}
function transfer (address recipient, uint256 amount ) public virtual override returns (bool ) {
_transfer(msg .sender , recipient, amount);
return true ;
}
function allowance (address owner, address spender ) public view virtual override returns (uint256 ) {
return _allowances[owner][spender];
}
function approve (address spender, uint256 amount ) public virtual override returns (bool ) {
_approve(msg .sender , spender, amount);
return true ;
}
function transferFrom (
address sender,
address recipient,
uint256 amount
) public virtual override returns (bool ) {
_transfer(sender, recipient, amount);
_approve(sender, msg .sender , _allowances[sender][msg .sender ].sub(amount, "ERC20: transfer amount exceeds allowance" ));
return true ;
}
function increaseAllowance (address spender, uint256 addedValue ) public virtual returns (bool ) {
_approve(msg .sender , spender, _allowances[msg .sender ][spender].add(addedValue));
return true ;
}
function decreaseAllowance (address spender, uint256 subtractedValue ) public virtual returns (bool ) {
_approve(msg .sender , spender, _allowances[msg .sender ][spender].sub(subtractedValue, "ERC20: decreased allowance below zero" ));
return true ;
}
function _transfer (
address sender,
address recipient,
uint256 amount
) internal virtual {
require (sender ! = address (0 ), "ERC20: transfer from the zero address" );
require (recipient ! = address (0 ), "ERC20: transfer to the zero address" );
_beforeTokenTransfer(sender, recipient, amount);
_balances[sender] = _balances[sender].sub(amount, "ERC20: transfer amount exceeds balance" );
_balances[recipient] = _balances[recipient].add(amount);
emit Transfer(sender, recipient, amount);
}
function _mint (address account, uint256 amount ) internal virtual {
require (account ! = address (0 ), "ERC20: mint to the zero address" );
_beforeTokenTransfer(address (0 ), account, amount);
_totalSupply = _totalSupply.add(amount);
_balances[account] = _balances[account].add(amount);
emit Transfer(address (0 ), account, amount);
}
function _burn (address account, uint256 amount ) internal virtual {
require (account ! = address (0 ), "ERC20: burn from the zero address" );
_beforeTokenTransfer(account, address (0 ), amount);
_balances[account] = _balances[account].sub(amount, "ERC20: burn amount exceeds balance" );
_totalSupply = _totalSupply.sub(amount);
emit Transfer(account, address (0 ), amount);
}
function _approve (
address owner,
address spender,
uint256 amount
) internal virtual {
require (owner ! = address (0 ), "ERC20: approve from the zero address" );
require (spender ! = address (0 ), "ERC20: approve to the zero address" );
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
function _beforeTokenTransfer (
address from_,
address to_,
uint256 amount_
) internal virtual {}
}
File 3 of 11: ERC20Permit.sol
pragma solidity ^0.7.5;
import "../libraries/Counters.sol" ;
import "../interfaces/IERC20Permit.sol" ;
import "./ERC20.sol" ;
abstract contract ERC20Permit is ERC20 , IERC20Permit {
using Counters for Counters .Counter ;
mapping (address = > Counters.Counter) private _nonces;
bytes32 public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9 ;
bytes32 public override DOMAIN_SEPARATOR;
constructor ( ) {
uint256 chainID;
assembly {
chainID := chainid ()
}
DOMAIN_SEPARATOR = keccak256 (
abi .encode (
keccak256 ("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)" ),
keccak256 (bytes (name())),
keccak256 (bytes ("1" )),
chainID,
address (this )
)
);
}
function permit (
address owner,
address spender,
uint256 amount,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual override {
require (block .timestamp < = deadline, "Permit: expired deadline" );
bytes32 hashStruct = keccak256 (abi .encode (PERMIT_TYPEHASH, owner, spender, amount, _nonces[owner].current(), deadline));
bytes32 _hash = keccak256 (abi .encodePacked (uint16 (0x1901 ), DOMAIN_SEPARATOR, hashStruct));
address signer = ecrecover (_hash, v, r, s);
require (signer ! = address (0 ) & & signer = = owner, "ZeroSwapPermit: Invalid signature" );
_nonces[owner].increment();
_approve(owner, spender, amount);
}
function nonces (address owner ) public view override returns (uint256 ) {
return _nonces[owner].current();
}
}
File 4 of 11: IERC20.sol
pragma solidity ^0.7.5;
interface IERC20 {
function decimals ( ) external view returns (uint8 ) ;
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 ) ;
}
File 5 of 11: IERC20Permit.sol
pragma solidity ^0.7.5;
interface IERC20Permit {
function permit (
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external ;
function nonces (address owner ) external view returns (uint256 ) ;
function DOMAIN_SEPARATOR ( ) external view returns (bytes32 ) ;
}
File 6 of 11: IMVD.sol
pragma solidity ^0.7.5;
import "./IERC20.sol" ;
interface IMVD is IERC20 {
function mint (address account_, uint256 amount_ ) external ;
function burn (uint256 amount ) external ;
function burnFrom (address account_, uint256 amount_ ) external ;
}
File 7 of 11: IMetaVaultAuthority.sol
pragma solidity ^0.7.5;
interface IMetaVaultAuthority {
event GovernorPushed (address indexed from , address indexed to, bool _effectiveImmediately ) ;
event PolicyPushed (address indexed from , address indexed to, bool _effectiveImmediately ) ;
event VaultPushed (address indexed from , address indexed to, bool _effectiveImmediately ) ;
event GovernorPulled (address indexed from , address indexed to ) ;
event PolicyPulled (address indexed from , address indexed to ) ;
event VaultPulled (address indexed from , address indexed to ) ;
function governor ( ) external view returns (address ) ;
function policy ( ) external view returns (address ) ;
function vault ( ) external view returns (address ) ;
}
File 8 of 11: MVD.sol
pragma solidity 0.7.5;
import "../shared/libraries/SafeMath.sol" ;
import "../shared/interfaces/IMVD.sol" ;
import "../shared/types/ERC20Permit.sol" ;
import "../shared/types/MetaVaultAC.sol" ;
import "../MetaVaultAuthority.sol" ;
contract MVD is ERC20Permit , MetaVaultAC {
using SafeMath for uint256 ;
constructor (address _authority ) ERC20 ("Metavault DAO" , "MVD" , 9 ) ERC20Permit ( ) MetaVaultAC (IMetaVaultAuthority(_authority ) ) {}
function mint (address account_, uint256 amount_ ) external onlyVault {
_mint(account_, amount_);
}
function burn (uint256 amount ) public virtual {
_burn(msg .sender , amount);
}
function burnFrom (address account_, uint256 amount_ ) public virtual {
_burnFrom(account_, amount_);
}
function _burnFrom (address account_, uint256 amount_ ) public virtual {
uint256 decreasedAllowance_ = allowance(account_, msg .sender ).sub(amount_, "ERC20: burn amount exceeds allowance" );
_approve(account_, msg .sender , decreasedAllowance_);
_burn(account_, amount_);
}
}
File 9 of 11: MetaVaultAC.sol
pragma solidity ^0.7.5;
import "../interfaces/IMetaVaultAuthority.sol" ;
abstract contract MetaVaultAC {
IMetaVaultAuthority public authority;
event AuthorityUpdated (IMetaVaultAuthority indexed authority ) ;
constructor (IMetaVaultAuthority _authority ) {
authority = _authority;
emit AuthorityUpdated(_authority);
}
modifier onlyGovernor ( ) {
require (msg .sender = = authority.governor(), "MetavaultAC: caller is not the Governer" );
_ ;
}
modifier onlyPolicy ( ) {
require (msg .sender = = authority.policy(), "MetavaultAC: caller is not the Policy" );
_ ;
}
modifier onlyVault ( ) {
require (msg .sender = = authority.vault(), "MetavaultAC: caller is not the Vault" );
_ ;
}
function setAuthority (IMetaVaultAuthority _newAuthority ) external onlyGovernor {
authority = _newAuthority;
emit AuthorityUpdated(_newAuthority);
}
}
File 10 of 11: MetaVaultAuthority.sol
pragma solidity ^0.7.5;
import "./shared/interfaces/IMetaVaultAuthority.sol" ;
import "./shared/types/MetaVaultAC.sol" ;
contract MetaVaultAuthority is IMetaVaultAuthority , MetaVaultAC {
address public override governor;
address public override policy;
address public override vault;
address public newGovernor;
address public newPolicy;
address public newVault;
constructor (
address _governor,
address _policy,
address _vault
) MetaVaultAC (IMetaVaultAuthority(address (this ) ) ) {
governor = _governor;
emit GovernorPushed(address (0 ), governor, true );
policy = _policy;
emit PolicyPushed(address (0 ), policy, true );
vault = _vault;
emit VaultPushed(address (0 ), vault, true );
}
function pushGovernor (address _newGovernor, bool _effectiveImmediately ) external onlyGovernor {
if (_effectiveImmediately) governor = _newGovernor;
newGovernor = _newGovernor;
emit GovernorPushed(governor, newGovernor, _effectiveImmediately);
}
function pushPolicy (address _newPolicy, bool _effectiveImmediately ) external onlyGovernor {
if (_effectiveImmediately) policy = _newPolicy;
newPolicy = _newPolicy;
emit PolicyPushed(policy, newPolicy, _effectiveImmediately);
}
function pushVault (address _newVault, bool _effectiveImmediately ) external onlyGovernor {
if (_effectiveImmediately) vault = _newVault;
newVault = _newVault;
emit VaultPushed(vault, newVault, _effectiveImmediately);
}
function pullGovernor ( ) external {
require (msg .sender = = newGovernor, "!newGovernor" );
emit GovernorPulled(governor, newGovernor);
governor = newGovernor;
}
function pullPolicy ( ) external {
require (msg .sender = = newPolicy, "!newPolicy" );
emit PolicyPulled(policy, newPolicy);
policy = newPolicy;
}
function pullVault ( ) external {
require (msg .sender = = newVault, "!newVault" );
emit VaultPulled(vault, newVault);
vault = newVault;
}
}
File 11 of 11: SafeMath.sol
pragma solidity ^0.7.5;
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;
}
function sqrrt (uint256 a ) internal pure returns (uint c ) {
if (a > 3 ) {
c = a;
uint b = add( div( a, 2 ), 1 );
while (b < c) {
c = b;
b = div( add( div( a, b ), b), 2 );
}
} else if (a ! = 0 ) {
c = 1 ;
}
}
function percentageAmount ( uint256 total_, uint8 percentage_ ) internal pure returns ( uint256 percentAmount_ ) {
return div( mul( total_, percentage_ ), 1000 );
}
function substractPercentage ( uint256 total_, uint8 percentageToSub_ ) internal pure returns ( uint256 result_ ) {
return sub( total_, div( mul( total_, percentageToSub_ ), 1000 ) );
}
function percentageOfTotal ( uint256 part_, uint256 total_ ) internal pure returns ( uint256 percent_ ) {
return div( mul(part_, 100 ) , total_ );
}
function average (uint256 a, uint256 b ) internal pure returns (uint256 ) {
return (a / 2 ) + (b / 2 ) + ((a % 2 + b % 2 ) / 2 );
}
function quadraticPricing ( uint256 payment_, uint256 multiplier_ ) internal pure returns (uint256 ) {
return sqrrt( mul( multiplier_, payment_ ) );
}
function bondingCurve ( uint256 supply_, uint256 multiplier_ ) internal pure returns (uint256 ) {
return mul( multiplier_, supply_ );
}
}
{
"compilationTarget" : {
"contracts/tokens/MVD.sol" : "MVD"
} ,
"evmVersion" : "istanbul" ,
"libraries" : { } ,
"metadata" : {
"bytecodeHash" : "none" ,
"useLiteralContent" : true
} ,
"optimizer" : {
"enabled" : true ,
"runs" : 100
} ,
"remappings" : [ ]
} [{"inputs":[{"internalType":"address","name":"_authority","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"contract IMetaVaultAuthority","name":"authority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PERMIT_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"_burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract IMetaVaultAuthority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"burnFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"amount_","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IMetaVaultAuthority","name":"_newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}]