Contract 0x3A0a17Bcc84576b099373ab3Eed9702b07D30402

  Note: Our ETH balance display is temporarily unavailable. Please check back later.

Contract Overview

Balance:

Txn Hash Method
Block
From
To
Value
Latest 25 internal transaction
Parent Txn Hash Block From To Value
0xda2f3b83983126076b491d03b9008abfe6798bb2f92b042b3ce55dd4d68f0936124661002023-07-26 8:31:08270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xda2f3b83983126076b491d03b9008abfe6798bb2f92b042b3ce55dd4d68f0936124661002023-07-26 8:31:08270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xda2f3b83983126076b491d03b9008abfe6798bb2f92b042b3ce55dd4d68f0936124661002023-07-26 8:31:08270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xd1ff4ad83317ee4d1b7330ec01ea0b2cad438e3f644fa262c9e5ebff08dfac1d124660742023-07-26 8:30:16270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xd1ff4ad83317ee4d1b7330ec01ea0b2cad438e3f644fa262c9e5ebff08dfac1d124660742023-07-26 8:30:16270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xd1ff4ad83317ee4d1b7330ec01ea0b2cad438e3f644fa262c9e5ebff08dfac1d124660742023-07-26 8:30:16270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xd1ff4ad83317ee4d1b7330ec01ea0b2cad438e3f644fa262c9e5ebff08dfac1d124660742023-07-26 8:30:16270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xd1ff4ad83317ee4d1b7330ec01ea0b2cad438e3f644fa262c9e5ebff08dfac1d124660742023-07-26 8:30:16270 days 11 hrs ago 0xba1cd2470f46778c9748ce676c00ba48d6f0b89d 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xfe6e64c2aa7e0ff195f92624b8f83b32da462508e1cdd764a774a8fb68449b83123894602023-07-24 13:56:28272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xfe6e64c2aa7e0ff195f92624b8f83b32da462508e1cdd764a774a8fb68449b83123894602023-07-24 13:56:28272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xfe6e64c2aa7e0ff195f92624b8f83b32da462508e1cdd764a774a8fb68449b83123894602023-07-24 13:56:28272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x949195e3c5abee79c2bd12f0e725886fa610b30e95734cc928101277ae0c0c4d123894442023-07-24 13:55:56272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x949195e3c5abee79c2bd12f0e725886fa610b30e95734cc928101277ae0c0c4d123894442023-07-24 13:55:56272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x949195e3c5abee79c2bd12f0e725886fa610b30e95734cc928101277ae0c0c4d123894442023-07-24 13:55:56272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xa60772c2e96d38b078851f0ff9ada5c678ba1168aaf0e6e17f3116e0e8803c7f123894282023-07-24 13:55:24272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020.0001 ETH
0xa60772c2e96d38b078851f0ff9ada5c678ba1168aaf0e6e17f3116e0e8803c7f123894282023-07-24 13:55:24272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xa60772c2e96d38b078851f0ff9ada5c678ba1168aaf0e6e17f3116e0e8803c7f123894282023-07-24 13:55:24272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xa60772c2e96d38b078851f0ff9ada5c678ba1168aaf0e6e17f3116e0e8803c7f123894282023-07-24 13:55:24272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x36aad2f14f7d1df1aef29f8c248b292a9e9ac6828d664cd988ed3f13adab0931123889572023-07-24 13:39:42272 days 6 hrs ago 0xa3612f527b7a767b8297b185bf38c121572f0e4f 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x36aad2f14f7d1df1aef29f8c248b292a9e9ac6828d664cd988ed3f13adab0931123889572023-07-24 13:39:42272 days 6 hrs ago 0xa3612f527b7a767b8297b185bf38c121572f0e4f 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0x36aad2f14f7d1df1aef29f8c248b292a9e9ac6828d664cd988ed3f13adab0931123889572023-07-24 13:39:42272 days 6 hrs ago 0xa3612f527b7a767b8297b185bf38c121572f0e4f 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xb9431c6ec368f682ef39be2460d51fb36ab157ea012bdd4cb188f21e8df6cc9a123888272023-07-24 13:35:22272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020.0001 ETH
0xb9431c6ec368f682ef39be2460d51fb36ab157ea012bdd4cb188f21e8df6cc9a123888272023-07-24 13:35:22272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xb9431c6ec368f682ef39be2460d51fb36ab157ea012bdd4cb188f21e8df6cc9a123888272023-07-24 13:35:22272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
0xb9431c6ec368f682ef39be2460d51fb36ab157ea012bdd4cb188f21e8df6cc9a123888272023-07-24 13:35:22272 days 6 hrs ago 0xcb2f663c87d811991c60402ac4947482554e3959 0x3a0a17bcc84576b099373ab3eed9702b07d304020 ETH
[ Download CSV Export 
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
CandideWallet

Compiler Version
v0.8.12+commit.f00d7308

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 28 : Helpers.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

/* solhint-disable no-inline-assembly */

/**
 * returned data from validateUserOp.
 * validateUserOp returns a uint256, with is created by `_packedValidationData` and parsed by `_parseValidationData`
 * @param aggregator - address(0) - the account validated the signature by itself.
 *              address(1) - the account failed to validate the signature.
 *              otherwise - this is an address of a signature aggregator that must be used to validate the signature.
 * @param validAfter - this UserOp is valid only after this timestamp.
 * @param validaUntil - this UserOp is valid only up to this timestamp.
 */
    struct ValidationData {
        address aggregator;
        uint48 validAfter;
        uint48 validUntil;
    }

//extract sigFailed, validAfter, validUntil.
// also convert zero validUntil to type(uint48).max
    function _parseValidationData(uint validationData) pure returns (ValidationData memory data) {
        address aggregator = address(uint160(validationData));
        uint48 validUntil = uint48(validationData >> 160);
        if (validUntil == 0) {
            validUntil = type(uint48).max;
        }
        uint48 validAfter = uint48(validationData >> (48 + 160));
        return ValidationData(aggregator, validAfter, validUntil);
    }

// intersect account and paymaster ranges.
    function _intersectTimeRange(uint256 validationData, uint256 paymasterValidationData) pure returns (ValidationData memory) {
        ValidationData memory accountValidationData = _parseValidationData(validationData);
        ValidationData memory pmValidationData = _parseValidationData(paymasterValidationData);
        address aggregator = accountValidationData.aggregator;
        if (aggregator == address(0)) {
            aggregator = pmValidationData.aggregator;
        }
        uint48 validAfter = accountValidationData.validAfter;
        uint48 validUntil = accountValidationData.validUntil;
        uint48 pmValidAfter = pmValidationData.validAfter;
        uint48 pmValidUntil = pmValidationData.validUntil;

        if (validAfter < pmValidAfter) validAfter = pmValidAfter;
        if (validUntil > pmValidUntil) validUntil = pmValidUntil;
        return ValidationData(aggregator, validAfter, validUntil);
    }

/**
 * helper to pack the return value for validateUserOp
 * @param data - the ValidationData to pack
 */
    function _packValidationData(ValidationData memory data) pure returns (uint256) {
        return uint160(data.aggregator) | (uint256(data.validUntil) << 160) | (uint256(data.validAfter) << (160 + 48));
    }

/**
 * helper to pack the return value for validateUserOp, when not using an aggregator
 * @param sigFailed - true for signature failure, false for success
 * @param validUntil last timestamp this UserOperation is valid (or zero for infinite)
 * @param validAfter first timestamp this UserOperation is valid
 */
    function _packValidationData(bool sigFailed, uint48 validUntil, uint48 validAfter) pure returns (uint256) {
        return (sigFailed ? 1 : 0) | (uint256(validUntil) << 160) | (uint256(validAfter) << (160 + 48));
    }

/**
 * keccak function over calldata.
 * @dev copy calldata into memory, do keccak and drop allocated memory. Strangely, this is more efficient than letting solidity do it.
 */
    function calldataKeccak(bytes calldata data) pure returns (bytes32 ret) {
        assembly {
            let mem := mload(0x40)
            let len := data.length
            calldatacopy(mem, data.offset, len)
            ret := keccak256(mem, len)
        }
    }

File 2 of 28 : IAggregator.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

import "./UserOperation.sol";

/**
 * Aggregated Signatures validator.
 */
interface IAggregator {

    /**
     * validate aggregated signature.
     * revert if the aggregated signature does not match the given list of operations.
     */
    function validateSignatures(UserOperation[] calldata userOps, bytes calldata signature) external view;

    /**
     * validate signature of a single userOp
     * This method is should be called by bundler after EntryPoint.simulateValidation() returns (reverts) with ValidationResultWithAggregation
     * First it validates the signature over the userOp. Then it returns data to be used when creating the handleOps.
     * @param userOp the userOperation received from the user.
     * @return sigForUserOp the value to put into the signature field of the userOp when calling handleOps.
     *    (usually empty, unless account and aggregator support some kind of "multisig"
     */
    function validateUserOpSignature(UserOperation calldata userOp)
    external view returns (bytes memory sigForUserOp);

    /**
     * aggregate multiple signatures into a single value.
     * This method is called off-chain to calculate the signature to pass with handleOps()
     * bundler MAY use optimized custom code perform this aggregation
     * @param userOps array of UserOperations to collect the signatures from.
     * @return aggregatedSignature the aggregated signature
     */
    function aggregateSignatures(UserOperation[] calldata userOps) external view returns (bytes memory aggregatedSignature);
}

File 3 of 28 : IEntryPoint.sol
/**
 ** Account-Abstraction (EIP-4337) singleton EntryPoint implementation.
 ** Only one instance required on each chain.
 **/
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

/* solhint-disable avoid-low-level-calls */
/* solhint-disable no-inline-assembly */
/* solhint-disable reason-string */

import "./UserOperation.sol";
import "./IStakeManager.sol";
import "./IAggregator.sol";
import "./INonceManager.sol";

interface IEntryPoint is IStakeManager, INonceManager {

    /***
     * An event emitted after each successful request
     * @param userOpHash - unique identifier for the request (hash its entire content, except signature).
     * @param sender - the account that generates this request.
     * @param paymaster - if non-null, the paymaster that pays for this request.
     * @param nonce - the nonce value from the request.
     * @param success - true if the sender transaction succeeded, false if reverted.
     * @param actualGasCost - actual amount paid (by account or paymaster) for this UserOperation.
     * @param actualGasUsed - total gas used by this UserOperation (including preVerification, creation, validation and execution).
     */
    event UserOperationEvent(bytes32 indexed userOpHash, address indexed sender, address indexed paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed);

    /**
     * account "sender" was deployed.
     * @param userOpHash the userOp that deployed this account. UserOperationEvent will follow.
     * @param sender the account that is deployed
     * @param factory the factory used to deploy this account (in the initCode)
     * @param paymaster the paymaster used by this UserOp
     */
    event AccountDeployed(bytes32 indexed userOpHash, address indexed sender, address factory, address paymaster);

    /**
     * An event emitted if the UserOperation "callData" reverted with non-zero length
     * @param userOpHash the request unique identifier.
     * @param sender the sender of this request
     * @param nonce the nonce used in the request
     * @param revertReason - the return bytes from the (reverted) call to "callData".
     */
    event UserOperationRevertReason(bytes32 indexed userOpHash, address indexed sender, uint256 nonce, bytes revertReason);

    /**
     * an event emitted by handleOps(), before starting the execution loop.
     * any event emitted before this event, is part of the validation.
     */
    event BeforeExecution();

    /**
     * signature aggregator used by the following UserOperationEvents within this bundle.
     */
    event SignatureAggregatorChanged(address indexed aggregator);

    /**
     * a custom revert error of handleOps, to identify the offending op.
     *  NOTE: if simulateValidation passes successfully, there should be no reason for handleOps to fail on it.
     *  @param opIndex - index into the array of ops to the failed one (in simulateValidation, this is always zero)
     *  @param reason - revert reason
     *      The string starts with a unique code "AAmn", where "m" is "1" for factory, "2" for account and "3" for paymaster issues,
     *      so a failure can be attributed to the correct entity.
     *   Should be caught in off-chain handleOps simulation and not happen on-chain.
     *   Useful for mitigating DoS attempts against batchers or for troubleshooting of factory/account/paymaster reverts.
     */
    error FailedOp(uint256 opIndex, string reason);

    /**
     * error case when a signature aggregator fails to verify the aggregated signature it had created.
     */
    error SignatureValidationFailed(address aggregator);

    /**
     * Successful result from simulateValidation.
     * @param returnInfo gas and time-range returned values
     * @param senderInfo stake information about the sender
     * @param factoryInfo stake information about the factory (if any)
     * @param paymasterInfo stake information about the paymaster (if any)
     */
    error ValidationResult(ReturnInfo returnInfo,
        StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo);

    /**
     * Successful result from simulateValidation, if the account returns a signature aggregator
     * @param returnInfo gas and time-range returned values
     * @param senderInfo stake information about the sender
     * @param factoryInfo stake information about the factory (if any)
     * @param paymasterInfo stake information about the paymaster (if any)
     * @param aggregatorInfo signature aggregation info (if the account requires signature aggregator)
     *      bundler MUST use it to verify the signature, or reject the UserOperation
     */
    error ValidationResultWithAggregation(ReturnInfo returnInfo,
        StakeInfo senderInfo, StakeInfo factoryInfo, StakeInfo paymasterInfo,
        AggregatorStakeInfo aggregatorInfo);

    /**
     * return value of getSenderAddress
     */
    error SenderAddressResult(address sender);

    /**
     * return value of simulateHandleOp
     */
    error ExecutionResult(uint256 preOpGas, uint256 paid, uint48 validAfter, uint48 validUntil, bool targetSuccess, bytes targetResult);

    //UserOps handled, per aggregator
    struct UserOpsPerAggregator {
        UserOperation[] userOps;

        // aggregator address
        IAggregator aggregator;
        // aggregated signature
        bytes signature;
    }

    /**
     * Execute a batch of UserOperation.
     * no signature aggregator is used.
     * if any account requires an aggregator (that is, it returned an aggregator when
     * performing simulateValidation), then handleAggregatedOps() must be used instead.
     * @param ops the operations to execute
     * @param beneficiary the address to receive the fees
     */
    function handleOps(UserOperation[] calldata ops, address payable beneficiary) external;

    /**
     * Execute a batch of UserOperation with Aggregators
     * @param opsPerAggregator the operations to execute, grouped by aggregator (or address(0) for no-aggregator accounts)
     * @param beneficiary the address to receive the fees
     */
    function handleAggregatedOps(
        UserOpsPerAggregator[] calldata opsPerAggregator,
        address payable beneficiary
    ) external;

    /**
     * generate a request Id - unique identifier for this request.
     * the request ID is a hash over the content of the userOp (except the signature), the entrypoint and the chainid.
     */
    function getUserOpHash(UserOperation calldata userOp) external view returns (bytes32);

    /**
     * Simulate a call to account.validateUserOp and paymaster.validatePaymasterUserOp.
     * @dev this method always revert. Successful result is ValidationResult error. other errors are failures.
     * @dev The node must also verify it doesn't use banned opcodes, and that it doesn't reference storage outside the account's data.
     * @param userOp the user operation to validate.
     */
    function simulateValidation(UserOperation calldata userOp) external;

    /**
     * gas and return values during simulation
     * @param preOpGas the gas used for validation (including preValidationGas)
     * @param prefund the required prefund for this operation
     * @param sigFailed validateUserOp's (or paymaster's) signature check failed
     * @param validAfter - first timestamp this UserOp is valid (merging account and paymaster time-range)
     * @param validUntil - last timestamp this UserOp is valid (merging account and paymaster time-range)
     * @param paymasterContext returned by validatePaymasterUserOp (to be passed into postOp)
     */
    struct ReturnInfo {
        uint256 preOpGas;
        uint256 prefund;
        bool sigFailed;
        uint48 validAfter;
        uint48 validUntil;
        bytes paymasterContext;
    }

    /**
     * returned aggregated signature info.
     * the aggregator returned by the account, and its current stake.
     */
    struct AggregatorStakeInfo {
        address aggregator;
        StakeInfo stakeInfo;
    }

    /**
     * Get counterfactual sender address.
     *  Calculate the sender contract address that will be generated by the initCode and salt in the UserOperation.
     * this method always revert, and returns the address in SenderAddressResult error
     * @param initCode the constructor code to be passed into the UserOperation.
     */
    function getSenderAddress(bytes memory initCode) external;


    /**
     * simulate full execution of a UserOperation (including both validation and target execution)
     * this method will always revert with "ExecutionResult".
     * it performs full validation of the UserOperation, but ignores signature error.
     * an optional target address is called after the userop succeeds, and its value is returned
     * (before the entire call is reverted)
     * Note that in order to collect the the success/failure of the target call, it must be executed
     * with trace enabled to track the emitted events.
     * @param op the UserOperation to simulate
     * @param target if nonzero, a target address to call after userop simulation. If called, the targetSuccess and targetResult
     *        are set to the return from that call.
     * @param targetCallData callData to pass to target address
     */
    function simulateHandleOp(UserOperation calldata op, address target, bytes calldata targetCallData) external;
}

File 4 of 28 : INonceManager.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

interface INonceManager {

    /**
     * Return the next nonce for this sender.
     * Within a given key, the nonce values are sequenced (starting with zero, and incremented by one on each userop)
     * But UserOp with different keys can come with arbitrary order.
     *
     * @param sender the account address
     * @param key the high 192 bit of the nonce
     * @return nonce a full nonce to pass for next UserOp with this sender.
     */
    function getNonce(address sender, uint192 key)
    external view returns (uint256 nonce);

    /**
     * Manually increment the nonce of the sender.
     * This method is exposed just for completeness..
     * Account does NOT need to call it, neither during validation, nor elsewhere,
     * as the EntryPoint will update the nonce regardless.
     * Possible use-case is call it with various keys to "initialize" their nonces to one, so that future
     * UserOperations will not pay extra for the first transaction with a given key.
     */
    function incrementNonce(uint192 key) external;
}

File 5 of 28 : IStakeManager.sol
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.12;

/**
 * manage deposits and stakes.
 * deposit is just a balance used to pay for UserOperations (either by a paymaster or an account)
 * stake is value locked for at least "unstakeDelay" by the staked entity.
 */
interface IStakeManager {

    event Deposited(
        address indexed account,
        uint256 totalDeposit
    );

    event Withdrawn(
        address indexed account,
        address withdrawAddress,
        uint256 amount
    );

    /// Emitted when stake or unstake delay are modified
    event StakeLocked(
        address indexed account,
        uint256 totalStaked,
        uint256 unstakeDelaySec
    );

    /// Emitted once a stake is scheduled for withdrawal
    event StakeUnlocked(
        address indexed account,
        uint256 withdrawTime
    );

    event StakeWithdrawn(
        address indexed account,
        address withdrawAddress,
        uint256 amount
    );

    /**
     * @param deposit the entity's deposit
     * @param staked true if this entity is staked.
     * @param stake actual amount of ether staked for this entity.
     * @param unstakeDelaySec minimum delay to withdraw the stake.
     * @param withdrawTime - first block timestamp where 'withdrawStake' will be callable, or zero if already locked
     * @dev sizes were chosen so that (deposit,staked, stake) fit into one cell (used during handleOps)
     *    and the rest fit into a 2nd cell.
     *    112 bit allows for 10^15 eth
     *    48 bit for full timestamp
     *    32 bit allows 150 years for unstake delay
     */
    struct DepositInfo {
        uint112 deposit;
        bool staked;
        uint112 stake;
        uint32 unstakeDelaySec;
        uint48 withdrawTime;
    }

    //API struct used by getStakeInfo and simulateValidation
    struct StakeInfo {
        uint256 stake;
        uint256 unstakeDelaySec;
    }

    /// @return info - full deposit information of given account
    function getDepositInfo(address account) external view returns (DepositInfo memory info);

    /// @return the deposit (for gas payment) of the account
    function balanceOf(address account) external view returns (uint256);

    /**
     * add to the deposit of the given account
     */
    function depositTo(address account) external payable;

    /**
     * add to the account's stake - amount and delay
     * any pending unstake is first cancelled.
     * @param _unstakeDelaySec the new lock duration before the deposit can be withdrawn.
     */
    function addStake(uint32 _unstakeDelaySec) external payable;

    /**
     * attempt to unlock the stake.
     * the value can be withdrawn (using withdrawStake) after the unstake delay.
     */
    function unlockStake() external;

    /**
     * withdraw from the (unlocked) stake.
     * must first call unlockStake and wait for the unstakeDelay to pass
     * @param withdrawAddress the address to send withdrawn value.
     */
    function withdrawStake(address payable withdrawAddress) external;

    /**
     * withdraw from the deposit.
     * @param withdrawAddress the address to send withdrawn value.
     * @param withdrawAmount the amount to withdraw.
     */
    function withdrawTo(address payable withdrawAddress, uint256 withdrawAmount) external;
}

File 6 of 28 : UserOperation.sol
// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.12;

/* solhint-disable no-inline-assembly */

import {calldataKeccak} from "../core/Helpers.sol";

/**
 * User Operation struct
 * @param sender the sender account of this request.
     * @param nonce unique value the sender uses to verify it is not a replay.
     * @param initCode if set, the account contract will be created by this constructor/
     * @param callData the method call to execute on this account.
     * @param callGasLimit the gas limit passed to the callData method call.
     * @param verificationGasLimit gas used for validateUserOp and validatePaymasterUserOp.
     * @param preVerificationGas gas not calculated by the handleOps method, but added to the gas paid. Covers batch overhead.
     * @param maxFeePerGas same as EIP-1559 gas parameter.
     * @param maxPriorityFeePerGas same as EIP-1559 gas parameter.
     * @param paymasterAndData if set, this field holds the paymaster address and paymaster-specific data. the paymaster will pay for the transaction instead of the sender.
     * @param signature sender-verified signature over the entire request, the EntryPoint address and the chain ID.
     */
    struct UserOperation {

        address sender;
        uint256 nonce;
        bytes initCode;
        bytes callData;
        uint256 callGasLimit;
        uint256 verificationGasLimit;
        uint256 preVerificationGas;
        uint256 maxFeePerGas;
        uint256 maxPriorityFeePerGas;
        bytes paymasterAndData;
        bytes signature;
    }

/**
 * Utility functions helpful when working with UserOperation structs.
 */
library UserOperationLib {

    function getSender(UserOperation calldata userOp) internal pure returns (address) {
        address data;
        //read sender from userOp, which is first userOp member (saves 800 gas...)
        assembly {data := calldataload(userOp)}
        return address(uint160(data));
    }

    //relayer/block builder might submit the TX with higher priorityFee, but the user should not
    // pay above what he signed for.
    function gasPrice(UserOperation calldata userOp) internal view returns (uint256) {
    unchecked {
        uint256 maxFeePerGas = userOp.maxFeePerGas;
        uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
        if (maxFeePerGas == maxPriorityFeePerGas) {
            //legacy mode (for networks that don't support basefee opcode)
            return maxFeePerGas;
        }
        return min(maxFeePerGas, maxPriorityFeePerGas + block.basefee);
    }
    }

    function pack(UserOperation calldata userOp) internal pure returns (bytes memory ret) {
        address sender = getSender(userOp);
        uint256 nonce = userOp.nonce;
        bytes32 hashInitCode = calldataKeccak(userOp.initCode);
        bytes32 hashCallData = calldataKeccak(userOp.callData);
        uint256 callGasLimit = userOp.callGasLimit;
        uint256 verificationGasLimit = userOp.verificationGasLimit;
        uint256 preVerificationGas = userOp.preVerificationGas;
        uint256 maxFeePerGas = userOp.maxFeePerGas;
        uint256 maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;
        bytes32 hashPaymasterAndData = calldataKeccak(userOp.paymasterAndData);

        return abi.encode(
            sender, nonce,
            hashInitCode, hashCallData,
            callGasLimit, verificationGasLimit, preVerificationGas,
            maxFeePerGas, maxPriorityFeePerGas,
            hashPaymasterAndData
        );
    }

    function hash(UserOperation calldata userOp) internal pure returns (bytes32) {
        return keccak256(pack(userOp));
    }

    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }
}

