ETH Price: $3,395.52 (+6.39%)

Contract

0x0654874eb7F59C6f5b39931FC45dC45337c967c3
Transaction Hash
Method
Block
From
To
Swap And Forward...1227329502024-07-15 17:31:1724 mins ago1721064677IN
0x0654874e...337c967c3
0.0035 ETH0.0000274796270.06179891
Forward Eth1227328002024-07-15 17:26:1729 mins ago1721064377IN
0x0654874e...337c967c3
0.14 ETH0.0000063369640.06182795
Forward Eth1227322672024-07-15 17:08:3146 mins ago1721063311IN
0x0654874e...337c967c3
0.221 ETH0.0000063139750.0619583
Forward Eth1227301322024-07-15 15:57:211 hr ago1721059041IN
0x0654874e...337c967c3
0.649 ETH0.0000061723960.0619213
Forward Eth1227288662024-07-15 15:15:092 hrs ago1721056509IN
0x0654874e...337c967c3
0.312 ETH0.000003501740.0344796
Swap And Forward...1227275822024-07-15 14:32:213 hrs ago1721053941IN
0x0654874e...337c967c3
0.151 ETH0.0000030100230.00460888
Forward Eth1227271942024-07-15 14:19:253 hrs ago1721053165IN
0x0654874e...337c967c3
0.3111 ETH0.0000004882220.0035191
Forward Eth1227271542024-07-15 14:18:053 hrs ago1721053085IN
0x0654874e...337c967c3
0.47 ETH0.0000022819240.0223512
Forward ERC201227266602024-07-15 14:01:373 hrs ago1721052097IN
0x0654874e...337c967c3
0 ETH0.0000006497090.00219048
Swap And Forward...1227265952024-07-15 13:59:273 hrs ago1721051967IN
0x0654874e...337c967c3
0 ETH0.0000014795110.0023536
Forward Eth1227257952024-07-15 13:32:474 hrs ago1721050367IN
0x0654874e...337c967c3
0.038 ETH0.0000002381480.00153394
Forward Eth1227252902024-07-15 13:15:574 hrs ago1721049357IN
0x0654874e...337c967c3
0.04410794 ETH0.000000260140.0016623
Forward ERC201227249872024-07-15 13:05:514 hrs ago1721048751IN
0x0654874e...337c967c3
0 ETH0.0000017022560.0070369
Forward ERC201227249522024-07-15 13:04:414 hrs ago1721048681IN
0x0654874e...337c967c3
0 ETH0.0000022606980.0095683
Swap And Forward...1227246582024-07-15 12:54:535 hrs ago1721048093IN
0x0654874e...337c967c3
0.00236823 ETH0.0000010366470.00136572
Forward Eth1227242172024-07-15 12:40:115 hrs ago1721047211IN
0x0654874e...337c967c3
0.07 ETH0.0000001906840.00130706
Swap And Forward...1227241102024-07-15 12:36:375 hrs ago1721046997IN
0x0654874e...337c967c3
0.075 ETH0.0000008677330.00138037
Forward Eth1227225522024-07-15 11:44:416 hrs ago1721043881IN
0x0654874e...337c967c3
0.069 ETH0.0000001984710.001484
Forward Eth1227211862024-07-15 10:59:096 hrs ago1721041149IN
0x0654874e...337c967c3
0.301 ETH0.0000003932630.003511
Forward Eth1227206012024-07-15 10:39:397 hrs ago1721039979IN
0x0654874e...337c967c3
0.0075 ETH0.000000234530.0015197
Forward Eth1227197222024-07-15 10:10:217 hrs ago1721038221IN
0x0654874e...337c967c3
0.03708 ETH0.0000001860650.00137999
Forward ERC201227193172024-07-15 9:56:517 hrs ago1721037411IN
0x0654874e...337c967c3
0 ETH0.0000004101680.00148447
Forward Eth1227176482024-07-15 9:01:138 hrs ago1721034073IN
0x0654874e...337c967c3
0.081 ETH0.0000002365150.00149124
Forward Eth1227171452024-07-15 8:44:279 hrs ago1721033067IN
0x0654874e...337c967c3
0.004 ETH0.0000002075640.0014368
Forward Eth1227169532024-07-15 8:38:039 hrs ago1721032683IN
0x0654874e...337c967c3
0.2 ETH0.0000001995840.0013486
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
1227329502024-07-15 17:31:1724 mins ago1721064677
0x0654874e...337c967c3
0.0035 ETH
1227328002024-07-15 17:26:1729 mins ago1721064377
0x0654874e...337c967c3
0.14 ETH
1227322672024-07-15 17:08:3146 mins ago1721063311
0x0654874e...337c967c3
0.221 ETH
1227301322024-07-15 15:57:211 hr ago1721059041
0x0654874e...337c967c3
0.649 ETH
1227288662024-07-15 15:15:092 hrs ago1721056509
0x0654874e...337c967c3
0.312 ETH
1227275822024-07-15 14:32:213 hrs ago1721053941
0x0654874e...337c967c3
0.151 ETH
1227271942024-07-15 14:19:253 hrs ago1721053165
0x0654874e...337c967c3
0.3111 ETH
1227271542024-07-15 14:18:053 hrs ago1721053085
0x0654874e...337c967c3
0.47 ETH
1227257952024-07-15 13:32:474 hrs ago1721050367
0x0654874e...337c967c3
0.038 ETH
1227252902024-07-15 13:15:574 hrs ago1721049357
0x0654874e...337c967c3
0.04410794 ETH
1227246582024-07-15 12:54:535 hrs ago1721048093
0x0654874e...337c967c3
0.00236823 ETH
1227242172024-07-15 12:40:115 hrs ago1721047211
0x0654874e...337c967c3
0.07 ETH
1227241102024-07-15 12:36:375 hrs ago1721046997
0x0654874e...337c967c3
0.075 ETH
1227225522024-07-15 11:44:416 hrs ago1721043881
0x0654874e...337c967c3
0.069 ETH
1227211862024-07-15 10:59:096 hrs ago1721041149
0x0654874e...337c967c3
0.301 ETH
1227206012024-07-15 10:39:397 hrs ago1721039979
0x0654874e...337c967c3
0.0075 ETH
1227197222024-07-15 10:10:217 hrs ago1721038221
0x0654874e...337c967c3
0.03708 ETH
1227176482024-07-15 9:01:138 hrs ago1721034073
0x0654874e...337c967c3
0.081 ETH
1227171452024-07-15 8:44:279 hrs ago1721033067
0x0654874e...337c967c3
0.004 ETH
1227169532024-07-15 8:38:039 hrs ago1721032683
0x0654874e...337c967c3
0.2 ETH
1227163102024-07-15 8:16:379 hrs ago1721031397
0x0654874e...337c967c3
0.233 ETH
1227137792024-07-15 6:52:1511 hrs ago1721026335
0x0654874e...337c967c3
0.099 ETH
1227100352024-07-15 4:47:2713 hrs ago1721018847
0x0654874e...337c967c3
0.054 ETH
1227092082024-07-15 4:19:5313 hrs ago1721017193
0x0654874e...337c967c3
0.0558 ETH
1227017022024-07-15 0:09:4117 hrs ago1721002181
0x0654874e...337c967c3
0.0709 ETH
View All Internal Transactions

Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
MayanForwarder

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 6 : MayanForwarder.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol";
import "./libs/BytesLib.sol";


