编译器
0.5.17+commit.d19bba13
文件 1 的 11:ICHI.sol
pragma solidity ^0.5.17;
interface ICHI {
function mint(uint256 value) external;
function transfer(address, uint256) external returns(bool);
function balanceOf(address) external view returns(uint256);
}
文件 2 的 11:IRebaser.sol
pragma solidity 0.5.17;
interface IRebaser {
function registerVelocity(uint256 amount) external;
function sEMA() external view returns (uint256);
function fEMA() external view returns (uint256);
}
文件 3 的 11:SafeMath.sol
pragma solidity ^0.5.17;
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;
}
}
文件 4 的 11:VELO.sol
pragma solidity 0.5.17;
import "./VELOGovernance.sol";
import "../feeCharger/VELOFeeCharger.sol";
import "../lib/IRebaser.sol";
library Math {
function max(uint256 a, uint256 b) internal pure returns (uint256) {
return a >= b ? a : b;
}
function min(uint256 a, uint256 b) internal pure returns (uint256) {
return a < b ? a : b;
}
}
contract VELOToken is VELOGovernanceToken {
modifier onlyGov() {
require(msg.sender == gov);
_;
}
modifier onlyRebaser() {
require(msg.sender == rebaser);
_;
}
modifier onlyMinter() {
require(msg.sender == rebaser || msg.sender == gov, "not minter");
_;
}
modifier validRecipient(address to) {
require(to != address(0x0));
require(to != address(this));
_;
}
function initialize(
string memory name_,
string memory symbol_,
uint8 decimals_
)
public
{
require(velosScalingFactor == 0, "already initialized");
name = name_;
symbol = symbol_;
decimals = decimals_;
}
function maxScalingFactor()
external
view
returns (uint256)
{
return _maxScalingFactor();
}
function _maxScalingFactor()
internal
view
returns (uint256)
{
return uint256(-1) / initSupply;
}
function mint(address to, uint256 amount)
external
onlyMinter
returns (bool)
{
_mint(to, amount);
return true;
}
function _mint(address to, uint256 amount)
internal
{
totalSupply = totalSupply.add(amount);
uint256 veloValue = amount.mul(internalDecimals).div(velosScalingFactor);
initSupply = initSupply.add(veloValue);
require(velosScalingFactor <= _maxScalingFactor(), "max scaling factor too low");
_veloBalances[to] = _veloBalances[to].add(veloValue);
_moveDelegates(address(0), _delegates[to], veloValue);
emit Mint(to, amount);
}
function transfer(address to, uint256 value)
external
validRecipient(to)
returns (bool)
{
uint256 veloValue = value.mul(internalDecimals).div(velosScalingFactor);
_veloBalances[msg.sender] = _veloBalances[msg.sender].sub(veloValue);
_veloBalances[to] = _veloBalances[to].add(veloValue);
emit Transfer(msg.sender, to, value);
_moveDelegates(_delegates[msg.sender], _delegates[to], veloValue);
if(msg.sender != gov) {
IRebaser rb = IRebaser(rebaser);
rb.registerVelocity(value);
VELOFeeCharger(feeCharger).chargeFee(rb.fEMA(), rb.sEMA(), totalSupply, value);
}
return true;
}
function transferFrom(address from, address to, uint256 value)
external
validRecipient(to)
returns (bool)
{
_allowedFragments[from][msg.sender] = _allowedFragments[from][msg.sender]
.sub(value);
uint256 veloValue = value.mul(internalDecimals).div(velosScalingFactor);
_veloBalances[from] = _veloBalances[from].sub(veloValue);
_veloBalances[to] = _veloBalances[to].add(veloValue);
emit Transfer(from, to, value);
_moveDelegates(_delegates[from], _delegates[to], veloValue);
if(msg.sender != gov) {
IRebaser rb = IRebaser(rebaser);
rb.registerVelocity(value);
VELOFeeCharger(feeCharger).chargeFee(rb.fEMA(), rb.sEMA(), totalSupply, value);
}
return true;
}
function balanceOf(address who)
external
view
returns (uint256)
{
return _veloBalances[who].mul(velosScalingFactor).div(internalDecimals);
}
function balanceOfUnderlying(address who)
external
view
returns (uint256)
{
return _veloBalances[who];
}
function allowance(address owner_, address spender)
external
view
returns (uint256)
{
return _allowedFragments[owner_][spender];
}
function approve(address spender, uint256 value)
external
returns (bool)
{
_allowedFragments[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
function increaseAllowance(address spender, uint256 addedValue)
external
returns (bool)
{
_allowedFragments[msg.sender][spender] =
_allowedFragments[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
return true;
}
function decreaseAllowance(address spender, uint256 subtractedValue)
external
returns (bool)
{
uint256 oldValue = _allowedFragments[msg.sender][spender];
if (subtractedValue >= oldValue) {
_allowedFragments[msg.sender][spender] = 0;
} else {
_allowedFragments[msg.sender][spender] = oldValue.sub(subtractedValue);
}
emit Approval(msg.sender, spender, _allowedFragments[msg.sender][spender]);
return true;
}
function setRebaser(address rebaser_)
external
onlyGov
{
address oldRebaser = rebaser;
rebaser = rebaser_;
emit NewRebaser(oldRebaser, rebaser_);
}
function setFeeCharger(address feeCharger_)
external
onlyGov
{
feeCharger = feeCharger_;
}
function _setPendingGov(address pendingGov_)
external
onlyGov
{
address oldPendingGov = pendingGov;
pendingGov = pendingGov_;
emit NewPendingGov(oldPendingGov, pendingGov_);
}
function setGov(address gov_) external onlyGov {
gov = gov_;
}
function _acceptGov()
external
{
require(msg.sender == pendingGov, "!pending");
address oldGov = gov;
gov = pendingGov;
pendingGov = address(0);
emit NewGov(oldGov, gov);
}
function rebase(uint256 scaling_modifier)
external
onlyRebaser
{
uint256 prevVelosScalingFactor = velosScalingFactor;
velosScalingFactor = velosScalingFactor
.mul(scaling_modifier)
.div(internalDecimals);
velosScalingFactor = Math.min(velosScalingFactor, 1 * internalDecimals);
totalSupply = initSupply.mul(velosScalingFactor).div(internalDecimals);
emit Rebase(prevVelosScalingFactor, velosScalingFactor);
}
}
contract VELO is VELOToken {
function initialize(
string memory name_,
string memory symbol_,
uint8 decimals_,
address initial_owner,
uint256 initSupply_
)
public
{
require(initSupply_ > 0, "0 init supply");
super.initialize(name_, symbol_, decimals_);
initSupply = initSupply_;
totalSupply = initSupply_;
velosScalingFactor = BASE;
_veloBalances[initial_owner] = initSupply_;
emit Transfer(address(0), msg.sender, initSupply_);
}
}
文件 5 的 11:VELODelegate.sol
pragma solidity 0.5.17;
import "./VELO.sol";
contract VELODelegationStorage {
address public implementation;
}
contract VELODelegatorInterface is VELODelegationStorage {
event NewImplementation(address oldImplementation, address newImplementation);
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public;
}
contract VELODelegateInterface is VELODelegationStorage {
function _becomeImplementation(bytes memory data) public;
function _resignImplementation() public;
}
contract VELODelegate is VELO, VELODelegateInterface {
constructor() public {}
function _becomeImplementation(bytes memory data) public {
data;
if (false) {
implementation = address(0);
}
require(msg.sender == gov, "only the gov may call _becomeImplementation");
}
function _resignImplementation() public {
if (false) {
implementation = address(0);
}
require(msg.sender == gov, "only the gov may call _resignImplementation");
}
}
文件 6 的 11:VELODelegator.sol
pragma solidity 0.5.17;
import "./VELOTokenInterface.sol";
import "./VELODelegate.sol";
contract VELODelegator is VELOTokenInterface, VELODelegatorInterface {
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 initSupply_,
address implementation_,
bytes memory becomeImplementationData
)
public
{
gov = msg.sender;
delegateTo(
implementation_,
abi.encodeWithSignature(
"initialize(string,string,uint8,address,uint256)",
name_,
symbol_,
decimals_,
msg.sender,
initSupply_
)
);
_setImplementation(implementation_, false, becomeImplementationData);
}
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
require(msg.sender == gov, "VELODelegator::_setImplementation: Caller must be gov");
if (allowResign) {
delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
}
address oldImplementation = implementation;
implementation = implementation_;
delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));
emit NewImplementation(oldImplementation, implementation);
}
function mint(address to, uint256 mintAmount)
external
returns (bool)
{
to; mintAmount;
delegateAndReturn();
}
function transfer(address dst, uint256 amount)
external
returns (bool)
{
dst; amount;
delegateAndReturn();
}
function transferFrom(
address src,
address dst,
uint256 amount
)
external
returns (bool)
{
src; dst; amount;
delegateAndReturn();
}
function approve(
address spender,
uint256 amount
)
external
returns (bool)
{
spender; amount;
delegateAndReturn();
}
function increaseAllowance(
address spender,
uint256 addedValue
)
external
returns (bool)
{
spender; addedValue;
delegateAndReturn();
}
function maxScalingFactor()
external
view
returns (uint256)
{
delegateToViewAndReturn();
}
function decreaseAllowance(
address spender,
uint256 subtractedValue
)
external
returns (bool)
{
spender; subtractedValue;
delegateAndReturn();
}
function allowance(
address owner,
address spender
)
external
view
returns (uint256)
{
owner; spender;
delegateToViewAndReturn();
}
function delegates(
address delegator
)
external
view
returns (address)
{
delegator;
delegateToViewAndReturn();
}
function balanceOf(address owner)
external
view
returns (uint256)
{
owner;
delegateToViewAndReturn();
}
function balanceOfUnderlying(address owner)
external
view
returns (uint256)
{
owner;
delegateToViewAndReturn();
}
function _setPendingGov(address newPendingGov)
external
{
newPendingGov;
delegateAndReturn();
}
function setRebaser(address rebaser_)
external
{
rebaser_;
delegateAndReturn();
}
function _setIncentivizer(address incentivizer_)
external
{
incentivizer_;
delegateAndReturn();
}
function _acceptGov()
external
{
delegateAndReturn();
}
function setGov(address gov_) external {
gov_;
delegateAndReturn();
}
function rebase(uint256 scaling_modifier) external {
delegateAndReturn();
}
function setFeeCharger(
address feeCharger_
) external {
feeCharger_;
delegateAndReturn();
}
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
account; blockNumber;
delegateToViewAndReturn();
}
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
delegatee; nonce; expiry; v; r; s;
delegateAndReturn();
}
function delegate(address delegatee)
external
{
delegatee;
delegateAndReturn();
}
function getCurrentVotes(address account)
external
view
returns (uint256)
{
account;
delegateToViewAndReturn();
}
function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return returnData;
}
function delegateToImplementation(bytes memory data) public returns (bytes memory) {
return delegateTo(implementation, data);
}
function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return abi.decode(returnData, (bytes));
}
function delegateToViewAndReturn() private view returns (bytes memory) {
(bool success, ) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", msg.data));
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(add(free_mem_ptr, 0x40), returndatasize) }
}
}
function delegateAndReturn() private returns (bytes memory) {
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
function () external payable {
require(msg.value == 0,"VELODelegator:fallback: cannot send value to fallback");
delegateAndReturn();
}
}
文件 7 的 11:VELOFeeCharger.sol
pragma solidity 0.5.17;
import "../lib/ICHI.sol";
import {VELOTokenInterface as IVELO} from "../token/VELOTokenInterface.sol";
contract VELOFeeCharger {
ICHI public constant chi = ICHI(0x0000000000004946c0e9F43F4Dee607b0eF1fA1c);
IVELO public velo;
uint256 public govFactor;
address public gov;
address public beneficiary;
uint256 public max_gas_block;
uint256 public min_gas_tx;
uint256 public gov_fee_factor;
uint256 public last_block_number;
uint256 public chi_fee_remaining;
function setMaxGasBlock(uint256 value) public {
max_gas_block = value;
}
function setMinGasTx(uint256 value) public {
min_gas_tx = value;
}
function setGovFeeFactor(uint256 value) public {
gov_fee_factor = value;
}
modifier onlyGov() {
require(msg.sender == gov, "!gov");
_;
}
constructor(address velo_) public {
velo = IVELO(velo_);
gov = msg.sender;
gov_fee_factor = 1 * 10**18;
max_gas_block = 135 * 10**18;
min_gas_tx = 2 * 10**18;
last_block_number = 0;
chi_fee_remaining = 0;
}
function setGov(address newGov) external onlyGov {
gov = newGov;
}
function setGovFactor(uint256 factor) external onlyGov {
govFactor = factor;
}
function setBeneficiary(address beneficiary_) external onlyGov {
beneficiary = beneficiary_;
}
function chargeFee(uint256 fEMA, uint256 sEMA, uint256 totalSupply, uint256 _amount) public {
uint256 chi_fee =
calc_fee_gas(max_gas_block, min_gas_tx, sEMA, _amount, totalSupply, gov_fee_factor);
if(last_block_number == block.number) {
if (chi_fee_remaining < chi_fee) {
chi_fee = chi_fee_remaining;
}
chi_fee_remaining = chi_fee_remaining - chi_fee;
} else {
last_block_number = block.number;
chi_fee_remaining = max_gas_block - chi_fee;
}
if (chi_fee > 0 && beneficiary != address(0x0)) {
chi.mint(chi_fee / 10**18);
chi.transfer(beneficiary, chi.balanceOf(address(this)));
}
}
function calc_fee_ratio_discrete(
uint256 ema1_vt,
uint256 ema2_vt,
uint256 tx_size,
uint256 total_supply,
uint256 _gov_fee_factor
) internal pure returns (uint256) {
uint256 tx_discount_factor = ema2_vt;
uint256 tx_fee_ratio = 10 * 10**18;
if(tx_size <= total_supply / 596) {
tx_fee_ratio = 6;
} else if(tx_size <= total_supply / 369) {
tx_fee_ratio = 9;
} else if(tx_size <= total_supply / 228) {
tx_fee_ratio = 15;
} else if(tx_size <= total_supply / 141) {
tx_fee_ratio = 23;
} else if(tx_size <= total_supply / 87) {
tx_fee_ratio = 37;
} else if(tx_size <= total_supply / 54) {
tx_fee_ratio = 55;
} else if(tx_size <= total_supply / 33) {
tx_fee_ratio = 76;
} else if(tx_size <= total_supply / 21) {
tx_fee_ratio = 92;
} else if(tx_size <= total_supply / 13) {
tx_fee_ratio = 98;
} else if(tx_size <= total_supply / 6) {
tx_fee_ratio = 99;
} else {
tx_fee_ratio = 100;
}
return ((tx_fee_ratio * tx_discount_factor / 100) * _gov_fee_factor)
/ 10**18;
}
function calc_fee_gas(
uint256 max_gas_block,
uint256 min_gas_tx,
uint256 ema_long,
uint256 tx_size,
uint256 total_supply,
uint256 _gov_fee_factor
) public pure returns (uint256) {
uint256 max_gas_chi_per_block = max_gas_block;
uint256 min_gas_chi_fee_per_tx = min_gas_tx;
uint256 tx_fee_ratio_disc =
calc_fee_ratio_discrete(0, ema_long, tx_size, total_supply, _gov_fee_factor);
uint256 tx_fee_chi_disc =
max_gas_chi_per_block * tx_fee_ratio_disc / 100 / 10**18;
if ( tx_fee_chi_disc < min_gas_chi_fee_per_tx ) {
tx_fee_chi_disc = min_gas_chi_fee_per_tx;
}
return tx_fee_chi_disc;
}
}
文件 8 的 11:VELOGovernance.sol
pragma solidity 0.5.17;
pragma experimental ABIEncoderV2;
import "./VELOGovernanceStorage.sol";
import "./VELOTokenInterface.sol";
contract VELOGovernanceToken is VELOTokenInterface {
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
function delegates(address delegator)
external
view
returns (address)
{
return _delegates[delegator];
}
function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
function delegateBySig(
address delegatee,
uint nonce,
uint expiry,
uint8 v,
bytes32 r,
bytes32 s
)
external
{
bytes32 domainSeparator = keccak256(
abi.encode(
DOMAIN_TYPEHASH,
keccak256(bytes(name)),
getChainId(),
address(this)
)
);
bytes32 structHash = keccak256(
abi.encode(
DELEGATION_TYPEHASH,
delegatee,
nonce,
expiry
)
);
bytes32 digest = keccak256(
abi.encodePacked(
"\x19\x01",
domainSeparator,
structHash
)
);
address signatory = ecrecover(digest, v, r, s);
require(signatory != address(0), "VELO::delegateBySig: invalid signature");
require(nonce == nonces[signatory]++, "VELO::delegateBySig: invalid nonce");
require(now <= expiry, "VELO::delegateBySig: signature expired");
return _delegate(signatory, delegatee);
}
function getCurrentVotes(address account)
external
view
returns (uint256)
{
uint32 nCheckpoints = numCheckpoints[account];
return nCheckpoints > 0 ? checkpoints[account][nCheckpoints - 1].votes : 0;
}
function getPriorVotes(address account, uint blockNumber)
external
view
returns (uint256)
{
require(blockNumber < block.number, "VELO::getPriorVotes: not yet determined");
uint32 nCheckpoints = numCheckpoints[account];
if (nCheckpoints == 0) {
return 0;
}
if (checkpoints[account][nCheckpoints - 1].fromBlock <= blockNumber) {
return checkpoints[account][nCheckpoints - 1].votes;
}
if (checkpoints[account][0].fromBlock > blockNumber) {
return 0;
}
uint32 lower = 0;
uint32 upper = nCheckpoints - 1;
while (upper > lower) {
uint32 center = upper - (upper - lower) / 2;
Checkpoint memory cp = checkpoints[account][center];
if (cp.fromBlock == blockNumber) {
return cp.votes;
} else if (cp.fromBlock < blockNumber) {
lower = center;
} else {
upper = center - 1;
}
}
return checkpoints[account][lower].votes;
}
function _delegate(address delegator, address delegatee)
internal
{
address currentDelegate = _delegates[delegator];
uint256 delegatorBalance = _veloBalances[delegator];
_delegates[delegator] = delegatee;
emit DelegateChanged(delegator, currentDelegate, delegatee);
_moveDelegates(currentDelegate, delegatee, delegatorBalance);
}
function _moveDelegates(address srcRep, address dstRep, uint256 amount) internal {
if (srcRep != dstRep && amount > 0) {
if (srcRep != address(0)) {
uint32 srcRepNum = numCheckpoints[srcRep];
uint256 srcRepOld = srcRepNum > 0 ? checkpoints[srcRep][srcRepNum - 1].votes : 0;
uint256 srcRepNew = srcRepOld.sub(amount);
_writeCheckpoint(srcRep, srcRepNum, srcRepOld, srcRepNew);
}
if (dstRep != address(0)) {
uint32 dstRepNum = numCheckpoints[dstRep];
uint256 dstRepOld = dstRepNum > 0 ? checkpoints[dstRep][dstRepNum - 1].votes : 0;
uint256 dstRepNew = dstRepOld.add(amount);
_writeCheckpoint(dstRep, dstRepNum, dstRepOld, dstRepNew);
}
}
}
function _writeCheckpoint(
address delegatee,
uint32 nCheckpoints,
uint256 oldVotes,
uint256 newVotes
)
internal
{
uint32 blockNumber = safe32(block.number, "VELO::_writeCheckpoint: block number exceeds 32 bits");
if (nCheckpoints > 0 && checkpoints[delegatee][nCheckpoints - 1].fromBlock == blockNumber) {
checkpoints[delegatee][nCheckpoints - 1].votes = newVotes;
} else {
checkpoints[delegatee][nCheckpoints] = Checkpoint(blockNumber, newVotes);
numCheckpoints[delegatee] = nCheckpoints + 1;
}
emit DelegateVotesChanged(delegatee, oldVotes, newVotes);
}
function safe32(uint n, string memory errorMessage) internal pure returns (uint32) {
require(n < 2**32, errorMessage);
return uint32(n);
}
function getChainId() internal pure returns (uint) {
uint256 chainId;
assembly { chainId := chainid() }
return chainId;
}
}
文件 9 的 11:VELOGovernanceStorage.sol
pragma solidity 0.5.17;
pragma experimental ABIEncoderV2;
contract VELOGovernanceStorage {
mapping (address => address) internal _delegates;
struct Checkpoint {
uint32 fromBlock;
uint256 votes;
}
mapping (address => mapping (uint32 => Checkpoint)) public checkpoints;
mapping (address => uint32) public numCheckpoints;
bytes32 public constant DOMAIN_TYPEHASH = keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
bytes32 public constant DELEGATION_TYPEHASH = keccak256("Delegation(address delegatee,uint256 nonce,uint256 expiry)");
mapping (address => uint) public nonces;
}
文件 10 的 11:VELOTokenInterface.sol
pragma solidity 0.5.17;
import "./VELOTokenStorage.sol";
import "./VELOGovernanceStorage.sol";
contract VELOTokenInterface is VELOTokenStorage, VELOGovernanceStorage {
event DelegateChanged(address indexed delegator, address indexed fromDelegate, address indexed toDelegate);
event DelegateVotesChanged(address indexed delegate, uint previousBalance, uint newBalance);
event Rebase(uint256 prevVelosScalingFactor, uint256 newVelosScalingFactor);
event NewPendingGov(address oldPendingGov, address newPendingGov);
event NewGov(address oldGov, address newGov);
event NewRebaser(address oldRebaser, address newRebaser);
event NewIncentivizer(address oldIncentivizer, address newIncentivizer);
event Transfer(address indexed from, address indexed to, uint amount);
event Approval(address indexed owner, address indexed spender, uint amount);
event Mint(address to, uint256 amount);
function transfer(address to, uint256 value) external returns(bool);
function transferFrom(address from, address to, uint256 value) external returns(bool);
function balanceOf(address who) external view returns(uint256);
function balanceOfUnderlying(address who) external view returns(uint256);
function allowance(address owner_, address spender) external view returns(uint256);
function approve(address spender, uint256 value) external returns (bool);
function increaseAllowance(address spender, uint256 addedValue) external returns (bool);
function decreaseAllowance(address spender, uint256 subtractedValue) external returns (bool);
function maxScalingFactor() external view returns (uint256);
function getPriorVotes(address account, uint blockNumber) external view returns (uint256);
function delegateBySig(address delegatee, uint nonce, uint expiry, uint8 v, bytes32 r, bytes32 s) external;
function delegate(address delegatee) external;
function delegates(address delegator) external view returns (address);
function getCurrentVotes(address account) external view returns (uint256);
function mint(address to, uint256 amount) external returns (bool);
function _setPendingGov(address pendingGov_) external;
function setGov(address gov_) external;
function _acceptGov() external;
function setRebaser(address rebaser_) external;
function rebase(uint256 scaling_modifier) external;
}
文件 11 的 11:VELOTokenStorage.sol
pragma solidity 0.5.17;
import "../lib/SafeMath.sol";
contract VELOTokenStorage {
using SafeMath for uint256;
bool internal _notEntered;
string public name;
string public symbol;
uint8 public decimals;
address public gov;
address public pendingGov;
address public rebaser;
uint256 public totalSupply;
uint256 public constant internalDecimals = 10**18;
uint256 public constant BASE = 10**18;
uint256 public velosScalingFactor;
mapping (address => uint256) internal _veloBalances;
mapping (address => mapping (address => uint256)) internal _allowedFragments;
uint256 public initSupply;
address public feeCharger;
}
{
"compilationTarget": {
"contracts/token/VELODelegator.sol": "VELODelegator"
},
"evmVersion": "istanbul",
"libraries": {},
"optimizer": {
"enabled": false,
"runs": 200
},
"remappings": []
}
[{"inputs":[{"internalType":"string","name":"name_","type":"string"},{"internalType":"string","name":"symbol_","type":"string"},{"internalType":"uint8","name":"decimals_","type":"uint8"},{"internalType":"uint256","name":"initSupply_","type":"uint256"},{"internalType":"address","name":"implementation_","type":"address"},{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"payable":false,"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":"amount","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mint","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldGov","type":"address"},{"indexed":false,"internalType":"address","name":"newGov","type":"address"}],"name":"NewGov","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldIncentivizer","type":"address"},{"indexed":false,"internalType":"address","name":"newIncentivizer","type":"address"}],"name":"NewIncentivizer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingGov","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingGov","type":"address"}],"name":"NewPendingGov","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldRebaser","type":"address"},{"indexed":false,"internalType":"address","name":"newRebaser","type":"address"}],"name":"NewRebaser","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"prevVelosScalingFactor","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newVelosScalingFactor","type":"uint256"}],"name":"Rebase","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":"amount","type":"uint256"}],"name":"Transfer","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":true,"inputs":[],"name":"BASE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"DELEGATION_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"DOMAIN_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"_acceptGov","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"implementation_","type":"address"},{"internalType":"bool","name":"allowResign","type":"bool"},{"internalType":"bytes","name":"becomeImplementationData","type":"bytes"}],"name":"_setImplementation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"incentivizer_","type":"address"}],"name":"_setIncentivizer","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingGov","type":"address"}],"name":"_setPendingGov","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOfUnderlying","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint32","name":"","type":"uint32"}],"name":"checkpoints","outputs":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint256","name":"votes","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"delegateToImplementation","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes","name":"data","type":"bytes"}],"name":"delegateToViewImplementation","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"delegator","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"feeCharger","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getCurrentVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPriorVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"gov","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"initSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"internalDecimals","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"maxScalingFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"mintAmount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"pendingGov","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"scaling_modifier","type":"uint256"}],"name":"rebase","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"rebaser","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"feeCharger_","type":"address"}],"name":"setFeeCharger","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"gov_","type":"address"}],"name":"setGov","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"rebaser_","type":"address"}],"name":"setRebaser","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"velosScalingFactor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]