File 7 of 28 : Executor.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/Enum.sol";

/**
 * @title Executor - A contract that can execute transactions
 * @author Richard Meissner - @rmeissner
 */
abstract contract Executor {
    /**
     * @notice Executes either a delegatecall or a call with provided parameters.
     * @dev This method doesn't perform any sanity check of the transaction, such as:
     *      - if the contract at `to` address has code or not
     *      It is the responsibility of the caller to perform such checks.
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @return success boolean flag indicating if the call succeeded.
     */
    function execute(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 txGas
    ) internal returns (bool success) {
        if (operation == Enum.Operation.DelegateCall) {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)
            }
        } else {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)
            }
        }
    }
}

File 8 of 28 : FallbackManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "../common/SelfAuthorized.sol";

/**
 * @title Fallback Manager - A contract managing fallback calls made to this contract
 * @author Richard Meissner - @rmeissner
 */
abstract contract FallbackManager is SelfAuthorized {
    event ChangedFallbackHandler(address indexed handler);

    // keccak256("fallback_manager.handler.address")
    bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;

    /**
     *  @notice Internal function to set the fallback handler.
     *  @param handler contract to handle fallback calls.
     */
    function internalSetFallbackHandler(address handler) internal {
        /*
            If a fallback handler is set to self, then the following attack vector is opened:
            Imagine we have a function like this:
            function withdraw() internal authorized {
                withdrawalAddress.call.value(address(this).balance)("");
            }

            If the fallback method is triggered, the fallback handler appends the msg.sender address to the calldata and calls the fallback handler.
            A potential attacker could call a Safe with the 3 bytes signature of a withdraw function. Since 3 bytes do not create a valid signature,
            the call would end in a fallback handler. Since it appends the msg.sender address to the calldata, the attacker could craft an address 
            where the first 3 bytes of the previous calldata + the first byte of the address make up a valid function signature. The subsequent call would result in unsanctioned access to Safe's internal protected methods.
            For some reason, solidity matches the first 4 bytes of the calldata to a function signature, regardless if more data follow these 4 bytes.
        */
        require(handler != address(this), "GS400");

        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(slot, handler)
        }
    }

    /**
     * @notice Set Fallback Handler to `handler` for the Safe.
     * @dev Only fallback calls without value and with data will be forwarded.
     *      This can only be done via a Safe transaction.
     *      Cannot be set to the Safe itself.
     * @param handler contract to handle fallback calls.
     */
    function setFallbackHandler(address handler) public authorized {
        internalSetFallbackHandler(handler);
        emit ChangedFallbackHandler(handler);
    }

    // @notice Forwards all calls to the fallback handler if set. Returns 0 if no handler is set.
    // @dev Appends the non-padded caller address to the calldata to be optionally used in the handler
    //      The handler can make us of `HandlerContext.sol` to extract the address.
    //      This is done because in the next call frame the `msg.sender` will be FallbackManager's address
    //      and having the original caller address may enable additional verification scenarios.
    // solhint-disable-next-line payable-fallback,no-complex-fallback
    fallback() external {
        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let handler := sload(slot)
            if iszero(handler) {
                return(0, 0)
            }
            calldatacopy(0, 0, calldatasize())
            // The msg.sender address is shifted to the left by 12 bytes to remove the padding
            // Then the address without padding is stored right after the calldata
            mstore(calldatasize(), shl(96, caller()))
            // Add 20 bytes for the address appended add the end
            let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)
            returndatacopy(0, 0, returndatasize())
            if iszero(success) {
                revert(0, returndatasize())
            }
            return(0, returndatasize())
        }
    }
}

File 9 of 28 : GuardManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "../common/Enum.sol";
import "../common/SelfAuthorized.sol";
import "../interfaces/IERC165.sol";

interface Guard is IERC165 {
    function checkTransaction(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures,
        address msgSender
    ) external;

    function checkAfterExecution(bytes32 txHash, bool success) external;
}

abstract contract BaseGuard is Guard {
    function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {
        return
            interfaceId == type(Guard).interfaceId || // 0xe6d7a83a
            interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7
    }
}

/**
 * @title Guard Manager - A contract managing transaction guards which perform pre and post-checks on Safe transactions.
 * @author Richard Meissner - @rmeissner
 */
abstract contract GuardManager is SelfAuthorized {
    event ChangedGuard(address indexed guard);

    // keccak256("guard_manager.guard.address")
    bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;

    /**
     * @dev Set a guard that checks transactions before execution
     *      This can only be done via a Safe transaction.
     *      ⚠️ IMPORTANT: Since a guard has full power to block Safe transaction execution,
     *        a broken guard can cause a denial of service for the Safe. Make sure to carefully
     *        audit the guard code and design recovery mechanisms.
     * @notice Set Transaction Guard `guard` for the Safe. Make sure you trust the guard.
     * @param guard The address of the guard to be used or the 0 address to disable the guard
     */
    function setGuard(address guard) external authorized {
        if (guard != address(0)) {
            require(Guard(guard).supportsInterface(type(Guard).interfaceId), "GS300");
        }
        bytes32 slot = GUARD_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            sstore(slot, guard)
        }
        emit ChangedGuard(guard);
    }

    /**
     * @dev Internal method to retrieve the current guard
     *      We do not have a public method because we're short on bytecode size limit,
     *      to retrieve the guard address, one can use `getStorageAt` from `StorageAccessible` contract
     *      with the slot `GUARD_STORAGE_SLOT`
     * @return guard The address of the guard
     */
    function getGuard() internal view returns (address guard) {
        bytes32 slot = GUARD_STORAGE_SLOT;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            guard := sload(slot)
        }
    }
}

File 10 of 28 : ModuleManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/Enum.sol";
import "../common/SelfAuthorized.sol";
import "./Executor.sol";

/**
 * @title Module Manager - A contract managing Safe modules
 * @notice Modules are extensions with unlimited access to a Safe that can be added to a Safe by its owners.
           ⚠️ WARNING: Modules are a security risk since they can execute arbitrary transactions, 
           so only trusted and audited modules should be added to a Safe. A malicious module can
           completely takeover a Safe.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
abstract contract ModuleManager is SelfAuthorized, Executor {
    event EnabledModule(address indexed module);
    event DisabledModule(address indexed module);
    event ExecutionFromModuleSuccess(address indexed module);
    event ExecutionFromModuleFailure(address indexed module);

    address internal constant SENTINEL_MODULES = address(0x1);

    mapping(address => address) internal modules;

    /**
     * @notice Setup function sets the initial storage of the contract.
     *         Optionally executes a delegate call to another contract to setup the modules.
     * @param to Optional destination address of call to execute.
     * @param data Optional data of call to execute.
     */
    function setupModules(address to, bytes memory data) internal {
        require(modules[SENTINEL_MODULES] == address(0), "GS100");
        modules[SENTINEL_MODULES] = SENTINEL_MODULES;
        if (to != address(0)) {
            require(isContract(to), "GS002");
            // Setup has to complete successfully or transaction fails.
            require(execute(to, 0, data, Enum.Operation.DelegateCall, gasleft()), "GS000");
        }
    }

    /**
     * @notice Enables the module `module` for the Safe.
     * @dev This can only be done via a Safe transaction.
     * @param module Module to be whitelisted.
     */
    function enableModule(address module) public authorized {
        // Module address cannot be null or sentinel.
        require(module != address(0) && module != SENTINEL_MODULES, "GS101");
        // Module cannot be added twice.
        require(modules[module] == address(0), "GS102");
        modules[module] = modules[SENTINEL_MODULES];
        modules[SENTINEL_MODULES] = module;
        emit EnabledModule(module);
    }

    /**
     * @notice Disables the module `module` for the Safe.
     * @dev This can only be done via a Safe transaction.
     * @param prevModule Previous module in the modules linked list.
     * @param module Module to be removed.
     */
    function disableModule(address prevModule, address module) public authorized {
        // Validate module address and check that it corresponds to module index.
        require(module != address(0) && module != SENTINEL_MODULES, "GS101");
        require(modules[prevModule] == module, "GS103");
        modules[prevModule] = modules[module];
        modules[module] = address(0);
        emit DisabledModule(module);
    }

    /**
     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token)
     * @dev Function is virtual to allow overriding for L2 singleton to emit an event for indexing.
     * @param to Destination address of module transaction.
     * @param value Ether value of module transaction.
     * @param data Data payload of module transaction.
     * @param operation Operation type of module transaction.
     * @return success Boolean flag indicating if the call succeeded.
     */
    function execTransactionFromModule(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation
    ) public virtual returns (bool success) {
        // Only whitelisted modules are allowed.
        require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), "GS104");
        // Execute transaction without further confirmations.
        success = execute(to, value, data, operation, type(uint256).max);
        if (success) emit ExecutionFromModuleSuccess(msg.sender);
        else emit ExecutionFromModuleFailure(msg.sender);
    }

    /**
     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token) and return data
     * @param to Destination address of module transaction.
     * @param value Ether value of module transaction.
     * @param data Data payload of module transaction.
     * @param operation Operation type of module transaction.
     * @return success Boolean flag indicating if the call succeeded.
     * @return returnData Data returned by the call.
     */
    function execTransactionFromModuleReturnData(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation
    ) public returns (bool success, bytes memory returnData) {
        success = execTransactionFromModule(to, value, data, operation);
        // solhint-disable-next-line no-inline-assembly
        assembly {
            // Load free memory location
            let ptr := mload(0x40)
            // We allocate memory for the return data by setting the free memory location to
            // current free memory location + data size + 32 bytes for data size value
            mstore(0x40, add(ptr, add(returndatasize(), 0x20)))
            // Store the size
            mstore(ptr, returndatasize())
            // Store the data
            returndatacopy(add(ptr, 0x20), 0, returndatasize())
            // Point the return data to the correct memory location
            returnData := ptr
        }
    }

    /**
     * @notice Returns if an module is enabled
     * @return True if the module is enabled
     */
    function isModuleEnabled(address module) public view returns (bool) {
        return SENTINEL_MODULES != module && modules[module] != address(0);
    }

    /**
     * @notice Returns an array of modules.
     *         If all entries fit into a single page, the next pointer will be 0x1.
     *         If another page is present, next will be the last element of the returned array.
     * @param start Start of the page. Has to be a module or start pointer (0x1 address)
     * @param pageSize Maximum number of modules that should be returned. Has to be > 0
     * @return array Array of modules.
     * @return next Start of the next page.
     */
    function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {
        require(start == SENTINEL_MODULES || isModuleEnabled(start), "GS105");
        require(pageSize > 0, "GS106");
        // Init array with max page size
        array = new address[](pageSize);

        // Populate return array
        uint256 moduleCount = 0;
        next = modules[start];
        while (next != address(0) && next != SENTINEL_MODULES && moduleCount < pageSize) {
            array[moduleCount] = next;
            next = modules[next];
            moduleCount++;
        }

        /**
          Because of the argument validation, we can assume that the loop will always iterate over the valid module list values
          and the `next` variable will either be an enabled module or a sentinel address (signalling the end). 
          
          If we haven't reached the end inside the loop, we need to set the next pointer to the last element of the modules array
          because the `next` variable (which is a module by itself) acting as a pointer to the start of the next page is neither 
          included to the current page, nor will it be included in the next one if you pass it as a start.
        */
        if (next != SENTINEL_MODULES) {
            next = array[moduleCount - 1];
        }
        // Set correct size of returned array
        // solhint-disable-next-line no-inline-assembly
        assembly {
            mstore(array, moduleCount)
        }
    }

    /**
     * @notice Returns true if `account` is a contract.
     * @dev This function will return false if invoked during the constructor of a contract,
     *      as the code is not actually created until after the constructor finishes.
     * @param account The address being queried
     */
    function isContract(address account) internal view returns (bool) {
        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }
}

