BNB Price: $670.01 (+3.77%)
Gas: 1 GWei
 

Overview

BNB Balance

BNB Smart Chain LogoBNB Smart Chain LogoBNB Smart Chain Logo0 BNB

BNB Value

$0.00

Multichain Info

No addresses found
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:
SmartWalletImplementation

Compiler Version
v0.7.6+commit.7338295f

Optimization Enabled:
Yes with 780 runs

Other Settings:
default evmVersion
File 1 of 15 : SmartWalletImplementation.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;

import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@kyber.network/utils-sc/contracts/IERC20Ext.sol";
import "./interfaces/ISmartWalletImplementation.sol";
import "./SmartWalletStorage.sol";
import "./swap/ISwap.sol";
import "./lending/ILending.sol";

contract SmartWalletImplementation is SmartWalletStorage, ISmartWalletImplementation {
    using SafeERC20 for IERC20Ext;
    using SafeMath for uint256;
    using EnumerableSet for EnumerableSet.AddressSet;

    event ApprovedAllowances(IERC20Ext[] tokens, address[] spenders, bool isReset);
    event ClaimedPlatformFees(address[] wallets, IERC20Ext[] tokens, address claimer);

    constructor(address _admin) SmartWalletStorage(_admin) {}

    receive() external payable {}

    /// Claim fee to platform wallets
    function claimPlatformFees(address[] calldata platformWallets, IERC20Ext[] calldata tokens)
        external
        override
        nonReentrant
    {
        for (uint256 i = 0; i < platformWallets.length; i++) {
            for (uint256 j = 0; j < tokens.length; j++) {
                uint256 fee = platformWalletFees[platformWallets[i]][tokens[j]];
                if (fee > 1) {
                    // fee set to 1 to avoid the SSTORE initial gas cost
                    platformWalletFees[platformWallets[i]][tokens[j]] = 1;
                    transferToken(payable(platformWallets[i]), tokens[j], fee - 1);
                }
            }
        }
        emit ClaimedPlatformFees(platformWallets, tokens, msg.sender);
    }

    /// @dev approve/unapprove LPs usage on the particular tokens
    function approveAllowances(
        IERC20Ext[] calldata tokens,
        address[] calldata spenders,
        bool isReset
    ) external onlyAdmin {
        uint256 allowance = isReset ? 0 : MAX_ALLOWANCE;
        for (uint256 i = 0; i < tokens.length; i++) {
            for (uint256 j = 0; j < spenders.length; j++) {
                tokens[i].safeApprove(spenders[j], allowance);
            }
            getSetDecimals(tokens[i]);
        }

        emit ApprovedAllowances(tokens, spenders, isReset);
    }

    /// @dev get expected return including the fee
    /// @return destAmount expected dest amount
    /// @return expectedRate expected swap rate
    function getExpectedReturn(
        ISmartWalletImplementation.GetExpectedReturnParams calldata params
    ) external view override returns (uint256 destAmount, uint256 expectedRate) {
        if (params.feeBps >= BPS) return (0, 0); // platform fee is too high
        
        uint256 actualSrc = (params.feeMode == FeeMode.FROM_SOURCE) 
            ? params.srcAmount * (BPS - params.feeBps) / BPS : params.srcAmount;

        destAmount = ISwap(params.swapContract).getExpectedReturn(
            ISwap.GetExpectedReturnParams({
                srcAmount: actualSrc, 
                tradePath: params.tradePath,
                feeBps: params.feeMode == FeeMode.BY_PROTOCOL ? params.feeBps : 0,
                extraArgs: params.extraArgs
            })
        );

        if (params.feeMode == FeeMode.FROM_DEST) {
            destAmount = destAmount * (BPS - params.feeBps) / BPS;
        }

        expectedRate = calcRateFromQty(
            params.srcAmount,
            destAmount,
            getDecimals(IERC20Ext(params.tradePath[0])),
            getDecimals(IERC20Ext(params.tradePath[params.tradePath.length - 1]))
        );
    }

    /// @dev get expected in amount including the fee
    /// @return srcAmount expected aource amount
    /// @return expectedRate expected swap rate
    function getExpectedIn(
        ISmartWalletImplementation.GetExpectedInParams calldata params
    ) external view override returns (uint256 srcAmount, uint256 expectedRate) {
        if (params.feeBps >= BPS) return (0, 0); // platform fee is too high
        
        uint256 actualDest = (params.feeMode == FeeMode.FROM_DEST) 
            ? params.destAmount * (BPS + params.feeBps) / BPS : params.destAmount;

        srcAmount = ISwap(params.swapContract).getExpectedIn(
            ISwap.GetExpectedInParams({
                destAmount: actualDest, 
                tradePath: params.tradePath,
                feeBps: params.feeMode == FeeMode.BY_PROTOCOL ? params.feeBps : 0,
                extraArgs: params.extraArgs
            })
        );

        if (params.feeMode == FeeMode.FROM_SOURCE) {
            srcAmount = srcAmount * (BPS + params.feeBps) / BPS;
        }

        expectedRate = calcRateFromQty(
            srcAmount,
            params.destAmount,
            getDecimals(IERC20Ext(params.tradePath[0])),
            getDecimals(IERC20Ext(params.tradePath[params.tradePath.length - 1]))
        );
    }


    /// @dev swap using particular swap contract
    /// @return destAmount actual dest amount
    function swap(
        ISmartWalletImplementation.SwapParams calldata params
    ) external payable override nonReentrant returns (uint256 destAmount) {
        destAmount = swapInternal(
            params.swapContract,
            params.srcAmount,
            params.minDestAmount,
            params.tradePath,
            msg.sender,
            params.feeMode,
            params.feeBps,
            params.platformWallet,
            params.extraArgs
        );

        emit Swap(
            msg.sender,
            params.swapContract,
            params.tradePath,
            params.srcAmount,
            destAmount,
            params.feeMode,
            params.feeBps,
            params.platformWallet
        );
    }

    /// @dev swap then deposit to platform
    ///     if tradePath has only 1 token, don't need to do swap
    /// @return destAmount actual dest amount
    function swapAndDeposit(
        ISmartWalletImplementation.SwapAndDepositParams calldata params
    ) external payable override nonReentrant returns (uint256 destAmount) {
        require(params.tradePath.length >= 1, "invalid tradePath");
        require(supportedLendings.contains(params.lendingContract), "unsupported lending");

        
        if (params.tradePath.length == 1) {
            // just collect src token, no need to swap
            validateSourceAmount(params.tradePath[0], params.srcAmount);
            destAmount = safeTransferWithFee(
                msg.sender, 
                params.lendingContract, 
                params.tradePath[0], 
                params.srcAmount,
                // Not taking lending fee
                0, 
                params.platformWallet
            );
        } else {
            destAmount = swapInternal(
                params.swapContract,
                params.srcAmount,
                params.minDestAmount,
                params.tradePath,
                params.lendingContract,
                params.feeMode,
                params.feeBps,
                params.platformWallet,                    
                params.extraArgs
            );
        }

        // eth or token already transferred to the address
        ILending(params.lendingContract).depositTo(
            msg.sender, IERC20Ext(params.tradePath[params.tradePath.length - 1]), destAmount
        );
    
        emit SwapAndDeposit(
            msg.sender,
            params.swapContract,
            params.lendingContract,
            params.tradePath,
            params.srcAmount,
            destAmount,
            params.feeMode,
            params.feeBps,
            params.platformWallet
        );
    }

    /// @dev withdraw token from Lending platforms (AAVE, COMPOUND)
    /// @return returnedAmount returns the amount withdrawn to the user
    function withdrawFromLendingPlatform(
        ISmartWalletImplementation.WithdrawFromLendingPlatformParams calldata params
    ) external override nonReentrant returns (uint256 returnedAmount) {
        require(supportedLendings.contains(params.lendingContract), "unsupported lending");

        IERC20Ext lendingToken = IERC20Ext(ILending(params.lendingContract).getLendingToken(params.token));
        require(lendingToken != IERC20Ext(0), "unsupported token");

        // AAVE aToken's transfer logic could have rounding errors
        uint256 tokenBalanceBefore = lendingToken.balanceOf(params.lendingContract);
        lendingToken.safeTransferFrom(msg.sender, params.lendingContract, params.amount);
        uint256 tokenBalanceAfter = lendingToken.balanceOf(params.lendingContract);

        returnedAmount = ILending(params.lendingContract).withdrawFrom(
            msg.sender,
            params.token,
            tokenBalanceAfter.sub(tokenBalanceBefore),
            params.minReturn
        );

        require(returnedAmount >= params.minReturn, "low returned amount");

        emit WithdrawFromLending(
            msg.sender,
            params.lendingContract,
            params.token,
            params.amount,
            params.minReturn,
            returnedAmount
        );
    }

    /// @dev swap and repay borrow for sender
    function swapAndRepay(
        ISmartWalletImplementation.SwapAndRepayParams calldata params
    ) external payable override nonReentrant returns (uint256 destAmount) {
        require(params.tradePath.length >= 1, "invalid tradePath");
        require(supportedLendings.contains(params.lendingContract), "unsupported lending");
        
        // use user debt value if debt is <= payAmount
        // user can pay all debt by putting really high payAmount as param
        uint256 debt = ILending(params.lendingContract).getUserDebtCurrent(params.tradePath[params.tradePath.length - 1], msg.sender);
        uint256 actualPayAmount = debt >= params.payAmount ? params.payAmount : debt; 
        
        if (params.tradePath.length == 1) {
            // just collect src token, no need to swap
            validateSourceAmount(params.tradePath[0], params.srcAmount);
            destAmount = safeTransferWithFee(
                msg.sender, 
                params.lendingContract, 
                params.tradePath[0],
                params.srcAmount,
                // Not taking repay fee
                0, 
                params.platformWallet
            );
        } else {
            destAmount = swapInternal(
                params.swapContract,
                params.srcAmount,
                actualPayAmount,
                params.tradePath,
                params.lendingContract,
                params.feeMode,
                params.feeBps,
                params.platformWallet,                    
                params.extraArgs
            );
        }
        ILending(params.lendingContract).repayBorrowTo(
            msg.sender,
            IERC20Ext(params.tradePath[params.tradePath.length - 1]),
            destAmount,
            actualPayAmount,
            abi.encodePacked(params.rateMode)
        );

        uint256 actualDebtPaid = debt.sub(ILending(params.lendingContract).getUserDebtCurrent(params.tradePath[params.tradePath.length - 1], msg.sender));
        require(actualDebtPaid >= actualPayAmount, "low paid amount");

        emit SwapAndRepay(
            msg.sender,
            params.swapContract,
            params.lendingContract,
            params.tradePath,
            params.srcAmount,
            destAmount,
            actualPayAmount,
            params.feeMode,
            params.feeBps,
            params.platformWallet
        );
    }

    function swapInternal(
        address payable swapContract,
        uint256 srcAmount,
        uint256 minDestAmount,
        address[] calldata tradePath,
        address payable recipient,
        FeeMode feeMode,
        uint256 platformFee,
        address payable platformWallet,
        bytes calldata extraArgs
    ) internal returns (uint256 destAmount) {
        require(supportedSwaps.contains(swapContract), "unsupported swap");
        require(tradePath.length >= 2, "invalid tradePath");
        require(platformFee < BPS, "high platform fee");

        validateSourceAmount(tradePath[0], srcAmount);

        uint256 actualSrcAmount = safeTransferWithFee(
            msg.sender, 
            swapContract, 
            tradePath[0], 
            srcAmount,
            feeMode == FeeMode.FROM_SOURCE ? platformFee : 0,
            platformWallet
        );

        {
            // to avoid stack too deep
            // who will receive the swapped token
            address _recipient = feeMode == FeeMode.FROM_DEST ? address(this) : recipient;
            destAmount = ISwap(swapContract).swap(
                ISwap.SwapParams({
                    srcAmount: actualSrcAmount,
                    minDestAmount: minDestAmount,
                    tradePath: tradePath,
                    recipient: _recipient,
                    feeBps: feeMode == FeeMode.BY_PROTOCOL ? platformFee : 0,
                    feeReceiver: platformWallet,
                    extraArgs: extraArgs
                })
            );
        }

        if (feeMode == FeeMode.FROM_DEST) {
            destAmount = safeTransferWithFee(
                address(this), 
                recipient,
                tradePath[tradePath.length - 1], 
                destAmount, 
                platformFee, 
                platformWallet
            );         
        }

        require(destAmount >= minDestAmount, "low return");
    }

    function validateSourceAmount(
        address srcToken,
        uint256 srcAmount
    ) internal {
        if (srcToken == address(ETH_TOKEN_ADDRESS)) {
            require(msg.value == srcAmount, "wrong msg value");
        } else {
            require(msg.value == 0, "bad msg value");
        }
    }

    function transferToken(
        address payable to,
        IERC20Ext token,
        uint256 amount
    ) internal {
        if (amount == 0) return;
        if (token == ETH_TOKEN_ADDRESS) {
            (bool success, ) = to.call{value: amount}("");
            require(success, "transfer failed");
        } else {
            token.safeTransfer(to, amount);
        }
    }

    function safeTransferWithFee(
        address payable from,
        address payable to,
        address token,
        uint256 amount,
        uint256 platformFeeBps,
        address payable platformWallet
    ) internal returns (uint256 amountTransferred) {
        uint256 fee = amount.mul(platformFeeBps).div(BPS);
        uint256 amountAfterFee = amount.sub(fee);
        IERC20Ext tokenErc = IERC20Ext(token);

        if (tokenErc == ETH_TOKEN_ADDRESS) {
            (bool success, ) = to.call{value: amountAfterFee}("");
            require(success, "transfer failed");
            amountTransferred = amountAfterFee;
        } else {
            uint256 balanceBefore = tokenErc.balanceOf(to);
            if (from != address(this)) {
                // case transfer from another address, need to transfer fee to this proxy contract
                tokenErc.safeTransferFrom(from, to, amountAfterFee);
                tokenErc.safeTransferFrom(from, address(this), fee);
            } else {
                tokenErc.safeTransfer(to, amountAfterFee);
            }
            amountTransferred = tokenErc.balanceOf(to).sub(balanceBefore);
        }

        addFeeToPlatform(platformWallet, tokenErc, fee);
    }

    function addFeeToPlatform(
        address payable platformWallet,
        IERC20Ext token,
        uint256 amount
    ) internal {
        if (amount > 0) {
            require(supportedPlatformWallets.contains(platformWallet), "unsupported platform");
            platformWalletFees[platformWallet][token] = platformWalletFees[platformWallet][token].add(amount);
        }
    }
}