contract MayanForwarder {

	using SafeERC20 for IERC20;
	using BytesLib for bytes;

	event SwapAndForwarded(uint256 amount);

	address public guardian;
	address public nextGuardian;
	mapping(address => bool) public swapProtocols;
	mapping(address => bool) public mayanProtocols;

	event ForwardedEth(address mayanProtocol, bytes protocolData);
	event ForwardedERC20(address token, uint256 amount, address mayanProtocol, bytes protocolData);
	event SwapAndForwardedEth(uint256 amountIn, address swapProtocol, address middleToken, uint256 middleAmount, address mayanProtocol, bytes mayanData);
	event SwapAndForwardedERC20(address tokenIn, uint256 amountIn, address swapProtocol, address middleToken, uint256 middleAmount, address mayanProtocol, bytes mayanData);

	error UnsupportedProtocol();

	struct PermitParams {
		uint256 value;
		uint256 deadline;
		uint8 v;
		bytes32 r;
		bytes32 s;
	}

	constructor(address _guardian, address[] memory _swapProtocols, address[] memory _mayanProtocols) {
		guardian = _guardian;
		for (uint256 i = 0; i < _swapProtocols.length; i++) {
			swapProtocols[_swapProtocols[i]] = true;
		}
		for (uint256 i = 0; i < _mayanProtocols.length; i++) {
			mayanProtocols[_mayanProtocols[i]] = true;
		}
	}

	function forwardEth(
		address mayanProtocol,
		bytes calldata protocolData
	) external payable {
		if (!mayanProtocols[mayanProtocol]) {
			revert UnsupportedProtocol();
		}
		(bool success, bytes memory returnedData) = mayanProtocol.call{value: msg.value}(protocolData);
		require(success, string(returnedData));

		emit ForwardedEth(mayanProtocol, protocolData);
	}
	
	function forwardERC20(
		address tokenIn,
		uint256 amountIn,
		PermitParams calldata permitParams,
		address mayanProtocol,
		bytes calldata protocolData
		) external payable {
		if (!mayanProtocols[mayanProtocol]) {
			revert UnsupportedProtocol();
		}

		pullTokenIn(tokenIn, amountIn, permitParams);

		maxApproveIfNeeded(tokenIn, mayanProtocol, amountIn);
		(bool success, bytes memory returnedData) = mayanProtocol.call{value: msg.value}(protocolData);
		require(success, string(returnedData));

		emit ForwardedERC20(tokenIn, amountIn, mayanProtocol, protocolData);
	}

	function swapAndForwardEth(
		uint256 amountIn,
		address swapProtocol,
		bytes calldata swapData,
		address middleToken,
		uint256 minMiddleAmount,
		address mayanProtocol,
		bytes calldata mayanData
	) external payable {
		if (!swapProtocols[swapProtocol] || !mayanProtocols[mayanProtocol]) {
			revert UnsupportedProtocol();
		}
		require(middleToken != address(0), "middleToken cannot be zero address");

		require(msg.value >= amountIn, "insufficient amountIn");
		uint256 middleAmount = IERC20(middleToken).balanceOf(address(this));

		(bool success, bytes memory returnedData) = swapProtocol.call{value: amountIn}(swapData);
		require(success, string(returnedData));

		middleAmount = IERC20(middleToken).balanceOf(address(this)) - middleAmount;
		require(middleAmount >= minMiddleAmount, "MayanForwarder: insufficient middle token amount");

		maxApproveIfNeeded(middleToken, mayanProtocol, middleAmount);

		bytes memory modifiedData = replaceMiddleAmount(mayanData, middleAmount);
		(success, returnedData) = mayanProtocol.call{value: msg.value - amountIn}(modifiedData);
		require(success, string(returnedData));

		emit SwapAndForwardedEth(amountIn, swapProtocol, middleToken, middleAmount, mayanProtocol, mayanData);
	}

	function swapAndForwardERC20(
		address tokenIn,
		uint256 amountIn,
		PermitParams calldata permitParams,
		address swapProtocol,
		bytes calldata swapData,
		address middleToken,
		uint256 minMiddleAmount,
		address mayanProtocol,
		bytes calldata mayanData
	) external payable {
		if (!swapProtocols[swapProtocol] || !mayanProtocols[mayanProtocol]) {
			revert UnsupportedProtocol();
		}
		require(tokenIn != middleToken, "tokenIn and tokenOut must be different");

		pullTokenIn(tokenIn, amountIn, permitParams);

		maxApproveIfNeeded(tokenIn, swapProtocol, amountIn);
		uint256 middleAmount = IERC20(middleToken).balanceOf(address(this));

		(bool success, bytes memory returnedData) = swapProtocol.call{value: 0}(swapData);
		require(success, string(returnedData));

		middleAmount = IERC20(middleToken).balanceOf(address(this)) - middleAmount;
		require(middleAmount >= minMiddleAmount, "insufficient middle token");

		maxApproveIfNeeded(middleToken, mayanProtocol, middleAmount);
		bytes memory modifiedData = replaceMiddleAmount(mayanData, middleAmount);
		(success, returnedData) = mayanProtocol.call{value: msg.value}(modifiedData);
		require(success, string(returnedData));

		transferBackRemaining(tokenIn, amountIn);

		emit SwapAndForwardedERC20(tokenIn, amountIn, swapProtocol, middleToken, middleAmount, mayanProtocol, mayanData);
	}

	function replaceMiddleAmount(bytes calldata mayanData, uint256 middleAmount) internal pure returns(bytes memory) {
		require(mayanData.length >= 68, "Mayan data too short");
		bytes memory modifiedData = new bytes(mayanData.length);

		// Copy the function selector and token in
		for (uint i = 0; i < 36; i++) {
			modifiedData[i] = mayanData[i];
		}

		// Encode the amount and place it into the modified call data
		// Starting from byte 36 to byte 67 (32 bytes for uint256)
		bytes memory encodedAmount = abi.encode(middleAmount);
		for (uint i = 0; i < 32; i++) {
			modifiedData[i + 36] = encodedAmount[i];
		}

		// Copy the rest of the original data after the first argument
		for (uint i = 68; i < mayanData.length; i++) {
			modifiedData[i] = mayanData[i];
		}

		return modifiedData;
	}

	function maxApproveIfNeeded(address tokenAddr, address spender, uint256 amount) internal {
		IERC20 token = IERC20(tokenAddr);
		uint256 currentAllowance = token.allowance(address(this), spender);

		if (currentAllowance < amount) {
			token.safeApprove(spender, 0);
			token.safeApprove(spender, type(uint256).max);
		}
	}

	function execPermit(
		address token,
		address owner,
		PermitParams calldata permitParams
	) internal {
		IERC20Permit(token).permit(
			owner,
			address(this),
			permitParams.value,
			permitParams.deadline,
			permitParams.v,
			permitParams.r,
			permitParams.s
		);
	}

	function pullTokenIn(
		address tokenIn,
		uint256 amountIn,
		PermitParams calldata permitParams
	) internal {
		uint256 allowance = IERC20(tokenIn).allowance(msg.sender, address(this));
		if (allowance < amountIn) {
			execPermit(tokenIn, msg.sender, permitParams);
		}
		IERC20(tokenIn).safeTransferFrom(msg.sender, address(this), amountIn);
	}

	function transferBackRemaining(address token, uint256 maxAmount) internal {
		uint256 remaining = IERC20(token).balanceOf(address(this));
		if (remaining > 0 && remaining <= maxAmount) {
			IERC20(token).safeTransfer(msg.sender, remaining);
		}
	}

	function rescueToken(address token, uint256 amount, address to) public {
		require(msg.sender == guardian, 'only guardian');
		IERC20(token).safeTransfer(to, amount);
	}

	function rescueEth(uint256 amount, address payable to) public {
		require(msg.sender == guardian, 'only guardian');
		require(to != address(0), 'transfer to the zero address');
		to.transfer(amount);
	}

	function changeGuardian(address newGuardian) public {
		require(msg.sender == guardian, 'only guardian');
		nextGuardian = newGuardian;
	}

	function claimGuardian() public {
		require(msg.sender == nextGuardian, 'only next guardian');
		guardian = nextGuardian;
	}

	function setSwapProtocol(address swapProtocol, bool enabled) public {
		require(msg.sender == guardian, 'only guardian');
		swapProtocols[swapProtocol] = enabled;
	}

	function setMayanProtocol(address mayanProtocol, bool enabled) public {
		require(msg.sender == guardian, 'only guardian');
		mayanProtocols[mayanProtocol] = enabled;
	}
}