File 11 of 28 : OwnerManager.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;
import "../common/SelfAuthorized.sol";

/**
 * @title OwnerManager - Manages Safe owners and a threshold to authorize transactions.
 * @dev Uses a linked list to store the owners because the code generate by the solidity compiler
 *      is more efficient than using a dynamic array.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
abstract contract OwnerManager is SelfAuthorized {
    event AddedOwner(address indexed owner);
    event RemovedOwner(address indexed owner);
    event ChangedThreshold(uint256 threshold);

    address internal constant SENTINEL_OWNERS = address(0x1);

    mapping(address => address) internal owners;
    uint256 internal ownerCount;
    uint256 internal threshold;

    /**
     * @notice Sets the initial storage of the contract.
     * @param _owners List of Safe owners.
     * @param _threshold Number of required confirmations for a Safe transaction.
     */
    function setupOwners(address[] memory _owners, uint256 _threshold) internal {
        // Threshold can only be 0 at initialization.
        // Check ensures that setup function can only be called once.
        require(threshold == 0, "GS200");
        // Validate that threshold is smaller than number of added owners.
        require(_threshold <= _owners.length, "GS201");
        // There has to be at least one Safe owner.
        require(_threshold >= 1, "GS202");
        // Initializing Safe owners.
        address currentOwner = SENTINEL_OWNERS;
        for (uint256 i = 0; i < _owners.length; i++) {
            // Owner address cannot be null.
            address owner = _owners[i];
            require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, "GS203");
            // No duplicate owners allowed.
            require(owners[owner] == address(0), "GS204");
            owners[currentOwner] = owner;
            currentOwner = owner;
        }
        owners[currentOwner] = SENTINEL_OWNERS;
        ownerCount = _owners.length;
        threshold = _threshold;
    }

    /**
     * @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param owner New owner address.
     * @param _threshold New threshold.
     */
    function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {
        // Owner address cannot be null, the sentinel or the Safe itself.
        require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), "GS203");
        // No duplicate owners allowed.
        require(owners[owner] == address(0), "GS204");
        owners[owner] = owners[SENTINEL_OWNERS];
        owners[SENTINEL_OWNERS] = owner;
        ownerCount++;
        emit AddedOwner(owner);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param prevOwner Owner that pointed to the owner to be removed in the linked list
     * @param owner Owner address to be removed.
     * @param _threshold New threshold.
     */
    function removeOwner(address prevOwner, address owner, uint256 _threshold) public authorized {
        // Only allow to remove an owner, if threshold can still be reached.
        require(ownerCount - 1 >= _threshold, "GS201");
        // Validate owner address and check that it corresponds to owner index.
        require(owner != address(0) && owner != SENTINEL_OWNERS, "GS203");
        require(owners[prevOwner] == owner, "GS205");
        owners[prevOwner] = owners[owner];
        owners[owner] = address(0);
        ownerCount--;
        emit RemovedOwner(owner);
        // Change threshold if threshold was changed.
        if (threshold != _threshold) changeThreshold(_threshold);
    }

    /**
     * @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.
     * @dev This can only be done via a Safe transaction.
     * @param prevOwner Owner that pointed to the owner to be replaced in the linked list
     * @param oldOwner Owner address to be replaced.
     * @param newOwner New owner address.
     */
    function swapOwner(address prevOwner, address oldOwner, address newOwner) public authorized {
        // Owner address cannot be null, the sentinel or the Safe itself.
        require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), "GS203");
        // No duplicate owners allowed.
        require(owners[newOwner] == address(0), "GS204");
        // Validate oldOwner address and check that it corresponds to owner index.
        require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, "GS203");
        require(owners[prevOwner] == oldOwner, "GS205");
        owners[newOwner] = owners[oldOwner];
        owners[prevOwner] = newOwner;
        owners[oldOwner] = address(0);
        emit RemovedOwner(oldOwner);
        emit AddedOwner(newOwner);
    }

    /**
     * @notice Changes the threshold of the Safe to `_threshold`.
     * @dev This can only be done via a Safe transaction.
     * @param _threshold New threshold.
     */
    function changeThreshold(uint256 _threshold) public authorized {
        // Validate that threshold is smaller than number of owners.
        require(_threshold <= ownerCount, "GS201");
        // There has to be at least one Safe owner.
        require(_threshold >= 1, "GS202");
        threshold = _threshold;
        emit ChangedThreshold(threshold);
    }

    /**
     * @notice Returns the number of required confirmations for a Safe transaction aka the threshold.
     * @return Threshold number.
     */
    function getThreshold() public view returns (uint256) {
        return threshold;
    }

    /**
     * @notice Returns if `owner` is an owner of the Safe.
     * @return Boolean if owner is an owner of the Safe.
     */
    function isOwner(address owner) public view returns (bool) {
        return owner != SENTINEL_OWNERS && owners[owner] != address(0);
    }

    /**
     * @notice Returns a list of Safe owners.
     * @return Array of Safe owners.
     */
    function getOwners() public view returns (address[] memory) {
        address[] memory array = new address[](ownerCount);

        // populate return array
        uint256 index = 0;
        address currentOwner = owners[SENTINEL_OWNERS];
        while (currentOwner != SENTINEL_OWNERS) {
            array[index] = currentOwner;
            currentOwner = owners[currentOwner];
            index++;
        }
        return array;
    }
}

File 12 of 28 : Enum.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Enum - Collection of enums used in Safe contracts.
 * @author Richard Meissner - @rmeissner
 */
abstract contract Enum {
    enum Operation {
        Call,
        DelegateCall
    }
}

File 13 of 28 : NativeCurrencyPaymentFallback.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title NativeCurrencyPaymentFallback - A contract that has a fallback to accept native currency payments.
 * @author Richard Meissner - @rmeissner
 */
abstract contract NativeCurrencyPaymentFallback {
    event SafeReceived(address indexed sender, uint256 value);

    /**
     * @notice Receive function accepts native currency transactions.
     * @dev Emits an event with sender and received value.
     */
    receive() external payable {
        emit SafeReceived(msg.sender, msg.value);
    }
}

File 14 of 28 : SecuredTokenTransfer.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SecuredTokenTransfer - Secure token transfer.
 * @author Richard Meissner - @rmeissner
 */
abstract contract SecuredTokenTransfer {
    /**
     * @notice Transfers a token and returns a boolean if it was a success
     * @dev It checks the return data of the transfer call and returns true if the transfer was successful.
     *      It doesn't check if the `token` address is a contract or not.
     * @param token Token that should be transferred
     * @param receiver Receiver to whom the token should be transferred
     * @param amount The amount of tokens that should be transferred
     * @return transferred Returns true if the transfer was successful
     */
    function transferToken(address token, address receiver, uint256 amount) internal returns (bool transferred) {
        // 0xa9059cbb - keccack("transfer(address,uint256)")
        bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);
        // solhint-disable-next-line no-inline-assembly
        assembly {
            // We write the return value to scratch space.
            // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory
            let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            switch returndatasize()
            case 0 {
                transferred := success
            }
            case 0x20 {
                transferred := iszero(or(iszero(success), iszero(mload(0))))
            }
            default {
                transferred := 0
            }
        }
    }
}

File 15 of 28 : SelfAuthorized.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SelfAuthorized - Authorizes current contract to perform actions to itself.
 * @author Richard Meissner - @rmeissner
 */
abstract contract SelfAuthorized {
    function requireSelfCall() private view {
        require(msg.sender == address(this), "GS031");
    }

    modifier authorized() {
        // Modifiers are copied around during compilation. This is a function call as it minimized the bytecode size
        requireSelfCall();
        _;
    }
}

File 16 of 28 : SignatureDecoder.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SignatureDecoder - Decodes signatures encoded as bytes
 * @author Richard Meissner - @rmeissner
 */
abstract contract SignatureDecoder {
    /**
     * @notice Splits signature bytes into `uint8 v, bytes32 r, bytes32 s`.
     * @dev Make sure to perform a bounds check for @param pos, to avoid out of bounds access on @param signatures
     *      The signature format is a compact form of {bytes32 r}{bytes32 s}{uint8 v}
     *      Compact means uint8 is not padded to 32 bytes.
     * @param pos Which signature to read.
     *            A prior bounds check of this parameter should be performed, to avoid out of bounds access.
     * @param signatures Concatenated {r, s, v} signatures.
     * @return v Recovery ID or Safe signature type.
     * @return r Output value r of the signature.
     * @return s Output value s of the signature.
     */
    function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns (uint8 v, bytes32 r, bytes32 s) {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let signaturePos := mul(0x41, pos)
            r := mload(add(signatures, add(signaturePos, 0x20)))
            s := mload(add(signatures, add(signaturePos, 0x40)))
            /**
             * Here we are loading the last 32 bytes, including 31 bytes
             * of 's'. There is no 'mload8' to do this.
             * 'byte' is not working due to the Solidity parser, so lets
             * use the second best option, 'and'
             */
            v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)
        }
    }
}

File 17 of 28 : Singleton.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title Singleton - Base for singleton contracts (should always be the first super contract)
 *        This contract is tightly coupled to our proxy contract (see `proxies/SafeProxy.sol`)
 * @author Richard Meissner - @rmeissner
 */
abstract contract Singleton {
    // singleton always has to be the first declared variable to ensure the same location as in the Proxy contract.
    // It should also always be ensured the address is stored alone (uses a full word)
    address private singleton;
}

File 18 of 28 : StorageAccessible.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title StorageAccessible - A generic base contract that allows callers to access all internal storage.
 * @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol
 *         It removes a method from the original contract not needed for the Safe contracts.
 * @author Gnosis Developers
 */
abstract contract StorageAccessible {
    /**
     * @notice Reads `length` bytes of storage in the currents contract
     * @param offset - the offset in the current contract's storage in words to start reading from
     * @param length - the number of words (32 bytes) of data to read
     * @return the bytes that were read.
     */
    function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {
        bytes memory result = new bytes(length * 32);
        for (uint256 index = 0; index < length; index++) {
            // solhint-disable-next-line no-inline-assembly
            assembly {
                let word := sload(add(offset, index))
                mstore(add(add(result, 0x20), mul(index, 0x20)), word)
            }
        }
        return result;
    }

    /**
     * @dev Performs a delegatecall on a targetContract in the context of self.
     * Internally reverts execution to avoid side effects (making it static).
     *
     * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.
     * Specifically, the `returndata` after a call to this method will be:
     * `success:bool || response.length:uint256 || response:bytes`.
     *
     * @param targetContract Address of the contract containing the code to execute.
     * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).
     */
    function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {
        // solhint-disable-next-line no-inline-assembly
        assembly {
            let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)

            mstore(0x00, success)
            mstore(0x20, returndatasize())
            returndatacopy(0x40, 0, returndatasize())
            revert(0, add(returndatasize(), 0x40))
        }
    }
}

File 19 of 28 : SafeMath.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/**
 * @title SafeMath
 * @notice Math operations with safety checks that revert on error (overflow/underflow)
 */
library SafeMath {
    /**
     * @notice Multiplies two numbers, reverts on overflow.
     * @param a First number
     * @param b Second number
     * @return Product of a and b
     */
    function mul(uint256 a, uint256 b) internal pure returns (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-solidity/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b);

        return c;
    }

    /**
     * @notice Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
     * @param a First number
     * @param b Second number
     * @return Difference of a and b
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        require(b <= a);
        uint256 c = a - b;

        return c;
    }

    /**
     * @notice Adds two numbers, reverts on overflow.
     * @param a First number
     * @param b Second number
     * @return Sum of a and b
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a);

        return c;
    }

    /**
     * @notice Returns the largest of two numbers.
     * @param a First number
     * @param b Second number
     * @return Largest of a and b
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a >= b ? a : b;
    }
}

File 20 of 28 : IERC165.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by `interfaceId`.
     * See the corresponding EIP section
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 21 of 28 : ISignatureValidator.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

contract ISignatureValidatorConstants {
    // bytes4(keccak256("isValidSignature(bytes,bytes)")
    bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;
}

abstract contract ISignatureValidator is ISignatureValidatorConstants {
    /**
     * @notice Legacy EIP1271 method to validate a signature.
     * @param _data Arbitrary length data signed on the behalf of address(this).
     * @param _signature Signature byte array associated with _data.
     *
     * MUST return the bytes4 magic value 0x20c13b0b when function passes.
     * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)
     * MUST allow external calls
     */
    function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);
}

File 22 of 28 : Safe.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "./base/ModuleManager.sol";
import "./base/OwnerManager.sol";
import "./base/FallbackManager.sol";
import "./base/GuardManager.sol";
import "./common/NativeCurrencyPaymentFallback.sol";
import "./common/Singleton.sol";
import "./common/SignatureDecoder.sol";
import "./common/SecuredTokenTransfer.sol";
import "./common/StorageAccessible.sol";
import "./interfaces/ISignatureValidator.sol";
import "./external/SafeMath.sol";

/**
 * @title Safe - A multisignature wallet with support for confirmations using signed messages based on EIP-712.
 * @dev Most important concepts:
 *      - Threshold: Number of required confirmations for a Safe transaction.
 *      - Owners: List of addresses that control the Safe. They are the only ones that can add/remove owners, change the threshold and
 *        approve transactions. Managed in `OwnerManager`.
 *      - Transaction Hash: Hash of a transaction is calculated using the EIP-712 typed structured data hashing scheme.
 *      - Nonce: Each transaction should have a different nonce to prevent replay attacks.
 *      - Signature: A valid signature of an owner of the Safe for a transaction hash.
 *      - Guard: Guard is a contract that can execute pre- and post- transaction checks. Managed in `GuardManager`.
 *      - Modules: Modules are contracts that can be used to extend the write functionality of a Safe. Managed in `ModuleManager`.
 *      - Fallback: Fallback handler is a contract that can provide additional read-only functional for Safe. Managed in `FallbackManager`.
 *      Note: This version of the implementation contract doesn't emit events for the sake of gas efficiency and therefore requires a tracing node for indexing/
 *      For the events-based implementation see `SafeL2.sol`.
 * @author Stefan George - @Georgi87
 * @author Richard Meissner - @rmeissner
 */
