ETH Price: $1,980.12 (-4.58%)

Contract

0x80EA852448c2807BeAe321deC7c603990209F7db
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Token Holdings

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Buy Fractions245996592026-03-06 16:38:117 hrs ago1772815091IN
0x80EA8524...90209F7db
0 ETH0.000413432.27123782
Buy Fractions245981332026-03-06 11:31:2312 hrs ago1772796683IN
0x80EA8524...90209F7db
0 ETH0.000010710.07863978
Buy Fractions245972392026-03-06 8:30:5915 hrs ago1772785859IN
0x80EA8524...90209F7db
0 ETH0.000279572.05116304
Buy Fractions245938192026-03-05 20:59:5927 hrs ago1772744399IN
0x80EA8524...90209F7db
0 ETH0.000014410.14513891
Buy Fractions245916372026-03-05 13:41:5934 hrs ago1772718119IN
0x80EA8524...90209F7db
0 ETH0.00002350.23666433
Buy Fractions245906322026-03-05 10:20:3538 hrs ago1772706035IN
0x80EA8524...90209F7db
0 ETH0.000284552.08764501
Buy Fractions245896042026-03-05 6:54:3541 hrs ago1772693675IN
0x80EA8524...90209F7db
0 ETH0.000016510.15319751
Buy Fractions245870612026-03-04 22:24:232 days ago1772663063IN
0x80EA8524...90209F7db
0 ETH0.000283642.08100033
Buy Fractions245863582026-03-04 20:03:112 days ago1772654591IN
0x80EA8524...90209F7db
0 ETH0.000232712.19017363
Buy Fractions245860362026-03-04 18:58:112 days ago1772650691IN
0x80EA8524...90209F7db
0 ETH0.000225442.12214968
Buy Fractions245850382026-03-04 15:37:592 days ago1772638679IN
0x80EA8524...90209F7db
0 ETH0.000165121.21143263
Buy Fractions245849302026-03-04 15:15:592 days ago1772637359IN
0x80EA8524...90209F7db
0 ETH0.000129261.21656502
Buy Fractions245799272026-03-03 22:30:353 days ago1772577035IN
0x80EA8524...90209F7db
0 ETH0.000012770.09370132
Buy Fractions245794462026-03-03 20:54:113 days ago1772571251IN
0x80EA8524...90209F7db
0 ETH0.000029370.21553689
Buy Fractions245792952026-03-03 20:23:593 days ago1772569439IN
0x80EA8524...90209F7db
0 ETH0.000303492.22661003
Buy Fractions245792482026-03-03 20:14:353 days ago1772568875IN
0x80EA8524...90209F7db
0 ETH0.000302122.21661509
Buy Fractions245789112026-03-03 19:06:473 days ago1772564807IN
0x80EA8524...90209F7db
0 ETH0.000314142.30476283
Buy Fractions245789002026-03-03 19:04:353 days ago1772564675IN
0x80EA8524...90209F7db
0 ETH0.000247212.32713996
Buy Fractions245786392026-03-03 18:12:233 days ago1772561543IN
0x80EA8524...90209F7db
0 ETH0.00018962.126627
Buy Fractions245786302026-03-03 18:10:353 days ago1772561435IN
0x80EA8524...90209F7db
0 ETH0.000294032.15721985
Buy Fractions245786212026-03-03 18:08:473 days ago1772561327IN
0x80EA8524...90209F7db
0 ETH0.000293672.15458753
Buy Fractions245786182026-03-03 18:08:113 days ago1772561291IN
0x80EA8524...90209F7db
0 ETH0.000294852.16324775
Buy Fractions245786082026-03-03 18:06:113 days ago1772561171IN
0x80EA8524...90209F7db
0 ETH0.000029210.21431701
Buy Fractions245786012026-03-03 18:04:473 days ago1772561087IN
0x80EA8524...90209F7db
0 ETH0.000042290.31033395
Buy Fractions245785962026-03-03 18:03:473 days ago1772561027IN
0x80EA8524...90209F7db
0 ETH0.000359222.10684635
View all transactions

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading
Loading...
Loading
Cross-Chain Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
OffchainFractions

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 1000000 runs

Other Settings:
prague EvmVersion
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {CounterfactualHolderFactory} from "./CounterfactualHolderFactory.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {Call} from "./Structs.sol";
/**
 * @title OffchainFractions
 * @notice A contract for creating and managing fractional token sales with optional minimum raise requirements
 * @dev Supports both direct transfers and counterfactual holder addresses for recipients
 * @dev Counterfactual tokens are held in the CFH Chain for address(this) which always forwards leftover tokens
 *         - This makes it safe to run multiple sales concurrently accruing to the CFH of address(this) 
 *         - without worrying about leftover tokens
 */

