ETH Price: $1,978.64 (+1.59%)

Contract

0xEC75cf9a18eF82Fa7F8F2A7afAf2521cD998D757

Overview

ETH Balance

0.8111602878705028 ETH

ETH Value

$1,604.99 (@ $1,978.64/ETH)

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Block
From
To
Execute With Pri...4312103442026-02-12 5:21:051 hr ago1770873665IN
Tigris : Forwarder
0 ETH0.000010170.020138
Execute With Pri...4312101122026-02-12 5:20:071 hr ago1770873607IN
Tigris : Forwarder
0 ETH0.000020660.020098
Execute With Pri...4218489252026-01-16 4:45:3827 days ago1768538738IN
Tigris : Forwarder
0 ETH0.000002340.020022
Execute With Pri...4218488842026-01-16 4:45:3027 days ago1768538730IN
Tigris : Forwarder
0 ETH0.000010110.020116
Execute With Pri...4218476582026-01-16 4:40:2327 days ago1768538423IN
Tigris : Forwarder
0 ETH0.000020690.02053
Execute With Pri...4218475542026-01-16 4:39:5627 days ago1768538396IN
Tigris : Forwarder
0 ETH0.000010110.020038
Execute With Pri...4218466902026-01-16 4:36:2127 days ago1768538181IN
Tigris : Forwarder
0 ETH0.000020590.020042
Execute With Pri...4218344452026-01-16 3:45:1627 days ago1768535116IN
Tigris : Forwarder
0 ETH0.00001010.02
Execute With Pri...4218341072026-01-16 3:43:5127 days ago1768535031IN
Tigris : Forwarder
0 ETH0.000020590.020034
Execute With Pri...4218336132026-01-16 3:41:4727 days ago1768534907IN
Tigris : Forwarder
0 ETH0.000004220.020002
Execute With Pri...4218335492026-01-16 3:41:3127 days ago1768534891IN
Tigris : Forwarder
0 ETH0.000004270.020326
Execute With Pri...4218329812026-01-16 3:39:0927 days ago1768534749IN
Tigris : Forwarder
0 ETH0.000004210.020016
Execute With Pri...4218328412026-01-16 3:38:3427 days ago1768534714IN
Tigris : Forwarder
0 ETH0.000004220.020042
Execute With Pri...4218302692026-01-16 3:27:5227 days ago1768534072IN
Tigris : Forwarder
0 ETH0.000004220.020062
Execute With Pri...4212016242026-01-14 7:49:4028 days ago1768376980IN
Tigris : Forwarder
0 ETH0.00001010.020012
Execute With Pri...4212015322026-01-14 7:49:1728 days ago1768376957IN
Tigris : Forwarder
0 ETH0.000021880.020012
Execute Without ...4211826882026-01-14 6:30:4328 days ago1768372243IN
Tigris : Forwarder
0 ETH0.000005430.020064
Execute With Pri...4211759722026-01-14 6:02:4529 days ago1768370565IN
Tigris : Forwarder
0 ETH0.000019230.020032
Execute Without ...4211757212026-01-14 6:01:4429 days ago1768370504IN
Tigris : Forwarder
0 ETH0.000005130.020002
Execute Without ...4211756192026-01-14 6:01:1929 days ago1768370479IN
Tigris : Forwarder
0 ETH0.000013590.020164
Execute Without ...4211754922026-01-14 6:00:4729 days ago1768370447IN
Tigris : Forwarder
0 ETH0.000014830.021022
Execute Without ...4211705462026-01-14 5:40:0729 days ago1768369207IN
Tigris : Forwarder
0 ETH0.000014160.020074
Execute With Pri...4211703452026-01-14 5:39:1629 days ago1768369156IN
Tigris : Forwarder
0 ETH0.000004210.020036
Execute With Pri...4211702372026-01-14 5:38:4929 days ago1768369129IN
Tigris : Forwarder
0 ETH0.000021070.02051
Execute With Pri...4211658122026-01-14 5:20:2129 days ago1768368021IN
Tigris : Forwarder
0 ETH0.000010050.02
View all transactions

Latest 25 internal transactions (View All)

Parent Transaction Hash Block From To
4312103442026-02-12 5:21:051 hr ago1770873665
Tigris : Forwarder
0.00002983 ETH
4312101122026-02-12 5:20:071 hr ago1770873607
Tigris : Forwarder
0.00004183 ETH
4312095992026-02-12 5:17:591 hr ago1770873479
Tigris : Forwarder
0.0020801 ETH
4312095882026-02-12 5:17:561 hr ago1770873476
Tigris : Forwarder
0.0020801 ETH
4218489252026-01-16 4:45:3827 days ago1768538738
Tigris : Forwarder
0.00001421 ETH
4218488842026-01-16 4:45:3027 days ago1768538730
Tigris : Forwarder
0.00002972 ETH
4218476582026-01-16 4:40:2327 days ago1768538423
Tigris : Forwarder
0.00004212 ETH
4218475542026-01-16 4:39:5627 days ago1768538396
Tigris : Forwarder
0.00002968 ETH
4218466902026-01-16 4:36:2127 days ago1768538181
Tigris : Forwarder
0.00004172 ETH
4218344452026-01-16 3:45:1627 days ago1768535116
Tigris : Forwarder
0.00002963 ETH
4218341072026-01-16 3:43:5127 days ago1768535031
Tigris : Forwarder
0.00004172 ETH
4218336132026-01-16 3:41:4727 days ago1768534907
Tigris : Forwarder
0.00001696 ETH
4218335492026-01-16 3:41:3127 days ago1768534891
Tigris : Forwarder
0.00001722 ETH
4218329812026-01-16 3:39:0927 days ago1768534749
Tigris : Forwarder
0.00001695 ETH
4218328412026-01-16 3:38:3427 days ago1768534714
Tigris : Forwarder
0.00001699 ETH
4218302692026-01-16 3:27:5227 days ago1768534072
Tigris : Forwarder
0.00001699 ETH
4218301802026-01-16 3:27:2927 days ago1768534049
Tigris : Forwarder
0.00208041 ETH
4212016242026-01-14 7:49:4028 days ago1768376980
Tigris : Forwarder
0.00002965 ETH
4212015322026-01-14 7:49:1728 days ago1768376957
Tigris : Forwarder
0.00004362 ETH
4211826882026-01-14 6:30:4328 days ago1768372243
Tigris : Forwarder
0.000021 ETH
4211759722026-01-14 6:02:4529 days ago1768370565
Tigris : Forwarder
0.00003966 ETH
4211757212026-01-14 6:01:4429 days ago1768370504
Tigris : Forwarder
0.00002042 ETH
4211756192026-01-14 6:01:1929 days ago1768370479
Tigris : Forwarder
0.00003127 ETH
4211754922026-01-14 6:00:4729 days ago1768370447
Tigris : Forwarder
0.00003359 ETH
4211705462026-01-14 5:40:0729 days ago1768369207
Tigris : Forwarder
0.00003207 ETH
View All Internal Transactions