contract Safe is
    Singleton,
    NativeCurrencyPaymentFallback,
    ModuleManager,
    OwnerManager,
    SignatureDecoder,
    SecuredTokenTransfer,
    ISignatureValidatorConstants,
    FallbackManager,
    StorageAccessible,
    GuardManager
{
    using SafeMath for uint256;

    string public constant VERSION = "1.4.0";

    // keccak256(
    //     "EIP712Domain(uint256 chainId,address verifyingContract)"
    // );
    bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;

    // keccak256(
    //     "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
    // );
    bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;

    event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);
    event ApproveHash(bytes32 indexed approvedHash, address indexed owner);
    event SignMsg(bytes32 indexed msgHash);
    event ExecutionFailure(bytes32 indexed txHash, uint256 payment);
    event ExecutionSuccess(bytes32 indexed txHash, uint256 payment);

    uint256 public nonce;
    bytes32 private _deprecatedDomainSeparator;
    // Mapping to keep track of all message hashes that have been approved by ALL REQUIRED owners
    mapping(bytes32 => uint256) public signedMessages;
    // Mapping to keep track of all hashes (message or transaction) that have been approved by ANY owners
    mapping(address => mapping(bytes32 => uint256)) public approvedHashes;

    // This constructor ensures that this contract can only be used as a singleton for Proxy contracts
    constructor() {
        /**
         * By setting the threshold it is not possible to call setup anymore,
         * so we create a Safe with 0 owners and threshold 1.
         * This is an unusable Safe, perfect for the singleton
         */
        threshold = 1;
    }

    /**
     * @notice Sets an initial storage of the Safe contract.
     * @dev This method can only be called once.
     *      If a proxy was created without setting up, anyone can call setup and claim the proxy.
     * @param _owners List of Safe owners.
     * @param _threshold Number of required confirmations for a Safe transaction.
     * @param to Contract address for optional delegate call.
     * @param data Data payload for optional delegate call.
     * @param fallbackHandler Handler for fallback calls to this contract
     * @param paymentToken Token that should be used for the payment (0 is ETH)
     * @param payment Value that should be paid
     * @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)
     */
    function setup(
        address[] calldata _owners,
        uint256 _threshold,
        address to,
        bytes calldata data,
        address fallbackHandler,
        address paymentToken,
        uint256 payment,
        address payable paymentReceiver
    ) external {
        // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice
        setupOwners(_owners, _threshold);
        if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);
        // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules
        setupModules(to, data);

        if (payment > 0) {
            // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)
            // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment
            handlePayment(payment, 0, 1, paymentToken, paymentReceiver);
        }
        emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);
    }

    /** @notice Executes a `operation` {0: Call, 1: DelegateCall}} transaction to `to` with `value` (Native Currency)
     *          and pays `gasPrice` * `gasLimit` in `gasToken` token to `refundReceiver`.
     * @dev The fees are always transferred, even if the user transaction fails.
     *      This method doesn't perform any sanity check of the transaction, such as:
     *      - if the contract at `to` address has code or not
     *      - if the `gasToken` is a contract or not
     *      It is the responsibility of the caller to perform such checks.
     * @param to Destination address of Safe transaction.
     * @param value Ether value of Safe transaction.
     * @param data Data payload of Safe transaction.
     * @param operation Operation type of Safe transaction.
     * @param safeTxGas Gas that should be used for the Safe transaction.
     * @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
     * @param gasPrice Gas price that should be used for the payment calculation.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     * @return success Boolean indicating transaction's success.
     */
    function execTransaction(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver,
        bytes memory signatures
    ) public payable virtual returns (bool success) {
        bytes32 txHash;
        // Use scope here to limit variable lifetime and prevent `stack too deep` errors
        {
            bytes memory txHashData = encodeTransactionData(
                // Transaction info
                to,
                value,
                data,
                operation,
                safeTxGas,
                // Payment info
                baseGas,
                gasPrice,
                gasToken,
                refundReceiver,
                // Signature info
                nonce
            );
            // Increase nonce and execute transaction.
            nonce++;
            txHash = keccak256(txHashData);
            checkSignatures(txHash, txHashData, signatures);
        }
        address guard = getGuard();
        {
            if (guard != address(0)) {
                Guard(guard).checkTransaction(
                    // Transaction info
                    to,
                    value,
                    data,
                    operation,
                    safeTxGas,
                    // Payment info
                    baseGas,
                    gasPrice,
                    gasToken,
                    refundReceiver,
                    // Signature info
                    signatures,
                    msg.sender
                );
            }
        }
        // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)
        // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150
        require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, "GS010");
        // Use scope here to limit variable lifetime and prevent `stack too deep` errors
        {
            uint256 gasUsed = gasleft();
            // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)
            // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas
            success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);
            gasUsed = gasUsed.sub(gasleft());
            // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful
            // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert
            require(success || safeTxGas != 0 || gasPrice != 0, "GS013");
            // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls
            uint256 payment = 0;
            if (gasPrice > 0) {
                payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);
            }
            if (success) emit ExecutionSuccess(txHash, payment);
            else emit ExecutionFailure(txHash, payment);
        }
        {
            if (guard != address(0)) {
                Guard(guard).checkAfterExecution(txHash, success);
            }
        }
    }

    /**
     * @notice Handles the payment for a Safe transaction.
     * @param gasUsed Gas used by the Safe transaction.
     * @param baseGas Gas costs that are independent of the transaction execution (e.g. base transaction fee, signature check, payment of the refund).
     * @param gasPrice Gas price that should be used for the payment calculation.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @return payment The amount of payment made in the specified token.
     */
    function handlePayment(
        uint256 gasUsed,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address payable refundReceiver
    ) private returns (uint256 payment) {
        // solhint-disable-next-line avoid-tx-origin
        address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;
        if (gasToken == address(0)) {
            // For ETH we will only adjust the gas price to not be higher than the actual used gas price
            payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);
            require(receiver.send(payment), "GS011");
        } else {
            payment = gasUsed.add(baseGas).mul(gasPrice);
            require(transferToken(gasToken, receiver, payment), "GS012");
        }
    }

    /**
     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.
     * @param dataHash Hash of the data (could be either a message hash or transaction hash)
     * @param data That should be signed (this is passed to an external validator contract)
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     */
    function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures) public view {
        // Load threshold to avoid multiple storage loads
        uint256 _threshold = threshold;
        // Check that a threshold is set
        require(_threshold > 0, "GS001");
        checkNSignatures(dataHash, data, signatures, _threshold);
    }

    /**
     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.
     * @dev Since the EIP-1271 does an external call, be mindful of reentrancy attacks.
     * @param dataHash Hash of the data (could be either a message hash or transaction hash)
     * @param data That should be signed (this is passed to an external validator contract)
     * @param signatures Signature data that should be verified.
     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.
     * @param requiredSignatures Amount of required valid signatures.
     */
    function checkNSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, uint256 requiredSignatures) public view {
        // Check that the provided signature data is not too short
        require(signatures.length >= requiredSignatures.mul(65), "GS020");
        // There cannot be an owner with address 0.
        address lastOwner = address(0);
        address currentOwner;
        uint8 v;
        bytes32 r;
        bytes32 s;
        uint256 i;
        for (i = 0; i < requiredSignatures; i++) {
            (v, r, s) = signatureSplit(signatures, i);
            if (v == 0) {
                require(keccak256(data) == dataHash, "GS027");
                // If v is 0 then it is a contract signature
                // When handling contract signatures the address of the contract is encoded into r
                currentOwner = address(uint160(uint256(r)));

                // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes
                // This check is not completely accurate, since it is possible that more signatures than the threshold are send.
                // Here we only check that the pointer is not pointing inside the part that is being processed
                require(uint256(s) >= requiredSignatures.mul(65), "GS021");

                // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)
                require(uint256(s).add(32) <= signatures.length, "GS022");

                // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length
                uint256 contractSignatureLen;
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    contractSignatureLen := mload(add(add(signatures, s), 0x20))
                }
                require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, "GS023");

                // Check signature
                bytes memory contractSignature;
                // solhint-disable-next-line no-inline-assembly
                assembly {
                    // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s
                    contractSignature := add(add(signatures, s), 0x20)
                }
                require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, "GS024");
            } else if (v == 1) {
                // If v is 1 then it is an approved hash
                // When handling approved hashes the address of the approver is encoded into r
                currentOwner = address(uint160(uint256(r)));
                // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction
                require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, "GS025");
            } else if (v > 30) {
                // If v > 30 then default va (27,28) has been adjusted for eth_sign flow
                // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover
                currentOwner = ecrecover(keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", dataHash)), v - 4, r, s);
            } else {
                // Default is the ecrecover flow with the provided data hash
                // Use ecrecover with the messageHash for EOA signatures
                currentOwner = ecrecover(dataHash, v, r, s);
            }
            require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, "GS026");
            lastOwner = currentOwner;
        }
    }

    /**
     * @notice Marks hash `hashToApprove` as approved.
     * @dev This can be used with a pre-approved hash transaction signature.
     *      IMPORTANT: The approved hash stays approved forever. There's no revocation mechanism, so it behaves similarly to ECDSA signatures
     * @param hashToApprove The hash to mark as approved for signatures that are verified by this contract.
     */
    function approveHash(bytes32 hashToApprove) external {
        require(owners[msg.sender] != address(0), "GS030");
        approvedHashes[msg.sender][hashToApprove] = 1;
        emit ApproveHash(hashToApprove, msg.sender);
    }

    /**
     * @notice Returns the ID of the chain the contract is currently deployed on.
     * @return The ID of the current chain as a uint256.
     */
    function getChainId() public view returns (uint256) {
        uint256 id;
        // solhint-disable-next-line no-inline-assembly
        assembly {
            id := chainid()
        }
        return id;
    }

    /**
     * @dev Returns the domain separator for this contract, as defined in the EIP-712 standard.
     * @return bytes32 The domain separator hash.
     */
    function domainSeparator() public view returns (bytes32) {
        return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));
    }

    /**
     * @notice Returns the pre-image of the transaction hash (see getTransactionHash).
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @param safeTxGas Gas that should be used for the safe transaction.
     * @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
     * @param gasPrice Maximum gas price that should be used for this transaction.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param _nonce Transaction nonce.
     * @return Transaction hash bytes.
     */
    function encodeTransactionData(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes memory) {
        bytes32 safeTxHash = keccak256(
            abi.encode(
                SAFE_TX_TYPEHASH,
                to,
                value,
                keccak256(data),
                operation,
                safeTxGas,
                baseGas,
                gasPrice,
                gasToken,
                refundReceiver,
                _nonce
            )
        );
        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);
    }

    /**
     * @notice Returns transaction hash to be signed by owners.
     * @param to Destination address.
     * @param value Ether value.
     * @param data Data payload.
     * @param operation Operation type.
     * @param safeTxGas Fas that should be used for the safe transaction.
     * @param baseGas Gas costs for data used to trigger the safe transaction.
     * @param gasPrice Maximum gas price that should be used for this transaction.
     * @param gasToken Token address (or 0 if ETH) that is used for the payment.
     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).
     * @param _nonce Transaction nonce.
     * @return Transaction hash.
     */
    function getTransactionHash(
        address to,
        uint256 value,
        bytes calldata data,
        Enum.Operation operation,
        uint256 safeTxGas,
        uint256 baseGas,
        uint256 gasPrice,
        address gasToken,
        address refundReceiver,
        uint256 _nonce
    ) public view returns (bytes32) {
        return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));
    }
}

File 23 of 28 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

import "./math/Math.sol";

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

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

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

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

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

File 27 of 28 : CandideWallet.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.0 <0.9.0;

import "@gnosis.pm/safe-contracts/contracts/Safe.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

import "@account-abstraction/contracts/interfaces/IEntryPoint.sol";
import "../utils/Exec.sol";

/// @title CandideWallet - Smart contract wallet based on Gnosis safe that supports Eip4337
/// @author CandideWallet Team
contract CandideWallet is Safe{
    using ECDSA for bytes32;

    //EIP4337 trusted entrypoint
    address public entryPoint;

    string public constant CANDIDE_VERSION = "0.0.1";
    //return value in case of signature failure, with no time-range.
    uint256 constant internal SIG_VALIDATION_FAILED = 1;

    /// @dev Setup function sets initial storage of contract.
    /// @param _owners List of Safe owners.
    /// @param _threshold Number of required confirmations for a Safe transaction.
    /// @param to Contract address for optional delegate call.
    /// @param data Data payload for optional delegate call.
    /// @param fallbackHandler Handler for fallback calls to this contract
    /// @param paymentToken Token that should be used for the payment (0 is ETH)
    /// @param payment Value that should be paid
    /// @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)
    /// @param _entryPoint Address for the trusted EIP4337 entrypoint
    function setupWithEntrypoint(
        address[] calldata _owners,
        uint256 _threshold,
        address to,
        bytes calldata data,
        address fallbackHandler,
        address paymentToken,
        uint256 payment,
        address payable paymentReceiver,
        address _entryPoint
    ) external {
        entryPoint = _entryPoint;

        _executeAndRevert(
            address(this),
            0,
            abi.encodeCall(Safe.setup, (
                _owners, _threshold,
                to, data,
                fallbackHandler,paymentToken,
                payment, paymentReceiver
            )),
            Enum.Operation.DelegateCall
        );
    }

    /// @dev Called by the entrypoint to validate the user's signature and nonce
    /// @param userOp is the entrypoint user operation
    /// @param userOpHash is the entrypoint user operation hash
    /// @param missingAccountFunds the minimum value this method should send the entrypoint.
    /// this value MAY be zero, in case there is enough deposit, or the userOp has a paymaster.
    /// @return validationData returns SIG_VALIDATION_FAILED value (1) for signature failure.
    function validateUserOp(UserOperation calldata userOp, bytes32 userOpHash, 
        uint256 missingAccountFunds) external returns (uint256 validationData){
        _requireFromEntryPoint();
        validationData = _validateSignature(userOp, userOpHash);
        // mimic normal Safe nonce behaviour: prevent parallel nonces
        require(userOp.nonce < type(uint64).max, "account: nonsequential nonce");
        _payPrefund(missingAccountFunds);
    }

    /**
    * ensure the request comes from the known entrypoint.
    */
    function _requireFromEntryPoint() internal virtual view {
        require(msg.sender == entryPoint, "account: not from EntryPoint");
    }

    function _validateSignature(UserOperation calldata userOp, bytes32 userOpHash)
    internal view returns (uint256 validationData) {
        bytes32 hash = userOpHash.toEthSignedMessageHash();
        try this.checkSignatures(
            hash,
            bytes(abi.encode(userOp)),
            userOp.signature
        ){
            return 0;
        } catch {
            return SIG_VALIDATION_FAILED;
        }
        return 0;
    }

    function _payPrefund(uint256 missingAccountFunds) internal {
        if (missingAccountFunds != 0) {
            (bool success,) = payable(msg.sender).call{value : missingAccountFunds, gas : type(uint256).max}("");
            (success);
            //ignore failure (its EntryPoint's job to verify, not account.)
        }
    }

    /// @dev Allows the entrypoint to execute a transaction without any further confirmations.
    /// @param to Destination address of module transaction.
    /// @param value Ether value of module transaction.
    /// @param data Data payload of module transaction.
    /// @param operation Operation type of module transaction.
    /// @param paymaster address.
    /// @param approveToken token to be approved for the paymaster.
    /// @param approveAmount token amount to be approved by the paymaster.
    function execTransactionFromEntrypoint(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation,
        address paymaster,
        address approveToken,
        uint256 approveAmount
    ) public {
        // Only Entrypoint is allowed.
        require(msg.sender == entryPoint, "account: not from EntryPoint");
        // Execute transaction without further confirmations.
        _executeAndRevert(to, value, data, operation);

        //instead of sending a separate transaction to approve tokens
        //for the paymaster for each transaction, it can be approved here
        if(paymaster != 0x0000000000000000000000000000000000000000){
            IERC20 token = IERC20(approveToken);
            token.approve(paymaster, approveAmount);
        }
    }

    function _executeAndRevert(
        address to,
        uint256 value,
        bytes memory data,
        Enum.Operation operation
    ) internal {

        bool success = execute(
            to,
            value,
            data,
            operation,
            type(uint256).max
        );

        bytes memory returnData = Exec.getReturnData(type(uint256).max);
        // Revert with the actual reason string
        // Adopted from: https://github.com/Uniswap/v3-periphery/blob/464a8a49611272f7349c970e0fadb7ec1d3c1086/contracts/base/Multicall.sol#L16-L23
        if (!success) {
            if (returnData.length < 68) revert();
            assembly {
                returnData := add(returnData, 0x04)
            }
            revert(abi.decode(returnData, (string)));
        }
    }

    /// @dev There should be only one verified entrypoint per chain
    /// @dev so this function should only be used if there is a problem with
    /// @dev the main entrypoint
    function replaceEntrypoint(address newEntrypoint) public authorized {
        entryPoint = newEntrypoint;
    }

    function getNonce() public view returns (uint256) {
        return IEntryPoint(entryPoint).getNonce(address(this), 0);
    }
}

File 28 of 28 : Exec.sol
// SPDX-License-Identifier: LGPL-3.0-only
pragma solidity >=0.7.5 <0.9.0;

// solhint-disable no-inline-assembly

/**
 * Utility functions helpful when making different kinds of contract calls in Solidity.
 */