File 2 of 15 : SafeERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./IERC20.sol";
import "../../math/SafeMath.sol";
import "../../utils/Address.sol";

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

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 3 of 15 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 4 of 15 : IERC20Ext.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";


/**
 * @dev Interface extending ERC20 standard to include decimals() as
 *      it is optional in the OpenZeppelin IERC20 interface.
 */
interface IERC20Ext is IERC20 {
    /**
     * @dev This function is required as Kyber requires to interact
     *      with token.decimals() with many of its operations.
     */
    function decimals() external view returns (uint8 digits);
}

File 5 of 15 : ISmartWalletImplementation.sol
pragma solidity 0.7.6;
pragma abicoder v2;

import "@kyber.network/utils-sc/contracts/IERC20Ext.sol";

interface ISmartWalletImplementation {
    enum FeeMode {
        FROM_SOURCE,
        FROM_DEST,
        BY_PROTOCOL
    }

    event Swap(
        address indexed trader,
        address indexed swapContract,
        address[] tradePath,
        uint256 srcAmount,
        uint256 destAmount,
        FeeMode feeMode,
        uint256 feeBps,
        address platformWallet
    );

    event SwapAndDeposit(
        address indexed trader,
        address indexed swapContract,
        address indexed lendingContract,
        address[] tradePath,
        uint256 srcAmount,
        uint256 destAmount,
        FeeMode feeMode,
        uint256 feeBps,
        address platformWallet
    );

    event WithdrawFromLending(
        address indexed trader,
        address indexed lendingContract,
        IERC20Ext token,
        uint256 amount,
        uint256 minReturn,
        uint256 actualReturnAmount
    );

    event SwapAndRepay(
        address indexed trader,
        address indexed swapContract,
        address indexed lendingContract,
        address[] tradePath,
        uint256 srcAmount,
        uint256 destAmount,
        uint256 payAmount,
        FeeMode feeMode,
        uint256 feeBps,
        address platformWallet
    );

    /// @param swapContract swap contract
    /// @param srcAmount amount of src token
    /// @param tradePath path of the trade on Uniswap
    /// @param platformFee fee if swapping feeMode = platformFee / BPS, feeBps = platformFee % BPS
    /// @param extraArgs extra data needed for swap on particular platforms
    struct GetExpectedReturnParams {
        address payable swapContract;
        uint256 srcAmount;
        address[] tradePath;
        FeeMode feeMode;
        uint256 feeBps;
        bytes extraArgs;
    }

    function getExpectedReturn(GetExpectedReturnParams calldata params)
        external
        view
        returns (uint256 destAmount, uint256 expectedRate);

    struct GetExpectedInParams {
        address payable swapContract;
        uint256 destAmount;
        address[] tradePath;
        FeeMode feeMode;
        uint256 feeBps;
        bytes extraArgs;
    }

    function getExpectedIn(GetExpectedInParams calldata params)
        external
        view
        returns (uint256 srcAmount, uint256 expectedRate);

    /// @param swapContract swap contract
    /// @param srcAmount amount of src token
    /// @param minDestAmount minimal accepted dest amount
    /// @param tradePath path of the trade on Uniswap
    /// @param feeMode fee mode
    /// @param feeBps fee bps
    /// @param platformWallet wallet to receive fee
    /// @param extraArgs extra data needed for swap on particular platforms
    struct SwapParams {
        address payable swapContract;
        uint256 srcAmount;
        uint256 minDestAmount;
        address[] tradePath;
        FeeMode feeMode;
        uint256 feeBps;
        address payable platformWallet;
        bytes extraArgs;
    }

    function swap(SwapParams calldata params) external payable returns (uint256 destAmount);

    /// @param swapContract swap contract
    /// @param lendingContract lending contract
    /// @param srcAmount amount of src token
    /// @param minDestAmount minimal accepted dest amount
    /// @param tradePath path of the trade on Uniswap
    /// @param feeMode fee mode
    /// @param feeBps fee bps
    /// @param platformWallet wallet to receive fee
    /// @param extraArgs extra data needed for swap on particular platforms
    struct SwapAndDepositParams {
        address payable swapContract;
        address payable lendingContract;
        uint256 srcAmount;
        uint256 minDestAmount;
        address[] tradePath;
        FeeMode feeMode;
        uint256 feeBps;
        address payable platformWallet;
        bytes extraArgs;
    }

    function swapAndDeposit(SwapAndDepositParams calldata params)
        external
        payable
        returns (uint256 destAmount);

    /// @param lendingContract lending contract to withdraw token
    /// @param token underlying token to withdraw, e.g ETH, USDT, DAI
    /// @param amount amount of cToken (COMPOUND) or aToken (AAVE) to withdraw
    /// @param minReturn minimum amount of underlying tokens to return
    struct WithdrawFromLendingPlatformParams {
        address payable lendingContract;
        IERC20Ext token;
        uint256 amount;
        uint256 minReturn;
    }

    function withdrawFromLendingPlatform(WithdrawFromLendingPlatformParams calldata params)
        external
        returns (uint256 returnedAmount);

    /// @param swapContract swap contract
    /// @param lendingContract lending contract
    /// @param srcAmount amount of src token
    /// @param payAmount: amount that user wants to pay, if the dest amount (after swap) is higher,
    ///     the remain amount will be sent back to user's wallet
    /// @param tradePath path of the trade on Uniswap
    /// @param rateMode rate mode for aave v2
    /// @param feeMode fee mode
    /// @param feeBps fee bps
    /// @param platformWallet wallet to receive fee
    /// @param extraArgs extra data needed for swap on particular platforms
    struct SwapAndRepayParams {
        address payable swapContract;
        address payable lendingContract;
        uint256 srcAmount;
        uint256 payAmount;
        address[] tradePath;
        uint256 rateMode; // for aave v2
        FeeMode feeMode;
        uint256 feeBps;
        address payable platformWallet;
        bytes extraArgs;
    }

    function swapAndRepay(SwapAndRepayParams calldata params)
        external
        payable
        returns (uint256 destAmount);

    function claimPlatformFees(address[] calldata platformWallets, IERC20Ext[] calldata tokens)
        external;
}

File 6 of 15 : SmartWalletStorage.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;

import "@kyber.network/utils-sc/contracts/IERC20Ext.sol";
import "@kyber.network/utils-sc/contracts/Utils.sol";
import "@kyber.network/utils-sc/contracts/Withdrawable.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/EnumerableSet.sol";

contract SmartWalletStorage is Utils, Withdrawable, ReentrancyGuard {
    uint256 internal constant MAX_AMOUNT = type(uint256).max;

    mapping(address => mapping(IERC20Ext => uint256)) public platformWalletFees;

    EnumerableSet.AddressSet internal supportedPlatformWallets;
    
    EnumerableSet.AddressSet internal supportedSwaps;

    EnumerableSet.AddressSet internal supportedLendings;

    // [EIP-1967] bytes32(uint256(keccak256("SmartWalletImplementation")) - 1)
    bytes32 internal constant IMPLEMENTATION =
        0x7cf58d76330f82325c2a503c72b55abca3eb533fadde43d95e3c0cceb1583e99;

    constructor(address _admin) Withdrawable(_admin) {}
}

File 7 of 15 : ISwap.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma abicoder v2;

interface ISwap {
    struct GetExpectedReturnParams {
        uint256 srcAmount;
        address[] tradePath;
        uint256 feeBps;
        bytes extraArgs;
    }

    function getExpectedReturn(GetExpectedReturnParams calldata params)
        external
        view
        returns (uint256 destAmount);

    struct GetExpectedInParams {
        uint256 destAmount;
        address[] tradePath;
        uint256 feeBps;
        bytes extraArgs;
    }

    function getExpectedIn(GetExpectedInParams calldata params)
        external
        view
        returns (uint256 srcAmount);

    struct SwapParams {
        uint256 srcAmount;
        // min return for uni, min conversionrate for kyber, etc.
        uint256 minDestAmount;
        address[] tradePath;
        address recipient;
        uint256 feeBps;
        address payable feeReceiver;
        bytes extraArgs;
    }

    function swap(SwapParams calldata params) external payable returns (uint256 destAmount);
}

File 8 of 15 : ILending.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.7.6;
pragma experimental ABIEncoderV2;

import "@kyber.network/utils-sc/contracts/IERC20Ext.sol";

interface ILending {
    function depositTo(
        address payable onBehalfOf,
        IERC20Ext token,
        uint256 amount
    ) external;

    function withdrawFrom(
        address payable onBehalfOf,
        IERC20Ext token,
        uint256 amount,
        uint256 minReturn
    ) external returns (uint256 returnedAmount);

