Transaction Hash:
Block:
17924275 at Aug-16-2023 02:00:35 AM +UTC
Transaction Fee:
0.00157071 ETH
$3.30
Gas Used:
52,357 Gas / 30 Gwei
Emitted Events:
| 270 |
FOX.Transfer( from=[Receiver] THORChain_Router, to=0x00000000d7C185343e6504E428b8F8B5Ad6C91b8, value=68885680729210000000000 )
|
| 271 |
THORChain_Router.TransferOut( vault=[Sender] 0x8810458a1b50924a7911de6cbd9d35293f152d90, to=0x00000000d7C185343e6504E428b8F8B5Ad6C91b8, asset=FOX, amount=68885680729210000000000, memo=OUT:6C8A9EB75B739B7CDC46A02A2EAFDD6B01BF0D9B61E1E27A78882AC1FA00F5D8 )
|
Account State Difference:
| Address | Before | After | State Difference | ||
|---|---|---|---|---|---|
| 0x8810458A...93f152D90 |
1,499.036815918682922598 Eth
Nonce: 1253
|
1,499.035245208682922598 Eth
Nonce: 1254
| 0.00157071 | ||
| 0xc770EEfA...d808ee52d | |||||
| 0xD37BbE57...a46aD7146 | (THORChain: THORChain Router v4.1.1) | ||||
|
0xE455036E...f81433478
Miner
| (Fee Recipient: 0xe455...478) | 209.452506710174059482 Eth | 209.452944623924778306 Eth | 0.000437913750718824 |
Execution Trace
THORChain_Router.transferOut( to=0x00000000d7C185343e6504E428b8F8B5Ad6C91b8, asset=0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d, amount=68885680729210000000000, memo=OUT:6C8A9EB75B739B7CDC46A02A2EAFDD6B01BF0D9B61E1E27A78882AC1FA00F5D8 )
-
FOX.transfer( to=0x00000000d7C185343e6504E428b8F8B5Ad6C91b8, value=68885680729210000000000 ) => ( True )
transferOut[THORChain_Router (ln:107)]
send[THORChain_Router (ln:111)]transfer[THORChain_Router (ln:113)]payable[THORChain_Router (ln:113)]call[THORChain_Router (ln:117)]encodeWithSignature[THORChain_Router (ln:117)]decode[THORChain_Router (ln:118)]TransferOut[THORChain_Router (ln:121)]
File 1 of 2: THORChain_Router
File 2 of 2: FOX
// SPDX-License-Identifier: MIT
// -------------------
// Router Version: 4.1
// -------------------
pragma solidity 0.8.13;
// ERC20 Interface
interface iERC20 {
function balanceOf(address) external view returns (uint256);
function burn(uint) external;
}
// RUNE Interface
interface iRUNE {
function transferTo(address, uint) external returns (bool);
}
// ROUTER Interface
interface iROUTER {
function depositWithExpiry(address, address, uint, string calldata, uint) external;
}
// THORChain_Router is managed by THORChain Vaults
contract THORChain_Router {
address public RUNE;
struct Coin {
address asset;
uint amount;
}
// Vault allowance for each asset
mapping(address => mapping(address => uint)) private _vaultAllowance;
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
// Emitted for all deposits, the memo distinguishes for swap, add, remove, donate etc
event Deposit(address indexed to, address indexed asset, uint amount, string memo);
// Emitted for all outgoing transfers, the vault dictates who sent it, memo used to track.
event TransferOut(address indexed vault, address indexed to, address asset, uint amount, string memo);
// Emitted for all outgoing transferAndCalls, the vault dictates who sent it, memo used to track.
event TransferOutAndCall(address indexed vault, address target, uint amount, address finalAsset, address to, uint256 amountOutMin, string memo);
// Changes the spend allowance between vaults
event TransferAllowance(address indexed oldVault, address indexed newVault, address asset, uint amount, string memo);
// Specifically used to batch send the entire vault assets
event VaultTransfer(address indexed oldVault, address indexed newVault, Coin[] coins, string memo);
modifier nonReentrant() {
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
_status = _ENTERED;
_;
_status = _NOT_ENTERED;
}
constructor(address rune) {
RUNE = rune;
_status = _NOT_ENTERED;
}
// Deposit with Expiry (preferred)
function depositWithExpiry(address payable vault, address asset, uint amount, string memory memo, uint expiration) external payable {
require(block.timestamp < expiration, "THORChain_Router: expired");
deposit(vault, asset, amount, memo);
}
// Deposit an asset with a memo. ETH is forwarded, ERC-20 stays in ROUTER
function deposit(address payable vault, address asset, uint amount, string memory memo) public payable nonReentrant{
uint safeAmount;
if(asset == address(0)){
safeAmount = msg.value;
bool success = vault.send(safeAmount);
require(success);
} else {
require(msg.value == 0, "THORChain_Router: unexpected eth"); // protect user from accidentally locking up eth
if(asset == RUNE) {
safeAmount = amount;
iRUNE(RUNE).transferTo(address(this), amount);
iERC20(RUNE).burn(amount);
} else {
safeAmount = safeTransferFrom(asset, amount); // Transfer asset
_vaultAllowance[vault][asset] += safeAmount; // Credit to chosen vault
}
}
emit Deposit(vault, asset, safeAmount, memo);
}
//############################## ALLOWANCE TRANSFERS ##############################
// Use for "moving" assets between vaults (asgard<>ygg), as well "churning" to a new Asgard
function transferAllowance(address router, address newVault, address asset, uint amount, string memory memo) external nonReentrant {
if (router == address(this)){
_adjustAllowances(newVault, asset, amount);
emit TransferAllowance(msg.sender, newVault, asset, amount, memo);
} else {
_routerDeposit(router, newVault, asset, amount, memo);
}
}
//############################## ASSET TRANSFERS ##############################
// Any vault calls to transfer any asset to any recipient.
// Note: Contract recipients of ETH are only given 2300 Gas to complete execution.
function transferOut(address payable to, address asset, uint amount, string memory memo) public payable nonReentrant {
uint safeAmount;
if(asset == address(0)){
safeAmount = msg.value;
bool success = to.send(safeAmount); // Send ETH.
if (!success) {
payable(address(msg.sender)).transfer(safeAmount); // For failure, bounce back to vault & continue.
}
} else {
_vaultAllowance[msg.sender][asset] -= amount; // Reduce allowance
(bool success, bytes memory data) = asset.call(abi.encodeWithSignature("transfer(address,uint256)" , to, amount));
require(success && (data.length == 0 || abi.decode(data, (bool))));
safeAmount = amount;
}
emit TransferOut(msg.sender, to, asset, safeAmount, memo);
}
// Any vault calls to transferAndCall on a target contract that conforms with "swapOut(address,address,uint256)"
// Example Memo: "~1b3:ETH.0xFinalToken:0xTo:"
// Aggregator is matched to the last three digits of whitelisted aggregators
// FinalToken, To, amountOutMin come from originating memo
// Memo passed in here is the "OUT:HASH" type
function transferOutAndCall(address payable aggregator, address finalToken, address to, uint256 amountOutMin, string memory memo) public payable nonReentrant {
uint256 _safeAmount = msg.value;
(bool erc20Success, ) = aggregator.call{value:_safeAmount}(abi.encodeWithSignature("swapOut(address,address,uint256)", finalToken, to, amountOutMin));
if (!erc20Success) {
bool ethSuccess = payable(to).send(_safeAmount); // If can't swap, just send the recipient the ETH
if (!ethSuccess) {
payable(address(msg.sender)).transfer(_safeAmount); // For failure, bounce back to vault & continue.
}
}
emit TransferOutAndCall(msg.sender, aggregator, _safeAmount, finalToken, to, amountOutMin, memo);
}
//############################## VAULT MANAGEMENT ##############################
// A vault can call to "return" all assets to an asgard, including ETH.
function returnVaultAssets(address router, address payable asgard, Coin[] memory coins, string memory memo) external payable nonReentrant {
if (router == address(this)){
for(uint i = 0; i < coins.length; i++){
_adjustAllowances(asgard, coins[i].asset, coins[i].amount);
}
emit VaultTransfer(msg.sender, asgard, coins, memo); // Does not include ETH.
} else {
for(uint i = 0; i < coins.length; i++){
_routerDeposit(router, asgard, coins[i].asset, coins[i].amount, memo);
}
}
bool success = asgard.send(msg.value);
require(success);
}
//############################## HELPERS ##############################
function vaultAllowance(address vault, address token) public view returns(uint amount){
return _vaultAllowance[vault][token];
}
// Safe transferFrom in case asset charges transfer fees
function safeTransferFrom(address _asset, uint _amount) internal returns(uint amount) {
uint _startBal = iERC20(_asset).balanceOf(address(this));
(bool success, bytes memory data) = _asset.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", msg.sender, address(this), _amount));
require(success && (data.length == 0 || abi.decode(data, (bool))));
return (iERC20(_asset).balanceOf(address(this)) - _startBal);
}
// Decrements and Increments Allowances between two vaults
function _adjustAllowances(address _newVault, address _asset, uint _amount) internal {
_vaultAllowance[msg.sender][_asset] -= _amount;
_vaultAllowance[_newVault][_asset] += _amount;
}
// Adjust allowance and forwards funds to new router, credits allowance to desired vault
function _routerDeposit(address _router, address _vault, address _asset, uint _amount, string memory _memo) internal {
_vaultAllowance[msg.sender][_asset] -= _amount;
(bool success,) = _asset.call(abi.encodeWithSignature("approve(address,uint256)", _router, _amount)); // Approve to transfer
require(success);
iROUTER(_router).depositWithExpiry(_vault, _asset, _amount, _memo, type(uint).max); // Transfer by depositing
}
}File 2 of 2: FOX
pragma solidity 0.5.4;
interface IERC20 {
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function transferFrom(address from, address to, uint256 value) external returns (bool);
function totalSupply() external view returns (uint256);
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
library SafeMath {
/**
* @dev Multiplies two unsigned integers, reverts on 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-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two unsigned integers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// Solidity only automatically asserts when dividing by 0
require(b > 0);
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
/**
* @dev Subtracts two unsigned integers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two unsigned integers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two unsigned integers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
library Roles {
struct Role {
mapping (address => bool) bearer;
}
/**
* @dev give an account access to this role
*/
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, account));
role.bearer[account] = true;
}
/**
* @dev remove an account's access to this role
*/
function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
role.bearer[account] = false;
}
/**
* @dev check if an account has this role
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0));
return role.bearer[account];
}
}
contract ERC20 is IERC20 {
using SafeMath for uint256;
mapping (address => uint256) private _balances;
mapping (address => mapping (address => uint256)) private _allowed;
uint256 private _totalSupply;
/**
* @dev Total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/**
* @dev Gets the balance of the specified address.
* @param owner The address to query the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address owner) public view returns (uint256) {
return _balances[owner];
}
/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param owner address The address which owns the funds.
* @param spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address owner, address spender) public view returns (uint256) {
return _allowed[owner][spender];
}
/**
* @dev Transfer token for a specified address
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function transfer(address to, uint256 value) public returns (bool) {
_transfer(msg.sender, to, value);
return true;
}
/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
* 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
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
*/
function approve(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = value;
emit Approval(msg.sender, spender, value);
return true;
}
/**
* @dev Transfer tokens from one address to another.
* Note that while this function emits an Approval event, this is not required as per the specification,
* and other compliant implementations may not emit the event.
* @param from address The address which you want to send tokens from
* @param to address The address which you want to transfer to
* @param value uint256 the amount of tokens to be transferred
*/
function transferFrom(address from, address to, uint256 value) public returns (bool) {
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value);
_transfer(from, to, value);
emit Approval(from, msg.sender, _allowed[from][msg.sender]);
return true;
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param addedValue The amount of tokens to increase the allowance by.
*/
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed_[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* Emits an Approval event.
* @param spender The address which will spend the funds.
* @param subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0));
_allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue);
emit Approval(msg.sender, spender, _allowed[msg.sender][spender]);
return true;
}
/**
* @dev Transfer token for a specified addresses
* @param from The address to transfer from.
* @param to The address to transfer to.
* @param value The amount to be transferred.
*/
function _transfer(address from, address to, uint256 value) internal {
require(to != address(0));
_balances[from] = _balances[from].sub(value);
_balances[to] = _balances[to].add(value);
emit Transfer(from, to, value);
}
/**
* @dev Internal function that mints an amount of the token and assigns it to
* an account. This encapsulates the modification of balances such that the
* proper events are emitted.
* @param account The account that will receive the created tokens.
* @param value The amount that will be created.
*/
function _mint(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.add(value);
_balances[account] = _balances[account].add(value);
emit Transfer(address(0), account, value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account.
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burn(address account, uint256 value) internal {
require(account != address(0));
_totalSupply = _totalSupply.sub(value);
_balances[account] = _balances[account].sub(value);
emit Transfer(account, address(0), value);
}
/**
* @dev Internal function that burns an amount of the token of a given
* account, deducting from the sender's allowance for said account. Uses the
* internal burn function.
* Emits an Approval event (reflecting the reduced allowance).
* @param account The account whose tokens will be burnt.
* @param value The amount that will be burnt.
*/
function _burnFrom(address account, uint256 value) internal {
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value);
_burn(account, value);
emit Approval(account, msg.sender, _allowed[account][msg.sender]);
}
}
contract MinterRole {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private _minters;
constructor () internal {
_addMinter(msg.sender);
}
modifier onlyMinter() {
require(isMinter(msg.sender));
_;
}
function isMinter(address account) public view returns (bool) {
return _minters.has(account);
}
function addMinter(address account) public onlyMinter {
_addMinter(account);
}
function renounceMinter() public {
_removeMinter(msg.sender);
}
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
}
contract ERC20Mintable is ERC20, MinterRole {
/**
* @dev Function to mint tokens
* @param to The address that will receive the minted tokens.
* @param value The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address to, uint256 value) public onlyMinter returns (bool) {
_mint(to, value);
return true;
}
}
contract ERC20Capped is ERC20Mintable {
uint256 private _cap;
constructor (uint256 cap) public {
require(cap > 0);
_cap = cap;
}
/**
* @return the cap for the token minting.
*/
function cap() public view returns (uint256) {
return _cap;
}
function _mint(address account, uint256 value) internal {
require(totalSupply().add(value) <= _cap);
super._mint(account, value);
}
}
contract FOX is ERC20, ERC20Capped {
string public constant name = "FOX";
string public constant symbol = "FOX";
uint8 public constant decimals = 18;
constructor() ERC20Capped(1000001337 * (uint(10) ** decimals)) public {
mint(msg.sender, 1000001337 * (uint(10) ** decimals));
}
}