File 2 of 6 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}

File 3 of 6 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @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);
}

File 4 of 6 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";

/**
 * @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. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    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));
    }
}

File 5 of 6 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @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);
        }
    }
}

File 6 of 6 : BytesLib.sol
// SPDX-License-Identifier: Unlicense
/*
 * @title Solidity Bytes Arrays Utils
 * @author Gonçalo Sá <[email protected]>
 *
 * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
 *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
 */
pragma solidity >=0.8.0 <0.9.0;


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;
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_guardian","type":"address"},{"internalType":"address[]","name":"_swapProtocols","type":"address[]"},{"internalType":"address[]","name":"_mayanProtocols","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"UnsupportedProtocol","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"mayanProtocol","type":"address"},{"indexed":false,"internalType":"bytes","name":"protocolData","type":"bytes"}],"name":"ForwardedERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"mayanProtocol","type":"address"},{"indexed":false,"internalType":"bytes","name":"protocolData","type":"bytes"}],"name":"ForwardedEth","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"SwapAndForwarded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"tokenIn","type":"address"},{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"address","name":"swapProtocol","type":"address"},{"indexed":false,"internalType":"address","name":"middleToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"middleAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"mayanProtocol","type":"address"},{"indexed":false,"internalType":"bytes","name":"mayanData","type":"bytes"}],"name":"SwapAndForwardedERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountIn","type":"uint256"},{"indexed":false,"internalType":"address","name":"swapProtocol","type":"address"},{"indexed":false,"internalType":"address","name":"middleToken","type":"address"},{"indexed":false,"internalType":"uint256","name":"middleAmount","type":"uint256"},{"indexed":false,"internalType":"address","name":"mayanProtocol","type":"address"},{"indexed":false,"internalType":"bytes","name":"mayanData","type":"bytes"}],"name":"SwapAndForwardedEth","type":"event"},{"inputs":[{"internalType":"address","name":"newGuardian","type":"address"}],"name":"changeGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimGuardian","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct MayanForwarder.PermitParams","name":"permitParams","type":"tuple"},{"internalType":"address","name":"mayanProtocol","type":"address"},{"internalType":"bytes","name":"protocolData","type":"bytes"}],"name":"forwardERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"mayanProtocol","type":"address"},{"internalType":"bytes","name":"protocolData","type":"bytes"}],"name":"forwardEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"guardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"mayanProtocols","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextGuardian","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"to","type":"address"}],"name":"rescueEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"to","type":"address"}],"name":"rescueToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"mayanProtocol","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setMayanProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"swapProtocol","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setSwapProtocol","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"tokenIn","type":"address"},{"internalType":"uint256","name":"amountIn","type":"uint256"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"internalType":"struct MayanForwarder.PermitParams","name":"permitParams","type":"tuple"},{"internalType":"address","name":"swapProtocol","type":"address"},{"internalType":"bytes","name":"swapData","type":"bytes"},{"internalType":"address","name":"middleToken","type":"address"},{"internalType":"uint256","name":"minMiddleAmount","type":"uint256"},{"internalType":"address","name":"mayanProtocol","type":"address"},{"internalType":"bytes","name":"mayanData","type":"bytes"}],"name":"swapAndForwardERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amountIn","type":"uint256"},{"internalType":"address","name":"swapProtocol","type":"address"},{"internalType":"bytes","name":"swapData","type":"bytes"},{"internalType":"address","name":"middleToken","type":"address"},{"internalType":"uint256","name":"minMiddleAmount","type":"uint256"},{"internalType":"address","name":"mayanProtocol","type":"address"},{"internalType":"bytes","name":"mayanData","type":"bytes"}],"name":"swapAndForwardEth","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"swapProtocols","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