    function repayBorrowTo(
        address payable onBehalfOf,
        IERC20Ext token,
        uint256 amount,
        uint256 payAmount,
        bytes calldata extraArgs // for extra data .i.e aave rateMode
    ) external;

    function getUserDebtCurrent(address _reserve, address _user) external returns (uint256 debt);

    function getLendingToken(IERC20Ext token) external view returns (address);
}

File 9 of 15 : IERC20.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20 {
    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

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

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

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

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

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

File 10 of 15 : SafeMath.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when an
 * operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        uint256 c = a + b;
        if (c < a) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the substraction of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b > a) return (false, 0);
        return (true, a - b);
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
     *
     * _Available since v3.4._
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) return (true, 0);
        uint256 c = a * b;
        if (c / a != b) return (false, 0);
        return (true, c);
    }

    /**
     * @dev Returns the division of two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a / b);
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
     *
     * _Available since v3.4._
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
        if (b == 0) return (false, 0);
        return (true, a % b);
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");
        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a, "SafeMath: subtraction overflow");
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        if (a == 0) return 0;
        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");
        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: division by zero");
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b > 0, "SafeMath: modulo by zero");
        return a % b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
     * overflow (when the result is negative).
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {trySub}.
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        return a - b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting with custom message on
     * division by zero. The result is rounded towards zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryDiv}.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a / b;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * reverting with custom message when dividing by zero.
     *
     * CAUTION: This function is deprecated because it requires allocating memory for the error
     * message unnecessarily. For custom revert reasons use {tryMod}.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b > 0, errorMessage);
        return a % b;
    }
}

File 11 of 15 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/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.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionDelegateCall(target, data, "Address: low-level delegate call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 12 of 15 : Utils.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;

import "./IERC20Ext.sol";


/**
 * @title Kyber utility file
 * mostly shared constants and rate calculation helpers
 * inherited by most of kyber contracts.
 * previous utils implementations are for previous solidity versions.
 */
abstract contract Utils {
    // Declared constants below to be used in tandem with
    // getDecimalsConstant(), for gas optimization purposes
    // which return decimals from a constant list of popular
    // tokens.
    IERC20Ext internal constant ETH_TOKEN_ADDRESS = IERC20Ext(
        0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
    );
    IERC20Ext internal constant USDT_TOKEN_ADDRESS = IERC20Ext(
        0xdAC17F958D2ee523a2206206994597C13D831ec7
    );
    IERC20Ext internal constant DAI_TOKEN_ADDRESS = IERC20Ext(
        0x6B175474E89094C44Da98b954EedeAC495271d0F
    );
    IERC20Ext internal constant USDC_TOKEN_ADDRESS = IERC20Ext(
        0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
    );
    IERC20Ext internal constant WBTC_TOKEN_ADDRESS = IERC20Ext(
        0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599
    );
    IERC20Ext internal constant KNC_TOKEN_ADDRESS = IERC20Ext(
        0xdd974D5C2e2928deA5F71b9825b8b646686BD200
    );
    uint256 public constant BPS = 10000; // Basic Price Steps. 1 step = 0.01%
    uint256 internal constant PRECISION = (10**18);
    uint256 internal constant MAX_QTY = (10**28); // 10B tokens
    uint256 internal constant MAX_RATE = (PRECISION * 10**7); // up to 10M tokens per eth
    uint256 internal constant MAX_DECIMALS = 18;
    uint256 internal constant ETH_DECIMALS = 18;
    uint256 internal constant MAX_ALLOWANCE = uint256(-1); // token.approve inifinite

    mapping(IERC20Ext => uint256) internal decimals;

    /// @dev Sets the decimals of a token to storage if not already set, and returns
    ///      the decimals value of the token. Prefer using this function over
    ///      getDecimals(), to avoid forgetting to set decimals in local storage.
    /// @param token The token type
    /// @return tokenDecimals The decimals of the token
    function getSetDecimals(IERC20Ext token) internal returns (uint256 tokenDecimals) {
        tokenDecimals = getDecimalsConstant(token);
        if (tokenDecimals > 0) return tokenDecimals;

        tokenDecimals = decimals[token];
        if (tokenDecimals == 0) {
            tokenDecimals = token.decimals();
            decimals[token] = tokenDecimals;
        }
    }

    /// @dev Get the balance of a user
    /// @param token The token type
    /// @param user The user's address
    /// @return The balance
    function getBalance(IERC20Ext token, address user) internal view returns (uint256) {
        if (token == ETH_TOKEN_ADDRESS) {
            return user.balance;
        } else {
            return token.balanceOf(user);
        }
    }

    /// @dev Get the decimals of a token, read from the constant list, storage,
    ///      or from token.decimals(). Prefer using getSetDecimals when possible.
    /// @param token The token type
    /// @return tokenDecimals The decimals of the token
    function getDecimals(IERC20Ext token) internal view returns (uint256 tokenDecimals) {
        // return token decimals if has constant value
        tokenDecimals = getDecimalsConstant(token);
        if (tokenDecimals > 0) return tokenDecimals;

        // handle case where token decimals is not a declared decimal constant
        tokenDecimals = decimals[token];
        // moreover, very possible that old tokens have decimals 0
        // these tokens will just have higher gas fees.
        return (tokenDecimals > 0) ? tokenDecimals : token.decimals();
    }

    function calcDestAmount(
        IERC20Ext src,
        IERC20Ext dest,
        uint256 srcAmount,
        uint256 rate
    ) internal view returns (uint256) {
        return calcDstQty(srcAmount, getDecimals(src), getDecimals(dest), rate);
    }

    function calcSrcAmount(
        IERC20Ext src,
        IERC20Ext dest,
        uint256 destAmount,
        uint256 rate
    ) internal view returns (uint256) {
        return calcSrcQty(destAmount, getDecimals(src), getDecimals(dest), rate);
    }

    function calcDstQty(
        uint256 srcQty,
        uint256 srcDecimals,
        uint256 dstDecimals,
        uint256 rate
    ) internal pure returns (uint256) {
        require(srcQty <= MAX_QTY, "srcQty > MAX_QTY");
        require(rate <= MAX_RATE, "rate > MAX_RATE");

        if (dstDecimals >= srcDecimals) {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS");
            return (srcQty * rate * (10**(dstDecimals - srcDecimals))) / PRECISION;
        } else {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS");
            return (srcQty * rate) / (PRECISION * (10**(srcDecimals - dstDecimals)));
        }
    }

    function calcSrcQty(
        uint256 dstQty,
        uint256 srcDecimals,
        uint256 dstDecimals,
        uint256 rate
    ) internal pure returns (uint256) {
        require(dstQty <= MAX_QTY, "dstQty > MAX_QTY");
        require(rate <= MAX_RATE, "rate > MAX_RATE");

        //source quantity is rounded up. to avoid dest quantity being too low.
        uint256 numerator;
        uint256 denominator;
        if (srcDecimals >= dstDecimals) {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS");
            numerator = (PRECISION * dstQty * (10**(srcDecimals - dstDecimals)));
            denominator = rate;
        } else {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS");
            numerator = (PRECISION * dstQty);
            denominator = (rate * (10**(dstDecimals - srcDecimals)));
        }
        return (numerator + denominator - 1) / denominator; //avoid rounding down errors
    }

    function calcRateFromQty(
        uint256 srcAmount,
        uint256 destAmount,
        uint256 srcDecimals,
        uint256 dstDecimals
    ) internal pure returns (uint256) {
        require(srcAmount <= MAX_QTY, "srcAmount > MAX_QTY");
        require(destAmount <= MAX_QTY, "destAmount > MAX_QTY");

        if (dstDecimals >= srcDecimals) {
            require((dstDecimals - srcDecimals) <= MAX_DECIMALS, "dst - src > MAX_DECIMALS");
            return ((destAmount * PRECISION) / ((10**(dstDecimals - srcDecimals)) * srcAmount));
        } else {
            require((srcDecimals - dstDecimals) <= MAX_DECIMALS, "src - dst > MAX_DECIMALS");
            return ((destAmount * PRECISION * (10**(srcDecimals - dstDecimals))) / srcAmount);
        }
    }

    /// @dev save storage access by declaring token decimal constants
    /// @param token The token type
    /// @return token decimals
    function getDecimalsConstant(IERC20Ext token) internal pure returns (uint256) {
        if (token == ETH_TOKEN_ADDRESS) {
            return ETH_DECIMALS;
        } else if (token == USDT_TOKEN_ADDRESS) {
            return 6;
        } else if (token == DAI_TOKEN_ADDRESS) {
            return 18;
        } else if (token == USDC_TOKEN_ADDRESS) {
            return 6;
        } else if (token == WBTC_TOKEN_ADDRESS) {
            return 8;
        } else if (token == KNC_TOKEN_ADDRESS) {
            return 18;
        } else {
            return 0;
        }
    }

    function minOf(uint256 x, uint256 y) internal pure returns (uint256) {
        return x > y ? y : x;
    }
}

File 13 of 15 : Withdrawable.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;

import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./IERC20Ext.sol";
import "./PermissionAdmin.sol";


abstract contract Withdrawable is PermissionAdmin {
    using SafeERC20 for IERC20Ext;

    event TokenWithdraw(IERC20Ext token, uint256 amount, address sendTo);
    event EtherWithdraw(uint256 amount, address sendTo);

    constructor(address _admin) PermissionAdmin(_admin) {}

    /**
     * @dev Withdraw all IERC20Ext compatible tokens
     * @param token IERC20Ext The address of the token contract
     */
    function withdrawToken(
        IERC20Ext token,
        uint256 amount,
        address sendTo
    ) external onlyAdmin {
        token.safeTransfer(sendTo, amount);
        emit TokenWithdraw(token, amount, sendTo);
    }

    /**
     * @dev Withdraw Ethers
     */
    function withdrawEther(uint256 amount, address payable sendTo) external onlyAdmin {
        (bool success, ) = sendTo.call{value: amount}("");
        require(success, "withdraw failed");
        emit EtherWithdraw(amount, sendTo);
    }
}

File 14 of 15 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor () internal {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;

        _;

        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }
}

File 15 of 15 : PermissionAdmin.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.7.6;