Cross-Chain Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
PermissionedForwarder

Compiler Version
v0.8.19+commit.7dd6d404

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: MIT

pragma solidity 0.8.19;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "./interfaces/IPermissionedForwarder.sol";

contract PermissionedForwarder is IPermissionedForwarder, EIP712, Ownable {
    using ECDSA for bytes32;

    bytes32 private constant _TYPEHASH =
    keccak256("ForwardRequest(address from,address to,bytes32 salt,uint256 deadline,bytes data)");
    bytes32 private constant PROXY_ERROR_STRING = 0x1350726f7879206e6f7420617070726f7665642e000000000000000000000000;

    mapping(bytes32 => bool) public usedHashes;
    mapping(address => bool) public isPrivateRelayer;
    mapping(address => bool) public isAllowedTarget;
    uint256 public fixedGasCompensation;
    uint256 public gas = 8_000_000;
    bool public doRevert = true;

    mapping(address => uint256) public userGas;

    event RelayFailed(ForwardRequest request, address user, string reason);

    constructor() EIP712("PermissionedForwarder", "1") {}

    function fundAccount(address _account) external payable {
        userGas[_account] += msg.value;
    }

    function fund() external payable {
        userGas[msg.sender] += msg.value;
    }

    function withdraw(uint256 _amount) external {
        require(userGas[msg.sender] >= _amount, "Not enough gas to withdraw");
        userGas[msg.sender] -= _amount;
        payable(msg.sender).transfer(_amount);
    }

    function withdrawAll() external {
        uint256 _amount = userGas[msg.sender];
        userGas[msg.sender] = 0;
        payable(msg.sender).transfer(_amount);
    }

    function spendGas(address _from, address _to, uint256 _amount) private {
        require(userGas[_from] >= _amount, "Not enough gas to spend.");
        unchecked {
            userGas[_from] -= _amount;
        }
        payable(_to).transfer(_amount);
    }

    /**
     * @dev Sets a fixed gas compensation amount
     * @param _gas gas amount
     */
    function setFixedGasCompensation(
        uint256 _gas
    ) external payable onlyOwner {
        require(_gas <= 2e6, "Gas amount too high");
        fixedGasCompensation = _gas;
    }

    function verify(ForwardRequest memory req, bytes calldata signature) private view returns (bool) {
        address signer = _hashTypedDataV4(
            keccak256(abi.encode(_TYPEHASH, req.from, req.to, req.salt, req.deadline, keccak256(req.data)))
        ).recover(signature);
        return signer == req.from;
    }

    function executeWithPrice(
        ForwardRequest calldata req,
        bytes calldata signature,
        PriceData calldata priceData
    ) external returns (bool, bytes memory) {
        uint256 _gasProvided = gasleft();
        require(isPrivateRelayer[msg.sender], "PermissionedForwarder: not a relayer");
        require(block.timestamp <= req.deadline, "PermissionedForwarder: signature expired");
        require(isAllowedTarget[req.to], "PermissionedForwarder: target not allowed");
        require(verify(req, signature), "PermissionedForwarder: signature does not match request");
        bytes32 dataHash = keccak256(abi.encode(req));
        require(!usedHashes[dataHash], "PermissionedForwarder: hash used");
        usedHashes[dataHash] = true;

        bytes memory _data = req.data;
        uint256 _dataLength = _data.length;

        address _user;
        assembly {
            _user := and(
                mload(add(add(_data, 0x20), sub(_dataLength, 32))),
                0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            )
        }
        address _from = req.from;
        (bool success, bytes memory returndata) = req.to.call{value: 0, gas: gas}(
            abi.encodePacked(_data, replaceFirst32Bytes(abi.encode(priceData), bytes32(_dataLength + 32 - _dataLength % 32)), _from)
        );
        if (!success) {
            if (doRevert) {
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            }
            bytes memory reason;
            assembly {
                let returndata_size := mload(returndata)
                reason := add(67, returndata)
                mstore(reason, 32)
            }
            if (bytes32(reason) == PROXY_ERROR_STRING) {
                revert("Proxy not approved.");
            }
            emit RelayFailed(req, _user, string(reason));
        }
        // Calculate gas used and refund. +50% for overhead and incentive
        uint256 _ethUsed = ((_gasProvided + fixedGasCompensation - gasleft()) * tx.gasprice * 3) >> 1;
        spendGas(_user, tx.origin, _ethUsed);
        return (success, returndata);
    }

    function executeWithoutPrice(
        ForwardRequest calldata req,
        bytes calldata signature
    ) external returns (bool, bytes memory) {
        uint256 _gasProvided = gasleft();
        require(isPrivateRelayer[msg.sender], "PermissionedForwarder: not a relayer");
        require(block.timestamp <= req.deadline, "PermissionedForwarder: signature expired");
        require(isAllowedTarget[req.to], "PermissionedForwarder: target not allowed");
        bytes32 dataHash = keccak256(abi.encode(req));
        require(verify(req, signature), "PermissionedForwarder: signature does not match request");
        require(!usedHashes[dataHash], "PermissionedForwarder: hash used");
        usedHashes[dataHash] = true;

        bytes memory _data = req.data;
        uint256 _dataLength = _data.length;

        address _user;
        assembly {
            _user := and(
                mload(add(add(_data, 0x20), sub(_dataLength, 32))),
                0x000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            )
        }
        (bool success, bytes memory returndata) = req.to.call{value: 0, gas: gas}(
            abi.encodePacked(_data, req.from)
        );
        if (!success) {
            if (doRevert) {
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            }
            bytes memory reason;
            assembly {
                let returndata_size := mload(returndata)
                reason := add(67, returndata)
                mstore(reason, 32)
            }
            if (bytes32(reason) == PROXY_ERROR_STRING) {
                revert("Proxy not approved.");
            }
            emit RelayFailed(req, _user, string(reason));
        }
        // Calculate gas used and refund. +50% for overhead and incentive
        uint256 _ethUsed = ((_gasProvided + fixedGasCompensation - gasleft()) * tx.gasprice * 3) >> 1;
        spendGas(_user, tx.origin, _ethUsed);
        return (success, returndata);
    }

    function setPrivateRelayer(address _relayer, bool _status) external onlyOwner {
        isPrivateRelayer[_relayer] = _status;
    }

    function setGas(uint256 _gas) external onlyOwner {
        gas = _gas;
    }

    function setAllowedTarget(address _target, bool _status) external onlyOwner {
        isAllowedTarget[_target] = _status;
    }

    function setDoRevert(bool _status) external onlyOwner {
        doRevert = _status;
    }

    function replaceFirst32Bytes(bytes memory data, bytes32 newValue) private pure returns (bytes memory) {
        require(data.length >= 32, "Input bytes array is too short.");

        assembly {
            let dataPtr := add(data, 32)
            mstore(dataPtr, newValue)
        }

        return data;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../Strings.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSA {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 */
abstract contract EIP712 {
    /* solhint-disable var-name-mixedcase */
    // Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
    // invalidate the cached domain separator if the chain id changes.
    bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
    uint256 private immutable _CACHED_CHAIN_ID;
    address private immutable _CACHED_THIS;

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = Math.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, Math.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../utils/TradingLibrary.sol";

interface IPermissionedForwarder {
    struct ForwardRequest {
        address from;
        address to;
        bytes32 salt;
        uint256 deadline;
        bytes data;
    }

    function fundAccount(address _account) external payable;
    function fund() external payable;
    function withdraw(uint256 _amount) external;
    function withdrawAll() external;
    function executeWithPrice(ForwardRequest calldata req, bytes calldata signature, PriceData calldata priceData) external returns (bool, bytes memory);
    function executeWithoutPrice(ForwardRequest calldata req, bytes calldata signature) external returns (bool, bytes memory);
    function setPrivateRelayer(address _relayer, bool _status) external;
    function setGas(uint256 _gas) external;
    function setAllowedTarget(address _target, bool _status) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IPosition {

    struct Trade {
        uint256 margin;
        uint256 leverage;
        uint256 asset;
        bool direction;
        uint256 price;
        uint256 tpPrice;
        uint256 slPrice;
        uint256 orderType;
        address trader;
        uint256 id;
        address tigAsset;
        int accInterest;
    }

    struct MintTrade {
        address account;
        uint256 margin;
        uint256 leverage;
        uint256 asset;
        bool direction;
        uint256 price;
        uint256 tp;
        uint256 sl;
        uint256 orderType;
        address tigAsset;
    }

    function trades(uint256) external view returns (Trade memory);
    function executeLimitOrder(uint256 _id, uint256 _price, uint256 _newMargin) external;
    function modifyMargin(uint256 _id, uint256 _newMargin, uint256 _newLeverage) external;
    function addToPosition(uint256 _id, uint256 _newMargin, uint256 _newPrice) external;
    function reducePosition(uint256 _id, uint256 _newMargin) external;
    function assetOpenPositions(uint256 _asset) external view returns (uint256[] calldata);
    function assetOpenPositionsIndexes(uint256 _asset, uint256 _id) external view returns (uint256);
    function limitOrders(uint256 _asset) external view returns (uint256[] memory);
    function limitOrderIndexes(uint256 _asset, uint256 _id) external view returns (uint256);
    function assetOpenPositionsLength(uint256 _asset) external view returns (uint256);
    function limitOrdersLength(uint256 _asset) external view returns (uint256);
    function ownerOf(uint256 _id) external view returns (address);
    function mint(MintTrade memory _mintTrade) external;
    function burn(uint256 _id) external;
    function modifyTp(uint256 _id, uint256 _tpPrice) external;
    function modifySl(uint256 _id, uint256 _slPrice) external;
    function getCount() external view returns (uint);
    function updateFunding(uint256 _asset, address _tigAsset, uint256 _longOi, uint256 _shortOi, uint256 _baseFundingRate, uint256 _vaultFundingPercent) external;
    function setAccInterest(uint256 _id) external;
}

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../utils/TradingLibrary.sol";

interface ITrading {

    struct TradeInfo {
        uint256 margin;
        address marginAsset;
        address stableVault;
        uint256 leverage;
        uint256 asset;
        bool direction;
        uint256 tpPrice;
        uint256 slPrice;
        address referrer;
    }
    struct ERC20PermitData {
        uint256 deadline;
        uint256 amount;
        uint8 v;
        bytes32 r;
        bytes32 s;
        bool usePermit;
    }
    struct Fees {
        uint256 daoFees;
        uint256 burnFees;
        uint256 refDiscount;
        uint256 botFees;
    }
    struct Delay {
        uint256 delay; // Block timestamp where delay ends
        bool actionType; // True for open, False for close
    }

    error LimitNotSet();
    error OnlyEOA();
    error NotLiquidatable();
    error TradingPaused();
    error OldPriceData();
    error OrderNotFound();
    error TooEarlyToCancel();
    error BadDeposit();
    error BadWithdraw();
    error BadStopLoss();
    error IsLimit();
    error ValueNotEqualToMargin();
    error BadLeverage();
    error NotMargin();
    error NotAllowedInVault();
    error NotVault();
    error NotOwner();
    error NotAllowedPair();
    error WaitDelay();
    error NotProxy();
    error BelowMinPositionSize();
    error BadClosePercent();
    error NoPrice();
    error LiqThreshold();
    error CloseToMaxPnL();
    error BadSetter();
    error BadConstructor();
    error NotLimit();
    error LimitNotMet();
    error NotEnoughGas();

    function marketOpen(
        TradeInfo calldata _tradeInfo,
        ERC20PermitData calldata _permitData,
        address _trader,
        PriceData calldata _priceData
    ) external;

    function marketClose(
        uint256 _id,
        uint256 _percent,
        address _stableVault,
        address _outputToken,
        address _trader,
        PriceData calldata _priceData
    ) external;

    function addMargin(
        uint256 _id,
        address _stableVault,
        address _marginAsset,
        uint256 _addMargin,
        ERC20PermitData calldata _permitData,
        address _trader,
        PriceData calldata _priceData
    ) external;

    function removeMargin(
        uint256 _id,
        address _stableVault,
        address _outputToken,
        uint256 _removeMargin,
        address _trader,
        PriceData calldata _priceData
    ) external;

     function addToPosition(
         uint256 _id,
         address _stableVault,
         address _marginAsset,
         uint256 _addMargin,
         ERC20PermitData calldata _permitData,
         address _trader,
         PriceData calldata _priceData
     ) external;

    function createLimitOrder(
        TradeInfo calldata _tradeInfo,
        uint256 _orderType, // 1 limit, 2 momentum
        uint256 _price,
        ERC20PermitData calldata _permitData,
        address _trader
    ) external;

    function cancelLimitOrder(
        uint256 _id,
        address _trader
    ) external;

    function updateTpSl(
        bool _type, // true is TP
        uint256 _id,
        uint256 _limitPrice,
        address _trader,
        PriceData calldata _priceData
    ) external;

    function executeLimitOrder(
        uint256 _id, 
        PriceData calldata _priceData
    ) external;

    function liquidatePosition(
        uint256 _id,
        PriceData calldata _priceData
    ) external;

    function limitClose(
        uint256 _id,
        bool _tp,
        PriceData calldata _priceData
    ) external;

    function proxyApprovals(address _account) external view returns(address);
}

//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../interfaces/IPosition.sol";
import "../interfaces/ITrading.sol";

struct PriceData {
    address provider;
    bool isClosed;
    uint256 asset;
    uint256 price;
    uint256 spread;
    uint256 timestamp;
    bytes signature;
}

library TradingLibrary {

    using ECDSA for bytes32;

    uint256 constant DIVISION_CONSTANT = 1e10;

    /**
    * @notice returns position profit or loss
    * @param _direction true if long
    * @param _currentPrice current price
    * @param _price opening price
    * @param _leverage position leverage
    * @param _margin collateral amount
    * @param accInterest funding fees
    * @return _positionSize position size
    * @return _payout payout trader should get
    */
    function pnl(bool _direction, uint256 _currentPrice, uint256 _price, uint256 _margin, uint256 _leverage, int256 accInterest) external pure returns (uint256 _positionSize, int256 _payout) {
        uint256 _initPositionSize = _margin * _leverage / 1e18;
        if (_direction && _currentPrice >= _price) {
            _payout = int256(_margin) + int256(_initPositionSize * (1e18 * _currentPrice / _price - 1e18)/1e18) + accInterest;
        } else if (_direction && _currentPrice < _price) {
            _payout = int256(_margin) - int256(_initPositionSize * (1e18 - 1e18 * _currentPrice / _price)/1e18) + accInterest;
        } else if (!_direction && _currentPrice <= _price) {
            _payout = int256(_margin) + int256(_initPositionSize * (1e18 - 1e18 * _currentPrice / _price)/1e18) + accInterest;
        } else {
            _payout = int256(_margin) - int256(_initPositionSize * (1e18 * _currentPrice / _price - 1e18)/1e18) + accInterest;
        }
        _positionSize = _direction ? _initPositionSize * _currentPrice / _price : _initPositionSize * _price / _currentPrice;
    }

    /**
    * @notice returns position liquidation price
    * @param _direction true if long
    * @param _tradePrice opening price
    * @param _leverage position leverage
    * @param _margin collateral amount
    * @param _accInterest funding fees
    * @param _liqPercent liquidation percent
    * @return _liqPrice liquidation price
    */
    function liqPrice(bool _direction, uint256 _tradePrice, uint256 _leverage, uint256 _margin, int256 _accInterest, uint256 _liqPercent) public pure returns (uint256 _liqPrice) {
        if (_direction) {
            _liqPrice = uint256(int256(_tradePrice) - int256(_tradePrice) * (int256(_margin) * int256(_liqPercent) / int256(DIVISION_CONSTANT) + _accInterest) * 1e18 / int256(_margin) / int256(_leverage));
        } else {
            _liqPrice = uint256(int256(_tradePrice) + int256(_tradePrice) * (int256(_margin) * int256(_liqPercent) / int256(DIVISION_CONSTANT) + _accInterest) * 1e18 / int256(_margin) / int256(_leverage));
        }
    }

    /**
    * @notice uses liqPrice() and returns position liquidation price
    * @param _positions positions contract address
    * @param _id position id
    * @param _liqPercent liquidation percent
    */
    function getLiqPrice(address _positions, uint256 _id, uint256 _liqPercent) external view returns (uint256) {
        IPosition.Trade memory _trade = IPosition(_positions).trades(_id);
        return liqPrice(_trade.direction, _trade.price, _trade.leverage, _trade.margin, _trade.accInterest, _liqPercent);
    }

    /**
    * @notice verifies that price is signed by a whitelisted node
    * @param _validSignatureTimer seconds allowed before price is old
    * @param _asset position asset
    * @param _priceData PriceData object
    * @param _isNode mapping of allowed nodes
    */
    function verifyPrice(
        uint256 _validSignatureTimer,
        uint256 _asset,
        PriceData calldata _priceData,
        mapping(address => bool) storage _isNode
    )
        external view
    {
        require(block.timestamp <= _priceData.timestamp + _validSignatureTimer, "Price has expired.");
        require(block.timestamp >= _priceData.timestamp, "FutSig");
        require(!_priceData.isClosed, "Market is closed.");
        require(_asset == _priceData.asset, "!Asset");
        require(_priceData.price != 0, "NoPrice");
        address _provider = (
            keccak256(abi.encode(
                _priceData.provider,
                _priceData.isClosed,
                _priceData.asset,
                _priceData.price,
                _priceData.spread,
                _priceData.timestamp
            ))
        ).toEthSignedMessageHash().recover(_priceData.signature);
        require(_provider == _priceData.provider, "BadSig");
        require(_isNode[_provider], "!Node");
    }
}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"indexed":false,"internalType":"struct IPermissionedForwarder.ForwardRequest","name":"request","type":"tuple"},{"indexed":false,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"RelayFailed","type":"event"},{"inputs":[],"name":"doRevert","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IPermissionedForwarder.ForwardRequest","name":"req","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"},{"components":[{"internalType":"address","name":"provider","type":"address"},{"internalType":"bool","name":"isClosed","type":"bool"},{"internalType":"uint256","name":"asset","type":"uint256"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"spread","type":"uint256"},{"internalType":"uint256","name":"timestamp","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct PriceData","name":"priceData","type":"tuple"}],"name":"executeWithPrice","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes32","name":"salt","type":"bytes32"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"internalType":"struct IPermissionedForwarder.ForwardRequest","name":"req","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"executeWithoutPrice","outputs":[{"internalType":"bool","name":"","type":"bool"},{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fixedGasCompensation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"fund","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"fundAccount","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"gas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isAllowedTarget","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"isPrivateRelayer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_target","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"setAllowedTarget","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_status","type":"bool"}],"name":"setDoRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gas","type":"uint256"}],"name":"setFixedGasCompensation","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_gas","type":"uint256"}],"name":"setGas","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_relayer","type":"address"},{"internalType":"bool","name":"_status","type":"bool"}],"name":"setPrivateRelayer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"usedHashes","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"userGas","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[],"stateMutability":"nonpayable","type":"function"}]

610140604052627a12006005556006805460ff191660011790553480156200002657600080fd5b50604080518082018252601581527f5065726d697373696f6e6564466f7277617264657200000000000000000000006020808301918252835180850190945260018452603160f81b908401528151902060e08190527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc66101008190524660a0529192917f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6200011a8184846040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b6080523060c05261012052506200013d9250620001379150503390565b62000143565b62000193565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60805160a05160c05160e0516101005161012051612548620001e3600039600061190701526000611956015260006119310152600061188a015260006118b4015260006118de01526125486000f3fe60806040526004361061016a5760003560e01c80638da5cb5b116100cb578063c0e890a01161007f578063cfec6cdf11610059578063cfec6cdf146103d2578063dd51faa2146103f2578063f2fde38b1461041257600080fd5b8063c0e890a014610372578063c85454431461039f578063ca1dd22e146103b257600080fd5b8063afc874d2116100b0578063afc874d21461033a578063b60d428814610354578063bb661e511461035c57600080fd5b80638da5cb5b146102d5578063aef18bf71461030a57600080fd5b8063715018a61161012257806378addb481161010757806378addb4814610250578063853828b61461029057806387cef39a146102a557600080fd5b8063715018a61461021b578063781dd7501461023057600080fd5b80635b6f032e116101535780635b6f032e146101b15780636ca7c216146101c45780636d6b71d8146101ed57600080fd5b806305e9a99b1461016f5780632e1a7d4d14610191575b600080fd5b34801561017b57600080fd5b5061018f61018a366004611cc1565b610432565b005b34801561019d57600080fd5b5061018f6101ac366004611cf4565b610490565b61018f6101bf366004611d0d565b610563565b3480156101d057600080fd5b506101da60055481565b6040519081526020015b60405180910390f35b3480156101f957600080fd5b5061020d610208366004611d89565b6105a0565b6040516101e4929190611e60565b34801561022757600080fd5b5061018f610b9b565b34801561023c57600080fd5b5061018f61024b366004611e83565b610baf565b34801561025c57600080fd5b5061028061026b366004611d0d565b60036020526000908152604090205460ff1681565b60405190151581526020016101e4565b34801561029c57600080fd5b5061018f610be8565b3480156102b157600080fd5b506102806102c0366004611d0d565b60026020526000908152604090205460ff1681565b3480156102e157600080fd5b5060005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e4565b34801561031657600080fd5b50610280610325366004611cf4565b60016020526000908152604090205460ff1681565b34801561034657600080fd5b506006546102809060ff1681565b61018f610c29565b34801561036857600080fd5b506101da60045481565b34801561037e57600080fd5b506101da61038d366004611d0d565b60076020526000908152604090205481565b61018f6103ad366004611cf4565b610c4f565b3480156103be57600080fd5b5061018f6103cd366004611cc1565b610cc9565b3480156103de57600080fd5b5061020d6103ed366004611e9e565b610d27565b3480156103fe57600080fd5b5061018f61040d366004611cf4565b6113a7565b34801561041e57600080fd5b5061018f61042d366004611d0d565b6113b4565b61043a61146b565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260026020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b3360009081526007602052604090205481111561050e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4e6f7420656e6f7567682067617320746f20776974686472617700000000000060448201526064015b60405180910390fd5b336000908152600760205260408120805483929061052d908490611f60565b9091555050604051339082156108fc029083906000818181858888f1935050505015801561055f573d6000803e3d6000fd5b5050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604081208054349290610598908490611f73565b909155505050565b6000606060005a3360009081526002602052604090205490915060ff16610648576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5065726d697373696f6e6564466f727761726465723a206e6f7420612072656c60448201527f61796572000000000000000000000000000000000000000000000000000000006064820152608401610505565b85606001354211156106dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20657870697265640000000000000000000000000000000000000000000000006064820152608401610505565b600360006106f06040890160208a01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000205460ff166107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5065726d697373696f6e6564466f727761726465723a20746172676574206e6f60448201527f7420616c6c6f77656400000000000000000000000000000000000000000000006064820152608401610505565b6000866040516020016107b991906120aa565b6040516020818303038152906040528051906020012090506107e5876107de90612164565b87876114ec565b610871576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20646f6573206e6f74206d6174636820726571756573740000000000000000006064820152608401610505565b60008181526001602052604090205460ff16156108ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5065726d697373696f6e6564466f727761726465723a206861736820757365646044820152606401610505565b6000818152600160208190526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690911790556109306080890189612254565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508451808601519596509473ffffffffffffffffffffffffffffffffffffffff169350915081905061099760408d0160208e01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16600060055490878f60000160208101906109c79190611d0d565b6040516020016109d89291906122b9565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610a1091612303565b600060405180830381858888f193505050503d8060008114610a4e576040519150601f19603f3d011682016040523d82523d6000602084013e610a53565b606091505b509150915081610b485760065460ff1615610a715780518082602001fd5b6020604382019081527f1350726f7879206e6f7420617070726f7665642e000000000000000000000000610aa48261231f565b03610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f50726f7879206e6f7420617070726f7665642e000000000000000000000000006044820152606401610505565b7f13051a59ffda80179c7de2b1ad1efa3e951d1cf2266cc70933b884ae229814428d8583604051610b3e93929190612361565b60405180910390a1505b600060013a5a600454610b5b908c611f73565b610b659190611f60565b610b6f91906123ac565b610b7a9060036123ac565b901c9050610b89843283611601565b50909b909a5098505050505050505050565b610ba361146b565b610bad60006116f0565b565b610bb761146b565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b33600081815260076020526040808220805490839055905190929183156108fc02918491818181858888f1935050505015801561055f573d6000803e3d6000fd5b3360009081526007602052604081208054349290610c48908490611f73565b9091555050565b610c5761146b565b621e8480811115610cc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f47617320616d6f756e7420746f6f2068696768000000000000000000000000006044820152606401610505565b600455565b610cd161146b565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6000606060005a3360009081526002602052604090205490915060ff16610dcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5065726d697373696f6e6564466f727761726465723a206e6f7420612072656c60448201527f61796572000000000000000000000000000000000000000000000000000000006064820152608401610505565b8660600135421115610e63576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20657870697265640000000000000000000000000000000000000000000000006064820152608401610505565b60036000610e7760408a0160208b01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000205460ff16610f2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5065726d697373696f6e6564466f727761726465723a20746172676574206e6f60448201527f7420616c6c6f77656400000000000000000000000000000000000000000000006064820152608401610505565b610f396107de88612164565b610fc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20646f6573206e6f74206d6174636820726571756573740000000000000000006064820152608401610505565b600087604051602001610fd891906120aa565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152600190935291205490915060ff1615611088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5065726d697373696f6e6564466f727761726465723a206861736820757365646044820152606401610505565b6000818152600160208190526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690911790556110ce60808a018a612254565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508451808601519596509473ffffffffffffffffffffffffffffffffffffffff1693509150611131905060208d018d611d0d565b90506000808d60200160208101906111499190611d0d565b73ffffffffffffffffffffffffffffffffffffffff16600060055490886111cd8f60405160200161117a91906123c3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526111b360208c61244a565b6111be8c6020611f73565b6111c89190611f60565b611765565b876040516020016111e093929190612485565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261121891612303565b600060405180830381858888f193505050503d8060008114611256576040519150601f19603f3d011682016040523d82523d6000602084013e61125b565b606091505b5091509150816113505760065460ff16156112795780518082602001fd5b6020604382019081527f1350726f7879206e6f7420617070726f7665642e0000000000000000000000006112ac8261231f565b03611313576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f50726f7879206e6f7420617070726f7665642e000000000000000000000000006044820152606401610505565b7f13051a59ffda80179c7de2b1ad1efa3e951d1cf2266cc70933b884ae229814428f868360405161134693929190612361565b60405180910390a1505b600060013a5a600454611363908d611f73565b61136d9190611f60565b61137791906123ac565b6113829060036123ac565b901c9050611391853283611601565b5090985096505050505050505b94509492505050565b6113af61146b565b600555565b6113bc61146b565b73ffffffffffffffffffffffffffffffffffffffff811661145f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610505565b611468816116f0565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610bad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b6000806115da84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505088516020808b01516040808d015160608e015160808f015180519086012092516115d498506115b997507fff5827cae21ecb488d94c136e049e4a586d093cc18af6aa0a67069269ade47ca9695929391920195865273ffffffffffffffffffffffffffffffffffffffff94851660208701529290931660408501526060840152608083019190915260a082015260c00190565b604051602081830303815290604052805190602001206117e3565b9061184c565b855173ffffffffffffffffffffffffffffffffffffffff9182169116149150509392505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260076020526040902054811115611690576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f7420656e6f7567682067617320746f207370656e642e00000000000000006044820152606401610505565b73ffffffffffffffffffffffffffffffffffffffff80841660009081526007602052604080822080548590039055519184169183156108fc0291849190818181858888f193505050501580156116ea573d6000803e3d6000fd5b50505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60606020835110156117d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e70757420627974657320617272617920697320746f6f2073686f72742e006044820152606401610505565b5060208201819052815b92915050565b60006117dd6117f0611870565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061185b85856119a4565b91509150611868816119e9565b509392505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000161480156118d657507f000000000000000000000000000000000000000000000000000000000000000046145b1561190057507f000000000000000000000000000000000000000000000000000000000000000090565b50604080517f00000000000000000000000000000000000000000000000000000000000000006020808301919091527f0000000000000000000000000000000000000000000000000000000000000000828401527f000000000000000000000000000000000000000000000000000000000000000060608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b60008082516041036119da5760208301516040840151606085015160001a6119ce87828585611b9c565b945094505050506119e2565b506000905060025b9250929050565b60008160048111156119fd576119fd6124e3565b03611a055750565b6001816004811115611a1957611a196124e3565b03611a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610505565b6002816004811115611a9457611a946124e3565b03611afb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610505565b6003816004811115611b0f57611b0f6124e3565b03611468576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610505565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611bd3575060009050600361139e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611c27573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116611c7b5760006001925092505061139e565b9660009650945050505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611cac57600080fd5b919050565b80358015158114611cac57600080fd5b60008060408385031215611cd457600080fd5b611cdd83611c88565b9150611ceb60208401611cb1565b90509250929050565b600060208284031215611d0657600080fd5b5035919050565b600060208284031215611d1f57600080fd5b611d2882611c88565b9392505050565b600060a08284031215611d4157600080fd5b50919050565b60008083601f840112611d5957600080fd5b50813567ffffffffffffffff811115611d7157600080fd5b6020830191508360208285010111156119e257600080fd5b600080600060408486031215611d9e57600080fd5b833567ffffffffffffffff80821115611db657600080fd5b611dc287838801611d2f565b94506020860135915080821115611dd857600080fd5b50611de586828701611d47565b9497909650939450505050565b60005b83811015611e0d578181015183820152602001611df5565b50506000910152565b60008151808452611e2e816020860160208601611df2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8215158152604060208201526000611e7b6040830184611e16565b949350505050565b600060208284031215611e9557600080fd5b611d2882611cb1565b60008060008060608587031215611eb457600080fd5b843567ffffffffffffffff80821115611ecc57600080fd5b611ed888838901611d2f565b95506020870135915080821115611eee57600080fd5b611efa88838901611d47565b90955093506040870135915080821115611f1357600080fd5b50850160e08188031215611f2657600080fd5b939692955090935050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156117dd576117dd611f31565b808201808211156117dd576117dd611f31565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112611fbb57600080fd5b830160208101925035905067ffffffffffffffff811115611fdb57600080fd5b8036038213156119e257600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600073ffffffffffffffffffffffffffffffffffffffff8061205484611c88565b1684528061206460208501611c88565b16602085015250604082013560408401526060820135606084015261208c6080830183611f86565b60a060808601526120a160a086018284611fea565b95945050505050565b602081526000611d286020830184612033565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561210f5761210f6120bd565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561215c5761215c6120bd565b604052919050565b600060a0823603121561217657600080fd5b61217e6120ec565b61218783611c88565b81526020612196818501611c88565b818301526040840135604083015260608401356060830152608084013567ffffffffffffffff808211156121c957600080fd5b9085019036601f8301126121dc57600080fd5b8135818111156121ee576121ee6120bd565b61221e847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612115565b9150808252368482850101111561223457600080fd5b808484018584013760009082019093019290925250608082015292915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261228957600080fd5b83018035915067ffffffffffffffff8211156122a457600080fd5b6020019150368190038213156119e257600080fd5b600083516122cb818460208801611df2565b60609390931b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169190920190815260140192915050565b60008251612315818460208701611df2565b9190910192915050565b80516020808301519190811015611d41577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910360031b1b16919050565b6060815260006123746060830186612033565b73ffffffffffffffffffffffffffffffffffffffff8516602084015282810360408401526123a28185611e16565b9695505050505050565b80820281158282048414176117dd576117dd611f31565b6020815273ffffffffffffffffffffffffffffffffffffffff6123e583611c88565b1660208201526123f760208301611cb1565b151560408201526040820135606082015260608201356080820152608082013560a082015260a082013560c0820152600061243560c0840184611f86565b60e0808501526120a161010085018284611fea565b600082612480577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b60008451612497818460208901611df2565b8451908301906124ab818360208901611df2565b60609490941b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169301928352505060140192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea26469706673582212209a2a0a7cb3d461ea0b2168691432223e96350a648b909696e570b5dfb14fe8cb64736f6c63430008130033

Deployed Bytecode

0x60806040526004361061016a5760003560e01c80638da5cb5b116100cb578063c0e890a01161007f578063cfec6cdf11610059578063cfec6cdf146103d2578063dd51faa2146103f2578063f2fde38b1461041257600080fd5b8063c0e890a014610372578063c85454431461039f578063ca1dd22e146103b257600080fd5b8063afc874d2116100b0578063afc874d21461033a578063b60d428814610354578063bb661e511461035c57600080fd5b80638da5cb5b146102d5578063aef18bf71461030a57600080fd5b8063715018a61161012257806378addb481161010757806378addb4814610250578063853828b61461029057806387cef39a146102a557600080fd5b8063715018a61461021b578063781dd7501461023057600080fd5b80635b6f032e116101535780635b6f032e146101b15780636ca7c216146101c45780636d6b71d8146101ed57600080fd5b806305e9a99b1461016f5780632e1a7d4d14610191575b600080fd5b34801561017b57600080fd5b5061018f61018a366004611cc1565b610432565b005b34801561019d57600080fd5b5061018f6101ac366004611cf4565b610490565b61018f6101bf366004611d0d565b610563565b3480156101d057600080fd5b506101da60055481565b6040519081526020015b60405180910390f35b3480156101f957600080fd5b5061020d610208366004611d89565b6105a0565b6040516101e4929190611e60565b34801561022757600080fd5b5061018f610b9b565b34801561023c57600080fd5b5061018f61024b366004611e83565b610baf565b34801561025c57600080fd5b5061028061026b366004611d0d565b60036020526000908152604090205460ff1681565b60405190151581526020016101e4565b34801561029c57600080fd5b5061018f610be8565b3480156102b157600080fd5b506102806102c0366004611d0d565b60026020526000908152604090205460ff1681565b3480156102e157600080fd5b5060005460405173ffffffffffffffffffffffffffffffffffffffff90911681526020016101e4565b34801561031657600080fd5b50610280610325366004611cf4565b60016020526000908152604090205460ff1681565b34801561034657600080fd5b506006546102809060ff1681565b61018f610c29565b34801561036857600080fd5b506101da60045481565b34801561037e57600080fd5b506101da61038d366004611d0d565b60076020526000908152604090205481565b61018f6103ad366004611cf4565b610c4f565b3480156103be57600080fd5b5061018f6103cd366004611cc1565b610cc9565b3480156103de57600080fd5b5061020d6103ed366004611e9e565b610d27565b3480156103fe57600080fd5b5061018f61040d366004611cf4565b6113a7565b34801561041e57600080fd5b5061018f61042d366004611d0d565b6113b4565b61043a61146b565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260026020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b3360009081526007602052604090205481111561050e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601a60248201527f4e6f7420656e6f7567682067617320746f20776974686472617700000000000060448201526064015b60405180910390fd5b336000908152600760205260408120805483929061052d908490611f60565b9091555050604051339082156108fc029083906000818181858888f1935050505015801561055f573d6000803e3d6000fd5b5050565b73ffffffffffffffffffffffffffffffffffffffff811660009081526007602052604081208054349290610598908490611f73565b909155505050565b6000606060005a3360009081526002602052604090205490915060ff16610648576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5065726d697373696f6e6564466f727761726465723a206e6f7420612072656c60448201527f61796572000000000000000000000000000000000000000000000000000000006064820152608401610505565b85606001354211156106dc576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20657870697265640000000000000000000000000000000000000000000000006064820152608401610505565b600360006106f06040890160208a01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000205460ff166107a6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5065726d697373696f6e6564466f727761726465723a20746172676574206e6f60448201527f7420616c6c6f77656400000000000000000000000000000000000000000000006064820152608401610505565b6000866040516020016107b991906120aa565b6040516020818303038152906040528051906020012090506107e5876107de90612164565b87876114ec565b610871576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20646f6573206e6f74206d6174636820726571756573740000000000000000006064820152608401610505565b60008181526001602052604090205460ff16156108ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5065726d697373696f6e6564466f727761726465723a206861736820757365646044820152606401610505565b6000818152600160208190526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690911790556109306080890189612254565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508451808601519596509473ffffffffffffffffffffffffffffffffffffffff169350915081905061099760408d0160208e01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16600060055490878f60000160208101906109c79190611d0d565b6040516020016109d89291906122b9565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815290829052610a1091612303565b600060405180830381858888f193505050503d8060008114610a4e576040519150601f19603f3d011682016040523d82523d6000602084013e610a53565b606091505b509150915081610b485760065460ff1615610a715780518082602001fd5b6020604382019081527f1350726f7879206e6f7420617070726f7665642e000000000000000000000000610aa48261231f565b03610b0b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f50726f7879206e6f7420617070726f7665642e000000000000000000000000006044820152606401610505565b7f13051a59ffda80179c7de2b1ad1efa3e951d1cf2266cc70933b884ae229814428d8583604051610b3e93929190612361565b60405180910390a1505b600060013a5a600454610b5b908c611f73565b610b659190611f60565b610b6f91906123ac565b610b7a9060036123ac565b901c9050610b89843283611601565b50909b909a5098505050505050505050565b610ba361146b565b610bad60006116f0565b565b610bb761146b565b600680547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b33600081815260076020526040808220805490839055905190929183156108fc02918491818181858888f1935050505015801561055f573d6000803e3d6000fd5b3360009081526007602052604081208054349290610c48908490611f73565b9091555050565b610c5761146b565b621e8480811115610cc4576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f47617320616d6f756e7420746f6f2068696768000000000000000000000000006044820152606401610505565b600455565b610cd161146b565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260036020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b6000606060005a3360009081526002602052604090205490915060ff16610dcf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152602060048201526024808201527f5065726d697373696f6e6564466f727761726465723a206e6f7420612072656c60448201527f61796572000000000000000000000000000000000000000000000000000000006064820152608401610505565b8660600135421115610e63576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602860248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20657870697265640000000000000000000000000000000000000000000000006064820152608401610505565b60036000610e7760408a0160208b01611d0d565b73ffffffffffffffffffffffffffffffffffffffff16815260208101919091526040016000205460ff16610f2d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602960248201527f5065726d697373696f6e6564466f727761726465723a20746172676574206e6f60448201527f7420616c6c6f77656400000000000000000000000000000000000000000000006064820152608401610505565b610f396107de88612164565b610fc5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152603760248201527f5065726d697373696f6e6564466f727761726465723a207369676e617475726560448201527f20646f6573206e6f74206d6174636820726571756573740000000000000000006064820152608401610505565b600087604051602001610fd891906120aa565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe081840301815291815281516020928301206000818152600190935291205490915060ff1615611088576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f5065726d697373696f6e6564466f727761726465723a206861736820757365646044820152606401610505565b6000818152600160208190526040822080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001690911790556110ce60808a018a612254565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201829052508451808601519596509473ffffffffffffffffffffffffffffffffffffffff1693509150611131905060208d018d611d0d565b90506000808d60200160208101906111499190611d0d565b73ffffffffffffffffffffffffffffffffffffffff16600060055490886111cd8f60405160200161117a91906123c3565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526111b360208c61244a565b6111be8c6020611f73565b6111c89190611f60565b611765565b876040516020016111e093929190612485565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529082905261121891612303565b600060405180830381858888f193505050503d8060008114611256576040519150601f19603f3d011682016040523d82523d6000602084013e61125b565b606091505b5091509150816113505760065460ff16156112795780518082602001fd5b6020604382019081527f1350726f7879206e6f7420617070726f7665642e0000000000000000000000006112ac8261231f565b03611313576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f50726f7879206e6f7420617070726f7665642e000000000000000000000000006044820152606401610505565b7f13051a59ffda80179c7de2b1ad1efa3e951d1cf2266cc70933b884ae229814428f868360405161134693929190612361565b60405180910390a1505b600060013a5a600454611363908d611f73565b61136d9190611f60565b61137791906123ac565b6113829060036123ac565b901c9050611391853283611601565b5090985096505050505050505b94509492505050565b6113af61146b565b600555565b6113bc61146b565b73ffffffffffffffffffffffffffffffffffffffff811661145f576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610505565b611468816116f0565b50565b60005473ffffffffffffffffffffffffffffffffffffffff163314610bad576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610505565b6000806115da84848080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152505088516020808b01516040808d015160608e015160808f015180519086012092516115d498506115b997507fff5827cae21ecb488d94c136e049e4a586d093cc18af6aa0a67069269ade47ca9695929391920195865273ffffffffffffffffffffffffffffffffffffffff94851660208701529290931660408501526060840152608083019190915260a082015260c00190565b604051602081830303815290604052805190602001206117e3565b9061184c565b855173ffffffffffffffffffffffffffffffffffffffff9182169116149150509392505050565b73ffffffffffffffffffffffffffffffffffffffff8316600090815260076020526040902054811115611690576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f4e6f7420656e6f7567682067617320746f207370656e642e00000000000000006044820152606401610505565b73ffffffffffffffffffffffffffffffffffffffff80841660009081526007602052604080822080548590039055519184169183156108fc0291849190818181858888f193505050501580156116ea573d6000803e3d6000fd5b50505050565b6000805473ffffffffffffffffffffffffffffffffffffffff8381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60606020835110156117d3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f496e70757420627974657320617272617920697320746f6f2073686f72742e006044820152606401610505565b5060208201819052815b92915050565b60006117dd6117f0611870565b836040517f19010000000000000000000000000000000000000000000000000000000000006020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b600080600061185b85856119a4565b91509150611868816119e9565b509392505050565b60003073ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000ec75cf9a18ef82fa7f8f2a7afaf2521cd998d757161480156118d657507f000000000000000000000000000000000000000000000000000000000000a4b146145b1561190057507f2866c434774417e8480cde78c26f496d3f4cea73d0f0a34cc34c45adf5dd153190565b50604080517f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6020808301919091527ff8d1bc95ce8b8c21f32640516d08e9fc0e17669749a46bee1fccd715da554508828401527fc89efdaa54c0f20c7adf612882df0950f5a951637e0307cdcb4c672f298b8bc660608301524660808301523060a0808401919091528351808403909101815260c0909201909252805191012090565b60008082516041036119da5760208301516040840151606085015160001a6119ce87828585611b9c565b945094505050506119e2565b506000905060025b9250929050565b60008160048111156119fd576119fd6124e3565b03611a055750565b6001816004811115611a1957611a196124e3565b03611a80576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610505565b6002816004811115611a9457611a946124e3565b03611afb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610505565b6003816004811115611b0f57611b0f6124e3565b03611468576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401610505565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115611bd3575060009050600361139e565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015611c27573d6000803e3d6000fd5b50506040517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0015191505073ffffffffffffffffffffffffffffffffffffffff8116611c7b5760006001925092505061139e565b9660009650945050505050565b803573ffffffffffffffffffffffffffffffffffffffff81168114611cac57600080fd5b919050565b80358015158114611cac57600080fd5b60008060408385031215611cd457600080fd5b611cdd83611c88565b9150611ceb60208401611cb1565b90509250929050565b600060208284031215611d0657600080fd5b5035919050565b600060208284031215611d1f57600080fd5b611d2882611c88565b9392505050565b600060a08284031215611d4157600080fd5b50919050565b60008083601f840112611d5957600080fd5b50813567ffffffffffffffff811115611d7157600080fd5b6020830191508360208285010111156119e257600080fd5b600080600060408486031215611d9e57600080fd5b833567ffffffffffffffff80821115611db657600080fd5b611dc287838801611d2f565b94506020860135915080821115611dd857600080fd5b50611de586828701611d47565b9497909650939450505050565b60005b83811015611e0d578181015183820152602001611df5565b50506000910152565b60008151808452611e2e816020860160208601611df2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b8215158152604060208201526000611e7b6040830184611e16565b949350505050565b600060208284031215611e9557600080fd5b611d2882611cb1565b60008060008060608587031215611eb457600080fd5b843567ffffffffffffffff80821115611ecc57600080fd5b611ed888838901611d2f565b95506020870135915080821115611eee57600080fd5b611efa88838901611d47565b90955093506040870135915080821115611f1357600080fd5b50850160e08188031215611f2657600080fd5b939692955090935050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b818103818111156117dd576117dd611f31565b808201808211156117dd576117dd611f31565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112611fbb57600080fd5b830160208101925035905067ffffffffffffffff811115611fdb57600080fd5b8036038213156119e257600080fd5b8183528181602085013750600060208284010152600060207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116840101905092915050565b600073ffffffffffffffffffffffffffffffffffffffff8061205484611c88565b1684528061206460208501611c88565b16602085015250604082013560408401526060820135606084015261208c6080830183611f86565b60a060808601526120a160a086018284611fea565b95945050505050565b602081526000611d286020830184612033565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b60405160a0810167ffffffffffffffff8111828210171561210f5761210f6120bd565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561215c5761215c6120bd565b604052919050565b600060a0823603121561217657600080fd5b61217e6120ec565b61218783611c88565b81526020612196818501611c88565b818301526040840135604083015260608401356060830152608084013567ffffffffffffffff808211156121c957600080fd5b9085019036601f8301126121dc57600080fd5b8135818111156121ee576121ee6120bd565b61221e847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601612115565b9150808252368482850101111561223457600080fd5b808484018584013760009082019093019290925250608082015292915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe184360301811261228957600080fd5b83018035915067ffffffffffffffff8211156122a457600080fd5b6020019150368190038213156119e257600080fd5b600083516122cb818460208801611df2565b60609390931b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169190920190815260140192915050565b60008251612315818460208701611df2565b9190910192915050565b80516020808301519190811015611d41577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910360031b1b16919050565b6060815260006123746060830186612033565b73ffffffffffffffffffffffffffffffffffffffff8516602084015282810360408401526123a28185611e16565b9695505050505050565b80820281158282048414176117dd576117dd611f31565b6020815273ffffffffffffffffffffffffffffffffffffffff6123e583611c88565b1660208201526123f760208301611cb1565b151560408201526040820135606082015260608201356080820152608082013560a082015260a082013560c0820152600061243560c0840184611f86565b60e0808501526120a161010085018284611fea565b600082612480577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b500690565b60008451612497818460208901611df2565b8451908301906124ab818360208901611df2565b60609490941b7fffffffffffffffffffffffffffffffffffffffff000000000000000000000000169301928352505060140192915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602160045260246000fdfea26469706673582212209a2a0a7cb3d461ea0b2168691432223e96350a648b909696e570b5dfb14fe8cb64736f6c63430008130033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading
[ 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.