// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @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 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) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
library BytesLib {
function concat(
bytes memory _preBytes,
bytes memory _postBytes
)
internal
pure
returns (bytes memory)
{
bytes memory tempBytes;
assembly {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// Store the length of the first bytes array at the beginning of
// the memory for tempBytes.
let length := mload(_preBytes)
mstore(tempBytes, length)
// Maintain a memory counter for the current write location in the
// temp bytes array by adding the 32 bytes for the array length to
// the starting location.
let mc := add(tempBytes, 0x20)
// Stop copying when the memory counter reaches the length of the
// first bytes array.
let end := add(mc, length)
for {
// Initialize a copy counter to the start of the _preBytes data,
// 32 bytes into its memory.
let cc := add(_preBytes, 0x20)
} lt(mc, end) {
// Increase both counters by 32 bytes each iteration.
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// Write the _preBytes data into the tempBytes memory 32 bytes
// at a time.
mstore(mc, mload(cc))
}
// Add the length of _postBytes to the current length of tempBytes
// and store it as the new length in the first 32 bytes of the
// tempBytes memory.
length := mload(_postBytes)
mstore(tempBytes, add(length, mload(tempBytes)))
// Move the memory counter back from a multiple of 0x20 to the
// actual end of the _preBytes data.
mc := end
// Stop copying when the memory counter reaches the new combined
// length of the arrays.
end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
// Update the free-memory pointer by padding our last write location
// to 32 bytes: add 31 bytes to the end of tempBytes to move to the
// next 32 byte block, then round down to the nearest multiple of
// 32. If the sum of the length of the two arrays is zero then add
// one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(0x40, and(
add(add(end, iszero(add(length, mload(_preBytes)))), 31),
not(31) // Round down to the nearest 32 bytes.
))
}
return tempBytes;
}
function concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
assembly {
// Read the first 32 bytes of _preBytes storage, which is the length
// of the array. (We don't need to use the offset into the slot
// because arrays use the entire slot.)
let fslot := sload(_preBytes.slot)
// Arrays of 31 bytes or less have an even value in their slot,
// while longer arrays have an odd value. The actual length is
// the slot divided by two for odd values, and the lowest order
// byte divided by two for even values.
// If the slot is even, bitwise and the slot with 255 and divide by
// two to get the length. If the slot is odd, bitwise and the slot
// with -1 and divide by two.
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
let newlength := add(slength, mlength)
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
switch add(lt(slength, 32), lt(newlength, 32))
case 2 {
// Since the new array still fits in the slot, we just need to
// update the contents of the slot.
// uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
sstore(
_preBytes.slot,
// all the modifications to the slot are inside this
// next block
add(
// we can just add to the slot contents because the
// bytes we want to change are the LSBs
fslot,
add(
mul(
div(
// load the bytes from memory
mload(add(_postBytes, 0x20)),
// zero all bytes to the right
exp(0x100, sub(32, mlength))
),
// and now shift left the number of bytes to
// leave space for the length in the slot
exp(0x100, sub(32, newlength))
),
// increase length by the double of the memory
// bytes length
mul(mlength, 2)
)
)
)
}
case 1 {
// The stored value fits in the slot, but the combined value
// will exceed it.
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// The contents of the _postBytes array start 32 bytes into
// the structure. Our first read should obtain the `submod`
// bytes that can fit into the unused space in the last word
// of the stored array. To get this, we read 32 bytes starting
// from `submod`, so the data we read overlaps with the array
// contents by `submod` bytes. Masking the lowest-order
// `submod` bytes allows us to add that value directly to the
// stored value.
let submod := sub(32, slength)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(
sc,
add(
and(
fslot,
0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
),
and(mload(mc), mask)
)
)
for {
mc := add(mc, 0x20)
sc := add(sc, 1)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
default {
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
// Start copying to the last used word of the stored array.
let sc := add(keccak256(0x0, 0x20), div(slength, 32))
// save new length
sstore(_preBytes.slot, add(mul(newlength, 2), 1))
// Copy over the first `submod` bytes of the new data as in
// case 1 above.
let slengthmod := mod(slength, 32)
let mlengthmod := mod(mlength, 32)
let submod := sub(32, slengthmod)
let mc := add(_postBytes, submod)
let end := add(_postBytes, mlength)
let mask := sub(exp(0x100, submod), 1)
sstore(sc, add(sload(sc), and(mload(mc), mask)))
for {
sc := add(sc, 1)
mc := add(mc, 0x20)
} lt(mc, end) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
sstore(sc, mload(mc))
}
mask := exp(0x100, sub(mc, end))
sstore(sc, mul(div(mload(mc), mask), mask))
}
}
}
function slice(
bytes memory _bytes,
uint256 _start,
uint256 _length
)
internal
pure
returns (bytes memory)
{
require(_length + 31 >= _length, "slice_overflow");
require(_bytes.length >= _start + _length, "slice_outOfBounds");
bytes memory tempBytes;
assembly {
switch iszero(_length)
case 0 {
// Get a location of some free memory and store it in tempBytes as
// Solidity does for memory variables.
tempBytes := mload(0x40)
// The first word of the slice result is potentially a partial
// word read from the original array. To read it, we calculate
// the length of that partial word and start copying that many
// bytes into the array. The first word we copy will start with
// data we don't care about, but the last `lengthmod` bytes will
// land at the beginning of the contents of the new array. When
// we're done copying, we overwrite the full first word with
// the actual length of the slice.
let lengthmod := and(_length, 31)
// The multiplication in the next line is necessary
// because when slicing multiples of 32 bytes (lengthmod == 0)
// the following copy loop was copying the origin's length
// and then ending prematurely not copying everything it should.
let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
let end := add(mc, _length)
for {
// The multiplication in the next line has the same exact purpose
// as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
} lt(mc, end) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
mstore(mc, mload(cc))
}
mstore(tempBytes, _length)
//update free-memory pointer
//allocating the array padded to 32 bytes like the compiler does now
mstore(0x40, and(add(mc, 31), not(31)))
}
//if we want a zero-length slice let's just return a zero-length array
default {
tempBytes := mload(0x40)
//zero out the 32 bytes slice we are about to return
//we need to do it because Solidity does not garbage collect
mstore(tempBytes, 0)
mstore(0x40, add(tempBytes, 0x20))
}
}
return tempBytes;
}
function toAddress(bytes memory _bytes, uint256 _start) internal pure returns (address) {
require(_bytes.length >= _start + 20, "toAddress_outOfBounds");
address tempAddress;
assembly {
tempAddress := div(mload(add(add(_bytes, 0x20), _start)), 0x1000000000000000000000000)
}
return tempAddress;
}
function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
require(_bytes.length >= _start + 1 , "toUint8_outOfBounds");
uint8 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x1), _start))
}
return tempUint;
}
function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
require(_bytes.length >= _start + 2, "toUint16_outOfBounds");
uint16 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x2), _start))
}
return tempUint;
}
function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
require(_bytes.length >= _start + 4, "toUint32_outOfBounds");
uint32 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x4), _start))
}
return tempUint;
}
function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
require(_bytes.length >= _start + 8, "toUint64_outOfBounds");
uint64 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x8), _start))
}
return tempUint;
}
function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
require(_bytes.length >= _start + 12, "toUint96_outOfBounds");
uint96 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0xc), _start))
}
return tempUint;
}
function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
require(_bytes.length >= _start + 16, "toUint128_outOfBounds");
uint128 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x10), _start))
}
return tempUint;
}
function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
require(_bytes.length >= _start + 32, "toUint256_outOfBounds");
uint256 tempUint;
assembly {
tempUint := mload(add(add(_bytes, 0x20), _start))
}
return tempUint;
}
function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
require(_bytes.length >= _start + 32, "toBytes32_outOfBounds");
bytes32 tempBytes32;
assembly {
tempBytes32 := mload(add(add(_bytes, 0x20), _start))
}
return tempBytes32;
}
function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
bool success = true;
assembly {
let length := mload(_preBytes)
// if lengths don't match the arrays are not equal
switch eq(length, mload(_postBytes))
case 1 {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
let mc := add(_preBytes, 0x20)
let end := add(mc, length)
for {
let cc := add(_postBytes, 0x20)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
} eq(add(lt(mc, end), cb), 2) {
mc := add(mc, 0x20)
cc := add(cc, 0x20)
} {
// if any of these checks fails then arrays are not equal
if iszero(eq(mload(mc), mload(cc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
function equalStorage(
bytes storage _preBytes,
bytes memory _postBytes
)
internal
view
returns (bool)
{
bool success = true;
assembly {
// we know _preBytes_offset is 0
let fslot := sload(_preBytes.slot)
// Decode the length of the stored array like in concatStorage().
let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
let mlength := mload(_postBytes)
// if lengths don't match the arrays are not equal
switch eq(slength, mlength)
case 1 {
// slength can contain both the length and contents of the array
// if length < 32 bytes so let's prepare for that
// v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
if iszero(iszero(slength)) {
switch lt(slength, 32)
case 1 {
// blank the last byte which is the length
fslot := mul(div(fslot, 0x100), 0x100)
if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
// unsuccess:
success := 0
}
}
default {
// cb is a circuit breaker in the for loop since there's
// no said feature for inline assembly loops
// cb = 1 - don't breaker
// cb = 0 - break
let cb := 1
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes.slot)
let sc := keccak256(0x0, 0x20)
let mc := add(_postBytes, 0x20)
let end := add(mc, mlength)
// the next line is the loop condition:
// while(uint256(mc < end) + cb == 2)
for {} eq(add(lt(mc, end), cb), 2) {
sc := add(sc, 1)
mc := add(mc, 0x20)
} {
if iszero(eq(sload(sc), mload(mc))) {
// unsuccess:
success := 0
cb := 0
}
}
}
}
}
default {
// unsuccess:
success := 0
}
}
return success;
}
}
/**
* @title Zap router interface
* @author kexley, Beefy
* @notice Interface for zap router that contains the structs for orders and routes
*/
interface IBeefyZapRouter {
/**
* @dev Input token and amount used in a step of the zap
* @param token Address of token
* @param amount Amount of token
*/
struct Input {
address token;
uint256 amount;
}
/**
* @dev Output token and amount from the end of the zap
* @param token Address of token
* @param minOutputAmount Minimum amount of token received
*/
struct Output {
address token;
uint256 minOutputAmount;
}
/**
* @dev External call at the end of zap
* @param target Target address to be called
* @param value Ether value of the call
* @param data Payload to call target address with
*/
struct Relay {
address target;
uint256 value;
bytes data;
}
/**
* @dev Token relevant to the current step of the route
* @param token Address of token
* @param index Location in the data that the balance of the token should be inserted
*/
struct StepToken {
address token;
int32 index;
}
/**
* @dev Step in a route
* @param target Target address to be called
* @param value Ether value to call the target address with
* @param data Payload to call target address with
* @param tokens Tokens relevant to the step that require approvals or their balances inserted
* into the data
*/
struct Step {
address target;
uint256 value;
bytes data;
StepToken[] tokens;
}
/**
* @dev Order created by the user
* @param inputs Tokens and amounts to be pulled from the user
* @param outputs Tokens and minimums to be sent to recipient
* @param relay External call to make after zap is completed
* @param user Source of input tokens
* @param recipient Destination of output tokens
*/
struct Order {
Input[] inputs;
Output[] outputs;
Relay relay;
address user;
address recipient;
}
/**
* @notice Execute an order directly
* @param _order Order created by the user
* @param _route Route supplied by user
*/
function executeOrder(Order calldata _order, Step[] calldata _route) external payable;
/**
* @notice Execute an order on behalf of a user
* @param _permit Token permits from Permit2 with the order as witness data signed by user
* @param _order Order created by user that was signed in the permit
* @param _signature Signature from user of combined permit and order
* @param _route Route supplied by user or third-party
*/
function executeOrder(
IPermit2.PermitBatchTransferFrom calldata _permit,
Order calldata _order,
bytes calldata _signature,
Step[] calldata _route
) external;
/**
* @notice Pause the contract from carrying out any more zaps
* @dev Only owner can pause
*/
function pause() external;
/**
* @notice Unpause the contract to allow new zaps
* @dev Only owner can unpause
*/
function unpause() external;
/**
* @notice Permit2 immutable address
*/
function permit2() external view returns (address);
/**
* @notice Token manager immutable address
*/
function tokenManager() external view returns (address);
}
/**
* @title Token manager interface
* @author kexley, Beefy
* @notice Interface for the token manager
*/
interface IBeefyTokenManager {
/**
* @notice Pull tokens from a user
* @param _user Address of user to transfer tokens from
* @param _inputs Addresses and amounts of tokens to transfer
*/
function pullTokens(address _user, IBeefyZapRouter.Input[] calldata _inputs) external;
}
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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 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 `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, 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 `from` to `to` 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 from, address to, uint256 amount) external returns (bool);
}
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
/**
* @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
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @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://consensys.net/diligence/blog/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.8.0/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");
(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 functionCallWithValue(target, data, 0, "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");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(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'
require(
(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));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Compatible with tokens that require the approval to be set to
* 0 before setting it to a non-zero value.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory 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. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}
/**
* @title Permit2 interface
* @author kexley, Beefy
* @notice Interface for Permit2
*/
interface IPermit2 {
/**
* @dev Token and amount in a permit message
* @param token Address of token to transfer
* @param amount Amount of token to transfer
*/
struct TokenPermissions {
address token;
uint256 amount;
}
/**
* @dev Batched permit with the unique nonce and deadline
* @param permitted Tokens and corresponding amounts permitted for a transfer
* @param nonce Unique value for every token owner's signature to prevent signature replays
* @param deadline Deadline on the permit signature
*/
struct PermitBatchTransferFrom {
TokenPermissions[] permitted;
uint256 nonce;
uint256 deadline;
}
/**
* @dev Transfer details for permitBatchTransferFrom
* @param to Recipient of tokens
* @param requestedAmount Amount to transfer
*/
struct SignatureTransferDetails {
address to;
uint256 requestedAmount;
}
/**
* @notice Consume a permit2 message and transfer tokens
* @param permit Batched permit
* @param transferDetails Recipient and amount of tokens to transfer
* @param owner Source of tokens
* @param witness Verified order data that was witnessed in the permit2 signature
* @param witnessTypeString Order function string used to create EIP-712 type string
* @param signature Signature from user
*/
function permitWitnessTransferFrom(
PermitBatchTransferFrom memory permit,
SignatureTransferDetails[] calldata transferDetails,
address owner,
bytes32 witness,
string calldata witnessTypeString,
bytes calldata signature
) external;
/**
* @notice Domain separator to differentiate the chain a permit exists on
*/
function DOMAIN_SEPARATOR() external view returns (bytes32);
}
/**
* @title Zap errors
* @author kexley, Beefy
* @notice Custom errors for the zap router
*/
contract ZapErrors {
error InvalidCaller(address owner, address caller);
error TargetingInvalidContract(address target);
error CallFailed(address target, uint256 value, bytes callData);
error Slippage(address token, uint256 minAmountOut, uint256 balance);
error EtherTransferFailed(address recipient);
error CallerNotZap(address caller);
error InsufficientRelayValue(uint256 balance, uint256 relayValue);
}
/**
* @title Token manager
* @author kexley, Beefy
* @notice Token manager handles the token approvals for the zap router
* @dev Users should approve this contract instead of the zap router to handle the input ERC20 tokens
*/
contract BeefyTokenManager is ZapErrors {
using SafeERC20 for IERC20;
/**
* @notice Zap router immutable address
*/
address public immutable zap;
/**
* @dev This contract is created in the constructor of the zap router
*/
constructor() {
zap = msg.sender;
}
/**
* @notice Pulls tokens from a user and transfers them directly to the zap router
* @dev Only the token owner can call this function indirectly via the zap router
* @param _user Address to pull tokens from
* @param _inputs Token addresses and amounts to pull
*/
function pullTokens(address _user, IBeefyZapRouter.Input[] calldata _inputs) external {
if (msg.sender != zap) revert CallerNotZap(msg.sender);
uint256 inputLength = _inputs.length;
for (uint256 i; i < inputLength;) {
IBeefyZapRouter.Input calldata input = _inputs[i];
unchecked {
++i;
}
if (input.token == address(0)) continue;
IERC20(input.token).safeTransferFrom(_user, msg.sender, input.amount);
}
}
}
/**
* @title Zap router for Beefy vaults
* @author kexley, Beefy
* @notice Adaptable router for zapping tokens to and from Beefy vaults
* @dev Router that allows arbitary calls to external contracts. Users can zap directly or sign
* using Permit2 to allow a relayer to execute zaps on their behalf. Do not directly approve this
* contract for spending your tokens, approve the TokenManager instead
*/
contract MoonZapRouter is IBeefyZapRouter, ZapErrors, Ownable, Pausable, ReentrancyGuard {
using SafeERC20 for IERC20;
using BytesLib for bytes;
/**
* @dev Witness string used in signing an order
*/
string private constant ORDER_STRING =
"Order order)Order(Input[] inputs,Output[] outputs,Relay relay,address user,address recipient)Input(address token,uint256 amount)Output(address token,uint256 minOutputAmount)Relay(address target,uint256 value,bytes data)TokenPermissions(address token,uint256 amount)";
/**
* @dev Witness typehash used in signing an order
*/
bytes32 private constant ORDER_TYPEHASH =
keccak256("Order(Input[] inputs,Output[] outputs,Relay relay,address user,address recipient)Input(address token,uint256 amount)Output(address token,uint256 minOutputAmount)Relay(address target,uint256 value,bytes data)");
/**
* @notice Permit2 immutable address
*/
address public permit2;
/**
* @notice Token manager immutable address
*/
address public tokenManager;
/**
* @notice Token and amount sent to the recipient at end of a zap
* @param token Address of the token sent to recipient
* @param amount Amount of the token sent to the recipient
*/
event TokenReturned(address indexed token, uint256 amount);
/**
* @notice External relay call at end of zap
* @param target Address of the target
* @param value Ether value of the call
* @param data Payload of the external call
*/
event RelayData(address indexed target, uint256 value, bytes data);
/**
* @notice Completed order
* @param order Order that has been fulfilled
* @param caller Address of the order's executor
* @param recipient Address of the order's recipient
*/
event FulfilledOrder(Order indexed order, address indexed caller, address indexed recipient);
constructor() {
}
/**
* @notice Execute an order directly
* @dev The user executes their own order directly. User must have already approved the token
* manager to move the tokens
* @param _order Order containing how many tokens to pull and the slippage amounts on outputs
* @param _route Route containing the steps to reach the output
*/
function executeOrder(Order calldata _order, Step[] calldata _route) external payable nonReentrant whenNotPaused {
if (msg.sender != _order.user) revert InvalidCaller(_order.user, msg.sender);
IBeefyTokenManager(tokenManager).pullTokens(_order.user, _order.inputs);
_executeOrder(_order, _route);
}
/**
* @notice Execute an order using a signature from the input token owner
* @dev Execute an order indirectly by passing a signed permit from Permit2 that contains the
* order as witness data. The user who owns the tokens must have already approved Permit2.
* Route is supplied at this stage as slippages and amounts are already set in the signed order
* @param _permit Struct of tokens that have been permitted and the nonce/deadline
* @param _order Order that details the input/output tokens and amounts
* @param _signature Resulting string from signing the permit and order data
* @param _route Actual steps that will transform input tokens to output tokens
*/
function executeOrder(
IPermit2.PermitBatchTransferFrom calldata _permit,
Order calldata _order,
bytes calldata _signature,
Step[] calldata _route
) external nonReentrant whenNotPaused {
IPermit2(permit2).permitWitnessTransferFrom(
_permit,
_getTransferDetails(_order.inputs),
_order.user,
keccak256(abi.encode(ORDER_TYPEHASH, _order)),
ORDER_STRING,
_signature
);
_executeOrder(_order, _route);
}
/**
* @dev Executes a valid order by executing the steps on the route, validating the output
* amounts and then sending them to the recipient. A final external call is made to relay
* data in the order to chain together calls
* @param _order Order struct with details of inputs and outputs
* @param _route Actual steps to transform inputs to outputs
*/
function _executeOrder(Order calldata _order, Step[] calldata _route) private {
_executeSteps(_route);
_returnAssets(_order.outputs, _order.recipient, _order.relay.value);
_executeRelay(_order.relay);
emit FulfilledOrder(_order, msg.sender, _order.recipient);
}
/**
* @dev Executes various steps to achieve the order outputs by making external calls. Balance
* data is dynamically inserted into payloads to always move the full balances of this contract
* @param _route Array of the steps the contract will execute
*/
function _executeSteps(Step[] calldata _route) private {
uint256 routeLength = _route.length;
for (uint256 i; i < routeLength;) {
Step calldata step = _route[i];
(
address stepTarget,
uint256 value,
bytes memory callData,
StepToken[] calldata stepTokens
) = (step.target, step.value, step.data, step.tokens);
if (stepTarget == permit2 || stepTarget == tokenManager) revert TargetingInvalidContract(stepTarget);
uint256 balance;
uint256 callDataLength = callData.length;
uint256 stepTokensLength = stepTokens.length;
for (uint256 j; j < stepTokensLength;) {
StepToken calldata stepToken = stepTokens[j];
(address stepTokenAddress, int32 stepTokenIndex) = (stepToken.token, stepToken.index);
if (stepTokenAddress == address(0)) {
value = address(this).balance;
} else {
balance = IERC20(stepTokenAddress).balanceOf(address(this));
_approveToken(stepTokenAddress, stepTarget, balance);
if (stepTokenIndex >= 0) {
uint256 idx = uint256(int256(stepTokenIndex));
callData = bytes.concat(
callData.slice(0, idx),
abi.encode(balance),
callData.slice(idx + 32, callDataLength - (idx + 32))
);
}
}
unchecked {
++j;
}
}
(bool success, bytes memory result) = stepTarget.call{value: value}(callData);
if (!success) _propagateError(stepTarget, value, callData, result);
unchecked {
++i;
}
}
}
/**
* @dev Approve a token to be spent by an address if not already approved enough
* @param _token Address of token to be approved
* @param _spender Address of spender that will be allowed to move tokens
* @param _amount Number of tokens that are going to be spent
*/
function _approveToken(address _token, address _spender, uint256 _amount) private {
if (IERC20(_token).allowance(address(this), _spender) < _amount) {
IERC20(_token).forceApprove(_spender, type(uint256).max);
}
}
/**
* @dev Bubble up an error message from an underlying contract
* @param _target Address that the call was sent to
* @param _value Amount of ether sent with the call
* @param _data Payload data of the call
* @param _returnedData Returned data from the call
*/
function _propagateError(address _target, uint256 _value, bytes memory _data, bytes memory _returnedData)
private
pure
{
if (_returnedData.length == 0) revert CallFailed(_target, _value, _data);
assembly {
revert(add(32, _returnedData), mload(_returnedData))
}
}
/**
* @dev Return the outputs to the recipient address
* @param _outputs Token addresses and amounts to validate against to ensure no major slippage
* @param _recipient Address of the receiver of the outputs
* @param _relayValue Unwrapped native amount that is reserved for calling the relay address
*/
function _returnAssets(Output[] calldata _outputs, address _recipient, uint256 _relayValue) private {
uint256 balance;
uint256 outputsLength = _outputs.length;
for (uint256 i; i < outputsLength;) {
Output calldata output = _outputs[i];
(address outputToken, uint256 outputMinAmount) = (output.token, output.minOutputAmount);
if (outputToken == address(0)) {
balance = address(this).balance;
if (balance < outputMinAmount) {
revert Slippage(outputToken, outputMinAmount, balance);
}
if (balance > _relayValue) {
balance -= _relayValue;
(bool success,) = _recipient.call{value: balance}("");
if (!success) revert EtherTransferFailed(_recipient);
}
} else {
balance = IERC20(outputToken).balanceOf(address(this));
if (balance < outputMinAmount) {
revert Slippage(outputToken, outputMinAmount, balance);
} else if (balance > 0) {
IERC20(outputToken).safeTransfer(_recipient, balance);
}
}
emit TokenReturned(outputToken, balance);
unchecked {
++i;
}
}
}
/**
* @dev Call an external contract at the end of a zap with a payload signed in the order
* @param _relay Target address and payload data in a struct
*/
function _executeRelay(Relay calldata _relay) private {
(address relayTarget, uint256 relayValue, bytes calldata relaydata)
= (_relay.target, _relay.value, _relay.data);
if (relayTarget != address(0)) {
if (relayTarget == permit2 || relayTarget == tokenManager) {
revert TargetingInvalidContract(relayTarget);
}
if (address(this).balance < relayValue) {
revert InsufficientRelayValue(address(this).balance, relayValue);
}
(bool success, bytes memory result) = relayTarget.call{value: relayValue}(relaydata);
if (!success) _propagateError(relayTarget, relayValue, relaydata, result);
emit RelayData(relayTarget, relayValue, relaydata);
}
}
/**
* @dev Parse the token transfer details from the order so it can be supplied to the Permit2
* transfer from request
* @param _inputs Token addresses and amounts in a struct
* @return transferDetails Transformed data
*/
function _getTransferDetails(Input[] calldata _inputs)
private
view
returns (IPermit2.SignatureTransferDetails[] memory)
{
uint256 inputsLength = _inputs.length;
IPermit2.SignatureTransferDetails[] memory transferDetails =
new IPermit2.SignatureTransferDetails[](inputsLength);
for (uint256 i; i < inputsLength;) {
transferDetails[i] =
IPermit2.SignatureTransferDetails({to: address(this), requestedAmount: _inputs[i].amount});
unchecked {
++i;
}
}
return transferDetails;
}
function setPermit2(address _permit2) external onlyOwner {
permit2 = _permit2;
}
function setTokenManager(address _tokenManager) external onlyOwner {
tokenManager = _tokenManager;
}
/**
* @notice Pause the contract from carrying out any more zaps
* @dev Only owner can pause
*/
function pause() external onlyOwner {
_pause();
}
/**
* @notice Unpause the contract to allow new zaps
* @dev Only owner can unpause
*/
function unpause() external onlyOwner {
_unpause();
}
/**
* @dev Allow receiving of native tokens
*/
receive() external payable {}
}[
{
"type": "constructor",
"inputs": [],
"stateMutability": "nonpayable"
},
{
"name": "CallFailed",
"type": "error",
"inputs": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "callData",
"type": "bytes",
"internalType": "bytes"
}
]
},
{
"name": "CallerNotZap",
"type": "error",
"inputs": [
{
"name": "caller",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "EtherTransferFailed",
"type": "error",
"inputs": [
{
"name": "recipient",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "InsufficientRelayValue",
"type": "error",
"inputs": [
{
"name": "balance",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "relayValue",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"name": "InvalidCaller",
"type": "error",
"inputs": [
{
"name": "owner",
"type": "address",
"internalType": "address"
},
{
"name": "caller",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "Slippage",
"type": "error",
"inputs": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "minAmountOut",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "balance",
"type": "uint256",
"internalType": "uint256"
}
]
},
{
"name": "TargetingInvalidContract",
"type": "error",
"inputs": [
{
"name": "target",
"type": "address",
"internalType": "address"
}
]
},
{
"name": "FulfilledOrder",
"type": "event",
"inputs": [
{
"name": "order",
"type": "tuple",
"indexed": true,
"components": [
{
"name": "inputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Input[]"
},
{
"name": "outputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "minOutputAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Output[]"
},
{
"name": "relay",
"type": "tuple",
"components": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
],
"internalType": "struct IBeefyZapRouter.Relay"
},
{
"name": "user",
"type": "address",
"internalType": "address"
},
{
"name": "recipient",
"type": "address",
"internalType": "address"
}
],
"internalType": "struct IBeefyZapRouter.Order"
},
{
"name": "caller",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "recipient",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "OwnershipTransferred",
"type": "event",
"inputs": [
{
"name": "previousOwner",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "newOwner",
"type": "address",
"indexed": true,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "Paused",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "RelayData",
"type": "event",
"inputs": [
{
"name": "target",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"indexed": false,
"internalType": "bytes"
}
],
"anonymous": false
},
{
"name": "TokenReturned",
"type": "event",
"inputs": [
{
"name": "token",
"type": "address",
"indexed": true,
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"indexed": false,
"internalType": "uint256"
}
],
"anonymous": false
},
{
"name": "Unpaused",
"type": "event",
"inputs": [
{
"name": "account",
"type": "address",
"indexed": false,
"internalType": "address"
}
],
"anonymous": false
},
{
"name": "executeOrder",
"type": "function",
"inputs": [
{
"name": "_permit",
"type": "tuple",
"components": [
{
"name": "permitted",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IPermit2.TokenPermissions[]"
},
{
"name": "nonce",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "deadline",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IPermit2.PermitBatchTransferFrom"
},
{
"name": "_order",
"type": "tuple",
"components": [
{
"name": "inputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Input[]"
},
{
"name": "outputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "minOutputAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Output[]"
},
{
"name": "relay",
"type": "tuple",
"components": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
],
"internalType": "struct IBeefyZapRouter.Relay"
},
{
"name": "user",
"type": "address",
"internalType": "address"
},
{
"name": "recipient",
"type": "address",
"internalType": "address"
}
],
"internalType": "struct IBeefyZapRouter.Order"
},
{
"name": "_signature",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "_route",
"type": "tuple[]",
"components": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "tokens",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "index",
"type": "int32",
"internalType": "int32"
}
],
"internalType": "struct IBeefyZapRouter.StepToken[]"
}
],
"internalType": "struct IBeefyZapRouter.Step[]"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "executeOrder",
"type": "function",
"inputs": [
{
"name": "_order",
"type": "tuple",
"components": [
{
"name": "inputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "amount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Input[]"
},
{
"name": "outputs",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "minOutputAmount",
"type": "uint256",
"internalType": "uint256"
}
],
"internalType": "struct IBeefyZapRouter.Output[]"
},
{
"name": "relay",
"type": "tuple",
"components": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
}
],
"internalType": "struct IBeefyZapRouter.Relay"
},
{
"name": "user",
"type": "address",
"internalType": "address"
},
{
"name": "recipient",
"type": "address",
"internalType": "address"
}
],
"internalType": "struct IBeefyZapRouter.Order"
},
{
"name": "_route",
"type": "tuple[]",
"components": [
{
"name": "target",
"type": "address",
"internalType": "address"
},
{
"name": "value",
"type": "uint256",
"internalType": "uint256"
},
{
"name": "data",
"type": "bytes",
"internalType": "bytes"
},
{
"name": "tokens",
"type": "tuple[]",
"components": [
{
"name": "token",
"type": "address",
"internalType": "address"
},
{
"name": "index",
"type": "int32",
"internalType": "int32"
}
],
"internalType": "struct IBeefyZapRouter.StepToken[]"
}
],
"internalType": "struct IBeefyZapRouter.Step[]"
}
],
"outputs": [],
"stateMutability": "payable"
},
{
"name": "owner",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "pause",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "paused",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "bool",
"internalType": "bool"
}
],
"stateMutability": "view"
},
{
"name": "permit2",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "renounceOwnership",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "setPermit2",
"type": "function",
"inputs": [
{
"name": "_permit2",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "setTokenManager",
"type": "function",
"inputs": [
{
"name": "_tokenManager",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "tokenManager",
"type": "function",
"inputs": [],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "view"
},
{
"name": "transferOwnership",
"type": "function",
"inputs": [
{
"name": "newOwner",
"type": "address",
"internalType": "address"
}
],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"name": "unpause",
"type": "function",
"inputs": [],
"outputs": [],
"stateMutability": "nonpayable"
},
{
"type": "receive",
"stateMutability": "payable"
}
]0x6080604052348015600e575f80fd5b50601633602a565b5f805460ff60a01b19169055600180556079565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b611f9f806100865f395ff3fe6080604052600436106100a8575f3560e01c8063715018a611610062578063715018a61461018a5780637cb2b79c1461019e5780638456cb59146101bd5780638da5cb5b146101d1578063f2fde38b146101ed578063f41b2db61461020c575f80fd5b8063101ec30a146100b357806312261ee7146100d45780632a709b14146101105780632e0af5e51461012f5780633f4ba83a1461014e5780635c975abb14610162575f80fd5b366100af57005b5f80fd5b3480156100be575f80fd5b506100d26100cd3660046115a3565b61021f565b005b3480156100df575f80fd5b506002546100f3906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561011b575f80fd5b506003546100f3906001600160a01b031681565b34801561013a575f80fd5b506100d2610149366004611621565b610249565b348015610159575f80fd5b506100d261035f565b34801561016d575f80fd5b505f54600160a01b900460ff166040519015158152602001610107565b348015610195575f80fd5b506100d2610371565b3480156101a9575f80fd5b506100d26101b83660046115a3565b610382565b3480156101c8575f80fd5b506100d26103ac565b3480156101dc575f80fd5b505f546001600160a01b03166100f3565b3480156101f8575f80fd5b506100d26102073660046115a3565b6103bc565b6100d261021a366004611704565b61043a565b61022761053c565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610251610595565b6102596105ee565b6002546001600160a01b031663fe8ec1a78761027d6102788980611768565b61063a565b61028d60808a0160608b016115a3565b7fc709880ce3db9deadf408dae85548b37e4530edc88a93e955bd080b45f3255c28a6040516020016102c0929190611916565b604051602081830303815290604052805190602001206040518061014001604052806101098152602001611e6161010991398a8a6040518863ffffffff1660e01b81526004016103169796959493929190611a75565b5f604051808303815f87803b15801561032d575f80fd5b505af115801561033f573d5f803e3d5ffd5b5050505061034e858383610711565b61035760018055565b505050505050565b61036761053c565b61036f6107cb565b565b61037961053c565b61036f5f61081f565b61038a61053c565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6103b461053c565b61036f61086e565b6103c461053c565b6001600160a01b03811661042e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6104378161081f565b50565b610442610595565b61044a6105ee565b61045a60808401606085016115a3565b6001600160a01b0316336001600160a01b0316146104ad5761048260808401606085016115a3565b6040516302d9d9c960e31b81526001600160a01b039091166004820152336024820152604401610425565b6003546001600160a01b03166377fc3fa86104ce60808601606087016115a3565b6104d88680611768565b6040518463ffffffff1660e01b81526004016104f693929190611b3e565b5f604051808303815f87803b15801561050d575f80fd5b505af115801561051f573d5f803e3d5ffd5b5050505061052e838383610711565b61053760018055565b505050565b5f546001600160a01b0316331461036f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610425565b6002600154036105e75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610425565b6002600155565b5f54600160a01b900460ff161561036f5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610425565b6060815f8167ffffffffffffffff81111561065757610657611b90565b60405190808252806020026020018201604052801561069b57816020015b604080518082019091525f80825260208201528152602001906001900390816106755790505b5090505f5b82811015610706576040518060400160405280306001600160a01b031681526020018787848181106106d4576106d4611ba4565b905060400201602001358152508282815181106106f3576106f3611ba4565b60209081029190910101526001016106a0565b509150505b92915050565b61071b82826108b0565b61075161072b6020850185611768565b61073b60a08701608088016115a3565b6107486040880188611bb8565b60200135610ba0565b6107666107616040850185611bb8565b610dd8565b61077660a08401608085016115a3565b6001600160a01b0316336001600160a01b0316846040516107979190611c28565b604051908190038120907f1ba5b6ed656994657175705961138c96bd8ec133c35817fa85903f450129e0b1905f90a4505050565b6107d3610f87565b5f805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6108766105ee565b5f805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586108023390565b805f5b81811015610b9a57368484838181106108ce576108ce611ba4565b90506020028101906108e09190611cda565b90505f808036816108f460208701876115a3565b60208701356109066040890189611cee565b61091360608b018b611768565b955095508080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152505060025494995092975090955050506001600160a01b038087169116148061097c57506003546001600160a01b038681169116145b156109a557604051631e055a2960e21b81526001600160a01b0386166004820152602401610425565b82515f9082825b81811015610b1357368686838181106109c7576109c7611ba4565b6040029190910191505f9050806109e160208401846115a3565b6109f16040850160208601611d31565b90925090506001600160a01b038216610a0c57479a50610b05565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610a4e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a729190611d51565b9650610a7f828d89610fd6565b5f8160030b12610b0557600381900b610a998b5f83611062565b60408051602081018b90520160408051601f19818403018152919052610ae0610ac3846020611d7c565b610ace856020611d7c565b610ad8908c611d8f565b8f9190611062565b604051602001610af293929190611db9565b6040516020818303038152906040529a50505b8360010193505050506109ac565b505f80896001600160a01b03168989604051610b2f9190611dd6565b5f6040518083038185875af1925050503d805f8114610b69576040519150601f19603f3d011682016040523d82523d5f602084013e610b6e565b606091505b509150915081610b8457610b848a8a8a8461116e565b8b6001019b5050505050505050505050506108b3565b50505050565b5f83815b81811015610dcf5736878783818110610bbf57610bbf611ba4565b6040029190910191505f905080610bd960208401846115a3565b91505060208201356001600160a01b038216610cc25747955080861015610c2c57604051636a67a2d160e11b81526001600160a01b03831660048201526024810182905260448101879052606401610425565b86861115610cbd57610c3e8787611d8f565b95505f886001600160a01b0316876040515f6040518083038185875af1925050503d805f8114610c89576040519150601f19603f3d011682016040523d82523d5f602084013e610c8e565b606091505b5050905080610cbb5760405163464e254d60e01b81526001600160a01b038a166004820152602401610425565b505b610d7e565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610d04573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d289190611d51565b955080861015610d6457604051636a67a2d160e11b81526001600160a01b03831660048201526024810182905260448101879052606401610425565b8515610d7e57610d7e6001600160a01b038316898861119d565b816001600160a01b03167feaf449319c042c9ba3474fa0c5329eb58cd1f23be110cdbf9d697b8d303dac1587604051610db991815260200190565b60405180910390a2836001019350505050610ba4565b50505050505050565b5f803681610de960208601866115a3565b6020860135610dfb6040880188611cee565b929650909450925090506001600160a01b03841615610f80576002546001600160a01b0385811691161480610e3d57506003546001600160a01b038581169116145b15610e6657604051631e055a2960e21b81526001600160a01b0385166004820152602401610425565b82471015610e9057604051633a6465f360e11b815247600482015260248101849052604401610425565b5f80856001600160a01b0316858585604051610ead929190611de1565b5f6040518083038185875af1925050503d805f8114610ee7576040519150601f19603f3d011682016040523d82523d5f602084013e610eec565b606091505b509150915081610f3857610f38868686868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525087925061116e915050565b856001600160a01b03167f6c936258f37a22c831493e49cb45429bdf7b6bb0e261f271a15f084e5b08aaff868686604051610f7593929190611df0565b60405180910390a250505b5050505050565b5f54600160a01b900460ff1661036f5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610425565b604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015282919085169063dd62ed3e90604401602060405180830381865afa158015611023573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110479190611d51565b1015610537576105376001600160a01b038416835f19611200565b60608161107081601f611d7c565b10156110af5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610425565b6110b98284611d7c565b845110156110fd5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610425565b60608215801561111b5760405191505f825260208201604052611165565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561115457805183526020928301920161113c565b5050858452601f01601f1916604052505b50949350505050565b80515f036111955783838360405163e1eec8f160e01b815260040161042593929190611e09565b805181602001fd5b6040516001600160a01b03831660248201526044810182905261053790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261128a565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611251848261135d565b610b9a576040516001600160a01b03841660248201525f604482015261128490859063095ea7b360e01b906064016111c9565b610b9a84825b5f6112de826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113fe9092919063ffffffff16565b905080515f14806112fe5750808060200190518101906112fe9190611e2f565b6105375760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610425565b5f805f846001600160a01b0316846040516113789190611dd6565b5f604051808303815f865af19150503d805f81146113b1576040519150601f19603f3d011682016040523d82523d5f602084013e6113b6565b606091505b50915091508180156113e05750805115806113e05750808060200190518101906113e09190611e2f565b80156113f557506001600160a01b0385163b15155b95945050505050565b606061140c84845f85611414565b949350505050565b6060824710156114755760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610425565b5f80866001600160a01b031685876040516114909190611dd6565b5f6040518083038185875af1925050503d805f81146114ca576040519150601f19603f3d011682016040523d82523d5f602084013e6114cf565b606091505b50915091506114e0878383876114eb565b979650505050505050565b606083156115595782515f03611552576001600160a01b0385163b6115525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610425565b508161140c565b61140c838381511561156e5781518083602001fd5b8060405162461bcd60e51b81526004016104259190611e4e565b80356001600160a01b038116811461159e575f80fd5b919050565b5f602082840312156115b3575f80fd5b6115bc82611588565b9392505050565b5f60a082840312156115d3575f80fd5b50919050565b5f8083601f8401126115e9575f80fd5b50813567ffffffffffffffff811115611600575f80fd5b6020830191508360208260051b850101111561161a575f80fd5b9250929050565b5f805f805f8060808789031215611636575f80fd5b863567ffffffffffffffff8082111561164d575f80fd5b908801906060828b031215611660575f80fd5b90965060208801359080821115611675575f80fd5b6116818a838b016115c3565b96506040890135915080821115611696575f80fd5b818901915089601f8301126116a9575f80fd5b8135818111156116b7575f80fd5b8a60208285010111156116c8575f80fd5b6020830196508095505060608901359150808211156116e5575f80fd5b506116f289828a016115d9565b979a9699509497509295939492505050565b5f805f60408486031215611716575f80fd5b833567ffffffffffffffff8082111561172d575f80fd5b611739878388016115c3565b9450602086013591508082111561174e575f80fd5b5061175b868287016115d9565b9497909650939450505050565b5f808335601e1984360301811261177d575f80fd5b83018035915067ffffffffffffffff821115611797575f80fd5b6020019150600681901b360382131561161a575f80fd5b5f808335601e198436030181126117c3575f80fd5b830160208101925035905067ffffffffffffffff8111156117e2575f80fd5b8060061b360382131561161a575f80fd5b6001600160a01b0361180482611588565b168252602090810135910152565b8183526020830192505f815f5b848110156118445761183186836117f3565b604095860195919091019060010161181f565b5093949350505050565b5f8235605e19833603018112611862575f80fd5b90910192915050565b5f808335601e19843603018112611880575f80fd5b830160208101925035905067ffffffffffffffff81111561189f575f80fd5b80360382131561161a575f80fd5b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b6001600160a01b036118e682611588565b168252602081013560208301525f611901604083018361186b565b606060408601526113f56060860182846118ad565b5f60408483526040602084015260e0830161193185866117ae565b60a0604087015291829052905f9061010086015b818310156119695761195781856117f3565b92840192600192909201918401611945565b61197660208901896117ae565b95509350603f19925082878203016060880152611994818686611812565b945050506119a5604087018761184e565b915080858403016080860152506119bc82826118d5565b9150506119cb60608501611588565b6001600160a01b031660a08401526119e560808501611588565b6001600160a01b03811660c0850152611165565b5f815180845260208085019450602084015f5b83811015611a3c57815180516001600160a01b031688528301518388015260409096019590820190600101611a0c565b509495945050505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b60c081525f6101208201611a898a8b6117ae565b606060c086015291829052905f9061014085015b81831015611ac257611aaf81856117f3565b6040938401936001939093019201611a9d565b60208d013560e087015260408d01356101008701528581036020870152611ae9818d6119f9565b9350505050611b0360408401896001600160a01b03169052565b8660608401528281036080840152611b1b8187611a47565b905082810360a0840152611b308185876118ad565b9a9950505050505050505050565b6001600160a01b03841681526040602082018190528181018390525f908460608401835b86811015611b8457611b7482846117f3565b9183019190830190600101611b62565b50979650505050505050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f8235605e19833603018112611bcc575f80fd5b9190910192915050565b6001600160a01b03611be782611588565b168252602081013560208301525f611c02604083018361186b565b808260408701375f604082870101526040601f19601f8301168601019250505092915050565b5f611c3383846117ae565b835f5b82811015611c5b57611c4882856117f3565b6040938401939190910190600101611c36565b50611c6960208701876117ae565b935091505f905b83821015611c9557611c8281846117f3565b6040928301926001929092019101611c70565b6114e0611cce611cb183611cac60408c018c61184e565b611bd6565b611cbd60608b01611588565b6001600160a01b0316815260200190565b611cbd60808a01611588565b5f8235607e19833603018112611bcc575f80fd5b5f808335601e19843603018112611d03575f80fd5b83018035915067ffffffffffffffff821115611d1d575f80fd5b60200191503681900382131561161a575f80fd5b5f60208284031215611d41575f80fd5b81358060030b81146115bc575f80fd5b5f60208284031215611d61575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561070b5761070b611d68565b8181038181111561070b5761070b611d68565b5f81518060208401855e5f93019283525090919050565b5f6113f5611dd0611dca8488611da2565b86611da2565b84611da2565b5f6115bc8284611da2565b818382375f9101908152919050565b838152604060208201525f6113f56040830184866118ad565b60018060a01b0384168152826020820152606060408201525f6113f56060830184611a47565b5f60208284031215611e3f575f80fd5b815180151581146115bc575f80fd5b602081525f6115bc6020830184611a4756fe4f72646572206f72646572294f7264657228496e7075745b5d20696e707574732c4f75747075745b5d206f7574707574732c52656c61792072656c61792c6164647265737320757365722c6164647265737320726563697069656e7429496e707574286164647265737320746f6b656e2c75696e7432353620616d6f756e74294f7574707574286164647265737320746f6b656e2c75696e74323536206d696e4f7574707574416d6f756e742952656c61792861646472657373207461726765742c75696e743235362076616c75652c6279746573206461746129546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c75696e7432353620616d6f756e7429a2646970667358221220905189a7449dd30944267c007a104fc409d6b910c89a0828d83b8c3d3845cf9464736f6c63430008190033
0x6080604052600436106100a8575f3560e01c8063715018a611610062578063715018a61461018a5780637cb2b79c1461019e5780638456cb59146101bd5780638da5cb5b146101d1578063f2fde38b146101ed578063f41b2db61461020c575f80fd5b8063101ec30a146100b357806312261ee7146100d45780632a709b14146101105780632e0af5e51461012f5780633f4ba83a1461014e5780635c975abb14610162575f80fd5b366100af57005b5f80fd5b3480156100be575f80fd5b506100d26100cd3660046115a3565b61021f565b005b3480156100df575f80fd5b506002546100f3906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561011b575f80fd5b506003546100f3906001600160a01b031681565b34801561013a575f80fd5b506100d2610149366004611621565b610249565b348015610159575f80fd5b506100d261035f565b34801561016d575f80fd5b505f54600160a01b900460ff166040519015158152602001610107565b348015610195575f80fd5b506100d2610371565b3480156101a9575f80fd5b506100d26101b83660046115a3565b610382565b3480156101c8575f80fd5b506100d26103ac565b3480156101dc575f80fd5b505f546001600160a01b03166100f3565b3480156101f8575f80fd5b506100d26102073660046115a3565b6103bc565b6100d261021a366004611704565b61043a565b61022761053c565b600280546001600160a01b0319166001600160a01b0392909216919091179055565b610251610595565b6102596105ee565b6002546001600160a01b031663fe8ec1a78761027d6102788980611768565b61063a565b61028d60808a0160608b016115a3565b7fc709880ce3db9deadf408dae85548b37e4530edc88a93e955bd080b45f3255c28a6040516020016102c0929190611916565b604051602081830303815290604052805190602001206040518061014001604052806101098152602001611e6161010991398a8a6040518863ffffffff1660e01b81526004016103169796959493929190611a75565b5f604051808303815f87803b15801561032d575f80fd5b505af115801561033f573d5f803e3d5ffd5b5050505061034e858383610711565b61035760018055565b505050505050565b61036761053c565b61036f6107cb565b565b61037961053c565b61036f5f61081f565b61038a61053c565b600380546001600160a01b0319166001600160a01b0392909216919091179055565b6103b461053c565b61036f61086e565b6103c461053c565b6001600160a01b03811661042e5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b6104378161081f565b50565b610442610595565b61044a6105ee565b61045a60808401606085016115a3565b6001600160a01b0316336001600160a01b0316146104ad5761048260808401606085016115a3565b6040516302d9d9c960e31b81526001600160a01b039091166004820152336024820152604401610425565b6003546001600160a01b03166377fc3fa86104ce60808601606087016115a3565b6104d88680611768565b6040518463ffffffff1660e01b81526004016104f693929190611b3e565b5f604051808303815f87803b15801561050d575f80fd5b505af115801561051f573d5f803e3d5ffd5b5050505061052e838383610711565b61053760018055565b505050565b5f546001600160a01b0316331461036f5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610425565b6002600154036105e75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610425565b6002600155565b5f54600160a01b900460ff161561036f5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610425565b6060815f8167ffffffffffffffff81111561065757610657611b90565b60405190808252806020026020018201604052801561069b57816020015b604080518082019091525f80825260208201528152602001906001900390816106755790505b5090505f5b82811015610706576040518060400160405280306001600160a01b031681526020018787848181106106d4576106d4611ba4565b905060400201602001358152508282815181106106f3576106f3611ba4565b60209081029190910101526001016106a0565b509150505b92915050565b61071b82826108b0565b61075161072b6020850185611768565b61073b60a08701608088016115a3565b6107486040880188611bb8565b60200135610ba0565b6107666107616040850185611bb8565b610dd8565b61077660a08401608085016115a3565b6001600160a01b0316336001600160a01b0316846040516107979190611c28565b604051908190038120907f1ba5b6ed656994657175705961138c96bd8ec133c35817fa85903f450129e0b1905f90a4505050565b6107d3610f87565b5f805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6108766105ee565b5f805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586108023390565b805f5b81811015610b9a57368484838181106108ce576108ce611ba4565b90506020028101906108e09190611cda565b90505f808036816108f460208701876115a3565b60208701356109066040890189611cee565b61091360608b018b611768565b955095508080601f0160208091040260200160405190810160405280939291908181526020018383808284375f920191909152505060025494995092975090955050506001600160a01b038087169116148061097c57506003546001600160a01b038681169116145b156109a557604051631e055a2960e21b81526001600160a01b0386166004820152602401610425565b82515f9082825b81811015610b1357368686838181106109c7576109c7611ba4565b6040029190910191505f9050806109e160208401846115a3565b6109f16040850160208601611d31565b90925090506001600160a01b038216610a0c57479a50610b05565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610a4e573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a729190611d51565b9650610a7f828d89610fd6565b5f8160030b12610b0557600381900b610a998b5f83611062565b60408051602081018b90520160408051601f19818403018152919052610ae0610ac3846020611d7c565b610ace856020611d7c565b610ad8908c611d8f565b8f9190611062565b604051602001610af293929190611db9565b6040516020818303038152906040529a50505b8360010193505050506109ac565b505f80896001600160a01b03168989604051610b2f9190611dd6565b5f6040518083038185875af1925050503d805f8114610b69576040519150601f19603f3d011682016040523d82523d5f602084013e610b6e565b606091505b509150915081610b8457610b848a8a8a8461116e565b8b6001019b5050505050505050505050506108b3565b50505050565b5f83815b81811015610dcf5736878783818110610bbf57610bbf611ba4565b6040029190910191505f905080610bd960208401846115a3565b91505060208201356001600160a01b038216610cc25747955080861015610c2c57604051636a67a2d160e11b81526001600160a01b03831660048201526024810182905260448101879052606401610425565b86861115610cbd57610c3e8787611d8f565b95505f886001600160a01b0316876040515f6040518083038185875af1925050503d805f8114610c89576040519150601f19603f3d011682016040523d82523d5f602084013e610c8e565b606091505b5050905080610cbb5760405163464e254d60e01b81526001600160a01b038a166004820152602401610425565b505b610d7e565b6040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa158015610d04573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d289190611d51565b955080861015610d6457604051636a67a2d160e11b81526001600160a01b03831660048201526024810182905260448101879052606401610425565b8515610d7e57610d7e6001600160a01b038316898861119d565b816001600160a01b03167feaf449319c042c9ba3474fa0c5329eb58cd1f23be110cdbf9d697b8d303dac1587604051610db991815260200190565b60405180910390a2836001019350505050610ba4565b50505050505050565b5f803681610de960208601866115a3565b6020860135610dfb6040880188611cee565b929650909450925090506001600160a01b03841615610f80576002546001600160a01b0385811691161480610e3d57506003546001600160a01b038581169116145b15610e6657604051631e055a2960e21b81526001600160a01b0385166004820152602401610425565b82471015610e9057604051633a6465f360e11b815247600482015260248101849052604401610425565b5f80856001600160a01b0316858585604051610ead929190611de1565b5f6040518083038185875af1925050503d805f8114610ee7576040519150601f19603f3d011682016040523d82523d5f602084013e610eec565b606091505b509150915081610f3857610f38868686868080601f0160208091040260200160405190810160405280939291908181526020018383808284375f9201919091525087925061116e915050565b856001600160a01b03167f6c936258f37a22c831493e49cb45429bdf7b6bb0e261f271a15f084e5b08aaff868686604051610f7593929190611df0565b60405180910390a250505b5050505050565b5f54600160a01b900460ff1661036f5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610425565b604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015282919085169063dd62ed3e90604401602060405180830381865afa158015611023573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906110479190611d51565b1015610537576105376001600160a01b038416835f19611200565b60608161107081601f611d7c565b10156110af5760405162461bcd60e51b815260206004820152600e60248201526d736c6963655f6f766572666c6f7760901b6044820152606401610425565b6110b98284611d7c565b845110156110fd5760405162461bcd60e51b8152602060048201526011602482015270736c6963655f6f75744f66426f756e647360781b6044820152606401610425565b60608215801561111b5760405191505f825260208201604052611165565b6040519150601f8416801560200281840101858101878315602002848b0101015b8183101561115457805183526020928301920161113c565b5050858452601f01601f1916604052505b50949350505050565b80515f036111955783838360405163e1eec8f160e01b815260040161042593929190611e09565b805181602001fd5b6040516001600160a01b03831660248201526044810182905261053790849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b03199093169290921790915261128a565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b179052611251848261135d565b610b9a576040516001600160a01b03841660248201525f604482015261128490859063095ea7b360e01b906064016111c9565b610b9a84825b5f6112de826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113fe9092919063ffffffff16565b905080515f14806112fe5750808060200190518101906112fe9190611e2f565b6105375760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610425565b5f805f846001600160a01b0316846040516113789190611dd6565b5f604051808303815f865af19150503d805f81146113b1576040519150601f19603f3d011682016040523d82523d5f602084013e6113b6565b606091505b50915091508180156113e05750805115806113e05750808060200190518101906113e09190611e2f565b80156113f557506001600160a01b0385163b15155b95945050505050565b606061140c84845f85611414565b949350505050565b6060824710156114755760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610425565b5f80866001600160a01b031685876040516114909190611dd6565b5f6040518083038185875af1925050503d805f81146114ca576040519150601f19603f3d011682016040523d82523d5f602084013e6114cf565b606091505b50915091506114e0878383876114eb565b979650505050505050565b606083156115595782515f03611552576001600160a01b0385163b6115525760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610425565b508161140c565b61140c838381511561156e5781518083602001fd5b8060405162461bcd60e51b81526004016104259190611e4e565b80356001600160a01b038116811461159e575f80fd5b919050565b5f602082840312156115b3575f80fd5b6115bc82611588565b9392505050565b5f60a082840312156115d3575f80fd5b50919050565b5f8083601f8401126115e9575f80fd5b50813567ffffffffffffffff811115611600575f80fd5b6020830191508360208260051b850101111561161a575f80fd5b9250929050565b5f805f805f8060808789031215611636575f80fd5b863567ffffffffffffffff8082111561164d575f80fd5b908801906060828b031215611660575f80fd5b90965060208801359080821115611675575f80fd5b6116818a838b016115c3565b96506040890135915080821115611696575f80fd5b818901915089601f8301126116a9575f80fd5b8135818111156116b7575f80fd5b8a60208285010111156116c8575f80fd5b6020830196508095505060608901359150808211156116e5575f80fd5b506116f289828a016115d9565b979a9699509497509295939492505050565b5f805f60408486031215611716575f80fd5b833567ffffffffffffffff8082111561172d575f80fd5b611739878388016115c3565b9450602086013591508082111561174e575f80fd5b5061175b868287016115d9565b9497909650939450505050565b5f808335601e1984360301811261177d575f80fd5b83018035915067ffffffffffffffff821115611797575f80fd5b6020019150600681901b360382131561161a575f80fd5b5f808335601e198436030181126117c3575f80fd5b830160208101925035905067ffffffffffffffff8111156117e2575f80fd5b8060061b360382131561161a575f80fd5b6001600160a01b0361180482611588565b168252602090810135910152565b8183526020830192505f815f5b848110156118445761183186836117f3565b604095860195919091019060010161181f565b5093949350505050565b5f8235605e19833603018112611862575f80fd5b90910192915050565b5f808335601e19843603018112611880575f80fd5b830160208101925035905067ffffffffffffffff81111561189f575f80fd5b80360382131561161a575f80fd5b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b6001600160a01b036118e682611588565b168252602081013560208301525f611901604083018361186b565b606060408601526113f56060860182846118ad565b5f60408483526040602084015260e0830161193185866117ae565b60a0604087015291829052905f9061010086015b818310156119695761195781856117f3565b92840192600192909201918401611945565b61197660208901896117ae565b95509350603f19925082878203016060880152611994818686611812565b945050506119a5604087018761184e565b915080858403016080860152506119bc82826118d5565b9150506119cb60608501611588565b6001600160a01b031660a08401526119e560808501611588565b6001600160a01b03811660c0850152611165565b5f815180845260208085019450602084015f5b83811015611a3c57815180516001600160a01b031688528301518388015260409096019590820190600101611a0c565b509495945050505050565b5f81518084528060208401602086015e5f602082860101526020601f19601f83011685010191505092915050565b60c081525f6101208201611a898a8b6117ae565b606060c086015291829052905f9061014085015b81831015611ac257611aaf81856117f3565b6040938401936001939093019201611a9d565b60208d013560e087015260408d01356101008701528581036020870152611ae9818d6119f9565b9350505050611b0360408401896001600160a01b03169052565b8660608401528281036080840152611b1b8187611a47565b905082810360a0840152611b308185876118ad565b9a9950505050505050505050565b6001600160a01b03841681526040602082018190528181018390525f908460608401835b86811015611b8457611b7482846117f3565b9183019190830190600101611b62565b50979650505050505050565b634e487b7160e01b5f52604160045260245ffd5b634e487b7160e01b5f52603260045260245ffd5b5f8235605e19833603018112611bcc575f80fd5b9190910192915050565b6001600160a01b03611be782611588565b168252602081013560208301525f611c02604083018361186b565b808260408701375f604082870101526040601f19601f8301168601019250505092915050565b5f611c3383846117ae565b835f5b82811015611c5b57611c4882856117f3565b6040938401939190910190600101611c36565b50611c6960208701876117ae565b935091505f905b83821015611c9557611c8281846117f3565b6040928301926001929092019101611c70565b6114e0611cce611cb183611cac60408c018c61184e565b611bd6565b611cbd60608b01611588565b6001600160a01b0316815260200190565b611cbd60808a01611588565b5f8235607e19833603018112611bcc575f80fd5b5f808335601e19843603018112611d03575f80fd5b83018035915067ffffffffffffffff821115611d1d575f80fd5b60200191503681900382131561161a575f80fd5b5f60208284031215611d41575f80fd5b81358060030b81146115bc575f80fd5b5f60208284031215611d61575f80fd5b5051919050565b634e487b7160e01b5f52601160045260245ffd5b8082018082111561070b5761070b611d68565b8181038181111561070b5761070b611d68565b5f81518060208401855e5f93019283525090919050565b5f6113f5611dd0611dca8488611da2565b86611da2565b84611da2565b5f6115bc8284611da2565b818382375f9101908152919050565b838152604060208201525f6113f56040830184866118ad565b60018060a01b0384168152826020820152606060408201525f6113f56060830184611a47565b5f60208284031215611e3f575f80fd5b815180151581146115bc575f80fd5b602081525f6115bc6020830184611a4756fe4f72646572206f72646572294f7264657228496e7075745b5d20696e707574732c4f75747075745b5d206f7574707574732c52656c61792072656c61792c6164647265737320757365722c6164647265737320726563697069656e7429496e707574286164647265737320746f6b656e2c75696e7432353620616d6f756e74294f7574707574286164647265737320746f6b656e2c75696e74323536206d696e4f7574707574416d6f756e742952656c61792861646472657373207461726765742c75696e743235362076616c75652c6279746573206461746129546f6b656e5065726d697373696f6e73286164647265737320746f6b656e2c75696e7432353620616d6f756e7429a2646970667358221220905189a7449dd30944267c007a104fc409d6b910c89a0828d83b8c3d3845cf9464736f6c63430008190033
| Token | Symbol | Balance | Price | Value |
|---|---|---|---|---|
| Global Dollar (USDG) | USDG | 25 | $1 | $25 |
| Global Dollar (USDG) | USDG | 16.5 | $1 | $16.5 |
| Global Dollar (USDG) | USDG | 6 | $1 | $6 |
| MarsCoin (MarsCoin) | MarsCoin | 25 | — | — |
| pipedoge (PIPEDOGE) | PIPEDOGE | 15 | — | — |
| What If (IF) | IF | 3 | — | — |
| The Robinhood (VLAD) | VLAD | 1 | — | — |
| Type | Age | Block | Details |
|---|---|---|---|
| no cross-chain L1↔L2 transactions for this address | |||
| Transaction Hash | Method | Block | Age | From | To | Type | Item | ||
|---|---|---|---|---|---|---|---|---|---|
| no NFT transfers for this address yet | |||||||||
| Block | Age | Parent Transaction Hash | Type | Method | From | To | Value | |
|---|---|---|---|---|---|---|---|---|
| 22,129,294 | 17 days agoWed, 29 Jul 2026 03:25:49 UTC | 0x685a95…cbe9e9 | CALL | executeOrder | 0xfa62…dc5f | OUT | 0x0bd7…ad73 | 0.001 ETH |
| 18,726,641 | 21 days agoSat, 25 Jul 2026 04:34:00 UTC | 0xb5fb16…7b44e0 | CALL | executeOrder | 0xfa62…dc5f | OUT | 0x0bd7…ad73 | 0.00037 ETH |
| 17,955,382 | 22 days agoFri, 24 Jul 2026 07:04:48 UTC | 0xd0d8d9…94034f | CALL | executeOrder | 0xfa62…dc5f | OUT | 0xcaf6…5cb2 | 0.00062 ETH |
| Transaction Hash | Method ? | Block | Age | From | To | Amount | Txn Fee ? | ||
|---|---|---|---|---|---|---|---|---|---|
| 0x2078cb…3abeac | executeOrder | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00004131 | |
| 0x432140…e993d8 | executeOrder | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00003324 | |
| 0x5b8832…d78d8a | executeOrder | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0x5c4d…9cf8 | IN | MoonZapRouter | $0.000 ETH | 0.00001984 | |
| 0xea7b26…3fbf38 | executeOrder | 30,378,486 | 8 days agoFri, 07 Aug 2026 17:08:02 UTC | 0x5c4d…9cf8 | IN | MoonZapRouter | $0.000 ETH | 0.00002471 | |
| 0xbe1a5c…1ef81d | executeOrder | 29,662,887 | 9 days agoThu, 06 Aug 2026 21:13:01 UTC | 0x5c4d…9cf8 | IN | MoonZapRouter | $0.000 ETH | 0.00001619 | |
| 0x3e2381…e53214 | executeOrder | 29,545,769 | 9 days agoThu, 06 Aug 2026 17:57:36 UTC | 0x5c4d…9cf8 | IN | MoonZapRouter | $0.000 ETH | 0.00002411 | |
| 0xe9638e…d2130a | executeOrder | 29,544,354 | 9 days agoThu, 06 Aug 2026 17:55:14 UTC | 0x5c4d…9cf8 | IN | MoonZapRouter | $0.000 ETH | 0.00002680 | |
| 0x929c0a…4bf774 | executeOrder | 28,493,959 | 10 days agoWed, 05 Aug 2026 12:42:11 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001796 | |
| 0x775af1…d81225 | executeOrder | 28,344,941 | 10 days agoWed, 05 Aug 2026 08:33:05 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001447 | |
| 0xc1b0ca…80115e | executeOrder | 28,334,299 | 10 days agoWed, 05 Aug 2026 08:15:17 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001400 | |
| 0xa263cd…78a282 | executeOrder | 27,343,431 | 11 days agoTue, 04 Aug 2026 04:38:57 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001623 | |
| 0xf89774…4e2559 | executeOrder | 27,332,223 | 11 days agoTue, 04 Aug 2026 04:20:12 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001696 | |
| 0x6f9582…8024c7 | executeOrder | 27,325,609 | 11 days agoTue, 04 Aug 2026 04:09:10 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001688 | |
| 0x5bc3e1…e84b43 | executeOrder | 22,611,106 | 17 days agoWed, 29 Jul 2026 16:51:35 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00001542 | |
| 0x685a95…cbe9e9 | executeOrder | 22,129,294 | 17 days agoWed, 29 Jul 2026 03:25:49 UTC | 0x9971…17f1 | IN | MoonZapRouter | $1.880.001 ETH | 0.00002277 | |
| 0xca6bd2…25656d | executeOrder | 21,755,217 | 18 days agoTue, 28 Jul 2026 17:01:13 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00001511 | |
| 0xaad8ac…86e6c3 | executeOrder | 21,743,666 | 18 days agoTue, 28 Jul 2026 16:41:55 UTC | 0x9971…17f1 | IN | MoonZapRouter | $0.000 ETH | 0.00001472 | |
| 0xedf9ad…d48ef6 | executeOrder | 19,157,315 | 21 days agoSat, 25 Jul 2026 16:35:10 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00006114 | |
| 0x59627e…b68150 | executeOrder | 18,793,450 | 21 days agoSat, 25 Jul 2026 06:26:04 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00009147 | |
| 0x7279d1…356f87 | executeOrder | 18,770,024 | 21 days agoSat, 25 Jul 2026 05:46:45 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00007123 | |
| 0x0cf204…e6a2c5 | executeOrder | 18,760,487 | 21 days agoSat, 25 Jul 2026 05:30:44 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00007564 | |
| 0xfe10b8…bcf06b | executeOrder | 18,759,691 | 21 days agoSat, 25 Jul 2026 05:29:25 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00006822 | |
| 0xdf8d2a…9845c5 | executeOrder | 18,755,098 | 21 days agoSat, 25 Jul 2026 05:21:43 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00007539 | |
| 0xc3dc3d…6d4d62 | executeOrder | 18,729,111 | 21 days agoSat, 25 Jul 2026 04:38:09 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.000 ETH | 0.00007367 | |
| 0xb5fb16…7b44e0 | executeOrder | 18,726,641 | 21 days agoSat, 25 Jul 2026 04:34:00 UTC | 0x63ef…2d1c | IN | MoonZapRouter | $0.710.00037 ETH | 0.00009044 |
| Transaction Hash | Method | Block | Age | From | To | Amount | Token | ||
|---|---|---|---|---|---|---|---|---|---|
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0xfa62…dc5f | OUT | 0x9971…17f1 | $3.143.148447 USDG | Global Dollar (USDG) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0xfa62…dc5f | OUT | 0x52e6…71ca | 0.000802 WETH | WETH (WETH) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x52e6…71ca | IN | 0xfa62…dc5f | $1.521.518521 USDG | Global Dollar (USDG) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x4c7c…06af | IN | 0xfa62…dc5f | $1.631.629926 USDG | Global Dollar (USDG) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x4c7c…06af | IN | 0xfa62…dc5f | 0.000802 WETH | WETH (WETH) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0xfa62…dc5f | OUT | 0x0000…0000 | 0.000000 moonUniswapRobinhoodWETH-USDG | Moon Uniswap Robinhood WETH-USDG (moonUniswapRobinhoodWETH-USDG) | |
| 0x2078cb16…3abeac | Transfer | 35,186,325 | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x9971…17f1 | IN | 0xfa62…dc5f | 0.000000 moonUniswapRobinhoodWETH-USDG | Moon Uniswap Robinhood WETH-USDG (moonUniswapRobinhoodWETH-USDG) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xfa62…dc5f | OUT | 0x9971…17f1 | $4.494.504011 USDG | Global Dollar (USDG) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xfa62…dc5f | OUT | 0x52e6…71ca | 0.002381 WETH | WETH (WETH) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x52e6…71ca | IN | 0xfa62…dc5f | $4.494.504011 USDG | Global Dollar (USDG) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xfa62…dc5f | OUT | 0xd42a…2b09 | $2.2617.485554 CASHCAT | ||
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xd42a…2b09 | IN | 0xfa62…dc5f | 0.001472 WETH | WETH (WETH) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x379d…f39c | IN | 0xfa62…dc5f | 0.000908 WETH | WETH (WETH) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x379d…f39c | IN | 0xfa62…dc5f | $2.2617.485554 CASHCAT | ||
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xfa62…dc5f | OUT | 0x0000…0000 | 0.001574 moonUniswapRobinhoodCASHCAT-WETH | Moon Uniswap Robinhood CASHCAT-WETH (moonUniswapRobinhoodCASHCAT-WETH) | |
| 0x43214055…e993d8 | Transfer | 35,186,124 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x9971…17f1 | IN | 0xfa62…dc5f | 0.001574 moonUniswapRobinhoodCASHCAT-WETH | Moon Uniswap Robinhood CASHCAT-WETH (moonUniswapRobinhoodCASHCAT-WETH) | |
| 0xee77e16a…7c820b | Transfer | 30,618,043 | 8 days agoFri, 07 Aug 2026 23:47:38 UTC | 0xc7a7…cec7 | IN | 0xfa62…dc5f | 3 IF | What If (IF) | |
| 0xf2013b27…57d848 | Transfer | 30,574,001 | 8 days agoFri, 07 Aug 2026 22:34:13 UTC | 0x2757…221a | IN | 0xfa62…dc5f | 25 MarsCoin | MarsCoin (MarsCoin) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0xfa62…dc5f | OUT | 0x5c4d…9cf8 | $392.69393.521821 USDG | Global Dollar (USDG) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0xfa62…dc5f | OUT | 0x52e6…71ca | 0.206037 WETH | WETH (WETH) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0x52e6…71ca | IN | 0xfa62…dc5f | $392.69393.521821 USDG | Global Dollar (USDG) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0xfa62…dc5f | OUT | 0xd42a…2b09 | $NaN1,995.349291 CASHCAT | ||
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0xd42a…2b09 | IN | 0xfa62…dc5f | 0.102669 WETH | WETH (WETH) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0x379d…f39c | IN | 0xfa62…dc5f | 0.103367 WETH | WETH (WETH) | |
| 0x5b88329a…d78d8a | Transfer | 30,378,948 | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0x379d…f39c | IN | 0xfa62…dc5f | $NaN1,990.523090 CASHCAT |
| Txn Hash | Age | Event | Topics / Data |
|---|---|---|---|
| 0x2078cb…3abeac | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0x1ba5b6…e0b1 | [0] 0x50a5eb4954da…be0ccd29 [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0x2078cb…3abeac | 2 days agoThu, 13 Aug 2026 06:46:53 UTC | 0xeaf449…ac15 | [0] 0x000000000000…16f1d168 data: 0x000000000000000000…00300a9f |
| 0x432140…e993d8 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0x1ba5b6…e0b1 | [0] 0x3110701e6e16…e4fd3e06 [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0x432140…e993d8 | 2 days agoThu, 13 Aug 2026 06:46:33 UTC | 0xeaf449…ac15 | [0] 0x000000000000…16f1d168 data: 0x000000000000000000…0044b9cb |
| 0x5b8832…d78d8a | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0x1ba5b6…e0b1 | [0] 0xdc05ca884d54…8052e82e [1] 0x000000000000…92149cf8 [2] 0x000000000000…92149cf8 |
| 0x5b8832…d78d8a | 8 days agoFri, 07 Aug 2026 17:08:49 UTC | 0xeaf449…ac15 | [0] 0x000000000000…16f1d168 data: 0x000000000000000000…1774aa9d |
| 0xea7b26…3fbf38 | 8 days agoFri, 07 Aug 2026 17:08:02 UTC | 0x1ba5b6…e0b1 | [0] 0x35e1742b035f…4be462c3 [1] 0x000000000000…92149cf8 [2] 0x000000000000…92149cf8 |
| 0xea7b26…3fbf38 | 8 days agoFri, 07 Aug 2026 17:08:02 UTC | 0xeaf449…ac15 | [0] 0x000000000000…a46bf39c data: 0x000000000000000000…34fe1dd5 |
| 0xbe1a5c…1ef81d | 9 days agoThu, 06 Aug 2026 21:13:01 UTC | 0x1ba5b6…e0b1 | [0] 0x466395c9179f…ded99bfc [1] 0x000000000000…92149cf8 [2] 0x000000000000…92149cf8 |
| 0xbe1a5c…1ef81d | 9 days agoThu, 06 Aug 2026 21:13:01 UTC | 0xeaf449…ac15 | [0] 0x000000000000…6344399c data: 0x000000000000000000…000f423f |
| 0x3e2381…e53214 | 9 days agoThu, 06 Aug 2026 17:57:36 UTC | 0x1ba5b6…e0b1 | [0] 0x5ed3c90763f3…d4e36195 [1] 0x000000000000…92149cf8 [2] 0x000000000000…92149cf8 |
| 0x3e2381…e53214 | 9 days agoThu, 06 Aug 2026 17:57:36 UTC | 0xeaf449…ac15 | [0] 0x000000000000…a46bf39c data: 0x000000000000000000…adf36447 |
| 0xe9638e…d2130a | 9 days agoThu, 06 Aug 2026 17:55:14 UTC | 0x1ba5b6…e0b1 | [0] 0x3664b8d4a174…c5b197a0 [1] 0x000000000000…92149cf8 [2] 0x000000000000…92149cf8 |
| 0xe9638e…d2130a | 9 days agoThu, 06 Aug 2026 17:55:14 UTC | 0xeaf449…ac15 | [0] 0x000000000000…a46bf39c data: 0x000000000000000000…bf66d8ed |
| 0x929c0a…4bf774 | 10 days agoWed, 05 Aug 2026 12:42:11 UTC | 0x1ba5b6…e0b1 | [0] 0xf9a526d4f05c…c5b8388b [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0x929c0a…4bf774 | 10 days agoWed, 05 Aug 2026 12:42:11 UTC | 0xeaf449…ac15 | [0] 0x000000000000…b89906af data: 0x000000000000000000…000e1fa1 |
| 0x775af1…d81225 | 10 days agoWed, 05 Aug 2026 08:33:05 UTC | 0x1ba5b6…e0b1 | [0] 0xb6b01f8e1662…41be65c6 [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0x775af1…d81225 | 10 days agoWed, 05 Aug 2026 08:33:05 UTC | 0xeaf449…ac15 | [0] 0x000000000000…1eacad73 data: 0x000000000000000000…e2636bd1 |
| 0xc1b0ca…80115e | 10 days agoWed, 05 Aug 2026 08:15:17 UTC | 0x1ba5b6…e0b1 | [0] 0xd0c7c28fbd67…04385489 [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0xc1b0ca…80115e | 10 days agoWed, 05 Aug 2026 08:15:17 UTC | 0xeaf449…ac15 | [0] 0x000000000000…291018b4 data: 0x000000000000000000…4b279dae |
| 0xa263cd…78a282 | 11 days agoTue, 04 Aug 2026 04:38:57 UTC | 0x1ba5b6…e0b1 | [0] 0x5ada95d891e3…3b122e1e [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0xa263cd…78a282 | 11 days agoTue, 04 Aug 2026 04:38:57 UTC | 0xeaf449…ac15 | [0] 0x000000000000…b89906af data: 0x000000000000000000…000e6960 |
| 0xf89774…4e2559 | 11 days agoTue, 04 Aug 2026 04:20:12 UTC | 0x1ba5b6…e0b1 | [0] 0xf3dea6dcce27…3200e88d [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |
| 0xf89774…4e2559 | 11 days agoTue, 04 Aug 2026 04:20:12 UTC | 0xeaf449…ac15 | [0] 0x000000000000…16f1d168 data: 0x000000000000000000…0009d8ee |
| 0x6f9582…8024c7 | 11 days agoTue, 04 Aug 2026 04:09:10 UTC | 0x1ba5b6…e0b1 | [0] 0x0280a152d2e4…4e15f68e [1] 0x000000000000…b65d17f1 [2] 0x000000000000…b65d17f1 |