abstract contract PermissionAdmin {
    address public admin;
    address public pendingAdmin;

    event AdminClaimed(address newAdmin, address previousAdmin);

    event TransferAdminPending(address pendingAdmin);

    constructor(address _admin) {
        require(_admin != address(0), "admin 0");
        admin = _admin;
    }

    modifier onlyAdmin() {
        require(msg.sender == admin, "only admin");
        _;
    }

    /**
     * @dev Allows the current admin to set the pendingAdmin address.
     * @param newAdmin The address to transfer ownership to.
     */
    function transferAdmin(address newAdmin) public onlyAdmin {
        require(newAdmin != address(0), "new admin 0");
        emit TransferAdminPending(newAdmin);
        pendingAdmin = newAdmin;
    }

    /**
     * @dev Allows the current admin to set the admin in one tx. Useful initial deployment.
     * @param newAdmin The address to transfer ownership to.
     */
    function transferAdminQuickly(address newAdmin) public onlyAdmin {
        require(newAdmin != address(0), "admin 0");
        emit TransferAdminPending(newAdmin);
        emit AdminClaimed(newAdmin, admin);
        admin = newAdmin;
    }

    /**
     * @dev Allows the pendingAdmin address to finalize the change admin process.
     */
    function claimAdmin() public {
        require(pendingAdmin == msg.sender, "not pending");
        emit AdminClaimed(pendingAdmin, admin);
        admin = pendingAdmin;
        pendingAdmin = address(0);
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 780
  },
  "metadata": {
    "bytecodeHash": "none"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"_admin","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"}],"name":"AdminClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20Ext[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"address[]","name":"spenders","type":"address[]"},{"indexed":false,"internalType":"bool","name":"isReset","type":"bool"}],"name":"ApprovedAllowances","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"wallets","type":"address[]"},{"indexed":false,"internalType":"contract IERC20Ext[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"address","name":"claimer","type":"address"}],"name":"ClaimedPlatformFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"EtherWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"swapContract","type":"address"},{"indexed":false,"internalType":"address[]","name":"tradePath","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destAmount","type":"uint256"},{"indexed":false,"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"feeBps","type":"uint256"},{"indexed":false,"internalType":"address","name":"platformWallet","type":"address"}],"name":"Swap","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"swapContract","type":"address"},{"indexed":true,"internalType":"address","name":"lendingContract","type":"address"},{"indexed":false,"internalType":"address[]","name":"tradePath","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destAmount","type":"uint256"},{"indexed":false,"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"feeBps","type":"uint256"},{"indexed":false,"internalType":"address","name":"platformWallet","type":"address"}],"name":"SwapAndDeposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"swapContract","type":"address"},{"indexed":true,"internalType":"address","name":"lendingContract","type":"address"},{"indexed":false,"internalType":"address[]","name":"tradePath","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"srcAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"destAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payAmount","type":"uint256"},{"indexed":false,"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"indexed":false,"internalType":"uint256","name":"feeBps","type":"uint256"},{"indexed":false,"internalType":"address","name":"platformWallet","type":"address"}],"name":"SwapAndRepay","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC20Ext","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"address","name":"sendTo","type":"address"}],"name":"TokenWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"pendingAdmin","type":"address"}],"name":"TransferAdminPending","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":true,"internalType":"address","name":"lendingContract","type":"address"},{"indexed":false,"internalType":"contract IERC20Ext","name":"token","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"minReturn","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"actualReturnAmount","type":"uint256"}],"name":"WithdrawFromLending","type":"event"},{"inputs":[],"name":"BPS","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20Ext[]","name":"tokens","type":"address[]"},{"internalType":"address[]","name":"spenders","type":"address[]"},{"internalType":"bool","name":"isReset","type":"bool"}],"name":"approveAllowances","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"claimAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"platformWallets","type":"address[]"},{"internalType":"contract IERC20Ext[]","name":"tokens","type":"address[]"}],"name":"claimPlatformFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"swapContract","type":"address"},{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISmartWalletImplementation.GetExpectedInParams","name":"params","type":"tuple"}],"name":"getExpectedIn","outputs":[{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"expectedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"swapContract","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISmartWalletImplementation.GetExpectedReturnParams","name":"params","type":"tuple"}],"name":"getExpectedReturn","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"},{"internalType":"uint256","name":"expectedRate","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"contract IERC20Ext","name":"","type":"address"}],"name":"platformWalletFees","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"swapContract","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"minDestAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"address payable","name":"platformWallet","type":"address"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISmartWalletImplementation.SwapParams","name":"params","type":"tuple"}],"name":"swap","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"swapContract","type":"address"},{"internalType":"address payable","name":"lendingContract","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"minDestAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"address payable","name":"platformWallet","type":"address"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISmartWalletImplementation.SwapAndDepositParams","name":"params","type":"tuple"}],"name":"swapAndDeposit","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"swapContract","type":"address"},{"internalType":"address payable","name":"lendingContract","type":"address"},{"internalType":"uint256","name":"srcAmount","type":"uint256"},{"internalType":"uint256","name":"payAmount","type":"uint256"},{"internalType":"address[]","name":"tradePath","type":"address[]"},{"internalType":"uint256","name":"rateMode","type":"uint256"},{"internalType":"enum ISmartWalletImplementation.FeeMode","name":"feeMode","type":"uint8"},{"internalType":"uint256","name":"feeBps","type":"uint256"},{"internalType":"address payable","name":"platformWallet","type":"address"},{"internalType":"bytes","name":"extraArgs","type":"bytes"}],"internalType":"struct ISmartWalletImplementation.SwapAndRepayParams","name":"params","type":"tuple"}],"name":"swapAndRepay","outputs":[{"internalType":"uint256","name":"destAmount","type":"uint256"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdminQuickly","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address payable","name":"sendTo","type":"address"}],"name":"withdrawEther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address payable","name":"lendingContract","type":"address"},{"internalType":"contract IERC20Ext","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"minReturn","type":"uint256"}],"internalType":"struct ISmartWalletImplementation.WithdrawFromLendingPlatformParams","name":"params","type":"tuple"}],"name":"withdrawFromLendingPlatform","outputs":[{"internalType":"uint256","name":"returnedAmount","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC20Ext","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"sendTo","type":"address"}],"name":"withdrawToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523480156200001157600080fd5b5060405162003bc338038062003bc38339810160408190526200003491620000aa565b8080806001600160a01b0381166200007d576040805162461bcd60e51b8152602060048201526007602482015266061646d696e20360cc1b604482015290519081900360640190fd5b600180546001600160a01b0319166001600160a01b039290921691909117815560035550620000da915050565b600060208284031215620000bc578081fd5b81516001600160a01b0381168114620000d3578182fd5b9392505050565b613ad980620000ea6000396000f3fe6080604052600436106101125760003560e01c80637acc8678116100a5578063ce56c45411610074578063e28c413511610059578063e28c4135146102d6578063f851a440146102f6578063fcd1f1481461030b57610119565b8063ce56c45414610288578063d282662f146102a857610119565b80637acc867814610215578063a03f2a0b14610235578063a7c4779714610248578063bc6555431461026857610119565b806335c7c3cf116100e157806335c7c3cf1461019e5780633ccdbb28146101c057806375829def146101e057806377f50f971461020057610119565b806323fcd0c91461011e578063249d39e91461015457806326782247146101695780632db897d01461018b57610119565b3661011957005b600080fd5b34801561012a57600080fd5b5061013e610139366004613298565b61031e565b60405161014b9190613449565b60405180910390f35b34801561016057600080fd5b5061013e610704565b34801561017557600080fd5b5061017e61070a565b60405161014b9190613452565b61013e61019936600461325f565b610719565b3480156101aa57600080fd5b506101be6101b936600461306c565b61086e565b005b3480156101cc57600080fd5b506101be6101db36600461315a565b610aa6565b3480156101ec57600080fd5b506101be6101fb366004612ffc565b610b55565b34801561020c57600080fd5b506101be610c67565b34801561022157600080fd5b506101be610230366004612ffc565b610d46565b61013e6102433660046131ed565b610ea0565b34801561025457600080fd5b5061013e610263366004613034565b6111de565b34801561027457600080fd5b506101be6102833660046130d5565b6111fb565b34801561029457600080fd5b506101be6102a33660046132c1565b61134a565b3480156102b457600080fd5b506102c86102c33660046131ba565b611484565b60405161014b929190613973565b3480156102e257600080fd5b506102c86102f13660046131ba565b6116e8565b34801561030257600080fd5b5061017e6118ed565b61013e610319366004613226565b6118fc565b600060026003541415610378576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260035561039561038d6020840184612ffc565b600990611e4b565b6103ba5760405162461bcd60e51b81526004016103b190613651565b60405180910390fd5b60006103c96020840184612ffc565b6001600160a01b03166310c760776103e76040860160208701612ffc565b6040518263ffffffff1660e01b81526004016104039190613452565b60206040518083038186803b15801561041b57600080fd5b505afa15801561042f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104539190613018565b90506001600160a01b03811661047b5760405162461bcd60e51b81526004016103b1906136f6565b60006001600160a01b0382166370a082316104996020870187612ffc565b6040518263ffffffff1660e01b81526004016104b59190613452565b60206040518083038186803b1580156104cd57600080fd5b505afa1580156104e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050591906132a9565b905061052e336105186020870187612ffc565b6001600160a01b03851691906040880135611e69565b60006001600160a01b0383166370a0823161054c6020880188612ffc565b6040518263ffffffff1660e01b81526004016105689190613452565b60206040518083038186803b15801561058057600080fd5b505afa158015610594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b891906132a9565b90506105c76020860186612ffc565b6001600160a01b031663d4fdc309336105e66040890160208a01612ffc565b6105f08587611ec9565b89606001356040518563ffffffff1660e01b8152600401610614949392919061348a565b602060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066691906132a9565b9350846060013584101561068c5760405162461bcd60e51b81526004016103b190613840565b6106996020860186612ffc565b6001600160a01b0316337f8535f320ef164ed88035c05c538ac8c71ab5fba9c64bc06794378060332042fc6106d46040890160208a01612ffc565b88604001358960600135896040516106ef949392919061362b565b60405180910390a35050600160035550919050565b61271081565b6002546001600160a01b031681565b600060026003541415610773576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026003556107d76107886020840184612ffc565b6020840135604085013561079f6060870187613981565b336107b060a08a0160808b0161319b565b60a08a01356107c560e08c0160c08d01612ffc565b6107d260e08d018d6139c8565b611f26565b90506107e66020830183612ffc565b6001600160a01b0316337ff23fb97e8642200d71532c9c5ae884a9236ca6b8eb58fed071a7cc3f2ac4161d61081e6060860186613981565b60208701358661083460a08a0160808b0161319b565b60a08a013561084960e08c0160c08d01612ffc565b60405161085c9796959493929190613548565b60405180910390a36001600355919050565b600260035414156108c6576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260035560005b83811015610a5b5760005b82811015610a52576000600460008888868181106108f357fe5b90506020020160208101906109089190612ffc565b6001600160a01b03166001600160a01b03168152602001908152602001600020600086868581811061093657fe5b905060200201602081019061094b9190612ffc565b6001600160a01b03166001600160a01b031681526020019081526020016000205490506001811115610a495760016004600089898781811061098957fe5b905060200201602081019061099e9190612ffc565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008787868181106109cc57fe5b90506020020160208101906109e19190612ffc565b6001600160a01b03168152602081019190915260400160002055610a49878785818110610a0a57fe5b9050602002016020810190610a1f9190612ffc565b868685818110610a2b57fe5b9050602002016020810190610a409190612ffc565b600184036121ef565b506001016108d9565b506001016108ce565b507fcbef5ab8ab58a3dba86704ce124241889d80c3a5fe3caaf4286b7e8c709a6c2d8484848433604051610a93959493929190613505565b60405180910390a1505060016003555050565b6001546001600160a01b03163314610af2576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b610b066001600160a01b03841682846122b9565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b6001546001600160a01b03163314610ba1576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610bfc576040805162461bcd60e51b815260206004820152600b60248201527f6e65772061646d696e2030000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a16002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6002546001600160a01b03163314610cc6576040805162461bcd60e51b815260206004820152600b60248201527f6e6f742070656e64696e67000000000000000000000000000000000000000000604482015290519081900360640190fd5b600254600154604080516001600160a01b03938416815292909116602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a1600280546001805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03841617909155169055565b6001546001600160a01b03163314610d92576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610ded576040805162461bcd60e51b815260206004820152600760248201527f61646d696e203000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600154604080516001600160a01b038085168252909216602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a16001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600060026003541415610efa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026003556001610f0e6080840184613981565b90501015610f2e5760405162461bcd60e51b81526004016103b190613877565b610f4161038d6040840160208501612ffc565b610f5d5760405162461bcd60e51b81526004016103b190613651565b610f6a6080830183613981565b90506001141561101357610fae610f846080840184613981565b6000818110610f8f57fe5b9050602002016020810190610fa49190612ffc565b836040013561230b565b61100c33610fc26040850160208601612ffc565b610fcf6080860186613981565b6000818110610fda57fe5b9050602002016020810190610fef9190612ffc565b60408601356000611007610100890160e08a01612ffc565b612376565b9050611081565b61107e6110236020840184612ffc565b6040840135606085013561103a6080870187613981565b61104a6040890160208a01612ffc565b61105a60c08a0160a08b0161319b565b60c08a01356110706101008c0160e08d01612ffc565b6107d26101008d018d6139c8565b90505b6110916040830160208401612ffc565b6001600160a01b031663f213159c336110ad6080860186613981565b60016110bc6080890189613981565b9050038181106110c857fe5b90506020020160208101906110dd9190612ffc565b846040518463ffffffff1660e01b81526004016110fc93929190613466565b600060405180830381600087803b15801561111657600080fd5b505af115801561112a573d6000803e3d6000fd5b5061113f925050506040830160208401612ffc565b6001600160a01b03166111556020840184612ffc565b6001600160a01b0316337f2edafe685397c056fa62be1804788786cdeac9ce01277e8216c4a3718011572361118d6080870187613981565b6040880135876111a360c08b0160a08c0161319b565b60c08b01356111b96101008d0160e08e01612ffc565b6040516111cc9796959493929190613548565b60405180910390a46001600355919050565b600460209081526000928352604080842090915290825290205481565b6001546001600160a01b03163314611247576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b60008161125657600019611259565b60005b905060005b858110156113025760005b848110156112cf576112c786868381811061128057fe5b90506020020160208101906112959190612ffc565b848a8a868181106112a257fe5b90506020020160208101906112b79190612ffc565b6001600160a01b031691906125c0565b600101611269565b506112f98787838181106112df57fe5b90506020020160208101906112f49190612ffc565b6126d3565b5060010161125e565b507ff34c5ed704407ea33d210cd1c76959be869adc80531ee3b3c93229fb606ac16e868686868660405161133a9594939291906135ef565b60405180910390a1505050505050565b6001546001600160a01b03163314611396576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d80600081146113e1576040519150601f19603f3d011682016040523d82523d6000602084013e6113e6565b606091505b505090508061143c576040805162461bcd60e51b815260206004820152600f60248201527f7769746864726177206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b60008061271083608001351061149f575060009050806116e3565b600060016114b3608086016060870161319b565b60028111156114be57fe5b146114cd5783602001356114df565b61271060208501356080860135820102045b90506114ee6020850185612ffc565b6001600160a01b0316634db1d03d604051806080016040528084815260200187806040019061151d9190613981565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001600261156660808a0160608b0161319b565b600281111561157157fe5b1461157d576000611583565b87608001355b815260200161159560a08901896139c8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b1681526115ec91906004016138e5565b60206040518083038186803b15801561160457600080fd5b505afa158015611618573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163c91906132a9565b92506000611650608086016060870161319b565b600281111561165b57fe5b1415611671576127106080850135810184020492505b6116df8360208601356116af61168a6040890189613981565b600081811061169557fe5b90506020020160208101906116aa9190612ffc565b612798565b6116da6116bf60408a018a613981565b60016116ce60408d018d613981565b90500381811061169557fe5b61283c565b9150505b915091565b600080612710836080013510611703575060009050806116e3565b600080611716608086016060870161319b565b600281111561172157fe5b14611730578360200135611742565b61271060208501356080860135820302045b90506117516020850185612ffc565b6001600160a01b03166343bea4b360405180608001604052808481526020018780604001906117809190613981565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060200160026117c960808a0160608b0161319b565b60028111156117d457fe5b146117e05760006117e6565b87608001355b81526020016117f860a08901896139c8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b16815261184f91906004016138e5565b60206040518083038186803b15801561186757600080fd5b505afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906132a9565b925060016118b3608086016060870161319b565b60028111156118be57fe5b14156118d4576127106080850135810384020492505b6116df6020850135846116af61168a6040890189613981565b6001546001600160a01b031681565b600060026003541415611956576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600355600161196a6080840184613981565b9050101561198a5760405162461bcd60e51b81526004016103b190613877565b61199d61038d6040840160208501612ffc565b6119b95760405162461bcd60e51b81526004016103b190613651565b60006119cb6040840160208501612ffc565b6001600160a01b031663e5c641b66119e66080860186613981565b60016119f56080890189613981565b905003818110611a0157fe5b9050602002016020810190611a169190612ffc565b336040518363ffffffff1660e01b8152600401611a349291906134eb565b602060405180830381600087803b158015611a4e57600080fd5b505af1158015611a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8691906132a9565b905060008360600135821015611a9c5781611aa2565b83606001355b9050611ab16080850185613981565b905060011415611b5657611af5611acb6080860186613981565b6000818110611ad657fe5b9050602002016020810190611aeb9190612ffc565b856040013561230b565b611b4f33611b096040870160208801612ffc565b611b166080880188613981565b6000818110611b2157fe5b9050602002016020810190611b369190612ffc565b604088013560006110076101208b016101008c01612ffc565b9250611bc1565b611bbe611b666020860186612ffc565b604086013583611b796080890189613981565b611b8960408b0160208c01612ffc565b611b9960e08c0160c08d0161319b565b60e08c0135611bb06101208e016101008f01612ffc565b6107d26101208f018f6139c8565b92505b611bd16040850160208601612ffc565b6001600160a01b03166339c3158a33611bed6080880188613981565b6001611bfc60808b018b613981565b905003818110611c0857fe5b9050602002016020810190611c1d9190612ffc565b86858960a00135604051602001611c349190613449565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611c639594939291906134b3565b600060405180830381600087803b158015611c7d57600080fd5b505af1158015611c91573d6000803e3d6000fd5b505050506000611d6f856020016020810190611cad9190612ffc565b6001600160a01b031663e5c641b6611cc86080890189613981565b6001611cd760808c018c613981565b905003818110611ce357fe5b9050602002016020810190611cf89190612ffc565b336040518363ffffffff1660e01b8152600401611d169291906134eb565b602060405180830381600087803b158015611d3057600080fd5b505af1158015611d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6891906132a9565b8490611ec9565b905081811015611d915760405162461bcd60e51b81526004016103b190613764565b611da16040860160208701612ffc565b6001600160a01b0316611db76020870187612ffc565b6001600160a01b0316337f3b623be279df32a44c2edd16708b64a952bd614abdd2a3bc2572786eaefd5ab3611def60808a018a613981565b8a604001358a898d60c0016020810190611e09919061319b565b8e60e001358f610100016020810190611e229190612ffc565b604051611e36989796959493929190613598565b60405180910390a45050600160035550919050565b6000611e60836001600160a01b0384166129fb565b90505b92915050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611ec3908590612a13565b50505050565b600082821115611f20576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000611f3360078d611e4b565b611f4f5760405162461bcd60e51b81526004016103b1906136bf565b6002881015611f705760405162461bcd60e51b81526004016103b190613877565b6127108510611f915760405162461bcd60e51b81526004016103b19061379b565b611fbc89896000818110611fa157fe5b9050602002016020810190611fb69190612ffc565b8c61230b565b6000612008338e8c8c6000818110611fd057fe5b9050602002016020810190611fe59190612ffc565b8f60008c6002811115611ff457fe5b14612000576000612002565b8a5b8a612376565b90506000600188600281111561201a57fe5b146120255788612027565b305b90508d6001600160a01b03166368aa6dd96040518060e001604052808581526020018f81526020018e8e808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506001600160a01b038516602082015260400160028c60028111156120a557fe5b146120b15760006120b3565b8a5b8152602001896001600160a01b0316815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b16815261212091906004016138f8565b602060405180830381600087803b15801561213a57600080fd5b505af115801561214e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217291906132a9565b92506001905087600281111561218457fe5b14156121bf576121bc30898c8c600019810181811061219f57fe5b90506020020160208101906121b49190612ffc565b858a8a612376565b91505b8a8210156121df5760405162461bcd60e51b81526004016103b1906137d2565b509b9a5050505050505050505050565b806121f9576122b4565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156122a0576000836001600160a01b03168260405161223790613446565b60006040518083038185875af1925050503d8060008114612274576040519150601f19603f3d011682016040523d82523d6000602084013e612279565b606091505b505090508061229a5760405162461bcd60e51b81526004016103b1906138ae565b506122b4565b6122b46001600160a01b03831684836122b9565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526122b4908490612a13565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156123545780341461234f5760405162461bcd60e51b81526004016103b190613688565b612372565b34156123725760405162461bcd60e51b81526004016103b190613809565b5050565b60008061238f6127106123898787612ac4565b90612b1d565b9050600061239d8683611ec9565b9050866001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561244a576000896001600160a01b0316836040516123de90613446565b60006040518083038185875af1925050503d806000811461241b576040519150601f19603f3d011682016040523d82523d6000602084013e612420565b606091505b50509050806124415760405162461bcd60e51b81526004016103b1906138ae565b829450506125a8565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190612479908d90600401613452565b60206040518083038186803b15801561249157600080fd5b505afa1580156124a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c991906132a9565b90506001600160a01b038b16301461250a576124f06001600160a01b0383168c8c86611e69565b6125056001600160a01b0383168c3087611e69565b61251e565b61251e6001600160a01b0383168b856122b9565b6125a481836001600160a01b03166370a082318d6040518263ffffffff1660e01b815260040161254e9190613452565b60206040518083038186803b15801561256657600080fd5b505afa15801561257a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259e91906132a9565b90611ec9565b9450505b6125b3858285612b84565b5050509695505050505050565b801580612646575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561261857600080fd5b505afa15801561262c573d6000803e3d6000fd5b505050506040513d602081101561264257600080fd5b5051155b6126815760405162461bcd60e51b8152600401808060200182810382526036815260200180613a976036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526122b4908490612a13565b60006126de82612c0c565b905080156126eb57612793565b506001600160a01b0381166000908152602081905260409020548061279357816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561274357600080fd5b505afa158015612757573d6000803e3d6000fd5b505050506040513d602081101561276d57600080fd5b50516001600160a01b038316600090815260208190526040902060ff9091169081905590505b919050565b60006127a382612c0c565b905080156127b057612793565b506001600160a01b0381166000908152602081905260409020548061279357816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561280857600080fd5b505afa15801561281c573d6000803e3d6000fd5b505050506040513d602081101561283257600080fd5b505160ff16611e63565b60006b204fce5e3e2502611000000085111561289f576040805162461bcd60e51b815260206004820152601360248201527f737263416d6f756e74203e204d41585f51545900000000000000000000000000604482015290519081900360640190fd5b6b204fce5e3e25026110000000841115612900576040805162461bcd60e51b815260206004820152601460248201527f64657374416d6f756e74203e204d41585f515459000000000000000000000000604482015290519081900360640190fd5b828210612981576012838303111561295f576040805162461bcd60e51b815260206004820152601860248201527f647374202d20737263203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b84838303600a0a02670de0b6b3a764000085028161297957fe5b0490506129f3565b601282840311156129d9576040805162461bcd60e51b815260206004820152601860248201527f737263202d20647374203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b84828403600a0a670de0b6b3a76400008602028161297957fe5b949350505050565b60009081526001919091016020526040902054151590565b6000612a68826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d249092919063ffffffff16565b8051909150156122b457808060200190516020811015612a8757600080fd5b50516122b45760405162461bcd60e51b815260040180806020018281038252602a815260200180613a6d602a913960400191505060405180910390fd5b600082612ad357506000611e63565b82820282848281612ae057fe5b0414611e605760405162461bcd60e51b8152600401808060200182810382526021815260200180613a4c6021913960400191505060405180910390fd5b6000808211612b73576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381612b7c57fe5b049392505050565b80156122b457612b95600584611e4b565b612bb15760405162461bcd60e51b81526004016103b19061372d565b6001600160a01b03808416600090815260046020908152604080832093861683529290522054612be19082612d3d565b6001600160a01b03808516600090815260046020908152604080832093871683529290522055505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612c3b57506012612793565b6001600160a01b03821673dac17f958d2ee523a2206206994597c13d831ec71415612c6857506006612793565b6001600160a01b038216736b175474e89094c44da98b954eedeac495271d0f1415612c9557506012612793565b6001600160a01b03821673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481415612cc257506006612793565b6001600160a01b038216732260fac5e5542a773aa44fbcfedf7c193bc2c5991415612cef57506008612793565b6001600160a01b03821673dd974d5c2e2928dea5f71b9825b8b646686bd2001415612d1c57506012612793565b506000612793565b6060612d338484600085612d97565b90505b9392505050565b600082820183811015611e60576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b606082471015612dd85760405162461bcd60e51b8152600401808060200182810382526026815260200180613a266026913960400191505060405180910390fd5b612de185612ef2565b612e32576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310612e705780518252601f199092019160209182019101612e51565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612ed2576040519150601f19603f3d011682016040523d82523d6000602084013e612ed7565b606091505b5091509150612ee7828286612ef8565b979650505050505050565b3b151590565b60608315612f07575081612d36565b825115612f175782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f61578181015183820152602001612f49565b50505050905090810190601f168015612f8e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008083601f840112612fad578182fd5b50813567ffffffffffffffff811115612fc4578182fd5b6020830191508360208083028501011115612fde57600080fd5b9250929050565b600060c08284031215612ff6578081fd5b50919050565b60006020828403121561300d578081fd5b8135611e6081613a0d565b600060208284031215613029578081fd5b8151611e6081613a0d565b60008060408385031215613046578081fd5b823561305181613a0d565b9150602083013561306181613a0d565b809150509250929050565b60008060008060408587031215613081578182fd5b843567ffffffffffffffff80821115613098578384fd5b6130a488838901612f9c565b909650945060208701359150808211156130bc578384fd5b506130c987828801612f9c565b95989497509550505050565b6000806000806000606086880312156130ec578081fd5b853567ffffffffffffffff80821115613103578283fd5b61310f89838a01612f9c565b90975095506020880135915080821115613127578283fd5b5061313488828901612f9c565b9094509250506040860135801515811461314c578182fd5b809150509295509295909350565b60008060006060848603121561316e578283fd5b833561317981613a0d565b925060208401359150604084013561319081613a0d565b809150509250925092565b6000602082840312156131ac578081fd5b813560038110611e60578182fd5b6000602082840312156131cb578081fd5b813567ffffffffffffffff8111156131e1578182fd5b6129f384828501612fe5565b6000602082840312156131fe578081fd5b813567ffffffffffffffff811115613214578182fd5b82016101208185031215611e60578182fd5b600060208284031215613237578081fd5b813567ffffffffffffffff81111561324d578182fd5b82016101408185031215611e60578182fd5b600060208284031215613270578081fd5b813567ffffffffffffffff811115613286578182fd5b82016101008185031215611e60578182fd5b600060808284031215612ff6578081fd5b6000602082840312156132ba578081fd5b5051919050565b600080604083850312156132d3578182fd5b82359150602083013561306181613a0d565b60008284526020808501945082825b8581101561332257813561330781613a0d565b6001600160a01b0316875295820195908201906001016132f4565b509495945050505050565b6000815180845260208085019450808401835b838110156133225781516001600160a01b031687529582019590820190600101613340565b60008284526020808501945082825b8581101561332257813561338781613a0d565b6001600160a01b031687529582019590820190600101613374565b60008151808452815b818110156133c7576020818501810151868301820152016133ab565b818111156133d85782602083870101525b50601f01601f19169290920160200192915050565b600381106133f757fe5b9052565b60008151835260208201516080602085015261341a608085018261332d565b9050604083015160408501526060830151848203606086015261343d82826133a2565b95945050505050565b90565b90815260200190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152612ee760a08301846133a2565b6001600160a01b0392831681529116602082015260400190565b6000606082526135196060830187896132e5565b828103602084015261352c818688613365565b9150506001600160a01b03831660408301529695505050505050565b600060c0825261355c60c08301898b6132e5565b905086602083015285604083015261357760608301866133ed565b8360808301526001600160a01b03831660a083015298975050505050505050565b600060e082526135ac60e083018a8c6132e5565b90508760208301528660408301528560608301526135cd60808301866133ed565b8360a08301526001600160a01b03831660c08301529998505050505050505050565b600060608252613603606083018789613365565b82810360208401526136168186886132e5565b91505082151560408301529695505050505050565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b60208082526013908201527f756e737570706f72746564206c656e64696e6700000000000000000000000000604082015260600190565b6020808252600f908201527f77726f6e67206d73672076616c75650000000000000000000000000000000000604082015260600190565b60208082526010908201527f756e737570706f72746564207377617000000000000000000000000000000000604082015260600190565b60208082526011908201527f756e737570706f7274656420746f6b656e000000000000000000000000000000604082015260600190565b60208082526014908201527f756e737570706f7274656420706c6174666f726d000000000000000000000000604082015260600190565b6020808252600f908201527f6c6f77207061696420616d6f756e740000000000000000000000000000000000604082015260600190565b60208082526011908201527f6869676820706c6174666f726d20666565000000000000000000000000000000604082015260600190565b6020808252600a908201527f6c6f772072657475726e00000000000000000000000000000000000000000000604082015260600190565b6020808252600d908201527f626164206d73672076616c756500000000000000000000000000000000000000604082015260600190565b60208082526013908201527f6c6f772072657475726e656420616d6f756e7400000000000000000000000000604082015260600190565b60208082526011908201527f696e76616c696420747261646550617468000000000000000000000000000000604082015260600190565b6020808252600f908201527f7472616e73666572206661696c65640000000000000000000000000000000000604082015260600190565b600060208252611e6060208301846133fb565b6000602082528251602083015260208301516040830152604083015160e0606084015261392961010084018261332d565b905060608401516001600160a01b038082166080860152608086015160a08601528060a08701511660c0860152505060c0840151601f198483030160e085015261343d82826133a2565b918252602082015260400190565b6000808335601e19843603018112613997578283fd5b83018035915067ffffffffffffffff8211156139b1578283fd5b6020908101925081023603821315612fde57600080fd5b6000808335601e198436030181126139de578283fd5b83018035915067ffffffffffffffff8211156139f8578283fd5b602001915036819003821315612fde57600080fd5b6001600160a01b0381168114613a2257600080fd5b5056fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a164736f6c6343000706000a000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da7278