60806040523480156200001157600080fd5b50604051620021b1380380620021b183398101604081905262000034916200021b565b600080546001600160a01b0319166001600160a01b0385161781555b8251811015620000c8576001600260008584815181106200008157634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff191691151591909117905580620000bf8162000295565b91505062000050565b5060005b81518110156200014457600160036000848481518110620000fd57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160a01b03168252810191909152604001600020805460ff1916911515919091179055806200013b8162000295565b915050620000cc565b50505050620002d3565b80516001600160a01b03811681146200016657600080fd5b919050565b600082601f8301126200017c578081fd5b815160206001600160401b03808311156200019b576200019b620002bd565b8260051b604051601f19603f83011681018181108482111715620001c357620001c3620002bd565b60405284815283810192508684018288018501891015620001e2578687fd5b8692505b858310156200020f57620001fa816200014e565b845292840192600192909201918401620001e6565b50979650505050505050565b60008060006060848603121562000230578283fd5b6200023b846200014e565b60208501519093506001600160401b038082111562000258578384fd5b62000266878388016200016b565b935060408601519150808211156200027c578283fd5b506200028b868287016200016b565b9150509250925092565b6000600019821415620002b657634e487b7160e01b81526011600452602481fd5b5060010190565b634e487b7160e01b600052604160045260246000fd5b611ece80620002e36000396000f3fe6080604052600436106100dd5760003560e01c8063af56ca031161007f578063e4269fc411610059578063e4269fc41461023c578063f8a67a621461024f578063fa74fd431461026f578063ffe805411461028257600080fd5b8063af56ca03146101c9578063b0f584ff14610209578063b25ea8fb1461021c57600080fd5b8063459656ee116100bb578063459656ee146101545780634818e84d146101695780637fc920eb14610189578063a44382fe146101a957600080fd5b80632fcb4f04146100e257806330dedc5714610104578063452a932014610117575b600080fd5b3480156100ee57600080fd5b506101026100fd366004611899565b6102b2565b005b610102610112366004611a0c565b610307565b34801561012357600080fd5b50600054610137906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561016057600080fd5b506101026106c0565b34801561017557600080fd5b50600154610137906001600160a01b031681565b34801561019557600080fd5b506101026101a43660046118bc565b610733565b3480156101b557600080fd5b506101026101c43660046118bc565b610788565b3480156101d557600080fd5b506101f96101e4366004611899565b60036020526000908152604090205460ff1681565b604051901515815260200161014b565b6101026102173660046118f4565b6107dd565b34801561022857600080fd5b50610102610237366004611b2a565b6108de565b61010261024a366004611988565b610999565b34801561025b57600080fd5b5061010261026a366004611947565b610ab7565b61010261027d366004611b4e565b610af5565b34801561028e57600080fd5b506101f961029d366004611899565b60026020526000908152604090205460ff1681565b6000546001600160a01b031633146102e55760405162461bcd60e51b81526004016102dc90611d70565b60405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03881660009081526002602052604090205460ff16158061034857506001600160a01b03831660009081526003602052604090205460ff16155b156103665760405163743f26e160e01b815260040160405180910390fd5b846001600160a01b03168b6001600160a01b031614156103d75760405162461bcd60e51b815260206004820152602660248201527f746f6b656e496e20616e6420746f6b656e4f7574206d7573742062652064696660448201526519995c995b9d60d21b60648201526084016102dc565b6103e28b8b8b610ee3565b6103ed8b898c610f93565b6040516370a0823160e01b81523060048201526000906001600160a01b038716906370a082319060240160206040518083038186803b15801561042f57600080fd5b505afa158015610443573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104679190611b12565b90506000808a6001600160a01b031660008b8b604051610488929190611c56565b60006040518083038185875af1925050503d80600081146104c5576040519150601f19603f3d011682016040523d82523d6000602084013e6104ca565b606091505b50915091508181906104ef5760405162461bcd60e51b81526004016102dc9190611d3d565b506040516370a0823160e01b815230600482015283906001600160a01b038a16906370a082319060240160206040518083038186803b15801561053157600080fd5b505afa158015610545573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105699190611b12565b6105739190611dfe565b9250868310156105c55760405162461bcd60e51b815260206004820152601960248201527f696e73756666696369656e74206d6964646c6520746f6b656e0000000000000060448201526064016102dc565b6105d0888785610f93565b60006105dd868686611053565b9050866001600160a01b031634826040516105f89190611c66565b60006040518083038185875af1925050503d8060008114610635576040519150601f19603f3d011682016040523d82523d6000602084013e61063a565b606091505b509093509150818361065f5760405162461bcd60e51b81526004016102dc9190611d3d565b5061066a8f8f6112b1565b7f23278f58875126c795a4072b98b5851fe9b21cea19895b02a6224fefbb1e32988f8f8e8c888c8c8c6040516106a7989796959493929190611cb0565b60405180910390a1505050505050505050505050505050565b6001546001600160a01b0316331461070f5760405162461bcd60e51b815260206004820152601260248201527137b7363c903732bc3a1033bab0b93234b0b760711b60448201526064016102dc565b600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000546001600160a01b0316331461075d5760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146107b25760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b6001600160a01b03831660009081526003602052604090205460ff166108165760405163743f26e160e01b815260040160405180910390fd5b600080846001600160a01b0316348585604051610834929190611c56565b60006040518083038185875af1925050503d8060008114610871576040519150601f19603f3d011682016040523d82523d6000602084013e610876565b606091505b509150915081819061089b5760405162461bcd60e51b81526004016102dc9190611d3d565b507fb8543d214cab9591941648db8d40126a163bfd0db4a865678320b921e13980438585856040516108cf93929190611c82565b60405180910390a15050505050565b6000546001600160a01b031633146109085760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03811661095e5760405162461bcd60e51b815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016102dc565b6040516001600160a01b0382169083156108fc029084906000818181858888f19350505050158015610994573d6000803e3d6000fd5b505050565b6001600160a01b03831660009081526003602052604090205460ff166109d25760405163743f26e160e01b815260040160405180910390fd5b6109dd868686610ee3565b6109e8868487610f93565b600080846001600160a01b0316348585604051610a06929190611c56565b60006040518083038185875af1925050503d8060008114610a43576040519150601f19603f3d011682016040523d82523d6000602084013e610a48565b606091505b5091509150818190610a6d5760405162461bcd60e51b81526004016102dc9190611d3d565b507fbf150db6b4a14b084f7346b4bc300f552ce867afe55be27bce2d6b37e3307cda8888878787604051610aa5959493929190611d09565b60405180910390a15050505050505050565b6000546001600160a01b03163314610ae15760405162461bcd60e51b81526004016102dc90611d70565b6109946001600160a01b0384168284611352565b6001600160a01b03881660009081526002602052604090205460ff161580610b3657506001600160a01b03831660009081526003602052604090205460ff16155b15610b545760405163743f26e160e01b815260040160405180910390fd5b6001600160a01b038516610bb55760405162461bcd60e51b815260206004820152602260248201527f6d6964646c65546f6b656e2063616e6e6f74206265207a65726f206164647265604482015261737360f01b60648201526084016102dc565b88341015610bfd5760405162461bcd60e51b815260206004820152601560248201527434b739bab33334b1b4b2b73a1030b6b7bab73a24b760591b60448201526064016102dc565b6040516370a0823160e01b81523060048201526000906001600160a01b038716906370a082319060240160206040518083038186803b158015610c3f57600080fd5b505afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190611b12565b90506000808a6001600160a01b03168c8b8b604051610c97929190611c56565b60006040518083038185875af1925050503d8060008114610cd4576040519150601f19603f3d011682016040523d82523d6000602084013e610cd9565b606091505b5091509150818190610cfe5760405162461bcd60e51b81526004016102dc9190611d3d565b506040516370a0823160e01b815230600482015283906001600160a01b038a16906370a082319060240160206040518083038186803b158015610d4057600080fd5b505afa158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d789190611b12565b610d829190611dfe565b925086831015610ded5760405162461bcd60e51b815260206004820152603060248201527f4d6179616e466f727761726465723a20696e73756666696369656e74206d696460448201526f191b19481d1bdad95b88185b5bdd5b9d60821b60648201526084016102dc565b610df8888785610f93565b6000610e05868686611053565b90506001600160a01b038716610e1b8e34611dfe565b82604051610e299190611c66565b60006040518083038185875af1925050503d8060008114610e66576040519150601f19603f3d011682016040523d82523d6000602084013e610e6b565b606091505b5090935091508183610e905760405162461bcd60e51b81526004016102dc9190611d3d565b507f7cbff921ae1f3ea71284120d2aabde13587df067f2bb5c831ea6e35d7a9242ac8d8d8b878b8b8b604051610ecc9796959493929190611d97565b60405180910390a150505050505050505050505050565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0385169063dd62ed3e9060440160206040518083038186803b158015610f2b57600080fd5b505afa158015610f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f639190611b12565b905082811015610f7857610f788433846113b5565b610f8d6001600160a01b03851633308661146d565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152849160009183169063dd62ed3e9060440160206040518083038186803b158015610fdf57600080fd5b505afa158015610ff3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110179190611b12565b90508281101561104c576110366001600160a01b0383168560006114a5565b61104c6001600160a01b038316856000196114a5565b5050505050565b6060604483101561109d5760405162461bcd60e51b815260206004820152601460248201527313585e585b8819185d18481d1bdbc81cda1bdc9d60621b60448201526064016102dc565b60008367ffffffffffffffff8111156110c657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156110f0576020820181803683370190505b50905060005b60248110156111725785858281811061111f57634e487b7160e01b600052603260045260246000fd5b9050013560f81c60f81b82828151811061114957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061116a81611e41565b9150506110f6565b5060008360405160200161118891815260200190565b604051602081830303815290604052905060005b6020811015611227578181815181106111c557634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b031916836111e0836024611de6565b815181106111fe57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061121f81611e41565b91505061119c565b5060445b858110156112a65786868281811061125357634e487b7160e01b600052603260045260246000fd5b9050013560f81c60f81b83828151811061127d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061129e81611e41565b91505061122b565b509095945050505050565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b1580156112f357600080fd5b505afa158015611307573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132b9190611b12565b905060008111801561133d5750818111155b15610994576109946001600160a01b03841633835b6040516001600160a01b03831660248201526044810182905261099490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526115c9565b6001600160a01b03831663d505accf8330843560208601356113dd6060880160408901611c0c565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e401600060405180830381600087803b15801561145057600080fd5b505af1158015611464573d6000803e3d6000fd5b50505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f8d9085906323b872dd60e01b9060840161137e565b80158061152e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156114f457600080fd5b505afa158015611508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152c9190611b12565b155b6115995760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016102dc565b6040516001600160a01b03831660248201526044810182905261099490849063095ea7b360e01b9060640161137e565b600061161e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661169e9092919063ffffffff16565b905080516000148061163f57508080602001905181019061163f9190611af6565b6109945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102dc565b60606116ad84846000856116b5565b949350505050565b6060824710156117165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102dc565b600080866001600160a01b031685876040516117329190611c66565b60006040518083038185875af1925050503d806000811461176f576040519150601f19603f3d011682016040523d82523d6000602084013e611774565b606091505b509150915061178587838387611790565b979650505050505050565b606083156117fc5782516117f5576001600160a01b0385163b6117f55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102dc565b50816116ad565b6116ad83838151156118115781518083602001fd5b8060405162461bcd60e51b81526004016102dc9190611d3d565b803561183681611e72565b919050565b60008083601f84011261184c578182fd5b50813567ffffffffffffffff811115611863578182fd5b60208301915083602082850101111561187b57600080fd5b9250929050565b600060a08284031215611893578081fd5b50919050565b6000602082840312156118aa578081fd5b81356118b581611e72565b9392505050565b600080604083850312156118ce578081fd5b82356118d981611e72565b915060208301356118e981611e8a565b809150509250929050565b600080600060408486031215611908578081fd5b833561191381611e72565b9250602084013567ffffffffffffffff81111561192e578182fd5b61193a8682870161183b565b9497909650939450505050565b60008060006060848603121561195b578283fd5b833561196681611e72565b925060208401359150604084013561197d81611e72565b809150509250925092565b60008060008060008061012087890312156119a1578182fd5b86356119ac81611e72565b9550602087013594506119c28860408901611882565b935060e08701356119d281611e72565b925061010087013567ffffffffffffffff8111156119ee578283fd5b6119fa89828a0161183b565b979a9699509497509295939492505050565b60008060008060008060008060008060006101a08c8e031215611a2d578485fd5b611a378c35611e72565b8b359a5060208c01359950611a4f8d60408e01611882565b9850611a5e60e08d0135611e72565b60e08c0135975067ffffffffffffffff806101008e01351115611a7f578586fd5b611a908e6101008f01358f0161183b565b9098509650611aa26101208e0161182b565b95506101408d01359450611ab96101608e0161182b565b9350806101808e01351115611acc578283fd5b50611ade8d6101808e01358e0161183b565b81935080925050509295989b509295989b9093969950565b600060208284031215611b07578081fd5b81516118b581611e8a565b600060208284031215611b23578081fd5b5051919050565b60008060408385031215611b3c578182fd5b8235915060208301356118e981611e72565b600080600080600080600080600060e08a8c031215611b6b578485fd5b8935985060208a0135611b7d81611e72565b975060408a013567ffffffffffffffff80821115611b99578687fd5b611ba58d838e0161183b565b909950975060608c01359150611bba82611e72565b90955060808b0135945060a08b013590611bd382611e72565b90935060c08b01359080821115611be8578384fd5b50611bf58c828d0161183b565b915080935050809150509295985092959850929598565b600060208284031215611c1d578081fd5b813560ff811681146118b5578182fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8183823760009101908152919050565b60008251611c78818460208701611e15565b9190910192915050565b6001600160a01b0384168152604060208201819052600090611ca79083018486611c2d565b95945050505050565b6001600160a01b038981168252602082018990528781166040830152868116606083015260808201869052841660a082015260e060c08201819052600090611cfb9083018486611c2d565b9a9950505050505050505050565b6001600160a01b03868116825260208201869052841660408201526080606082018190526000906117859083018486611c2d565b6020815260008251806020840152611d5c816040850160208701611e15565b601f01601f19169190910160400192915050565b6020808252600d908201526c37b7363c9033bab0b93234b0b760991b604082015260600190565b8781526001600160a01b0387811660208301528681166040830152606082018690528416608082015260c060a08201819052600090611dd99083018486611c2d565b9998505050505050505050565b60008219821115611df957611df9611e5c565b500190565b600082821015611e1057611e10611e5c565b500390565b60005b83811015611e30578181015183820152602001611e18565b83811115610f8d5750506000910152565b6000600019821415611e5557611e55611e5c565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114611e8757600080fd5b50565b8015158114611e8757600080fdfea2646970667358221220176b35b7e098e21adeeb0836a2056b80125acddf51a74296ed548c4785653bd164736f6c63430008040033000000000000000000000000933e3922e04d47a466e60a20e486b372b64f1ea8000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000111111125421ca6dc452d289314280a0f8842a650000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a4ef5efb2f42edc4f7f5f3ab5557455db55e2464

