Transaction Hash:
Block:
21024090 at Oct-22-2024 10:25:59 PM +UTC
Transaction Fee:
0.000229906542304206 ETH
$0.60
Gas Used:
43,114 Gas / 5.332526379 Gwei
Emitted Events:
237 |
TimeOwnedUpgradeabilityProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x00000000000000000000000006fd4ba7973a0d39a91734bbc35bc2bcaa99e3b0, 0x00000000000000000000000028c6c06298d514db089934071355e5743bf21d60, 0000000000000000000000000000000000000000000000000000095bc1e9d100 )
|
Account State Difference:
Address | Before | After | State Difference | ||
---|---|---|---|---|---|
0x06FD4bA7...Caa99E3B0 | (Binance Dep: 0x06FD4bA7973a0d39a91734bbc35bC2bCaa99E3B0) |
0.032190731741263156 Eth
Nonce: 16677
|
0.03196082519895895 Eth
Nonce: 16678
| 0.000229906542304206 | |
0x4838B106...B0BAD5f97
Miner
| (Titan Builder) | 6.088767404876810638 Eth | 6.088771935341933276 Eth | 0.000004530465122638 | |
0x4C19596f...AE6543784 |
Execution Trace
TimeOwnedUpgradeabilityProxy.a9059cbb( )