Deployed Bytecode

0x6080604052600436106101125760003560e01c80637acc8678116100a5578063ce56c45411610074578063e28c413511610059578063e28c4135146102d6578063f851a440146102f6578063fcd1f1481461030b57610119565b8063ce56c45414610288578063d282662f146102a857610119565b80637acc867814610215578063a03f2a0b14610235578063a7c4779714610248578063bc6555431461026857610119565b806335c7c3cf116100e157806335c7c3cf1461019e5780633ccdbb28146101c057806375829def146101e057806377f50f971461020057610119565b806323fcd0c91461011e578063249d39e91461015457806326782247146101695780632db897d01461018b57610119565b3661011957005b600080fd5b34801561012a57600080fd5b5061013e610139366004613298565b61031e565b60405161014b9190613449565b60405180910390f35b34801561016057600080fd5b5061013e610704565b34801561017557600080fd5b5061017e61070a565b60405161014b9190613452565b61013e61019936600461325f565b610719565b3480156101aa57600080fd5b506101be6101b936600461306c565b61086e565b005b3480156101cc57600080fd5b506101be6101db36600461315a565b610aa6565b3480156101ec57600080fd5b506101be6101fb366004612ffc565b610b55565b34801561020c57600080fd5b506101be610c67565b34801561022157600080fd5b506101be610230366004612ffc565b610d46565b61013e6102433660046131ed565b610ea0565b34801561025457600080fd5b5061013e610263366004613034565b6111de565b34801561027457600080fd5b506101be6102833660046130d5565b6111fb565b34801561029457600080fd5b506101be6102a33660046132c1565b61134a565b3480156102b457600080fd5b506102c86102c33660046131ba565b611484565b60405161014b929190613973565b3480156102e257600080fd5b506102c86102f13660046131ba565b6116e8565b34801561030257600080fd5b5061017e6118ed565b61013e610319366004613226565b6118fc565b600060026003541415610378576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260035561039561038d6020840184612ffc565b600990611e4b565b6103ba5760405162461bcd60e51b81526004016103b190613651565b60405180910390fd5b60006103c96020840184612ffc565b6001600160a01b03166310c760776103e76040860160208701612ffc565b6040518263ffffffff1660e01b81526004016104039190613452565b60206040518083038186803b15801561041b57600080fd5b505afa15801561042f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104539190613018565b90506001600160a01b03811661047b5760405162461bcd60e51b81526004016103b1906136f6565b60006001600160a01b0382166370a082316104996020870187612ffc565b6040518263ffffffff1660e01b81526004016104b59190613452565b60206040518083038186803b1580156104cd57600080fd5b505afa1580156104e1573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061050591906132a9565b905061052e336105186020870187612ffc565b6001600160a01b03851691906040880135611e69565b60006001600160a01b0383166370a0823161054c6020880188612ffc565b6040518263ffffffff1660e01b81526004016105689190613452565b60206040518083038186803b15801561058057600080fd5b505afa158015610594573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105b891906132a9565b90506105c76020860186612ffc565b6001600160a01b031663d4fdc309336105e66040890160208a01612ffc565b6105f08587611ec9565b89606001356040518563ffffffff1660e01b8152600401610614949392919061348a565b602060405180830381600087803b15801561062e57600080fd5b505af1158015610642573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061066691906132a9565b9350846060013584101561068c5760405162461bcd60e51b81526004016103b190613840565b6106996020860186612ffc565b6001600160a01b0316337f8535f320ef164ed88035c05c538ac8c71ab5fba9c64bc06794378060332042fc6106d46040890160208a01612ffc565b88604001358960600135896040516106ef949392919061362b565b60405180910390a35050600160035550919050565b61271081565b6002546001600160a01b031681565b600060026003541415610773576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026003556107d76107886020840184612ffc565b6020840135604085013561079f6060870187613981565b336107b060a08a0160808b0161319b565b60a08a01356107c560e08c0160c08d01612ffc565b6107d260e08d018d6139c8565b611f26565b90506107e66020830183612ffc565b6001600160a01b0316337ff23fb97e8642200d71532c9c5ae884a9236ca6b8eb58fed071a7cc3f2ac4161d61081e6060860186613981565b60208701358661083460a08a0160808b0161319b565b60a08a013561084960e08c0160c08d01612ffc565b60405161085c9796959493929190613548565b60405180910390a36001600355919050565b600260035414156108c6576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b600260035560005b83811015610a5b5760005b82811015610a52576000600460008888868181106108f357fe5b90506020020160208101906109089190612ffc565b6001600160a01b03166001600160a01b03168152602001908152602001600020600086868581811061093657fe5b905060200201602081019061094b9190612ffc565b6001600160a01b03166001600160a01b031681526020019081526020016000205490506001811115610a495760016004600089898781811061098957fe5b905060200201602081019061099e9190612ffc565b6001600160a01b03166001600160a01b0316815260200190815260200160002060008787868181106109cc57fe5b90506020020160208101906109e19190612ffc565b6001600160a01b03168152602081019190915260400160002055610a49878785818110610a0a57fe5b9050602002016020810190610a1f9190612ffc565b868685818110610a2b57fe5b9050602002016020810190610a409190612ffc565b600184036121ef565b506001016108d9565b506001016108ce565b507fcbef5ab8ab58a3dba86704ce124241889d80c3a5fe3caaf4286b7e8c709a6c2d8484848433604051610a93959493929190613505565b60405180910390a1505060016003555050565b6001546001600160a01b03163314610af2576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b610b066001600160a01b03841682846122b9565b604080516001600160a01b0380861682526020820185905283168183015290517f72cb8a894ddb372ceec3d2a7648d86f17d5a15caae0e986c53109b8a9a9385e69181900360600190a1505050565b6001546001600160a01b03163314610ba1576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610bfc576040805162461bcd60e51b815260206004820152600b60248201527f6e65772061646d696e2030000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a16002805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b6002546001600160a01b03163314610cc6576040805162461bcd60e51b815260206004820152600b60248201527f6e6f742070656e64696e67000000000000000000000000000000000000000000604482015290519081900360640190fd5b600254600154604080516001600160a01b03938416815292909116602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a1600280546001805473ffffffffffffffffffffffffffffffffffffffff199081166001600160a01b03841617909155169055565b6001546001600160a01b03163314610d92576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6001600160a01b038116610ded576040805162461bcd60e51b815260206004820152600760248201527f61646d696e203000000000000000000000000000000000000000000000000000604482015290519081900360640190fd5b604080516001600160a01b038316815290517f3b81caf78fa51ecbc8acb482fd7012a277b428d9b80f9d156e8a54107496cc409181900360200190a1600154604080516001600160a01b038085168252909216602083015280517f65da1cfc2c2e81576ad96afb24a581f8e109b7a403b35cbd3243a1c99efdb9ed9281900390910190a16001805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0392909216919091179055565b600060026003541415610efa576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026003556001610f0e6080840184613981565b90501015610f2e5760405162461bcd60e51b81526004016103b190613877565b610f4161038d6040840160208501612ffc565b610f5d5760405162461bcd60e51b81526004016103b190613651565b610f6a6080830183613981565b90506001141561101357610fae610f846080840184613981565b6000818110610f8f57fe5b9050602002016020810190610fa49190612ffc565b836040013561230b565b61100c33610fc26040850160208601612ffc565b610fcf6080860186613981565b6000818110610fda57fe5b9050602002016020810190610fef9190612ffc565b60408601356000611007610100890160e08a01612ffc565b612376565b9050611081565b61107e6110236020840184612ffc565b6040840135606085013561103a6080870187613981565b61104a6040890160208a01612ffc565b61105a60c08a0160a08b0161319b565b60c08a01356110706101008c0160e08d01612ffc565b6107d26101008d018d6139c8565b90505b6110916040830160208401612ffc565b6001600160a01b031663f213159c336110ad6080860186613981565b60016110bc6080890189613981565b9050038181106110c857fe5b90506020020160208101906110dd9190612ffc565b846040518463ffffffff1660e01b81526004016110fc93929190613466565b600060405180830381600087803b15801561111657600080fd5b505af115801561112a573d6000803e3d6000fd5b5061113f925050506040830160208401612ffc565b6001600160a01b03166111556020840184612ffc565b6001600160a01b0316337f2edafe685397c056fa62be1804788786cdeac9ce01277e8216c4a3718011572361118d6080870187613981565b6040880135876111a360c08b0160a08c0161319b565b60c08b01356111b96101008d0160e08e01612ffc565b6040516111cc9796959493929190613548565b60405180910390a46001600355919050565b600460209081526000928352604080842090915290825290205481565b6001546001600160a01b03163314611247576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b60008161125657600019611259565b60005b905060005b858110156113025760005b848110156112cf576112c786868381811061128057fe5b90506020020160208101906112959190612ffc565b848a8a868181106112a257fe5b90506020020160208101906112b79190612ffc565b6001600160a01b031691906125c0565b600101611269565b506112f98787838181106112df57fe5b90506020020160208101906112f49190612ffc565b6126d3565b5060010161125e565b507ff34c5ed704407ea33d210cd1c76959be869adc80531ee3b3c93229fb606ac16e868686868660405161133a9594939291906135ef565b60405180910390a1505050505050565b6001546001600160a01b03163314611396576040805162461bcd60e51b815260206004820152600a60248201526937b7363c9030b236b4b760b11b604482015290519081900360640190fd5b6040516000906001600160a01b0383169084908381818185875af1925050503d80600081146113e1576040519150601f19603f3d011682016040523d82523d6000602084013e6113e6565b606091505b505090508061143c576040805162461bcd60e51b815260206004820152600f60248201527f7769746864726177206661696c65640000000000000000000000000000000000604482015290519081900360640190fd5b604080518481526001600160a01b038416602082015281517fec47e7ed86c86774d1a72c19f35c639911393fe7c1a34031fdbd260890da90de929181900390910190a1505050565b60008061271083608001351061149f575060009050806116e3565b600060016114b3608086016060870161319b565b60028111156114be57fe5b146114cd5783602001356114df565b61271060208501356080860135820102045b90506114ee6020850185612ffc565b6001600160a01b0316634db1d03d604051806080016040528084815260200187806040019061151d9190613981565b80806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250505090825250602001600261156660808a0160608b0161319b565b600281111561157157fe5b1461157d576000611583565b87608001355b815260200161159560a08901896139c8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b1681526115ec91906004016138e5565b60206040518083038186803b15801561160457600080fd5b505afa158015611618573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061163c91906132a9565b92506000611650608086016060870161319b565b600281111561165b57fe5b1415611671576127106080850135810184020492505b6116df8360208601356116af61168a6040890189613981565b600081811061169557fe5b90506020020160208101906116aa9190612ffc565b612798565b6116da6116bf60408a018a613981565b60016116ce60408d018d613981565b90500381811061169557fe5b61283c565b9150505b915091565b600080612710836080013510611703575060009050806116e3565b600080611716608086016060870161319b565b600281111561172157fe5b14611730578360200135611742565b61271060208501356080860135820302045b90506117516020850185612ffc565b6001600160a01b03166343bea4b360405180608001604052808481526020018780604001906117809190613981565b8080602002602001604051908101604052809392919081815260200183836020028082843760009201919091525050509082525060200160026117c960808a0160608b0161319b565b60028111156117d457fe5b146117e05760006117e6565b87608001355b81526020016117f860a08901896139c8565b8080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b16815261184f91906004016138e5565b60206040518083038186803b15801561186757600080fd5b505afa15801561187b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189f91906132a9565b925060016118b3608086016060870161319b565b60028111156118be57fe5b14156118d4576127106080850135810384020492505b6116df6020850135846116af61168a6040890189613981565b6001546001600160a01b031681565b600060026003541415611956576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600355600161196a6080840184613981565b9050101561198a5760405162461bcd60e51b81526004016103b190613877565b61199d61038d6040840160208501612ffc565b6119b95760405162461bcd60e51b81526004016103b190613651565b60006119cb6040840160208501612ffc565b6001600160a01b031663e5c641b66119e66080860186613981565b60016119f56080890189613981565b905003818110611a0157fe5b9050602002016020810190611a169190612ffc565b336040518363ffffffff1660e01b8152600401611a349291906134eb565b602060405180830381600087803b158015611a4e57600080fd5b505af1158015611a62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8691906132a9565b905060008360600135821015611a9c5781611aa2565b83606001355b9050611ab16080850185613981565b905060011415611b5657611af5611acb6080860186613981565b6000818110611ad657fe5b9050602002016020810190611aeb9190612ffc565b856040013561230b565b611b4f33611b096040870160208801612ffc565b611b166080880188613981565b6000818110611b2157fe5b9050602002016020810190611b369190612ffc565b604088013560006110076101208b016101008c01612ffc565b9250611bc1565b611bbe611b666020860186612ffc565b604086013583611b796080890189613981565b611b8960408b0160208c01612ffc565b611b9960e08c0160c08d0161319b565b60e08c0135611bb06101208e016101008f01612ffc565b6107d26101208f018f6139c8565b92505b611bd16040850160208601612ffc565b6001600160a01b03166339c3158a33611bed6080880188613981565b6001611bfc60808b018b613981565b905003818110611c0857fe5b9050602002016020810190611c1d9190612ffc565b86858960a00135604051602001611c349190613449565b6040516020818303038152906040526040518663ffffffff1660e01b8152600401611c639594939291906134b3565b600060405180830381600087803b158015611c7d57600080fd5b505af1158015611c91573d6000803e3d6000fd5b505050506000611d6f856020016020810190611cad9190612ffc565b6001600160a01b031663e5c641b6611cc86080890189613981565b6001611cd760808c018c613981565b905003818110611ce357fe5b9050602002016020810190611cf89190612ffc565b336040518363ffffffff1660e01b8152600401611d169291906134eb565b602060405180830381600087803b158015611d3057600080fd5b505af1158015611d44573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d6891906132a9565b8490611ec9565b905081811015611d915760405162461bcd60e51b81526004016103b190613764565b611da16040860160208701612ffc565b6001600160a01b0316611db76020870187612ffc565b6001600160a01b0316337f3b623be279df32a44c2edd16708b64a952bd614abdd2a3bc2572786eaefd5ab3611def60808a018a613981565b8a604001358a898d60c0016020810190611e09919061319b565b8e60e001358f610100016020810190611e229190612ffc565b604051611e36989796959493929190613598565b60405180910390a45050600160035550919050565b6000611e60836001600160a01b0384166129fb565b90505b92915050565b604080516001600160a01b0380861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180516001600160e01b03166323b872dd60e01b179052611ec3908590612a13565b50505050565b600082821115611f20576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000611f3360078d611e4b565b611f4f5760405162461bcd60e51b81526004016103b1906136bf565b6002881015611f705760405162461bcd60e51b81526004016103b190613877565b6127108510611f915760405162461bcd60e51b81526004016103b19061379b565b611fbc89896000818110611fa157fe5b9050602002016020810190611fb69190612ffc565b8c61230b565b6000612008338e8c8c6000818110611fd057fe5b9050602002016020810190611fe59190612ffc565b8f60008c6002811115611ff457fe5b14612000576000612002565b8a5b8a612376565b90506000600188600281111561201a57fe5b146120255788612027565b305b90508d6001600160a01b03166368aa6dd96040518060e001604052808581526020018f81526020018e8e808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152505050908252506001600160a01b038516602082015260400160028c60028111156120a557fe5b146120b15760006120b3565b8a5b8152602001896001600160a01b0316815260200188888080601f01602080910402602001604051908101604052809392919081815260200183838082843760009201919091525050509152506040516001600160e01b031960e084901b16815261212091906004016138f8565b602060405180830381600087803b15801561213a57600080fd5b505af115801561214e573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061217291906132a9565b92506001905087600281111561218457fe5b14156121bf576121bc30898c8c600019810181811061219f57fe5b90506020020160208101906121b49190612ffc565b858a8a612376565b91505b8a8210156121df5760405162461bcd60e51b81526004016103b1906137d2565b509b9a5050505050505050505050565b806121f9576122b4565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156122a0576000836001600160a01b03168260405161223790613446565b60006040518083038185875af1925050503d8060008114612274576040519150601f19603f3d011682016040523d82523d6000602084013e612279565b606091505b505090508061229a5760405162461bcd60e51b81526004016103b1906138ae565b506122b4565b6122b46001600160a01b03831684836122b9565b505050565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663a9059cbb60e01b1790526122b4908490612a13565b6001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee14156123545780341461234f5760405162461bcd60e51b81526004016103b190613688565b612372565b34156123725760405162461bcd60e51b81526004016103b190613809565b5050565b60008061238f6127106123898787612ac4565b90612b1d565b9050600061239d8683611ec9565b9050866001600160a01b03811673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee141561244a576000896001600160a01b0316836040516123de90613446565b60006040518083038185875af1925050503d806000811461241b576040519150601f19603f3d011682016040523d82523d6000602084013e612420565b606091505b50509050806124415760405162461bcd60e51b81526004016103b1906138ae565b829450506125a8565b6040516370a0823160e01b81526000906001600160a01b038316906370a0823190612479908d90600401613452565b60206040518083038186803b15801561249157600080fd5b505afa1580156124a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c991906132a9565b90506001600160a01b038b16301461250a576124f06001600160a01b0383168c8c86611e69565b6125056001600160a01b0383168c3087611e69565b61251e565b61251e6001600160a01b0383168b856122b9565b6125a481836001600160a01b03166370a082318d6040518263ffffffff1660e01b815260040161254e9190613452565b60206040518083038186803b15801561256657600080fd5b505afa15801561257a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061259e91906132a9565b90611ec9565b9450505b6125b3858285612b84565b5050509695505050505050565b801580612646575060408051636eb1769f60e11b81523060048201526001600160a01b03848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b15801561261857600080fd5b505afa15801561262c573d6000803e3d6000fd5b505050506040513d602081101561264257600080fd5b5051155b6126815760405162461bcd60e51b8152600401808060200182810382526036815260200180613a976036913960400191505060405180910390fd5b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180516001600160e01b031663095ea7b360e01b1790526122b4908490612a13565b60006126de82612c0c565b905080156126eb57612793565b506001600160a01b0381166000908152602081905260409020548061279357816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561274357600080fd5b505afa158015612757573d6000803e3d6000fd5b505050506040513d602081101561276d57600080fd5b50516001600160a01b038316600090815260208190526040902060ff9091169081905590505b919050565b60006127a382612c0c565b905080156127b057612793565b506001600160a01b0381166000908152602081905260409020548061279357816001600160a01b031663313ce5676040518163ffffffff1660e01b815260040160206040518083038186803b15801561280857600080fd5b505afa15801561281c573d6000803e3d6000fd5b505050506040513d602081101561283257600080fd5b505160ff16611e63565b60006b204fce5e3e2502611000000085111561289f576040805162461bcd60e51b815260206004820152601360248201527f737263416d6f756e74203e204d41585f51545900000000000000000000000000604482015290519081900360640190fd5b6b204fce5e3e25026110000000841115612900576040805162461bcd60e51b815260206004820152601460248201527f64657374416d6f756e74203e204d41585f515459000000000000000000000000604482015290519081900360640190fd5b828210612981576012838303111561295f576040805162461bcd60e51b815260206004820152601860248201527f647374202d20737263203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b84838303600a0a02670de0b6b3a764000085028161297957fe5b0490506129f3565b601282840311156129d9576040805162461bcd60e51b815260206004820152601860248201527f737263202d20647374203e204d41585f444543494d414c530000000000000000604482015290519081900360640190fd5b84828403600a0a670de0b6b3a76400008602028161297957fe5b949350505050565b60009081526001919091016020526040902054151590565b6000612a68826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b0316612d249092919063ffffffff16565b8051909150156122b457808060200190516020811015612a8757600080fd5b50516122b45760405162461bcd60e51b815260040180806020018281038252602a815260200180613a6d602a913960400191505060405180910390fd5b600082612ad357506000611e63565b82820282848281612ae057fe5b0414611e605760405162461bcd60e51b8152600401808060200182810382526021815260200180613a4c6021913960400191505060405180910390fd5b6000808211612b73576040805162461bcd60e51b815260206004820152601a60248201527f536166654d6174683a206469766973696f6e206279207a65726f000000000000604482015290519081900360640190fd5b818381612b7c57fe5b049392505050565b80156122b457612b95600584611e4b565b612bb15760405162461bcd60e51b81526004016103b19061372d565b6001600160a01b03808416600090815260046020908152604080832093861683529290522054612be19082612d3d565b6001600160a01b03808516600090815260046020908152604080832093871683529290522055505050565b60006001600160a01b03821673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee1415612c3b57506012612793565b6001600160a01b03821673dac17f958d2ee523a2206206994597c13d831ec71415612c6857506006612793565b6001600160a01b038216736b175474e89094c44da98b954eedeac495271d0f1415612c9557506012612793565b6001600160a01b03821673a0b86991c6218b36c1d19d4a2e9eb0ce3606eb481415612cc257506006612793565b6001600160a01b038216732260fac5e5542a773aa44fbcfedf7c193bc2c5991415612cef57506008612793565b6001600160a01b03821673dd974d5c2e2928dea5f71b9825b8b646686bd2001415612d1c57506012612793565b506000612793565b6060612d338484600085612d97565b90505b9392505050565b600082820183811015611e60576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b606082471015612dd85760405162461bcd60e51b8152600401808060200182810382526026815260200180613a266026913960400191505060405180910390fd5b612de185612ef2565b612e32576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600080866001600160a01b031685876040518082805190602001908083835b60208310612e705780518252601f199092019160209182019101612e51565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114612ed2576040519150601f19603f3d011682016040523d82523d6000602084013e612ed7565b606091505b5091509150612ee7828286612ef8565b979650505050505050565b3b151590565b60608315612f07575081612d36565b825115612f175782518084602001fd5b8160405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f61578181015183820152602001612f49565b50505050905090810190601f168015612f8e5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b60008083601f840112612fad578182fd5b50813567ffffffffffffffff811115612fc4578182fd5b6020830191508360208083028501011115612fde57600080fd5b9250929050565b600060c08284031215612ff6578081fd5b50919050565b60006020828403121561300d578081fd5b8135611e6081613a0d565b600060208284031215613029578081fd5b8151611e6081613a0d565b60008060408385031215613046578081fd5b823561305181613a0d565b9150602083013561306181613a0d565b809150509250929050565b60008060008060408587031215613081578182fd5b843567ffffffffffffffff80821115613098578384fd5b6130a488838901612f9c565b909650945060208701359150808211156130bc578384fd5b506130c987828801612f9c565b95989497509550505050565b6000806000806000606086880312156130ec578081fd5b853567ffffffffffffffff80821115613103578283fd5b61310f89838a01612f9c565b90975095506020880135915080821115613127578283fd5b5061313488828901612f9c565b9094509250506040860135801515811461314c578182fd5b809150509295509295909350565b60008060006060848603121561316e578283fd5b833561317981613a0d565b925060208401359150604084013561319081613a0d565b809150509250925092565b6000602082840312156131ac578081fd5b813560038110611e60578182fd5b6000602082840312156131cb578081fd5b813567ffffffffffffffff8111156131e1578182fd5b6129f384828501612fe5565b6000602082840312156131fe578081fd5b813567ffffffffffffffff811115613214578182fd5b82016101208185031215611e60578182fd5b600060208284031215613237578081fd5b813567ffffffffffffffff81111561324d578182fd5b82016101408185031215611e60578182fd5b600060208284031215613270578081fd5b813567ffffffffffffffff811115613286578182fd5b82016101008185031215611e60578182fd5b600060808284031215612ff6578081fd5b6000602082840312156132ba578081fd5b5051919050565b600080604083850312156132d3578182fd5b82359150602083013561306181613a0d565b60008284526020808501945082825b8581101561332257813561330781613a0d565b6001600160a01b0316875295820195908201906001016132f4565b509495945050505050565b6000815180845260208085019450808401835b838110156133225781516001600160a01b031687529582019590820190600101613340565b60008284526020808501945082825b8581101561332257813561338781613a0d565b6001600160a01b031687529582019590820190600101613374565b60008151808452815b818110156133c7576020818501810151868301820152016133ab565b818111156133d85782602083870101525b50601f01601f19169290920160200192915050565b600381106133f757fe5b9052565b60008151835260208201516080602085015261341a608085018261332d565b9050604083015160408501526060830151848203606086015261343d82826133a2565b95945050505050565b90565b90815260200190565b6001600160a01b0391909116815260200190565b6001600160a01b039384168152919092166020820152604081019190915260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260800190565b60006001600160a01b03808816835280871660208401525084604083015283606083015260a06080830152612ee760a08301846133a2565b6001600160a01b0392831681529116602082015260400190565b6000606082526135196060830187896132e5565b828103602084015261352c818688613365565b9150506001600160a01b03831660408301529695505050505050565b600060c0825261355c60c08301898b6132e5565b905086602083015285604083015261357760608301866133ed565b8360808301526001600160a01b03831660a083015298975050505050505050565b600060e082526135ac60e083018a8c6132e5565b90508760208301528660408301528560608301526135cd60808301866133ed565b8360a08301526001600160a01b03831660c08301529998505050505050505050565b600060608252613603606083018789613365565b82810360208401526136168186886132e5565b91505082151560408301529695505050505050565b6001600160a01b0394909416845260208401929092526040830152606082015260800190565b60208082526013908201527f756e737570706f72746564206c656e64696e6700000000000000000000000000604082015260600190565b6020808252600f908201527f77726f6e67206d73672076616c75650000000000000000000000000000000000604082015260600190565b60208082526010908201527f756e737570706f72746564207377617000000000000000000000000000000000604082015260600190565b60208082526011908201527f756e737570706f7274656420746f6b656e000000000000000000000000000000604082015260600190565b60208082526014908201527f756e737570706f7274656420706c6174666f726d000000000000000000000000604082015260600190565b6020808252600f908201527f6c6f77207061696420616d6f756e740000000000000000000000000000000000604082015260600190565b60208082526011908201527f6869676820706c6174666f726d20666565000000000000000000000000000000604082015260600190565b6020808252600a908201527f6c6f772072657475726e00000000000000000000000000000000000000000000604082015260600190565b6020808252600d908201527f626164206d73672076616c756500000000000000000000000000000000000000604082015260600190565b60208082526013908201527f6c6f772072657475726e656420616d6f756e7400000000000000000000000000604082015260600190565b60208082526011908201527f696e76616c696420747261646550617468000000000000000000000000000000604082015260600190565b6020808252600f908201527f7472616e73666572206661696c65640000000000000000000000000000000000604082015260600190565b600060208252611e6060208301846133fb565b6000602082528251602083015260208301516040830152604083015160e0606084015261392961010084018261332d565b905060608401516001600160a01b038082166080860152608086015160a08601528060a08701511660c0860152505060c0840151601f198483030160e085015261343d82826133a2565b918252602082015260400190565b6000808335601e19843603018112613997578283fd5b83018035915067ffffffffffffffff8211156139b1578283fd5b6020908101925081023603821315612fde57600080fd5b6000808335601e198436030181126139de578283fd5b83018035915067ffffffffffffffff8211156139f8578283fd5b602001915036819003821315612fde57600080fd5b6001600160a01b0381168114613a2257600080fd5b5056fe416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f775361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365a164736f6c6343000706000a

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

000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da7278

-----Decoded View---------------
Arg [0] : _admin (address): 0xa3e78aB6f120C730D6F3939c0Dc6dcD0E3da7278

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 000000000000000000000000a3e78ab6f120c730d6f3939c0dc6dcd0e3da7278


Block Transaction Gas Used Reward
view all blocks produced
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
View All Validatorset

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

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.