Deployed Bytecode

0x6080604052600436106100dd5760003560e01c8063af56ca031161007f578063e4269fc411610059578063e4269fc41461023c578063f8a67a621461024f578063fa74fd431461026f578063ffe805411461028257600080fd5b8063af56ca03146101c9578063b0f584ff14610209578063b25ea8fb1461021c57600080fd5b8063459656ee116100bb578063459656ee146101545780634818e84d146101695780637fc920eb14610189578063a44382fe146101a957600080fd5b80632fcb4f04146100e257806330dedc5714610104578063452a932014610117575b600080fd5b3480156100ee57600080fd5b506101026100fd366004611899565b6102b2565b005b610102610112366004611a0c565b610307565b34801561012357600080fd5b50600054610137906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561016057600080fd5b506101026106c0565b34801561017557600080fd5b50600154610137906001600160a01b031681565b34801561019557600080fd5b506101026101a43660046118bc565b610733565b3480156101b557600080fd5b506101026101c43660046118bc565b610788565b3480156101d557600080fd5b506101f96101e4366004611899565b60036020526000908152604090205460ff1681565b604051901515815260200161014b565b6101026102173660046118f4565b6107dd565b34801561022857600080fd5b50610102610237366004611b2a565b6108de565b61010261024a366004611988565b610999565b34801561025b57600080fd5b5061010261026a366004611947565b610ab7565b61010261027d366004611b4e565b610af5565b34801561028e57600080fd5b506101f961029d366004611899565b60026020526000908152604090205460ff1681565b6000546001600160a01b031633146102e55760405162461bcd60e51b81526004016102dc90611d70565b60405180910390fd5b600180546001600160a01b0319166001600160a01b0392909216919091179055565b6001600160a01b03881660009081526002602052604090205460ff16158061034857506001600160a01b03831660009081526003602052604090205460ff16155b156103665760405163743f26e160e01b815260040160405180910390fd5b846001600160a01b03168b6001600160a01b031614156103d75760405162461bcd60e51b815260206004820152602660248201527f746f6b656e496e20616e6420746f6b656e4f7574206d7573742062652064696660448201526519995c995b9d60d21b60648201526084016102dc565b6103e28b8b8b610ee3565b6103ed8b898c610f93565b6040516370a0823160e01b81523060048201526000906001600160a01b038716906370a082319060240160206040518083038186803b15801561042f57600080fd5b505afa158015610443573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104679190611b12565b90506000808a6001600160a01b031660008b8b604051610488929190611c56565b60006040518083038185875af1925050503d80600081146104c5576040519150601f19603f3d011682016040523d82523d6000602084013e6104ca565b606091505b50915091508181906104ef5760405162461bcd60e51b81526004016102dc9190611d3d565b506040516370a0823160e01b815230600482015283906001600160a01b038a16906370a082319060240160206040518083038186803b15801561053157600080fd5b505afa158015610545573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105699190611b12565b6105739190611dfe565b9250868310156105c55760405162461bcd60e51b815260206004820152601960248201527f696e73756666696369656e74206d6964646c6520746f6b656e0000000000000060448201526064016102dc565b6105d0888785610f93565b60006105dd868686611053565b9050866001600160a01b031634826040516105f89190611c66565b60006040518083038185875af1925050503d8060008114610635576040519150601f19603f3d011682016040523d82523d6000602084013e61063a565b606091505b509093509150818361065f5760405162461bcd60e51b81526004016102dc9190611d3d565b5061066a8f8f6112b1565b7f23278f58875126c795a4072b98b5851fe9b21cea19895b02a6224fefbb1e32988f8f8e8c888c8c8c6040516106a7989796959493929190611cb0565b60405180910390a1505050505050505050505050505050565b6001546001600160a01b0316331461070f5760405162461bcd60e51b815260206004820152601260248201527137b7363c903732bc3a1033bab0b93234b0b760711b60448201526064016102dc565b600154600080546001600160a01b0319166001600160a01b03909216919091179055565b6000546001600160a01b0316331461075d5760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03919091166000908152600260205260409020805460ff1916911515919091179055565b6000546001600160a01b031633146107b25760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03919091166000908152600360205260409020805460ff1916911515919091179055565b6001600160a01b03831660009081526003602052604090205460ff166108165760405163743f26e160e01b815260040160405180910390fd5b600080846001600160a01b0316348585604051610834929190611c56565b60006040518083038185875af1925050503d8060008114610871576040519150601f19603f3d011682016040523d82523d6000602084013e610876565b606091505b509150915081819061089b5760405162461bcd60e51b81526004016102dc9190611d3d565b507fb8543d214cab9591941648db8d40126a163bfd0db4a865678320b921e13980438585856040516108cf93929190611c82565b60405180910390a15050505050565b6000546001600160a01b031633146109085760405162461bcd60e51b81526004016102dc90611d70565b6001600160a01b03811661095e5760405162461bcd60e51b815260206004820152601c60248201527f7472616e7366657220746f20746865207a65726f20616464726573730000000060448201526064016102dc565b6040516001600160a01b0382169083156108fc029084906000818181858888f19350505050158015610994573d6000803e3d6000fd5b505050565b6001600160a01b03831660009081526003602052604090205460ff166109d25760405163743f26e160e01b815260040160405180910390fd5b6109dd868686610ee3565b6109e8868487610f93565b600080846001600160a01b0316348585604051610a06929190611c56565b60006040518083038185875af1925050503d8060008114610a43576040519150601f19603f3d011682016040523d82523d6000602084013e610a48565b606091505b5091509150818190610a6d5760405162461bcd60e51b81526004016102dc9190611d3d565b507fbf150db6b4a14b084f7346b4bc300f552ce867afe55be27bce2d6b37e3307cda8888878787604051610aa5959493929190611d09565b60405180910390a15050505050505050565b6000546001600160a01b03163314610ae15760405162461bcd60e51b81526004016102dc90611d70565b6109946001600160a01b0384168284611352565b6001600160a01b03881660009081526002602052604090205460ff161580610b3657506001600160a01b03831660009081526003602052604090205460ff16155b15610b545760405163743f26e160e01b815260040160405180910390fd5b6001600160a01b038516610bb55760405162461bcd60e51b815260206004820152602260248201527f6d6964646c65546f6b656e2063616e6e6f74206265207a65726f206164647265604482015261737360f01b60648201526084016102dc565b88341015610bfd5760405162461bcd60e51b815260206004820152601560248201527434b739bab33334b1b4b2b73a1030b6b7bab73a24b760591b60448201526064016102dc565b6040516370a0823160e01b81523060048201526000906001600160a01b038716906370a082319060240160206040518083038186803b158015610c3f57600080fd5b505afa158015610c53573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c779190611b12565b90506000808a6001600160a01b03168c8b8b604051610c97929190611c56565b60006040518083038185875af1925050503d8060008114610cd4576040519150601f19603f3d011682016040523d82523d6000602084013e610cd9565b606091505b5091509150818190610cfe5760405162461bcd60e51b81526004016102dc9190611d3d565b506040516370a0823160e01b815230600482015283906001600160a01b038a16906370a082319060240160206040518083038186803b158015610d4057600080fd5b505afa158015610d54573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d789190611b12565b610d829190611dfe565b925086831015610ded5760405162461bcd60e51b815260206004820152603060248201527f4d6179616e466f727761726465723a20696e73756666696369656e74206d696460448201526f191b19481d1bdad95b88185b5bdd5b9d60821b60648201526084016102dc565b610df8888785610f93565b6000610e05868686611053565b90506001600160a01b038716610e1b8e34611dfe565b82604051610e299190611c66565b60006040518083038185875af1925050503d8060008114610e66576040519150601f19603f3d011682016040523d82523d6000602084013e610e6b565b606091505b5090935091508183610e905760405162461bcd60e51b81526004016102dc9190611d3d565b507f7cbff921ae1f3ea71284120d2aabde13587df067f2bb5c831ea6e35d7a9242ac8d8d8b878b8b8b604051610ecc9796959493929190611d97565b60405180910390a150505050505050505050505050565b604051636eb1769f60e11b81523360048201523060248201526000906001600160a01b0385169063dd62ed3e9060440160206040518083038186803b158015610f2b57600080fd5b505afa158015610f3f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f639190611b12565b905082811015610f7857610f788433846113b5565b610f8d6001600160a01b03851633308661146d565b50505050565b604051636eb1769f60e11b81523060048201526001600160a01b038381166024830152849160009183169063dd62ed3e9060440160206040518083038186803b158015610fdf57600080fd5b505afa158015610ff3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110179190611b12565b90508281101561104c576110366001600160a01b0383168560006114a5565b61104c6001600160a01b038316856000196114a5565b5050505050565b6060604483101561109d5760405162461bcd60e51b815260206004820152601460248201527313585e585b8819185d18481d1bdbc81cda1bdc9d60621b60448201526064016102dc565b60008367ffffffffffffffff8111156110c657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156110f0576020820181803683370190505b50905060005b60248110156111725785858281811061111f57634e487b7160e01b600052603260045260246000fd5b9050013560f81c60f81b82828151811061114957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061116a81611e41565b9150506110f6565b5060008360405160200161118891815260200190565b604051602081830303815290604052905060005b6020811015611227578181815181106111c557634e487b7160e01b600052603260045260246000fd5b01602001516001600160f81b031916836111e0836024611de6565b815181106111fe57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061121f81611e41565b91505061119c565b5060445b858110156112a65786868281811061125357634e487b7160e01b600052603260045260246000fd5b9050013560f81c60f81b83828151811061127d57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053508061129e81611e41565b91505061122b565b509095945050505050565b6040516370a0823160e01b81523060048201526000906001600160a01b038416906370a082319060240160206040518083038186803b1580156112f357600080fd5b505afa158015611307573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061132b9190611b12565b905060008111801561133d5750818111155b15610994576109946001600160a01b03841633835b6040516001600160a01b03831660248201526044810182905261099490849063a9059cbb60e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526115c9565b6001600160a01b03831663d505accf8330843560208601356113dd6060880160408901611c0c565b6040516001600160e01b031960e088901b1681526001600160a01b0395861660048201529490931660248501526044840191909152606483015260ff166084820152606084013560a4820152608084013560c482015260e401600060405180830381600087803b15801561145057600080fd5b505af1158015611464573d6000803e3d6000fd5b50505050505050565b6040516001600160a01b0380851660248301528316604482015260648101829052610f8d9085906323b872dd60e01b9060840161137e565b80158061152e5750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e9060440160206040518083038186803b1580156114f457600080fd5b505afa158015611508573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152c9190611b12565b155b6115995760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b60648201526084016102dc565b6040516001600160a01b03831660248201526044810182905261099490849063095ea7b360e01b9060640161137e565b600061161e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b031661169e9092919063ffffffff16565b905080516000148061163f57508080602001905181019061163f9190611af6565b6109945760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b60648201526084016102dc565b60606116ad84846000856116b5565b949350505050565b6060824710156117165760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b60648201526084016102dc565b600080866001600160a01b031685876040516117329190611c66565b60006040518083038185875af1925050503d806000811461176f576040519150601f19603f3d011682016040523d82523d6000602084013e611774565b606091505b509150915061178587838387611790565b979650505050505050565b606083156117fc5782516117f5576001600160a01b0385163b6117f55760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e747261637400000060448201526064016102dc565b50816116ad565b6116ad83838151156118115781518083602001fd5b8060405162461bcd60e51b81526004016102dc9190611d3d565b803561183681611e72565b919050565b60008083601f84011261184c578182fd5b50813567ffffffffffffffff811115611863578182fd5b60208301915083602082850101111561187b57600080fd5b9250929050565b600060a08284031215611893578081fd5b50919050565b6000602082840312156118aa578081fd5b81356118b581611e72565b9392505050565b600080604083850312156118ce578081fd5b82356118d981611e72565b915060208301356118e981611e8a565b809150509250929050565b600080600060408486031215611908578081fd5b833561191381611e72565b9250602084013567ffffffffffffffff81111561192e578182fd5b61193a8682870161183b565b9497909650939450505050565b60008060006060848603121561195b578283fd5b833561196681611e72565b925060208401359150604084013561197d81611e72565b809150509250925092565b60008060008060008061012087890312156119a1578182fd5b86356119ac81611e72565b9550602087013594506119c28860408901611882565b935060e08701356119d281611e72565b925061010087013567ffffffffffffffff8111156119ee578283fd5b6119fa89828a0161183b565b979a9699509497509295939492505050565b60008060008060008060008060008060006101a08c8e031215611a2d578485fd5b611a378c35611e72565b8b359a5060208c01359950611a4f8d60408e01611882565b9850611a5e60e08d0135611e72565b60e08c0135975067ffffffffffffffff806101008e01351115611a7f578586fd5b611a908e6101008f01358f0161183b565b9098509650611aa26101208e0161182b565b95506101408d01359450611ab96101608e0161182b565b9350806101808e01351115611acc578283fd5b50611ade8d6101808e01358e0161183b565b81935080925050509295989b509295989b9093969950565b600060208284031215611b07578081fd5b81516118b581611e8a565b600060208284031215611b23578081fd5b5051919050565b60008060408385031215611b3c578182fd5b8235915060208301356118e981611e72565b600080600080600080600080600060e08a8c031215611b6b578485fd5b8935985060208a0135611b7d81611e72565b975060408a013567ffffffffffffffff80821115611b99578687fd5b611ba58d838e0161183b565b909950975060608c01359150611bba82611e72565b90955060808b0135945060a08b013590611bd382611e72565b90935060c08b01359080821115611be8578384fd5b50611bf58c828d0161183b565b915080935050809150509295985092959850929598565b600060208284031215611c1d578081fd5b813560ff811681146118b5578182fd5b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b8183823760009101908152919050565b60008251611c78818460208701611e15565b9190910192915050565b6001600160a01b0384168152604060208201819052600090611ca79083018486611c2d565b95945050505050565b6001600160a01b038981168252602082018990528781166040830152868116606083015260808201869052841660a082015260e060c08201819052600090611cfb9083018486611c2d565b9a9950505050505050505050565b6001600160a01b03868116825260208201869052841660408201526080606082018190526000906117859083018486611c2d565b6020815260008251806020840152611d5c816040850160208701611e15565b601f01601f19169190910160400192915050565b6020808252600d908201526c37b7363c9033bab0b93234b0b760991b604082015260600190565b8781526001600160a01b0387811660208301528681166040830152606082018690528416608082015260c060a08201819052600090611dd99083018486611c2d565b9998505050505050505050565b60008219821115611df957611df9611e5c565b500190565b600082821015611e1057611e10611e5c565b500390565b60005b83811015611e30578181015183820152602001611e18565b83811115610f8d5750506000910152565b6000600019821415611e5557611e55611e5c565b5060010190565b634e487b7160e01b600052601160045260246000fd5b6001600160a01b0381168114611e8757600080fd5b50565b8015158114611e8757600080fdfea2646970667358221220176b35b7e098e21adeeb0836a2056b80125acddf51a74296ed548c4785653bd164736f6c63430008040033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

000000000000000000000000933e3922e04d47a466e60a20e486b372b64f1ea8000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000001000000000000000000000000111111125421ca6dc452d289314280a0f8842a650000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a4ef5efb2f42edc4f7f5f3ab5557455db55e2464

-----Decoded View---------------
Arg [0] : _guardian (address): 0x933E3922E04d47a466e60A20e486b372B64F1Ea8
Arg [1] : _swapProtocols (address[]): 0x111111125421cA6dc452d289314280a0f8842A65
Arg [2] : _mayanProtocols (address[]): 0xa4EF5EFB2F42edC4f7F5F3Ab5557455DB55E2464

-----Encoded View---------------
7 Constructor Arguments found :
Arg [0] : 000000000000000000000000933e3922e04d47a466e60a20e486b372b64f1ea8
Arg [1] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [2] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [4] : 000000000000000000000000111111125421ca6dc452d289314280a0f8842a65
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [6] : 000000000000000000000000a4ef5efb2f42edc4f7f5f3ab5557455db55e2464


Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.