library Exec {

    function call(
        address to,
        uint256 value,
        bytes memory data,
        uint256 txGas
    ) internal returns (bool success) {
        assembly {
            success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)
        }
    }

    function staticcall(
        address to,
        bytes memory data,
        uint256 txGas
    ) internal view returns (bool success) {
        assembly {
            success := staticcall(txGas, to, add(data, 0x20), mload(data), 0, 0)
        }
    }

    function delegateCall(
        address to,
        bytes memory data,
        uint256 txGas
    ) internal returns (bool success) {
        assembly {
            success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)
        }
    }

    // get returned data from last call or calldelegate
    function getReturnData(uint256 maxLen) internal pure returns (bytes memory returnData) {
        assembly {
            let len := returndatasize()
            if gt(len, maxLen) {
                len := maxLen
            }
            let ptr := mload(0x40)
            mstore(0x40, add(ptr, add(len, 0x20)))
            mstore(ptr, len)
            returndatacopy(add(ptr, 0x20), 0, len)
            returnData := ptr
        }
    }

    // revert with explicit byte array (probably reverted info from call)
    function revertWithData(bytes memory returnData) internal pure {
        assembly {
            revert(add(returnData, 32), mload(returnData))
        }
    }

    function callAndRevert(address to, bytes memory data, uint256 maxLen) internal {
        bool success = call(to,0,data,gasleft());
        if (!success) {
            revertWithData(getReturnData(maxLen));
        }
    }
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"AddedOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"approvedHash","type":"bytes32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"ApproveHash","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"handler","type":"address"}],"name":"ChangedFallbackHandler","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"guard","type":"address"}],"name":"ChangedGuard","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"}],"name":"ChangedThreshold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"DisabledModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"EnabledModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"txHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"payment","type":"uint256"}],"name":"ExecutionFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"ExecutionFromModuleFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"module","type":"address"}],"name":"ExecutionFromModuleSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"txHash","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"payment","type":"uint256"}],"name":"ExecutionSuccess","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"RemovedOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeReceived","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"initiator","type":"address"},{"indexed":false,"internalType":"address[]","name":"owners","type":"address[]"},{"indexed":false,"internalType":"uint256","name":"threshold","type":"uint256"},{"indexed":false,"internalType":"address","name":"initializer","type":"address"},{"indexed":false,"internalType":"address","name":"fallbackHandler","type":"address"}],"name":"SafeSetup","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"msgHash","type":"bytes32"}],"name":"SignMsg","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[],"name":"CANDIDE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"addOwnerWithThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hashToApprove","type":"bytes32"}],"name":"approveHash","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"approvedHashes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"changeThreshold","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signatures","type":"bytes"},{"internalType":"uint256","name":"requiredSignatures","type":"uint256"}],"name":"checkNSignatures","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"dataHash","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"bytes","name":"signatures","type":"bytes"}],"name":"checkSignatures","outputs":[],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"prevModule","type":"address"},{"internalType":"address","name":"module","type":"address"}],"name":"disableModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"domainSeparator","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"enableModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"address","name":"refundReceiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"encodeTransactionData","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"entryPoint","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"address payable","name":"refundReceiver","type":"address"},{"internalType":"bytes","name":"signatures","type":"bytes"}],"name":"execTransaction","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"},{"internalType":"address","name":"paymaster","type":"address"},{"internalType":"address","name":"approveToken","type":"address"},{"internalType":"uint256","name":"approveAmount","type":"uint256"}],"name":"execTransactionFromEntrypoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"}],"name":"execTransactionFromModule","outputs":[{"internalType":"bool","name":"success","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"}],"name":"execTransactionFromModuleReturnData","outputs":[{"internalType":"bool","name":"success","type":"bool"},{"internalType":"bytes","name":"returnData","type":"bytes"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getChainId","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"start","type":"address"},{"internalType":"uint256","name":"pageSize","type":"uint256"}],"name":"getModulesPaginated","outputs":[{"internalType":"address[]","name":"array","type":"address[]"},{"internalType":"address","name":"next","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getOwners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"offset","type":"uint256"},{"internalType":"uint256","name":"length","type":"uint256"}],"name":"getStorageAt","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"enum Enum.Operation","name":"operation","type":"uint8"},{"internalType":"uint256","name":"safeTxGas","type":"uint256"},{"internalType":"uint256","name":"baseGas","type":"uint256"},{"internalType":"uint256","name":"gasPrice","type":"uint256"},{"internalType":"address","name":"gasToken","type":"address"},{"internalType":"address","name":"refundReceiver","type":"address"},{"internalType":"uint256","name":"_nonce","type":"uint256"}],"name":"getTransactionHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"module","type":"address"}],"name":"isModuleEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"prevOwner","type":"address"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"_threshold","type":"uint256"}],"name":"removeOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newEntrypoint","type":"address"}],"name":"replaceEntrypoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"handler","type":"address"}],"name":"setFallbackHandler","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"guard","type":"address"}],"name":"setGuard","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_owners","type":"address[]"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"fallbackHandler","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"payment","type":"uint256"},{"internalType":"address payable","name":"paymentReceiver","type":"address"}],"name":"setup","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_owners","type":"address[]"},{"internalType":"uint256","name":"_threshold","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"address","name":"fallbackHandler","type":"address"},{"internalType":"address","name":"paymentToken","type":"address"},{"internalType":"uint256","name":"payment","type":"uint256"},{"internalType":"address payable","name":"paymentReceiver","type":"address"},{"internalType":"address","name":"_entryPoint","type":"address"}],"name":"setupWithEntrypoint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"signedMessages","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"targetContract","type":"address"},{"internalType":"bytes","name":"calldataPayload","type":"bytes"}],"name":"simulateAndRevert","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"prevOwner","type":"address"},{"internalType":"address","name":"oldOwner","type":"address"},{"internalType":"address","name":"newOwner","type":"address"}],"name":"swapOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"bytes","name":"initCode","type":"bytes"},{"internalType":"bytes","name":"callData","type":"bytes"},{"internalType":"uint256","name":"callGasLimit","type":"uint256"},{"internalType":"uint256","name":"verificationGasLimit","type":"uint256"},{"internalType":"uint256","name":"preVerificationGas","type":"uint256"},{"internalType":"uint256","name":"maxFeePerGas","type":"uint256"},{"internalType":"uint256","name":"maxPriorityFeePerGas","type":"uint256"},{"internalType":"bytes","name":"paymasterAndData","type":"bytes"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct UserOperation","name":"userOp","type":"tuple"},{"internalType":"bytes32","name":"userOpHash","type":"bytes32"},{"internalType":"uint256","name":"missingAccountFunds","type":"uint256"}],"name":"validateUserOp","outputs":[{"internalType":"uint256","name":"validationData","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

608060405234801561001057600080fd5b506001600455613be0806100256000396000f3fe60806040526004361061021e5760003560e01c8063affed0e011610123578063e19a9dd9116100ab578063f30d76a31161006f578063f30d76a314610724578063f34308ef14610744578063f698da2514610764578063f8dc5dd914610779578063ffa1ad74146107995761025a565b8063e19a9dd91461068f578063e318b52b146106af578063e75235b8146106cf578063e86637db146106e4578063f08a0323146107045761025a565b8063cc2f8452116100f2578063cc2f8452146105ec578063d087d2881461061a578063d4d9bdcd1461062f578063d8d11f781461064f578063e009cfde1461066f5761025a565b8063affed0e01461055e578063b0d691fe14610574578063b4faba09146105ac578063b63e800d146105cc5761025a565b80635624b25b116101a65780636a1e9826116101755780636a1e9826146104b15780636a761202146104d15780637d832974146104e4578063934f3a111461051c578063a0e67e2b1461053c5761025a565b80635624b25b146104245780635ae6bd3714610444578063610b592514610471578063694e80c3146104915761025a565b80632f54bf6e116101ed5780632f54bf6e146103795780633408e470146103995780633a871cdd146103b6578063468721a7146103d65780635229073f146103f65761025a565b80630d582f13146102c057806312fb68e0146102e257806327fcac76146103025780632d9ad53d146103495761025a565b3661025a5760405134815233907f3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d9060200160405180910390a2005b34801561026657600080fd5b507f6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d580548061029157005b36600080373360601b365260008060143601600080855af190503d6000803e806102ba573d6000fd5b503d6000f35b3480156102cc57600080fd5b506102e06102db366004612be3565b6107ca565b005b3480156102ee57600080fd5b506102e06102fd366004612cd2565b610922565b34801561030e57600080fd5b5061033360405180604001604052806005815260200164302e302e3160d81b81525081565b6040516103409190612d9e565b60405180910390f35b34801561035557600080fd5b50610369610364366004612db1565b610dc7565b6040519015158152602001610340565b34801561038557600080fd5b50610369610394366004612db1565b610e02565b3480156103a557600080fd5b50465b604051908152602001610340565b3480156103c257600080fd5b506103a86103d1366004612dce565b610e3a565b3480156103e257600080fd5b506103696103f1366004612e30565b610eba565b34801561040257600080fd5b50610416610411366004612e30565b610f93565b604051610340929190612e99565b34801561043057600080fd5b5061033361043f366004612eb4565b610fc9565b34801561045057600080fd5b506103a861045f366004612ed6565b60076020526000908152604090205481565b34801561047d57600080fd5b506102e061048c366004612db1565b61104e565b34801561049d57600080fd5b506102e06104ac366004612ed6565b611187565b3480156104bd57600080fd5b506102e06104cc366004612f7b565b611225565b6103696104df366004613059565b6112aa565b3480156104f057600080fd5b506103a86104ff366004612be3565b600860209081526000928352604080842090915290825290205481565b34801561052857600080fd5b506102e061053736600461311f565b6115f5565b34801561054857600080fd5b5061055161163f565b60405161034091906131cf565b34801561056a57600080fd5b506103a860055481565b34801561058057600080fd5b50600954610594906001600160a01b031681565b6040516001600160a01b039091168152602001610340565b3480156105b857600080fd5b506102e06105c73660046131e2565b61172f565b3480156105d857600080fd5b506102e06105e7366004613231565b611752565b3480156105f857600080fd5b5061060c610607366004612be3565b611854565b604051610340929190613301565b34801561062657600080fd5b506103a8611a0f565b34801561063b57600080fd5b506102e061064a366004612ed6565b611a88565b34801561065b57600080fd5b506103a861066a36600461332b565b611b1d565b34801561067b57600080fd5b506102e061068a3660046133eb565b611b4a565b34801561069b57600080fd5b506102e06106aa366004612db1565b611c6c565b3480156106bb57600080fd5b506102e06106ca366004613424565b611d82565b3480156106db57600080fd5b506004546103a8565b3480156106f057600080fd5b506103336106ff36600461332b565b611f5d565b34801561071057600080fd5b506102e061071f366004612db1565b612036565b34801561073057600080fd5b506102e061073f366004612db1565b61207e565b34801561075057600080fd5b506102e061075f36600461346f565b6120a8565b34801561077057600080fd5b506103a861219f565b34801561078557600080fd5b506102e0610794366004613509565b6121f6565b3480156107a557600080fd5b50610333604051806040016040528060058152602001640312e342e360dc1b81525081565b6107d2612361565b6001600160a01b038216158015906107f457506001600160a01b038216600114155b801561080957506001600160a01b0382163014155b61082e5760405162461bcd60e51b81526004016108259061354a565b60405180910390fd5b6001600160a01b0382811660009081526002602052604090205416156108665760405162461bcd60e51b815260040161082590613569565b60026020527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e080546001600160a01b038481166000818152604081208054939094166001600160a01b0319938416179093556001835283549091161790915560038054916108d38361359e565b90915550506040516001600160a01b038316907f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea2690600090a2806004541461091e5761091e81611187565b5050565b61092d81604161239a565b825110156109655760405162461bcd60e51b8152602060048201526005602482015264047533032360dc1b6044820152606401610825565b6000808060008060005b86811015610dbb576041818102890160208101516040820151919092015160ff169550909350915083610b7957885160208a01208a146109d95760405162461bcd60e51b8152602060048201526005602482015264475330323760d81b6044820152606401610825565b91935083916109e987604161239a565b821015610a205760405162461bcd60e51b8152602060048201526005602482015264475330323160d81b6044820152606401610825565b8751610a2d8360206123cc565b1115610a635760405162461bcd60e51b815260206004820152600560248201526423a998191960d91b6044820152606401610825565b602082890181015189519091610a86908390610a809087906123cc565b906123cc565b1115610abc5760405162461bcd60e51b8152602060048201526005602482015264475330323360d81b6044820152606401610825565b6040516320c13b0b60e01b8082528a8501602001916001600160a01b038916906320c13b0b90610af2908f9086906004016135b9565b602060405180830381865afa158015610b0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3391906135de565b6001600160e01b03191614610b725760405162461bcd60e51b815260206004820152600560248201526411d4cc0c8d60da1b6044820152606401610825565b5050610d21565b8360ff1660011415610bfc579193508391336001600160a01b0384161480610bc357506001600160a01b03851660009081526008602090815260408083208d845290915290205415155b610bf75760405162461bcd60e51b8152602060048201526005602482015264475330323560d81b6044820152606401610825565b610d21565b601e8460ff161115610cc1576040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018b9052600190605c0160405160208183030381529060405280519060200120600486610c619190613608565b6040805160008152602081018083529390935260ff90911690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610cb0573d6000803e3d6000fd5b505050602060405103519450610d21565b6040805160008152602081018083528c905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610d14573d6000803e3d6000fd5b5050506020604051035194505b856001600160a01b0316856001600160a01b0316118015610d5b57506001600160a01b038581166000908152600260205260409020541615155b8015610d7157506001600160a01b038516600114155b610da55760405162461bcd60e51b815260206004820152600560248201526423a998191b60d91b6044820152606401610825565b8495508080610db39061359e565b91505061096f565b50505050505050505050565b600060016001600160a01b03831614801590610dfc57506001600160a01b038281166000908152600160205260409020541615155b92915050565b60006001600160a01b038216600114801590610dfc5750506001600160a01b0390811660009081526002602052604090205416151590565b6000610e446123e8565b610e4e8484612442565b90506001600160401b03602085013510610eaa5760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f6e73657175656e7469616c206e6f6e6365000000006044820152606401610825565b610eb38261253d565b9392505050565b600033600114801590610ee45750336000908152600160205260409020546001600160a01b031615155b610f185760405162461bcd60e51b815260206004820152600560248201526411d4cc4c0d60da1b6044820152606401610825565b610f2785858585600019612597565b90508015610f5f5760405133907f6895c13664aa4f67288b25d7a21d7aaa34916e355fb9b6fae0a139a9085becb890600090a2610f8b565b60405133907facd2c8702804128fdb0db2bb49f6d127dd0181c13fd45dbfe16de0930e2bd37590600090a25b949350505050565b60006060610fa386868686610eba565b915060405160203d0181016040523d81523d6000602083013e8091505094509492505050565b60606000610fd883602061362b565b6001600160401b03811115610fef57610fef612c0f565b6040519080825280601f01601f191660200182016040528015611019576020820181803683370190505b50905060005b8381101561104657848101546020808302840101528061103e8161359e565b91505061101f565b509392505050565b611056612361565b6001600160a01b0381161580159061107857506001600160a01b038116600114155b6110ac5760405162461bcd60e51b8152602060048201526005602482015264475331303160d81b6044820152606401610825565b6001600160a01b0381811660009081526001602052604090205416156110fc5760405162461bcd60e51b815260206004820152600560248201526423a998981960d91b6044820152606401610825565b600160208190527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b03848116600081815260408082208054949095166001600160a01b031994851617909455948552835490911681179092555190917fecdf3a3effea5783a3c4c2140e677577666428d44ed9d474a0b3a4c9943f844091a250565b61118f612361565b6003548111156111b15760405162461bcd60e51b81526004016108259061364a565b60018110156111ea5760405162461bcd60e51b815260206004820152600560248201526423a999181960d91b6044820152606401610825565b60048190556040518181527f610f7ff2b304ae8903c3de74c60c6ab1f7d6226b3f52c5161905bb5ad4039c939060200160405180910390a150565b600980546001600160a01b0319166001600160a01b03831617905560405161129d90309060009061126c908f908f908f908f908f908f908f908f908f908f906024016136d0565b60408051601f198184030181529190526020810180516001600160e01b031663b63e800d60e01b17905260016125df565b5050505050505050505050565b60008060006112c48e8e8e8e8e8e8e8e8e8e600554611f5d565b6005805491925060006112d68361359e565b90915550508051602082012091506112ef8282866115f5565b50600061131a7f4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c85490565b90506001600160a01b038116156113a057806001600160a01b03166375f0bb528f8f8f8f8f8f8f8f8f8f8f336040518d63ffffffff1660e01b815260040161136d9c9b9a99989796959493929190613777565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b505050505b6113cc6113af8a6109c4613803565b603f6113bc8c604061362b565b6113c6919061381b565b90612650565b6113d8906101f4613803565b5a101561140f5760405162461bcd60e51b8152602060048201526005602482015264047533031360dc1b6044820152606401610825565b60005a90506114808f8f8f8f8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508e8c60001461146d578e612597565b6109c45a61147b919061383d565b612597565b935061148d5a8290612667565b9050838061149a57508915155b806114a457508715155b6114d85760405162461bcd60e51b8152602060048201526005602482015264475330313360d81b6044820152606401610825565b600088156114f0576114ed828b8b8b8b612682565b90505b841561153557837f442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e8260405161152891815260200190565b60405180910390a2611570565b837f23428b18acfb3ea64b08dc0c1d296ea9c09702c09083ca5272e64d115b687d238260405161156791815260200190565b60405180910390a25b50506001600160a01b038116156115e457604051631264e26d60e31b81526004810183905283151560248201526001600160a01b03821690639327136890604401600060405180830381600087803b1580156115cb57600080fd5b505af11580156115df573d6000803e3d6000fd5b505050505b50509b9a5050505050505050505050565b6004548061162d5760405162461bcd60e51b8152602060048201526005602482015264475330303160d81b6044820152606401610825565b61163984848484610922565b50505050565b606060006003546001600160401b0381111561165d5761165d612c0f565b604051908082528060200260200182016040528015611686578160200160208202803683370190505b506001600090815260026020527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e054919250906001600160a01b03165b6001600160a01b03811660011461172757808383815181106116e7576116e7613854565b6001600160a01b0392831660209182029290920181019190915291811660009081526002909252604090912054168161171f8161359e565b9250506116c3565b509092915050565b600080825160208401855af480600052503d6020523d600060403e60403d016000fd5b6117908a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508c9250612788915050565b6001600160a01b038416156117a8576117a88461296e565b6117e88787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129d392505050565b81156117ff576117fd82600060018685612682565b505b336001600160a01b03167f141df868a6331af528e38c83b7aa03edc19be66e37ae67f9285bf4f8e3c6a1a88b8b8b8b8960405161184095949392919061386a565b60405180910390a250505050505050505050565b606060006001600160a01b03841660011480611874575061187484610dc7565b6118a85760405162461bcd60e51b8152602060048201526005602482015264475331303560d81b6044820152606401610825565b600083116118e05760405162461bcd60e51b815260206004820152600560248201526423a998981b60d91b6044820152606401610825565b826001600160401b038111156118f8576118f8612c0f565b604051908082528060200260200182016040528015611921578160200160208202803683370190505b506001600160a01b03808616600090815260016020526040812054929450911691505b6001600160a01b0382161580159061196657506001600160a01b038216600114155b801561197157508381105b156119cc578183828151811061198957611989613854565b6001600160a01b039283166020918202929092018101919091529281166000908152600190935260409092205490911690806119c48161359e565b915050611944565b6001600160a01b038216600114611a0457826119e960018361383d565b815181106119f9576119f9613854565b602002602001015191505b808352509250929050565b600954604051631aab3f0d60e11b8152306004820152600060248201819052916001600160a01b0316906335567e1a90604401602060405180830381865afa158015611a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8391906138a5565b905090565b336000908152600260205260409020546001600160a01b0316611ad55760405162461bcd60e51b8152602060048201526005602482015264047533033360dc1b6044820152606401610825565b336000818152600860209081526040808320858452909152808220600190555183917ff2a0eb156472d1440255b0d7c1e19cc07115d1051fe605b0dce69acfec884d9c91a350565b6000611b328c8c8c8c8c8c8c8c8c8c8c611f5d565b8051906020012090509b9a5050505050505050505050565b611b52612361565b6001600160a01b03811615801590611b7457506001600160a01b038116600114155b611ba85760405162461bcd60e51b8152602060048201526005602482015264475331303160d81b6044820152606401610825565b6001600160a01b03828116600090815260016020526040902054811690821614611bfc5760405162461bcd60e51b8152602060048201526005602482015264475331303360d81b6044820152606401610825565b6001600160a01b03818116600081815260016020526040808220805487861684528284208054919096166001600160a01b0319918216179095558383528054909416909355915190917faab4fa2b463f581b2b32cb3b7e3b704b9ce37cc209b5fb4d77e593ace405427691a25050565b611c74612361565b6001600160a01b03811615611d26576040516301ffc9a760e01b815263736bd41d60e11b60048201526001600160a01b038216906301ffc9a790602401602060405180830381865afa158015611cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf291906138be565b611d265760405162461bcd60e51b8152602060048201526005602482015264047533330360dc1b6044820152606401610825565b7f4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c88181556040516001600160a01b038316907f1151116914515bc0891ff9047a6cb32cf902546f83066499bcf8ba33d2353fa290600090a25050565b611d8a612361565b6001600160a01b03811615801590611dac57506001600160a01b038116600114155b8015611dc157506001600160a01b0381163014155b611ddd5760405162461bcd60e51b81526004016108259061354a565b6001600160a01b038181166000908152600260205260409020541615611e155760405162461bcd60e51b815260040161082590613569565b6001600160a01b03821615801590611e3757506001600160a01b038216600114155b611e535760405162461bcd60e51b81526004016108259061354a565b6001600160a01b03838116600090815260026020526040902054811690831614611ea75760405162461bcd60e51b8152602060048201526005602482015264475332303560d81b6044820152606401610825565b6001600160a01b03828116600081815260026020526040808220805486861680855283852080549288166001600160a01b03199384161790559589168452828420805482169096179095558383528054909416909355915190917ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf91a26040516001600160a01b038216907f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea2690600090a2505050565b606060007fbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d860001b8d8d8d8d604051611f979291906138e0565b604051908190038120611fbd949392918e908e908e908e908e908e908e906020016138f0565b60408051601f1981840301815291905280516020909101209050601960f81b600160f81b611fe961219f565b6040516001600160f81b031993841660208201529290911660218301526022820152604281018290526062016040516020818303038152906040529150509b9a5050505050505050505050565b61203e612361565b6120478161296e565b6040516001600160a01b038216907f5ac6c46c93c8d0e53714ba3b53db3e7c046da994313d7ed0d192028bc7c228b090600090a250565b612086612361565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031633146121025760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e74000000006044820152606401610825565b61210e878787876125df565b6001600160a01b038316156121965760405163095ea7b360e01b81526001600160a01b0384811660048301526024820183905283919082169063095ea7b3906044016020604051808303816000875af115801561216f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219391906138be565b50505b50505050505050565b60007f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a794692184660408051602081019390935282015230606082015260800160405160208183030381529060405280519060200120905090565b6121fe612361565b80600160035461220e919061383d565b101561222c5760405162461bcd60e51b81526004016108259061364a565b6001600160a01b0382161580159061224e57506001600160a01b038216600114155b61226a5760405162461bcd60e51b81526004016108259061354a565b6001600160a01b038381166000908152600260205260409020548116908316146122be5760405162461bcd60e51b8152602060048201526005602482015264475332303560d81b6044820152606401610825565b6001600160a01b03828116600081815260026020526040808220805488861684529183208054929095166001600160a01b031992831617909455918152825490911690915560038054916123118361395f565b90915550506040516001600160a01b038316907ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf90600090a2806004541461235c5761235c81611187565b505050565b3330146123985760405162461bcd60e51b8152602060048201526005602482015264475330333160d81b6044820152606401610825565b565b6000826123a957506000610dfc565b60006123b5838561362b565b9050826123c2858361381b565b14610eb357600080fd5b6000806123d98385613803565b905083811015610eb357600080fd5b6009546001600160a01b031633146123985760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e74000000006044820152606401610825565b60008061249c836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b9050306001600160a01b031663934f3a1182866040516020016124bf91906139bb565b60408051601f198184030181529190526124dd610140890189613acb565b6040518563ffffffff1660e01b81526004016124fc9493929190613b11565b60006040518083038186803b15801561251457600080fd5b505afa925050508015612525575060015b612533576001915050610dfc565b6000915050610dfc565b801561259457604051600090339060001990849084818181858888f193505050503d806000811461258a576040519150601f19603f3d011682016040523d82523d6000602084013e61258f565b606091505b505050505b50565b600060018360018111156125ad576125ad61373f565b14156125c6576000808551602087018986f490506125d6565b600080855160208701888a87f190505b95945050505050565b60006125f085858585600019612597565b905060006125ff600019612b03565b9050816126485760448151101561261557600080fd5b6004810190508080602001905181019061262f9190613b3d565b60405162461bcd60e51b81526004016108259190612d9e565b505050505050565b6000818310156126605781610eb3565b5090919050565b60008282111561267657600080fd5b6000610f8b838561383d565b6000806001600160a01b0383161561269a578261269c565b325b90506001600160a01b03841661272f576126ce3a86106126bc573a6126be565b855b6126c889896123cc565b9061239a565b6040519092506001600160a01b0382169083156108fc029084906000818181858888f1935050505061272a5760405162461bcd60e51b8152602060048201526005602482015264475330313160d81b6044820152606401610825565b61277e565b61273d856126c889896123cc565b915061274a848284612b2f565b61277e5760405162461bcd60e51b815260206004820152600560248201526423a998189960d91b6044820152606401610825565b5095945050505050565b600454156127c05760405162461bcd60e51b8152602060048201526005602482015264047533230360dc1b6044820152606401610825565b81518111156127e15760405162461bcd60e51b81526004016108259061364a565b600181101561281a5760405162461bcd60e51b815260206004820152600560248201526423a999181960d91b6044820152606401610825565b600160005b835181101561293b57600084828151811061283c5761283c613854565b6020026020010151905060006001600160a01b0316816001600160a01b03161415801561287357506001600160a01b038116600114155b801561288857506001600160a01b0381163014155b80156128a65750806001600160a01b0316836001600160a01b031614155b6128c25760405162461bcd60e51b81526004016108259061354a565b6001600160a01b0381811660009081526002602052604090205416156128fa5760405162461bcd60e51b815260040161082590613569565b6001600160a01b03928316600090815260026020526040902080546001600160a01b03191693821693909317909255806129338161359e565b91505061281f565b506001600160a01b0316600090815260026020526040902080546001600160a01b03191660011790559051600355600455565b6001600160a01b0381163014156129af5760405162461bcd60e51b8152602060048201526005602482015264047533430360dc1b6044820152606401610825565b7f6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d555565b600160008190526020527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f546001600160a01b031615612a3d5760405162461bcd60e51b8152602060048201526005602482015264047533130360dc1b6044820152606401610825565b6001600081905260208190527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b03191690911790556001600160a01b0382161561091e57813b612ac05760405162461bcd60e51b815260206004820152600560248201526423a998181960d91b6044820152606401610825565b612acf8260008360015a612597565b61091e5760405162461bcd60e51b8152602060048201526005602482015264047533030360dc1b6044820152606401610825565b60603d82811115612b115750815b604051602082018101604052818152816000602083013e9392505050565b604080516001600160a01b03841660248201526044808201849052825180830390910181526064909101909152602080820180516001600160e01b031663a9059cbb60e01b1781528251600093929184919082896127105a03f13d8015612ba15760208114612ba95760009350612bb4565b819350612bb4565b600051158215171593505b5050509392505050565b6001600160a01b038116811461259457600080fd5b8035612bde81612bbe565b919050565b60008060408385031215612bf657600080fd5b8235612c0181612bbe565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612c4d57612c4d612c0f565b604052919050565b60006001600160401b03821115612c6e57612c6e612c0f565b50601f01601f191660200190565b600082601f830112612c8d57600080fd5b8135612ca0612c9b82612c55565b612c25565b818152846020838601011115612cb557600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612ce857600080fd5b8435935060208501356001600160401b0380821115612d0657600080fd5b612d1288838901612c7c565b94506040870135915080821115612d2857600080fd5b50612d3587828801612c7c565b949793965093946060013593505050565b60005b83811015612d61578181015183820152602001612d49565b838111156116395750506000910152565b60008151808452612d8a816020860160208601612d46565b601f01601f19169290920160200192915050565b602081526000610eb36020830184612d72565b600060208284031215612dc357600080fd5b8135610eb381612bbe565b600080600060608486031215612de357600080fd5b83356001600160401b03811115612df957600080fd5b84016101608187031215612e0c57600080fd5b95602085013595506040909401359392505050565b803560028110612bde57600080fd5b60008060008060808587031215612e4657600080fd5b8435612e5181612bbe565b93506020850135925060408501356001600160401b03811115612e7357600080fd5b612e7f87828801612c7c565b925050612e8e60608601612e21565b905092959194509250565b8215158152604060208201526000610f8b6040830184612d72565b60008060408385031215612ec757600080fd5b50508035926020909101359150565b600060208284031215612ee857600080fd5b5035919050565b60008083601f840112612f0157600080fd5b5081356001600160401b03811115612f1857600080fd5b6020830191508360208260051b8501011115612f3357600080fd5b9250929050565b60008083601f840112612f4c57600080fd5b5081356001600160401b03811115612f6357600080fd5b602083019150836020828501011115612f3357600080fd5b60008060008060008060008060008060006101208c8e031215612f9d57600080fd5b6001600160401b03808d351115612fb357600080fd5b612fc08e8e358f01612eef565b909c509a5060208d01359950612fd960408e0135612bbe565b60408d013598508060608e01351115612ff157600080fd5b506130028d60608e01358e01612f3a565b909750955060808c013561301581612bbe565b945061302360a08d01612bd3565b935060c08c0135925061303860e08d01612bd3565b91506130476101008d01612bd3565b90509295989b509295989b9093969950565b60008060008060008060008060008060006101408c8e03121561307b57600080fd5b6130848c612bd3565b9a5060208c013599506001600160401b038060408e013511156130a657600080fd5b6130b68e60408f01358f01612f3a565b909a5098506130c760608e01612e21565b975060808d0135965060a08d0135955060c08d013594506130ea60e08e01612bd3565b93506130f96101008e01612bd3565b9250806101208e0135111561310d57600080fd5b506130478d6101208e01358e01612c7c565b60008060006060848603121561313457600080fd5b8335925060208401356001600160401b038082111561315257600080fd5b61315e87838801612c7c565b9350604086013591508082111561317457600080fd5b5061318186828701612c7c565b9150509250925092565b600081518084526020808501945080840160005b838110156131c45781516001600160a01b03168752958201959082019060010161319f565b509495945050505050565b602081526000610eb3602083018461318b565b600080604083850312156131f557600080fd5b823561320081612bbe565b915060208301356001600160401b0381111561321b57600080fd5b61322785828601612c7c565b9150509250929050565b6000806000806000806000806000806101008b8d03121561325157600080fd5b8a356001600160401b038082111561326857600080fd5b6132748e838f01612eef565b909c509a5060208d0135995060408d0135915061329082612bbe565b90975060608c013590808211156132a657600080fd5b506132b38d828e01612f3a565b90975095505060808b01356132c781612bbe565b935060a08b01356132d781612bbe565b925060c08b0135915060e08b01356132ee81612bbe565b809150509295989b9194979a5092959850565b604081526000613314604083018561318b565b905060018060a01b03831660208301529392505050565b60008060008060008060008060008060006101408c8e03121561334d57600080fd5b8b3561335881612bbe565b9a5060208c0135995060408c01356001600160401b0381111561337a57600080fd5b6133868e828f01612f3a565b909a509850613399905060608d01612e21565b965060808c0135955060a08c0135945060c08c0135935060e08c01356133be81612bbe565b92506101008c01356133cf81612bbe565b809250506101208c013590509295989b509295989b9093969950565b600080604083850312156133fe57600080fd5b823561340981612bbe565b9150602083013561341981612bbe565b809150509250929050565b60008060006060848603121561343957600080fd5b833561344481612bbe565b9250602084013561345481612bbe565b9150604084013561346481612bbe565b809150509250925092565b600080600080600080600060e0888a03121561348a57600080fd5b873561349581612bbe565b96506020880135955060408801356001600160401b038111156134b757600080fd5b6134c38a828b01612c7c565b9550506134d260608901612e21565b935060808801356134e281612bbe565b925060a08801356134f281612bbe565b8092505060c0880135905092959891949750929550565b60008060006060848603121561351e57600080fd5b833561352981612bbe565b9250602084013561353981612bbe565b929592945050506040919091013590565b602080825260059082015264475332303360d81b604082015260600190565b60208082526005908201526411d4cc8c0d60da1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006000198214156135b2576135b2613588565b5060010190565b6040815260006135cc6040830185612d72565b82810360208401526125d68185612d72565b6000602082840312156135f057600080fd5b81516001600160e01b031981168114610eb357600080fd5b600060ff821660ff84168082101561362257613622613588565b90039392505050565b600081600019048311821515161561364557613645613588565b500290565b602080825260059082015264475332303160d81b604082015260600190565b8183526000602080850194508260005b858110156131c457813561368c81612bbe565b6001600160a01b031687529582019590820190600101613679565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101008083526136e58184018d8f613669565b602084018c90526001600160a01b038b811660408601528482036060860152909150613712828a8c6136a7565b978116608085015295861660a0840152505060c081019290925290911660e0909101529695505050505050565b634e487b7160e01b600052602160045260246000fd5b6002811061377357634e487b7160e01b600052602160045260246000fd5b9052565b600060018060a01b03808f1683528d602084015261016060408401526137a261016084018d8f6136a7565b6137af606085018d613755565b8a60808501528960a08501528860c085015281881660e08501528187166101008501528381036101208501526137e58187612d72565b925050808416610140840152509d9c50505050505050505050505050565b6000821982111561381657613816613588565b500190565b60008261383857634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561384f5761384f613588565b500390565b634e487b7160e01b600052603260045260246000fd5b60808152600061387e608083018789613669565b6020830195909552506001600160a01b039283166040820152911660609091015292915050565b6000602082840312156138b757600080fd5b5051919050565b6000602082840312156138d057600080fd5b81518015158114610eb357600080fd5b8183823760009101908152919050565b8b81526001600160a01b038b81166020830152604082018b9052606082018a9052610160820190613924608084018b613755565b60a083019890985260c082019690965260e0810194909452918516610100840152909316610120820152610140019190915295945050505050565b60008161396e5761396e613588565b506000190190565b6000808335601e1984360301811261398d57600080fd5b83016020810192503590506001600160401b038111156139ac57600080fd5b803603831315612f3357600080fd5b602081526139dc602082016139cf84612bd3565b6001600160a01b03169052565b6020820135604082015260006139f56040840184613976565b610160806060860152613a0d610180860183856136a7565b9250613a1c6060870187613976565b9250601f1980878603016080880152613a368585846136a7565b9450608088013560a088015260a088013560c088015260c088013560e0880152610100935060e08801358488015261012091508388013582880152613a7d82890189613976565b94509150610140818887030181890152613a988686856136a7565b9550613aa6818a018a613976565b955092505080878603018388015250613ac08484836136a7565b979650505050505050565b6000808335601e19843603018112613ae257600080fd5b8301803591506001600160401b03821115613afc57600080fd5b602001915036819003821315612f3357600080fd5b848152606060208201526000613b2a6060830186612d72565b8281036040840152613ac08185876136a7565b600060208284031215613b4f57600080fd5b81516001600160401b03811115613b6557600080fd5b8201601f81018413613b7657600080fd5b8051613b84612c9b82612c55565b818152856020838501011115613b9957600080fd5b6125d6826020830160208601612d4656fea2646970667358221220f181a20a2e70d60040741328d6ca1f3678b55feefdd8a25e9f6331a54baa0fee64736f6c634300080c0033

Deployed Bytecode

0x60806040526004361061021e5760003560e01c8063affed0e011610123578063e19a9dd9116100ab578063f30d76a31161006f578063f30d76a314610724578063f34308ef14610744578063f698da2514610764578063f8dc5dd914610779578063ffa1ad74146107995761025a565b8063e19a9dd91461068f578063e318b52b146106af578063e75235b8146106cf578063e86637db146106e4578063f08a0323146107045761025a565b8063cc2f8452116100f2578063cc2f8452146105ec578063d087d2881461061a578063d4d9bdcd1461062f578063d8d11f781461064f578063e009cfde1461066f5761025a565b8063affed0e01461055e578063b0d691fe14610574578063b4faba09146105ac578063b63e800d146105cc5761025a565b80635624b25b116101a65780636a1e9826116101755780636a1e9826146104b15780636a761202146104d15780637d832974146104e4578063934f3a111461051c578063a0e67e2b1461053c5761025a565b80635624b25b146104245780635ae6bd3714610444578063610b592514610471578063694e80c3146104915761025a565b80632f54bf6e116101ed5780632f54bf6e146103795780633408e470146103995780633a871cdd146103b6578063468721a7146103d65780635229073f146103f65761025a565b80630d582f13146102c057806312fb68e0146102e257806327fcac76146103025780632d9ad53d146103495761025a565b3661025a5760405134815233907f3d0ce9bfc3ed7d6862dbb28b2dea94561fe714a1b4d019aa8af39730d1ad7c3d9060200160405180910390a2005b34801561026657600080fd5b507f6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d580548061029157005b36600080373360601b365260008060143601600080855af190503d6000803e806102ba573d6000fd5b503d6000f35b3480156102cc57600080fd5b506102e06102db366004612be3565b6107ca565b005b3480156102ee57600080fd5b506102e06102fd366004612cd2565b610922565b34801561030e57600080fd5b5061033360405180604001604052806005815260200164302e302e3160d81b81525081565b6040516103409190612d9e565b60405180910390f35b34801561035557600080fd5b50610369610364366004612db1565b610dc7565b6040519015158152602001610340565b34801561038557600080fd5b50610369610394366004612db1565b610e02565b3480156103a557600080fd5b50465b604051908152602001610340565b3480156103c257600080fd5b506103a86103d1366004612dce565b610e3a565b3480156103e257600080fd5b506103696103f1366004612e30565b610eba565b34801561040257600080fd5b50610416610411366004612e30565b610f93565b604051610340929190612e99565b34801561043057600080fd5b5061033361043f366004612eb4565b610fc9565b34801561045057600080fd5b506103a861045f366004612ed6565b60076020526000908152604090205481565b34801561047d57600080fd5b506102e061048c366004612db1565b61104e565b34801561049d57600080fd5b506102e06104ac366004612ed6565b611187565b3480156104bd57600080fd5b506102e06104cc366004612f7b565b611225565b6103696104df366004613059565b6112aa565b3480156104f057600080fd5b506103a86104ff366004612be3565b600860209081526000928352604080842090915290825290205481565b34801561052857600080fd5b506102e061053736600461311f565b6115f5565b34801561054857600080fd5b5061055161163f565b60405161034091906131cf565b34801561056a57600080fd5b506103a860055481565b34801561058057600080fd5b50600954610594906001600160a01b031681565b6040516001600160a01b039091168152602001610340565b3480156105b857600080fd5b506102e06105c73660046131e2565b61172f565b3480156105d857600080fd5b506102e06105e7366004613231565b611752565b3480156105f857600080fd5b5061060c610607366004612be3565b611854565b604051610340929190613301565b34801561062657600080fd5b506103a8611a0f565b34801561063b57600080fd5b506102e061064a366004612ed6565b611a88565b34801561065b57600080fd5b506103a861066a36600461332b565b611b1d565b34801561067b57600080fd5b506102e061068a3660046133eb565b611b4a565b34801561069b57600080fd5b506102e06106aa366004612db1565b611c6c565b3480156106bb57600080fd5b506102e06106ca366004613424565b611d82565b3480156106db57600080fd5b506004546103a8565b3480156106f057600080fd5b506103336106ff36600461332b565b611f5d565b34801561071057600080fd5b506102e061071f366004612db1565b612036565b34801561073057600080fd5b506102e061073f366004612db1565b61207e565b34801561075057600080fd5b506102e061075f36600461346f565b6120a8565b34801561077057600080fd5b506103a861219f565b34801561078557600080fd5b506102e0610794366004613509565b6121f6565b3480156107a557600080fd5b50610333604051806040016040528060058152602001640312e342e360dc1b81525081565b6107d2612361565b6001600160a01b038216158015906107f457506001600160a01b038216600114155b801561080957506001600160a01b0382163014155b61082e5760405162461bcd60e51b81526004016108259061354a565b60405180910390fd5b6001600160a01b0382811660009081526002602052604090205416156108665760405162461bcd60e51b815260040161082590613569565b60026020527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e080546001600160a01b038481166000818152604081208054939094166001600160a01b0319938416179093556001835283549091161790915560038054916108d38361359e565b90915550506040516001600160a01b038316907f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea2690600090a2806004541461091e5761091e81611187565b5050565b61092d81604161239a565b825110156109655760405162461bcd60e51b8152602060048201526005602482015264047533032360dc1b6044820152606401610825565b6000808060008060005b86811015610dbb576041818102890160208101516040820151919092015160ff169550909350915083610b7957885160208a01208a146109d95760405162461bcd60e51b8152602060048201526005602482015264475330323760d81b6044820152606401610825565b91935083916109e987604161239a565b821015610a205760405162461bcd60e51b8152602060048201526005602482015264475330323160d81b6044820152606401610825565b8751610a2d8360206123cc565b1115610a635760405162461bcd60e51b815260206004820152600560248201526423a998191960d91b6044820152606401610825565b602082890181015189519091610a86908390610a809087906123cc565b906123cc565b1115610abc5760405162461bcd60e51b8152602060048201526005602482015264475330323360d81b6044820152606401610825565b6040516320c13b0b60e01b8082528a8501602001916001600160a01b038916906320c13b0b90610af2908f9086906004016135b9565b602060405180830381865afa158015610b0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b3391906135de565b6001600160e01b03191614610b725760405162461bcd60e51b815260206004820152600560248201526411d4cc0c8d60da1b6044820152606401610825565b5050610d21565b8360ff1660011415610bfc579193508391336001600160a01b0384161480610bc357506001600160a01b03851660009081526008602090815260408083208d845290915290205415155b610bf75760405162461bcd60e51b8152602060048201526005602482015264475330323560d81b6044820152606401610825565b610d21565b601e8460ff161115610cc1576040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c81018b9052600190605c0160405160208183030381529060405280519060200120600486610c619190613608565b6040805160008152602081018083529390935260ff90911690820152606081018590526080810184905260a0016020604051602081039080840390855afa158015610cb0573d6000803e3d6000fd5b505050602060405103519450610d21565b6040805160008152602081018083528c905260ff861691810191909152606081018490526080810183905260019060a0016020604051602081039080840390855afa158015610d14573d6000803e3d6000fd5b5050506020604051035194505b856001600160a01b0316856001600160a01b0316118015610d5b57506001600160a01b038581166000908152600260205260409020541615155b8015610d7157506001600160a01b038516600114155b610da55760405162461bcd60e51b815260206004820152600560248201526423a998191b60d91b6044820152606401610825565b8495508080610db39061359e565b91505061096f565b50505050505050505050565b600060016001600160a01b03831614801590610dfc57506001600160a01b038281166000908152600160205260409020541615155b92915050565b60006001600160a01b038216600114801590610dfc5750506001600160a01b0390811660009081526002602052604090205416151590565b6000610e446123e8565b610e4e8484612442565b90506001600160401b03602085013510610eaa5760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f6e73657175656e7469616c206e6f6e6365000000006044820152606401610825565b610eb38261253d565b9392505050565b600033600114801590610ee45750336000908152600160205260409020546001600160a01b031615155b610f185760405162461bcd60e51b815260206004820152600560248201526411d4cc4c0d60da1b6044820152606401610825565b610f2785858585600019612597565b90508015610f5f5760405133907f6895c13664aa4f67288b25d7a21d7aaa34916e355fb9b6fae0a139a9085becb890600090a2610f8b565b60405133907facd2c8702804128fdb0db2bb49f6d127dd0181c13fd45dbfe16de0930e2bd37590600090a25b949350505050565b60006060610fa386868686610eba565b915060405160203d0181016040523d81523d6000602083013e8091505094509492505050565b60606000610fd883602061362b565b6001600160401b03811115610fef57610fef612c0f565b6040519080825280601f01601f191660200182016040528015611019576020820181803683370190505b50905060005b8381101561104657848101546020808302840101528061103e8161359e565b91505061101f565b509392505050565b611056612361565b6001600160a01b0381161580159061107857506001600160a01b038116600114155b6110ac5760405162461bcd60e51b8152602060048201526005602482015264475331303160d81b6044820152606401610825565b6001600160a01b0381811660009081526001602052604090205416156110fc5760405162461bcd60e51b815260206004820152600560248201526423a998981960d91b6044820152606401610825565b600160208190527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b03848116600081815260408082208054949095166001600160a01b031994851617909455948552835490911681179092555190917fecdf3a3effea5783a3c4c2140e677577666428d44ed9d474a0b3a4c9943f844091a250565b61118f612361565b6003548111156111b15760405162461bcd60e51b81526004016108259061364a565b60018110156111ea5760405162461bcd60e51b815260206004820152600560248201526423a999181960d91b6044820152606401610825565b60048190556040518181527f610f7ff2b304ae8903c3de74c60c6ab1f7d6226b3f52c5161905bb5ad4039c939060200160405180910390a150565b600980546001600160a01b0319166001600160a01b03831617905560405161129d90309060009061126c908f908f908f908f908f908f908f908f908f908f906024016136d0565b60408051601f198184030181529190526020810180516001600160e01b031663b63e800d60e01b17905260016125df565b5050505050505050505050565b60008060006112c48e8e8e8e8e8e8e8e8e8e600554611f5d565b6005805491925060006112d68361359e565b90915550508051602082012091506112ef8282866115f5565b50600061131a7f4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c85490565b90506001600160a01b038116156113a057806001600160a01b03166375f0bb528f8f8f8f8f8f8f8f8f8f8f336040518d63ffffffff1660e01b815260040161136d9c9b9a99989796959493929190613777565b600060405180830381600087803b15801561138757600080fd5b505af115801561139b573d6000803e3d6000fd5b505050505b6113cc6113af8a6109c4613803565b603f6113bc8c604061362b565b6113c6919061381b565b90612650565b6113d8906101f4613803565b5a101561140f5760405162461bcd60e51b8152602060048201526005602482015264047533031360dc1b6044820152606401610825565b60005a90506114808f8f8f8f8080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f820116905080830192505050505050508e8c60001461146d578e612597565b6109c45a61147b919061383d565b612597565b935061148d5a8290612667565b9050838061149a57508915155b806114a457508715155b6114d85760405162461bcd60e51b8152602060048201526005602482015264475330313360d81b6044820152606401610825565b600088156114f0576114ed828b8b8b8b612682565b90505b841561153557837f442e715f626346e8c54381002da614f62bee8d27386535b2521ec8540898556e8260405161152891815260200190565b60405180910390a2611570565b837f23428b18acfb3ea64b08dc0c1d296ea9c09702c09083ca5272e64d115b687d238260405161156791815260200190565b60405180910390a25b50506001600160a01b038116156115e457604051631264e26d60e31b81526004810183905283151560248201526001600160a01b03821690639327136890604401600060405180830381600087803b1580156115cb57600080fd5b505af11580156115df573d6000803e3d6000fd5b505050505b50509b9a5050505050505050505050565b6004548061162d5760405162461bcd60e51b8152602060048201526005602482015264475330303160d81b6044820152606401610825565b61163984848484610922565b50505050565b606060006003546001600160401b0381111561165d5761165d612c0f565b604051908082528060200260200182016040528015611686578160200160208202803683370190505b506001600090815260026020527fe90b7bceb6e7df5418fb78d8ee546e97c83a08bbccc01a0644d599ccd2a7c2e054919250906001600160a01b03165b6001600160a01b03811660011461172757808383815181106116e7576116e7613854565b6001600160a01b0392831660209182029290920181019190915291811660009081526002909252604090912054168161171f8161359e565b9250506116c3565b509092915050565b600080825160208401855af480600052503d6020523d600060403e60403d016000fd5b6117908a8a808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152508c9250612788915050565b6001600160a01b038416156117a8576117a88461296e565b6117e88787878080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506129d392505050565b81156117ff576117fd82600060018685612682565b505b336001600160a01b03167f141df868a6331af528e38c83b7aa03edc19be66e37ae67f9285bf4f8e3c6a1a88b8b8b8b8960405161184095949392919061386a565b60405180910390a250505050505050505050565b606060006001600160a01b03841660011480611874575061187484610dc7565b6118a85760405162461bcd60e51b8152602060048201526005602482015264475331303560d81b6044820152606401610825565b600083116118e05760405162461bcd60e51b815260206004820152600560248201526423a998981b60d91b6044820152606401610825565b826001600160401b038111156118f8576118f8612c0f565b604051908082528060200260200182016040528015611921578160200160208202803683370190505b506001600160a01b03808616600090815260016020526040812054929450911691505b6001600160a01b0382161580159061196657506001600160a01b038216600114155b801561197157508381105b156119cc578183828151811061198957611989613854565b6001600160a01b039283166020918202929092018101919091529281166000908152600190935260409092205490911690806119c48161359e565b915050611944565b6001600160a01b038216600114611a0457826119e960018361383d565b815181106119f9576119f9613854565b602002602001015191505b808352509250929050565b600954604051631aab3f0d60e11b8152306004820152600060248201819052916001600160a01b0316906335567e1a90604401602060405180830381865afa158015611a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a8391906138a5565b905090565b336000908152600260205260409020546001600160a01b0316611ad55760405162461bcd60e51b8152602060048201526005602482015264047533033360dc1b6044820152606401610825565b336000818152600860209081526040808320858452909152808220600190555183917ff2a0eb156472d1440255b0d7c1e19cc07115d1051fe605b0dce69acfec884d9c91a350565b6000611b328c8c8c8c8c8c8c8c8c8c8c611f5d565b8051906020012090509b9a5050505050505050505050565b611b52612361565b6001600160a01b03811615801590611b7457506001600160a01b038116600114155b611ba85760405162461bcd60e51b8152602060048201526005602482015264475331303160d81b6044820152606401610825565b6001600160a01b03828116600090815260016020526040902054811690821614611bfc5760405162461bcd60e51b8152602060048201526005602482015264475331303360d81b6044820152606401610825565b6001600160a01b03818116600081815260016020526040808220805487861684528284208054919096166001600160a01b0319918216179095558383528054909416909355915190917faab4fa2b463f581b2b32cb3b7e3b704b9ce37cc209b5fb4d77e593ace405427691a25050565b611c74612361565b6001600160a01b03811615611d26576040516301ffc9a760e01b815263736bd41d60e11b60048201526001600160a01b038216906301ffc9a790602401602060405180830381865afa158015611cce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cf291906138be565b611d265760405162461bcd60e51b8152602060048201526005602482015264047533330360dc1b6044820152606401610825565b7f4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c88181556040516001600160a01b038316907f1151116914515bc0891ff9047a6cb32cf902546f83066499bcf8ba33d2353fa290600090a25050565b611d8a612361565b6001600160a01b03811615801590611dac57506001600160a01b038116600114155b8015611dc157506001600160a01b0381163014155b611ddd5760405162461bcd60e51b81526004016108259061354a565b6001600160a01b038181166000908152600260205260409020541615611e155760405162461bcd60e51b815260040161082590613569565b6001600160a01b03821615801590611e3757506001600160a01b038216600114155b611e535760405162461bcd60e51b81526004016108259061354a565b6001600160a01b03838116600090815260026020526040902054811690831614611ea75760405162461bcd60e51b8152602060048201526005602482015264475332303560d81b6044820152606401610825565b6001600160a01b03828116600081815260026020526040808220805486861680855283852080549288166001600160a01b03199384161790559589168452828420805482169096179095558383528054909416909355915190917ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf91a26040516001600160a01b038216907f9465fa0c962cc76958e6373a993326400c1c94f8be2fe3a952adfa7f60b2ea2690600090a2505050565b606060007fbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d860001b8d8d8d8d604051611f979291906138e0565b604051908190038120611fbd949392918e908e908e908e908e908e908e906020016138f0565b60408051601f1981840301815291905280516020909101209050601960f81b600160f81b611fe961219f565b6040516001600160f81b031993841660208201529290911660218301526022820152604281018290526062016040516020818303038152906040529150509b9a5050505050505050505050565b61203e612361565b6120478161296e565b6040516001600160a01b038216907f5ac6c46c93c8d0e53714ba3b53db3e7c046da994313d7ed0d192028bc7c228b090600090a250565b612086612361565b600980546001600160a01b0319166001600160a01b0392909216919091179055565b6009546001600160a01b031633146121025760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e74000000006044820152606401610825565b61210e878787876125df565b6001600160a01b038316156121965760405163095ea7b360e01b81526001600160a01b0384811660048301526024820183905283919082169063095ea7b3906044016020604051808303816000875af115801561216f573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061219391906138be565b50505b50505050505050565b60007f47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a794692184660408051602081019390935282015230606082015260800160405160208183030381529060405280519060200120905090565b6121fe612361565b80600160035461220e919061383d565b101561222c5760405162461bcd60e51b81526004016108259061364a565b6001600160a01b0382161580159061224e57506001600160a01b038216600114155b61226a5760405162461bcd60e51b81526004016108259061354a565b6001600160a01b038381166000908152600260205260409020548116908316146122be5760405162461bcd60e51b8152602060048201526005602482015264475332303560d81b6044820152606401610825565b6001600160a01b03828116600081815260026020526040808220805488861684529183208054929095166001600160a01b031992831617909455918152825490911690915560038054916123118361395f565b90915550506040516001600160a01b038316907ff8d49fc529812e9a7c5c50e69c20f0dccc0db8fa95c98bc58cc9a4f1c1299eaf90600090a2806004541461235c5761235c81611187565b505050565b3330146123985760405162461bcd60e51b8152602060048201526005602482015264475330333160d81b6044820152606401610825565b565b6000826123a957506000610dfc565b60006123b5838561362b565b9050826123c2858361381b565b14610eb357600080fd5b6000806123d98385613803565b905083811015610eb357600080fd5b6009546001600160a01b031633146123985760405162461bcd60e51b815260206004820152601c60248201527f6163636f756e743a206e6f742066726f6d20456e747279506f696e74000000006044820152606401610825565b60008061249c836040517f19457468657265756d205369676e6564204d6573736167653a0a3332000000006020820152603c8101829052600090605c01604051602081830303815290604052805190602001209050919050565b9050306001600160a01b031663934f3a1182866040516020016124bf91906139bb565b60408051601f198184030181529190526124dd610140890189613acb565b6040518563ffffffff1660e01b81526004016124fc9493929190613b11565b60006040518083038186803b15801561251457600080fd5b505afa925050508015612525575060015b612533576001915050610dfc565b6000915050610dfc565b801561259457604051600090339060001990849084818181858888f193505050503d806000811461258a576040519150601f19603f3d011682016040523d82523d6000602084013e61258f565b606091505b505050505b50565b600060018360018111156125ad576125ad61373f565b14156125c6576000808551602087018986f490506125d6565b600080855160208701888a87f190505b95945050505050565b60006125f085858585600019612597565b905060006125ff600019612b03565b9050816126485760448151101561261557600080fd5b6004810190508080602001905181019061262f9190613b3d565b60405162461bcd60e51b81526004016108259190612d9e565b505050505050565b6000818310156126605781610eb3565b5090919050565b60008282111561267657600080fd5b6000610f8b838561383d565b6000806001600160a01b0383161561269a578261269c565b325b90506001600160a01b03841661272f576126ce3a86106126bc573a6126be565b855b6126c889896123cc565b9061239a565b6040519092506001600160a01b0382169083156108fc029084906000818181858888f1935050505061272a5760405162461bcd60e51b8152602060048201526005602482015264475330313160d81b6044820152606401610825565b61277e565b61273d856126c889896123cc565b915061274a848284612b2f565b61277e5760405162461bcd60e51b815260206004820152600560248201526423a998189960d91b6044820152606401610825565b5095945050505050565b600454156127c05760405162461bcd60e51b8152602060048201526005602482015264047533230360dc1b6044820152606401610825565b81518111156127e15760405162461bcd60e51b81526004016108259061364a565b600181101561281a5760405162461bcd60e51b815260206004820152600560248201526423a999181960d91b6044820152606401610825565b600160005b835181101561293b57600084828151811061283c5761283c613854565b6020026020010151905060006001600160a01b0316816001600160a01b03161415801561287357506001600160a01b038116600114155b801561288857506001600160a01b0381163014155b80156128a65750806001600160a01b0316836001600160a01b031614155b6128c25760405162461bcd60e51b81526004016108259061354a565b6001600160a01b0381811660009081526002602052604090205416156128fa5760405162461bcd60e51b815260040161082590613569565b6001600160a01b03928316600090815260026020526040902080546001600160a01b03191693821693909317909255806129338161359e565b91505061281f565b506001600160a01b0316600090815260026020526040902080546001600160a01b03191660011790559051600355600455565b6001600160a01b0381163014156129af5760405162461bcd60e51b8152602060048201526005602482015264047533430360dc1b6044820152606401610825565b7f6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d555565b600160008190526020527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f546001600160a01b031615612a3d5760405162461bcd60e51b8152602060048201526005602482015264047533130360dc1b6044820152606401610825565b6001600081905260208190527fcc69885fda6bcc1a4ace058b4a62bf5e179ea78fd58a1ccd71c22cc9b688792f80546001600160a01b03191690911790556001600160a01b0382161561091e57813b612ac05760405162461bcd60e51b815260206004820152600560248201526423a998181960d91b6044820152606401610825565b612acf8260008360015a612597565b61091e5760405162461bcd60e51b8152602060048201526005602482015264047533030360dc1b6044820152606401610825565b60603d82811115612b115750815b604051602082018101604052818152816000602083013e9392505050565b604080516001600160a01b03841660248201526044808201849052825180830390910181526064909101909152602080820180516001600160e01b031663a9059cbb60e01b1781528251600093929184919082896127105a03f13d8015612ba15760208114612ba95760009350612bb4565b819350612bb4565b600051158215171593505b5050509392505050565b6001600160a01b038116811461259457600080fd5b8035612bde81612bbe565b919050565b60008060408385031215612bf657600080fd5b8235612c0181612bbe565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715612c4d57612c4d612c0f565b604052919050565b60006001600160401b03821115612c6e57612c6e612c0f565b50601f01601f191660200190565b600082601f830112612c8d57600080fd5b8135612ca0612c9b82612c55565b612c25565b818152846020838601011115612cb557600080fd5b816020850160208301376000918101602001919091529392505050565b60008060008060808587031215612ce857600080fd5b8435935060208501356001600160401b0380821115612d0657600080fd5b612d1288838901612c7c565b94506040870135915080821115612d2857600080fd5b50612d3587828801612c7c565b949793965093946060013593505050565b60005b83811015612d61578181015183820152602001612d49565b838111156116395750506000910152565b60008151808452612d8a816020860160208601612d46565b601f01601f19169290920160200192915050565b602081526000610eb36020830184612d72565b600060208284031215612dc357600080fd5b8135610eb381612bbe565b600080600060608486031215612de357600080fd5b83356001600160401b03811115612df957600080fd5b84016101608187031215612e0c57600080fd5b95602085013595506040909401359392505050565b803560028110612bde57600080fd5b60008060008060808587031215612e4657600080fd5b8435612e5181612bbe565b93506020850135925060408501356001600160401b03811115612e7357600080fd5b612e7f87828801612c7c565b925050612e8e60608601612e21565b905092959194509250565b8215158152604060208201526000610f8b6040830184612d72565b60008060408385031215612ec757600080fd5b50508035926020909101359150565b600060208284031215612ee857600080fd5b5035919050565b60008083601f840112612f0157600080fd5b5081356001600160401b03811115612f1857600080fd5b6020830191508360208260051b8501011115612f3357600080fd5b9250929050565b60008083601f840112612f4c57600080fd5b5081356001600160401b03811115612f6357600080fd5b602083019150836020828501011115612f3357600080fd5b60008060008060008060008060008060006101208c8e031215612f9d57600080fd5b6001600160401b03808d351115612fb357600080fd5b612fc08e8e358f01612eef565b909c509a5060208d01359950612fd960408e0135612bbe565b60408d013598508060608e01351115612ff157600080fd5b506130028d60608e01358e01612f3a565b909750955060808c013561301581612bbe565b945061302360a08d01612bd3565b935060c08c0135925061303860e08d01612bd3565b91506130476101008d01612bd3565b90509295989b509295989b9093969950565b60008060008060008060008060008060006101408c8e03121561307b57600080fd5b6130848c612bd3565b9a5060208c013599506001600160401b038060408e013511156130a657600080fd5b6130b68e60408f01358f01612f3a565b909a5098506130c760608e01612e21565b975060808d0135965060a08d0135955060c08d013594506130ea60e08e01612bd3565b93506130f96101008e01612bd3565b9250806101208e0135111561310d57600080fd5b506130478d6101208e01358e01612c7c565b60008060006060848603121561313457600080fd5b8335925060208401356001600160401b038082111561315257600080fd5b61315e87838801612c7c565b9350604086013591508082111561317457600080fd5b5061318186828701612c7c565b9150509250925092565b600081518084526020808501945080840160005b838110156131c45781516001600160a01b03168752958201959082019060010161319f565b509495945050505050565b602081526000610eb3602083018461318b565b600080604083850312156131f557600080fd5b823561320081612bbe565b915060208301356001600160401b0381111561321b57600080fd5b61322785828601612c7c565b9150509250929050565b6000806000806000806000806000806101008b8d03121561325157600080fd5b8a356001600160401b038082111561326857600080fd5b6132748e838f01612eef565b909c509a5060208d0135995060408d0135915061329082612bbe565b90975060608c013590808211156132a657600080fd5b506132b38d828e01612f3a565b90975095505060808b01356132c781612bbe565b935060a08b01356132d781612bbe565b925060c08b0135915060e08b01356132ee81612bbe565b809150509295989b9194979a5092959850565b604081526000613314604083018561318b565b905060018060a01b03831660208301529392505050565b60008060008060008060008060008060006101408c8e03121561334d57600080fd5b8b3561335881612bbe565b9a5060208c0135995060408c01356001600160401b0381111561337a57600080fd5b6133868e828f01612f3a565b909a509850613399905060608d01612e21565b965060808c0135955060a08c0135945060c08c0135935060e08c01356133be81612bbe565b92506101008c01356133cf81612bbe565b809250506101208c013590509295989b509295989b9093969950565b600080604083850312156133fe57600080fd5b823561340981612bbe565b9150602083013561341981612bbe565b809150509250929050565b60008060006060848603121561343957600080fd5b833561344481612bbe565b9250602084013561345481612bbe565b9150604084013561346481612bbe565b809150509250925092565b600080600080600080600060e0888a03121561348a57600080fd5b873561349581612bbe565b96506020880135955060408801356001600160401b038111156134b757600080fd5b6134c38a828b01612c7c565b9550506134d260608901612e21565b935060808801356134e281612bbe565b925060a08801356134f281612bbe565b8092505060c0880135905092959891949750929550565b60008060006060848603121561351e57600080fd5b833561352981612bbe565b9250602084013561353981612bbe565b929592945050506040919091013590565b602080825260059082015264475332303360d81b604082015260600190565b60208082526005908201526411d4cc8c0d60da1b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b60006000198214156135b2576135b2613588565b5060010190565b6040815260006135cc6040830185612d72565b82810360208401526125d68185612d72565b6000602082840312156135f057600080fd5b81516001600160e01b031981168114610eb357600080fd5b600060ff821660ff84168082101561362257613622613588565b90039392505050565b600081600019048311821515161561364557613645613588565b500290565b602080825260059082015264475332303160d81b604082015260600190565b8183526000602080850194508260005b858110156131c457813561368c81612bbe565b6001600160a01b031687529582019590820190600101613679565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006101008083526136e58184018d8f613669565b602084018c90526001600160a01b038b811660408601528482036060860152909150613712828a8c6136a7565b978116608085015295861660a0840152505060c081019290925290911660e0909101529695505050505050565b634e487b7160e01b600052602160045260246000fd5b6002811061377357634e487b7160e01b600052602160045260246000fd5b9052565b600060018060a01b03808f1683528d602084015261016060408401526137a261016084018d8f6136a7565b6137af606085018d613755565b8a60808501528960a08501528860c085015281881660e08501528187166101008501528381036101208501526137e58187612d72565b925050808416610140840152509d9c50505050505050505050505050565b6000821982111561381657613816613588565b500190565b60008261383857634e487b7160e01b600052601260045260246000fd5b500490565b60008282101561384f5761384f613588565b500390565b634e487b7160e01b600052603260045260246000fd5b60808152600061387e608083018789613669565b6020830195909552506001600160a01b039283166040820152911660609091015292915050565b6000602082840312156138b757600080fd5b5051919050565b6000602082840312156138d057600080fd5b81518015158114610eb357600080fd5b8183823760009101908152919050565b8b81526001600160a01b038b81166020830152604082018b9052606082018a9052610160820190613924608084018b613755565b60a083019890985260c082019690965260e0810194909452918516610100840152909316610120820152610140019190915295945050505050565b60008161396e5761396e613588565b506000190190565b6000808335601e1984360301811261398d57600080fd5b83016020810192503590506001600160401b038111156139ac57600080fd5b803603831315612f3357600080fd5b602081526139dc602082016139cf84612bd3565b6001600160a01b03169052565b6020820135604082015260006139f56040840184613976565b610160806060860152613a0d610180860183856136a7565b9250613a1c6060870187613976565b9250601f1980878603016080880152613a368585846136a7565b9450608088013560a088015260a088013560c088015260c088013560e0880152610100935060e08801358488015261012091508388013582880152613a7d82890189613976565b94509150610140818887030181890152613a988686856136a7565b9550613aa6818a018a613976565b955092505080878603018388015250613ac08484836136a7565b979650505050505050565b6000808335601e19843603018112613ae257600080fd5b8301803591506001600160401b03821115613afc57600080fd5b602001915036819003821315612f3357600080fd5b848152606060208201526000613b2a6060830186612d72565b8281036040840152613ac08185876136a7565b600060208284031215613b4f57600080fd5b81516001600160401b03811115613b6557600080fd5b8201601f81018413613b7657600080fd5b8051613b84612c9b82612c55565b818152856020838501011115613b9957600080fd5b6125d6826020830160208601612d4656fea2646970667358221220f181a20a2e70d60040741328d6ca1f3678b55feefdd8a25e9f6331a54baa0fee64736f6c634300080c0033

Block Transaction Difficulty Gas Used Reward
Block Uncle Number Difficulty Gas Used Reward
Loading