¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.5.0+commit.1d4f565a
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 9: Address.sol
pragmasolidity ^0.5.0;/**
* @title LOAPROTOCOL
*/libraryAddress{
/**
* @dev Returns true if `account` is a contract.
*
* This test is non-exhaustive, and there may be false-negatives: during the
* execution of a contract's constructor, its address will be reported as
* not containing a contract.
*
* > It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*/functionisContract(address account) internalviewreturns (bool) {
// This method relies in extcodesize, which returns 0 for contracts in// construction, since the code is only stored at the end of the// constructor execution.uint256 size;
// solhint-disable-next-line no-inline-assemblyassembly { size :=extcodesize(account) }
return size >0;
}
/**
* @dev Converts an `address` into `address payable`. Note that this is
* simply a type cast: the actual underlying value is not changed.
*/functiontoPayable(address account) internalpurereturns (addresspayable) {
returnaddress(uint160(account));
}
}
Código Fuente del Contrato
Archivo 2 de 9: ERC20.sol
pragmasolidity ^0.5.0;import"./IERC20.sol";
import"./SafeMath.sol";
/**
* @title LOAPROTOCOL
*/contractERC20isIERC20{
usingSafeMathforuint256;
mapping (address=>uint256) private _balances;
mapping (address=>mapping (address=>uint256)) private _allowances;
uint256private _totalSupply;
functiontotalSupply() publicviewreturns (uint256) {
return _totalSupply;
}
functionbalanceOf(address owner) publicviewreturns (uint256) {
return _balances[owner];
}
functionallowance(address owner, address spender) publicviewreturns (uint256) {
return _allowances[owner][spender];
}
functiontransfer(address to, uint256 value) publicreturns (bool) {
_transfer(msg.sender, to, value);
returntrue;
}
functionapprove(address spender, uint256 value) publicreturns (bool) {
_approve(msg.sender, spender, value);
returntrue;
}
functiontransferFrom(addressfrom, address to, uint256 value) publicreturns (bool) {
_transfer(from, to, value);
_approve(from, msg.sender, _allowances[from][msg.sender].sub(value));
returntrue;
}
functionincreaseAllowance(address spender, uint256 addedValue) publicreturns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].add(addedValue));
returntrue;
}
functiondecreaseAllowance(address spender, uint256 subtractedValue) publicreturns (bool) {
_approve(msg.sender, spender, _allowances[msg.sender][spender].sub(subtractedValue));
returntrue;
}
function_transfer(addressfrom, address to, uint256 value) internal{
require(from!=address(0), "ERC20: transfer from the zero address");
require(to !=address(0), "ERC20: transfer to the zero address");
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
function_mint(address account, uint256 value) internal{
require(account !=address(0), "ERC20: mint to the zero address");
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
function_burn(address account, uint256 value) internal{
require(account !=address(0), "ERC20: burn from the zero address");
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
function_approve(address owner, address spender, uint256 value) internal{
require(owner !=address(0), "ERC20: approve from the zero address");
require(spender !=address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = value;
emit Approval(owner, spender, value);
}
function_burnFrom(address account, uint256 value) internal{
_burn(account, value);
_approve(account, msg.sender, _allowances[account][msg.sender].sub(value));
}
}
pragmasolidity ^0.5.0;import"./IERC20.sol";
import"./SafeMath.sol";
import"./Address.sol";
/**
* @title LOAPROTOCOL
*/librarySafeERC20{
usingSafeMathforuint256;
usingAddressforaddress;
functionsafeTransfer(IERC20 token, address to, uint256 value) internal{
callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
functionsafeTransferFrom(IERC20 token, addressfrom, address to, uint256 value) internal{
callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
functionsafeApprove(IERC20 token, address spender, uint256 value) internal{
// safeApprove should only be called when setting an initial allowance,// or when resetting it to zero. To increase and decrease it, use// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'// solhint-disable-next-line max-line-lengthrequire((value ==0) || (token.allowance(address(this), spender) ==0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
functionsafeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal{
uint256 newAllowance = token.allowance(address(this), spender).add(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
functionsafeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal{
uint256 newAllowance = token.allowance(address(this), spender).sub(value);
callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
functioncallOptionalReturn(IERC20 token, bytesmemory data) private{
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since// we're implementing it ourselves.// A Solidity high level call has three parts:// 1. The target address is checked to verify it contains contract code// 2. The call itself is made, and success asserted// 3. The return value is decoded, which in turn checks the size of the returned data.// solhint-disable-next-line max-line-lengthrequire(address(token).isContract(), "SafeERC20: call to non-contract");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytesmemory returndata) =address(token).call(data);
require(success, "SafeERC20: low-level call failed");
if (returndata.length>0) { // Return data is optional// solhint-disable-next-line max-line-lengthrequire(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
Código Fuente del Contrato
Archivo 8 de 9: SafeMath.sol
pragmasolidity ^0.5.0;librarySafeMath{
functionadd(uint256 a, uint256 b) internalpurereturns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
functionsub(uint256 a, uint256 b) internalpurereturns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
uint256 c = a - b;
return c;
}
functionmul(uint256 a, uint256 b) internalpurereturns (uint256) {
if (a ==0) {
return0;
}
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
functiondiv(uint256 a, uint256 b) internalpurereturns (uint256) {
require(b >0, "SafeMath: division by zero");
uint256 c = a / b;
return c;
}
functionmod(uint256 a, uint256 b) internalpurereturns (uint256) {
require(b !=0, "SafeMath: modulo by zero");
return a % b;
}
}
Código Fuente del Contrato
Archivo 9 de 9: TokenTimelock.sol
pragmasolidity ^0.5.0;import"./SafeERC20.sol";
/**
* @title LOAPROTOCOL
*/contractTokenTimelock{
usingSafeERC20forIERC20;
// ERC20 basic token contract being held
IERC20 private _token;
// beneficiary of tokens after they are releasedaddressprivate _beneficiary;
// timestamp when token release is enableduint256private _releaseTime;
constructor (IERC20 token, address beneficiary, uint256 releaseTime) public{
// solhint-disable-next-line not-rely-on-timerequire(releaseTime >block.timestamp, "TokenTimelock: release time is before current time");
_token = token;
_beneficiary = beneficiary;
_releaseTime = releaseTime;
}
/**
* @return the token being held.
*/functiontoken() publicviewreturns (IERC20) {
return _token;
}
/**
* @return the beneficiary of the tokens.
*/functionbeneficiary() publicviewreturns (address) {
return _beneficiary;
}
/**
* @return the time when the tokens are released.
*/functionreleaseTime() publicviewreturns (uint256) {
return _releaseTime;
}
/**
* @notice Transfers tokens held by timelock to beneficiary.
*/functionrelease() public{
// solhint-disable-next-line not-rely-on-timerequire(block.timestamp>= _releaseTime, "TokenTimelock: current time is before release time");
uint256 amount = _token.balanceOf(address(this));
require(amount >0, "TokenTimelock: no tokens to release");
_token.safeTransfer(_beneficiary, amount);
}
}