S Price: $0.455915 (+1.08%)

Contract

0xC8d6bDE488A3C6AF322fB20C2654e311792e44a8

Overview

S Balance

Sonic LogoSonic LogoSonic Logo0 S

S Value

$0.00

Multichain Info

1 address found via
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Parent Transaction Hash Block From To
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
SmartAccountImplementation

Compiler Version
v0.8.20+commit.a1b79de6

Optimization Enabled:
Yes with 200 runs

Other Settings:
paris EvmVersion
File 1 of 13 : SmartAccountImplementation.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '../interface/IGateway.sol';
import '../manager/IManager.sol';
import '../library/Consts.sol';
import '../library/Errors.sol';
import '../library/ETHAndERC20.sol';
import './SmartAccountStorage.sol';

contract SmartAccountImplementation is SmartAccountStorage {

    using ETHAndERC20 for address;

    address public immutable manager;

    address public immutable tokenB0;

    modifier _onlyExecutorOrOwner_() {
        require(
            IManager(manager).isExecutor(msg.sender) || msg.sender == owner,
            Errors.ONLY_EXECUTOR_OR_OWNER
        );
        _;
    }

    constructor (address manager_, address tokenB0_) {
        manager = manager_;
        tokenB0 = tokenB0_;
    }

    function getGateway(uint256 gatewayIdx) public view returns (address) {
        return IManager(manager).getGateway(gatewayIdx);
    }

    function getOpGas(uint256 opIndex) external view returns (address bToken, uint256 amount) {
        return _getOpGas(opIndex);
    }

    function claimUnusedIChainExecutionFee(uint256 gatewayIdx, uint256 pTokenId) external {
        address gateway = getGateway(gatewayIdx);
        IGateway(gateway).claimUnusedIChainExecutionFee(pTokenId, false);
    }

    function requestAddMargin(
        uint256 gatewayIdx,
        uint256 pTokenId,
        address bToken,
        uint256 bAmount
    ) external payable _onlyExecutorOrOwner_
    {
        address gateway = getGateway(gatewayIdx);
        if (bToken == Consts.TOKEN_ETH) {
            IGateway(gateway).requestAddMargin{value: bAmount}(
                pTokenId,
                bToken,
                bAmount,
                true
            );
        } else {
            _approve(bToken, gateway, bAmount);
            IGateway(gateway).requestAddMargin(
                pTokenId,
                bToken,
                bAmount,
                true
            );
        }
        _payGas(Consts.OP_INDEX_ADD_MARGIN);
    }

    function requestRemoveMargin(
        uint256 gatewayIdx,
        uint256 pTokenId,
        address bToken,
        uint256 bAmount
    ) external payable _onlyExecutorOrOwner_
    {
        address gateway = getGateway(gatewayIdx);
        IGateway(gateway).requestRemoveMargin{value: msg.value}(
            pTokenId,
            bToken,
            bAmount
        );
        _payGas(Consts.OP_INDEX_REMOVE_MARGIN);
    }

    function requestTrade(
        uint256 gatewayIdx,
        uint256 pTokenId,
        bytes32 symbolId,
        int256[] memory tradeParams
    ) external payable _onlyExecutorOrOwner_
    {
        address gateway = getGateway(gatewayIdx);
        IGateway(gateway).requestTrade{value: msg.value}(
            pTokenId,
            symbolId,
            tradeParams
        );
        _payGas(Consts.OP_INDEX_TRADE);
    }

    function requestAddMarginAndTrade(
        uint256 gatewayIdx,
        uint256 pTokenId,
        address bToken,
        uint256 bAmount,
        bytes32 symbolId,
        int256[] calldata tradeParams
    ) external payable _onlyExecutorOrOwner_
    {
        address gateway = getGateway(gatewayIdx);
        if (bToken == Consts.TOKEN_ETH) {
            IGateway(gateway).requestAddMarginAndTrade{value: bAmount + msg.value}(
                pTokenId,
                bToken,
                bAmount,
                symbolId,
                tradeParams,
                true
            );
        } else {
            _approve(bToken, gateway, bAmount);
            IGateway(gateway).requestAddMarginAndTrade{value: msg.value}(
                pTokenId,
                bToken,
                bAmount,
                symbolId,
                tradeParams,
                true
            );
        }
        _payGas(Consts.OP_INDEX_ADD_MARGIN_AND_TRADE);
    }

    function requestTradeAndRemoveMargin(
        uint256 gatewayIdx,
        uint256 pTokenId,
        address bToken,
        uint256 bAmount,
        bytes32 symbolId,
        int256[] calldata tradeParams
    ) external payable _onlyExecutorOrOwner_
    {
        address gateway = getGateway(gatewayIdx);
        IGateway(gateway).requestTradeAndRemoveMargin{value: msg.value}(
            pTokenId,
            bToken,
            bAmount,
            symbolId,
            tradeParams
        );
        _payGas(Consts.OP_INDEX_TRADE_AND_REMOVE_MARGIN);
    }

    function withdraw(address token, uint256 amount) external _onlyExecutorOrOwner_ {
        _withdraw(token, amount);
        _payGas(Consts.OP_INDEX_WITHDRAW);
    }

    function withdrawEthAndB0() external _onlyExecutorOrOwner_ {
        _withdraw(Consts.TOKEN_ETH, Consts.TOKEN_ETH.balanceOfThis());
        _withdraw(tokenB0, tokenB0.balanceOfThis());
        _payGas(Consts.OP_INDEX_WITHDRAW);
    }

    //================================================================================

    function _approve(address bToken, address spender, uint256 amount) internal {
        uint256 allowance = IERC20(bToken).allowance(address(this), spender);
        if (allowance == 0) {
            bToken.approveMax(spender);
        } else if (allowance < amount) {
            bToken.unapprove(spender);
            bToken.approveMax(spender);
        }
    }

    function _withdraw(address token, uint256 amount) internal {
        token.transferOut(owner, amount);
    }

    function _getOpGas(uint256 opIndex) internal view returns (address bToken, uint256 amount) {
        address[] memory tokens = IManager(manager).getOpGasTokens();
        for (uint256 i = 0; i < tokens.length; i++) {
            amount = IManager(manager).getOpGas(i, opIndex);
            if (amount > 0) {
                uint256 balance = tokens[i].balanceOfThis();
                if (balance >= amount) {
                    return (tokens[i], amount);
                }
            }
        }
    }

    function _payGas(uint256 opIndex) internal {
        if (msg.sender != owner) {
            (address bToken, uint256 amount) = _getOpGas(opIndex);
            require(bToken != address(0), Errors.INVALID_OP_GAS_TOKEN);
            bToken.transferOut(msg.sender, amount);
        }
    }

    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external view returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }

}