-
TrueFi.transfer( recipient=0x28C6c06298d514Db089934071355E5743bf21d60, amount=10289700000000 ) => ( True )
transfer[ERC20 (ln:817)]
_transfer[ERC20 (ln:818)]
_beforeTokenTransfer[ERC20 (ln:906)]
sub[ERC20 (ln:908)]
add[ERC20 (ln:909)]
Transfer[ERC20 (ln:910)]
_msgSender[ERC20 (ln:818)]
File 1 of 2: TimeOwnedUpgradeabilityProxy
File 2 of 2: TrueFi
// File: @trusttoken/trusttokens/contracts/Proxy/OwnedUpgradeabilityProxy.sol pragma solidity 0.5.13; /** * @title OwnedUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with basic authorization control functionalities */ contract OwnedUpgradeabilityProxy { /** * @dev Event to show ownership has been transferred * @param previousOwner representing the address of the previous owner * @param newOwner representing the address of the new owner */ event ProxyOwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Event to show ownership transfer is pending * @param currentOwner representing the address of the current owner * @param pendingOwner representing the address of the pending owner */ event NewPendingOwner(address currentOwner, address pendingOwner); // Storage position of the owner and pendingOwner of the contract bytes32 private constant proxyOwnerPosition = 0x6279e8199720cf3557ecd8b58d667c8edc486bd1cf3ad59ea9ebdfcae0d0dfac;//keccak256("trueUSD.proxy.owner"); bytes32 private constant pendingProxyOwnerPosition = 0x8ddbac328deee8d986ec3a7b933a196f96986cb4ee030d86cc56431c728b83f4;//keccak256("trueUSD.pending.proxy.owner"); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor() public { _setUpgradeabilityOwner(msg.sender); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyProxyOwner() { require(msg.sender == proxyOwner(), "only Proxy Owner"); _; } /** * @dev Throws if called by any account other than the pending owner. */ modifier onlyPendingProxyOwner() { require(msg.sender == pendingProxyOwner(), "only pending Proxy Owner"); _; } /** * @dev Tells the address of the owner * @return the address of the owner */ function proxyOwner() public view returns (address owner) { bytes32 position = proxyOwnerPosition; assembly { owner := sload(position) } } /** * @dev Tells the address of the owner * @return the address of the owner */ function pendingProxyOwner() public view returns (address pendingOwner) { bytes32 position = pendingProxyOwnerPosition; assembly { pendingOwner := sload(position) } } /** * @dev Sets the address of the owner */ function _setUpgradeabilityOwner(address newProxyOwner) internal { bytes32 position = proxyOwnerPosition; assembly { sstore(position, newProxyOwner) } } /** * @dev Sets the address of the owner */ function _setPendingUpgradeabilityOwner(address newPendingProxyOwner) internal { bytes32 position = pendingProxyOwnerPosition; assembly { sstore(position, newPendingProxyOwner) } } /** * @dev Allows the current owner to transfer control of the contract to a newOwner. *changes the pending owner to newOwner. But doesn't actually transfer * @param newOwner The address to transfer ownership to. */ function transferProxyOwnership(address newOwner) external onlyProxyOwner { require(newOwner != address(0)); _setPendingUpgradeabilityOwner(newOwner); emit NewPendingOwner(proxyOwner(), newOwner); } /** * @dev Allows the pendingOwner to claim ownership of the proxy */ function claimProxyOwnership() external onlyPendingProxyOwner { emit ProxyOwnershipTransferred(proxyOwner(), pendingProxyOwner()); _setUpgradeabilityOwner(pendingProxyOwner()); _setPendingUpgradeabilityOwner(address(0)); } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param implementation representing the address of the new implementation to be set. */ function upgradeTo(address implementation) public onlyProxyOwner { address currentImplementation; bytes32 position = implementationPosition; assembly { currentImplementation := sload(position) } require(currentImplementation != implementation); assembly { sstore(position, implementation) } emit Upgraded(implementation); } /** * @dev This event will be emitted every time the implementation gets upgraded * @param implementation representing the address of the upgraded implementation */ event Upgraded(address indexed implementation); // Storage position of the address of the current implementation bytes32 private constant implementationPosition = 0x6e41e0fbe643dfdb6043698bf865aada82dc46b953f754a3468eaa272a362dc7; //keccak256("trueUSD.proxy.implementation"); function implementation() public view returns (address impl) { bytes32 position = implementationPosition; assembly { impl := sload(position) } } /** * @dev Fallback function allowing to perform a delegatecall to the given implementation. * This function will return whatever the implementation call returns */ function() external payable { bytes32 position = implementationPosition; assembly { let ptr := mload(0x40) calldatacopy(ptr, returndatasize, calldatasize) let result := delegatecall(gas, sload(position), ptr, calldatasize, returndatasize, returndatasize) returndatacopy(ptr, 0, returndatasize) switch result case 0 { revert(ptr, returndatasize) } default { return(ptr, returndatasize) } } } } // File: @trusttoken/trusttokens/contracts/Proxy/TimeOwnedUpgradeabilityProxy.sol pragma solidity 0.5.13; /** * @title TimeOwnedUpgradeabilityProxy * @dev This contract combines an upgradeability proxy with * basic authorization control functionalities * * This contract allows us to specify a time at which the proxy can no longer * be upgraded */ contract TimeOwnedUpgradeabilityProxy is OwnedUpgradeabilityProxy { bytes32 private constant expirationPosition = bytes32(uint256(keccak256('trusttoken.expiration')) - 1); /** * @dev the constructor sets the original owner of the contract to the sender account. */ constructor() public { _setUpgradeabilityOwner(msg.sender); // set expiration to ~4 months from now _setExpiration(block.timestamp + 124 days); } /** * @dev sets new expiration time */ function setExpiration(uint256 newExpirationTime) external onlyProxyOwner { require(block.timestamp < expiration(), "after expiration time"); require(block.timestamp < newExpirationTime, "new expiration time must be in the future"); _setExpiration(newExpirationTime); } function _setExpiration(uint256 newExpirationTime) internal onlyProxyOwner { bytes32 position = expirationPosition; assembly { sstore(position, newExpirationTime) } } function expiration() public view returns (uint256 _expiration) { bytes32 position = expirationPosition; assembly { _expiration := sload(position) } } /** * @dev Allows the proxy owner to upgrade the current version of the proxy. * @param implementation representing the address of the new implementation to be set. */ function upgradeTo(address implementation) public onlyProxyOwner { require(block.timestamp < expiration(), "after expiration date"); super.upgradeTo(implementation); } }
File 2 of 2: TrueFi
/** *Submitted for verification at Etherscan.io on 2020-11-12 */ // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&%&&&&%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&%(, .*#&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&#. ,/#%%%%%%%#(/, *%&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&( /&&&&&&&&&&&&&&&&&&&&&%&%* ,%&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&%, *%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%, (&&&&&&&&&&&&& // &&&&&&&&&&&&&, #&&# ./#&&&&&&&&%, %&&&&&&&&&&& // &&&&&&&&&&&# (&&&&# ,%&&&&&&*/&&&&&&&&&& // &&&&&&&&&&( %&&&&&# /&&&&&&&&&&&&&&&&&&%#, .%&&&&&(%&&&&&&&& // &&&&&&&&&% #&&&&&&# /&&&&&&&&&&&&&&&&&&&&&&&( .%&&&&&&&&&&&&& // &&&&&&&&&/ ,&&&&&&&# /&&&&&&&&&&&&&&&&%%%%&&&&%% /&&&&&&&&&&&& // &&&&&&&&&* /&&&&&&&# %&&&&&&, (&&&&&&&* /&&&&&&&&&&& // &&&&&&&&&/ *&&&&&&&%////////* %&&&&&&, (&&&&&&&&, #&&&&&&&&&& // &&&&&&&&&# &&&&&&&&&&&&&&&&%. %&&&&&&. #&&&&&&&&# *&&&&&&&&&& // &&&&&&&&&&* ,&&%&&&&&&&&&&&&%. %&&&&&( .%&&&&&&&&# *&&&&&&&&&& // &&&&&&&&&&&, .&&&&&&&&&&&&&&%. /&&&&&# #&&&&&&&&&* (&&&&&&&&&& // &&&&&&&&&&&&# ,&&&&&&&&&&&&%.,%&&&&%, %&&&&&&&&&# .%&&&&&&&&&& // &&&&&&&&&&&&&&( ,#&&&&&&&&&&&&&&( (&&&&&&&&&&/ .%&&&&&&&&&&& // &&&&&&&&&&&&&&&&&* .. ,%&&&&&&&&&&# *&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&%(. ./%&&&&&&&&&&&%* *&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&%(. .#&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&%/(%&&&&&&&&&&&&%#/. *%&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&%(, ,(%&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; /** * @dev Wrappers over Solidity's arithmetic operations with added overflow * checks. * * Arithmetic operations in Solidity wrap on overflow. This can easily result * in bugs, because programmers usually assume that an overflow raises an * error, which is the standard behavior in high level programming languages. * `SafeMath` restores this intuition by reverting the transaction when an * operation overflows. * * Using this library instead of the unchecked operations eliminates an entire * class of bugs, so it's recommended to use it always. */ library SafeMath { /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { uint256 c = a + b; require(c >= a, "SafeMath: addition overflow"); return c; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return sub(a, b, "SafeMath: subtraction overflow"); } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b <= a, errorMessage); uint256 c = a - b; return c; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) { return 0; } uint256 c = a * b; require(c / a == b, "SafeMath: multiplication overflow"); return c; } /** * @dev Returns the integer division of two unsigned integers. Reverts on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return div(a, b, "SafeMath: division by zero"); } /** * @dev Returns the integer division of two unsigned integers. Reverts with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b > 0, errorMessage); uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold return c; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return mod(a, b, "SafeMath: modulo by zero"); } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * Reverts with custom message when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) { require(b != 0, errorMessage); return a % b; } } pragma solidity ^0.6.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20 { /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `recipient`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address recipient, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `sender` to `recipient` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom(address sender, address recipient, uint256 amount) external returns (bool); /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); } pragma solidity 0.6.10; interface RegistryClone { function syncAttributeValue( address _who, bytes32 _attribute, uint256 _value ) external; } contract Registry { struct AttributeData { uint256 value; bytes32 notes; address adminAddr; uint256 timestamp; } // never remove any storage variables address public owner; address public pendingOwner; bool initialized; // Stores arbitrary attributes for users. An example use case is an IERC20 // token that requires its users to go through a KYC/AML check - in this case // a validator can set an account's "hasPassedKYC/AML" attribute to 1 to indicate // that account can use the token. This mapping stores that value (1, in the // example) as well as which validator last set the value and at what time, // so that e.g. the check can be renewed at appropriate intervals. mapping(address => mapping(bytes32 => AttributeData)) attributes; // The logic governing who is allowed to set what attributes is abstracted as // this accessManager, so that it may be replaced by the owner as needed bytes32 constant WRITE_PERMISSION = keccak256("canWriteTo-"); mapping(bytes32 => RegistryClone[]) subscribers; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event SetAttribute(address indexed who, bytes32 attribute, uint256 value, bytes32 notes, address indexed adminAddr); event SetManager(address indexed oldManager, address indexed newManager); event StartSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber); event StopSubscription(bytes32 indexed attribute, RegistryClone indexed subscriber); // Allows a write if either a) the writer is that Registry's owner, or // b) the writer is writing to attribute foo and that writer already has // the canWriteTo-foo attribute set (in that same Registry) function confirmWrite(bytes32 _attribute, address _admin) internal view returns (bool) { return (_admin == owner || hasAttribute(_admin, keccak256(abi.encodePacked(WRITE_PERMISSION ^ _attribute)))); } // Writes are allowed only if the accessManager approves function setAttribute( address _who, bytes32 _attribute, uint256 _value, bytes32 _notes ) public { require(confirmWrite(_attribute, msg.sender)); attributes[_who][_attribute] = AttributeData(_value, _notes, msg.sender, block.timestamp); emit SetAttribute(_who, _attribute, _value, _notes, msg.sender); RegistryClone[] storage targets = subscribers[_attribute]; uint256 index = targets.length; while (index-- > 0) { targets[index].syncAttributeValue(_who, _attribute, _value); } } function subscribe(bytes32 _attribute, RegistryClone _syncer) external onlyOwner { subscribers[_attribute].push(_syncer); emit StartSubscription(_attribute, _syncer); } function unsubscribe(bytes32 _attribute, uint256 _index) external onlyOwner { uint256 length = subscribers[_attribute].length; require(_index < length); emit StopSubscription(_attribute, subscribers[_attribute][_index]); subscribers[_attribute][_index] = subscribers[_attribute][length - 1]; subscribers[_attribute].pop(); } function subscriberCount(bytes32 _attribute) public view returns (uint256) { return subscribers[_attribute].length; } function setAttributeValue( address _who, bytes32 _attribute, uint256 _value ) public { require(confirmWrite(_attribute, msg.sender)); attributes[_who][_attribute] = AttributeData(_value, "", msg.sender, block.timestamp); emit SetAttribute(_who, _attribute, _value, "", msg.sender); RegistryClone[] storage targets = subscribers[_attribute]; uint256 index = targets.length; while (index-- > 0) { targets[index].syncAttributeValue(_who, _attribute, _value); } } // Returns true if the uint256 value stored for this attribute is non-zero function hasAttribute(address _who, bytes32 _attribute) public view returns (bool) { return attributes[_who][_attribute].value != 0; } // Returns the exact value of the attribute, as well as its metadata function getAttribute(address _who, bytes32 _attribute) public view returns ( uint256, bytes32, address, uint256 ) { AttributeData memory data = attributes[_who][_attribute]; return (data.value, data.notes, data.adminAddr, data.timestamp); } function getAttributeValue(address _who, bytes32 _attribute) public view returns (uint256) { return attributes[_who][_attribute].value; } function getAttributeAdminAddr(address _who, bytes32 _attribute) public view returns (address) { return attributes[_who][_attribute].adminAddr; } function getAttributeTimestamp(address _who, bytes32 _attribute) public view returns (uint256) { return attributes[_who][_attribute].timestamp; } function syncAttribute( bytes32 _attribute, uint256 _startIndex, address[] calldata _addresses ) external { RegistryClone[] storage targets = subscribers[_attribute]; uint256 index = targets.length; while (index-- > _startIndex) { RegistryClone target = targets[index]; for (uint256 i = _addresses.length; i-- > 0; ) { address who = _addresses[i]; target.syncAttributeValue(who, _attribute, attributes[who][_attribute].value); } } } function reclaimEther(address payable _to) external onlyOwner { _to.transfer(address(this).balance); } function reclaimToken(IERC20 token, address _to) external onlyOwner { uint256 balance = token.balanceOf(address(this)); token.transfer(_to, balance); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner, "only Owner"); _; } /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { emit OwnershipTransferred(owner, pendingOwner); owner = pendingOwner; pendingOwner = address(0); } } pragma solidity 0.6.10; /** * All storage must be declared here * New storage must be appended to the end * Never remove items from this list */ contract ProxyStorage { bool initalized; uint256 public totalSupply; mapping(address => uint256) public balanceOf; mapping(address => mapping(address => uint256)) public allowance; mapping(uint144 => uint256) attributes; // see RegistrySubscriber address owner_; address pendingOwner_; /* Additionally, we have several keccak-based storage locations. * If you add more keccak-based storage mappings, such as mappings, you must document them here. * If the length of the keccak input is the same as an existing mapping, it is possible there could be a preimage collision. * A preimage collision can be used to attack the contract by treating one storage location as another, * which would always be a critical issue. * Carefully examine future keccak-based storage to ensure there can be no preimage collisions. ******************************************************************************************************* ** length input usage ******************************************************************************************************* ** 19 "trueXXX.proxy.owner" Proxy Owner ** 27 "trueXXX.pending.proxy.owner" Pending Proxy Owner ** 28 "trueXXX.proxy.implementation" Proxy Implementation ** 64 uint256(address),uint256(1) balanceOf ** 64 uint256(address),keccak256(uint256(address),uint256(2)) allowance ** 64 uint256(address),keccak256(bytes32,uint256(3)) attributes **/ } pragma solidity 0.6.10; /** * @title ClaimableContract * @dev The ClaimableContract contract is a copy of Claimable Contract by Zeppelin. and provides basic authorization control functions. Inherits storage layout of ProxyStorage. */ contract ClaimableContract is ProxyStorage { function owner() public view returns (address) { return owner_; } function pendingOwner() public view returns (address) { return pendingOwner_; } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev sets the original `owner` of the contract to the sender * at construction. Must then be reinitialized */ constructor() public { owner_ = msg.sender; emit OwnershipTransferred(address(0), msg.sender); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { require(msg.sender == owner_, "only owner"); _; } /** * @dev Modifier throws if called by any account other than the pendingOwner. */ modifier onlyPendingOwner() { require(msg.sender == pendingOwner_); _; } /** * @dev Allows the current owner to set the pendingOwner address. * @param newOwner The address to transfer ownership to. */ function transferOwnership(address newOwner) public onlyOwner { pendingOwner_ = newOwner; } /** * @dev Allows the pendingOwner address to finalize the transfer. */ function claimOwnership() public onlyPendingOwner { address _pendingOwner = pendingOwner_; emit OwnershipTransferred(owner_, _pendingOwner); owner_ = _pendingOwner; pendingOwner_ = address(0); } } pragma solidity ^0.6.0; /* * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with GSN meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address payable) { return msg.sender; } function _msgData() internal view virtual returns (bytes memory) { this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691 return msg.data; } } pragma solidity ^0.6.2; /** * @dev Collection of functions related to the address type */ library Address { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // According to EIP-1052, 0x0 is the value returned for not-yet created accounts // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned // for accounts without code, i.e. `keccak256('')` bytes32 codehash; bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470; // solhint-disable-next-line no-inline-assembly assembly { codehash := extcodehash(account) } return (codehash != accountHash && codehash != 0x0); } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); // solhint-disable-next-line avoid-low-level-calls, avoid-call-value (bool success, ) = recipient.call{ value: amount }(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain`call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) { return _functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ 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"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ 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"); // solhint-disable-next-line avoid-low-level-calls (bool success, bytes memory returndata) = target.call{ value: weiValue }(data); if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly // solhint-disable-next-line no-inline-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File: contracts/trusttoken/common/ERC20.sol /** * @notice This is a copy of openzeppelin ERC20 contract with removed state variables. * Removing state variables has been necessary due to proxy pattern usage. * Changes to Openzeppelin ERC20 https://github.com/OpenZeppelin/openzeppelin-contracts/blob/de99bccbfd4ecd19d7369d01b070aa72c64423c9/contracts/token/ERC20/ERC20.sol: * - Remove state variables _name, _symbol, _decimals * - Use state variables balances, allowances, totalSupply from ProxyStorage * - Remove constructor * - Solidity version changed from ^0.6.0 to 0.6.10 * - Contract made abstract * - Remove inheritance from IERC20 because of ProxyStorage name conflicts * * See also: ClaimableOwnable.sol and ProxyStorage.sol */ pragma solidity 0.6.10; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin guidelines: functions revert instead * of returning `false` on failure. This behavior is nonetheless conventional * and does not conflict with the expectations of ERC20 applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ abstract contract ERC20 is ProxyStorage, Context { using SafeMath for uint256; using Address for address; /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the name of the token. */ function name() public virtual pure returns (string memory); /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public virtual pure returns (string memory); /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5,05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless {_setupDecimals} is * called. * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public virtual pure returns (uint8) { return 18; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `recipient` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address recipient, uint256 amount) public virtual returns (bool) { _transfer(_msgSender(), recipient, amount); return true; } /** * @dev See {IERC20-approve}. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual returns (bool) { _approve(_msgSender(), spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool) { _transfer(sender, recipient, amount); _approve(sender, _msgSender(), allowance[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, allowance[_msgSender()][spender].add(addedValue)); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { _approve(_msgSender(), spender, allowance[_msgSender()][spender].sub(subtractedValue, "ERC20: decreased allowance below zero")); return true; } /** * @dev Moves tokens `amount` from `sender` to `recipient`. * * This is internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `sender` cannot be the zero address. * - `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. */ 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); balanceOf[sender] = balanceOf[sender].sub(amount, "ERC20: transfer amount exceeds balance"); balanceOf[recipient] = balanceOf[recipient].add(amount); emit Transfer(sender, recipient, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements * * - `to` cannot be the zero address. */ 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); balanceOf[account] = balanceOf[account].add(amount); emit Transfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); balanceOf[account] = balanceOf[account].sub(amount, "ERC20: burn amount exceeds balance"); totalSupply = totalSupply.sub(amount); emit Transfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner`s tokens. * * This is internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ 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"); allowance[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be to transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ // solhint-disable-next-line no-empty-blocks function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual { } } pragma solidity 0.6.10; /** * @title TimeLockedToken * @notice Time Locked ERC20 Token * @author Harold Hyatt * @dev Contract which gives the ability to time-lock tokens * * The registerLockup() function allows an account to transfer * its tokens to another account, locking them according to the * distribution epoch periods * * By overriding the balanceOf(), transfer(), and transferFrom() * functions in ERC20, an account can show its full, post-distribution * balance but only transfer or spend up to an allowed amount * * Every time an epoch passes, a portion of previously non-spendable tokens * are allowed to be transferred, and after all epochs have passed, the full * account balance is unlocked */ abstract contract TimeLockedToken is ERC20, ClaimableContract { using SafeMath for uint256; // represents total distribution for locked balances mapping(address => uint256) distribution; // start of the lockup period // Friday, July 24, 2020 4:58:31 PM GMT uint256 constant LOCK_START = 1595609911; // length of time to delay first epoch uint256 constant FIRST_EPOCH_DELAY = 30 days; // how long does an epoch last uint256 constant EPOCH_DURATION = 90 days; // number of epochs uint256 constant TOTAL_EPOCHS = 8; // registry of locked addresses address public timeLockRegistry; // allow unlocked transfers to special account bool public returnsLocked; modifier onlyTimeLockRegistry() { require(msg.sender == timeLockRegistry, "only TimeLockRegistry"); _; } /** * @dev Set TimeLockRegistry address * @param newTimeLockRegistry Address of TimeLockRegistry contract */ function setTimeLockRegistry(address newTimeLockRegistry) external onlyOwner { require(newTimeLockRegistry != address(0), "cannot be zero address"); require(newTimeLockRegistry != timeLockRegistry, "must be new TimeLockRegistry"); timeLockRegistry = newTimeLockRegistry; } /** * @dev Permanently lock transfers to return address * Lock returns so there isn't always a way to send locked tokens */ function lockReturns() external onlyOwner { returnsLocked = true; } /** * @dev Transfer function which includes unlocked tokens * Locked tokens can always be transfered back to the returns address * Transferring to owner allows re-issuance of funds through registry * * @param _from The address to send tokens from * @param _to The address that will receive the tokens * @param _value The amount of tokens to be transferred */ function _transfer( address _from, address _to, uint256 _value ) internal override { require(balanceOf[_from] >= _value, "insufficient balance"); // transfers to owner proceed as normal when returns allowed if (!returnsLocked && _to == owner_) { transferToOwner(_from, _value); return; } // check if enough unlocked balance to transfer require(unlockedBalance(_from) >= _value, "attempting to transfer locked funds"); super._transfer(_from, _to, _value); } /** * @dev Transfer tokens to owner. Used only when returns allowed. * @param _from The address to send tokens from * @param _value The amount of tokens to be transferred */ function transferToOwner(address _from, uint256 _value) internal { uint256 unlocked = unlockedBalance(_from); if (unlocked < _value) { // We want to have unlocked = value, i.e. // value = balance - distribution * epochsLeft / totalEpochs // distribution = (balance - value) * totalEpochs / epochsLeft distribution[_from] = balanceOf[_from].sub(_value).mul(TOTAL_EPOCHS).div(epochsLeft()); } super._transfer(_from, owner_, _value); } /** * @dev Check if amount we want to burn is unlocked before burning * @param _from The address whose tokens will burn * @param _value The amount of tokens to be burnt */ function _burn(address _from, uint256 _value) internal override { require(balanceOf[_from] >= _value, "insufficient balance"); require(unlockedBalance(_from) >= _value, "attempting to burn locked funds"); super._burn(_from, _value); } /** * @dev Transfer tokens to another account under the lockup schedule * Emits a transfer event showing a transfer to the recipient * Only the registry can call this function * @param receiver Address to receive the tokens * @param amount Tokens to be transferred */ function registerLockup(address receiver, uint256 amount) external onlyTimeLockRegistry { require(balanceOf[msg.sender] >= amount, "insufficient balance"); // add amount to locked distribution distribution[receiver] = distribution[receiver].add(amount); // transfer to recipient _transfer(msg.sender, receiver, amount); } /** * @dev Get locked balance for an account * @param account Account to check * @return Amount locked */ function lockedBalance(address account) public view returns (uint256) { // distribution * (epochsLeft / totalEpochs) return distribution[account].mul(epochsLeft()).div(TOTAL_EPOCHS); } /** * @dev Get unlocked balance for an account * @param account Account to check * @return Amount that is unlocked and available eg. to transfer */ function unlockedBalance(address account) public view returns (uint256) { // totalBalance - lockedBalance return balanceOf[account].sub(lockedBalance(account)); } /* * @dev Get number of epochs passed * @return Value between 0 and 8 of lockup epochs already passed */ function epochsPassed() public view returns (uint256) { // return 0 if timestamp is lower than start time if (block.timestamp < LOCK_START) { return 0; } // how long it has been since the beginning of lockup period uint256 timePassed = block.timestamp.sub(LOCK_START); // 1st epoch is FIRST_EPOCH_DELAY longer; we check to prevent subtraction underflow if (timePassed < FIRST_EPOCH_DELAY) { return 0; } // subtract the FIRST_EPOCH_DELAY, so that we can count all epochs as lasting EPOCH_DURATION uint256 totalEpochsPassed = timePassed.sub(FIRST_EPOCH_DELAY).div(EPOCH_DURATION); // epochs don't count over TOTAL_EPOCHS if (totalEpochsPassed > TOTAL_EPOCHS) { return TOTAL_EPOCHS; } return totalEpochsPassed; } function epochsLeft() public view returns (uint256) { return TOTAL_EPOCHS.sub(epochsPassed()); } /** * @dev Get timestamp of next epoch * Will revert if all epochs have passed * @return Timestamp of when the next epoch starts */ function nextEpoch() public view returns (uint256) { // get number of epochs passed uint256 passed = epochsPassed(); // if all epochs passed, return if (passed == TOTAL_EPOCHS) { // return INT_MAX return uint256(-1); } // if no epochs passed, return latest epoch + delay + standard duration if (passed == 0) { return latestEpoch().add(FIRST_EPOCH_DELAY).add(EPOCH_DURATION); } // otherwise return latest epoch + epoch duration return latestEpoch().add(EPOCH_DURATION); } /** * @dev Get timestamp of latest epoch * @return Timestamp of when the current epoch has started */ function latestEpoch() public view returns (uint256) { // get number of epochs passed uint256 passed = epochsPassed(); // if no epochs passed, return lock start time if (passed == 0) { return LOCK_START; } // accounts for first epoch being longer // lockStart + firstEpochDelay + (epochsPassed * epochDuration) return LOCK_START.add(FIRST_EPOCH_DELAY).add(passed.mul(EPOCH_DURATION)); } /** * @dev Get timestamp of final epoch * @return Timestamp of when the last epoch ends and all funds are released */ function finalEpoch() public pure returns (uint256) { // lockStart + firstEpochDelay + (epochDuration * totalEpochs) return LOCK_START.add(FIRST_EPOCH_DELAY).add(EPOCH_DURATION.mul(TOTAL_EPOCHS)); } /** * @dev Get timestamp of locking period start * @return Timestamp of locking period start */ function lockStart() public pure returns (uint256) { return LOCK_START; } } pragma solidity 0.6.10; /** * @title TrustToken * @dev The TrustToken contract is a claimable contract where the * owner can only mint or transfer ownership. TrustTokens use 8 decimals * in order to prevent rewards from getting stuck in the remainder on division. * Tolerates dilution to slash stake and accept rewards. */ contract TrueFi is TimeLockedToken { using SafeMath for uint256; uint256 constant MAX_SUPPLY = 145000000000000000; /** * @dev initialize trusttoken and give ownership to sender * This is necessary to set ownership for proxy */ function initialize() public { require(!initalized, "already initialized"); owner_ = msg.sender; initalized = true; } /** * @dev mint TRU * Can never mint more than MAX_SUPPLY = 1.45 billion */ function mint(address _to, uint256 _amount) external onlyOwner { if (totalSupply.add(_amount) <= MAX_SUPPLY) { _mint(_to, _amount); } else { revert("Max supply exceeded"); } } function burn(uint256 amount) external { _burn(msg.sender, amount); } function decimals() public override pure returns (uint8) { return 8; } function rounding() public pure returns (uint8) { return 8; } function name() public override pure returns (string memory) { return "TrueFi"; } function symbol() public override pure returns (string memory) { return "TRU"; } }