contract OffchainFractions is ReentrancyGuard {
    using SafeERC20 for IERC20;

    // === Fraction Management Errors ===
    error AlreadyExists();
    error AlreadyClosed();
    error Expired();
    error MinSharesCannotBeGreaterThanTotalSteps();
    error NotFractionsCloser();

    // === Purchase/Sale Errors ===
    error InsufficientSharesAvailable();
    error NoStepsPurchased();
    error StepMustBeGreaterThanZero();
    error ZeroSteps();
    error MinStepsToBuyCannotBeZero();
    error MinStepsToBuyCannotBeGreaterThanStepsToBuy();
    // === Validation Errors ===
    error InvalidToken();
    error InvalidToAddress();
    error RecipientCannotBeSelf();
    error CannotHaveZeroTotalSteps();
    error TaxTokenNotSupported();
    error ExpirationMustBeInTheFuture();
    error UseCounterfactualAddressForRefundNotAllowedIfAddressIsZero();

    // === Refund/Claim Errors ===
    error CannotClaimRefundWhenThresholdReached();
    error CannotClaimRefundWhenNotExpired();
    error CannotCloseWhenThresholdReached();
    error ExpirationCannotBeGreaterThanMaxDuration();
    error TotalRaisedOverflow();
    error RefundOperatorNotApproved();
    error CannotSetRefundDetailsWhenThresholdReached();

    /**
     * @notice Data structure representing a fractional token sale
     * @param token The ERC20 token being sold
     * @param expiration Timestamp when the sale expires
     * @param manuallyClosed Whether the sale was manually closed by the owner
     * @param minSharesToRaise Minimum number of steps that must be sold for the sale to be valid
     * @param useCounterfactualAddress Whether to use a counterfactual holder address for the recipient
     * @param claimedFromMinSharesToRaise Whether funds have been claimed after reaching minimum shares
     * @param owner The creator/owner of this fraction sale
     * @param step Price per step (in wei of the token)
     * @param to The recipient address for the raised funds
     * @param soldSteps Number of steps already sold
     * @param totalSteps Total number of steps available for sale
     * @param closer The address that manually closed the sale
     */
    struct FractionData {
        address token;
        uint48 expiration;
        bool manuallyClosed;
        uint256 minSharesToRaise;
        bool useCounterfactualAddress;
        bool claimedFromMinSharesToRaise;
        uint256 step;
        address to;
        uint256 soldSteps;
        uint256 totalSteps;
        address closer;
    }

    /**
     * @notice Internal struct to hold purchase calculation results (avoids stack too deep)
     * @param stepsToBuy Final number of steps to purchase (adjusted for availability)
     * @param amount Total cost for the purchase
     * @param newFractionsSold Total steps that will be sold after this purchase
     * @param sendTo Address where funds should be sent
     * @param roundFullyFilled Whether this purchase completes the round
     */
    struct PurchaseDetails {
        uint256 stepsToBuy;
        uint256 amount;
        uint256 newFractionsSold;
        address sendTo;
        bool roundFullyFilled;
    }

    struct RefundDetails {
        address refundTo;
        bool useCounterfactualAddress;
    }

    /// @notice Tracks the number of steps purchased by each user for each fraction sale
    mapping(address user => mapping(address creator => mapping(bytes32 id => uint256 stepsPurchased))) public
        stepsPurchased;

    mapping(address user => mapping(address refundOperator => bool isApproved)) public refundApprovals;
    mapping(address user => mapping(address creator => mapping(bytes32 id => RefundDetails))) private _refundDetails;

    /// @notice Stores fraction sale data indexed by creator and fraction ID
    mapping(address user => mapping(bytes32 id => FractionData)) private _fractions;

    address public constant REFUND_WILDCARD_OPERATOR = 0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF;

    uint256 private constant MAX_DURATION = 100 weeks;
    /// @notice Factory contract for creating counterfactual holder addresses
    CounterfactualHolderFactory public immutable i_CFHFactory;

    /// @notice Emitted when a new fraction sale is created
    event FractionCreated(
        bytes32 indexed id,
        address indexed token,
        address indexed owner,
        uint256 step,
        uint256 totalSteps,
        uint48 expiration,
        address to,
        bool useCounterfactualAddress,
        uint256 minSharesToRaise,
        address closer
    );

    /// @notice Emitted when steps are purchased in a fraction sale
    event FractionSold(
        bytes32 indexed id,
        address indexed creator,
        address indexed creditTo,
        address buyer,
        uint256 step,
        uint256 amount
    );

    /// @notice Emitted when a fraction sale round is completely filled
    event RoundFilled(bytes32 indexed id, address indexed creator);

    /// @notice Emitted when a fraction sale is manually closed by the owner
    event FractionClosed(bytes32 indexed id, address indexed token, address indexed owner);

    /// @notice Emitted when a user claims a refund from an unfilled sale
    event FractionRefunded(
        bytes32 indexed id, address indexed creator, address indexed user, address refundTo, uint256 amount
    );

    /// @notice Emitted when the minimum shares threshold is reached and funds are released
    event MinSharesReached(bytes32 indexed id, address indexed creator, uint256 minShares, uint256 newTotalSharesSold);

    event RefundOperatorStatusSet(address indexed user, address indexed refundOperator, bool isApproved);

    constructor(CounterfactualHolderFactory _counterfactualHolderFactory) {
        i_CFHFactory = _counterfactualHolderFactory;
    }

    /**
     * @notice Creates a new fractional token sale
     * @param id Unique identifier for this fraction sale
     * @param token The ERC20 token to be sold
     * @param step Price per step (in wei of the token)
     * @param totalSteps Total number of steps available for sale
     * @param expiration Timestamp when the sale expires
     * @param to Recipient address for the raised funds
     * @param useCounterfactualAddress Whether to use a counterfactual holder for the recipient
     * @param minSharesToRaise Minimum steps required for the sale to be valid (0 = no minimum)
     * @param closer The address that is allowed to manually close the sale
     */
    function createFraction(
        bytes32 id,
        address token,
        uint256 step,
        uint256 totalSteps,
        uint48 expiration,
        address to,
        bool useCounterfactualAddress,
        uint256 minSharesToRaise,
        address closer
    ) external nonReentrant {
        // Validate input parameters
        _validateFractionCreationParams(token, to, step, totalSteps, minSharesToRaise, expiration);

        // Ensure fraction doesn't already exist
        if (_fractions[msg.sender][id].totalSteps != 0) {
            revert AlreadyExists();
        }

        // Create the fraction data
        _fractions[msg.sender][id] = FractionData({
            token: token,
            step: step,
            soldSteps: 0,
            totalSteps: totalSteps,
            expiration: expiration,
            manuallyClosed: false,
            useCounterfactualAddress: useCounterfactualAddress,
            to: to,
            minSharesToRaise: minSharesToRaise,
            claimedFromMinSharesToRaise: minSharesToRaise == 0,
            closer: closer
        });

        emit FractionCreated(
            id, token, msg.sender, step, totalSteps, expiration, to, useCounterfactualAddress, minSharesToRaise, closer
        );
    }

    /**
     * @notice Purchase steps in a fractional token sale
     * @param creator The address that created the fraction sale
     * @param id The unique identifier of the fraction sale
     * @param stepsToBuy Maximum number of steps to purchase
     * @param minStepsToBuy Minimum number of steps that must be available to purchase
     */
    function buyFractions(
        address creator,
        bytes32 id,
        uint256 stepsToBuy,
        uint256 minStepsToBuy,
        address refundTo,
        address creditTo,
        bool useCounterfactualAddressForRefund
    ) external nonReentrant {
        FractionData storage fraction = _fractions[creator][id];
        if (minStepsToBuy == 0) {
            revert MinStepsToBuyCannotBeZero();
        }
        if (stepsToBuy == 0) {
            revert ZeroSteps();
        }
        if (minStepsToBuy > stepsToBuy) {
            revert MinStepsToBuyCannotBeGreaterThanStepsToBuy();
        }

        if (refundTo != address(0) && useCounterfactualAddressForRefund) {
            revert UseCounterfactualAddressForRefundNotAllowedIfAddressIsZero();
        }

        // Validate the purchase can proceed
        _validatePurchaseConditions(fraction);

        // Calculate purchase details with stack isolation
        PurchaseDetails memory details = _calculatePurchaseDetails(fraction, stepsToBuy, minStepsToBuy);

        // Handle the token transfers based on minimum shares logic
        bool minSharesReached =
            _handlePurchaseTransfers(fraction, details, creator, id, fraction.useCounterfactualAddress);

        if (refundTo != address(0) && !minSharesReached) {
            _refundDetails[msg.sender][creator][id] =
                RefundDetails({refundTo: refundTo, useCounterfactualAddress: useCounterfactualAddressForRefund});
        }

        // Update state and emit events
        _finalizePurchase(fraction, details, creator, creditTo, id);
    }

    /**
     * @notice Allows participants to claim a refund if the round didn't reach minimum shares
     * @dev Can only claim refund if:
     *      - Round didn't reach minSharesToRaise threshold
     *      - Round is expired OR manually closed
     * @param creator The address that created the fraction sale
     * @param id The unique identifier of the fraction sale
     */
    function claimRefund(address user, address creator, bytes32 id) external nonReentrant {
        FractionData storage fraction = _fractions[creator][id];
        RefundDetails memory refundDetails = _refundDetails[user][creator][id];
        address refundToInStruct = refundDetails.refundTo;
        address refundTo = refundToInStruct == address(0) ? user : refundToInStruct;

        // Either the user or the refund to address must have approved the refund operator
        if (!isRefundOperatorApproved(user, msg.sender) && !isRefundOperatorApproved(refundToInStruct, msg.sender)) {
            revert RefundOperatorNotApproved();
        }
        if (refundDetails.useCounterfactualAddress) {
            refundTo = i_CFHFactory.getCurrentCFH({user: refundTo, token: fraction.token});
        }

        uint256 _stepsPurchased = stepsPurchased[user][creator][id];
        if (_stepsPurchased == 0) {
            revert NoStepsPurchased();
        }

        // Check if round reached minimum threshold
        uint256 soldSteps = fraction.soldSteps;
        bool roundFilled = soldSteps >= fraction.minSharesToRaise;
        if (roundFilled) {
            revert CannotClaimRefundWhenThresholdReached();
        }

        // Check if refund conditions are met (expired OR manually closed)
        bool expired = block.timestamp > fraction.expiration;
        bool manuallyClosed = fraction.manuallyClosed;
        // equivalent to require(manually closed || expired)
        if (!manuallyClosed && !expired) {
            revert CannotClaimRefundWhenNotExpired();
        }

        // Calculate refund amount and update state
        uint256 amount = _stepsPurchased * fraction.step;
        stepsPurchased[user][creator][id] = 0;
        fraction.soldSteps = soldSteps - _stepsPurchased;

        // Transfer refund to user
        if (fraction.useCounterfactualAddress) {
            Call[] memory calls = new Call[](1);
            calls[0] = Call({
                target: address(fraction.token),
                data: abi.encodeWithSelector(IERC20.transfer.selector, refundTo, amount)
            });
            i_CFHFactory.execute(fraction.token, calls);
        } else {
            IERC20(fraction.token).safeTransfer(refundTo, amount);
        }
        emit FractionRefunded(id, creator, user, refundTo, amount);
    }

    /**
     * @notice Manually close a fraction sale before expiration
     * @dev Only the closer can close their own fraction sale
     * @dev Can only close if the round hasn't reached minimum shares threshold
     * @param creator The address that created the fraction sale
     * @param id The unique identifier of the fraction sale to close
     */
    function closeFraction(address creator, bytes32 id) external nonReentrant {
        FractionData storage fraction = _fractions[creator][id];
        if (msg.sender != fraction.closer) {
            revert NotFractionsCloser();
        }

        // Validate closure conditions
        if (fraction.manuallyClosed) {
            revert AlreadyClosed();
        }
        if (fraction.soldSteps >= fraction.minSharesToRaise) {
            revert CannotCloseWhenThresholdReached();
        }
        if (block.timestamp > fraction.expiration) {
            revert Expired();
        }

        // Mark as manually closed
        fraction.manuallyClosed = true;
        emit FractionClosed(id, fraction.token, creator);
    }

    /**
     * @notice Sets the refund details for a specific fraction sale
     * @dev This function allows a user to specify the refund address and whether to use a counterfactual address
     * @param creator The address of the creator of the fraction sale
     * @param id The unique identifier of the fraction sale
     * @param refundTo The address to which refunds should be sent
     * @param useCounterfactualAddress A boolean indicating whether to use a counterfactual address for the refund
     * @dev Reverts if `refundTo` is not zero and `useCounterfactualAddress` is true
     */
    function setRefundDetails(address creator, bytes32 id, address refundTo, bool useCounterfactualAddress) external {
        if (refundTo != address(0) && useCounterfactualAddress) {
            revert UseCounterfactualAddressForRefundNotAllowedIfAddressIsZero();
        }

        FractionData storage fraction = _fractions[creator][id];

        if (fraction.soldSteps >= fraction.minSharesToRaise) {
            revert CannotSetRefundDetailsWhenThresholdReached();
        }

        _refundDetails[msg.sender][creator][id] =
            RefundDetails({refundTo: refundTo, useCounterfactualAddress: useCounterfactualAddress});
    }

    /**
     * @notice Sets the approval status of a refund operator for the caller
     * @dev This function allows the caller to approve or revoke approval for a refund operator
     * @param refundOperator The address of the refund operator to set the status for
     * @param isApproved A boolean indicating whether the refund operator is approved (true) or not (false)
     */
    function setRefundOperatorStatus(address refundOperator, bool isApproved) external {
        refundApprovals[msg.sender][refundOperator] = isApproved;
        emit RefundOperatorStatusSet(msg.sender, refundOperator, isApproved);
    }

    /**
     * @notice Get the fraction sale data for a specific creator and ID
     * @param creator The address that created the fraction sale
     * @param id The unique identifier of the fraction sale
     * @return The complete fraction sale data
     */
    function getFraction(address creator, bytes32 id) external view returns (FractionData memory) {
        return _fractions[creator][id];
    }

    function getRefundDetails(address user, address creator, bytes32 id) external view returns (RefundDetails memory) {
        return _refundDetails[user][creator][id];
    }

    /**
     * @notice Checks if a refund operator is approved for a specific user
     * @dev The function first checks if the caller is the user, in which case it returns true.
     *      It then checks if the wildcard operator is approved for the user.
     * @param user The address of the user for whom the refund operator approval is being checked
     * @param refundOperator The address of the refund operator to check approval status for
     * @return A boolean indicating whether the refund operator is approved for the user
     */
    function isRefundOperatorApproved(address user, address refundOperator) public view returns (bool) {
        if (msg.sender == user) return true;
        bool isWildcardOperatorApproved = refundApprovals[user][REFUND_WILDCARD_OPERATOR];
        if (isWildcardOperatorApproved) return true;
        return refundApprovals[user][refundOperator];
    }

    // ============ INTERNAL FUNCTIONS ============

    /**
     * @notice Validates parameters for fraction creation
     * @param token The ERC20 token address
     * @param to The recipient address
     * @param step The price per step
     * @param totalSteps The total number of steps
     * @param minSharesToRaise The minimum number of steps to raise
     */
    function _validateFractionCreationParams(
        address token,
        address to,
        uint256 step,
        uint256 totalSteps,
        uint256 minSharesToRaise,
        uint48 expiration
    ) internal view {
        if (token == address(0)) revert InvalidToken();
        if (to == address(0)) revert InvalidToAddress();
        if (step == 0) revert StepMustBeGreaterThanZero();
        if (totalSteps == 0) revert CannotHaveZeroTotalSteps();
        if (to == address(this)) revert RecipientCannotBeSelf();
        if (minSharesToRaise > totalSteps) revert MinSharesCannotBeGreaterThanTotalSteps();
        if (expiration <= block.timestamp) revert ExpirationMustBeInTheFuture();
        if (expiration - block.timestamp > MAX_DURATION) revert ExpirationCannotBeGreaterThanMaxDuration();
        if (willMultiplyOverflow(step, totalSteps)) revert TotalRaisedOverflow();
    }

    /**
     * @notice Validates that a purchase can proceed
     * @param fraction The fraction data to validate
     */
    function _validatePurchaseConditions(FractionData storage fraction) internal view {
        if (fraction.manuallyClosed) revert AlreadyClosed();
        if (block.timestamp > fraction.expiration) revert Expired();
    }

    /**
     * @notice Calculates purchase details including adjusted steps and recipient address
     * @param fraction The fraction data
     * @param stepsToBuy Requested number of steps to buy
     * @param minStepsToBuy Minimum steps required to be available
     * @return details Calculated purchase details
     */
    function _calculatePurchaseDetails(FractionData storage fraction, uint256 stepsToBuy, uint256 minStepsToBuy)
        internal
        view
        returns (PurchaseDetails memory details)
    {
        {
            address toInStruct = fraction.to;
            details.sendTo = fraction.useCounterfactualAddress
                ? i_CFHFactory.getCurrentCFH({user: toInStruct, token: fraction.token})
                : toInStruct;
        }

        {
            uint256 soldSteps = fraction.soldSteps;
            uint256 totalSteps = fraction.totalSteps;
            uint256 stepsLeft = totalSteps - soldSteps;

            if (stepsLeft < minStepsToBuy) revert InsufficientSharesAvailable();
            details.stepsToBuy = min(stepsLeft, stepsToBuy);
        }

        details.newFractionsSold = fraction.soldSteps + details.stepsToBuy;
        details.amount = details.stepsToBuy * fraction.step;

        details.roundFullyFilled = details.newFractionsSold == fraction.totalSteps;
    }

    /**
     * @notice Handles token transfers based on minimum shares logic
     * @dev With Counterfactual Holder (CFH) enabled, all fundraised amounts before `minSharesToRaise` is reached
     *      are held in the OffchainFractions CFH address rather than the contract balance. This ensures that any
     *      on-chain monitoring reflects the actual behavior of funds being held in the CFH address.
     * @dev When `minSharesToRaise` is reached, the funds are transferred to the recipient.
     * @param fraction The fraction data
     * @param details Purchase calculation results
     * @param creator The fraction creator
     * @param id The fraction ID
     */
    function _handlePurchaseTransfers(
        FractionData storage fraction,
        PurchaseDetails memory details,
        address creator,
        bytes32 id,
        bool isGuardedToken
    ) internal returns (bool minSharesReached) {
        address token = fraction.token;
        uint256 minSharesToRaise = fraction.minSharesToRaise;

        minSharesReached = details.newFractionsSold >= minSharesToRaise;

        /// If `minShares` has not been reached, send funds to the contract.
        if (details.newFractionsSold < minSharesToRaise) {
            // Below minimum threshold - hold funds in contract
            _safeTransferFromNoTaxToken(token, msg.sender, address(this), details.amount, isGuardedToken);
        }
        // If `minShares` has been reached
        // If it's the first time reaching `minShares`, transfer all accumulated funds to the recipient. and mark it as claimed.
        // If it's not the first time reaching `minShares`, transfer the funds to the recipient.
        else {
            // Above minimum threshold - handle fund distribution
            if (fraction.claimedFromMinSharesToRaise) {
                // Minimum already claimed, send directly to recipient
                IERC20(token).safeTransferFrom(msg.sender, details.sendTo, details.amount);
            } else {
                // First time reaching minimum - transfer all accumulated funds
                _safeTransferFromNoTaxToken(token, msg.sender, address(this), details.amount, isGuardedToken);
                uint256 totalAmount = details.newFractionsSold * fraction.step;
                if (isGuardedToken) {
                    Call[] memory calls = new Call[](1);
                    calls[0] = Call({
                        target: address(token),
                        data: abi.encodeWithSelector(IERC20.transfer.selector, details.sendTo, totalAmount)
                    });
                    i_CFHFactory.execute(token, calls);
                } else {
                    IERC20(token).safeTransfer(details.sendTo, totalAmount);
                }
                fraction.claimedFromMinSharesToRaise = true;
                // For `0` min shares, this won't be emitted.
                emit MinSharesReached(id, creator, minSharesToRaise, details.newFractionsSold);
            }
        }
    }

    /**
     * @notice Finalizes the purchase by updating state and emitting events
     * @param fraction The fraction data
     * @param details Purchase calculation results
     * @param creator The fraction creator
     * @param id The fraction ID
     */
    function _finalizePurchase(
        FractionData storage fraction,
        PurchaseDetails memory details,
        address creator,
        address creditTo,
        bytes32 id
    ) internal {
        // Update user's purchase record
        stepsPurchased[msg.sender][creator][id] += details.stepsToBuy;

        // Update fraction's sold steps
        fraction.soldSteps = details.newFractionsSold;

        // Emit events
        if (details.roundFullyFilled) {
            emit RoundFilled(id, creator);
        }

        emit FractionSold(id, creator, creditTo, msg.sender, fraction.step, details.amount);
    }

    /**
     * @notice Safe transfer that ensures no tax tokens are used
     * @dev Reverts if the received amount doesn't match the sent amount (indicating a tax token)
     * @param token The ERC20 token to transfer
     * @param from The address to transfer from
     * @param to The address to transfer to
     * @param amount The amount to transfer
     */
    function _safeTransferFromNoTaxToken(address token, address from, address to, uint256 amount, bool isGuardedToken)
        internal
    {
        address sendTo = isGuardedToken ? i_CFHFactory.getCurrentCFH({user: to, token: token}) : to;
        uint256 balBefore = IERC20(token).balanceOf(sendTo);
        IERC20(token).safeTransferFrom(from, sendTo, amount);
        uint256 balAfter = IERC20(token).balanceOf(sendTo);
        if (balAfter - balBefore != amount) {
            revert TaxTokenNotSupported();
        }
    }

    /**
     * @notice Returns the minimum of two values
     * @param a First value
     * @param b Second value
     * @return The smaller of the two values
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /// @notice Checks if a * b would overflow
    /// @param a The first operand
    /// @param b The second operand
    /// @return bool True if multiplication would overflow, false otherwise
    function willMultiplyOverflow(uint256 a, uint256 b) internal pure returns (bool) {
        // Gas-optimized shortcut: zero can't overflow
        if (a == 0 || b == 0) return false;
        // Overflow occurs if a > type(uint256).max / b
        return a > type(uint256).max / b;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

    /**
     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
     * Revert on invalid signature.
     */
    function safePermit(
        IERC20Permit token,
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal {
        uint256 nonceBefore = token.nonces(owner);
        token.permit(owner, spender, value, deadline, v, r, s);
        uint256 nonceAfter = token.nonces(owner);
        if (nonceAfter != nonceBefore + 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

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

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

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {CounterfactualHolder} from "./CounterfactualHolder.sol";
import {Call} from "./Structs.sol";
import {TransientBytes} from "./utils/TransientBytes/TransientBytes.sol";
import {ICounterfactualHolderFactory} from "./ICounterfactualHolderFactory.sol";
import {TransientSlot} from "./utils/TransientBytes/TransientSlot.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";

contract CounterfactualHolderFactory is ICounterfactualHolderFactory, ReentrancyGuard {
    using SafeERC20 for IERC20;
    using TransientBytes for *;
    using TransientSlot for *;

    error NotApproved(address from, address operator);

    event TransferToCFH(
        address indexed from, address indexed toUser, address indexed token, address cfh, uint256 amount
    );

    event Execute(address indexed user, address indexed cfh, address indexed token, Call[] calls);
    event Approval(address indexed from, address indexed operator, bool status);

    struct UserTokenData {
        uint256 nextSalt;
    }

    mapping(address user => mapping(address token => UserTokenData)) public userTokenData;
    mapping(address owner => mapping(address operator => bool status)) public approvals;

    function transferCFHToCFH(address toUser, address token, uint256 amount) external nonReentrant {
        _executeCFHTransfer(msg.sender, toUser, token, amount);
    }

    function transferFromCFHToCFH(address fromUser, address toUser, address token, uint256 amount)
        external
        nonReentrant
    {
        if (!isApproved(fromUser, msg.sender)) {
            revert NotApproved(fromUser, msg.sender);
        }
        _executeCFHTransfer(fromUser, toUser, token, amount);
    }

    function _executeCFHTransfer(address fromUser, address toUser, address token, uint256 amount) internal {
        UserTokenData storage d = userTokenData[toUser][token];
        address currentHolder = _predictCFH(token, deriveUserNonce(toUser, token, d.nextSalt));

        Call[] memory calls = new Call[](1);
        calls[0] = Call({
            target: address(token),
            data: abi.encodeWithSelector(IERC20.transfer.selector, currentHolder, amount)
        });
        _execute(fromUser, token, calls);

        emit TransferToCFH(fromUser, toUser, token, currentHolder, amount);
    }

    function transferToCFH(address user, address token, uint256 amount) external nonReentrant {
        UserTokenData storage d = userTokenData[user][token];
        address currentHolder = _predictCFH(token, deriveUserNonce(user, token, d.nextSalt));
        IERC20(token).safeTransferFrom(msg.sender, currentHolder, amount);
        emit TransferToCFH(msg.sender, user, token, currentHolder, amount);
    }

    function executeFrom(address from, address token, Call[] memory calls) external nonReentrant {
        if (!isApproved(from, msg.sender)) {
            revert NotApproved(from, msg.sender);
        }

        _execute(from, token, calls);
    }

    function execute(address token, Call[] memory calls) external nonReentrant {
        _execute(msg.sender, token, calls);
    }

    function setApprovalStatus(address operator, bool status) external {
        approvals[msg.sender][operator] = status;
        emit Approval(msg.sender, operator, status);
    }

    function _execute(address from, address token, Call[] memory calls) internal {
        bytes32 baseCallsSlot = deriveCallsBaseSlot();
        bytes memory dataCalls = abi.encode(calls);
        baseCallsSlot.tstoreBytes(dataCalls);

        UserTokenData storage d = userTokenData[from][token];

        uint256 nextSalt = d.nextSalt;
        address nextHolder = _predictCFH(token, deriveUserNonce(from, token, nextSalt + 1));
        bytes32 baseNextHolderSlot = deriveNextHolderBaseSlot();
        baseNextHolderSlot.asAddress().tstore(nextHolder);

        bytes32 nonce = deriveUserNonce(from, token, nextSalt);
        address cfh = address(new CounterfactualHolder{salt: nonce}(IERC20(token)));
        d.nextSalt = nextSalt + 1;

        emit Execute(from, cfh, token, calls);
    }

    function isApproved(address from, address operator) public view returns (bool) {
        return approvals[from][operator];
    }

    function getCurrentCFH(address user, address token) public view returns (address) {
        UserTokenData storage d = userTokenData[user][token];
        return _predictCFH(token, deriveUserNonce(user, token, d.nextSalt));
    }

    function balanceOfCFH(address user, address token) external view returns (uint256) {
        return IERC20(token).balanceOf(getCurrentCFH(user, token));
    }

    function deriveUserNonce(address user, address token, uint256 nonce) internal view returns (bytes32) {
        return keccak256(abi.encodePacked(user, token, nonce, address(this)));
    }

    function getTransientCalls() external view returns (Call[] memory) {
        bytes32 baseCallsSlot = deriveCallsBaseSlot();
        bytes memory dataCalls = baseCallsSlot.tloadBytes();
        return abi.decode(dataCalls, (Call[]));
    }

    function getTransientNextHolder() external view returns (address) {
        bytes32 baseNextHolderSlot = deriveNextHolderBaseSlot();
        return baseNextHolderSlot.asAddress().tload();
    }

    function deriveCallsBaseSlot() internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("CALLS"));
    }

    function deriveNextHolderBaseSlot() internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("NEXT_HOLDER"));
    }

    /// @dev Predict the create2
    function _predictCFH(address token, bytes32 salt) internal view returns (address currentHolder) {
        bytes32 initCodeHash = keccak256(abi.encodePacked(type(CounterfactualHolder).creationCode, abi.encode(token)));
        // EIP-1014: keccak256(0xff ++ deployer ++ salt ++ keccak256(init_code))[12:]
        bytes32 hash = keccak256(abi.encodePacked(bytes1(0xff), address(this), salt, initCodeHash));

        currentHolder = address(uint160(uint256(hash)));
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.20;

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

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

    uint256 private _status;

    /**
     * @dev Unauthorized reentrant call.
     */
    error ReentrancyGuardReentrantCall();

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        if (_status == _ENTERED) {
            revert ReentrancyGuardReentrantCall();
        }

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

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

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

File 6 of 12 : Structs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

struct Call {
    address target;
    bytes data;
}

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20Permit {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

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

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

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

pragma solidity ^0.8.20;

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

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

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

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

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

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

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

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

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

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

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

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

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

import {Call} from "./Structs.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ICounterfactualHolderFactory} from "./ICounterfactualHolderFactory.sol";

contract CounterfactualHolder {
    using SafeERC20 for IERC20;

    error ExecutionFailed(uint256 index, address target, bytes data);

    constructor(IERC20 _token) {
        ICounterfactualHolderFactory factory = ICounterfactualHolderFactory(msg.sender);
        Call[] memory _calls = factory.getTransientCalls();
        _executeCalls(_calls);
        uint256 leftoverBalance = _token.balanceOf(address(this));
        if (leftoverBalance > 0) {
            address nextHolder = factory.getTransientNextHolder();
            _token.safeTransfer(nextHolder, leftoverBalance);
        }
    }

    function _executeCalls(Call[] memory _calls) internal {
        uint256 length = _calls.length;
        for (uint256 i; i < length; ++i) {
            (bool success,) = _calls[i].target.call(_calls[i].data);
            if (!success) {
                revert ExecutionFailed(i, _calls[i].target, _calls[i].data);
            }
        }
    }
}

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

/**
 * TransientBytes (incremental slots)
 * - Length at `baseSlot`
 * - Data starts at keccak256(abi.encodePacked(baseSlot, DOMAIN))
 * - Chunk i lives at dataStart + i
 *
 * Uses OpenZeppelin TransientSlot for typed tload/tstore.
 */
import "./TransientSlot.sol";

library TransientBytes {
    using TransientSlot for *;

    // Domain-separate the data region to avoid accidental overlap
    bytes32 private constant _DOMAIN = keccak256("TransientBytes.v2");

    /*//////////////////////////////////////////////////////////////
                              WRITE
    //////////////////////////////////////////////////////////////*/

    function tstoreBytes(bytes32 baseSlot, bytes memory data) internal {
        uint256 len = data.length;
        baseSlot.asUint256().tstore(len);

        if (len == 0) return;

        uint256 nChunks = (len + 31) / 32; // ceil_div
        bytes32 dataStart = _dataStart(baseSlot);

        uint256 src;
        assembly {
            src := add(data, 32)
        }

        for (uint256 i = 0; i < nChunks; ++i) {
            bytes32 word;
            assembly {
                word := mload(add(src, mul(i, 32)))
            }
            _slotAdd(dataStart, i).asBytes32().tstore(word);
        }
    }

    /*//////////////////////////////////////////////////////////////
                               READ
    //////////////////////////////////////////////////////////////*/

    function tloadBytes(bytes32 baseSlot) internal view returns (bytes memory out) {
        uint256 len = baseSlot.asUint256().tload();
        if (len == 0) return bytes("");

        out = new bytes(len);
        uint256 nChunks = (len + 31) / 32;
        bytes32 dataStart = _dataStart(baseSlot);

        uint256 dst;
        assembly {
            dst := add(out, 32)
        }

        for (uint256 i = 0; i < nChunks; ++i) {
            bytes32 word = _slotAdd(dataStart, i).asBytes32().tload();
            assembly {
                mstore(add(dst, mul(i, 32)), word)
            }
        }
    }

    /*//////////////////////////////////////////////////////////////
                               CLEAR
    //////////////////////////////////////////////////////////////*/

    /// @dev Logically clear by zeroing length (no need to zero chunks).
    function tclear(bytes32 baseSlot) internal {
        baseSlot.asUint256().tstore(0);
    }

    /*//////////////////////////////////////////////////////////////
                             INTERNALS
    //////////////////////////////////////////////////////////////*/

    /// @dev Start of data region = keccak256(baseSlot || DOMAIN)
    function _dataStart(bytes32 baseSlot) private pure returns (bytes32 start) {
        bytes32 d = _DOMAIN;
        assembly {
            let ptr := mload(0x40)
            mstore(ptr, baseSlot)
            mstore(add(ptr, 0x20), d)
            start := keccak256(ptr, 64)
        }
    }

    /// @dev Return base + index as a bytes32 slot.
    function _slotAdd(bytes32 base, uint256 index) private pure returns (bytes32 slot) {
        assembly {
            slot := add(base, index)
        }
    }
}

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

import {Call} from "./Structs.sol";

interface ICounterfactualHolderFactory {
    function getTransientCalls() external view returns (Call[] memory);
    function getTransientNextHolder() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/TransientSlot.sol)
// This file was procedurally generated from scripts/generate/templates/TransientSlot.js.

pragma solidity ^0.8.24;

/**
 * @dev Library for reading and writing value-types to specific transient storage slots.
 *
 * Transient slots are often used to store temporary values that are removed after the current transaction.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 *  * Example reading and writing values using transient storage:
 * ```solidity
 * contract Lock {
 *     using TransientSlot for *;
 *
 *     // Define the slot. Alternatively, use the SlotDerivation library to derive the slot.
 *     bytes32 internal constant _LOCK_SLOT = 0xf4678858b2b588224636b8522b729e7722d32fc491da849ed75b3fdf3c84f542;
 *
 *     modifier locked() {
 *         require(!_LOCK_SLOT.asBoolean().tload());
 *
 *         _LOCK_SLOT.asBoolean().tstore(true);
 *         _;
 *         _LOCK_SLOT.asBoolean().tstore(false);
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {SlotDerivation}.
 */
library TransientSlot {
    /**
     * @dev UDVT that represents a slot holding an address.
     */
    type AddressSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a AddressSlot.
     */
    function asAddress(bytes32 slot) internal pure returns (AddressSlot) {
        return AddressSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a bool.
     */
    type BooleanSlot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a BooleanSlot.
     */
    function asBoolean(bytes32 slot) internal pure returns (BooleanSlot) {
        return BooleanSlot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a bytes32.
     */
    type Bytes32Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Bytes32Slot.
     */
    function asBytes32(bytes32 slot) internal pure returns (Bytes32Slot) {
        return Bytes32Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a uint256.
     */
    type Uint256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Uint256Slot.
     */
    function asUint256(bytes32 slot) internal pure returns (Uint256Slot) {
        return Uint256Slot.wrap(slot);
    }

    /**
     * @dev UDVT that represents a slot holding a int256.
     */
    type Int256Slot is bytes32;

    /**
     * @dev Cast an arbitrary slot to a Int256Slot.
     */
    function asInt256(bytes32 slot) internal pure returns (Int256Slot) {
        return Int256Slot.wrap(slot);
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(AddressSlot slot) internal view returns (address value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(AddressSlot slot, address value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(BooleanSlot slot) internal view returns (bool value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(BooleanSlot slot, bool value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Bytes32Slot slot) internal view returns (bytes32 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Bytes32Slot slot, bytes32 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Uint256Slot slot) internal view returns (uint256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Uint256Slot slot, uint256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }

    /**
     * @dev Load the value held at location `slot` in transient storage.
     */
    function tload(Int256Slot slot) internal view returns (int256 value) {
        assembly ("memory-safe") {
            value := tload(slot)
        }
    }

    /**
     * @dev Store `value` at location `slot` in transient storage.
     */
    function tstore(Int256Slot slot, int256 value) internal {
        assembly ("memory-safe") {
            tstore(slot, value)
        }
    }
}

Settings
{
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "solmate/=lib/solmate/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@/=src/",
    "#/=test/",
    "@solady/=lib/solady/src/",
    "@solady-tests/=lib/solady/test/",
    "@unifapv2/=src/UnifapV2/",
    "clones/=lib/clones-with-immutable-args/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "@clones/=lib/unifap-v2/lib/clones-with-immutable-args/src/",
    "@ds/=lib/unifap-v2/lib/ds-test/src/",
    "@solmate/=lib/unifap-v2/lib/solmate/src/",
    "@std/=lib/unifap-v2/lib/forge-std/src/",
    "abdk-libraries-solidity/=lib/abdk-libraries-solidity/",
    "clones-with-immutable-args/=lib/clones-with-immutable-args/src/",
    "erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solady/=lib/solady/",
    "unifap-v2/=lib/unifap-v2/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 1000000
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "prague",
  "viaIR": false
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract CounterfactualHolderFactory","name":"_counterfactualHolderFactory","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"AddressInsufficientBalance","type":"error"},{"inputs":[],"name":"AlreadyClosed","type":"error"},{"inputs":[],"name":"AlreadyExists","type":"error"},{"inputs":[],"name":"CannotClaimRefundWhenNotExpired","type":"error"},{"inputs":[],"name":"CannotClaimRefundWhenThresholdReached","type":"error"},{"inputs":[],"name":"CannotCloseWhenThresholdReached","type":"error"},{"inputs":[],"name":"CannotHaveZeroTotalSteps","type":"error"},{"inputs":[],"name":"CannotSetRefundDetailsWhenThresholdReached","type":"error"},{"inputs":[],"name":"ExpirationCannotBeGreaterThanMaxDuration","type":"error"},{"inputs":[],"name":"ExpirationMustBeInTheFuture","type":"error"},{"inputs":[],"name":"Expired","type":"error"},{"inputs":[],"name":"FailedInnerCall","type":"error"},{"inputs":[],"name":"InsufficientSharesAvailable","type":"error"},{"inputs":[],"name":"InvalidToAddress","type":"error"},{"inputs":[],"name":"InvalidToken","type":"error"},{"inputs":[],"name":"MinSharesCannotBeGreaterThanTotalSteps","type":"error"},{"inputs":[],"name":"MinStepsToBuyCannotBeGreaterThanStepsToBuy","type":"error"},{"inputs":[],"name":"MinStepsToBuyCannotBeZero","type":"error"},{"inputs":[],"name":"NoStepsPurchased","type":"error"},{"inputs":[],"name":"NotFractionsCloser","type":"error"},{"inputs":[],"name":"RecipientCannotBeSelf","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[],"name":"RefundOperatorNotApproved","type":"error"},{"inputs":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"StepMustBeGreaterThanZero","type":"error"},{"inputs":[],"name":"TaxTokenNotSupported","type":"error"},{"inputs":[],"name":"TotalRaisedOverflow","type":"error"},{"inputs":[],"name":"UseCounterfactualAddressForRefundNotAllowedIfAddressIsZero","type":"error"},{"inputs":[],"name":"ZeroSteps","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"}],"name":"FractionClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":false,"internalType":"uint256","name":"step","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalSteps","type":"uint256"},{"indexed":false,"internalType":"uint48","name":"expiration","type":"uint48"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"bool","name":"useCounterfactualAddress","type":"bool"},{"indexed":false,"internalType":"uint256","name":"minSharesToRaise","type":"uint256"},{"indexed":false,"internalType":"address","name":"closer","type":"address"}],"name":"FractionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"address","name":"refundTo","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FractionRefunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":true,"internalType":"address","name":"creditTo","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint256","name":"step","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"FractionSold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"creator","type":"address"},{"indexed":false,"internalType":"uint256","name":"minShares","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTotalSharesSold","type":"uint256"}],"name":"MinSharesReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"refundOperator","type":"address"},{"indexed":false,"internalType":"bool","name":"isApproved","type":"bool"}],"name":"RefundOperatorStatusSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"id","type":"bytes32"},{"indexed":true,"internalType":"address","name":"creator","type":"address"}],"name":"RoundFilled","type":"event"},{"inputs":[],"name":"REFUND_WILDCARD_OPERATOR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"uint256","name":"stepsToBuy","type":"uint256"},{"internalType":"uint256","name":"minStepsToBuy","type":"uint256"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"address","name":"creditTo","type":"address"},{"internalType":"bool","name":"useCounterfactualAddressForRefund","type":"bool"}],"name":"buyFractions","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"claimRefund","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"closeFraction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"step","type":"uint256"},{"internalType":"uint256","name":"totalSteps","type":"uint256"},{"internalType":"uint48","name":"expiration","type":"uint48"},{"internalType":"address","name":"to","type":"address"},{"internalType":"bool","name":"useCounterfactualAddress","type":"bool"},{"internalType":"uint256","name":"minSharesToRaise","type":"uint256"},{"internalType":"address","name":"closer","type":"address"}],"name":"createFraction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"getFraction","outputs":[{"components":[{"internalType":"address","name":"token","type":"address"},{"internalType":"uint48","name":"expiration","type":"uint48"},{"internalType":"bool","name":"manuallyClosed","type":"bool"},{"internalType":"uint256","name":"minSharesToRaise","type":"uint256"},{"internalType":"bool","name":"useCounterfactualAddress","type":"bool"},{"internalType":"bool","name":"claimedFromMinSharesToRaise","type":"bool"},{"internalType":"uint256","name":"step","type":"uint256"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"soldSteps","type":"uint256"},{"internalType":"uint256","name":"totalSteps","type":"uint256"},{"internalType":"address","name":"closer","type":"address"}],"internalType":"struct OffchainFractions.FractionData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"getRefundDetails","outputs":[{"components":[{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"useCounterfactualAddress","type":"bool"}],"internalType":"struct OffchainFractions.RefundDetails","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"i_CFHFactory","outputs":[{"internalType":"contract CounterfactualHolderFactory","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"refundOperator","type":"address"}],"name":"isRefundOperatorApproved","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"refundOperator","type":"address"}],"name":"refundApprovals","outputs":[{"internalType":"bool","name":"isApproved","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"},{"internalType":"address","name":"refundTo","type":"address"},{"internalType":"bool","name":"useCounterfactualAddress","type":"bool"}],"name":"setRefundDetails","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"refundOperator","type":"address"},{"internalType":"bool","name":"isApproved","type":"bool"}],"name":"setRefundOperatorStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"address","name":"creator","type":"address"},{"internalType":"bytes32","name":"id","type":"bytes32"}],"name":"stepsPurchased","outputs":[{"internalType":"uint256","name":"stepsPurchased","type":"uint256"}],"stateMutability":"view","type":"function"}]

60a060405234801561000f575f5ffd5b50604051612b5a380380612b5a83398101604081905261002e91610043565b60015f556001600160a01b0316608052610070565b5f60208284031215610053575f5ffd5b81516001600160a01b0381168114610069575f5ffd5b9392505050565b608051612aaf6100ab5f395f81816103cb015281816110f70152818161149a015281816119f701528181611d0701526120ac0152612aaf5ff3fe608060405234801561000f575f5ffd5b50600436106100da575f3560e01c806344dc5c311161008857806370308c881161006357806370308c8814610212578063b73922a214610258578063ddfb4fa5146103c6578063fa0d5cfc146103ed575f5ffd5b806344dc5c31146101ae57806353e072fb146101c157806361a8f116146101d4575f5ffd5b806323b512c0116100b857806323b512c01461012e5780633b00af2b1461014157806344051f2a14610181575f5ffd5b806309473a17146100de5780631babf2e1146101065780632213098e1461011b575b5f5ffd5b6100f16100ec36600461250c565b610400565b60405190151581526020015b60405180910390f35b610119610114366004612550565b6104a7565b005b61011961012936600461257c565b61053d565b61011961013c3660046125a6565b610742565b61015c73ffffffffffffffffffffffffffffffffffffffff81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100fd565b6100f161018f36600461250c565b600260209081525f928352604080842090915290825290205460ff1681565b6101196101bc366004612642565b610af0565b6101196101cf3660046126b8565b610dc9565b6102046101e2366004612708565b600160209081525f938452604080852082529284528284209052825290205481565b6040519081526020016100fd565b610225610220366004612708565b610f2d565b60408051825173ffffffffffffffffffffffffffffffffffffffff168152602092830151151592810192909252016100fd565b6103b961026636600461257c565b60408051610160810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101919091525073ffffffffffffffffffffffffffffffffffffffff8083165f9081526004602081815260408084208685528252928390208351610160810185528154808716825265ffffffffffff740100000000000000000000000000000000000000008204169382019390935260ff7a01000000000000000000000000000000000000000000000000000090930483161515948101949094526001810154606085015260028101548083161515608086015261010090819004909216151560a0850152600381015460c085015291820154841660e084015260058201549083015260068101546101208301526007015490911661014082015292915050565b6040516100fd9190612746565b61015c7f000000000000000000000000000000000000000000000000000000000000000081565b6101196103fb366004612708565b610fad565b5f73ffffffffffffffffffffffffffffffffffffffff83163303610426575060016104a1565b73ffffffffffffffffffffffffffffffffffffffff8084165f908152600260209081526040808320938352929052205460ff1680156104695760019150506104a1565b505073ffffffffffffffffffffffffffffffffffffffff8083165f9081526002602090815260408083209385168352929052205460ff165b92915050565b335f81815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f4782ca8508d6afbd5d68dfc34150dc33571b953e0a37e50621e84c29dfd5fe77910160405180910390a35050565b6105456115cc565b73ffffffffffffffffffffffffffffffffffffffff8281165f9081526004602090815260408083208584529091529020600781015490911633146105b5576040517faf5dc60d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547a010000000000000000000000000000000000000000000000000000900460ff161561060f576040517f9acb7e5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010154816005015410610650576040517fecbd4e9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474010000000000000000000000000000000000000000900465ffffffffffff164211156106ab576040517f203d82d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff81167a01000000000000000000000000000000000000000000000000000017825560405173ffffffffffffffffffffffffffffffffffffffff80861692169084907f964970a0342d6bbfbfbe7b021dcfe8edad8ae54379940df5f7205d4c38033f42905f90a45061073e60015f55565b5050565b61074a6115cc565b61075888858989868a61160d565b335f9081526004602090815260408083208c8452909152902060060154156107ac576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518061016001604052808973ffffffffffffffffffffffffffffffffffffffff1681526020018665ffffffffffff1681526020015f151581526020018381526020018415158152602001835f14151581526020018881526020018573ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020018781526020018273ffffffffffffffffffffffffffffffffffffffff1681525060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8b81526020019081526020015f205f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151815f0160146101000a81548165ffffffffffff021916908365ffffffffffff1602179055506040820151815f01601a6101000a81548160ff021916908315150217905550606082015181600101556080820151816002015f6101000a81548160ff02191690831515021790555060a08201518160020160016101000a81548160ff02191690831515021790555060c0820151816003015560e0820151816004015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061010082015181600501556101208201518160060155610140820151816007015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff168a7fc74aefedb98220bd7ac12cdb1c1eefecbb31bc09d07dbe789c5f529d46b7dc688a8a8a8a8a8a8a604051610ad49796959493929190968752602087019590955265ffffffffffff93909316604086015273ffffffffffffffffffffffffffffffffffffffff91821660608601521515608085015260a08401919091521660c082015260e00190565b60405180910390a4610ae560015f55565b505050505050505050565b610af86115cc565b73ffffffffffffffffffffffffffffffffffffffff87165f908152600460209081526040808320898452909152812090859003610b61576040517f26777fbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b855f03610b9a576040517f7a3ceb3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85851115610bd4576040517f7f45cb9c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841615801590610bf65750815b15610c2d576040517fe7f6953e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c368161187b565b5f610c42828888611933565b90505f610c6283838c8c876002015f9054906101000a900460ff16611b23565b905073ffffffffffffffffffffffffffffffffffffffff861615801590610c87575080155b15610da75760405180604001604052808773ffffffffffffffffffffffffffffffffffffffff16815260200185151581525060035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8b81526020019081526020015f205f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151815f0160146101000a81548160ff0219169083151502179055509050505b610db483838c888d611e2b565b505050610dc060015f55565b50505050505050565b73ffffffffffffffffffffffffffffffffffffffff821615801590610deb5750805b15610e22576040517fe7f6953e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84165f90815260046020908152604080832086845290915290206001810154600582015410610e92576040517ff2f885cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5060408051808201825273ffffffffffffffffffffffffffffffffffffffff93841681529115156020808401918252335f90815260038252838120978616815296815282872095875294909452909320925183549251151574010000000000000000000000000000000000000000027fffffffffffffffffffffff000000000000000000000000000000000000000000909316911617179055565b6040805180820182525f808252602091820181905273ffffffffffffffffffffffffffffffffffffffff86811682526003835283822086821683528352838220858352835290839020835180850190945254908116835274010000000000000000000000000000000000000000900460ff161515908201525b9392505050565b610fb56115cc565b73ffffffffffffffffffffffffffffffffffffffff8281165f818152600460209081526040808320868452825280832088861684526003835281842094845293825280832086845282528083208151808301909252549485168082527401000000000000000000000000000000000000000090950460ff1615159181019190915291929081156110455781611047565b865b90506110538733610400565b15801561106757506110658233610400565b155b1561109e576040517f8d807a9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260200151156111655783546040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015291821660248201527f000000000000000000000000000000000000000000000000000000000000000090911690638749eacc90604401602060405180830381865afa15801561113e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611162919061283f565b90505b73ffffffffffffffffffffffffffffffffffffffff8088165f908152600160209081526040808320938a168352928152828220888352905290812054908190036111db576040517fff8597ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600585015460018601548110801590611220576040517ff7b6003700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b865474010000000000000000000000000000000000000000810465ffffffffffff164211907a010000000000000000000000000000000000000000000000000000900460ff1680158015611272575081155b156112a9576040517f22abffd500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8960030154866112ba9190612887565b90505f60015f8f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8d81526020019081526020015f20819055508585611354919061289e565b60058b015560028a015460ff1615611508576040805160018082528183019092525f91816020015b604080518082019091525f81526060602082015281526020019060019003908161137c5750506040805180820182528d5473ffffffffffffffffffffffffffffffffffffffff90811682528251908c1660248201526044808201879052835180830390910181526064909101909252602082810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905281019190915281519192509082905f90611450576114506128b1565b60209081029190910101528a546040517fe30c1e1a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000081169263e30c1e1a926114d592919091169085906004016128de565b5f604051808303815f87803b1580156114ec575f5ffd5b505af11580156114fe573d5f5f3e3d5ffd5b505050505061152b565b895461152b9073ffffffffffffffffffffffffffffffffffffffff168883611f72565b8c73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff168c7ff254e2593561a9aed8c322b7f727abcbd3a61b90dd79ee2db5ffb9149998bd988a856040516115ac92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60405180910390a4505050505050505050506115c760015f55565b505050565b60025f5403611607576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f55565b73ffffffffffffffffffffffffffffffffffffffff861661165a576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff85166116a7576040517f8aa3a72f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b835f036116e0576040517fa76d0f8b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b825f03611719576040517f99515c6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff861603611768576040517fe2918e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828211156117a2576040517fc8761eed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b428165ffffffffffff16116117e3576040517f952e22f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63039ada006117fa4265ffffffffffff841661289e565b1115611832576040517f1b73c9d500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61183c8484611ff3565b15611873576040517f7764768a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b80547a010000000000000000000000000000000000000000000000000000900460ff16156118d5576040517f9acb7e5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474010000000000000000000000000000000000000000900465ffffffffffff16421115611930576040517f203d82d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6119786040518060a001604052805f81526020015f81526020015f81526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f151581525090565b6004840154600285015473ffffffffffffffffffffffffffffffffffffffff9091169060ff166119a85780611a62565b84546040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015291821660248201527f000000000000000000000000000000000000000000000000000000000000000090911690638749eacc90604401602060405180830381865afa158015611a3e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a62919061283f565b73ffffffffffffffffffffffffffffffffffffffff16606083015250600584015460068501545f611a93838361289e565b905084811015611acf576040517f840f17b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ad9818761203e565b8085526005880154611af0945090925090506129e6565b604082015260038401548151611b069190612887565b602082015260069093015460408401511460808401525090919050565b8454600186015460408601518111159173ffffffffffffffffffffffffffffffffffffffff169082611b6557611b608233308a6020015188612053565b611e20565b6002880154610100900460ff1615611ba55760608701516020880151611b609173ffffffffffffffffffffffffffffffffffffffff8516913391906122ab565b611bb68233308a6020015188612053565b5f88600301548860400151611bcb9190612887565b90508415611d71576040805160018082528183019092525f91816020015b604080518082019091525f815260606020820152815260200190600190039081611be957505060408051808201825273ffffffffffffffffffffffffffffffffffffffff878116825260608d01518351911660248201526044808201879052835180830390910181526064909101909252602082810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905281019190915281519192509082905f90611cbf57611cbf6128b1565b60209081029190910101526040517fe30c1e1a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000000000000000000000000000000000000000000000169063e30c1e1a90611d3e90879085906004016128de565b5f604051808303815f87803b158015611d55575f5ffd5b505af1158015611d67573d5f5f3e3d5ffd5b5050505050611d98565b6060880151611d989073ffffffffffffffffffffffffffffffffffffffff85169083611f72565b6002890180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790556040888101518151848152602081019190915273ffffffffffffffffffffffffffffffffffffffff89169188917f2176ad82842c18ffacc7dd574ef740019194587cb36d3eb52ead7e5d9c043725910160405180910390a3505b505095945050505050565b8351335f90815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff88168452825280832085845290915281208054909190611e749084906129e6565b909155505060408401516005860155608084015115611ed05760405173ffffffffffffffffffffffffffffffffffffffff84169082907f604944707ed6db53f4b45f2052524bb799f902b0864a71e69d83252b5fad8234905f90a35b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16827f31c608390612eea6cdd1ba98fe5c90f960aec88aceb233d7e3fd5e01ec36f1443389600301548960200151604051611f639392919073ffffffffffffffffffffffffffffffffffffffff9390931683526020830191909152604082015260600190565b60405180910390a45050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390526115c791859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506122f7565b5f821580611fff575081155b1561200b57505f6104a1565b612035827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6129f9565b90921192915050565b5f81831061204c5781610fa6565b5090919050565b5f8161205f5783612115565b6040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015287811660248301527f00000000000000000000000000000000000000000000000000000000000000001690638749eacc90604401602060405180830381865afa1580156120f1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612115919061283f565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192505f918816906370a0823190602401602060405180830381865afa158015612184573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121a89190612a31565b90506121cc73ffffffffffffffffffffffffffffffffffffffff88168784876122ab565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f91908916906370a0823190602401602060405180830381865afa158015612239573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061225d9190612a31565b90508461226a838361289e565b146122a1576040517f61f5187700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526122f19186918216906323b872dd90608401611fac565b50505050565b5f61231873ffffffffffffffffffffffffffffffffffffffff841683612390565b905080515f1415801561233c57508080602001905181019061233a9190612a48565b155b156115c7576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841660048201526024015b60405180910390fd5b6060610fa683835f845f5f8573ffffffffffffffffffffffffffffffffffffffff1684866040516123c19190612a63565b5f6040518083038185875af1925050503d805f81146123fb576040519150601f19603f3d011682016040523d82523d5f602084013e612400565b606091505b509150915061241086838361241a565b9695505050505050565b60608261242f5761242a826124a9565b610fa6565b8151158015612453575073ffffffffffffffffffffffffffffffffffffffff84163b155b156124a2576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401612387565b5080610fa6565b8051156124b95780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81168114611930575f5ffd5b5f5f6040838503121561251d575f5ffd5b8235612528816124eb565b91506020830135612538816124eb565b809150509250929050565b8015158114611930575f5ffd5b5f5f60408385031215612561575f5ffd5b823561256c816124eb565b9150602083013561253881612543565b5f5f6040838503121561258d575f5ffd5b8235612598816124eb565b946020939093013593505050565b5f5f5f5f5f5f5f5f5f6101208a8c0312156125bf575f5ffd5b8935985060208a01356125d1816124eb565b975060408a0135965060608a0135955060808a013565ffffffffffff811681146125f9575f5ffd5b945060a08a0135612609816124eb565b935060c08a013561261981612543565b925060e08a013591506101008a0135612631816124eb565b809150509295985092959850929598565b5f5f5f5f5f5f5f60e0888a031215612658575f5ffd5b8735612663816124eb565b96506020880135955060408801359450606088013593506080880135612688816124eb565b925060a0880135612698816124eb565b915060c08801356126a881612543565b8091505092959891949750929550565b5f5f5f5f608085870312156126cb575f5ffd5b84356126d6816124eb565b93506020850135925060408501356126ed816124eb565b915060608501356126fd81612543565b939692955090935050565b5f5f5f6060848603121561271a575f5ffd5b8335612725816124eb565b92506020840135612735816124eb565b929592945050506040919091013590565b815173ffffffffffffffffffffffffffffffffffffffff1681526101608101602083015161277e602084018265ffffffffffff169052565b506040830151612792604084018215159052565b506060830151606083015260808301516127b0608084018215159052565b5060a08301516127c460a084018215159052565b5060c083015160c083015260e08301516127f660e084018273ffffffffffffffffffffffffffffffffffffffff169052565b5061010083015161010083015261012083015161012083015261014083015161283861014084018273ffffffffffffffffffffffffffffffffffffffff169052565b5092915050565b5f6020828403121561284f575f5ffd5b8151610fa6816124eb565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b80820281158282048414176104a1576104a161285a565b818103818111156104a1576104a161285a565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6040820173ffffffffffffffffffffffffffffffffffffffff851683526040602084015280845180835260608501915060608160051b8601019250602086015f5b828110156129d9577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0878603018452815173ffffffffffffffffffffffffffffffffffffffff8151168652602081015190506040602087015280518060408801528060208301606089015e5f6060828901015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011688010196505050602082019150602084019350600181019050612920565b5092979650505050505050565b808201808211156104a1576104a161285a565b5f82612a2c577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b5f60208284031215612a41575f5ffd5b5051919050565b5f60208284031215612a58575f5ffd5b8151610fa681612543565b5f82518060208501845e5f92019182525091905056fea26469706673582212209706b82ab8df4b94c696f407133a1b213169db5632bfd45dabf1af8fbba2e93864736f6c634300081c00330000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f

Deployed Bytecode

0x608060405234801561000f575f5ffd5b50600436106100da575f3560e01c806344dc5c311161008857806370308c881161006357806370308c8814610212578063b73922a214610258578063ddfb4fa5146103c6578063fa0d5cfc146103ed575f5ffd5b806344dc5c31146101ae57806353e072fb146101c157806361a8f116146101d4575f5ffd5b806323b512c0116100b857806323b512c01461012e5780633b00af2b1461014157806344051f2a14610181575f5ffd5b806309473a17146100de5780631babf2e1146101065780632213098e1461011b575b5f5ffd5b6100f16100ec36600461250c565b610400565b60405190151581526020015b60405180910390f35b610119610114366004612550565b6104a7565b005b61011961012936600461257c565b61053d565b61011961013c3660046125a6565b610742565b61015c73ffffffffffffffffffffffffffffffffffffffff81565b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016100fd565b6100f161018f36600461250c565b600260209081525f928352604080842090915290825290205460ff1681565b6101196101bc366004612642565b610af0565b6101196101cf3660046126b8565b610dc9565b6102046101e2366004612708565b600160209081525f938452604080852082529284528284209052825290205481565b6040519081526020016100fd565b610225610220366004612708565b610f2d565b60408051825173ffffffffffffffffffffffffffffffffffffffff168152602092830151151592810192909252016100fd565b6103b961026636600461257c565b60408051610160810182525f80825260208201819052918101829052606081018290526080810182905260a0810182905260c0810182905260e08101829052610100810182905261012081018290526101408101919091525073ffffffffffffffffffffffffffffffffffffffff8083165f9081526004602081815260408084208685528252928390208351610160810185528154808716825265ffffffffffff740100000000000000000000000000000000000000008204169382019390935260ff7a01000000000000000000000000000000000000000000000000000090930483161515948101949094526001810154606085015260028101548083161515608086015261010090819004909216151560a0850152600381015460c085015291820154841660e084015260058201549083015260068101546101208301526007015490911661014082015292915050565b6040516100fd9190612746565b61015c7f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f81565b6101196103fb366004612708565b610fad565b5f73ffffffffffffffffffffffffffffffffffffffff83163303610426575060016104a1565b73ffffffffffffffffffffffffffffffffffffffff8084165f908152600260209081526040808320938352929052205460ff1680156104695760019150506104a1565b505073ffffffffffffffffffffffffffffffffffffffff8083165f9081526002602090815260408083209385168352929052205460ff165b92915050565b335f81815260026020908152604080832073ffffffffffffffffffffffffffffffffffffffff87168085529083529281902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff001686151590811790915590519081529192917f4782ca8508d6afbd5d68dfc34150dc33571b953e0a37e50621e84c29dfd5fe77910160405180910390a35050565b6105456115cc565b73ffffffffffffffffffffffffffffffffffffffff8281165f9081526004602090815260408083208584529091529020600781015490911633146105b5576040517faf5dc60d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547a010000000000000000000000000000000000000000000000000000900460ff161561060f576040517f9acb7e5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060010154816005015410610650576040517fecbd4e9500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474010000000000000000000000000000000000000000900465ffffffffffff164211156106ab576040517f203d82d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80547fffffffffff00ffffffffffffffffffffffffffffffffffffffffffffffffffff81167a01000000000000000000000000000000000000000000000000000017825560405173ffffffffffffffffffffffffffffffffffffffff80861692169084907f964970a0342d6bbfbfbe7b021dcfe8edad8ae54379940df5f7205d4c38033f42905f90a45061073e60015f55565b5050565b61074a6115cc565b61075888858989868a61160d565b335f9081526004602090815260408083208c8452909152902060060154156107ac576040517f23369fa600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518061016001604052808973ffffffffffffffffffffffffffffffffffffffff1681526020018665ffffffffffff1681526020015f151581526020018381526020018415158152602001835f14151581526020018881526020018573ffffffffffffffffffffffffffffffffffffffff1681526020015f81526020018781526020018273ffffffffffffffffffffffffffffffffffffffff1681525060045f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8b81526020019081526020015f205f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151815f0160146101000a81548165ffffffffffff021916908365ffffffffffff1602179055506040820151815f01601a6101000a81548160ff021916908315150217905550606082015181600101556080820151816002015f6101000a81548160ff02191690831515021790555060a08201518160020160016101000a81548160ff02191690831515021790555060c0820151816003015560e0820151816004015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555061010082015181600501556101208201518160060155610140820151816007015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055509050503373ffffffffffffffffffffffffffffffffffffffff168873ffffffffffffffffffffffffffffffffffffffff168a7fc74aefedb98220bd7ac12cdb1c1eefecbb31bc09d07dbe789c5f529d46b7dc688a8a8a8a8a8a8a604051610ad49796959493929190968752602087019590955265ffffffffffff93909316604086015273ffffffffffffffffffffffffffffffffffffffff91821660608601521515608085015260a08401919091521660c082015260e00190565b60405180910390a4610ae560015f55565b505050505050505050565b610af86115cc565b73ffffffffffffffffffffffffffffffffffffffff87165f908152600460209081526040808320898452909152812090859003610b61576040517f26777fbf00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b855f03610b9a576040517f7a3ceb3900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b85851115610bd4576040517f7f45cb9c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff841615801590610bf65750815b15610c2d576040517fe7f6953e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610c368161187b565b5f610c42828888611933565b90505f610c6283838c8c876002015f9054906101000a900460ff16611b23565b905073ffffffffffffffffffffffffffffffffffffffff861615801590610c87575080155b15610da75760405180604001604052808773ffffffffffffffffffffffffffffffffffffffff16815260200185151581525060035f3373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8c73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8b81526020019081526020015f205f820151815f015f6101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506020820151815f0160146101000a81548160ff0219169083151502179055509050505b610db483838c888d611e2b565b505050610dc060015f55565b50505050505050565b73ffffffffffffffffffffffffffffffffffffffff821615801590610deb5750805b15610e22576040517fe7f6953e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff84165f90815260046020908152604080832086845290915290206001810154600582015410610e92576040517ff2f885cc00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5060408051808201825273ffffffffffffffffffffffffffffffffffffffff93841681529115156020808401918252335f90815260038252838120978616815296815282872095875294909452909320925183549251151574010000000000000000000000000000000000000000027fffffffffffffffffffffff000000000000000000000000000000000000000000909316911617179055565b6040805180820182525f808252602091820181905273ffffffffffffffffffffffffffffffffffffffff86811682526003835283822086821683528352838220858352835290839020835180850190945254908116835274010000000000000000000000000000000000000000900460ff161515908201525b9392505050565b610fb56115cc565b73ffffffffffffffffffffffffffffffffffffffff8281165f818152600460209081526040808320868452825280832088861684526003835281842094845293825280832086845282528083208151808301909252549485168082527401000000000000000000000000000000000000000090950460ff1615159181019190915291929081156110455781611047565b865b90506110538733610400565b15801561106757506110658233610400565b155b1561109e576040517f8d807a9600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260200151156111655783546040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015291821660248201527f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f90911690638749eacc90604401602060405180830381865afa15801561113e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611162919061283f565b90505b73ffffffffffffffffffffffffffffffffffffffff8088165f908152600160209081526040808320938a168352928152828220888352905290812054908190036111db576040517fff8597ab00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600585015460018601548110801590611220576040517ff7b6003700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b865474010000000000000000000000000000000000000000810465ffffffffffff164211907a010000000000000000000000000000000000000000000000000000900460ff1680158015611272575081155b156112a9576040517f22abffd500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f8960030154866112ba9190612887565b90505f60015f8f73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8e73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020015f205f8d81526020019081526020015f20819055508585611354919061289e565b60058b015560028a015460ff1615611508576040805160018082528183019092525f91816020015b604080518082019091525f81526060602082015281526020019060019003908161137c5750506040805180820182528d5473ffffffffffffffffffffffffffffffffffffffff90811682528251908c1660248201526044808201879052835180830390910181526064909101909252602082810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905281019190915281519192509082905f90611450576114506128b1565b60209081029190910101528a546040517fe30c1e1a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f81169263e30c1e1a926114d592919091169085906004016128de565b5f604051808303815f87803b1580156114ec575f5ffd5b505af11580156114fe573d5f5f3e3d5ffd5b505050505061152b565b895461152b9073ffffffffffffffffffffffffffffffffffffffff168883611f72565b8c73ffffffffffffffffffffffffffffffffffffffff168c73ffffffffffffffffffffffffffffffffffffffff168c7ff254e2593561a9aed8c322b7f727abcbd3a61b90dd79ee2db5ffb9149998bd988a856040516115ac92919073ffffffffffffffffffffffffffffffffffffffff929092168252602082015260400190565b60405180910390a4505050505050505050506115c760015f55565b505050565b60025f5403611607576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60025f55565b73ffffffffffffffffffffffffffffffffffffffff861661165a576040517fc1ab6dc100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff85166116a7576040517f8aa3a72f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b835f036116e0576040517fa76d0f8b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b825f03611719576040517f99515c6400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff861603611768576040517fe2918e9f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b828211156117a2576040517fc8761eed00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b428165ffffffffffff16116117e3576040517f952e22f900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b63039ada006117fa4265ffffffffffff841661289e565b1115611832576040517f1b73c9d500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61183c8484611ff3565b15611873576040517f7764768a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050565b80547a010000000000000000000000000000000000000000000000000000900460ff16156118d5576040517f9acb7e5200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b805474010000000000000000000000000000000000000000900465ffffffffffff16421115611930576040517f203d82d800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50565b6119786040518060a001604052805f81526020015f81526020015f81526020015f73ffffffffffffffffffffffffffffffffffffffff1681526020015f151581525090565b6004840154600285015473ffffffffffffffffffffffffffffffffffffffff9091169060ff166119a85780611a62565b84546040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff838116600483015291821660248201527f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f90911690638749eacc90604401602060405180830381865afa158015611a3e573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611a62919061283f565b73ffffffffffffffffffffffffffffffffffffffff16606083015250600584015460068501545f611a93838361289e565b905084811015611acf576040517f840f17b100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611ad9818761203e565b8085526005880154611af0945090925090506129e6565b604082015260038401548151611b069190612887565b602082015260069093015460408401511460808401525090919050565b8454600186015460408601518111159173ffffffffffffffffffffffffffffffffffffffff169082611b6557611b608233308a6020015188612053565b611e20565b6002880154610100900460ff1615611ba55760608701516020880151611b609173ffffffffffffffffffffffffffffffffffffffff8516913391906122ab565b611bb68233308a6020015188612053565b5f88600301548860400151611bcb9190612887565b90508415611d71576040805160018082528183019092525f91816020015b604080518082019091525f815260606020820152815260200190600190039081611be957505060408051808201825273ffffffffffffffffffffffffffffffffffffffff878116825260608d01518351911660248201526044808201879052835180830390910181526064909101909252602082810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fa9059cbb0000000000000000000000000000000000000000000000000000000017905281019190915281519192509082905f90611cbf57611cbf6128b1565b60209081029190910101526040517fe30c1e1a00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff7f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f169063e30c1e1a90611d3e90879085906004016128de565b5f604051808303815f87803b158015611d55575f5ffd5b505af1158015611d67573d5f5f3e3d5ffd5b5050505050611d98565b6060880151611d989073ffffffffffffffffffffffffffffffffffffffff85169083611f72565b6002890180547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790556040888101518151848152602081019190915273ffffffffffffffffffffffffffffffffffffffff89169188917f2176ad82842c18ffacc7dd574ef740019194587cb36d3eb52ead7e5d9c043725910160405180910390a3505b505095945050505050565b8351335f90815260016020908152604080832073ffffffffffffffffffffffffffffffffffffffff88168452825280832085845290915281208054909190611e749084906129e6565b909155505060408401516005860155608084015115611ed05760405173ffffffffffffffffffffffffffffffffffffffff84169082907f604944707ed6db53f4b45f2052524bb799f902b0864a71e69d83252b5fad8234905f90a35b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16827f31c608390612eea6cdd1ba98fe5c90f960aec88aceb233d7e3fd5e01ec36f1443389600301548960200151604051611f639392919073ffffffffffffffffffffffffffffffffffffffff9390931683526020830191909152604082015260600190565b60405180910390a45050505050565b60405173ffffffffffffffffffffffffffffffffffffffff8381166024830152604482018390526115c791859182169063a9059cbb906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506122f7565b5f821580611fff575081155b1561200b57505f6104a1565b612035827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff6129f9565b90921192915050565b5f81831061204c5781610fa6565b5090919050565b5f8161205f5783612115565b6040517f8749eacc00000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff858116600483015287811660248301527f0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f1690638749eacc90604401602060405180830381865afa1580156120f1573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190612115919061283f565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff80831660048301529192505f918816906370a0823190602401602060405180830381865afa158015612184573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906121a89190612a31565b90506121cc73ffffffffffffffffffffffffffffffffffffffff88168784876122ab565b6040517f70a0823100000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff83811660048301525f91908916906370a0823190602401602060405180830381865afa158015612239573d5f5f3e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061225d9190612a31565b90508461226a838361289e565b146122a1576040517f61f5187700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050505050505050565b60405173ffffffffffffffffffffffffffffffffffffffff84811660248301528381166044830152606482018390526122f19186918216906323b872dd90608401611fac565b50505050565b5f61231873ffffffffffffffffffffffffffffffffffffffff841683612390565b905080515f1415801561233c57508080602001905181019061233a9190612a48565b155b156115c7576040517f5274afe700000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff841660048201526024015b60405180910390fd5b6060610fa683835f845f5f8573ffffffffffffffffffffffffffffffffffffffff1684866040516123c19190612a63565b5f6040518083038185875af1925050503d805f81146123fb576040519150601f19603f3d011682016040523d82523d5f602084013e612400565b606091505b509150915061241086838361241a565b9695505050505050565b60608261242f5761242a826124a9565b610fa6565b8151158015612453575073ffffffffffffffffffffffffffffffffffffffff84163b155b156124a2576040517f9996b31500000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85166004820152602401612387565b5080610fa6565b8051156124b95780518082602001fd5b6040517f1425ea4200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b73ffffffffffffffffffffffffffffffffffffffff81168114611930575f5ffd5b5f5f6040838503121561251d575f5ffd5b8235612528816124eb565b91506020830135612538816124eb565b809150509250929050565b8015158114611930575f5ffd5b5f5f60408385031215612561575f5ffd5b823561256c816124eb565b9150602083013561253881612543565b5f5f6040838503121561258d575f5ffd5b8235612598816124eb565b946020939093013593505050565b5f5f5f5f5f5f5f5f5f6101208a8c0312156125bf575f5ffd5b8935985060208a01356125d1816124eb565b975060408a0135965060608a0135955060808a013565ffffffffffff811681146125f9575f5ffd5b945060a08a0135612609816124eb565b935060c08a013561261981612543565b925060e08a013591506101008a0135612631816124eb565b809150509295985092959850929598565b5f5f5f5f5f5f5f60e0888a031215612658575f5ffd5b8735612663816124eb565b96506020880135955060408801359450606088013593506080880135612688816124eb565b925060a0880135612698816124eb565b915060c08801356126a881612543565b8091505092959891949750929550565b5f5f5f5f608085870312156126cb575f5ffd5b84356126d6816124eb565b93506020850135925060408501356126ed816124eb565b915060608501356126fd81612543565b939692955090935050565b5f5f5f6060848603121561271a575f5ffd5b8335612725816124eb565b92506020840135612735816124eb565b929592945050506040919091013590565b815173ffffffffffffffffffffffffffffffffffffffff1681526101608101602083015161277e602084018265ffffffffffff169052565b506040830151612792604084018215159052565b506060830151606083015260808301516127b0608084018215159052565b5060a08301516127c460a084018215159052565b5060c083015160c083015260e08301516127f660e084018273ffffffffffffffffffffffffffffffffffffffff169052565b5061010083015161010083015261012083015161012083015261014083015161283861014084018273ffffffffffffffffffffffffffffffffffffffff169052565b5092915050565b5f6020828403121561284f575f5ffd5b8151610fa6816124eb565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b80820281158282048414176104a1576104a161285a565b818103818111156104a1576104a161285a565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b5f6040820173ffffffffffffffffffffffffffffffffffffffff851683526040602084015280845180835260608501915060608160051b8601019250602086015f5b828110156129d9577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa0878603018452815173ffffffffffffffffffffffffffffffffffffffff8151168652602081015190506040602087015280518060408801528060208301606089015e5f6060828901015260607fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f83011688010196505050602082019150602084019350600181019050612920565b5092979650505050505050565b808201808211156104a1576104a161285a565b5f82612a2c577f4e487b71000000000000000000000000000000000000000000000000000000005f52601260045260245ffd5b500490565b5f60208284031215612a41575f5ffd5b5051919050565b5f60208284031215612a58575f5ffd5b8151610fa681612543565b5f82518060208501845e5f92019182525091905056fea26469706673582212209706b82ab8df4b94c696f407133a1b213169db5632bfd45dabf1af8fbba2e93864736f6c634300081c0033

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

0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f

-----Decoded View---------------
Arg [0] : _counterfactualHolderFactory (address): 0x5bB7eC88cA80146FF47019079Cf0330532A1157F

-----Encoded View---------------
1 Constructor Arguments found :
Arg [0] : 0000000000000000000000005bb7ec88ca80146ff47019079cf0330532a1157f


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]

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