File 2 of 13 : IERC20Metadata.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 3 of 13 : IERC20Permit.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * ==== Security Considerations
 *
 * There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
 * expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
 * considered as an intention to spend the allowance in any specific way. The second is that because permits have
 * built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
 * take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
 * generally recommended is:
 *
 * ```solidity
 * function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
 *     try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
 *     doThing(..., value);
 * }
 *
 * function doThing(..., uint256 value) public {
 *     token.safeTransferFrom(msg.sender, address(this), value);
 *     ...
 * }
 * ```
 *
 * Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
 * `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
 * {SafeERC20-safeTransferFrom}).
 *
 * Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
 * contracts should have entry points that don't rely on permit.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     *
     * CAUTION: See Security Considerations above.
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 4 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 value) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 value) external returns (bool);
}

File 5 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using Address for address;

    /**
     * @dev An operation with an ERC20 token failed.
     */
    error SafeERC20FailedOperation(address token);

    /**
     * @dev Indicates a failed `decreaseAllowance` request.
     */
    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);

    /**
     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
    }

    /**
     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
     */
    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
    }

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

        if (!_callOptionalReturnBool(token, approvalCall)) {
            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
            _callOptionalReturn(token, approvalCall);
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
        // the target address contains contract code and also asserts for success in the low-level call.

        bytes memory returndata = address(token).functionCall(data);
        if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
        // and not revert is the subcall reverts.

        (bool success, bytes memory returndata) = address(token).call(data);
        return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
    }
}

File 6 of 13 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.20;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be
     * reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 7 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error AddressInsufficientBalance(address account);

    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedInnerCall();

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        if (address(this).balance < amount) {
            revert AddressInsufficientBalance(address(this));
        }

        (bool success, ) = recipient.call{value: amount}("");
        if (!success) {
            revert FailedInnerCall();
        }
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason or custom error, it is bubbled
     * up by this function (like regular Solidity function calls). However, if
     * the call reverted with no returned reason, this function reverts with a
     * {FailedInnerCall} error.
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        if (address(this).balance < value) {
            revert AddressInsufficientBalance(address(this));
        }
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResultFromTarget(target, success, returndata);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
     * was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
     * unsuccessful call.
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata
    ) internal view returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            // only check if target is a contract if the call was successful and the return data is empty
            // otherwise we already know that it was a contract
            if (returndata.length == 0 && target.code.length == 0) {
                revert AddressEmptyCode(target);
            }
            return returndata;
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
     * revert reason or with a default {FailedInnerCall} error.
     */
    function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
        if (!success) {
            _revert(returndata);
        } else {
            return returndata;
        }
    }

    /**
     * @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
     */
    function _revert(bytes memory returndata) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert FailedInnerCall();
        }
    }
}

File 8 of 13 : IGateway.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IGateway {

    function claimUnusedIChainExecutionFee(uint256 dTokenId, bool isLp) external;

    function requestAddMargin(uint256 pTokenId, address bToken, uint256 bAmount, bool singlePosition)
    external payable returns (uint256);

    function requestRemoveMargin(uint256 pTokenId, address bToken, uint256 bAmount) external payable;

    function requestTrade(uint256 pTokenId, bytes32 symbolId, int256[] calldata tradeParams) external payable;

    function requestAddMarginAndTrade(
        uint256 pTokenId,
        address bToken,
        uint256 bAmount,
        bytes32 symbolId,
        int256[] calldata tradeParams,
        bool singlePosition
    ) external payable;

    function requestTradeAndRemoveMargin(
        uint256 pTokenId,
        address bToken,
        uint256 bAmount,
        bytes32 symbolId,
        int256[] calldata tradeParams
    ) external payable;

}

File 9 of 13 : Consts.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

library Consts {

    address internal constant TOKEN_ETH = address(1);

    // op index
    uint256 internal constant OP_INDEX_LENGTH = 6;
    uint256 internal constant OP_INDEX_ADD_MARGIN = 0;
    uint256 internal constant OP_INDEX_REMOVE_MARGIN = 1;
    uint256 internal constant OP_INDEX_TRADE = 2;
    uint256 internal constant OP_INDEX_ADD_MARGIN_AND_TRADE = 3;
    uint256 internal constant OP_INDEX_TRADE_AND_REMOVE_MARGIN = 4;
    uint256 internal constant OP_INDEX_WITHDRAW = 5;

}

File 10 of 13 : Errors.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

library Errors {

    string internal constant ETH_BALANCE_0 = 'EB0';
    string internal constant INSUFFICIENT_EXECUTION_FEE = 'IEF';
    string internal constant INVALID_OP_GAS_TOKEN = 'IOGT';
    string internal constant ONLY_EXECUTOR = 'OE';
    string internal constant ONLY_EXECUTOR_OR_OWNER = 'OEO';
    string internal constant OWNER_ALREADY_SET = 'OAS';
    string internal constant TRANSFER_ETH_FAIL = 'TEF';
    string internal constant WRONG_TOKEN_IN_AMOUNT = 'WTIA';
    string internal constant WRONG_TOKEN_OUT_AMOUNT = 'WTOA';

}

File 11 of 13 : ETHAndERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

import '@openzeppelin/contracts/token/ERC20/IERC20.sol';
import '@openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol';
import '@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol';
import './Consts.sol';
import './Errors.sol';

/// Library for operating ERC20 and ETH in one logic

library ETHAndERC20 {

    using SafeERC20 for IERC20;

    function decimals(address token) internal view returns (uint8) {
        return token == Consts.TOKEN_ETH ? 18 : IERC20Metadata(token).decimals();
    }

    // @notice Get the balance of ERC20 tokens or Ether held by this contract
    function balanceOfThis(address token) internal view returns (uint256) {
        return token == Consts.TOKEN_ETH
            ? address(this).balance
            : IERC20(token).balanceOf(address(this));
    }

    function approveMax(address token, address spender) internal {
        if (token != Consts.TOKEN_ETH) {
            uint256 allowance = IERC20(token).allowance(address(this), spender);
            if (allowance != type(uint256).max) {
                if (allowance != 0) {
                    IERC20(token).approve(spender, 0);
                }
                IERC20(token).approve(spender, type(uint256).max);
            }
        }
    }

    function unapprove(address token, address spender) internal {
        if (token != Consts.TOKEN_ETH) {
            uint256 allowance = IERC20(token).allowance(address(this), spender);
            if (allowance != 0) {
                IERC20(token).approve(spender, 0);
            }
        }
    }

    // @notice Transfer ERC20 tokens or Ether from 'from' to this contract
    function transferIn(address token, address from, uint256 amount) internal {
        if (token == Consts.TOKEN_ETH) {
            require(amount == msg.value, Errors.WRONG_TOKEN_IN_AMOUNT);
        } else {
            uint256 balance1 = balanceOfThis(token);
            IERC20(token).safeTransferFrom(from, address(this), amount);
            uint256 balance2 = balanceOfThis(token);
            require(balance2 == balance1 + amount, Errors.WRONG_TOKEN_IN_AMOUNT);
        }
    }

    // @notice Transfer ERC20 tokens or Ether from this contract to 'to'
    function transferOut(address token, address to, uint256 amount) internal {
        uint256 balance1 = balanceOfThis(token);
        if (token == Consts.TOKEN_ETH) {
            (bool success, ) = payable(to).call{value: amount}('');
            require(success, Errors.TRANSFER_ETH_FAIL);
        } else {
            IERC20(token).safeTransfer(to, amount);
        }
        uint256 balance2 = balanceOfThis(token);
        require(balance1 == balance2 + amount, Errors.WRONG_TOKEN_OUT_AMOUNT);
    }

}

File 12 of 13 : IManager.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

interface IManager {

    function getGateway(uint256 gatewayIdx) external view returns (address);

    function smartAccountTemplate() external view returns (address);

    function smartAccountImplementation() external view returns (address);

    function isExecutor(address executor) external view returns (bool);

    function getSmartAccount(address owner) external view returns (address);

    function getOpGasTokens() external view returns (address[] memory);

    function getOpGases() external view returns(uint256[6][] memory);

    function getOpGas(uint256 bIndex, uint256 opIndex) external view returns (uint256);

    function setGateways(address[] memory gateways) external;

    function addExecutor(address executor) external;

    function removeExecutor(address executor) external;

    function setOpGasTokens(address[] memory tokens) external;

    function setOpGases(uint256[6][] memory opGases) external;

}

File 13 of 13 : SmartAccountStorage.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.8.0 <0.9.0;

abstract contract SmartAccountStorage {

    address public owner;

}

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

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"manager_","type":"address"},{"internalType":"address","name":"tokenB0_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"}],"name":"claimUnusedIChainExecutionFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"}],"name":"getGateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"opIndex","type":"uint256"}],"name":"getOpGas","outputs":[{"internalType":"address","name":"bToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"manager","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"},{"internalType":"address","name":"bToken","type":"address"},{"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"requestAddMargin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"},{"internalType":"address","name":"bToken","type":"address"},{"internalType":"uint256","name":"bAmount","type":"uint256"},{"internalType":"bytes32","name":"symbolId","type":"bytes32"},{"internalType":"int256[]","name":"tradeParams","type":"int256[]"}],"name":"requestAddMarginAndTrade","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"},{"internalType":"address","name":"bToken","type":"address"},{"internalType":"uint256","name":"bAmount","type":"uint256"}],"name":"requestRemoveMargin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"},{"internalType":"bytes32","name":"symbolId","type":"bytes32"},{"internalType":"int256[]","name":"tradeParams","type":"int256[]"}],"name":"requestTrade","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"gatewayIdx","type":"uint256"},{"internalType":"uint256","name":"pTokenId","type":"uint256"},{"internalType":"address","name":"bToken","type":"address"},{"internalType":"uint256","name":"bAmount","type":"uint256"},{"internalType":"bytes32","name":"symbolId","type":"bytes32"},{"internalType":"int256[]","name":"tradeParams","type":"int256[]"}],"name":"requestTradeAndRemoveMargin","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"tokenB0","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawEthAndB0","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60c06040523480156200001157600080fd5b5060405162001e8c38038062001e8c833981016040819052620000349162000069565b6001600160a01b039182166080521660a052620000a1565b80516001600160a01b03811681146200006457600080fd5b919050565b600080604083850312156200007d57600080fd5b62000088836200004c565b915062000098602084016200004c565b90509250929050565b60805160a051611d716200011b6000396000818161027601528181610e070152610e2b01526000818161018a015281816102f50152818161050001528181610617015281816108360152818161098801528181610ae001528181610c3c01528181610d2c01528181610fb501526110640152611d716000f3fe6080604052600436106100dc5760003560e01c80638da5cb5b1161007f578063b016ec9c11610059578063b016ec9c14610264578063db0fbaa714610298578063f3fef3a3146102ab578063f85836db146102cb57600080fd5b80638da5cb5b1461021e5780638e0e4c791461023e5780639da22e731461025157600080fd5b8063481c6a75116100bb578063481c6a75146101785780634dc4a664146101ac578063719fa7f6146101cc57806374b98e9e1461020b57600080fd5b80625c85d9146100e1578063150b7a02146100f657806330cc0e0c14610140575b600080fd5b6100f46100ef366004611756565b6102e0565b005b34801561010257600080fd5b50610122610111366004611805565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b34801561014c57600080fd5b5061016061015b3660046118a4565b6104e7565b6040516001600160a01b039091168152602001610137565b34801561018457600080fd5b506101607f000000000000000000000000000000000000000000000000000000000000000081565b3480156101b857600080fd5b506100f46101c73660046118bd565b610579565b3480156101d857600080fd5b506101ec6101e73660046118a4565b6105ed565b604080516001600160a01b039093168352602083019190915201610137565b6100f46102193660046118df565b610602565b34801561022a57600080fd5b50600054610160906001600160a01b031681565b6100f461024c366004611989565b610821565b6100f461025f366004611756565b610973565b34801561027057600080fd5b506101607f000000000000000000000000000000000000000000000000000000000000000081565b6100f46102a63660046118df565b610acb565b3480156102b757600080fd5b506100f46102c6366004611a3c565b610c27565b3480156102d757600080fd5b506100f4610d17565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103689190611a68565b8061037d57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906103c05760405162461bcd60e51b81526004016103b79190611aae565b60405180910390fd5b5060006103cc886104e7565b90506000196001600160a01b0387160161045a576001600160a01b0381166316890fc26103f93488611af7565b89898989898960016040518963ffffffff1660e01b81526004016104239796959493929190611b41565b6000604051808303818588803b15801561043c57600080fd5b505af1158015610450573d6000803e3d6000fd5b50505050506104d3565b610465868287610e64565b604051630b4487e160e11b81526001600160a01b038216906316890fc29034906104a0908b908b908b908b908b908b90600190600401611b41565b6000604051808303818588803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50505050505b6104dd6003610f2e565b5050505050505050565b604051630c33038360e21b8152600481018290526000907f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906330cc0e0c90602401602060405180830381865afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105739190611b8b565b92915050565b6000610584836104e7565b6040516323cc0ebf60e01b815260048101849052600060248201529091506001600160a01b038216906323cc0ebf90604401600060405180830381600087803b1580156105d057600080fd5b505af11580156105e4573d6000803e3d6000fd5b50505050505050565b6000806105f983610fae565b91509150915091565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a9190611a68565b8061069f57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906106d95760405162461bcd60e51b81526004016103b79190611aae565b5060006106e5856104e7565b90506000196001600160a01b0384160161078257604051633f4a2cdd60e11b8152600481018590526001600160a01b0384811660248301526044820184905260016064830152821690637e9459ba90849060840160206040518083038185885af1158015610757573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061077c9190611ba8565b50610810565b61078d838284610e64565b604051633f4a2cdd60e11b8152600481018590526001600160a01b0384811660248301526044820184905260016064830152821690637e9459ba906084016020604051808303816000875af11580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190611ba8565b505b61081a6000610f2e565b5050505050565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a99190611a68565b806108be57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906108f85760405162461bcd60e51b81526004016103b79190611aae565b506000610904856104e7565b9050806001600160a01b031663fa321c26348686866040518563ffffffff1660e01b815260040161093793929190611bc1565b6000604051808303818588803b15801561095057600080fd5b505af1158015610964573d6000803e3d6000fd5b505050505061081a6002610f2e565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa1580156109d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fb9190611a68565b80610a1057506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610a4a5760405162461bcd60e51b81526004016103b79190611aae565b506000610a56886104e7565b9050806001600160a01b031663e1faff56348989898989896040518863ffffffff1660e01b8152600401610a8f96959493929190611c16565b6000604051808303818588803b158015610aa857600080fd5b505af1158015610abc573d6000803e3d6000fd5b50505050506104dd6004610f2e565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610b2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b539190611a68565b80610b6857506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610ba25760405162461bcd60e51b81526004016103b79190611aae565b506000610bae856104e7565b604051633df1835160e21b8152600481018690526001600160a01b038581166024830152604482018590529192509082169063f7c60d449034906064016000604051808303818588803b158015610c0457600080fd5b505af1158015610c18573d6000803e3d6000fd5b505050505061081a6001610f2e565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190611a68565b80610cc457506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610cfe5760405162461bcd60e51b81526004016103b79190611aae565b50610d098282611154565b610d136005610f2e565b5050565b604051630debfda360e41b81523360048201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063debfda3090602401602060405180830381865afa158015610d7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9f9190611a68565b80610db457506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610dee5760405162461bcd60e51b81526004016103b79190611aae565b50610e026001610dfd8161116e565b611154565b610e587f0000000000000000000000000000000000000000000000000000000000000000610dfd7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661116e565b610e626005610f2e565b565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed89190611ba8565b905080600003610efa57610ef56001600160a01b038516846111f5565b610f28565b81811015610f2857610f156001600160a01b03851684611375565b610f286001600160a01b038516846111f5565b50505050565b6000546001600160a01b03163314610fab57600080610f4c83610fae565b6040805180820190915260048152631253d1d560e21b602082015291935091506001600160a01b038316610f935760405162461bcd60e51b81526004016103b79190611aae565b50610fa86001600160a01b0383163383611437565b50505b50565b60008060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166338a649916040518163ffffffff1660e01b8152600401600060405180830381865afa158015611011573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110399190810190611c56565b905060005b815181101561114d576040516394abac1b60e01b815260048101829052602481018690527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316906394abac1b90604401602060405180830381865afa1580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d79190611ba8565b9250821561113b57600061110c8383815181106110f6576110f6611cf0565b60200260200101516001600160a01b031661116e565b90508381106111395782828151811061112757611127611cf0565b60200260200101519450505050915091565b505b8061114581611d06565b91505061103e565b5050915091565b600054610d13906001600160a01b03848116911683611437565b60006001600160a01b0382166001146111ee576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156111c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e99190611ba8565b610573565b4792915050565b6001600160a01b038216600114610d1357604051636eb1769f60e11b81523060048201526001600160a01b0382811660248301526000919084169063dd62ed3e90604401602060405180830381865afa158015611256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127a9190611ba8565b90506000198114610fa85780156113005760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b3906044016020604051808303816000875af11580156112da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fe9190611a68565b505b60405163095ea7b360e01b81526001600160a01b038381166004830152600019602483015284169063095ea7b3906044015b6020604051808303816000875af1158015611351573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f289190611a68565b6001600160a01b038216600114610d1357604051636eb1769f60e11b81523060048201526001600160a01b0382811660248301526000919084169063dd62ed3e90604401602060405180830381865afa1580156113d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fa9190611ba8565b90508015610fa85760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b390604401611332565b60006114428461116e565b90506000196001600160a01b038516016114ee576000836001600160a01b03168360405160006040518083038185875af1925050503d80600081146114a3576040519150601f19603f3d011682016040523d82523d6000602084013e6114a8565b606091505b5050905080604051806040016040528060038152602001622a22a360e91b815250906114e75760405162461bcd60e51b81526004016103b79190611aae565b5050611502565b6115026001600160a01b038516848461155e565b600061150d8561116e565b90506115198382611af7565b82146040518060400160405280600481526020016357544f4160e01b815250906115565760405162461bcd60e51b81526004016103b79190611aae565b505050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663a9059cbb60e01b179052610fa8918591906000906115bc9084168361160a565b905080516000141580156115e15750808060200190518101906115df9190611a68565b155b15610fa857604051635274afe760e01b81526001600160a01b03841660048201526024016103b7565b60606116188383600061161f565b9392505050565b6060814710156116445760405163cd78605960e01b81523060048201526024016103b7565b600080856001600160a01b031684866040516116609190611d1f565b60006040518083038185875af1925050503d806000811461169d576040519150601f19603f3d011682016040523d82523d6000602084013e6116a2565b606091505b50915091506116b28683836116bc565b9695505050505050565b6060826116d1576116cc82611718565b611618565b81511580156116e857506001600160a01b0384163b155b1561171157604051639996b31560e01b81526001600160a01b03851660048201526024016103b7565b5080611618565b8051156117285780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b0381168114610fab57600080fd5b600080600080600080600060c0888a03121561177157600080fd5b8735965060208801359550604088013561178a81611741565b9450606088013593506080880135925060a088013567ffffffffffffffff808211156117b557600080fd5b818a0191508a601f8301126117c957600080fd5b8135818111156117d857600080fd5b8b60208260051b85010111156117ed57600080fd5b60208301945080935050505092959891949750929550565b60008060008060006080868803121561181d57600080fd5b853561182881611741565b9450602086013561183881611741565b935060408601359250606086013567ffffffffffffffff8082111561185c57600080fd5b818801915088601f83011261187057600080fd5b81358181111561187f57600080fd5b89602082850101111561189157600080fd5b9699959850939650602001949392505050565b6000602082840312156118b657600080fd5b5035919050565b600080604083850312156118d057600080fd5b50508035926020909101359150565b600080600080608085870312156118f557600080fd5b8435935060208501359250604085013561190e81611741565b9396929550929360600135925050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561195d5761195d61191e565b604052919050565b600067ffffffffffffffff82111561197f5761197f61191e565b5060051b60200190565b6000806000806080858703121561199f57600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff8111156119cc57600080fd5b8601601f810188136119dd57600080fd5b80356119f06119eb82611965565b611934565b81815260059190911b8201830190838101908a831115611a0f57600080fd5b928401925b82841015611a2d57833582529284019290840190611a14565b979a9699509497505050505050565b60008060408385031215611a4f57600080fd5b8235611a5a81611741565b946020939093013593505050565b600060208284031215611a7a57600080fd5b8151801515811461161857600080fd5b60005b83811015611aa5578181015183820152602001611a8d565b50506000910152565b6020815260008251806020840152611acd816040850160208701611a8a565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561057357610573611ae1565b8183526000602080850194508260005b85811015611b3657813587529582019590820190600101611b1a565b509495945050505050565b87815260018060a01b038716602082015285604082015284606082015260c060808201526000611b7560c083018587611b0a565b905082151560a083015298975050505050505050565b600060208284031215611b9d57600080fd5b815161161881611741565b600060208284031215611bba57600080fd5b5051919050565b6000606082018583526020858185015260606040850152818551808452608086019150828701935060005b81811015611c0857845183529383019391830191600101611bec565b509098975050505050505050565b86815260018060a01b038616602082015284604082015283606082015260a060808201526000611c4a60a083018486611b0a565b98975050505050505050565b60006020808385031215611c6957600080fd5b825167ffffffffffffffff811115611c8057600080fd5b8301601f81018513611c9157600080fd5b8051611c9f6119eb82611965565b81815260059190911b82018301908381019087831115611cbe57600080fd5b928401925b82841015611ce5578351611cd681611741565b82529284019290840190611cc3565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b600060018201611d1857611d18611ae1565b5060010190565b60008251611d31818460208701611a8a565b919091019291505056fea26469706673582212202c2d25b21d30dc68a46dcddfae34527b24db91d21aca0679e7c415640ef245ac64736f6c634300081400330000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d06188500000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894

Deployed Bytecode

0x6080604052600436106100dc5760003560e01c80638da5cb5b1161007f578063b016ec9c11610059578063b016ec9c14610264578063db0fbaa714610298578063f3fef3a3146102ab578063f85836db146102cb57600080fd5b80638da5cb5b1461021e5780638e0e4c791461023e5780639da22e731461025157600080fd5b8063481c6a75116100bb578063481c6a75146101785780634dc4a664146101ac578063719fa7f6146101cc57806374b98e9e1461020b57600080fd5b80625c85d9146100e1578063150b7a02146100f657806330cc0e0c14610140575b600080fd5b6100f46100ef366004611756565b6102e0565b005b34801561010257600080fd5b50610122610111366004611805565b630a85bd0160e11b95945050505050565b6040516001600160e01b031990911681526020015b60405180910390f35b34801561014c57600080fd5b5061016061015b3660046118a4565b6104e7565b6040516001600160a01b039091168152602001610137565b34801561018457600080fd5b506101607f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d06188581565b3480156101b857600080fd5b506100f46101c73660046118bd565b610579565b3480156101d857600080fd5b506101ec6101e73660046118a4565b6105ed565b604080516001600160a01b039093168352602083019190915201610137565b6100f46102193660046118df565b610602565b34801561022a57600080fd5b50600054610160906001600160a01b031681565b6100f461024c366004611989565b610821565b6100f461025f366004611756565b610973565b34801561027057600080fd5b506101607f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d403889481565b6100f46102a63660046118df565b610acb565b3480156102b757600080fd5b506100f46102c6366004611a3c565b610c27565b3480156102d757600080fd5b506100f4610d17565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610344573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103689190611a68565b8061037d57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906103c05760405162461bcd60e51b81526004016103b79190611aae565b60405180910390fd5b5060006103cc886104e7565b90506000196001600160a01b0387160161045a576001600160a01b0381166316890fc26103f93488611af7565b89898989898960016040518963ffffffff1660e01b81526004016104239796959493929190611b41565b6000604051808303818588803b15801561043c57600080fd5b505af1158015610450573d6000803e3d6000fd5b50505050506104d3565b610465868287610e64565b604051630b4487e160e11b81526001600160a01b038216906316890fc29034906104a0908b908b908b908b908b908b90600190600401611b41565b6000604051808303818588803b1580156104b957600080fd5b505af11580156104cd573d6000803e3d6000fd5b50505050505b6104dd6003610f2e565b5050505050505050565b604051630c33038360e21b8152600481018290526000907f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b0316906330cc0e0c90602401602060405180830381865afa15801561054f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105739190611b8b565b92915050565b6000610584836104e7565b6040516323cc0ebf60e01b815260048101849052600060248201529091506001600160a01b038216906323cc0ebf90604401600060405180830381600087803b1580156105d057600080fd5b505af11580156105e4573d6000803e3d6000fd5b50505050505050565b6000806105f983610fae565b91509150915091565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061068a9190611a68565b8061069f57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906106d95760405162461bcd60e51b81526004016103b79190611aae565b5060006106e5856104e7565b90506000196001600160a01b0384160161078257604051633f4a2cdd60e11b8152600481018590526001600160a01b0384811660248301526044820184905260016064830152821690637e9459ba90849060840160206040518083038185885af1158015610757573d6000803e3d6000fd5b50505050506040513d601f19601f8201168201806040525081019061077c9190611ba8565b50610810565b61078d838284610e64565b604051633f4a2cdd60e11b8152600481018590526001600160a01b0384811660248301526044820184905260016064830152821690637e9459ba906084016020604051808303816000875af11580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190611ba8565b505b61081a6000610f2e565b5050505050565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610885573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108a99190611a68565b806108be57506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b815250906108f85760405162461bcd60e51b81526004016103b79190611aae565b506000610904856104e7565b9050806001600160a01b031663fa321c26348686866040518563ffffffff1660e01b815260040161093793929190611bc1565b6000604051808303818588803b15801561095057600080fd5b505af1158015610964573d6000803e3d6000fd5b505050505061081a6002610f2e565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa1580156109d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109fb9190611a68565b80610a1057506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610a4a5760405162461bcd60e51b81526004016103b79190611aae565b506000610a56886104e7565b9050806001600160a01b031663e1faff56348989898989896040518863ffffffff1660e01b8152600401610a8f96959493929190611c16565b6000604051808303818588803b158015610aa857600080fd5b505af1158015610abc573d6000803e3d6000fd5b50505050506104dd6004610f2e565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610b2f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b539190611a68565b80610b6857506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610ba25760405162461bcd60e51b81526004016103b79190611aae565b506000610bae856104e7565b604051633df1835160e21b8152600481018690526001600160a01b038581166024830152604482018590529192509082169063f7c60d449034906064016000604051808303818588803b158015610c0457600080fd5b505af1158015610c18573d6000803e3d6000fd5b505050505061081a6001610f2e565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610c8b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610caf9190611a68565b80610cc457506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610cfe5760405162461bcd60e51b81526004016103b79190611aae565b50610d098282611154565b610d136005610f2e565b5050565b604051630debfda360e41b81523360048201527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03169063debfda3090602401602060405180830381865afa158015610d7b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d9f9190611a68565b80610db457506000546001600160a01b031633145b604051806040016040528060038152602001624f454f60e81b81525090610dee5760405162461bcd60e51b81526004016103b79190611aae565b50610e026001610dfd8161116e565b611154565b610e587f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894610dfd7f00000000000000000000000029219dd400f2bf60e5a23d13be72b486d40388946001600160a01b031661116e565b610e626005610f2e565b565b604051636eb1769f60e11b81523060048201526001600160a01b0383811660248301526000919085169063dd62ed3e90604401602060405180830381865afa158015610eb4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ed89190611ba8565b905080600003610efa57610ef56001600160a01b038516846111f5565b610f28565b81811015610f2857610f156001600160a01b03851684611375565b610f286001600160a01b038516846111f5565b50505050565b6000546001600160a01b03163314610fab57600080610f4c83610fae565b6040805180820190915260048152631253d1d560e21b602082015291935091506001600160a01b038316610f935760405162461bcd60e51b81526004016103b79190611aae565b50610fa86001600160a01b0383163383611437565b50505b50565b60008060007f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b03166338a649916040518163ffffffff1660e01b8152600401600060405180830381865afa158015611011573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526110399190810190611c56565b905060005b815181101561114d576040516394abac1b60e01b815260048101829052602481018690527f0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d0618856001600160a01b0316906394abac1b90604401602060405180830381865afa1580156110b3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110d79190611ba8565b9250821561113b57600061110c8383815181106110f6576110f6611cf0565b60200260200101516001600160a01b031661116e565b90508381106111395782828151811061112757611127611cf0565b60200260200101519450505050915091565b505b8061114581611d06565b91505061103e565b5050915091565b600054610d13906001600160a01b03848116911683611437565b60006001600160a01b0382166001146111ee576040516370a0823160e01b81523060048201526001600160a01b038316906370a0823190602401602060405180830381865afa1580156111c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e99190611ba8565b610573565b4792915050565b6001600160a01b038216600114610d1357604051636eb1769f60e11b81523060048201526001600160a01b0382811660248301526000919084169063dd62ed3e90604401602060405180830381865afa158015611256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127a9190611ba8565b90506000198114610fa85780156113005760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b3906044016020604051808303816000875af11580156112da573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112fe9190611a68565b505b60405163095ea7b360e01b81526001600160a01b038381166004830152600019602483015284169063095ea7b3906044015b6020604051808303816000875af1158015611351573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f289190611a68565b6001600160a01b038216600114610d1357604051636eb1769f60e11b81523060048201526001600160a01b0382811660248301526000919084169063dd62ed3e90604401602060405180830381865afa1580156113d6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113fa9190611ba8565b90508015610fa85760405163095ea7b360e01b81526001600160a01b0383811660048301526000602483015284169063095ea7b390604401611332565b60006114428461116e565b90506000196001600160a01b038516016114ee576000836001600160a01b03168360405160006040518083038185875af1925050503d80600081146114a3576040519150601f19603f3d011682016040523d82523d6000602084013e6114a8565b606091505b5050905080604051806040016040528060038152602001622a22a360e91b815250906114e75760405162461bcd60e51b81526004016103b79190611aae565b5050611502565b6115026001600160a01b038516848461155e565b600061150d8561116e565b90506115198382611af7565b82146040518060400160405280600481526020016357544f4160e01b815250906115565760405162461bcd60e51b81526004016103b79190611aae565b505050505050565b604080516001600160a01b03848116602483015260448083018590528351808403909101815260649092019092526020810180516001600160e01b031663a9059cbb60e01b179052610fa8918591906000906115bc9084168361160a565b905080516000141580156115e15750808060200190518101906115df9190611a68565b155b15610fa857604051635274afe760e01b81526001600160a01b03841660048201526024016103b7565b60606116188383600061161f565b9392505050565b6060814710156116445760405163cd78605960e01b81523060048201526024016103b7565b600080856001600160a01b031684866040516116609190611d1f565b60006040518083038185875af1925050503d806000811461169d576040519150601f19603f3d011682016040523d82523d6000602084013e6116a2565b606091505b50915091506116b28683836116bc565b9695505050505050565b6060826116d1576116cc82611718565b611618565b81511580156116e857506001600160a01b0384163b155b1561171157604051639996b31560e01b81526001600160a01b03851660048201526024016103b7565b5080611618565b8051156117285780518082602001fd5b604051630a12f52160e11b815260040160405180910390fd5b6001600160a01b0381168114610fab57600080fd5b600080600080600080600060c0888a03121561177157600080fd5b8735965060208801359550604088013561178a81611741565b9450606088013593506080880135925060a088013567ffffffffffffffff808211156117b557600080fd5b818a0191508a601f8301126117c957600080fd5b8135818111156117d857600080fd5b8b60208260051b85010111156117ed57600080fd5b60208301945080935050505092959891949750929550565b60008060008060006080868803121561181d57600080fd5b853561182881611741565b9450602086013561183881611741565b935060408601359250606086013567ffffffffffffffff8082111561185c57600080fd5b818801915088601f83011261187057600080fd5b81358181111561187f57600080fd5b89602082850101111561189157600080fd5b9699959850939650602001949392505050565b6000602082840312156118b657600080fd5b5035919050565b600080604083850312156118d057600080fd5b50508035926020909101359150565b600080600080608085870312156118f557600080fd5b8435935060208501359250604085013561190e81611741565b9396929550929360600135925050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561195d5761195d61191e565b604052919050565b600067ffffffffffffffff82111561197f5761197f61191e565b5060051b60200190565b6000806000806080858703121561199f57600080fd5b84359350602080860135935060408601359250606086013567ffffffffffffffff8111156119cc57600080fd5b8601601f810188136119dd57600080fd5b80356119f06119eb82611965565b611934565b81815260059190911b8201830190838101908a831115611a0f57600080fd5b928401925b82841015611a2d57833582529284019290840190611a14565b979a9699509497505050505050565b60008060408385031215611a4f57600080fd5b8235611a5a81611741565b946020939093013593505050565b600060208284031215611a7a57600080fd5b8151801515811461161857600080fd5b60005b83811015611aa5578181015183820152602001611a8d565b50506000910152565b6020815260008251806020840152611acd816040850160208701611a8a565b601f01601f19169190910160400192915050565b634e487b7160e01b600052601160045260246000fd5b8082018082111561057357610573611ae1565b8183526000602080850194508260005b85811015611b3657813587529582019590820190600101611b1a565b509495945050505050565b87815260018060a01b038716602082015285604082015284606082015260c060808201526000611b7560c083018587611b0a565b905082151560a083015298975050505050505050565b600060208284031215611b9d57600080fd5b815161161881611741565b600060208284031215611bba57600080fd5b5051919050565b6000606082018583526020858185015260606040850152818551808452608086019150828701935060005b81811015611c0857845183529383019391830191600101611bec565b509098975050505050505050565b86815260018060a01b038616602082015284604082015283606082015260a060808201526000611c4a60a083018486611b0a565b98975050505050505050565b60006020808385031215611c6957600080fd5b825167ffffffffffffffff811115611c8057600080fd5b8301601f81018513611c9157600080fd5b8051611c9f6119eb82611965565b81815260059190911b82018301908381019087831115611cbe57600080fd5b928401925b82841015611ce5578351611cd681611741565b82529284019290840190611cc3565b979650505050505050565b634e487b7160e01b600052603260045260246000fd5b600060018201611d1857611d18611ae1565b5060010190565b60008251611d31818460208701611a8a565b919091019291505056fea26469706673582212202c2d25b21d30dc68a46dcddfae34527b24db91d21aca0679e7c415640ef245ac64736f6c63430008140033

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

0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d06188500000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894

-----Decoded View---------------
Arg [0] : manager_ (address): 0x3965E1e2863C2fE7201C9FDF26C53c779D061885
Arg [1] : tokenB0_ (address): 0x29219dd400f2Bf60E5a23d13Be72B486D4038894

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 0000000000000000000000003965e1e2863c2fe7201c9fdf26c53c779d061885
Arg [1] : 00000000000000000000000029219dd400f2bf60e5a23d13be72b486d4038894


Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits

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.